summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/paging.h
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2024-03-11 21:30:31 -0400
committerJon Santmyer <jon@jonsantmyer.com>2024-03-11 21:30:31 -0400
commitd1ff7bcc91886626dc9060ec5fb67ee102ab7c1d (patch)
tree8f0b5cd8aad31089131785dc6e37b659490f9955 /arch/x86_64/paging.h
downloadjove-kernel-d1ff7bcc91886626dc9060ec5fb67ee102ab7c1d.tar.gz
jove-kernel-d1ff7bcc91886626dc9060ec5fb67ee102ab7c1d.tar.bz2
jove-kernel-d1ff7bcc91886626dc9060ec5fb67ee102ab7c1d.zip
usermode capable kernel with logging syscall
Diffstat (limited to 'arch/x86_64/paging.h')
-rw-r--r--arch/x86_64/paging.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/arch/x86_64/paging.h b/arch/x86_64/paging.h
new file mode 100644
index 0000000..1e88a0b
--- /dev/null
+++ b/arch/x86_64/paging.h
@@ -0,0 +1,44 @@
+#ifndef JOVE_ARCH_x86_64_PAGING_H
+#define JOVE_ARCH_x86_64_PAGING_H 1
+
+#include <stdint.h>
+#include "mem/memory.h"
+
+union PageEntry
+{
+ struct {
+ uint8_t p : 1; /* Present */
+ uint8_t rw : 1; /* Read/write. 0 for RO.*/
+ uint8_t us : 1; /* User/supervisor. 0 for DPL3 forbid */
+ uint8_t pwt : 1;
+ uint8_t pcd : 1;
+ uint8_t a : 1; /* Accessed */
+ uint8_t d : 1; /* Dirty */
+ uint8_t ps_pat : 1;
+ uint8_t g : 1; /* Global */
+ uint8_t _r0 : 2;
+ uint8_t r : 1;
+ uint64_t paddr : 35;
+ uint8_t _r1;
+ uint8_t pk : 4;
+ uint8_t xd : 1;
+ }__attribute__((packed));
+ uint64_t value;
+}__attribute__((packed));
+
+struct PageDirectory
+{
+ union PageEntry *pml4_vaddr;
+ physptr_t pml4_paddr;
+ size_t references;
+};
+
+extern struct PageDirectory *mem_current_pd;
+
+void mem_pd_new(struct PageDirectory *pd);
+void mem_pd_clone(struct PageDirectory *pd, struct PageDirectory *parent);
+
+void mem_pd_ensure_4k(struct PageDirectory *pd, uintptr_t virt, uint8_t flg);
+void mem_pd_ensure_range(struct PageDirectory *pd, uintptr_t from, uintptr_t to, uint8_t flg);
+
+#endif