aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv/include/vmem.h
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2021-10-01 20:36:15 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2021-10-01 20:36:15 +0300
commitb30ee14270a44e48167934b9b3923b4280bdc855 (patch)
treefe900fd442e834f857927e9094ce7cbdda59b9fd /arch/riscv/include/vmem.h
parent2d173beb3392aff35c8a33f4ac001bf63bb9adc6 (diff)
downloadkmi-b30ee14270a44e48167934b9b3923b4280bdc855.tar.gz
kmi-b30ee14270a44e48167934b9b3923b4280bdc855.zip
First jump to virtual memory!
+ Lots of bughunting to do, probably lots of off-by-one and so on errors, and I make a lot of naive and possibly dangerous assumptions. But cool start nonetheless. Should also come up with some method of exchanging data between the init and actual kernel, probably some struct of some sort. TODO
Diffstat (limited to 'arch/riscv/include/vmem.h')
-rw-r--r--arch/riscv/include/vmem.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/arch/riscv/include/vmem.h b/arch/riscv/include/vmem.h
new file mode 100644
index 0000000..3c27c7b
--- /dev/null
+++ b/arch/riscv/include/vmem.h
@@ -0,0 +1,29 @@
+#ifndef APOS_RISCV_VMAP_H
+#define APOS_RISCV_VMAP_H
+
+#include <apos/sizes.h>
+#include <apos/types.h>
+#include <apos/attrs.h>
+
+#define VM_V (1 << 0)
+#define VM_R (1 << 1)
+#define VM_W (1 << 2)
+#define VM_X (1 << 3)
+#define VM_U (1 << 4)
+#define VM_G (1 << 5)
+#define VM_A (1 << 6)
+#define VM_D (1 << 7)
+
+typedef size_t vaddr_t;
+struct __packed vm_branch_t {
+ struct vm_branch_t *leaf[512];
+};
+
+void map_vmem(struct vm_branch_t *branch,
+ paddr_t paddr, vaddr_t vaddr,
+ uint8_t flags, enum mm_order_t order);
+
+void unmap_vmem(struct vm_branch_t *branch, vaddr_t vaddr, enum mm_order_t order);
+
+
+#endif /* APOS_RISCV_VMAP_H */