piscus wrote:
I obtain information about the memory installed on my PC using the e820 mechanism provided by the BIOS. I have tried to attach an image showing my results (if the image is not displaying I will work on getting it up ASAP). However, my questions may be able to be answered with the image.
I believe I executed retrieved the data correctly, but am surprised by the results (see image below). Following is a list of questions and a screen shot of my results.
a) Regarding the status of the regions returned from the e820 function, the states are: Available and Reserved. However, some regions returned 4. Does anyone know what 4 means? Should this just be considered reserved?
b) I have 4 Gigabytes of memory installed. However, the maximum address returned is 0xBF77A000 + 0x7000 ( 0xBF781000 ). Why is this shown as the maximum amount of memory and not 0xFFFFFFFF? Further, if the only evidence of the memory installed is this map, how can I know for certain how much memory is installed?
c) Consider the last two regions in the picture below. Both are reserved. What is the reason that two reserved regions aren't merged into one large reserved region?
https://photos.app.goo.gl/sJ1VLmOKCRO4PZcF2There are hardware devices that are mapped into the same address space as "regular RAM", so just because you have 4GB of RAM installed don't expect the maximum address to be 0xFFFFFFFF. The reason the BIOS returns two entries of the same type in adjacent regions is probably because the BIOS developers were lazy and didn't want to check to see if it was possible to merge a region before adding it. Either way its still a perfectly valid E820 map.
To know how much usable RAM is installed you just sum up the length of all the 'type 1' regions. This may differ slightly from what the user expects, e.g. it might not be exactly 16GB if they have 2x8GB sticks of RAM installed. The E820 function is the only way to get a reliable memory map that is useful enough to continue with. So long as the E820 function doesn't indicate an error the map it provides should be trusted but you have to account for weird things like overlapping regions, etc. If it returns an error or isn't available it really isn't worth trying to use other methods (IMHO, I'm sure others will disagree) to detect memory.
piscus wrote:
Omar, thanks for the response! That e820 map was produced on my Lenovo Thinkpad t410 (also a 64 Bit machine).
Regarding your question about the 4 Gigs, I double checked:
Since I have Linux installed on this PC, I did a 'cat /proc/meminfo' and got:
MemTotal: 3917488 kB
MemFree: 2108540 kB
MemAvailable: 2573120 kB
... etc.
3917488 kB --> 397488000 B --> 0xE9801F80 Bytes
This is pretty close to 4G which is where I am getting that number from.
Try:
Code:
dmesg | grep BIOS-e820
and see what it shows in Linux. Should be 100% identical to what the BIOS gave the kernel.
I suspect that you're somehow missing the last entry (or more) when you're printing your map. Can you post the code on how you call the E820 function? Is it possible you're incrementing the "entry count" after you check if EBX=0 so the last entry is missed?