Skip to content

Commit 62a06d2

Browse files
collucaclaude
andauthored
Add xCAUSE interrupt and exception code field masks (#427)
* Add MCAUSE/SCAUSE/UCAUSE Interrupt and Exception Code field masks Define MCAUSE32/64_INT and MCAUSE32/64_EXCCODE for the Interrupt and Exception Code fields of mcause, plus XLEN-generic aliases in the __riscv_xlen selection block, following the same pattern used for MSTATUS_SD and SATP_MODE. scause and ucause share the identical bit layout per the privileged spec, so SCAUSE_* and UCAUSE_* are defined as aliases of the MCAUSE_* masks. * Remove UCAUSE macros There is no ucause CSR in the privileged spec, so the UCAUSE32/64_INT and UCAUSE32/64_EXCCODE masks (and the UCAUSE_INT/UCAUSE_EXCCODE xlen-generic aliases) don't apply. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
1 parent aeb94df commit 62a06d2

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

encoding.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,16 @@
171171

172172
#define MIDELEG_FORCED_MASK MIP_HS_MASK
173173

174+
#define MCAUSE32_INT _RISCV_UL(0x80000000)
175+
#define MCAUSE32_EXCCODE _RISCV_UL(0x7FFFFFFF)
176+
#define MCAUSE64_INT _RISCV_ULL(0x8000000000000000)
177+
#define MCAUSE64_EXCCODE _RISCV_ULL(0x7FFFFFFFFFFFFFFF)
178+
179+
#define SCAUSE32_INT MCAUSE32_INT
180+
#define SCAUSE32_EXCCODE MCAUSE32_EXCCODE
181+
#define SCAUSE64_INT MCAUSE64_INT
182+
#define SCAUSE64_EXCCODE MCAUSE64_EXCCODE
183+
174184
#define SIP_SSIP MIP_SSIP
175185
#define SIP_STIP MIP_STIP
176186

@@ -521,11 +531,19 @@
521531
# define SSTATUS_SD SSTATUS64_SD
522532
# define RISCV_PGLEVEL_BITS 9
523533
# define SATP_MODE SATP64_MODE
534+
# define MCAUSE_INT MCAUSE64_INT
535+
# define MCAUSE_EXCCODE MCAUSE64_EXCCODE
536+
# define SCAUSE_INT SCAUSE64_INT
537+
# define SCAUSE_EXCCODE SCAUSE64_EXCCODE
524538
#else
525539
# define MSTATUS_SD MSTATUS32_SD
526540
# define SSTATUS_SD SSTATUS32_SD
527541
# define RISCV_PGLEVEL_BITS 10
528542
# define SATP_MODE SATP32_MODE
543+
# define MCAUSE_INT MCAUSE32_INT
544+
# define MCAUSE_EXCCODE MCAUSE32_EXCCODE
545+
# define SCAUSE_INT SCAUSE32_INT
546+
# define SCAUSE_EXCCODE SCAUSE32_EXCCODE
529547
#endif
530548
#define RISCV_PGSHIFT 12
531549
#define RISCV_PGSIZE (1 << RISCV_PGSHIFT)

0 commit comments

Comments
 (0)