walk multiboot2 memory map
This commit is contained in:
parent
cbd427b14b
commit
bffd652c16
26
src/mbinfo.c
26
src/mbinfo.c
@ -26,6 +26,32 @@ static void mbinfo_process_tag(const multiboot2_info_tag_t * tag)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MULTIBOOT2_INFO_MEMORY_MAP:
|
||||||
|
{
|
||||||
|
multiboot2_info_memory_map_t * mmap_info =
|
||||||
|
(multiboot2_info_memory_map_t *)tag;
|
||||||
|
size_t sz = sizeof(mmap_info->header) +
|
||||||
|
sizeof(mmap_info->entry_size) +
|
||||||
|
sizeof(mmap_info->entry_version);
|
||||||
|
multiboot2_info_memory_map_entry_t * entry = &mmap_info->entries[0];
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
sz += mmap_info->entry_size;
|
||||||
|
if (sz > mmap_info->header.size)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (entry->type == MULTIBOOT2_MEMORY_MAP_TYPE_RAM)
|
||||||
|
{
|
||||||
|
klog_printf("Memory region %16lx : %16lx\n",
|
||||||
|
entry->base_addr,
|
||||||
|
entry->length);
|
||||||
|
}
|
||||||
|
entry = (multiboot2_info_memory_map_entry_t *)((uintptr_t)entry + mmap_info->entry_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case MULTIBOOT2_INFO_FRAMEBUFFER_INFO:
|
case MULTIBOOT2_INFO_FRAMEBUFFER_INFO:
|
||||||
{
|
{
|
||||||
multiboot2_info_framebuffer_info_t * fbinfo =
|
multiboot2_info_framebuffer_info_t * fbinfo =
|
||||||
|
@ -84,16 +84,23 @@ typedef struct {
|
|||||||
uint32_t mem_upper;
|
uint32_t mem_upper;
|
||||||
} multiboot2_info_basic_memory_info_t;
|
} multiboot2_info_basic_memory_info_t;
|
||||||
|
|
||||||
|
#define MULTIBOOT2_MEMORY_MAP_TYPE_RAM 1u
|
||||||
|
#define MULTIBOOT2_MEMORY_MAP_TYPE_ACPI 3u
|
||||||
|
#define MULTIBOOT2_MEMORY_MAP_TYPE_PRESERVE 4u
|
||||||
|
#define MULTIBOOT2_MEMORY_MAP_TYPE_DEFECTIVE 5u
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint64_t base_addr;
|
||||||
|
uint64_t length;
|
||||||
|
uint32_t type;
|
||||||
|
uint32_t _reserved;
|
||||||
|
} multiboot2_info_memory_map_entry_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
multiboot2_info_tag_t header;
|
multiboot2_info_tag_t header;
|
||||||
uint32_t entry_size;
|
uint32_t entry_size;
|
||||||
uint32_t entry_version;
|
uint32_t entry_version;
|
||||||
struct {
|
multiboot2_info_memory_map_entry_t entries[];
|
||||||
uint64_t base_addr;
|
|
||||||
uint64_t length;
|
|
||||||
uint32_t type;
|
|
||||||
uint32_t _reserved;
|
|
||||||
} entries[];
|
|
||||||
} multiboot2_info_memory_map_t;
|
} multiboot2_info_memory_map_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user