Skip to content

Commit 0237d37

Browse files
magp-nordicnashif
authored andcommitted
arch: riscv: add an option for empty spurious interrupt handler
Add the possibility to disable fault handling in spurious interrupt handler on RISCs and replacce it with an infinite loop. Signed-off-by: Magdalena Pastula <[email protected]>
1 parent f44146a commit 0237d37

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

arch/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ config RISCV
113113
select ARCH_IS_SET
114114
select ARCH_SUPPORTS_COREDUMP
115115
select ARCH_SUPPORTS_ROM_START if !SOC_FAMILY_ESPRESSIF_ESP32
116+
select ARCH_SUPPORTS_EMPTY_IRQ_SPURIOUS
116117
select ARCH_HAS_CODE_DATA_RELOCATION
117118
select ARCH_HAS_THREAD_LOCAL_STORAGE
118119
select IRQ_OFFLOAD_NESTED if IRQ_OFFLOAD
@@ -608,6 +609,14 @@ config SIMPLIFIED_EXCEPTION_CODES
608609
down to the generic K_ERR_CPU_EXCEPTION, which makes testing code
609610
much more portable.
610611

612+
config EMPTY_IRQ_SPURIOUS
613+
bool "Create empty spurious interrupt handler"
614+
depends on ARCH_SUPPORTS_EMPTY_IRQ_SPURIOUS
615+
help
616+
This option changes body of spurious interrupt handler. When enabled,
617+
handler contains only an infinite while loop, when disabled, handler
618+
contains the whole Zephyr fault handling procedure.
619+
611620
endmenu # Interrupt configuration
612621

613622
config INIT_ARCH_HW_AT_BOOT
@@ -673,6 +682,9 @@ config ARCH_SUPPORTS_ARCH_HW_INIT
673682
config ARCH_SUPPORTS_ROM_START
674683
bool
675684

685+
config ARCH_SUPPORTS_EMPTY_IRQ_SPURIOUS
686+
bool
687+
676688
config ARCH_HAS_EXTRA_EXCEPTION_INFO
677689
bool
678690

arch/riscv/core/irq_manage.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
1919

2020
FUNC_NORETURN void z_irq_spurious(const void *unused)
2121
{
22+
#ifdef CONFIG_EMPTY_IRQ_SPURIOUS
23+
while (1) {
24+
}
25+
26+
CODE_UNREACHABLE;
27+
#else
2228
unsigned long mcause;
2329

2430
ARG_UNUSED(unused);
@@ -37,6 +43,7 @@ FUNC_NORETURN void z_irq_spurious(const void *unused)
3743
}
3844
#endif
3945
z_riscv_fatal_error(K_ERR_SPURIOUS_IRQ, NULL);
46+
#endif /* CONFIG_EMPTY_IRQ_SPURIOUS */
4047
}
4148

4249
#ifdef CONFIG_DYNAMIC_INTERRUPTS

0 commit comments

Comments
 (0)