I am writing a higher-half 32-bit kernel loaded at 0xC0000000 (3GByte) virtual address and I am using multiboot_info struct to get the physical memory map. When I use #1, the first mmap_addr I'm getting is 0x9000 but I'm not able to examine the address using gdb. By hit and trail, I wrote #2 and it works perfectly. May I know if what I did was correct? And how exactly is it correct? Thank you.
#1
void get_mbmmap(void){
memory_map_t* mmap = (memory_map_t*)(mbinfo_addr -> mmap_addr);
while((uint32_t)mmap < mbinfo_addr->mmap_addr + mbinfo_addr->mmap_length)
mmap = (memory_map_t*)((uint32_t)mmap + mmap->size + sizeof(mmap->size));}
#2
void get_mbmmap(void){
memory_map_t* mmap = (memory_map_t*)(mbinfo_addr -> mmap_addr + 0xC0000000);
while((uint32_t)mmap < mbinfo_addr->mmap_addr + 0xC0000000 + mbinfo_addr->mmap_length)
mmap = (memory_map_t*)((uint32_t)mmap + mmap->size + sizeof(mmap->size));
}