1# General architecture configuration options
2
3# Copyright (c) 2014-2015 Wind River Systems, Inc.
4# Copyright (c) 2015 Intel Corporation
5# Copyright (c) 2016 Cadence Design Systems, Inc.
6# SPDX-License-Identifier: Apache-2.0
7
8# Include these first so that any properties (e.g. defaults) below can be
9# overridden (by defining symbols in multiple locations)
10
11source "$(KCONFIG_BINARY_DIR)/arch/Kconfig"
12
13# ToDo: Generate a Kconfig.arch for loading of additional arch in HWMv2.
14osource "$(KCONFIG_BINARY_DIR)/Kconfig.arch"
15
16# Architecture symbols
17#
18# Should be 'select'ed by low-level symbols like SOC_SERIES_* or, lacking that,
19# by SOC_*.
20
21config ARC
22	bool
23	select ARCH_IS_SET
24	imply XIP
25	select ARCH_HAS_THREAD_LOCAL_STORAGE
26	select ARCH_SUPPORTS_ROM_START
27	select ARCH_HAS_DIRECTED_IPIS
28	help
29	  ARC architecture
30
31config ARM
32	bool
33	select ARCH_IS_SET
34	select ARCH_SUPPORTS_COREDUMP if CPU_CORTEX_M
35	select ARCH_SUPPORTS_COREDUMP_THREADS if CPU_CORTEX_M
36	select ARCH_SUPPORTS_COREDUMP_STACK_PTR if CPU_CORTEX_M
37	# FIXME: current state of the code for all ARM requires this, but
38	# is really only necessary for Cortex-M with ARM MPU!
39	select GEN_PRIV_STACKS
40	select ARCH_HAS_THREAD_LOCAL_STORAGE if CPU_AARCH32_CORTEX_R || CPU_CORTEX_M || CPU_AARCH32_CORTEX_A
41	select BARRIER_OPERATIONS_ARCH
42	help
43	  ARM architecture
44
45config ARM64
46	bool
47	select ARCH_IS_SET
48	select 64BIT
49	select ARCH_SUPPORTS_COREDUMP
50	select HAS_ARM_SMCCC
51	select ARCH_HAS_THREAD_LOCAL_STORAGE
52	select USE_SWITCH
53	select USE_SWITCH_SUPPORTED
54	select BARRIER_OPERATIONS_ARCH
55	select ARCH_HAS_DIRECTED_IPIS
56	select ARCH_HAS_DEMAND_PAGING
57	select ARCH_HAS_DEMAND_MAPPING
58	select ARCH_SUPPORTS_EVICTION_TRACKING
59	select EVICTION_TRACKING if DEMAND_PAGING
60	help
61	  ARM64 (AArch64) architecture
62
63config MIPS
64	bool
65	select ARCH_IS_SET
66	select ATOMIC_OPERATIONS_C
67	help
68	  MIPS architecture
69
70config SPARC
71	bool
72	select ARCH_IS_SET
73	select USE_SWITCH
74	select USE_SWITCH_SUPPORTED
75	select BIG_ENDIAN
76	select ATOMIC_OPERATIONS_BUILTIN if SPARC_CASA
77	select ATOMIC_OPERATIONS_C if !SPARC_CASA
78	select ARCH_HAS_THREAD_LOCAL_STORAGE
79	select ARCH_HAS_EXTRA_EXCEPTION_INFO
80	help
81	  SPARC architecture
82
83config X86
84	bool
85	select ARCH_IS_SET
86	select ATOMIC_OPERATIONS_BUILTIN
87	select ARCH_SUPPORTS_COREDUMP
88	select ARCH_SUPPORTS_COREDUMP_PRIV_STACKS
89	select ARCH_SUPPORTS_ROM_START if !X86_64
90	select CPU_HAS_MMU
91	select ARCH_MEM_DOMAIN_DATA if USERSPACE && !X86_COMMON_PAGE_TABLE
92	select ARCH_MEM_DOMAIN_SYNCHRONOUS_API if USERSPACE
93	select ARCH_HAS_GDBSTUB if !X86_64
94	select ARCH_HAS_TIMING_FUNCTIONS
95	select ARCH_HAS_THREAD_LOCAL_STORAGE
96	select ARCH_HAS_DEMAND_PAGING if !X86_64
97	select ARCH_HAS_DEMAND_MAPPING if ARCH_HAS_DEMAND_PAGING
98	select NEED_LIBC_MEM_PARTITION if USERSPACE && TIMING_FUNCTIONS \
99					  && !BOARD_HAS_TIMING_FUNCTIONS \
100					  && !SOC_HAS_TIMING_FUNCTIONS
101	select ARCH_HAS_STACK_CANARIES_TLS
102	select ARCH_SUPPORTS_MEM_MAPPED_STACKS if X86_MMU && !DEMAND_PAGING
103	select ARCH_HAS_THREAD_PRIV_STACK_SPACE_GET if USERSPACE
104	help
105	  x86 architecture
106
107config RISCV
108	bool
109	select ARCH_IS_SET
110	select ATOMIC_OPERATIONS_C if !RISCV_ISA_EXT_A
111	select ATOMIC_OPERATIONS_BUILTIN if RISCV_ISA_EXT_A
112	select ARCH_SUPPORTS_COREDUMP
113	select ARCH_SUPPORTS_COREDUMP_PRIV_STACKS
114	select ARCH_SUPPORTS_ROM_START if !SOC_FAMILY_ESPRESSIF_ESP32
115	select ARCH_SUPPORTS_EMPTY_IRQ_SPURIOUS
116	select ARCH_HAS_CODE_DATA_RELOCATION
117	select ARCH_HAS_THREAD_LOCAL_STORAGE
118	select USE_SWITCH_SUPPORTED
119	select USE_SWITCH
120	select SCHED_IPI_SUPPORTED if SMP
121	select ARCH_HAS_DIRECTED_IPIS
122	select BARRIER_OPERATIONS_BUILTIN
123	select ARCH_HAS_THREAD_PRIV_STACK_SPACE_GET if USERSPACE
124	help
125	  RISCV architecture
126
127config XTENSA
128	bool
129	select ARCH_IS_SET
130	select USE_SWITCH
131	select USE_SWITCH_SUPPORTED
132	select ARCH_HAS_CODE_DATA_RELOCATION
133	select ARCH_HAS_TIMING_FUNCTIONS
134	select ARCH_MEM_DOMAIN_DATA if USERSPACE
135	select ARCH_HAS_DIRECTED_IPIS
136	select THREAD_STACK_INFO
137	select ARCH_HAS_THREAD_PRIV_STACK_SPACE_GET if USERSPACE
138	help
139	  Xtensa architecture
140
141config ARCH_POSIX
142	bool
143	select ARCH_IS_SET
144	select ATOMIC_OPERATIONS_BUILTIN
145	select ARCH_HAS_CUSTOM_SWAP_TO_MAIN
146	select ARCH_HAS_CUSTOM_BUSY_WAIT
147	select ARCH_HAS_THREAD_ABORT
148	select ARCH_HAS_THREAD_NAME_HOOK
149	select NATIVE_BUILD
150	select HAS_COVERAGE_SUPPORT
151	select BARRIER_OPERATIONS_BUILTIN
152	# POSIX arch based targets get their memory cleared on entry by the host OS
153	select SKIP_BSS_CLEAR
154	# Override the C standard used for compilation to C 2011
155	# This is due to some tests using _Static_assert which is a 2011 feature, but
156	# otherwise relying on compilers supporting it also when set to C99.
157	# This was in general ok, but with some host compilers and C library versions
158	# it led to problems. So we override it to 2011 for the native targets.
159	select REQUIRES_STD_C11
160	help
161	  POSIX (native) architecture
162
163config RX
164	bool
165	select ARCH_IS_SET
166	select ATOMIC_OPERATIONS_C
167	select USE_SWITCH
168	select USE_SWITCH_SUPPORTED
169	help
170	  Renesas RX architecture
171
172config ARCH_IS_SET
173	bool
174	help
175	  Helper symbol to detect SoCs forgetting to select one of the arch
176	  symbols above. See the top-level CMakeLists.txt.
177
178menu "General Architecture Options"
179
180source "arch/common/Kconfig"
181
182module = ARCH
183module-str = arch
184source "subsys/logging/Kconfig.template.log_config"
185
186config BIG_ENDIAN
187	bool
188	help
189	  This option tells the build system that the target system is big-endian.
190	  Little-endian architecture is the default and should leave this option
191	  unselected.  This option is selected by arch/$ARCH/Kconfig,
192	  soc/**/Kconfig, or boards/**/Kconfig and the user should generally avoid
193	  modifying it.  The option is used to select linker script OUTPUT_FORMAT,
194	  the toolchain flags (TOOLCHAIN_C_FLAGS, TOOLCHAIN_LD_FLAGS), and command
195	  line option for gen_isr_tables.py.
196
197config LITTLE_ENDIAN
198	# Hidden Kconfig option representing the default little-endian architecture
199	# This is just the opposite of BIG_ENDIAN and is used for non-negative
200	# conditional compilation
201	bool
202	depends on !BIG_ENDIAN
203	default y
204
205config 64BIT
206	bool
207	help
208	  This option tells the build system that the target system is
209	  using a 64-bit address space, meaning that pointer and long types
210	  are 64 bits wide. This option is selected by arch/$ARCH/Kconfig,
211	  soc/**/Kconfig, or boards/**/Kconfig and the user should generally
212	  avoid modifying it.
213
214# Workaround for not being able to have commas in macro arguments
215DT_CHOSEN_Z_SRAM := zephyr,sram
216
217config SRAM_SIZE
218	int "SRAM Size in kB"
219	default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K)
220	help
221	  The SRAM size in kB. The default value comes from /chosen/zephyr,sram in
222	  devicetree. The user should generally avoid changing it via menuconfig or
223	  in configuration files.
224
225config SRAM_BASE_ADDRESS
226	hex "SRAM Base Address"
227	default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_SRAM))
228	help
229	  The SRAM base address. The default value comes from
230	  /chosen/zephyr,sram in devicetree. The user should generally avoid
231	  changing it via menuconfig or in configuration files.
232
233if ARC || ARM || ARM64 || X86 || RISCV || RX
234
235# Workaround for not being able to have commas in macro arguments
236DT_CHOSEN_Z_FLASH := zephyr,flash
237
238config FLASH_SIZE
239	int "Flash Size in kB"
240	default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_FLASH),0,K) if (XIP && (ARM ||ARM64)) || !ARM
241	default 0 if !XIP
242	help
243	  This option specifies the size of the flash in kB.  It is normally set by
244	  the board's defconfig file and the user should generally avoid modifying
245	  it via the menu configuration.
246
247config FLASH_BASE_ADDRESS
248	hex "Flash Base Address"
249	default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_FLASH)) if (XIP && (ARM || ARM64)) || !ARM
250	default 0 if !XIP
251	help
252	  This option specifies the base address of the flash on the board. It is
253	  normally set by the board's defconfig file and the user should generally
254	  avoid modifying it via the menu configuration.
255
256endif # ARM || ARM64 || ARC || X86 || RISCV || RX
257
258if ARCH_HAS_TRUSTED_EXECUTION
259
260config TRUSTED_EXECUTION_SECURE
261	bool "Trusted Execution: Secure firmware image"
262	help
263	  Select this option to enable building a Secure firmware
264	  image for a platform that supports Trusted Execution. A
265	  Secure firmware image will execute in Secure state. It may
266	  allow the CPU to execute in Non-Secure (Normal) state.
267	  Therefore, a Secure firmware image shall be able to
268	  configure security attributions of CPU resources (memory
269	  areas, peripherals, interrupts, etc.) as well as to handle
270	  faults, related to security violations. It may optionally
271	  allow certain functions to be called from the Non-Secure
272	  (Normal) domain.
273
274config TRUSTED_EXECUTION_NONSECURE
275	depends on !TRUSTED_EXECUTION_SECURE
276	bool "Trusted Execution: Non-Secure firmware image"
277	help
278	  Select this option to enable building a Non-Secure
279	  firmware image for a platform that supports Trusted
280	  Execution. A Non-Secure firmware image will execute
281	  in Non-Secure (Normal) state. Therefore, it shall not
282	  access CPU resources (memory areas, peripherals,
283	  interrupts etc.) belonging to the Secure domain.
284
285endif # ARCH_HAS_TRUSTED_EXECUTION
286
287config HW_STACK_PROTECTION
288	bool "Hardware Stack Protection"
289	depends on ARCH_HAS_STACK_PROTECTION
290	help
291	  Select this option to enable hardware-based platform features to
292	  catch stack overflows when the system is running in privileged
293	  mode. If CONFIG_USERSPACE is not enabled, the system is always
294	  running in privileged mode.
295
296	  Note that this does not necessarily prevent corruption and assertions
297	  about the overall system state when a fault is triggered cannot be
298	  made.
299
300config USERSPACE
301	bool "User mode threads"
302	depends on ARCH_HAS_USERSPACE
303	depends on RUNTIME_ERROR_CHECKS
304	depends on SRAM_REGION_PERMISSIONS
305	select THREAD_STACK_INFO
306	select LINKER_USE_NO_RELAX
307	help
308	  When enabled, threads may be created or dropped down to user mode,
309	  which has significantly restricted permissions and must interact
310	  with the kernel via system calls. See Zephyr documentation for more
311	  details about this feature.
312
313	  If a user thread overflows its stack, this will be caught and the
314	  kernel itself will be shielded from harm. Enabling this option
315	  may or may not catch stack overflows when the system is in
316	  privileged mode or handling a system call; to ensure these are always
317	  caught, enable CONFIG_HW_STACK_PROTECTION.
318
319config NOINIT_SNIPPET_FIRST
320	bool "Place the no-init linker script snippet first"
321	help
322	  By default the include/zephyr/linker/common-noinit.ld file inserts the
323	  snippets-noinit.ld file at the end of the section.  There are times when
324	  the directives in the snippets-noinit.ld file apply to the other directives
325	  in this file.  And in that case the include statement for the snippets-noinit.ld
326	  file needs to come at the start of the section.  This configuration option
327	  allows that to happen.
328
329config PRIVILEGED_STACK_SIZE
330	int "Size of privileged stack"
331	default 2048 if EMUL
332	default 1024
333	depends on USERSPACE
334	help
335	  This option sets the privileged stack region size that will be used
336	  in addition to the user mode thread stack.  During normal execution,
337	  this region will be inaccessible from user mode.  During system calls,
338	  this region will be utilized by the system call. This value must be
339	  a multiple of the minimum stack alignment.
340
341config KOBJECT_TEXT_AREA
342	int "Size of kobject text area"
343	default 1024 if UBSAN
344	default 512 if COVERAGE_GCOV
345	default 512 if NO_OPTIMIZATIONS
346	default 512 if STACK_CANARIES && RISCV
347	default 256
348	depends on USERSPACE
349	help
350	  Size of kernel object text area. Used in linker script.
351
352config KOBJECT_DATA_AREA_RESERVE_EXTRA_PERCENT
353	int "Reserve extra kobject data area (in percentage)"
354	default 100
355	depends on USERSPACE
356	help
357	  Multiplication factor used to calculate the size of placeholder to
358	  reserve space for kobject metadata hash table. The hash table is
359	  generated via gperf is highly dependent on the absolute addresses of
360	  kobjects which might change between prebuilts. To reserve enough
361	  space for the hash table during final linking passes to keep
362	  kobjects in same place, the size of reserved space is calculated
363	  from the first prebuilt plus additional space calculated with
364	  this percentage (of the kobject data area in first prebuilt).
365
366config KOBJECT_RODATA_AREA_EXTRA_BYTES
367	int "Reserve extra bytes for kobject rodata area"
368	default 16
369	depends on USERSPACE
370	help
371	  Reserve a few more bytes for the RODATA region for kobject metadata.
372	  This is to account for the uncertainty of tables generated by gperf.
373
374config GEN_PRIV_STACKS
375	bool
376	help
377	  Selected if the architecture requires that privilege elevation stacks
378	  be allocated in a separate memory area. This is typical of arches
379	  whose MPUs require regions to be power-of-two aligned/sized.
380
381	  FIXME: This should be removed and replaced with checks against
382	  CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT, but both ARM and ARC
383	  changes will be necessary for this.
384
385config STACK_GROWS_UP
386	bool "Stack grows towards higher memory addresses"
387	help
388	  Select this option if the architecture has upward growing thread
389	  stacks. This is not common.
390
391config NO_UNUSED_STACK_INSPECTION
392	bool
393	help
394	  Selected if the architecture will generate a fault if unused stack
395	  memory is examined, which is the region between the current stack
396	  pointer and the deepest available address in the current stack
397	  region.
398
399config MAX_THREAD_BYTES
400	int "Bytes to use when tracking object thread permissions"
401	default 2
402	depends on USERSPACE
403	help
404	  Every kernel object will have an associated bitfield to store
405	  thread permissions for that object. This controls the size of the
406	  bitfield (in bytes) and imposes a limit on how many threads can
407	  be created in the system.
408
409config DYNAMIC_OBJECTS
410	bool "Allow kernel objects to be allocated at runtime"
411	depends on USERSPACE
412	help
413	  Enabling this option allows for kernel objects to be requested from
414	  the calling thread's resource pool, at a slight cost in performance
415	  due to the supplemental run-time tables required to validate such
416	  objects.
417
418	  Objects allocated in this way can be freed with a supervisor-only
419	  API call, or when the number of references to that object drops to
420	  zero.
421
422config NOCACHE_MEMORY
423	bool "Support for uncached memory"
424	depends on ARCH_HAS_NOCACHE_MEMORY_SUPPORT
425	help
426	  Add a "nocache" read-write memory section that is configured to
427	  not be cached. This memory section can be used to perform DMA
428	  transfers when cache coherence issues are not optimal or can not
429	  be solved using cache maintenance operations.
430
431config FRAME_POINTER
432	bool "Compile the kernel with frame pointers"
433	select OVERRIDE_FRAME_POINTER_DEFAULT
434	help
435	  Select Y here to gain precise stack traces at the expense of slightly
436	  increased size and decreased speed.
437
438config ARCH_STACKWALK
439	bool "Compile the stack walking function"
440	default y
441	depends on ARCH_HAS_STACKWALK
442	help
443	  Select Y here to compile the `arch_stack_walk()` function
444
445config ARCH_STACKWALK_MAX_FRAMES
446	int "Max depth for stack walk function"
447	default 8
448	depends on ARCH_STACKWALK
449	help
450	  Depending on implementation, this can place a hard limit on the depths of the stack
451	  for the stack walk function to examine.
452
453menu "Interrupt Configuration"
454
455config TOOLCHAIN_SUPPORTS_ISR_TABLES_LOCAL_DECLARATION
456	bool
457	help
458	  Hidden option to signal that toolchain supports local declaration of
459	  interrupt tables.
460
461config ISR_TABLES_LOCAL_DECLARATION_SUPPORTED
462	bool
463	default y
464	# Userspace is currently not supported
465	depends on !USERSPACE
466	# List of currently supported architectures
467	depends on ARM || ARM64 || RISCV
468	# List of currently supported toolchains
469	depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "zephyr" || "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "gnuarmemb" || "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "llvm" || TOOLCHAIN_SUPPORTS_ISR_TABLES_LOCAL_DECLARATION
470
471config ISR_TABLES_LOCAL_DECLARATION
472	bool "ISR tables created locally and placed by linker"
473	depends on ISR_TABLES_LOCAL_DECLARATION_SUPPORTED
474	help
475	  Enable new scheme of interrupt tables generation.
476	  This is totally different generator that would create tables entries locally
477	  where the IRQ_CONNECT macro is called and then use the linker script to position it
478	  in the right place in memory.
479	  The most important advantage of such approach is that the generated interrupt tables
480	  are LTO compatible.
481	  The drawback is that the support on the architecture port is required.
482
483config DYNAMIC_INTERRUPTS
484	bool "Installation of IRQs at runtime"
485	select SRAM_SW_ISR_TABLE
486	help
487	  Enable installation of interrupts at runtime, which will move some
488	  interrupt-related data structures to RAM instead of ROM, and
489	  on some architectures increase code size.
490
491config SHARED_INTERRUPTS
492	bool "Set this to enable support for shared interrupts"
493	depends on GEN_SW_ISR_TABLE
494	select EXPERIMENTAL
495	help
496	  Set this to enable support for shared interrupts. Use this with
497	  caution as enabling this will increase the image size by a
498	  non-negligible amount.
499
500config SHARED_IRQ_MAX_NUM_CLIENTS
501	int "Maximum number of clients allowed per shared interrupt"
502	default 2
503	depends on SHARED_INTERRUPTS
504	help
505	  This option controls the maximum number of clients allowed
506	  per shared interrupt. Set this according to your needs.
507
508config GEN_ISR_TABLES
509	bool "Use generated IRQ tables"
510	help
511	  This option controls whether a platform uses the gen_isr_tables
512	  script to generate its interrupt tables. This mechanism will create
513	  an appropriate hardware vector table and/or software IRQ table.
514
515config GEN_IRQ_VECTOR_TABLE
516	bool "Generate an interrupt vector table"
517	default y
518	depends on GEN_ISR_TABLES
519	help
520	  This option controls whether a platform using gen_isr_tables
521	  needs an interrupt vector table created. Only disable this if the
522	  platform does not use a vector table at all, or requires the vector
523	  table to be in a format that is not an array of function pointers
524	  indexed by IRQ line. In the latter case, the vector table must be
525	  supplied by the application or architecture code.
526
527config ARCH_IRQ_VECTOR_TABLE_ALIGN
528	int "Alignment size of the interrupt vector table"
529	default 4
530	depends on GEN_IRQ_VECTOR_TABLE
531	help
532	  This option controls alignment size of generated
533	  _irq_vector_table.  Some architecture needs an IRQ vector table
534	  to be aligned to architecture specific size.  The default
535	  size is 0 for no alignment.
536
537config ARCH_DEVICE_STATE_ALIGN
538	int "Alignment size of device state"
539	default 4
540	help
541	  This option controls alignment size of device state.
542
543choice IRQ_VECTOR_TABLE_TYPE
544	prompt "IRQ vector table type"
545	depends on GEN_IRQ_VECTOR_TABLE
546	default IRQ_VECTOR_TABLE_JUMP_BY_CODE if (RISCV && !RISCV_HAS_CLIC)
547	default IRQ_VECTOR_TABLE_JUMP_BY_ADDRESS
548
549config IRQ_VECTOR_TABLE_JUMP_BY_ADDRESS
550	bool "Jump by address"
551	help
552	  The IRQ vector table contains the address of the interrupt handler.
553
554config IRQ_VECTOR_TABLE_JUMP_BY_CODE
555	bool "Jump by code"
556	help
557	  The IRQ vector table contains the opcode of a jump instruction to the
558	  interrupt handler address.
559
560endchoice
561
562config GEN_SW_ISR_TABLE
563	bool "Generate a software ISR table"
564	default y
565	depends on GEN_ISR_TABLES
566	help
567	  This option controls whether a platform using gen_isr_tables
568	  needs a software ISR table table created. This is an array of struct
569	  _isr_table_entry containing the interrupt service routine and supplied
570	  parameter.
571
572config ARCH_SW_ISR_TABLE_ALIGN
573	int "Alignment size of a software ISR table"
574	default 64 if RISCV_HAS_CLIC
575	default 4
576	depends on GEN_SW_ISR_TABLE
577	help
578	  This option controls alignment size of generated
579	  _sw_isr_table.  Some architecture needs a software ISR table
580	  to be aligned to architecture specific size.  The default
581	  size is 4.
582
583config GEN_IRQ_START_VECTOR
584	int
585	default 0
586	depends on GEN_ISR_TABLES
587	help
588	  On some architectures, part of the vector table may be reserved for
589	  system exceptions and is declared separately from the tables
590	  created by gen_isr_tables.py. When creating these tables, this value
591	  will be subtracted from CONFIG_NUM_IRQS to properly size them.
592	  This is a hidden option which needs to be set per architecture and
593	  left alone.
594
595config IRQ_OFFLOAD
596	bool "IRQ offload"
597	depends on TEST
598	help
599	  Enable irq_offload() API which allows functions to be synchronously
600	  run in interrupt context. Only useful for test cases that need
601	  to validate the correctness of kernel objects in IRQ context.
602
603config SRAM_VECTOR_TABLE
604	bool "Place the vector table in SRAM instead of flash"
605	depends on ARCH_HAS_VECTOR_TABLE_RELOCATION
606	depends on XIP
607	depends on !ROMSTART_RELOCATION_ROM
608	help
609	  When XiP is enabled, this option will result in the vector table being
610	  relocated from Flash to SRAM.
611
612config SRAM_SW_ISR_TABLE
613	bool "Place the software ISR table in SRAM instead of flash"
614	help
615	  The option specifies that the software interrupts vector table will be
616	  placed inside SRAM instead of the flash.
617
618config IRQ_OFFLOAD_NESTED
619	bool "irq_offload() supports nested IRQs"
620	depends on IRQ_OFFLOAD
621	default y if ARM64 || X86 || RISCV || XTENSA
622	help
623	  When set by the platform layers, indicates that
624	  irq_offload() may legally be called in interrupt context to
625	  cause a synchronous nested interrupt on the current CPU.
626	  Not all hardware is capable.
627
628config EXCEPTION_DEBUG
629	bool "Unhandled exception debugging"
630	default y
631	depends on PRINTK || LOG
632	help
633	  Install handlers for various CPU exception/trap vectors to
634	  make debugging them easier, at a small expense in code size.
635	  This prints out the specific exception vector and any associated
636	  error codes.
637
638config EXTRA_EXCEPTION_INFO
639	bool "Collect extra exception info"
640	depends on ARCH_HAS_EXTRA_EXCEPTION_INFO
641	help
642	  This option enables the collection of extra information, such as
643	  register state, when a fault occurs. This information can be useful
644	  to collect for post-mortem analysis and debug of issues.
645
646config SIMPLIFIED_EXCEPTION_CODES
647	bool "Convert arch specific exception codes to K_ERR_CPU_EXCEPTION"
648	default y if ZTEST
649	help
650	  The same piece of faulty code (NULL dereference, etc) can result in
651	  a multitude of potential exception codes at the CPU level, depending
652	  upon whether addresses exist, an MPU is configured, the particular
653	  implementation of the CPU or any number of other reasons. Enabling
654	  this option collapses all the architecture specific exception codes
655	  down to the generic K_ERR_CPU_EXCEPTION, which makes testing code
656	  much more portable.
657
658config EMPTY_IRQ_SPURIOUS
659	bool "Create empty spurious interrupt handler"
660	depends on ARCH_SUPPORTS_EMPTY_IRQ_SPURIOUS
661	help
662	  This option changes body of spurious interrupt handler. When enabled,
663	  handler contains only an infinite while loop, when disabled, handler
664	  contains the whole Zephyr fault handling procedure.
665
666endmenu # Interrupt configuration
667
668config INIT_ARCH_HW_AT_BOOT
669	bool "Initialize internal architecture state at boot"
670	depends on ARCH_SUPPORTS_ARCH_HW_INIT
671	help
672	  This option instructs Zephyr to force the initialization
673	  of the internal architectural state (for example ARCH-level
674	  HW registers and system control blocks) during boot to
675	  the reset values as specified by the corresponding
676	  architecture manual. The option is useful when the Zephyr
677	  firmware image is chain-loaded, for example, by a debugger
678	  or a bootloader, and we need to guarantee that the internal
679	  states of the architecture core blocks are restored to the
680	  reset values (as specified by the architecture).
681
682	  Note: the functionality is architecture-specific. For the
683	  implementation details refer to each architecture where
684	  this feature is supported.
685
686endmenu
687
688#
689# Architecture Capabilities
690#
691
692config ARCH_HAS_SINGLE_THREAD_SUPPORT
693	bool
694
695config ARCH_HAS_TIMING_FUNCTIONS
696	bool
697
698config ARCH_HAS_TRUSTED_EXECUTION
699	bool
700
701config ARCH_HAS_STACK_PROTECTION
702	bool
703
704config ARCH_HAS_USERSPACE
705	bool
706
707config ARCH_HAS_EXECUTABLE_PAGE_BIT
708	bool
709
710config ARCH_HAS_NOCACHE_MEMORY_SUPPORT
711	bool
712
713config ARCH_HAS_RAMFUNC_SUPPORT
714	bool
715
716config ARCH_HAS_VECTOR_TABLE_RELOCATION
717	bool
718
719config ARCH_HAS_NESTED_EXCEPTION_DETECTION
720	bool
721
722config ARCH_SUPPORTS_COREDUMP
723	bool
724
725config ARCH_SUPPORTS_COREDUMP_THREADS
726	bool
727
728config ARCH_SUPPORTS_COREDUMP_PRIV_STACKS
729	bool
730
731config ARCH_SUPPORTS_COREDUMP_STACK_PTR
732	bool
733
734config ARCH_SUPPORTS_ARCH_HW_INIT
735	bool
736
737config ARCH_SUPPORTS_ROM_START
738	bool
739
740config ARCH_SUPPORTS_EMPTY_IRQ_SPURIOUS
741	bool
742
743config ARCH_SUPPORTS_EVICTION_TRACKING
744	bool
745	help
746	  Architecture code supports page tracking for eviction algorithms
747	  when demand paging is enabled.
748
749config ARCH_HAS_EXTRA_EXCEPTION_INFO
750	bool
751
752config ARCH_HAS_GDBSTUB
753	bool
754
755config ARCH_HAS_COHERENCE
756	bool
757	help
758	  When selected, the architecture supports the
759	  arch_mem_coherent() API and can link into incoherent/cached
760	  memory using the ".cached" linker section.
761
762config ARCH_HAS_THREAD_LOCAL_STORAGE
763	bool
764
765config ARCH_HAS_SUSPEND_TO_RAM
766	bool
767	help
768	  When selected, the architecture supports suspend-to-RAM (S2RAM).
769
770config ARCH_HAS_STACK_CANARIES_TLS
771	bool
772
773config ARCH_SUPPORTS_MEM_MAPPED_STACKS
774	bool
775	help
776	  Select when the architecture supports memory mapped stacks.
777
778config ARCH_HAS_THREAD_PRIV_STACK_SPACE_GET
779	bool
780	help
781	  Select when the architecture implements arch_thread_priv_stack_space_get().
782
783#
784# Other architecture related options
785#
786
787config ARCH_HAS_THREAD_ABORT
788	bool
789
790config ARCH_HAS_CODE_DATA_RELOCATION
791	bool
792	help
793	  When selected, the architecture/SoC implements support for
794	  CODE_DATA_RELOCATION in its linker scripts.
795
796#
797# Hidden CPU family configs
798#
799
800config CPU_HAS_TEE
801	bool
802	help
803	  This option is enabled when the CPU has support for Trusted
804	  Execution Environment (e.g. when it has a security attribution
805	  unit).
806
807config CPU_HAS_DCLS
808	bool
809	help
810	  This option is enabled when the processor hardware has support for
811	  Dual-redundant Core Lock-step (DCLS) topology.
812
813config CPU_HAS_FPU
814	bool
815	help
816	  This option is enabled when the CPU has hardware floating point
817	  unit.
818
819config CPU_HAS_DSP
820	bool
821	help
822	  This option is enabled when the CPU has hardware DSP unit.
823
824config CPU_HAS_FPU_DOUBLE_PRECISION
825	bool
826	select CPU_HAS_FPU
827	help
828	  When enabled, this indicates that the CPU has a double floating point
829	  precision unit.
830
831config CPU_HAS_MPU
832	bool
833	help
834	  This option is enabled when the CPU has a Memory Protection Unit (MPU).
835
836config CPU_HAS_MMU
837	bool
838	help
839	  This hidden option is selected when the CPU has a Memory Management Unit
840	  (MMU).
841
842config ARCH_HAS_DEMAND_PAGING
843	bool
844	help
845	  This hidden configuration should be selected by the architecture if
846	  demand paging is supported.
847
848config ARCH_HAS_DEMAND_MAPPING
849	bool
850	help
851	  This hidden configuration should be selected by the architecture if
852	  demand paging is supported and arch_mem_map() supports
853	  K_MEM_MAP_UNPAGED.
854
855config ARCH_HAS_RESERVED_PAGE_FRAMES
856	bool
857	help
858	  This hidden configuration should be selected by the architecture if
859	  certain RAM page frames need to be marked as reserved and never used for
860	  memory mappings. The architecture will need to implement
861	  arch_reserved_pages_update().
862
863config ARCH_HAS_DIRECTED_IPIS
864	bool
865	help
866	  This hidden configuration should be selected by the architecture if
867	  it has an implementation for arch_sched_directed_ipi() which allows
868	  for IPIs to be directed to specific CPUs.
869
870config CPU_HAS_DCACHE
871	bool
872	help
873	  This hidden configuration should be selected when the CPU has a d-cache.
874
875config CPU_CACHE_INCOHERENT
876	bool
877	help
878	  This hidden configuration should be selected when the CPU has
879	  incoherent cache. This applies to intra-CPU multiprocessing
880	  incoherence and makes only sense when MP_MAX_NUM_CPUS > 1.
881
882config CPU_HAS_ICACHE
883	bool
884	help
885	  This hidden configuration should be selected when the CPU has an i-cache.
886
887config ARCH_MAPS_ALL_RAM
888	bool
889	help
890	  This hidden option is selected by the architecture to inform the kernel
891	  that all RAM is mapped at boot, and not just the bounds of the Zephyr image.
892	  If RAM starts at 0x0, the first page must remain un-mapped to catch NULL
893	  pointer dereferences. With this enabled, the kernel will not assume that
894	  virtual memory addresses past the kernel image are available for mappings,
895	  but instead takes into account an entire RAM mapping instead.
896
897	  This is typically set by architectures which need direct access to all memory.
898	  It is the architecture's responsibility to mark reserved memory regions
899	  as such in arch_reserved_pages_update().
900
901	  Although the kernel will not disturb this RAM mapping by re-mapping the associated
902	  virtual addresses elsewhere, this is limited to only management of the
903	  virtual address space. The kernel's page frame ontology will not consider
904	  this mapping at all; non-kernel pages will be considered free (unless marked
905	  as reserved) and K_MEM_PAGE_FRAME_MAPPED will not be set.
906
907config DCLS
908	bool "Processor is configured in DCLS mode"
909	depends on CPU_HAS_DCLS
910	default y
911	help
912	  This option is enabled when the processor hardware is configured in
913	  Dual-redundant Core Lock-step (DCLS) topology. For the processor that
914	  supports DCLS, but is configured in split-lock mode (by default or
915	  changed at flash time), this option should be disabled.
916
917menuconfig MPU
918	bool "MPU features"
919	depends on CPU_HAS_MPU
920	help
921	  This option, when enabled, indicates to the core kernel that an MPU
922	  is enabled.
923
924if MPU
925module = MPU
926module-str = mpu
927source "subsys/logging/Kconfig.template.log_config"
928
929config MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT
930	bool
931	help
932	  This option is enabled when the MPU requires a power of two alignment
933	  and size for MPU regions.
934
935config MPU_REQUIRES_NON_OVERLAPPING_REGIONS
936	bool
937	help
938	  This option is enabled when the MPU requires the active (i.e. enabled)
939	  MPU regions to be non-overlapping with each other.
940
941config MPU_GAP_FILLING
942	bool "Force MPU to be filling in background memory regions"
943	depends on MPU_REQUIRES_NON_OVERLAPPING_REGIONS
944	default y if !USERSPACE
945	help
946	  This Kconfig option instructs the MPU driver to enforce
947	  a full kernel SRAM partitioning, when it programs the
948	  dynamic MPU regions (user thread stack, PRIV stack guard
949	  and application memory domains) during context-switch. We
950	  allow this to be a configurable option, in order to be able
951	  to switch the option off and have an increased number of MPU
952	  regions available for application memory domain programming.
953
954	  Notes:
955	  An increased number of MPU regions should only be required,
956	  when building with USERSPACE support. As a result, when we
957	  build without USERSPACE support, gap filling should always
958	  be required.
959
960	  When the option is switched off, access to memory areas not
961	  covered by explicit MPU regions is restricted to privileged
962	  code on an ARCH-specific basis. Refer to ARCH-specific
963	  documentation for more information on how this option is
964	  used.
965
966endif # MPU
967
968config SRAM_REGION_PERMISSIONS
969	bool "Assign appropriate permissions to kernel areas in SRAM"
970	depends on MMU || MPU
971	default y
972	help
973	  This option indicates that memory protection hardware
974	  is present, enabled, and regions have been configured at boot for memory
975	  ranges within the kernel image.
976
977	  If this option is turned on, certain areas of the kernel image will
978	  have the following access policies applied for all threads, including
979	  supervisor threads:
980
981	  1) All program text will be have read-only, execute memory permission
982	  2) All read-only data will have read-only permission, and execution
983	     disabled if the hardware supports it.
984	  3) All other RAM addresses will have read-write permission, and
985	     execution disabled if the hardware supports it.
986
987	  Options such as USERSPACE or HW_STACK_PROTECTION may additionally
988	  impose additional policies on the memory map, which may be global
989	  or local to the current running thread.
990
991	  This option may consume additional memory to satisfy memory protection
992	  hardware alignment constraints.
993
994	  If this option is disabled, the entire kernel will have default memory
995	  access permissions set, typically read/write/execute. It may be desirable
996	  to turn this off on MMU systems which are using the MMU for demand
997	  paging, do not need memory protection, and would rather not use up
998	  RAM for the alignment between regions.
999
1000config CODE_DATA_RELOCATION
1001	bool "Support code/data section relocation"
1002	depends on ARCH_HAS_CODE_DATA_RELOCATION
1003	help
1004	  Enable support for relocating .text, data and .bss sections from specified
1005	  files and placing them in a chosen memory region. Files to relocate and
1006	  the target regions should be specified in CMakeLists.txt using
1007	  zephyr_code_relocate().
1008
1009menu "DSP Options"
1010
1011config DSP_SHARING
1012	bool "DSP register sharing"
1013	depends on CPU_HAS_DSP
1014	help
1015	  This option enables preservation of the hardware DSP registers
1016	  across context switches to allow multiple threads to perform concurrent
1017	  DSP operations.
1018endmenu
1019
1020menu "Floating Point Options"
1021
1022config FPU
1023	bool "Floating point unit (FPU)"
1024	depends on CPU_HAS_FPU
1025	help
1026	  This option enables the hardware Floating Point Unit (FPU), in order to
1027	  support using the floating point registers and instructions.
1028
1029	  When this option is enabled, by default, threads may use the floating
1030	  point registers only in an exclusive manner, and this usually means that
1031	  only one thread may perform floating point operations.
1032
1033	  If it is necessary for multiple threads to perform concurrent floating
1034	  point operations, the "FPU register sharing" option must be enabled to
1035	  preserve the floating point registers across context switches.
1036
1037	  Note that this option cannot be selected for the platforms that do not
1038	  include a hardware floating point unit; the floating point support for
1039	  those platforms is dependent on the availability of the toolchain-
1040	  provided software floating point library.
1041
1042config FPU_SHARING
1043	bool "FPU register sharing"
1044	depends on FPU && MULTITHREADING
1045	help
1046	  This option enables preservation of the hardware floating point registers
1047	  across context switches to allow multiple threads to perform concurrent
1048	  floating point operations.
1049
1050	  Note that some compiler configurations may activate a floating point
1051	  context by generating FP instructions for any thread, and that
1052	  context must be preserved when switching such threads in and out.
1053	  The developers can still disable the FP sharing mode in their
1054	  application projects, and switch to Unshared FP registers mode,
1055	  if it is guaranteed that the image code does not generate FP
1056	  instructions outside the single thread context that is allowed
1057	  to do so.
1058
1059endmenu
1060
1061menu "Cache Options"
1062
1063config DCACHE
1064	bool "Data cache (d-cache) support"
1065	depends on CPU_HAS_DCACHE
1066	default y
1067	help
1068	  This option enables the support for the data cache (d-cache).
1069
1070config ICACHE
1071	bool "Instruction cache (i-cache) support"
1072	depends on CPU_HAS_ICACHE
1073	default y
1074	help
1075	  This option enables the support for the instruction cache (i-cache).
1076
1077config CACHE_DOUBLEMAP
1078	bool "Cache double-mapping support"
1079	depends on CPU_CACHE_INCOHERENT
1080	default y
1081	help
1082	  Double-mapping behavior where a pointer can be cheaply converted to
1083	  point to the same cached/uncached memory at different locations.
1084
1085	  This applies to intra-CPU multiprocessing incoherence and makes only
1086	  sense when MP_MAX_NUM_CPUS > 1.
1087
1088config CACHE_MANAGEMENT
1089	bool "Cache management features"
1090	depends on DCACHE || ICACHE
1091	help
1092	  This option enables the cache management functions backed by arch or
1093	  driver code.
1094
1095config DCACHE_LINE_SIZE_DETECT
1096	bool "Detect d-cache line size at runtime"
1097	depends on CACHE_MANAGEMENT && DCACHE
1098	help
1099	  This option enables querying some architecture-specific hardware for
1100	  finding the d-cache line size at the expense of taking more memory and
1101	  code and a slightly increased boot time.
1102
1103	  If the CPU's d-cache line size is known in advance, disable this option and
1104	  manually enter the value for DCACHE_LINE_SIZE or set it in the DT
1105	  using the 'd-cache-line-size' property.
1106
1107config DCACHE_LINE_SIZE
1108	int "d-cache line size"
1109	depends on CACHE_MANAGEMENT && DCACHE && !DCACHE_LINE_SIZE_DETECT
1110	default 0
1111	help
1112	  Size in bytes of a CPU d-cache line. If this is set to 0 the value is
1113	  obtained from the 'd-cache-line-size' DT property instead if present.
1114
1115
1116	  Detect automatically at runtime by selecting DCACHE_LINE_SIZE_DETECT.
1117
1118config ICACHE_LINE_SIZE_DETECT
1119	bool "Detect i-cache line size at runtime"
1120	depends on CACHE_MANAGEMENT && ICACHE
1121	help
1122	  This option enables querying some architecture-specific hardware for
1123	  finding the i-cache line size at the expense of taking more memory and
1124	  code and a slightly increased boot time.
1125
1126	  If the CPU's i-cache line size is known in advance, disable this option and
1127	  manually enter the value for ICACHE_LINE_SIZE or set it in the DT
1128	  using the 'i-cache-line-size' property.
1129
1130config ICACHE_LINE_SIZE
1131	int "i-cache line size"
1132	depends on CACHE_MANAGEMENT && ICACHE && !ICACHE_LINE_SIZE_DETECT
1133	default 0
1134	help
1135	  Size in bytes of a CPU i-cache line. If this is set to 0 the value is
1136	  obtained from the 'i-cache-line-size' DT property instead if present.
1137
1138	  Detect automatically at runtime by selecting ICACHE_LINE_SIZE_DETECT.
1139
1140choice CACHE_TYPE
1141	prompt "Cache type"
1142	depends on CACHE_MANAGEMENT
1143	default ARCH_CACHE
1144
1145config ARCH_CACHE
1146	bool "Integrated cache controller"
1147	help
1148	  Integrated on-core cache controller
1149
1150config EXTERNAL_CACHE
1151	bool "External cache controller"
1152	help
1153	  External cache controller
1154
1155endchoice
1156
1157endmenu
1158
1159config ARCH
1160	string
1161	help
1162	  System architecture string.
1163
1164config TOOLCHAIN_HAS_BUILTIN_FFS
1165	bool
1166	default y if !(64BIT && RISCV)
1167	help
1168	  Hidden option to signal that toolchain has __builtin_ffs*().
1169
1170config ARCH_HAS_CUSTOM_CPU_IDLE
1171	bool
1172	help
1173	  This options allows applications to override the default arch idle implementation with
1174	  a custom one.
1175
1176config ARCH_HAS_CUSTOM_CPU_ATOMIC_IDLE
1177	bool
1178	help
1179	  This options allows applications to override the default arch idle implementation with
1180	  a custom one.
1181
1182config ARCH_HAS_CUSTOM_SWAP_TO_MAIN
1183	bool
1184	help
1185	  It's possible that an architecture port cannot use z_swap_unlocked()
1186	  to swap to the main thread (bg_thread_main), but instead must do
1187	  something custom. It must enable this option in that case.
1188
1189config ARCH_HAS_CUSTOM_BUSY_WAIT
1190	bool
1191	help
1192	  It's possible that an architecture port cannot or does not want to use
1193	  the provided k_busy_wait(), but instead must do something custom. It must
1194	  enable this option in that case.
1195
1196config ARCH_HAS_CUSTOM_CURRENT_IMPL
1197	bool
1198	help
1199	  Select when architecture implements arch_current_thread() &
1200	  arch_current_thread_set().
1201
1202config ARCH_IPI_LAZY_COPROCESSORS_SAVE
1203	bool
1204	help
1205	  Select when the architecture has multi-CPU lazy context switching
1206	  of coprocessor registers.
1207