First steps: getting memory map from Limine request and looking at it

This commit is contained in:
2025-12-30 21:33:38 +01:00
parent cf4915d9f4
commit 8f5e2eae3e
10 changed files with 113 additions and 7 deletions

View File

@@ -1,5 +1,8 @@
#include <stddef.h>
#include <stdint.h>
#include <limine.h>
#include "../../kernel.h"
#include "../../string/string.h"
// We won't be linked to standard library, but still need the basic mem* functions
// so everything goes allright with the compiler
@@ -67,4 +70,47 @@ int memcmp(const void* s1, const void* s2, size_t n)
}
return 0;
}
// Display the memmap so we see how the memory is laid out at handoff
void memmap_display(struct limine_memmap_response* response)
{
DEBUG("Got memory map from Limine: revision %u, %u entries", response->revision, response->entry_count);
for (size_t i=0; i<response->entry_count; i++)
{
struct limine_memmap_entry* entry = response->entries[i];
char type[32] = {0};
switch(entry->type)
{
case LIMINE_MEMMAP_USABLE:
strcpy(type, "USABLE");
break;
case LIMINE_MEMMAP_RESERVED:
strcpy(type, "RESERVED");
break;
case LIMINE_MEMMAP_ACPI_RECLAIMABLE:
strcpy(type, "ACPI_RECLAIMABLE");
break;
case LIMINE_MEMMAP_ACPI_NVS:
strcpy(type, "ACPI_NVS");
break;
case LIMINE_MEMMAP_BAD_MEMORY:
strcpy(type, "BAD_MEMORY");
break;
case LIMINE_MEMMAP_BOOTLOADER_RECLAIMABLE:
strcpy(type, "BOOTLOADER_RECLAIMABLE");
break;
case LIMINE_MEMMAP_KERNEL_AND_MODULES:
strcpy(type, "KERNEL_AND_MODULES");
break;
case LIMINE_MEMMAP_FRAMEBUFFER:
strcpy(type, "FRAMEBUFFER");
break;
default:
strcpy(type, "UNKNOWN");
break;
}
DEBUG("entry %u: [%016x | %u bytes] - %s", i, entry->base, entry->length, type);
}
}