Rename sbadaddr to satp
[riscv-tests.git] / debug / programs / mprv.S
index df346b3504ddc291ed3282424b2a0278c9a64f5f..8ec261eee98d858498439f28195059431b25540c 100644 (file)
@@ -1,18 +1,22 @@
-#include "../riscv/encoding.h"
+#include "encoding.h"
 #define PGSHIFT         12
 
-        .global         _start
+        .global         main
 
         .section        .text
-_start:
+main:
         # Set up a page table entry that maps 0x0... to 0x8...
         la      t0, page_table
         srli    t0, t0, PGSHIFT
-        csrw    CSR_SPTBR, t0
+        csrw    CSR_SATP, t0
 
         # update mstatus
         csrr    t1, CSR_MSTATUS
-        li      t0, (MSTATUS_MPRV | (VM_SV39 << 24))
+#if XLEN == 32
+        li      t0, (MSTATUS_MPRV | (SATP_MODE_SV32 << 24))
+#else
+        li      t0, (MSTATUS_MPRV | (SATP_MODE_SV39 << 24))
+#endif
         #li      t0, ((VM_SV39 << 24))
         or      t1, t0, t1
         csrw    CSR_MSTATUS, t1
@@ -34,5 +38,9 @@ data:
 
         .balign 0x1000
 page_table:
-        .word   ((0x80000000 >> 2) | PTE_V | PTE_TYPE_URWX_SRWX)
+#if XLEN == 32
+        .word   ((0x80000000 >> 2) | PTE_V | PTE_R | PTE_W | PTE_X | PTE_G | PTE_U)
+#else
+        .word   ((0x80000000 >> 2) | PTE_V | PTE_R | PTE_W | PTE_X | PTE_G | PTE_U)
         .word   0
+#endif