Compare commits
No commits in common. "ed9505ae12c9ed1ea8682c32edb00251b81e7506" and "f65ea0f131a6454c2458558ccf27b5b3881d1b3a" have entirely different histories.
ed9505ae12
...
f65ea0f131
3 changed files with 4 additions and 14 deletions
|
|
@ -21,16 +21,6 @@ r_mhartid()
|
||||||
#define MSTATUS_MPP_U (0L << 11)
|
#define MSTATUS_MPP_U (0L << 11)
|
||||||
#define MSTATUS_MIE (1L << 3) // machine-mode interrupt enable.
|
#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
|
static inline u64
|
||||||
r_mstatus()
|
r_mstatus()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -77,8 +77,8 @@ timerinit()
|
||||||
scratch[4] = interval;
|
scratch[4] = interval;
|
||||||
w_mscratch((u64)scratch);
|
w_mscratch((u64)scratch);
|
||||||
|
|
||||||
// Set the machine-mode trap handler. Set to direct, since scause is examined in the handler.
|
// Set the machine-mode trap handler.
|
||||||
w_mtvec(MTVEC_VALUE((u64)timervec, MTVEC_MODE_DIRECT));
|
w_mtvec((u64)timervec);
|
||||||
|
|
||||||
// Enable machine-mode interrupts.
|
// Enable machine-mode interrupts.
|
||||||
w_mstatus(r_mstatus() | MSTATUS_MIE);
|
w_mstatus(r_mstatus() | MSTATUS_MIE);
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,5 @@ typedef unsigned char u8;
|
||||||
typedef unsigned short u16;
|
typedef unsigned short u16;
|
||||||
typedef unsigned int u32;
|
typedef unsigned int u32;
|
||||||
typedef unsigned long u64;
|
typedef unsigned long u64;
|
||||||
typedef unsigned long uintptr_t;
|
|
||||||
typedef u64 pde_t;
|
typedef u64 pde_t;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue