BL: Query and store e820 memory map

- bl stage 1: move gdt+pm setup to stage 2 (avoids mode switching)
- bl stage 2: at entry query e820 table from bios, then setup gdt+pm
- kernel/memmap: pad map entry to 24 bytes, as exported by bl
- kernel/memmap: map copy (gbowne1)
- Makefile: facilitate placing the memory map at a known location
- Update bl docs
This commit is contained in:
vmttmv
2026-01-15 21:39:53 +02:00
parent f572101d6b
commit 4fa82854dd
6 changed files with 98 additions and 53 deletions

View File

@@ -1,21 +1,18 @@
#include "memmap.h"
#define BOOTLOADER_MEMMAP_COUNT_ADDR MEMMAP_BASE
#define BOOTLOADER_MEMMAP_ADDR (MEMMAP_BASE + 4)
uint32_t get_memory_map(memory_map_entry_t *map, uint32_t max_entries) {
// Read the number of entries found by the bootloader
uint32_t entries_found = *(uint32_t*)BOOTLOADER_MEMMAP_COUNT_ADDR;
memory_map_entry_t *bios_data = (memory_map_entry_t*)BOOTLOADER_MEMMAP_ADDR;
uint32_t count = 0;
if (max_entries >= 1) {
map[count].base_addr = 0x00000000;
map[count].length = 0x0009FC00;
map[count].type = 1;
count++;
}
if (max_entries >= 2) {
map[count].base_addr = 0x00100000;
map[count].length = 0x1FF00000;
map[count].type = 1;
while (count < entries_found && count < max_entries) {
map[count] = bios_data[count];
count++;
}
return count;
}
}