From 64f29facc5699bcc14afe17aff105cb24fbaa830 Mon Sep 17 00:00:00 2001 From: vanten-s Date: Sun, 23 Feb 2025 18:26:02 +0100 Subject: [PATCH] Added some Page Table stuff :3 --- arch/i686/paging.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/arch/i686/paging.c b/arch/i686/paging.c index fd8c586..c9ce1dd 100644 --- a/arch/i686/paging.c +++ b/arch/i686/paging.c @@ -15,13 +15,36 @@ struct x86_Page_Directory { bool available_2: 1; bool page_size: 1; uint8_t available_1 : 4; - uint32_t address : 20; + uint32_t address : 20; // Multiply by 0x1000 } __attribute__((packed)); -extern uint32_t boot_page_directory[1024] __attribute__((aligned(4096))); +struct x86_Page_Table { + bool present: 1; + bool read_write: 1; + bool user_supervisor: 1; + bool write_through: 1; + bool cache_disable: 1; + bool accesed: 1; + bool dirty: 1; + bool page_attribute_table: 1; + bool global: 1; + uint8_t available_1 : 3; + uint32_t address : 20; // Multiply by 0x1000 +} __attribute__((packed)); + +extern struct x86_Page_Directory boot_page_directory[1024] __attribute__((aligned(4096))); + +static struct x86_Page_Table* get_table(uint16_t index) { + struct x86_Page_Table* table = (struct x86_Page_Table*)(boot_page_directory[index].address * 0x1000 + 0xC0000000); + return table; +} void setup_paging() { - size_t size = sizeof(boot_page_directory[0]); - struct x86_Page_Directory *directory = (struct x86_Page_Directory*) boot_page_directory; - uint32_t table_1 = boot_page_directory[768]; + struct x86_Page_Table* kernel = get_table(768); + for (int i = 0; i < 1024; i++) { + if (kernel[i].address != 0) { + struct x86_Page_Table test = kernel[i]; + } + } } +