Skip to content

Commit 452a2f6

Browse files
gmarullcarlescufi
authored andcommitted
arch: riscv: use CONFIG_RISCV_MCAUSE_EXCEPTION_MASK
Instead of custom SOC_MCAUSE_EXP_MASK definition. Note that SoCs selecting RISCV_PRIVILEGED already used such config indirectly (see changes in soc_common.h). Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent ee60977 commit 452a2f6

File tree

10 files changed

+8
-46
lines changed

10 files changed

+8
-46
lines changed

arch/riscv/core/fatal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ void _Fault(z_arch_esf_t *esf)
168168
__asm__ volatile("csrr %0, mtval" : "=r" (mtval));
169169
#endif
170170

171-
mcause &= SOC_MCAUSE_EXP_MASK;
171+
mcause &= CONFIG_RISCV_MCAUSE_EXCEPTION_MASK;
172172
LOG_ERR("");
173173
LOG_ERR(" mcause: %ld, %s", mcause, cause_str(mcause));
174174
#ifndef CONFIG_SOC_OPENISA_RV32M1_RISCV32

arch/riscv/core/irq_manage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ FUNC_NORETURN void z_irq_spurious(const void *unused)
2020

2121
mcause = csr_read(mcause);
2222

23-
mcause &= SOC_MCAUSE_EXP_MASK;
23+
mcause &= CONFIG_RISCV_MCAUSE_EXCEPTION_MASK;
2424

2525
LOG_ERR("Spurious interrupt detected! IRQ: %ld", mcause);
2626
#if defined(CONFIG_RISCV_HAS_PLIC)

arch/riscv/core/isr.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ no_fp: /* increment _current->arch.exception_depth */
295295
* to report the exception.
296296
*/
297297
csrr t0, mcause
298-
li t2, SOC_MCAUSE_EXP_MASK
298+
li t2, CONFIG_RISCV_MCAUSE_EXCEPTION_MASK
299299
and t0, t0, t2
300300

301301
/*
@@ -528,7 +528,7 @@ on_irq_stack:
528528

529529
/* Get IRQ causing interrupt */
530530
csrr a0, mcause
531-
li t0, SOC_MCAUSE_EXP_MASK
531+
li t0, CONFIG_RISCV_MCAUSE_EXCEPTION_MASK
532532
and a0, a0, t0
533533

534534
/*

include/zephyr/arch/riscv/irq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static inline void arch_isr_direct_footer(int swap)
9191

9292
/* Get the IRQ number */
9393
__asm__ volatile("csrr %0, mcause" : "=r" (mcause));
94-
mcause &= SOC_MCAUSE_EXP_MASK;
94+
mcause &= CONFIG_RISCV_MCAUSE_EXCEPTION_MASK;
9595

9696
/* Clear the pending IRQ */
9797
__soc_handle_irq(mcause);

soc/riscv/common/riscv-privileged/soc_common.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
#define RISCV_MACHINE_SOFT_IRQ 3 /* Machine Software Interrupt */
1717
#define RISCV_MACHINE_EXT_IRQ 11 /* Machine External Interrupt */
1818

19-
/* Exception code Mask */
20-
#define SOC_MCAUSE_EXP_MASK CONFIG_RISCV_MCAUSE_EXCEPTION_MASK
21-
2219
#ifndef _ASMLANGUAGE
2320

2421
#include <zephyr/drivers/interrupt_controller/riscv_clic.h>

soc/riscv/espressif_esp32/esp32c3/soc.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
#define RISCV_MACHINE_TIMER_IRQ 7 /* Machine Timer Interrupt */
2222
#define RISCV_MACHINE_EXT_IRQ 11 /* Machine External Interrupt */
2323

24-
/* Exception code Mask */
25-
#define SOC_MCAUSE_EXP_MASK 0x7FFFFFFF
26-
2724
#ifndef _ASMLANGUAGE
2825

2926
void __esp_platform_start(void);

soc/riscv/ite_ec/common/soc_common.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414

1515
#include "chip_chipregs.h"
1616

17-
/* SOC-specific MCAUSE bitfields */
18-
19-
/* Exception code Mask */
20-
#define SOC_MCAUSE_EXP_MASK 0x7FFFFFFF
21-
2217
#ifndef _ASMLANGUAGE
2318

2419
#ifdef CONFIG_HAS_ITE_INTC

soc/riscv/openisa_rv32m1/Kconfig.defconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ config RISCV_SOC_OFFSETS
3333
config RISCV_SOC_INTERRUPT_INIT
3434
default y
3535

36+
config RISCV_MCAUSE_EXCEPTION_MASK
37+
default 0x1F
38+
3639
# We need to disable the watchdog out of reset, as it's enabled by
3740
# default. Use the WDOG_INIT hook for doing that.
3841
config WDOG_INIT

soc/riscv/openisa_rv32m1/soc_ri5cy.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,4 @@
4040
#define RI5CY_PRIVLV 0xC10
4141
#define RI5CY_MHARTID 0xF14
4242

43-
/*
44-
* Map from SoC-specific configuration to generic Zephyr macros.
45-
*
46-
* These are expected by the code in arch/, and must be provided for
47-
* the kernel to work (or even build at all).
48-
*
49-
* Some of these may also apply to ZERO-RISCY; needs investigation.
50-
*/
51-
52-
/*
53-
* Exception code mask. Use of the bottom five bits is a subset of
54-
* what the standard allocates (which is XLEN-1 bits).
55-
*/
56-
#define SOC_MCAUSE_EXP_MASK 0x1F
57-
5843
#endif /* SOC_RISCV32_OPENISA_RV32M1_SOC_RI5CY_H_ */

soc/riscv/openisa_rv32m1/soc_zero_riscy.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,4 @@
2828
#define ZERO_RISCY_PCMR 0x7A1U
2929
#define ZERO_RISCY_MHARTID 0xF14U
3030

31-
/*
32-
* Map from SoC-specific configuration to generic Zephyr macros.
33-
*
34-
* These are expected by the code in arch/, and must be provided for
35-
* the kernel to work (or even build at all).
36-
*
37-
* Some of these may also apply to ZERO-RISCY; needs investigation.
38-
*/
39-
40-
/*
41-
* Exception code mask. Use of the bottom five bits is a subset of
42-
* what the standard allocates (which is XLEN-1 bits).
43-
*/
44-
#define SOC_MCAUSE_EXP_MASK 0x1F
45-
4631
#endif /* SOC_RISCV32_OPENISA_RV32M1_SOC_ZERO_RISCY_H_ */

0 commit comments

Comments
 (0)