Skip to content

Commit a364420

Browse files
gmarullcarlescufi
authored andcommitted
soc: riscv: cleanup usage/definition of MCAUSE IRQ flag
The MCAUSE register has the "Interrupt" flag defined defined at XLEN-1 position (31 for 32-bit, 63 for 64-bit). This is not an SoC specific option, and there's no need to expose it publicly. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent fcbfe74 commit a364420

File tree

5 files changed

+8
-17
lines changed

5 files changed

+8
-17
lines changed

include/zephyr/arch/riscv/irq.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ extern "C" {
3232
/** Environment Call from M-mode */
3333
#define RISCV_EXC_ECALLM 11
3434

35+
#ifdef CONFIG_64BIT
36+
#define RISCV_MCAUSE_IRQ_BIT (1 << 63)
37+
#else
38+
#define RISCV_MCAUSE_IRQ_BIT (1 << 31)
39+
#endif
40+
3541
#ifndef _ASMLANGUAGE
3642

3743
extern void arch_irq_enable(unsigned int irq);

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

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

19-
/* SOC-specific MCAUSE bitfields */
20-
#ifdef CONFIG_64BIT
21-
/* Interrupt Mask */
22-
#define SOC_MCAUSE_IRQ_MASK (1 << 63)
23-
#else
24-
/* Interrupt Mask */
25-
#define SOC_MCAUSE_IRQ_MASK (1 << 31)
26-
#endif
27-
2819
/* Exception code Mask */
2920
#define SOC_MCAUSE_EXP_MASK CONFIG_RISCV_SOC_MCAUSE_EXCEPTION_MASK
3021

soc/riscv/common/riscv-privileged/soc_irq.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <offsets.h>
1313
#include <zephyr/toolchain.h>
1414
#include <zephyr/linker/sections.h>
15-
#include <soc.h>
15+
#include <zephyr/arch/riscv/irq.h>
1616

1717
/*
1818
* __soc_handle_irq is defined as .weak to allow re-implementation by
@@ -48,7 +48,7 @@ WTEXT(__soc_is_irq)
4848
SECTION_FUNC(exception.other, __soc_is_irq)
4949
/* Read mcause and check if interrupt bit is set */
5050
csrr t0, mcause
51-
li t1, SOC_MCAUSE_IRQ_MASK
51+
li t1, RISCV_MCAUSE_IRQ_BIT
5252
and t0, t0, t1
5353

5454
/* If interrupt bit is not set, return with 0 */

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-
/* Interrupt Mask */
25-
#define SOC_MCAUSE_IRQ_MASK (1 << 31)
26-
2724
/* Exception code Mask */
2825
#define SOC_MCAUSE_EXP_MASK 0x7FFFFFFF
2926

soc/riscv/ite_ec/common/soc_common.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
/* SOC-specific MCAUSE bitfields */
1818

19-
/* Interrupt Mask. 1 (interrupt) or 0 (exception) */
20-
#define SOC_MCAUSE_IRQ_MASK BIT(31)
21-
2219
/* Exception code Mask */
2320
#define SOC_MCAUSE_EXP_MASK 0x7FFFFFFF
2421

0 commit comments

Comments
 (0)