diff options
Diffstat (limited to 'arch/x86_64/memory')
-rw-r--r-- | arch/x86_64/memory/page_directory.c | 20 | ||||
-rw-r--r-- | arch/x86_64/memory/untyped_memory.c | 52 |
2 files changed, 3 insertions, 69 deletions
diff --git a/arch/x86_64/memory/page_directory.c b/arch/x86_64/memory/page_directory.c index 7030b05..11e4861 100644 --- a/arch/x86_64/memory/page_directory.c +++ b/arch/x86_64/memory/page_directory.c @@ -1,30 +1,16 @@ #include "arch/x86_64/page.h" -#include "arch/x86_64/object.h" #include "device/processor.h" -#include "print.h" #include "memory.h" +#include "boot.h" #include "object.h" #include "string.h" #include "jove.h" #include <stdint.h> -physptr_t s_kpbase(void); - -#if defined(__limine__) - -#include "boot/limine/limine.h" -static struct limine_kernel_address_request s_kaddr_req = { - .id = LIMINE_KERNEL_ADDRESS_REQUEST -}; - -physptr_t s_kpbase(void) { return s_kaddr_req.response->physical_base; } - -#endif - physptr_t vmem_tophys_koff(virtptr_t v) { - return v - (physptr_t)&_kernel_start + s_kpbase(); + return v - (physptr_t)&_kernel_start + _boot_kernel_phys_base; } #define IDENTITY_BASE 0xFFFF800000000000 @@ -106,7 +92,7 @@ vmem_setup(void) s_kernel_pml3[kernel_pml3_i].value = kernel_pml2_base | 2 | 1; s_kernel_pml2[kernel_pml2_i].value = kernel_pml1_base | 2 | 1; for(pmli_t i = kernel_pml1_ib; i < kernel_pml1_ie; i++) { - s_kernel_pml1[i].value = ((i * 0x1000) + s_kpbase()) | 3; + s_kernel_pml1[i].value = ((i * 0x1000) + _boot_kernel_phys_base) | 3; } __asm__ volatile("mov %0, %%cr3":: "r"(kernel_pml4_base)); diff --git a/arch/x86_64/memory/untyped_memory.c b/arch/x86_64/memory/untyped_memory.c deleted file mode 100644 index bd3bc6d..0000000 --- a/arch/x86_64/memory/untyped_memory.c +++ /dev/null @@ -1,52 +0,0 @@ -#include "memory.h" -#include "jove.h" -#include "print.h" -#include "arch/x86_64/object.h" -#include "arch/x86_64/page.h" -#include <stddef.h> - -static struct jove_ObjectDirectory s_untyped_dir = { - .self = { .type = KO_OBJECT_DIRECTORY, .data = 1 }, -}; - -static void s_populate_tables(); - -#if defined(__limine__) - -#include "boot/limine/limine.h" -static volatile struct limine_memmap_request s_memmap_req = { - .id = LIMINE_MEMMAP_REQUEST, - .response = NULL -}; - -void -pmem_setup(void) -{ - _initDirectory.entries[INIT_OBJECT_UNTYPED_DIR] = (objdir_entry_t) { - .type = KO_OBJECT_DIRECTORY, - .data = (uintptr_t)&s_untyped_dir - }; - - if(s_memmap_req.response == NULL) { - klogf("Failed to load physical memory map"); - hcf(); - } - struct limine_memmap_response *response = s_memmap_req.response; - for(size_t i = 0; i < response->entry_count; i++) { - struct limine_memmap_entry *entry = response->entries[i]; - if(entry->type != LIMINE_MEMMAP_USABLE) continue; - - size_t table_index = s_untyped_dir.self.data++; - uintmax_t *untyped_data = vmem_phys_tovirt(entry->base); - objdir_entry_t *table_entry = &s_untyped_dir.entries[table_index]; - - table_entry->type = KO_MEMORY_UNTYPED; - table_entry->data = (uintptr_t)entry->base; - *untyped_data = entry->length; - - klogf("New untyped block %i at %p:%p\n", - table_index, entry->base, entry->length); - } -} - -#endif |