Merge pull request #109 from vmttmv/bl-e820

BL: Query and store e820 memory map
This commit is contained in:
2026-02-02 07:49:09 -08:00
committed by GitHub
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;
}
}

View File

@@ -7,6 +7,7 @@ typedef struct {
uint64_t base_addr;
uint64_t length;
uint32_t type;
uint32_t ext;
} __attribute__((packed)) memory_map_entry_t;
uint32_t get_memory_map(memory_map_entry_t *map, uint32_t max_entries);