Page 1 of 1

Detecting memory

Posted: Fri Aug 22, 2008 9:18 am
by souradipm
Hi,
I am creating a mechanism at boot-time, for when the user has not got enough memory. Seems hard to believe, as I have started at 8MB RAM in bochs and gone down 1 by 1 until it has stopped working at my memory tests. When I have 4MB as the amount of RAM available, the system freezes when allocating memory, so that's the amount i need to check for.

However, when getting the amount of memory from GRUB and adding the upper memory and lower memory together and dividing the total (to get the memory available in megabytes) it's not what I expected the memory to be. It prints out the value of the megabytes detected, and that is 2MB when I tell bochs to give the emulation 4MB. It's 6MB when I told bochs to give the emulation 8MB. So, logically I got my code to add 2 to whatever the calculated value was. I tried this trick when giving the emulation 32MB, but the amount reported by my OS was 33MB. So obviously that is not the right way of doing it. Anyone know of a method the get *accurate* values for the amount of RAM?

~souradipm

Re: Detecting memory

Posted: Fri Aug 22, 2008 10:48 am
by Combuster
The key is, there is more physical memory in the computer than what's actually available for you. The IVT, BDA, EBDA occupy parts of the first 640k of memory, and hence do not count to the amount of available memory. Systems may lose the bit from 640k to 1M by not returning what's in that bit of memory, but rather the various bios images and the video ram that was there. There goes about half an MB of every computer's physical memory.

And then there was this bloatware called ACPI, which also claims large portions in memory for its own stuff. Bye Bye another MB.

I suggest you fix your code rather than blaming Bochs :wink:

Re: Detecting memory

Posted: Fri Aug 22, 2008 11:12 am
by souradipm
I was asking how to get the total amount of memory. Thanks for the information and why GRUB returns the memory available. However, I guess I will just use the available amount of memory to base my calculations if the OS will run or not on.

I plan to use ACPI (or at least APM) when I get enough time to sit down and read the specs, so I will (try) use it to my advantage :D

Thanks for your help anyway,
souradipm