I'm new to OS development, and currently I try to write the physical memory manager.
Therefore I want to use the memory map from GRUB.
Here's my code for looping through the memory-map structs (I'm using the struct from multiboot.h of the osdev-page):
Code: Select all
uint64_t mem_begin;
uint64_t mem_range;
uint64_t mem_end;
while(mmap < (memory_map_t*) (mbt->mmap_addr + mbt->mmap_length))
{
mem_begin = mmap->base_addr_low;
mem_begin |= mmap->base_addr_high << 32;
mem_range = mmap->length_high << 32;
mem_range |= mmap->length_low;
//mem_end = mem_begin + mem_range;
printf("%x%x\n", mmap->length_high, mmap->length_low);
printf("0x%x%x to 0x%x%x -> ", mem_begin, (mem_begin >> 32), mem_range, (mem_range >> 32));
if(mmap->type == 1)
printf("available\n");
else
printf("reserved\n");
mmap = (memory_map_t*) ((uint32_t)mmap + mmap->size + sizeof(uint32_t));
}
0x9FC00
0x00 to 0x00 ->available
0x400
0x9FC000 to 0x00 -> reserverd
... and so on
as you can see, if I use length_high and _low for the output, I get a "valid" output.
(I have to use (mem_begin >> 32) in the printf, because it has no support for 64 bit variables yet.
I'm wondering why I get a "vaild" output for the mem_begin, but not for mem_range although I use the same
code for both.
Can anyone help me please?
PS: sorry for my bad english