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_BUILTINS_BY_SLID
90	bool "Export built-in symbols to llexts via SLIDs"
91	help
92	  When enabled, symbols exported from the Zephyr kernel
93	  or application (via EXPORT_SYMBOL) are linked to LLEXTs
94	  via Symbol Link Identifiers (SLIDs) instead of name.
95
96	  Enabling this option provides a huge size reduction,
97	  makes the linking process faster and provides more
98	  confidentiality, as exported symbol names are dropped
99	  from the binary. However, it can make LLEXT debugging
100	  harder and prevents usage of 'llext_find_sym' to look
101	  up symbols from the built-in table by name. It also
102	  requires the LLEXTs to be post-processed after build.
103
104module = LLEXT
105module-str = llext
106source "subsys/logging/Kconfig.template.log_config"
107
108endif
109
110menu "Linkable loadable Extension Development Kit (EDK)"
111
112config LLEXT_EDK_NAME
113	string "Name for llext EDK (Extension Development Kit)"
114	default "llext-edk"
115	help
116	  Name will be used when generating the EDK file, as <name>.tar.xz.
117	  It will also be used, normalized, as the prefix for the variable
118	  stating EDK location, used on generated Makefile.cflags. For
119	  instance, the default name, "llext-edk", becomes LLEXT_EDK_INSTALL_DIR.
120
121config LLEXT_EDK_USERSPACE_ONLY
122	bool "Only generate the Userpace codepath on syscall stubs for the EDK"
123	help
124	  Syscall stubs can contain code that verifies if running code is at user
125	  or kernel space and route the call accordingly. If the EDK is expected
126	  to be used by userspace only extensions, this option will make EDK stubs
127	  not contain the routing code, and only generate the userspace one.
128
129endmenu
130