1# Copyright (c) 2023 Intel Corporation
2# SPDX-License-Identifier: Apache-2.0
3
4menuconfig LLEXT
5	bool "Linkable loadable extensions"
6	select CACHE_MANAGEMENT if DCACHE
7	select KERNEL_WHOLE_ARCHIVE
8	depends on !HARVARD
9	help
10	  Enable the linkable loadable extension subsystem
11
12if LLEXT
13
14choice LLEXT_BINARY_TYPE
15	prompt "Binary object type for llext"
16	default LLEXT_TYPE_ELF_OBJECT if ARM || ARM64
17	default LLEXT_TYPE_ELF_SHAREDLIB if XTENSA
18	default LLEXT_TYPE_ELF_RELOCATABLE if RISCV
19	help
20	  Object type for llext
21
22config LLEXT_TYPE_ELF_OBJECT
23	bool "Single object ELF file"
24	depends on !RISCV
25	help
26	  Build and expect object files as binary object type for the
27	  llext subsystem. A single compiler invocation is used to
28	  generate the object file. Currently not supported on RISC-V.
29
30config LLEXT_TYPE_ELF_RELOCATABLE
31	bool "Relocatable ELF file"
32	help
33	  Build and expect relocatable (partially linked) files as the
34	  binary object type for the llext subsystem. These object files
35	  are generated by the linker by combining multiple object files
36	  into a single one.
37
38config LLEXT_TYPE_ELF_SHAREDLIB
39	bool "Shared library ELF file"
40	help
41	  Build and expect shared libraries as binary object type for
42	  the llext subsystem. The usual linking process is used to
43	  generate the shared library from multiple object files.
44
45endchoice
46
47config LLEXT_HEAP_SIZE
48	int "llext heap memory size in kilobytes"
49	default 8
50	help
51	  Heap size in kilobytes available to llext for dynamic allocation
52
53config LLEXT_BUILD_PIC
54	bool "Use -fPIC when building LLEXT"
55	depends on XTENSA
56	default y if LLEXT_TYPE_ELF_SHAREDLIB
57	help
58	  By default LLEXT compilation is performed with -fno-pic -fno-pie compiler
59	  flags. Some platforms can benefit from using -fPIC instead, in which case
60	  most internal linking is performed by the linker at build time. Select "y"
61	  to make use of that advantage.
62
63config LLEXT_SHELL
64	bool "llext shell commands"
65	depends on SHELL
66	help
67	  Manage llext with shell commands for loading, unloading, and introspection
68
69config LLEXT_SHELL_MAX_SIZE
70	int "Maximum size of llext in bytes"
71	depends on LLEXT_SHELL
72	default 8192
73	help
74	  When loading llext with shell it is stored in a temporary buffer of this size
75
76config LLEXT_STORAGE_WRITABLE
77	bool "llext storage is writable"
78	default y if XTENSA
79	help
80	  Select if LLEXT storage is writable, i.e. if extensions are stored in
81	  RAM and can be modified in place
82
83config LLEXT_EXPORT_DEVICES
84	bool "Export all DT devices to llexts"
85	help
86	  When enabled, all Zephyr devices defined in the device tree are
87	  made available to llexts via the standard DT_ / DEVICE_* macros.
88
89config LLEXT_EXPORT_DEV_IDS_BY_HASH
90	bool "Use hash of device path in device name"
91	depends on LLEXT_EXPORT_DEVICES
92	help
93	  When enabled, exported device names are generated from a hash of the
94	  node path instead of an ordinal number. Identifiers generated this
95	  way are stable across rebuilds.
96
97config LLEXT_EXPORT_BUILTINS_BY_SLID
98	bool "Export built-in symbols to llexts via SLIDs"
99	help
100	  When enabled, symbols exported from the Zephyr kernel
101	  or application (via EXPORT_SYMBOL) are linked to LLEXTs
102	  via Symbol Link Identifiers (SLIDs) instead of name.
103
104	  Enabling this option provides a huge size reduction,
105	  makes the linking process faster and provides more
106	  confidentiality, as exported symbol names are dropped
107	  from the binary. However, it can make LLEXT debugging
108	  harder and prevents usage of 'llext_find_sym' to look
109	  up symbols from the built-in table by name. It also
110	  requires the LLEXTs to be post-processed after build.
111
112config LLEXT_IMPORT_ALL_GLOBALS
113	bool "Import all global symbols from extensions"
114	help
115	  When loading an extension, by default only symbols that are mentioned
116	  in the '.exported_sym' section (possibly via EXPORT_SYMBOL) are made
117	  available to the Zephyr core.
118
119	  This option instead allows all global symbols from extensions to be
120	  used by the main application. This is useful to load basic extensions
121	  that have been compiled without the full Zephyr EDK.
122
123module = LLEXT
124module-str = llext
125source "subsys/logging/Kconfig.template.log_config"
126
127endif
128
129menuconfig LLEXT_EDK
130	bool "Linkable loadable Extension Development Kit (EDK)"
131	default y if LLEXT
132	help
133	  Enable the generation of an Extension Development Kit (EDK) for the
134	  Linkable Loadable Extension subsystem. The EDK is an archive that
135	  contains the necessary files and build settings to build extensions
136	  for Zephyr without the need to have the full Zephyr source tree.
137
138if LLEXT_EDK
139
140config LLEXT_EDK_NAME
141	string "Name for llext EDK (Extension Development Kit)"
142	default "llext-edk"
143	help
144	  <name> will be used when generating the EDK file; the appropriate
145	  extension will be appended depending on the chosen output format.
146	  It will also be used, normalized, as the prefix for the variable
147	  stating EDK location, used on generated Makefile.cflags. For
148	  instance, the default name, "llext-edk", becomes LLEXT_EDK_INSTALL_DIR.
149
150choice LLEXT_EDK_FORMAT
151prompt "EDK compression and output format"
152default LLEXT_EDK_FORMAT_TAR_XZ
153
154config LLEXT_EDK_FORMAT_TAR_XZ
155	bool ".tar.xz"
156	help
157	  Use GNU tar with XZ compression for the EDK file. Highest compression
158	  ratio, slower choice.
159
160config LLEXT_EDK_FORMAT_TAR_ZSTD
161	bool ".tar.Z"
162	help
163	  Use GNU tar with Zstd compression for the EDK file. Way faster than
164	  XZ, but still with a high compression ratio.
165
166config LLEXT_EDK_FORMAT_ZIP
167	bool ".zip"
168	help
169	  Use Zip format and compression for the EDK file. This is the most
170	  portable option, but it may not compress as well as XZ or Zstd.
171
172endchoice
173
174config LLEXT_EDK_USERSPACE_ONLY
175	bool "Only generate the Userspace codepath on syscall stubs for the EDK"
176	help
177	  Syscall stubs can contain code that verifies if running code is at user
178	  or kernel space and route the call accordingly. If the EDK is expected
179	  to be used by userspace only extensions, this option will make EDK stubs
180	  not contain the routing code, and only generate the userspace one.
181
182endif
183