Proper masking of the mtvec CSR word using macros.
This commit is contained in:
parent
75264e130d
commit
ed9505ae12
2 changed files with 12 additions and 2 deletions
|
|
@ -21,6 +21,16 @@ r_mhartid()
|
|||
#define MSTATUS_MPP_U (0L << 11)
|
||||
#define MSTATUS_MIE (1L << 3) // machine-mode interrupt enable.
|
||||
|
||||
#define MTVEC_MODE_DIRECT 0x0 // mtvec MODE values (RISC-V Privileged Spec)
|
||||
#define MTVEC_MODE_VECTORED 0x1
|
||||
#define MTVEC_MODE_MASK 0x3 // Mask for the MODE bits (bits [1:0])
|
||||
|
||||
// Align an mtvec base address (clear low 2 bits)
|
||||
#define MTVEC_ALIGN(addr) ((uintptr_t)(addr) & ~MTVEC_MODE_MASK)
|
||||
|
||||
// Construct a complete mtvec value from BASE + MODE
|
||||
#define MTVEC_VALUE(base, mode) (MTVEC_ALIGN(base) | ((mode) & MTVEC_MODE_MASK))
|
||||
|
||||
static inline u64
|
||||
r_mstatus()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue