diff options
Diffstat (limited to 'arch/x86_64/boot/limine/memorymap.c')
-rw-r--r-- | arch/x86_64/boot/limine/memorymap.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/arch/x86_64/boot/limine/memorymap.c b/arch/x86_64/boot/limine/memorymap.c new file mode 100644 index 0000000..ec0f545 --- /dev/null +++ b/arch/x86_64/boot/limine/memorymap.c @@ -0,0 +1,45 @@ +#include "boot.h" +#include "limine.h" +#include "object.h" +#include "print.h" +#include "jove.h" +#include "arch/x86_64/page.h" + +static struct jove_ObjectDirectory s_untyped_dir = { + .self = { .type = KO_OBJECT_DIRECTORY, .data = 1 }, +}; + +static volatile struct limine_memmap_request s_memmap_req = { + .id = LIMINE_MEMMAP_REQUEST +}; + +void +boot_populate_untyped(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); + } +} + |