Page 1 of 1
The size of RAM...
Posted: Wed Jun 19, 2002 1:40 pm
by Peter_Vigren
Hi, is there any way to get the size of the total RAM without using a BIOS interrupt??
Re:The size of RAM...
Posted: Wed Jun 19, 2002 5:00 pm
by pete.piper
I've read some stuff on USENET but they all preach against determining RAM size yourself. For instance, direct probing is the act of writing a magic number at every 1 MB (arbitrary) intervals, reading it back, and concluding that it's usable RAM if it has maintained the data you wrote. I've heard of many instances of computer's locking up, memory holes at 16 MB, yada, yada, yada. Just go to
http://groups.google.com and search for "RAM direct probing" or something of that nature and you'll get all that you want and more. (:
So the logical question is... how the heck does the BIOS do it? I'm not completely sure, to be honest. Any experts care to share? I've heard that it's still not stable to use similar methods to the BIOS because it needs to be done during system initialization (or something of that nature).
Pete
Re:The size of RAM...
Posted: Wed Jun 19, 2002 6:31 pm
by crazybuddha
Re:The size of RAM...
Posted: Wed Jun 19, 2002 7:02 pm
by Peter_Vigren
I need a way that circumvent BIOS... but thanks anyway.
Re:The size of RAM...
Posted: Wed Jun 19, 2002 8:06 pm
by crazybuddha
Oops. Didn't read to the end.
mov edi, 0x00100000
mov ebx, edi
probe:
mov eax, [edi]
xor [edi], edi
cmp [edi], eax
jz end
add edi, ebx
jmp probe
end:
sub edi, ebx ; EDI = bytes > 1 meg
Re:The size of RAM...
Posted: Wed Jun 19, 2002 10:49 pm
by .bdjames
MemSize:
push ebx
push ecx
mov eax, 100000h
mov ebx, 100000h
jmp ProbeMemory
MemoryLoop:
add eax,ebx
ProbeMemory:
mov ecx, [eax]
xor [eax], eax
cmp [eax], ecx
jnz MemoryLoop
sub eax, ebx
pop ecx
pop ebx
ret
Re:The size of RAM...
Posted: Thu Jun 20, 2002 8:41 am
by Tim
Peter_Vigren wrote:I need a way that circumvent BIOS... but thanks anyway.
Don't want to use the BIOS? Then program the motherboard chipset manually. You'll need different code for every model of motherboard, and you'll have to talk to the chipset manufacturers yourself, because they almost certainly don't document the direct hardware interfaces.
Don't use direct probing of memory locations, because a lot of machines with memory-mapped devices will crash if you write to some sensitive area.
If you don't want to program the motherboard manually, use the handy built-in motherboard driver called "BIOS". Seriously -- get the memory size using the BIOS interrupts before you switch to protected mode. It's the only reliable way of doing it.
Re:The size of RAM...
Posted: Thu Jun 20, 2002 9:37 am
by crazybuddha
Tim Robinson wrote:
Peter_Vigren wrote:I need a way that circumvent BIOS... but thanks anyway.
, because a lot of machines with memory-mapped devices will crash if you write to some sensitive area.
I've wondered about this. Does this mean there are devices which are mapped to memory locations above 1 Meg??
Re:The size of RAM...
Posted: Thu Jun 20, 2002 9:46 am
by Pype.Clicker
well, at least the VBE framebuffer lies in high addresses, but there is (usually) a gap between it and RAM...
Re:The size of RAM...
Posted: Thu Jun 20, 2002 10:17 am
by .bdjames
Well,
It would be a pretty crapy os, if you did not know
where the holes are, so instead of depending on the
magical bios, why not determine the holes first then
probe. :-*
For your startup code the bios is fine (<16meg). So what are
the devices mapped above 16megs?
advanced interrupt control, ...
Re:The size of RAM...
Posted: Thu Jun 20, 2002 10:52 am
by crazybuddha
.bdjames wrote:
advanced interrupt control, ...
Is this the APIC? I've never dealt with it.
And regarding the VBE framebuffer, you have to set this up early anyway, so you know you might not want to clobber it if you plan to support it. True?
Any others??
Re:The size of RAM...
Posted: Thu Jun 20, 2002 12:11 pm
by pete.piper
Re:The size of RAM...
Posted: Thu Jun 20, 2002 3:02 pm
by Tim
Is this the APIC? I've never dealt with it.
Yes, the APICs map to physical addresses fairly high up (I think around FEE00000). If your memory probing function is hitting these, something's gone wrong...
And regarding the VBE framebuffer, you have to set this up early anyway, so you know you might not want to clobber it if you plan to support it. True?
On a PCI card that supports a linear framebuffer (i.e. any modern one), the framebuffer will be mapped as a big chunk of memory high up in the address space. For example, my 32MB card is at 4GB - 32MB.
Any others??
Memory hole between 15MB and 16MB? Some BIOSes enforce that. ISA adapters between A0000 and E0000 (e.g. SCSI card). Some other weird memory-mapped device (a lot of PCI cards have the option to map their registers as memory locations rather than I/O ports).
Re:The size of RAM...
Posted: Thu Jul 04, 2002 4:27 pm
by Peter_Vigren
There is a way that I can get the memory size (limit lies at 64 Mb) without an interrupt... By reading the CMOS... First telling port 70h which register I want to access and the read port 71h...
Mov Al,Register
Out 70h,Al
;Jmp $+2 ; Windows doesn't like this one, that's why it is commented out
In Al,71h
Registers Meaning
--------- -------
15h Low word of base memory (kb)
16h High word of base memory (kb)
17h Low word of expanded memory (kb)
18h High word of expanded memory (kb)
But as I wrote... that's the 64 Mb-limit...
Re:The size of RAM...
Posted: Fri Jul 05, 2002 12:19 pm
by K.J.
Do be warned, some of the BIOS functions for memory probing don't work in Bochs.
K.J.