Posted: Tue Jul 31, 2007 10:29 am
Hi,
Tell me if this code does what you'd expect:
I'm guessing they didn't test that on computers with BIOSs made during or before 1989...
They only have one way of probing memory, but their memory probing code is split into 2 parts - one function to test for RAM at a specific address, and another function to test a range of addresses (by calling the first function).
The function to test for RAM at a specific address doesn't even flush caches between writing and reading (they write to the cache then check if the value is still in the cache, all without accessing RAM). This should actually work for newer computers with MTRRs (which probably support the BIOS functions anyway), but won't work on older computers unless the memory controller is "friendly".
The function to test a range of addresses will (hopefully) stop at the first non-RAM address, so if you've got a computer with 256 MB of RAM with an ISA memory hole then it'll only detect 15 MB of RAM (unless there's an ISA video card in this area, in which case it'll think the video display memory is usable RAM).
Their "checkA20()" also may not work on some computers due to caching. AFAIK the caches in newer CPUs are aware of A20, but older CPUs and computers with external caches aren't. Not that this matters much - they don't check A20 until *after* they've done manual probing ("Yay, my 8 MB computer has 9 MB now!"), so A20 had better be enabled....
I'm not sure how many other bugs there are in this (short) piece of code - I only spent 5 minutes or so looking.
Cheers,
Brendan
Hehe...Brynet-Inc wrote:I know OpenBSD uses int 15, AX=E820 first, then int 15, AX=E801.. (Or it did? E801 is #if 0'd out apparently..)
After if those two methods fail, it attempts int 15, AX=8800 which has a 64MB barrier..
If "all" of this fails, It seems to have "two" methods of probing memory.. View Source Here.
Memory can also be "manually added" via the boot console as well..
Tell me if this code does what you'd expect:
Code: Select all
/* Check for 94 or later bios */
info = (void *)0xFFFFB;
if (info[0] == '9' && info[1] <= '3')
return NULL;
They only have one way of probing memory, but their memory probing code is split into 2 parts - one function to test for RAM at a specific address, and another function to test a range of addresses (by calling the first function).
The function to test for RAM at a specific address doesn't even flush caches between writing and reading (they write to the cache then check if the value is still in the cache, all without accessing RAM). This should actually work for newer computers with MTRRs (which probably support the BIOS functions anyway), but won't work on older computers unless the memory controller is "friendly".
The function to test a range of addresses will (hopefully) stop at the first non-RAM address, so if you've got a computer with 256 MB of RAM with an ISA memory hole then it'll only detect 15 MB of RAM (unless there's an ISA video card in this area, in which case it'll think the video display memory is usable RAM).
Their "checkA20()" also may not work on some computers due to caching. AFAIK the caches in newer CPUs are aware of A20, but older CPUs and computers with external caches aren't. Not that this matters much - they don't check A20 until *after* they've done manual probing ("Yay, my 8 MB computer has 9 MB now!"), so A20 had better be enabled....
I'm not sure how many other bugs there are in this (short) piece of code - I only spent 5 minutes or so looking.
Cheers,
Brendan