Skip to content

Commit

Permalink
arch: riscv: add an option for empty spurious interrupt handler
Browse files Browse the repository at this point in the history
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 <magdalena.pastula@nordicsemi.no>
  • Loading branch information
magp-nordic authored and nashif committed Sep 2, 2024
1 parent f44146a commit 0237d37
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ config RISCV
select ARCH_IS_SET
select ARCH_SUPPORTS_COREDUMP
select ARCH_SUPPORTS_ROM_START if !SOC_FAMILY_ESPRESSIF_ESP32
select ARCH_SUPPORTS_EMPTY_IRQ_SPURIOUS
select ARCH_HAS_CODE_DATA_RELOCATION
select ARCH_HAS_THREAD_LOCAL_STORAGE
select IRQ_OFFLOAD_NESTED if IRQ_OFFLOAD
Expand Down Expand Up @@ -608,6 +609,14 @@ config SIMPLIFIED_EXCEPTION_CODES
down to the generic K_ERR_CPU_EXCEPTION, which makes testing code
much more portable.

config EMPTY_IRQ_SPURIOUS
bool "Create empty spurious interrupt handler"
depends on ARCH_SUPPORTS_EMPTY_IRQ_SPURIOUS
help
This option changes body of spurious interrupt handler. When enabled,
handler contains only an infinite while loop, when disabled, handler
contains the whole Zephyr fault handling procedure.

endmenu # Interrupt configuration

config INIT_ARCH_HW_AT_BOOT
Expand Down Expand Up @@ -673,6 +682,9 @@ config ARCH_SUPPORTS_ARCH_HW_INIT
config ARCH_SUPPORTS_ROM_START
bool

config ARCH_SUPPORTS_EMPTY_IRQ_SPURIOUS
bool

config ARCH_HAS_EXTRA_EXCEPTION_INFO
bool

Expand Down
7 changes: 7 additions & 0 deletions arch/riscv/core/irq_manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);

FUNC_NORETURN void z_irq_spurious(const void *unused)
{
#ifdef CONFIG_EMPTY_IRQ_SPURIOUS
while (1) {
}

CODE_UNREACHABLE;
#else
unsigned long mcause;

ARG_UNUSED(unused);
Expand All @@ -37,6 +43,7 @@ FUNC_NORETURN void z_irq_spurious(const void *unused)
}
#endif
z_riscv_fatal_error(K_ERR_SPURIOUS_IRQ, NULL);
#endif /* CONFIG_EMPTY_IRQ_SPURIOUS */
}

#ifdef CONFIG_DYNAMIC_INTERRUPTS
Expand Down

0 comments on commit 0237d37

Please sign in to comment.