Skip to content

Commit 3d1b996

Browse files
committed
arch: riscv: added helper config to include isr wrapper
Added helper Kcoinfig option USE_ISR_WRAPPER which can be used to include isr_wrapper even if GEN_SW_ISR_TABLE is not enabled. This is needed to enable configurations where only IRQ vector table is used with multithreading (only direct isr used). This change is backward compatibible with previous config. Signed-off-by: Łukasz Stępnicki <[email protected]>
1 parent 1e6c549 commit 3d1b996

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

arch/riscv/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,15 @@ config RISCV_GENERIC_TOOLCHAIN
262262
Allow SOCs that have custom extended riscv ISA to still
263263
compile with generic riscv32 toolchain.
264264

265+
config USE_ISR_WRAPPER
266+
bool "Use isr_wrapper to handle interrupt and/or exception/fault"
267+
default y if GEN_SW_ISR_TABLE
268+
default y if MULTITHREADING
269+
help
270+
This is helper config to be able to use exception handling
271+
when GEN_SW_ISR_TABLE is not used but multithreading is, which
272+
needs exception handling and thread entry/switch functions.
273+
265274
config GEN_ISR_TABLES
266275
default y
267276

arch/riscv/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ endif()
2626
zephyr_library_sources_ifdef(CONFIG_FPU_SHARING fpu.c fpu.S)
2727
zephyr_library_sources_ifdef(CONFIG_DEBUG_COREDUMP coredump.c)
2828
zephyr_library_sources_ifdef(CONFIG_IRQ_OFFLOAD irq_offload.c)
29-
zephyr_library_sources_ifdef(CONFIG_GEN_SW_ISR_TABLE isr.S)
29+
zephyr_library_sources_ifdef(CONFIG_USE_ISR_WRAPPER isr.S)
3030
zephyr_library_sources_ifdef(CONFIG_RISCV_PMP pmp.c pmp.S)
3131
zephyr_library_sources_ifdef(CONFIG_THREAD_LOCAL_STORAGE tls.c)
3232
zephyr_library_sources_ifdef(CONFIG_USERSPACE userspace.S)

arch/riscv/core/isr.S

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ GTEXT(__soc_is_irq)
7373
#endif
7474
GTEXT(__soc_handle_irq)
7575
GTEXT(z_riscv_fault)
76+
GTEXT(z_irq_spurious)
7677
#ifdef CONFIG_RISCV_SOC_CONTEXT_SAVE
7778
GTEXT(__soc_save_context)
7879
GTEXT(__soc_restore_context)
@@ -331,6 +332,7 @@ no_fp: /* increment _current->arch.exception_depth */
331332
* function (that needs to be implemented by each SOC). The result is
332333
* returned via register a0 (1: interrupt, 0 exception)
333334
*/
335+
334336
#ifdef CONFIG_RISCV_SOC_EXCEPTION_FROM_IRQ
335337
jal ra, __soc_is_irq
336338
bnez a0, is_interrupt
@@ -646,6 +648,7 @@ on_irq_stack:
646648
*/
647649
jal ra, __soc_handle_irq
648650

651+
#if defined CONFIG_GEN_SW_ISR_TABLE
649652
/*
650653
* Call corresponding registered function in _sw_isr_table.
651654
* (table is 2-word wide, we should shift index accordingly)
@@ -659,6 +662,12 @@ on_irq_stack:
659662

660663
/* Load ISR function address in register t1 */
661664
lr t1, RV_REGSIZE(t0)
665+
#else
666+
/* Load spurious interrupt function in case _sw_isr_table does not exist */
667+
la t1, z_irq_spurious
668+
/* NULL as parameter */
669+
li a0, 0
670+
#endif
662671

663672
/* Call ISR function */
664673
jalr ra, t1, 0

soc/common/riscv-privileged/vector.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ GTEXT(__start)
1212

1313
/* imports */
1414
GTEXT(__initialize)
15-
#if defined(CONFIG_GEN_SW_ISR_TABLE)
15+
#if defined(CONFIG_USE_ISR_WRAPPER)
1616
GTEXT(_isr_wrapper)
1717
#endif
1818

@@ -41,7 +41,7 @@ SECTION_FUNC(vectors, __start)
4141
* mtvec.base must be aligned to 64 bytes (this is done using
4242
* CONFIG_RISCV_TRAP_HANDLER_ALIGNMENT)
4343
*/
44-
#if defined(CONFIG_GEN_SW_ISR_TABLE)
44+
#if defined(CONFIG_USE_ISR_WRAPPER)
4545
la t0, _isr_wrapper
4646
#else
4747
add t0, zero, zero

0 commit comments

Comments
 (0)