diff options
| author | Jon Santmyer <jon@jonsantmyer.com> | 2026-09-04 11:31:40 -0400 |
|---|---|---|
| committer | Jon Santmyer <jon@jonsantmyer.com> | 2026-09-04 11:31:40 -0400 |
| commit | 8251da342161767fe203627223ccd4a7026701c6 (patch) | |
| tree | af2db0f11b0ea8ad35f88663a855bab39a80f679 /boot/limine/memorymap.c | |
| download | jove-kernel-8251da342161767fe203627223ccd4a7026701c6.tar.gz jove-kernel-8251da342161767fe203627223ccd4a7026701c6.tar.bz2 jove-kernel-8251da342161767fe203627223ccd4a7026701c6.zip | |
initial commit. working on tasking
Diffstat (limited to 'boot/limine/memorymap.c')
| -rw-r--r-- | boot/limine/memorymap.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/boot/limine/memorymap.c b/boot/limine/memorymap.c new file mode 100644 index 0000000..905ff3a --- /dev/null +++ b/boot/limine/memorymap.c @@ -0,0 +1,73 @@ +#include "hal/obj.h" +#include "limine.h" +#include "hal/memory.h" +#include "hal/obj.h" +#include "lib/panic.h" +#include "init.h" +#include "lib/printf.h" + +extern struct limine_memmap_response *_limine_memmap_resp; +static jove_objdir_t s_untyped_objdir; + +#define MEMMAP_MAX_ENTRIES 255 + +static const char *limine_mmap_entry_type_str[9] = { + "USABLE", + "RESERVED", + "ACPI RECLAIMABLE", + "ACPI NVS", + "BAD", + "LIMINE RECLAIMABLE", + "KERNEL", + "FRAMEBUFFER", + "ACPI TABLES" +}; + +void +mem_setup_untyped(void) +{ + { + jove_owned_obj_t *untyped_objdir_obj = obj_take(objdir_getlocal(_rootdir_obj, ROOTDIR_UNTYPED_I)); + obj_settype(untyped_objdir_obj, JOVE_OBJ_OBJDIR); + obj_setvalue(untyped_objdir_obj, (uintptr_t)&s_untyped_objdir); + obj_release(untyped_objdir_obj); + } + + if(_limine_memmap_resp == NULL) { + kpanic("Limine failed to provide memory map.\n"); + } + + kprintf("Memory map provided by Limine:\n"); + + size_t untyped_i = 0; + uintptr_t highest_phys = 0; + for(size_t i = 0; i < _limine_memmap_resp->entry_count; i++) { + struct limine_memmap_entry *entry = _limine_memmap_resp->entries[i]; + kprintf("Limine: %p : %p %s\n", entry->base, entry->length, limine_mmap_entry_type_str[entry->type]); + + if(entry->type == LIMINE_MEMMAP_USABLE || + entry->type == LIMINE_MEMMAP_ACPI_RECLAIMABLE || + entry->type == LIMINE_MEMMAP_BOOTLOADER_RECLAIMABLE) + { + + if(entry->base == 0) continue; + if(entry->base + entry->length > highest_phys) highest_phys = entry->base + entry->length; + + { + jove_owned_obj_t *untyped_obj = obj_take(&s_untyped_objdir.entries[untyped_i++]); + obj_settype(untyped_obj, JOVE_OBJ_UNTYPED); + obj_setvalue(untyped_obj, entry->base); + + jove_untyped_t *untyped_data = obj_deref(untyped_obj); + untyped_data->limit = entry->length; + obj_release(untyped_obj); + } + + if(untyped_i > MEMMAP_MAX_ENTRIES){ + kprintf("!!!Provided memory map exceeds kernel limits. Some memory may not be accessable!!!"); + break; + } + } + } + kprintf("Highest physical address: %p\n", highest_phys); +} |
