memory size calculation from multiboot

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator: Moderators

memory size calculation from multiboot

Postby vjain20 » Thu May 10, 2012 1:15 am

Hi,

I did not understand the calculation of memory size from the fields in multiboot structure.

Code: Select all
uint32_t memSize = 1024 + bootinfo->m_memoryLo + bootinfo->m_memoryHi*64;


Please explain the addition of 1024 and multiplication by 64.
vjain20
 
Posts: 12
Joined: Fri Apr 06, 2012 7:24 am

Re: memory size calculation from multiboot

Postby Andyhhp » Thu May 10, 2012 11:10 pm

I would agree that that calculation looks wrong.

However, the information in the multiboot header is advisory only, and even then only gives you the available memory up to the first MMIO hole which is typically at 15MB for compatability.

Realistically, the only way to accuratly determine the extent of memory is to get your hands on the e820 map, and verify the regions provided in there.

~Andrew
Image
Andyhhp
Moderator
 
Posts: 387
Joined: Tue Oct 23, 2007 10:05 am
Location: 127.0.0.1

Re: memory size calculation from multiboot

Postby linuxfreak » Sat May 12, 2012 5:08 pm

For Andyhhp:

Sory if I am understanding your post incorrectly but, you said that the multiboot MMIO hole is at 15MB. Does that mean the mm can only detect 15mb of ram? That is not the case, I set my memory in the virtual machine to 158mb and it detected 161mb. I also use the multiboot stuff to detect my memory at startup!

So, it is able to detect that much, but gets very inacurate.

Please correct me if i am wrong.
User avatar
linuxfreak
 
Posts: 52
Joined: Tue Jul 26, 2011 7:36 pm
Location: Paarl, Western Cape, South Africa

Re: memory size calculation from multiboot

Postby Andyhhp » Sat May 12, 2012 7:34 pm

Virtual environments tend not to have an MMIO hole at 15 MB because it is not backed by the legacy hardware which requires it.

As for your specific example, I would say that the number is simply being reported wrongly; The only way virtual environments want to communicate RAM information is throug the e820 map - all other methods are legacy artifacts which are typically ignored.

~Andrew
Image
Andyhhp
Moderator
 
Posts: 387
Joined: Tue Oct 23, 2007 10:05 am
Location: 127.0.0.1

Re: memory size calculation from multiboot

Postby linuxfreak » Sun May 13, 2012 4:21 pm

:shock: Oh!

Thank you for clearing a few "misconceptions". I really did not know that! :lol:
The Anti-Microsoft revolution has begun, and soon Apple will take over the universe. The world is primed for war - someone should just take the first blow.
User avatar
linuxfreak
 
Posts: 52
Joined: Tue Jul 26, 2011 7:36 pm
Location: Paarl, Western Cape, South Africa


Return to Beginning OS Development

Who is online

Users browsing this forum: Bing [Bot] and 1 guest