summaryrefslogtreecommitdiff
path: root/kernel/riscv.h
diff options
context:
space:
mode:
authorMole Shang <[email protected]>2024-02-13 19:39:56 +0800
committerMole Shang <[email protected]>2024-02-13 19:39:56 +0800
commit89ef6f717ed4b3e702e5f6f906f58fe1ea27d366 (patch)
tree760cce316675479a6cca77551438e8d2cc5fe9ae /kernel/riscv.h
parentcfae93475dfb4cb5cfe264f4c029136e1447c262 (diff)
parent4a6593f1a6f666c618d303a4858c4c6d31b41c63 (diff)
downloadxv6-labs-89ef6f717ed4b3e702e5f6f906f58fe1ea27d366.tar.gz
xv6-labs-89ef6f717ed4b3e702e5f6f906f58fe1ea27d366.tar.bz2
xv6-labs-89ef6f717ed4b3e702e5f6f906f58fe1ea27d366.zip
Merge branch 'cow' into net
Conflicts: .gitignore Makefile conf/lab.mk kernel/defs.h kernel/syscall.c kernel/vm.c user/pingpong.c user/user.h user/usys.pl
Diffstat (limited to 'kernel/riscv.h')
-rw-r--r--kernel/riscv.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/kernel/riscv.h b/kernel/riscv.h
index 20a01db..7d6eb6e 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
@@ -343,6 +352,8 @@ typedef uint64 *pagetable_t; // 512 PTEs
#define PTE_W (1L << 2)
#define PTE_X (1L << 3)
#define PTE_U (1L << 4) // user can access
+#define PTE_A (1L << 6) // riscv access bit
+#define PTE_C (1L << 8) // RSW low bit, use it to mark whether a page is COW
// shift a physical address to the right place for a PTE.
#define PA2PTE(pa) ((((uint64)pa) >> 12) << 10)