Okay, I don't understand this. Everything seems to be correct. According to the Multiboot Specs (
http://www.gnu.org/software/grub/manual ... iboot.html) This is the structure for the memory map descriptors:
Code: Select all
/*! Defines a memory region descriptor from the memory map */
struct memory_region {
u32 size;
u32 startLo; //base address
u32 startHi;
u32 sizeLo; //length (in bytes)
u32 sizeHi;
u32 type;
} __attribute__( (packed) );
and this seems to work for the first descriptor. According to the manual, size is the size of the structure without the size member (it's wierd i know lol), and does not necessaraly equal 20 (as you would expect). This value is 20 in the first descriptor, and After the first descriptor, all the other descriptors are NULL. every value in the structure is zero. When I use the "displaymem" command in grub I get 6 entry with valid values, but I'm not getting all of those values in my kernel. The first one lines up with grub, though. Here is my printing loop:
Code: Select all
struct memory_region* region = (struct memory_region*)(info->mmap_addr);
u32 i = 0, length = info->mmap_length / sizeof(struct memory_region);
for(i; i < length; ++i)
{
k_printf("\t\t%s: Base Address: 0x%X%X,\n\t\t\tLength: 0x%X%X\n", region->type == 1 ? "Usable RAM" : "Reserved",
region->startHi, region->startLo,
region->sizeHi, region->sizeLo);
pmm_init_region (region->startLo, region->sizeLo);
region += region->size + 4;
}
k_printf: exactly what you would expect. printf style console output
pmm_init_region: Physical Memory Manager function used to free up a region of memory for use
info: pointer to the multiboot info structure that grub passed to me.
I have a screenshot of my output attached to the post. I have been staring at this all morning and most of yesterday, and just can't see anything wrong! Lol I can't move on with out a memory manager
By the way, I just realized that the way I'm calculating "length" isn't going to work if "size" isn't always 20. But that isn't going to affect my output. I will fix it, though. xD