Page 1 of 1

Low Memory Area

Posted: Tue Nov 07, 2006 7:44 am
by Tyler
Could anyone please supply a good website or own knowledge with detailed information on the exact boundries that cannot be accessed below the 1MB mark and there function... i really need to find extra areas of memory for use before loading my protected mode kernel.

Thankyou in advance

Posted: Tue Nov 07, 2006 8:35 am
by muisei
Read this:http://my.execpc.com/~geezer/osd/ram/index.htm
There is a mistake in alomost ALL tutorials.The first free byte is 0x600(linear address) not 0x500.So the free convencional memory is between 0x600- 0x9FBFF(linear address)

Posted: Tue Nov 07, 2006 8:43 am
by Tyler
Thanks... i can't believe i never noticed the article before...

and sorry to anyone who read this post... i just read my original post and i can't believe how anal retentive i sound... old age is setting it obviously.

Posted: Tue Nov 07, 2006 8:55 am
by muisei
There is no need to apologise.That's why this forum was created.
"There are no stupid questions,just stupid answers."

Posted: Tue Nov 07, 2006 9:13 am
by smiddy

Posted: Tue Nov 07, 2006 9:30 am
by Brendan
Hi,
muisei wrote:Read this:http://my.execpc.com/~geezer/osd/ram/index.htm
There is a mistake in alomost ALL tutorials.The first free byte is 0x600(linear address) not 0x500.So the free convencional memory is between 0x600- 0x9FBFF(linear address)
The EBDA may or may not exist, and can be larger than 1 KB in some cases. Also, in some (rare and/or unusual) situations there can be nothing between 0x00080000 and 0x0009FFFF (a memory hole), or some BIOS code (e.g. network boot UNDI/PXE stack). Use BIOS Int 0x12 to determine how much you can/can't use starting at 0x00000000.

Also, the area from 0x000C8000 to 0x000EFFFF may contain device ROMs (network, SCSI, etc), may contain RAM, or could be a memory hole (nothing). IIRC Windows 95 used to scan this area and use any RAM it found. This isn't really recommended as modern "many-CPU" computers can use this area for SMRAM, and Windows 95 didn't work on some (rare at the time) systems unless this memory scan was disabled.

Despite this, it would be possible for a chipset driver to scan this area and make any RAM found available to the OS. It'd also be possible for the chipset driver to remove any PCI device ROMs beforehand (potentially freeing up an extra 160 KB of RAM). Of course suitable warnings apply.... ;)


Cheers,

Brendan

Posted: Thu Nov 09, 2006 11:33 am
by JAAman
muisei wrote:Read this:http://my.execpc.com/~geezer/osd/ram/index.htm
There is a mistake in alomost ALL tutorials.The first free byte is 0x600(linear address) not 0x500.So the free conventional memory is between 0x600- 0x9FBFF(linear address)
since when? someone needs to tell MS, since there bootloader uses 0x500-0x600 as free memory -- that must be why windows wont install on most computers -- oh wait, it works without problem on all systems

MS MBRs reload themselves to 0x500-0x700 before loading the bootsector at 0x7C00, MS bootsectors also load the MBR into this space (unnecessary if loaded by MS MBR, but since that isnt necessarily the case, so it reloads it anyway)

Posted: Thu Nov 09, 2006 1:00 pm
by muisei
Take a look at this: http://www.frontiernet.net/~fys/rombios.htm
Is this wrong?

Posted: Thu Nov 09, 2006 1:19 pm
by smiddy
muisei wrote:Take a look at this: http://www.frontiernet.net/~fys/rombios.htm
Is this wrong?
I don't think it is wrong and I don't think JAAman is wrong either. Some folks for the purposes of devlopment, write their OS' to be able to run ontop of DOS. DOS uses linear 500h - 600h-ish for those items mentioned and more I presume. If you don't intend to use DOS as a devlopment tool to launch your OS you are fine using that area. As JAAman points out, MS uses those areas for their OS'. To be safe, even if you're not launching from DOS, you could simply use 600h - A0000h (if no EBDA).

Posted: Thu Nov 09, 2006 3:47 pm
by Tyler
So to be super safe just assume u can only use 0x600 -> 0x9FC00, way more than you need anyway

Posted: Sun Nov 12, 2006 8:17 pm
by smiddy
For the most part, yep. ;-)

Posted: Wed Nov 15, 2006 5:30 pm
by Tyler
i love that... you think its sorted and then someone comes in with "for the most part"... i dont even want to know what is wrong with it

Posted: Wed Nov 15, 2006 6:12 pm
by bubach
Haha, but didn't you know that everything is "for the most part" with PC's.. :wink:

Posted: Wed Nov 15, 2006 9:03 pm
by smiddy
Sorry Tyler, everything is relative. Call it Einstein-ish or whatever, the fact is there are too many permutation with the number of machines, there is no definitive answer. So, in order to be compatible a certain degree of acceptance has to be done in order to move forward, or you pull all your hair out trying to solve an insolveable situation, so you compromise. I hope you didn't take it as derogatory, that wasn't my intention. I'm cynical due to my own experience dealing with PCs and other devices. That is all I was conveying with "for the most part" :D

Posted: Wed Nov 15, 2006 10:40 pm
by Brendan
Hi,
Tyler wrote:i love that... you think its sorted and then someone comes in with "for the most part"... i dont even want to know what is wrong with it
For most computers, the area from 0x00000500 to 0x0009FBFF should be safe to use.

However...

Some computers do use a larger EBDA, and there isn't really anything that specifies a limit for how large the EBDA can be. For example, it's possible for the BIOS in a large server to use 4 KB, or for a SCSI card ROM to use an extra 1 KB for it's own purposes.

If you ever want to use network boot, then the area from 0x00080000 to the beginning of the EBDA is off limits, because it is used by the networking code (BIOS, network card ROM or utility like etherboot).

Some chipsets (including recent Intel chipsets) support a memory hole at 0x00080000. I've never seen a BIOS provide an option to enable this memory hole, and don't quite know why the chipset still supports it, but some do.

I think part of this comes from backwards compatability with old XTs, where it's possible to have 512 KB of RAM and nothing else, and programmers used BIOS Int 0x12 to find out how much RAM was installed. This led to people not using RAM above 0x00080000 without checking BIOS Int 0x12 first, and allowed things like the EBDA to be added to the architecture later.

Therefore, in general, if you want your OS to support even the most unusual modern computers possible (or network boot), then don't use memory above 0x00080000 without checking BIOS Int 0x12 first. If you do use memory from 0x00000500 to 0x0009FBFF without checking, then your OS will probably only work on 99.8% of "80x86 compatible" computers when network boot isn't used.

For my OS, I use RAM from 0x00001000 to 0x0007FFFF, and 2 MB or more of RAM starting at 0x00100000 without finding out if there's any usable RAM in these areas first.

AFAIK the area at 0x00100000 is safe if (and only if) there's enough RAM installed. E.g. for a computer with 4 MB of RAM installed it should be safe to use from 0x00100000 to 0x003FFFFF. For computers with more than 16 MB of RAM, this area is only safe up to 0x00EFFFFF as there can be a memory hole from 15 MB to 16 MB.

BTW curious people might want to click this link - it's the results of a google search, and contains a large number of people complaining about an "EBDA too big" error message from LILO and being unable to boot. It seems LILO has a "LARGE_EBDA" option in it's makefile... ;)


Cheers,

Brendan