The size of RAM...
The size of RAM...
Hi, is there any way to get the size of the total RAM without using a BIOS interrupt??
Re:The size of RAM...
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
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...
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
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...
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
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...
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.Peter_Vigren wrote:I need a way that circumvent BIOS... but thanks anyway.
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...
I've wondered about this. Does this mean there are devices which are mapped to memory locations above 1 Meg??Tim Robinson wrote:, because a lot of machines with memory-mapped devices will crash if you write to some sensitive area.Peter_Vigren wrote:I need a way that circumvent BIOS... but thanks anyway.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:The size of RAM...
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...
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, ...
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...
Is this the APIC? I've never dealt with it..bdjames wrote:
advanced interrupt control, ...
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...
Check out this thread that does a decent job of tackling many issues that arise in direct probing:
http://groups.google.com/groups?hl=en&l ... fd5&rnum=3
Here's another good one:
http://groups.google.com/groups?hl=en&l ... 394&rnum=5
Heck, and:
http://groups.google.com/groups?hl=en&l ... 865&rnum=7
Pete
http://groups.google.com/groups?hl=en&l ... fd5&rnum=3
Here's another good one:
http://groups.google.com/groups?hl=en&l ... 394&rnum=5
Heck, and:
http://groups.google.com/groups?hl=en&l ... 865&rnum=7
Pete
Re:The size of RAM...
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...Is this the APIC? I've never dealt with it.
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.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?
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).Any others??
Re:The size of RAM...
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...
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...
Do be warned, some of the BIOS functions for memory probing don't work in Bochs.
K.J.
K.J.