From 45d9495e77dba212551ae9bc8e09b51e9ed6d324 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 23 Nov 2019 00:36:28 +0100 Subject: Tried implementing memory based paging... Also did many other fixes/improvements. While I think I did most things correct, the ACPI doesn't work anymore (triple fault) and the resolution detection fails with 0x2... :c --- src/kernel/paging/paging.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/kernel/paging/paging.c') diff --git a/src/kernel/paging/paging.c b/src/kernel/paging/paging.c index fa0610e..a08d253 100644 --- a/src/kernel/paging/paging.c +++ b/src/kernel/paging/paging.c @@ -1,8 +1,10 @@ #include #include #include +#include #include +int paging_enabled = 0; uint32_t page_directory[1024] __attribute__((aligned(4096))); uint32_t page_tables[1024][1024] __attribute__((aligned(4096))); @@ -18,26 +20,20 @@ void paging_install() { } // TODO: Calculate max memory - // paging_set_present(0, memory_get_all() >> 2); - paging_set_present(0, 0x1000000); - - paging_set_used(0, ((uint32_t) ASM_KERNEL_END >> 12) + 1); + paging_set_present(0, memory_get_all() >> 2); // /4 + paging_set_used(0, ((uint32_t) ASM_KERNEL_END >> 12) + 1); // /4096 paging_enable(); + serial_write_dec(memory_get_all() / 1024); vga_log("Installed paging", 4); } -int paging_enabled() { - uint32_t cr0; - asm volatile("mov %%cr0, %0": "=r"(cr0)); - return (cr0 | 0x80000000) == cr0; -} - void paging_disable() { uint32_t cr0; asm volatile("mov %%cr0, %0": "=r"(cr0)); cr0 &= 0x7fffffff; asm volatile("mov %0, %%cr0"::"r"(cr0)); + paging_enabled = 0; } void paging_enable() { @@ -46,6 +42,7 @@ void paging_enable() { asm volatile("mov %%cr0, %0": "=r"(cr0)); cr0 |= 0x80000000; asm volatile("mov %0, %%cr0"::"r"(cr0)); + paging_enabled = 1; } inline void invlpg(uint32_t addr) { -- cgit v1.2.3