buddy: add fancy memmap printing to serial output

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-07-17 03:57:39 -04:00
commit 4eb1841158
2 changed files with 21 additions and 2 deletions

View file

@ -167,8 +167,6 @@ static void init_zone(struct mem_zone *zone)
if (zone->len < 0x1000)
return;
kprintf("zone_len: %x\n", zone->len);
struct buddy_zone *bzone = buddy_zones + n_buddy_zones;
n_buddy_zones += 1;

View file

@ -5,6 +5,16 @@
static struct mem_zone zones[128];
static size_t n_zones;
static const char *zone_type_strings[] = {"USABLE",
"RESERVED",
"ACPI_RECLAIMABLE",
"ACPI_NVS",
"BAD_MEMORY",
"BOOTLOADER_RECLAIMABLE",
"EXECUTABLE_AND_MODULES",
"FRAMEBUFFER",
"RESERVED_MAPPED"};
size_t mem_get_zones(struct mem_zone **ret)
{
*ret = zones;
@ -17,8 +27,19 @@ static void mem_init_zones()
bool last_usable = false;
struct mem_zone *last;
static const char *grid[] = {"Entry", "Physical base", "Length", "Type"};
int grid_width = kprintf("| %-5s | %-18s | %-18s | %-22s |\n", grid[0], grid[1], grid[2], grid[3]);
kprintf("|");
for (int i = 0; i < grid_width - 3; i++) {
kprintf("-");
}
kprintf("|\n");
for (int i = 0; i < map->entry_count; i++) {
struct limine_memmap_entry *ent = kern_map_res->entries[i];
if (ARRAY_SIZE(zone_type_strings) > ent->type)
kprintf("| %-5d | 0x%-16x | 0x%-16x | %-22s |\n", i, ent->base, ent->length, zone_type_strings[ent->type]);
bool usable;
switch (ent->type) {