Page 1 of 1
How to detect low (<1MB) memory?
Posted: Wed Oct 12, 2005 11:00 pm
by Osbios
How can I detect the size of the basic (<1MB) memory?
I only know that the max. value is 640KiB. All I found on the web is >1MB detect stuff.
But what's with realy old systems less then 640KiB?
And I read about >1MB systems with less then 640KiB basic Mem? :/
Re: How to detect low (<1MB) memory?
Posted: Wed Oct 12, 2005 11:00 pm
by JAAman
well 386+ don't work very well with <640KB ram and if you target <386 then your stuck with real mode (which is really not worth it) so if you target 386 (which was released over 20 years ago) you should usually have at least the full conventional ram -- and if you go for PMode then youll need to store some large structures and need more memory (most OSs wont even USE ram below the 1MB RMode limit) so for these reasons most people don't bother detecting ram<640KB
most 386s should have at least 4MB (although some might not) and they usually can support up to 8MB - but if you support 386s you also have to worry about FPU emulation and supporting 287/387 and the bugs (some 387s had system crashing bugs -- something to do with deadlocking)
some early 286/386 systems created a memory hole at 512kb but i don't know anything more than that
there is a int that reports mem below 1MB but i cant remember which one(get RBIL - it will be there)
you should always try to use int15-e80 if its supported (and limit your memory to <1GB if it isn't) or you could have so really big problems (and in theory could permanently destroy your computer)
Re: How to detect low (<1MB) memory?
Posted: Wed Oct 12, 2005 11:00 pm
by deadmutex
use GRUB. It will calculate the size for you.
Re: How to detect low (<1MB) memory?
Posted: Wed Oct 12, 2005 11:00 pm
by JAAman
Grub will NOT work on systems with less than 1MB ram
Grub won't detect ram <640Kb
Grub ONLY uses e820 (which is the best but only supported on the very newest systems)
Re: How to detect low (<1MB) memory?
Posted: Thu Oct 13, 2005 11:00 pm
by mrkaktus
Use BIOS calls:
I: INT 15h
AH 88h
O: AX = size of RAM after 1MB (EAX?), in KB so (64MB=MAX)
-------------------------------------------------------
I: INT 12h
O: AX = size of RAM below 1MB returned in KB
-------------------------------------------------------
PS: My system also supports PC with 1mb of RAM
(Maybe because I have such 386 up to year 2000
).
look at:
www.acd.prv.pl
Re: How to detect low (<1MB) memory?
Posted: Thu Oct 13, 2005 11:00 pm
by JAAman
well i'm still useing a 386 (for older games that won't run on newer systems and for OSdev testing)
i'm targeting 386 w/4MB ram
less than 4MB makes PMode a LOT harder so i just use that as the minimum
Re: How to detect low (<1MB) memory?
Posted: Fri Oct 14, 2005 11:00 pm
by Osbios
Thx for all the infos!
Int12h is exatly what i need. (btw word[0x413] have the same value
http://www.clipx.net/ng/bios/ng1971.php)
And well, my oldes machine is a 486 with 8MiB. But 640 KiB from 7808 KiB is over 8% not uses mem. ;D
Bochs returns 0x27F = 639 KiB and my real testmachine 0x280 = 640 KiB.
Re: How to detect low (<1MB) memory?
Posted: Fri Oct 14, 2005 11:00 pm
by JAAman
yes but that 8% is hard-to-use (and its unlikely youll need it)
you have some very complicated mapping and still can't use it all due to bios shadowing and hardware remaping (even if you don't need want to save it for v86 mode)
the ultimate reference for BIOS calls, ports, and many other hardware related things (including odd assignments used by specific models) is RBIL -- get it it should be you 2nd best companion (second only to the intel manuals)
http://www.cs.cmu.edu/afs/cs/user/ralf/ ... files.html
Re: How to detect low (<1MB) memory?
Posted: Sat Oct 15, 2005 11:00 pm
by mrkaktus
OsBios write:
"Bochs returns 0x27F = 639 KiB and my real testmachine 0x280 = 640 KiB."
This is because most of new machines have at adress 639kb EBDA (Extended Bios Data Area).
If you want you can use my memory map that I create for firs MB
(if there are some errors please tell me
):
Code: Select all
--- <= Means free memory block
+------------------------+---------+----------------------------------------------+
| Beginning adress | Size | Description |
+------------------------+---------+----------------------------------------------+
| 00000 - 0KB - 000000 | 1KB | Table of pointers to IRQ |
| 00400 - 1KB - 001024 | 172B | BDA (Bios Data Area) |
| 004AC - 1196B - 001196 | 68B | Reserved by IBM |
| 004F0 - 1264B - 001264 | 16B | User communication area (?) |
| 00500 - 1280B - 001280 | 29.75KB | --- |
| 07C00 - 31KB - 031744 | 0.5KB | Here is loaded bootloader |
| 07E00 -31.5KB - 032256 | 607.5KB | --- |
|*9FC00 - 639KB - 654366 | 1KB | EBDA (Extended BIOS Data Area) |
| A0000 - 640KB - 655360 | 64KB | Graphic screen of Video Card |
| B0000 - 704KB - 720896 | 32KB | Hercules text screen area |
| B8000 - 736KB - 753664 | 32KB | 8 planes of VGA text screen area |
| C0000 - 768KB - 786432 | 32KB | BIOS Of Video Card |
| C8000 - 800KB - 819200 | 160KB | BIOS Shadow Area |
| F0000 - 960KB - 983040 | 64KB | BIOS of System (main BIOS ROM) |
+------------------------+---------+----------------------------------------------+
heve fun
Re: How to detect low (<1MB) memory?
Posted: Sat Oct 15, 2005 11:00 pm
by Osbios
That's my currently knowledge about the memory map:
Code: Select all
; start end size region/exception description
; 0 - 3FF 400 RAM Real-Mode Interrupt Vector Table (IVT)
; 400 - 4FF 100 RAM BIOS data area (BDA)
; 500 - 9FBFF 9F700 RAM/free for use Conventional memory
;- 7C00 - 7DFF 200 RAM Operating System BootSector
; 9FC00 - 9FFFF 400 RAM Extended BIOS data area (EBDA)
; A0000 - 100000 60000 various ROM ARREA (384KB)
; 100000 - FEBFFFFF FEB00000 RAM?/free for use? Extended memory
;- 1000000 - 10FFFFF 100000 ? ISA 15-16MB (only with ISA bus?)
; FEC00000 - FFFFFFFF 1400000 various PnP NVRAM?, LAPIC, ...
;Standard usage of the ROM ARREA:
;- A0000 - BFFFF 20000 video RAM VGA Mem (128KB)
;- - A0000 - AFFFF 10000 video RAM VGA framebuffer (64KB)
;- - B0000 - B7FFF 8000 video RAM text monochrom (32KB)
;- - B8000 - BFFFF 8000 video RAM text color (32KB)
;- C0000 - C7FFF 8000 ROM Video BIOS* (32K is typical size)
;- F0000 - FFFFF 10000 ROM Motherboard BIOS* (64K is typical size)
Re: How to detect low (<1MB) memory?
Posted: Sun Oct 16, 2005 11:00 pm
by JAAman
actually there isn't any ROM at address E000-10000
this is a copy of some ROM entry rutines copied from ROM into RAM at that address and the actual BIOS ROM is located at top of the 32bit address space (not sure if its been moved to top-of-36bit address-space?)
also in upper memory (sometimes as low as the 1GB mark) is your actual Video memory (the 128k in lower mem is remaped by the video controller into the character or frame buffer as neccesary -- this is why direct probbing is dangerous - in fact i wouldn't even trust int15/e801 for mem > 1GB (mabey even less if your paranoid) because it has no way to inform you of mem-mapped-io and external memory that could be located within this area