File tree Expand file tree Collapse file tree 4 files changed +21
-3
lines changed
soc/common/riscv-privileged Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Original file line number Diff line number Diff 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+
265274config GEN_ISR_TABLES
266275 default y
267276
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ endif()
2626zephyr_library_sources_ifdef(CONFIG_FPU_SHARING fpu.c fpu.S)
2727zephyr_library_sources_ifdef(CONFIG_DEBUG_COREDUMP coredump.c)
2828zephyr_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)
3030zephyr_library_sources_ifdef(CONFIG_RISCV_PMP pmp.c pmp.S)
3131zephyr_library_sources_ifdef(CONFIG_THREAD_LOCAL_STORAGE tls.c)
3232zephyr_library_sources_ifdef(CONFIG_USERSPACE userspace.S)
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ GTEXT(__soc_is_irq)
7373#endif
7474GTEXT(__soc_handle_irq)
7575GTEXT(z_riscv_fault)
76+ GTEXT(z_irq_spurious)
7677#ifdef CONFIG_RISCV_SOC_CONTEXT_SAVE
7778GTEXT(__soc_save_context)
7879GTEXT(__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
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ GTEXT(__start)
1212
1313/* imports */
1414GTEXT(__initialize)
15- #if defined(CONFIG_GEN_SW_ISR_TABLE )
15+ #if defined(CONFIG_USE_ISR_WRAPPER )
1616GTEXT(_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
You can’t perform that action at this time.
0 commit comments