Page 1 of 1

memory size calculation from multiboot

Posted: Thu May 10, 2012 1:15 am
by vjain20
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.

Re: memory size calculation from multiboot

Posted: Thu May 10, 2012 11:10 pm
by Andyhhp
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

Re: memory size calculation from multiboot

Posted: Sat May 12, 2012 5:08 pm
by linuxfreak
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.

Re: memory size calculation from multiboot

Posted: Sat May 12, 2012 7:34 pm
by Andyhhp
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

Re: memory size calculation from multiboot

Posted: Sun May 13, 2012 4:21 pm
by linuxfreak
:shock: Oh!

Thank you for clearing a few "misconceptions". I really did not know that! :lol: