diff options
author | Marvin Borner | 2019-11-23 00:36:28 +0100 |
---|---|---|
committer | Marvin Borner | 2019-11-23 00:36:28 +0100 |
commit | 45d9495e77dba212551ae9bc8e09b51e9ed6d324 (patch) | |
tree | 1e8ead9a55b41fa009c28823ca7a9ac0b1b5b2fe /src/kernel/paging | |
parent | 4b178c0feb4c415be36be0e4c0def8c447ed42af (diff) |
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
Diffstat (limited to 'src/kernel/paging')
-rw-r--r-- | src/kernel/paging/paging.c | 17 | ||||
-rw-r--r-- | src/kernel/paging/paging.h | 2 |
2 files changed, 9 insertions, 10 deletions
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 <stdint.h> #include <kernel/paging/paging.h> #include <kernel/system.h> +#include <kernel/io/io.h> #include <kernel/lib/lib.h> +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) { diff --git a/src/kernel/paging/paging.h b/src/kernel/paging/paging.h index 85ef120..270c082 100644 --- a/src/kernel/paging/paging.h +++ b/src/kernel/paging/paging.h @@ -21,6 +21,8 @@ #define PT_GLOBAL 1 << 8 #define PT_USED 1 << 9 +int paging_enabled; + void paging_install(); void paging_enable(); |