diff options
author | Nathan Ringo <nathan@remexre.com> | 2024-08-25 09:51:28 -0500 |
---|---|---|
committer | Nathan Ringo <nathan@remexre.com> | 2024-08-25 09:51:28 -0500 |
commit | d7f6c738ac1d955a9919421fbb161efc97c6b8f8 (patch) | |
tree | d496aa2903482e9c62c1da094b3f37ec83e1d99d /boards | |
parent | 63775f39e28fdd91d4c5fc6406a73ca694dfffaa (diff) |
Sets up PMP to allow access to all of physical memory.
Diffstat (limited to 'boards')
-rw-r--r-- | boards/qemu-virt/qemu-virt.s | 13 |
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 |