summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--boards/qemu-virt/qemu-virt.s13
1 files changed, 11 insertions, 2 deletions
diff --git a/boards/qemu-virt/qemu-virt.s b/boards/qemu-virt/qemu-virt.s
index 5c58153..063e67c 100644
--- a/boards/qemu-virt/qemu-virt.s
+++ b/boards/qemu-virt/qemu-virt.s
@@ -25,7 +25,7 @@ _start:
# The rest of this function is to get out of machine mode and into
# supervisor mode by fictitiously returning from a trap.
-
+
# First, set MSTATUS.MPP to Supervisor, so that when we execute mret,
# the privilege level will lower to Supervisor.
csrr t0, mstatus
@@ -44,11 +44,20 @@ _start:
li t0, 0xffff
csrw medeleg, t0
csrw mideleg, t0
-
+
# Set SATP.MODE to Bare, and clear the rest of the bits. This disables
# paging in Supervisor mode.
csrw satp, zero
+ # Set PMP0CFG.{R, W, X} to 1, PMP0CFG.A to TOR, and PMP0ADDR to the
+ # maximum value. This allows supervisor mode to access all of physical
+ # memory.
+ li t0, (0b01 << 3) | 0b111
+ csrw pmpcfg0, t0
+ li t0, -1
+ csrw pmpaddr0, t0
+
+ # Jump to supervisor mode.
mret
.size _start, . - _start