Files
RockOS/kernel/memory/mm.c
2026-06-13 20:43:09 -04:00

37 lines
1.3 KiB
C

#include "multiboot.h"
static uint32_t max_address = 0;
static uint32_t total_available_memory = 0;
void parse_mmap(void* base, uint32_t limit) {
multiboot_mmap_entry* entry = (multiboot_mmap_entry*)base;
void* end = (void*)((uint32_t)base + limit);
while ((void*)entry < end) {
if (entry->type == 1) {
uint32_t region_start = (uint32_t)(entry->addr);
uint32_t region_end = (uint32_t)(entry->addr + entry->len);
if (region_end > max_address) {
max_address = region_end;
}
total_available_memory += entry->len;
// start breaking up the address range
// if it's safe (not kernel, not BIOS structures, etc..), find the corresponding page in our PMM, mark it free
// need to align start and end to 4kb
if (entry->len < 4096) {
continue;
}
for (uint32_t addr = region_start; addr < region_end; addr += 4096) {
// check for physical kernel address range
// check if this address range contains our multiboot structure
// don't allow pages under 1MB
}
}
entry = (multiboot_mmap_entry*)((uint32_t)entry + entry->size + sizeof(entry->size));
}
}