summaryrefslogtreecommitdiff
path: root/kernel/riscv.h
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/riscv.h')
-rw-r--r--kernel/riscv.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/kernel/riscv.h b/kernel/riscv.h
index 33fa9ee..5ede50a 100644
--- a/kernel/riscv.h
+++ b/kernel/riscv.h
@@ -327,6 +327,15 @@ sfence_vma()
asm volatile("sfence.vma zero, zero");
}
+// read the frame pointer of currently executing func
+static inline uint64
+r_fp()
+{
+ uint64 x;
+ asm volatile("mv %0, s0" : "=r" (x) );
+ return x;
+}
+
typedef uint64 pte_t;
typedef uint64 *pagetable_t; // 512 PTEs