Weird mmap entries...
Posted: Mon Aug 16, 2010 4:45 am
This is my pmm's init function for multiboot memory maps. It's supposed to get the highest valid page in ver_page, then go through the mmap again to reserve all pages between the highest valid one and 0. It doesn't seem to work right, ver_page is always 0, because there are no valid(MULT..._AVAILABLE) entries. I know memory is limited to 64MB, but how do I determine that when the available memory ranges are not reported?
Notice that a lot is commented out. There are bugs .
Output in attached image.[DELETED]
Code: Select all
void pmem_multiboot_init(multiboot_memory_map_t* mmap, int len)
{
unsigned int i, ver_pages = 0;
struct multiboot_mmap_entry* mmap_entry;
for(i = 0;i < len;i += (mmap->size + sizeof(mmap->size)))
{
printf("Base: %x Len: %x Type: %d\n", (unsigned int)mmap_entry->addr, (unsigned int)mmap_entry->len, mmap->type);
mmap_entry = (struct multiboot_mmap_entry*)((char*)(unsigned int)mmap->addr + i);
/*if(mmap_entry->addr < MEM)
{
if(mmap_entry->addr + mmap_entry->len >= 0xffffffff)
mmap_entry->len = 0xffffffff - mmap_entry->addr;
mmap_entry->len += pagesize - (unsigned int)mmap_entry->len % pagesize;
if(((unsigned int)((((unsigned int)mmap_entry->addr >> 12) + ((unsigned int)mmap_entry->len >> 12))) > ver_pages) && (mmap_entry->type == MULTIBOOT_MEMORY_AVAILABLE))
ver_pages = ((mmap_entry->addr + mmap_entry->len) >> 12) + 1;
}*/
}
/*printf("pages: %x\n", ver_pages);
for(i = 0;i < len;i += mmap->size + sizeof(mmap->size))
if(mmap_entry->addr < MEM)
if(mmap_entry->type != MULTIBOOT_MEMORY_AVAILABLE)
{
pmem_alloc_block((void*)(unsigned int)mmap_entry->addr, (void*)(unsigned int)(mmap_entry->addr + mmap_entry->len));
printf("Reserved: %x - %x\n", (unsigned int)mmap_entry->addr, (unsigned int)(mmap_entry->addr + mmap_entry->len));
}
pmem_alloc_block((void*)0, (void*)0x100000);*/
}
Output in attached image.[DELETED]