|
|
@ -98,6 +98,7 @@ static void hart_init() |
|
|
#ifndef BBL_BOOT_MACHINE |
|
|
#ifndef BBL_BOOT_MACHINE |
|
|
delegate_traps(); |
|
|
delegate_traps(); |
|
|
#endif /* BBL_BOOT_MACHINE */ |
|
|
#endif /* BBL_BOOT_MACHINE */ |
|
|
|
|
|
setup_pmp(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void plic_init() |
|
|
static void plic_init() |
|
|
@ -187,7 +188,7 @@ void init_other_hart(uintptr_t hartid, uintptr_t dtb) |
|
|
boot_other_hart(dtb); |
|
|
boot_other_hart(dtb); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static inline void setup_pmp(void) |
|
|
void setup_pmp(void) |
|
|
{ |
|
|
{ |
|
|
// Set up a PMP to permit access to all of memory.
|
|
|
// Set up a PMP to permit access to all of memory.
|
|
|
// Ignore the illegal-instruction trap if PMPs aren't supported.
|
|
|
// Ignore the illegal-instruction trap if PMPs aren't supported.
|
|
|
@ -203,8 +204,6 @@ static inline void setup_pmp(void) |
|
|
|
|
|
|
|
|
void enter_supervisor_mode(void (*fn)(uintptr_t), uintptr_t arg0, uintptr_t arg1) |
|
|
void enter_supervisor_mode(void (*fn)(uintptr_t), uintptr_t arg0, uintptr_t arg1) |
|
|
{ |
|
|
{ |
|
|
setup_pmp(); |
|
|
|
|
|
|
|
|
|
|
|
uintptr_t mstatus = read_csr(mstatus); |
|
|
uintptr_t mstatus = read_csr(mstatus); |
|
|
mstatus = INSERT_FIELD(mstatus, MSTATUS_MPP, PRV_S); |
|
|
mstatus = INSERT_FIELD(mstatus, MSTATUS_MPP, PRV_S); |
|
|
mstatus = INSERT_FIELD(mstatus, MSTATUS_MPIE, 0); |
|
|
mstatus = INSERT_FIELD(mstatus, MSTATUS_MPIE, 0); |
|
|
@ -224,8 +223,6 @@ void enter_supervisor_mode(void (*fn)(uintptr_t), uintptr_t arg0, uintptr_t arg1 |
|
|
|
|
|
|
|
|
void enter_machine_mode(void (*fn)(uintptr_t, uintptr_t), uintptr_t arg0, uintptr_t arg1) |
|
|
void enter_machine_mode(void (*fn)(uintptr_t, uintptr_t), uintptr_t arg0, uintptr_t arg1) |
|
|
{ |
|
|
{ |
|
|
setup_pmp(); |
|
|
|
|
|
|
|
|
|
|
|
uintptr_t mstatus = read_csr(mstatus); |
|
|
uintptr_t mstatus = read_csr(mstatus); |
|
|
mstatus = INSERT_FIELD(mstatus, MSTATUS_MPIE, 0); |
|
|
mstatus = INSERT_FIELD(mstatus, MSTATUS_MPIE, 0); |
|
|
write_csr(mstatus, mstatus); |
|
|
write_csr(mstatus, mstatus); |
|
|
|