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