Nucleus
Barry Paging structure lookup 38845f1 (3 years, 3 months ago)
diff --git a/memory/paging.c b/memory/paging.c
index 10d20d5..ef591f1 100644
--- a/memory/paging.c
+++ b/memory/paging.c
@@ -12,6 +12,7 @@
void copy_page_frame(uintptr_t src, uintptr_t dest);
+page_t zeroFrame;
static page_dir_t kernelDir;
/* Switch page directory */
@@ -21,6 +22,19 @@ switch_dir(page_dir_t dir)
asm volatile("mov %0, %%cr3" :: "r" (dir));
}
+/* Get a page mapping */
+page_t
+get_page(uintptr_t vaddr)
+{
+ page_t *mappings = (void *) 0xFFC00000;
+ page_table_t *tables = (void *) 0xFFFFF000;
+ uintptr_t address = vaddr >> 12;
+ uint32_t tbl = address / 1024;
+ if (!(tables[tbl] & PDE_PRESENT))
+ return 0x00000000;
+ return mappings[address];
+}
+
/* Set a page mapping */
void
set_page(uintptr_t vaddr, page_t page)
@@ -134,6 +148,8 @@ init_paging(void)
uintptr_t stk;
for (stk = 0xF0400000; stk < 0xF0800000; stk += PAGE_SIZE)
set_page(stk, alloc_frame() | PTE_PRESENT | PTE_WRITE);
+
+ zeroFrame = alloc_frame();
}
/* Enable paging on the current CPU */
diff --git a/memory/paging.h b/memory/paging.h
index 636ca86..284d0e3 100644
--- a/memory/paging.h
+++ b/memory/paging.h
@@ -3,6 +3,9 @@
#include <stdint.h>
#include <nucleus/cpu.h>
+#include <nucleus/memory.h>
+
+extern page_t zeroFrame;
void early_page_fault_handler(struct InterruptFrame *frame, uint32_t err);