Basically,
Code: Select all
if(MBT->flags & (1 << 6))
{
unsigned long TotalMapAddress = MBT->mmap_addr;
unsigned long TotalMapLength = MBT->mmap_length;
puts("----\n");
puthex(TotalMapAddress);
puts("\n");
puthex(TotalMapLength);
puts("\n----");
puts("\n\n");
memory_map_t *MemMap = (memory_map_t*)MBT->mmap_addr;
unsigned long CurrentReadingAddress = TotalMapAddress;
while(MemMap < TotalMapAddress + TotalMapLength)
{
puthex(MemMap);
puts(" -- ");
putnum(MemMap->type);
puts(" == ");
puthex(MemMap->base_addr_low);
puts(" == ");
puthex(MemMap->length_low);
puts("\n");
if(MemMap->type == 1)
{
//UsableMemoryEnd = CurrentReadingAddress + MemMap->size;
}
//CurrentReadingAddress += MemMap->size;
MemMap = (memory_map_t*)((unsigned long)MemMap + MemMap->size + sizeof(unsigned int));
}
}
1. Is this the right way of getting the memory map?
2. Is this a valid memory map?
Code: Select all
0x359A0 -- 1 == 0x1 == 0x9F400
0x359B8 -- 2 == 0x9F400 == 0xC00
0x359D0 -- 2 == 0xF0000 == 0x10000
0x359E8 -- 1 == 0x100000 == 0x1FEFE000
0x35A00 -- 2 == 0x1FFE000 == 0x2000
0x35A18 -- 2 == 0xFFFC0000 == 0x40000
The second field is the type, which leads to another question:
2. Is the 'type' field from GRUB memory map the same as the type field returned from INT 0x15, EAX=0xE820?
3. There seems to be an apparent lack of usable memory; Whether I pass -m 2 or -m 64 to qemu-system-x86_64, I get the same values.
4. Is that simply a problem with QEMU? I get different values on VMWare Fusion:
Code: Select all
0x359A0 -- 1 == 0x1 == 0x9F800
0x359B8 -- 2 == 0x9F800 == 0x800
0x359D0 -- 2 == 0xDC000 == 0x2400
0x359E8 -- 1 == 0x100000 == 0xFDF0000
0x35A00 -- 3 == 0xFEF0000 == 0xF000
0x35A18 -- 4 == 0xFEFF000 == 0x1000
0x35A30 -- 1 == 0xFF00000 == 0x100000
0x35A48 -- 2 == 0xE0000000 == 0x10000000
0x35A60 -- 2 == 0xFEC00000 == 0x10000
0x35A78 -- 2 == 0xFEE00000 == 0x1000
0x35A90 -- 2 == 0xFFFE0000 == 0x20000
With 4 MB (I'll post a screenie) Some values are different. However, there seems to be memory beyond whatever MB I allocate to the VM. I can't test this on hardware because I have a mac.
EDIT:
4. Is there a way to verify the memory map?