diff --git a/stage23/mm/pmm.s2.c b/stage23/mm/pmm.s2.c index 2d968221..36b78a7e 100644 --- a/stage23/mm/pmm.s2.c +++ b/stage23/mm/pmm.s2.c @@ -216,7 +216,18 @@ void init_memmap(void) { panic("Memory map exhausted."); } - memmap[memmap_entries++] = e820_map[i]; + memmap[memmap_entries] = e820_map[i]; + + if (memmap[memmap_entries].base < 0x1000) { + if (memmap[memmap_entries].base + memmap[memmap_entries].length <= 0x1000) { + continue; + } + + memmap[memmap_entries].length -= 0x1000 - memmap[memmap_entries].base; + memmap[memmap_entries].base = 0x1000; + } + + memmap_entries++; } // Allocate bootloader itself @@ -226,8 +237,6 @@ void init_memmap(void) { sanitise_entries(false); allocations_disallowed = false; - - print_memmap(memmap, memmap_entries); } #endif @@ -286,6 +295,15 @@ void init_memmap(void) { memmap[memmap_entries].base = entry->PhysicalStart; memmap[memmap_entries].length = entry->NumberOfPages * 4096; + if (memmap[memmap_entries].base < 0x1000) { + if (memmap[memmap_entries].base + memmap[memmap_entries].length <= 0x1000) { + continue; + } + + memmap[memmap_entries].length -= 0x1000 - memmap[memmap_entries].base; + memmap[memmap_entries].base = 0x1000; + } + memmap_entries++; }