summaryrefslogtreecommitdiff
path: root/riscv.h
diff options
context:
space:
mode:
Diffstat (limited to 'riscv.h')
-rw-r--r--riscv.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/riscv.h b/riscv.h
index 92fa6e3..5e54935 100644
--- a/riscv.h
+++ b/riscv.h
@@ -129,7 +129,7 @@ w_sscratch(uint64 x)
asm("csrw sscratch, %0" : : "r" (x));
}
-// Supervisor trap cause
+// Supervisor Trap Cause
static inline uint64
r_scause()
{
@@ -138,6 +138,15 @@ r_scause()
return x;
}
+// Supervisor Trap Value
+static inline uint64
+r_stval()
+{
+ uint64 x;
+ asm("csrr %0, stval" : "=r" (x) );
+ return x;
+}
+
#define PGSIZE 4096 // bytes per page
#define PGSHIFT 12 // bits of offset within a page