Low Memory Area

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Low Memory Area

Post 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
User avatar
muisei
Member
Member
Posts: 79
Joined: Sat Sep 23, 2006 2:10 pm
Location: Bulgaria
Contact:

Post 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)
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Post 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.
User avatar
muisei
Member
Member
Posts: 79
Joined: Sat Sep 23, 2006 2:10 pm
Location: Bulgaria
Contact:

Post by muisei »

There is no need to apologise.That's why this forum was created.
"There are no stupid questions,just stupid answers."
User avatar
smiddy
Member
Member
Posts: 127
Joined: Sun Oct 24, 2004 11:00 pm
Location: In my cube, like a good leming. ;-)

Post by smiddy »

User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post 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)
User avatar
muisei
Member
Member
Posts: 79
Joined: Sat Sep 23, 2006 2:10 pm
Location: Bulgaria
Contact:

Post by muisei »

Take a look at this: http://www.frontiernet.net/~fys/rombios.htm
Is this wrong?
User avatar
smiddy
Member
Member
Posts: 127
Joined: Sun Oct 24, 2004 11:00 pm
Location: In my cube, like a good leming. ;-)

Post 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).
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Post by Tyler »

So to be super safe just assume u can only use 0x600 -> 0x9FC00, way more than you need anyway
User avatar
smiddy
Member
Member
Posts: 127
Joined: Sun Oct 24, 2004 11:00 pm
Location: In my cube, like a good leming. ;-)

Post by smiddy »

For the most part, yep. ;-)
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Post 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
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Post by bubach »

Haha, but didn't you know that everything is "for the most part" with PC's.. :wink:
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
User avatar
smiddy
Member
Member
Posts: 127
Joined: Sun Oct 24, 2004 11:00 pm
Location: In my cube, like a good leming. ;-)

Post 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
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply