summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kernel/riscv.h12
-rw-r--r--kernel/start.c5
2 files changed, 17 insertions, 0 deletions
diff --git a/kernel/riscv.h b/kernel/riscv.h
index 0aec003..33b4335 100644
--- a/kernel/riscv.h
+++ b/kernel/riscv.h
@@ -181,6 +181,18 @@ w_mtvec(uint64 x)
asm volatile("csrw mtvec, %0" : : "r" (x));
}
+static inline void
+w_pmpcfg0(uint64 x)
+{
+ asm volatile("csrw pmpcfg0, %0" : : "r" (x));
+}
+
+static inline void
+w_pmpaddr0(uint64 x)
+{
+ asm volatile("csrw pmpaddr0, %0" : : "r" (x));
+}
+
// use riscv's sv39 page table scheme.
#define SATP_SV39 (8L << 60)
diff --git a/kernel/start.c b/kernel/start.c
index 1876680..938e837 100644
--- a/kernel/start.c
+++ b/kernel/start.c
@@ -38,6 +38,11 @@ start()
w_mideleg(0xffff);
w_sie(r_sie() | SIE_SEIE | SIE_STIE | SIE_SSIE);
+ // configure Physical Memory Protection to give supervisor mode
+ // access to all of physical memory.
+ w_pmpaddr0(0x3fffffffffffffull);
+ w_pmpcfg0(0xf);
+
// ask for clock interrupts.
timerinit();