What do the mmaps provided in multiboot information mean?

165 views Asked by At

From the multiboot 1 documentation:

If bit 6 in the ‘flags’ word is set, then the ‘mmap_*’ fields are valid, and indicate the address and length of a buffer containing a memory map of the machine provided by the BIOS. ‘mmap_addr’ is the address, and ‘mmap_length’ is the total size of the buffer.

I see that each mmap has an associated type:

‘type’ is the variety of address range represented, where a value of 1 indicates available RAM, value of 3 indicates usable memory holding ACPI information, value of 4 indicates reserved memory which needs to be preserved on hibernation, value of 5 indicates a memory which is occupied by defective RAM modules and all other values currently indicated a reserved area.

What exactly do each of these types mean in the context of a memory map of the machine provided by the BIOS? Does type 1 memory refer to physical memory that was used by something like the bootloader (GRUB in my case), but is now free for use? Does type 3 memory indicate some parseable data about the machine this is running on? Does type 5 mean that there is a range of physical addresses that just can't be used (hence the defective)?

Up until now I think I've been overwriting these mmaps without thinking about what they do. If I were to dump them using the example multiboot kernel code, I get something like this:

mmap_addr = 0x00009000, mmap_length = 0x00000090
 size = 0x00000014, base_addr = 0x0000000000000000, length = 0x000000000009fc00, type = 0x00000001
 size = 0x00000014, base_addr = 0x000000000009fc00, length = 0x0000000000000400, type = 0x00000002
 size = 0x00000014, base_addr = 0x00000000000f0000, length = 0x0000000000010000, type = 0x00000002
 size = 0x00000014, base_addr = 0x0000000000100000, length = 0x0000000007ee0000, type = 0x00000001
 size = 0x00000014, base_addr = 0x0000000007fe0000, length = 0x0000000000020000, type = 0x00000002
 size = 0x00000014, base_addr = 0x00000000fffc0000, length = 0x0000000000040000, type = 0x00000002

but I don't know what these mmaps are supposed to represent.

1

There are 1 answers

1
BrockLee On

It looks like I was initially right (at least for type 1 mem). That mem type seems to indicate physical RAM that is available for me to write to after bootloading. Anything of type 2 seems to be physical mem I shouldn't/can't write to. I found this out by accidentally mapping some virtual mem to a physical page in a type 2 mmap. 3, 4, and 5 I'm still not entirely sure what they are for, but I've ignored them for now since I know at least type 1 mem is useable.