summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/hal/paging.h
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-09-04 11:31:40 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-09-04 11:31:40 -0400
commit8251da342161767fe203627223ccd4a7026701c6 (patch)
treeaf2db0f11b0ea8ad35f88663a855bab39a80f679 /arch/x86_64/hal/paging.h
downloadjove-kernel-8251da342161767fe203627223ccd4a7026701c6.tar.gz
jove-kernel-8251da342161767fe203627223ccd4a7026701c6.tar.bz2
jove-kernel-8251da342161767fe203627223ccd4a7026701c6.zip
initial commit. working on tasking
Diffstat (limited to 'arch/x86_64/hal/paging.h')
-rw-r--r--arch/x86_64/hal/paging.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/arch/x86_64/hal/paging.h b/arch/x86_64/hal/paging.h
new file mode 100644
index 0000000..54df1eb
--- /dev/null
+++ b/arch/x86_64/hal/paging.h
@@ -0,0 +1,52 @@
+#ifndef _JOVE_x86_64_HAL_PAGING_H
+#define _JOVE_x86_64_HAL_PAGING_H 1
+
+#include "jove.h"
+#include <stdint.h>
+
+typedef union page_table_entry
+{
+ struct {
+ uint8_t p : 1;
+ uint8_t rw : 1;
+ uint8_t u : 1;
+ uint8_t pwt : 1;
+ uint8_t pcd : 1;
+ uint8_t a : 1;
+ uint8_t d : 1;
+ uint8_t ps : 1;
+ uint8_t g : 1;
+ uint8_t ign_0 : 2;
+ uint8_t r : 1;
+ uint64_t paddr : 35;
+ uint8_t ign_1 : 4;
+ uint8_t pkey : 4;
+ uint8_t xd : 1;
+ };
+ uint64_t value;
+} PACKED page_t;
+
+#define PAGE_PRESENT 0b1
+#define PAGE_WRITEABLE 0b10
+#define PAGE_USER 0b100
+#define PAGE_WRITETHROUGH 0b1000
+#define PAGE_CACHEDISABLE 0b10000
+#define PAGE_ACCESSED 0b100000
+#define PAGE_DIRTY 0b1000000
+#define PAGE_PS 0b10000000
+#define PAGE_GLOBAL 0b100000000
+#define PAGE_XD (1ULL << 63)
+
+extern void *_kernel_physptr;
+
+#define PMLI_SHL(l) (12 + (l * 9))
+#define PMLI_MASK(l) (~0xFFFF << PMLI_SHL(l))
+
+#define IDENT_VIRT_BASE 0xFFFF800000000000ULL
+#define KERNEL_VIRT_BASE 0xFFFFFFFF80000000ULL
+#define KPTR_TOPHYS(v) (v - KERNEL_VIRT_BASE + (uintptr_t)_kernel_physptr)
+
+uintptr_t paging_get_pml4(void);
+void paging_pml4_init(void);
+
+#endif