-
Notifications
You must be signed in to change notification settings - Fork 786
Expand file tree
/
Copy pathKconfig
More file actions
617 lines (512 loc) · 20.3 KB
/
Kconfig
File metadata and controls
617 lines (512 loc) · 20.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
# Copyright (c) 2016 Jean-Paul Etienne <fractalclone@gmail.com>
# Copyright (c) 2024 Antmicro <www.antmicro.com>
# SPDX-License-Identifier: Apache-2.0
menu "RISCV Options"
depends on RISCV
config ARCH
string
default "riscv"
config FLOAT_HARD
bool "Hard-float calling convention"
default y
depends on FPU
depends on !RISCV_ISA_RV32E
depends on RISCV_ISA_EXT_F
help
This option enables the hard-float calling convention.
Adds eight floating-point argument registers.
config RISCV_USE_MSAVE_RESTORE
bool "Compile with -msave-restore to reduce some code footprint"
help
The `-msave-restore` option enables the compiler to emit calls to library
routines `__riscv_save_X` and `__riscv_restore_X` for preserving the
callee-saved registers instead of inlining them in every function. This
can reduce code size in some large functions. However, it introduces extra
branching overhead, which may impact the performance in hot paths.
If supported by your SoC, the `Zcmp` ISA extension should be preferred.
choice RISCV_GP_PURPOSE
prompt "Purpose of the global pointer (GP) register"
default RISCV_GP if RISCV_SOC_HAS_GP_RELATIVE_ADDRESSING
config RISCV_GP
bool "RISC-V global pointer relative addressing"
depends on RISCV_SOC_HAS_GP_RELATIVE_ADDRESSING
help
Use global pointer relative addressing for small globals declared
anywhere in the executable. It can benefit performance and reduce
the code size.
Note: To support this feature, RISC-V SoC needs to initialize
global pointer at program start or earlier than any instruction
using GP relative addressing.
config RISCV_CURRENT_VIA_GP
bool "Store current thread into the global pointer (GP) register"
depends on MP_MAX_NUM_CPUS > 1
select ARCH_HAS_CUSTOM_CURRENT_IMPL
help
Store the current thread's pointer into the global pointer (GP) register.
When is enabled, calls to `_current` & `k_sched_current_thread_query()` will
be reduced to a single register read.
endchoice # RISCV_GP_PURPOSE
config RISCV_ALWAYS_SWITCH_THROUGH_ECALL
bool "Do not use mret outside a trap handler context"
depends on MULTITHREADING
help
Use mret instruction only when in a trap handler.
This is for RISC-V implementations that require every mret to be
balanced with an ecall. This is not required by the RISC-V spec
and most people should say n here to minimize context switching
overhead.
DT_CHOSEN_Z_SRAM = zephyr,sram
choice RISCV_CMODEL
prompt "RISC-V Code Model"
default RISCV_CMODEL_LARGE if (SRAM_DEPRECATED_KCONFIG_SET && SRAM_BASE_ADDRESS > 0xffffffff) || \
(!SRAM_DEPRECATED_KCONFIG_SET && $(dt_chosen_reg_addr_int,$(DT_CHOSEN_Z_SRAM),0) > 0xffffffff) || \
(KERNEL_VM_BASE > 0xffffffff)
default RISCV_CMODEL_MEDANY if 64BIT
default RISCV_CMODEL_MEDLOW
config RISCV_CMODEL_MEDLOW
bool "Medium-low code model"
help
In medium-low code model (medlow), the program and its statically defined symbols must lie
within a single 2 GiB address range and between absolute addresses -2 GiB and +2 GiB.
config RISCV_CMODEL_MEDANY
bool "Medium-any code model"
help
In medium-any code model (medany), the program and its statically defined symbols must be
within any single 2 GiB address range. The code generated by this model is
position-independent.
config RISCV_CMODEL_LARGE
bool "Large code model"
help
In large code model (large), the program and its statically defined symbols have no
restrictions on size and placement.
endchoice
choice RISCV_SMP_IPI_IMPL
prompt "RISC-V SMP IPI implementation"
depends on SMP
default RISCV_SMP_IPI_CLINT if DT_HAS_SIFIVE_CLINT0_ENABLED
default RISCV_SMP_IPI_CUSTOM
config RISCV_SMP_IPI_CLINT
bool "CLINT-based IPI"
depends on DT_HAS_SIFIVE_CLINT0_ENABLED
help
Use CLINT-based IPI implementation.
config RISCV_SMP_IPI_CUSTOM
bool "Custom IPI implementation"
help
Allow custom IPI implementation.
When this is selected, the following functions must be provided:
- arch_sched_directed_ipi()
- arch_flush_fpu_ipi() if CONFIG_FPU_SHARING
- arch_spin_relax() if CONFIG_FPU_SHARING
- arch_smp_init()
endchoice # RISCV_SMP_IPI_IMPL
menu "RISCV Processor Options"
config INCLUDE_RESET_VECTOR
bool "Jumps to __initialize directly"
help
Select 'y' here to use the Zephyr provided default implementation that
jumps to `__initialize` directly. Otherwise a SOC needs to provide its
custom `__reset` routine.
config RISCV_PRIVILEGED
bool
select ARCH_HAS_RAMFUNC_SUPPORT if XIP
help
Option selected by SoCs implementing the RISC-V privileged ISA.
config RISCV_SOC_HAS_ISR_STACKING
bool
depends on !USERSPACE
help
Enable low-level SOC-specific hardware stacking / unstacking
operations during ISR. This hidden option needs to be selected by SoC
if this feature is supported.
Some SOCs implement a mechanism for which, on interrupt handling,
part of the context is automatically saved by the hardware on the
stack according to a custom ESF format. The same part of the context
is automatically restored by hardware on mret.
Enabling this option requires that the SoC provides a
soc_isr_stacking.h header which defines the following:
- SOC_ISR_SW_STACKING: macro guarded by _ASMLANGUAGE called by the
IRQ wrapper assembly code on ISR entry to save in the ESF the
remaining part of the context not pushed already on the stack by
the hardware.
- SOC_ISR_SW_UNSTACKING: macro guarded by _ASMLANGUAGE called by the
IRQ wrapper assembly code on ISR exit to restore the part of the
context from the ESF that won't be restored by hardware on mret.
- SOC_ISR_STACKING_ESF_DECLARE: structure declaration for the ESF
guarded by !_ASMLANGUAGE. The ESF should be defined to account for
the hardware stacked registers in the proper order as they are
saved on the stack by the hardware, and the registers saved by the
software macros. The structure must be called 'struct arch_esf'.
- SOC_ISR_STACKING_ESR_INIT: macro guarded by !_ASMLANGUAGE.
Some hardware stacked registers should be initialized on init
stack with proper values. This prevents from incorrect behavior
on entry context switch when initial stack is restored.
config RISCV_SOC_HAS_CUSTOM_IRQ_HANDLING
bool
help
This allows the SoC to overwrite the irq handling. If enabled, the
function __soc_handle_all_irqs has to be implemented. It shall service
and clear all pending interrupts.
config RISCV_SOC_HAS_CUSTOM_IRQ_LOCK_OPS
bool
help
Hidden option to allow SoC to overwrite arch_irq_lock(),
arch_irq_unlock() and arch_irq_unlocked() functions with
platform-specific versions named z_soc_irq_lock(), z_soc_irq_unlock()
and z_soc_irq_unlocked().
Enable this hidden option and specialize the z_soc_* functions when
the RISC-V SoC needs to do something different and more than reading and
writing the mstatus register to lock and unlock the IRQs.
config RISCV_SOC_HAS_CUSTOM_SYS_IO
bool
help
Hidden option to allow SoC to overwrite sys_read*(), sys_write*() functions with
platform-specific versions named z_soc_sys_read*() and z_soc_sys_write*().
Enable this hidden option and specialize the z_soc_* functions when
the RISC-V SoC needs to do something different and more than reading and
writing the registers.
config RISCV_SOC_HAS_GP_RELATIVE_ADDRESSING
bool
help
Selected when SoC has implemented the initialization of global pointer (GP)
at program start, or earlier than any instruction using GP relative addressing.
config RISCV_SOC_CONTEXT_SAVE
bool "SOC-based context saving in IRQ handlers"
select RISCV_SOC_OFFSETS
help
Enable low-level SOC-specific context management, for SOCs
with extra state that must be saved when entering an
interrupt/exception, and restored on exit. If unsure, leave
this at the default value.
Enabling this option requires that the SoC provide a
soc_context.h header which defines the following macros:
- SOC_ESF_MEMBERS: structure component declarations to
allocate space for. The last such declaration should not
end in a semicolon, for portability. The generic RISC-V
architecture code will allocate space for these members in
a "struct soc_esf" type (typedefed to soc_esf_t), which will
be available if arch.h is included.
- SOC_ESF_INIT: structure contents initializer for struct soc_esf
state. The last initialized member should not end in a comma.
The generic architecture IRQ wrapper will also call
\_\_soc_save_context and \_\_soc_restore_context routines at
ISR entry and exit, respectively. These should typically
be implemented in assembly. If they were C functions, they
would have these signatures:
``void __soc_save_context(soc_esf_t *state);``
``void __soc_restore_context(soc_esf_t *state);``
The calls obey standard calling conventions; i.e., the state
pointer address is in a0, and ra contains the return address.
config RISCV_SOC_OFFSETS
bool "SOC-based offsets"
help
Enabling this option requires that the SoC provide a soc_offsets.h
header which defines the following macros:
- GEN_SOC_OFFSET_SYMS(): a macro which expands to
GEN_OFFSET_SYM(soc_esf_t, soc_specific_member) calls
to ensure offset macros for SOC_ESF_MEMBERS are defined
in offsets.h. The last one should not end in a semicolon.
See gen_offset.h for more details.
config RISCV_HAS_PLIC
bool
depends on RISCV_PRIVILEGED
help
Does the SOC provide support for a Platform Level Interrupt Controller (PLIC).
config RISCV_HAS_CLIC
bool
depends on RISCV_PRIVILEGED
select RISCV_ALWAYS_SWITCH_THROUGH_ECALL if MULTITHREADING
select CLIC_SUPPORT_INTERRUPT_LEVEL if !NRFX_CLIC
help
Does the SOC provide support for a Core-Local Interrupt Controller (CLIC).
config CLIC_SUPPORT_INTERRUPT_LEVEL
bool
depends on RISCV_HAS_CLIC
help
For CLIC implementations with extended interrupt level, where
higher-numbered interrupt levels can preempt lower-numbered interrupt
levels. This option handles interrupt level in ISR to ensure proper
nested ISR exits.
config RISCV_SOC_INTERRUPT_INIT
bool "SOC-based interrupt initialization"
help
Enable SOC-based interrupt initialization
(call soc_interrupt_init, within _IntLibInit when enabled)
config RISCV_MCAUSE_EXCEPTION_MASK
hex
default 0x7FFFFFFFFFFFFFFF if 64BIT
default 0x7FFFFFFF
help
Specify the bits to use for exception code in mcause register.
config RISCV_GENERIC_TOOLCHAIN
bool "Compile using generic riscv32 toolchain"
default y
help
Compile using generic riscv32 toolchain.
Allow SOCs that have custom extended riscv ISA to still
compile with generic riscv32 toolchain.
config USE_ISR_WRAPPER
bool "Use isr_wrapper to handle interrupt and/or exception/fault"
default y if MULTITHREADING
help
This is helper config to be able to use exception handling from
_isr_wrapper when GEN_SW_ISR_TABLE is not enabled. E.g. MULTITHREADING
needs exception handling and thread entry/switch functions but may
use only irq vector table.
config GEN_ISR_TABLES
default y
config GEN_SW_ISR_TABLE
default y
select USE_ISR_WRAPPER
config GEN_IRQ_VECTOR_TABLE
default n
config RISCV_RESERVED_IRQ_ISR_TABLES_OFFSET
int
default 0
depends on GEN_ISR_TABLES
help
On some RISCV platform the first interrupt vectors are primarily
intended for inter-hart interrupt signaling and so retained for that
purpose and not available. When this option is set, all the IRQ
vectors are shifted by this offset value when installed into the
software ISR table and the IRQ vector table. CONFIG_NUM_IRQS must be
properly sized to take into account this offset. This is a hidden
option which needs to be set per architecture and left alone.
config NUM_IRQS
int
config RV_BOOT_HART
int "Starting HART ID"
default 0
help
This option sets the starting HART ID for the SMP core.
For RISC-V systems such as MPFS and FU540 this would be set to 1 to
skip the E51 HART 0 as it is not usable in SMP configurations.
config RISCV_HART_MASK
int
default -1
help
Configures the mask for the HART ID.
For RISC-V systems with HART ID starting from non-zero value,
i.e. 128, 129, ..(0x80, 8x81, ..), this can be configured to 63 (0x7f)
such that we can extract the bits that start from 0.
config EXTRA_EXCEPTION_INFO
bool "Collect extra exception info [DEPRECATED]"
select DEPRECATED
help
This option is deprecated and should be replaced with CONFIG_EXCEPTION_DEBUG.
config RISCV_PMP
bool "RISC-V PMP Support"
select THREAD_STACK_INFO
select CPU_HAS_MPU
select ARCH_HAS_USERSPACE
select ARCH_HAS_STACK_PROTECTION
select MPU
select SRAM_REGION_PERMISSIONS
select ARCH_MEM_DOMAIN_SYNCHRONOUS_API if USERSPACE
select ARCH_MEM_DOMAIN_DATA if USERSPACE
select THREAD_LOCAL_STORAGE if USERSPACE
select ARCH_MEM_DOMAIN_SUPPORTS_ISOLATED_STACKS
select MEM_DOMAIN_ISOLATED_STACKS
select PMP_KERNEL_MODE_DYNAMIC if MEM_ATTR
help
MCU implements Physical Memory Protection.
if RISCV_PMP
config PMP_SLOTS
int "Number of PMP slots"
default 8
help
This is the number of PMP entries implemented by the hardware.
Typical values are 8 or 16.
config PMP_NO_TOR
bool
help
Set this if TOR (Top Of Range) mode is not supported.
config PMP_NO_NA4
bool
help
Set this if NA4 (Naturally Aligned 4-byte) mode is not supported.
config PMP_NO_NAPOT
bool
help
Set this if NAPOT (Naturally Aligned Power Of Two) is not supported.
config PMP_POWER_OF_TWO_ALIGNMENT
bool "Enforce power-of-two alignment on PMP memory areas" if !PMP_NO_TOR
default y if TEST_USERSPACE
default y if (PMP_SLOTS = 8)
default y if PMP_NO_TOR
select MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT
select GEN_PRIV_STACKS
help
This option reduces the PMP slot usage but increases
memory consumption. Useful when enabling userspace mode with
many memory domains and/or few PMP slots available.
config PMP_GRANULARITY
int "The granularity of PMP address matching"
default 8 if (PMP_NO_TOR && PMP_NO_NA4)
default 4
help
The granularity must be a power of 2 greater than or equal to 4
(ie 4, 8, 16, ...), but if neither TOR mode nor NA4 mode is
supported, the minimum granularity is 8.
config PMP_NO_LOCK_GLOBAL
bool "Do not lock the global PMP entries"
select PMP_KERNEL_MODE_DYNAMIC
help
Configure the PMP entries as unlocked (L=0) to implement PMP relative
features. This allows application to dynamically reconfigure PMP
entries without requiring hard reset.
config PMP_UNLOCK_ROM_FOR_DEBUG
bool "Unlock ROM region for debugger access"
default n
help
When enabled, the ROM region PMP entry is configured without
the lock bit (L=0), allowing debuggers running in machine mode
to set breakpoints and read instructions. NULL pointer guards
and stack guards remain locked to catch critical bugs during
development. Only enable for debug builds.
endif #RISCV_PMP
config PMP_STACK_GUARD
bool
depends on HW_STACK_PROTECTION
select PMP_KERNEL_MODE_DYNAMIC if MULTITHREADING
config PMP_STACK_GUARD_MIN_SIZE
int "Stack Guard area size"
depends on PMP_STACK_GUARD
default 1024 if 64BIT
default 512
help
The Hardware Stack Protection implements a guard area at the bottom
of the stack using the PMP to catch stack overflows by marking that
guard area not accessible.
This is the size of the guard area. This should be large enough to
catch any sudden jump in stack pointer decrement, plus some
wiggle room to accommodate the eventual overflow exception
stack usage.
config PMP_KERNEL_MODE_DYNAMIC
bool
help
Enable this to dynamically reconfigure and activate PMP entries for
Machine mode when switching between kernel (ISR, syscall) and threads.
# Implement the null pointer detection using the Physical Memory Protection
# (PMP) Unit.
config NULL_POINTER_EXCEPTION_DETECTION_PMP
bool "Use PMP for null pointer exception detection"
depends on RISCV_PMP
help
Null pointer dereference detection implemented
using PMP functionality.
if NULL_POINTER_EXCEPTION_DETECTION_PMP
config NULL_POINTER_EXCEPTION_REGION_SIZE
hex "Inaccessible region to implement null pointer detection"
default 0x10
help
Use a PMP slot to make region (starting at address 0x0) inaccessible for
detecting null pointer dereferencing (raising a CPU access fault).
Minimum is 4 bytes.
endif # NULL_POINTER_EXCEPTION_DETECTION_PMP
config RISCV_IMPRECISE_FPU_STATE_TRACKING
bool "Imprecise implementation of FPU state tracking"
depends on FPU
help
According to the RISC-V Instruction Set Manual: Volume II, Version 20240411
(Section 3.1.6.6), some implementations may choose to track the dirtiness of
the floating-point register state imprecisely by reporting the state to be
dirty even when it has not been modified. This option reflects that.
config RISCV_SMRNMI_ENABLE_NMI_DELIVERY
bool "NMI delivery on SMRNMI hardware (MNSTATUS.NMIE=1)"
select RISCV_ISA_EXT_ZICSR
help
Set MNSTATUS.NMIE bit to 1 during boot to enable NMI delivery on
RISC-V hardware implementing the SMRNMI extension.
This option only enables NMI delivery. It does not provide RNMI
handlers or mnret instruction support. Proper RNMI handlers must
be implemented in SoC-specific code to handle NMI events.
config RISCV_HAS_CUSTOM_STACK_GUARD
bool
help
Selected when the hardware provides a custom stack guard.
config CUSTOM_STACK_GUARD
bool "Thread Stack Guards based on custom stack guard"
depends on RISCV_HAS_CUSTOM_STACK_GUARD
select THREAD_STACK_INFO
help
Enable Thread/Interrupt Stack Guards via custom stack guard.
The functionality must be supported by HW.
config CUSTOM_STACK_GUARD_RESERVED_SIZE
int "Custom stack guard reserved area size"
depends on CUSTOM_STACK_GUARD
default 1024 if 64BIT
default 768
help
This is the size of the custom stack guard reserved area.
This should be large enough to catch any sudden jump in stack pointer
decrement, plus some wiggle room to accommodate the eventual overflow
exception stack usage.
config RISCV_STACK_PROTECTION
bool
default y if HW_STACK_PROTECTION
imply CUSTOM_STACK_GUARD if RISCV_HAS_CUSTOM_STACK_GUARD
select PMP_STACK_GUARD if (!CUSTOM_STACK_GUARD && RISCV_PMP)
help
This option enables either:
- The custom stack guard, or
- the PMP-based stack guard
to cause a system fatal error
if the bounds of the current process stack are overflowed.
The two stack guard options are mutually exclusive. The
selection of the custom stack guard is prioritized over the
PMP-based stack guard. The developer still has the option to
manually select the PMP-based stack guard, if this is desired.
endmenu
config MAIN_STACK_SIZE
default 4096 if 64BIT
default 2048 if PMP_STACK_GUARD
config TEST_EXTRA_STACK_SIZE
default 4096 if CPP_EXCEPTIONS
default 1536
config CMSIS_THREAD_MAX_STACK_SIZE
default 1024 if 64BIT
config CMSIS_V2_THREAD_MAX_STACK_SIZE
default 1024 if 64BIT
config ARCH_IRQ_VECTOR_TABLE_ALIGN
default 256
config RISCV_TRAP_HANDLER_ALIGNMENT
int "Alignment of RISC-V trap handler in bytes"
default 64 if RISCV_HAS_CLIC
default 4
help
This value configures the alignment of RISC-V trap handling
code. The requirement for a particular alignment arises from
the format of MTVEC register which is RISC-V platform-specific.
The minimum alignment is 4 bytes according to the Spec.
config GEN_IRQ_VECTOR_TABLE
select RISCV_VECTORED_MODE if RISCV_PRIVILEGED
config ARCH_HAS_SINGLE_THREAD_SUPPORT
default y if !SMP
config ARCH_HAS_STACKWALK
bool
default y
imply THREAD_STACK_INFO
help
Internal config to indicate that the arch_stack_walk() API is implemented
and it can be enabled.
config RISCV_NO_MTVAL_ON_FP_TRAP
bool
default y if QEMU_TARGET
help
This implementation does not provide useful information in the mtval
CSR (Machine Trap Value register) when floating-point illegal
instruction exceptions occur.
The RISC-V specification allows implementations to decide on a
case-by-case basis when mtval contains meaningful values. The spec
states that mtval is "either set to zero or written with
exception-specific information" on traps. However, this
"exception-specific information" may not necessarily be the faulting
instruction value, and implementations have flexibility in what they
provide.
When this option is enabled, the mtval content cannot be relied upon
to contain the faulting FP instruction, requiring alternative methods
to handle FP exceptions.
rsource "Kconfig.isa"
rsource "custom/Kconfig"
endmenu