Kernel at end of RAM

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
Maniace
Posts: 6
Joined: Wed May 04, 2005 11:00 pm

Kernel at end of RAM

Post by Maniace »

I decided to move my kernel at the end of RAM to get more DMA pages. But PC has miscellaneous information at 0xFEC00000 - 0xFFFFFFFF. Stuff like BIOS, PnP, ACPI, etc.

So that makes somekind of exception to my kernel copy routines, should I avoid those memory addresses and copy kernel below or above them? Those things really are at middle of extended memory? Insane :P

(Well not exactly at the middle but you got the point :)
deathangel
Member
Member
Posts: 31
Joined: Thu Apr 14, 2005 11:00 pm
Location: Planet Earth
Contact:

Re: Kernel at end of RAM

Post by deathangel »

Well, you can't copy the kernel above 0xFFFFFFFF, even if you're using paging, as the memory addresses don't exist. I copied my kernel to the 2MB mark. Also, copying your kernel to the top of memory won't give you more DMA pages. DMA can only access low memory (e.g. below the 1MB mark) as far as I know.
frizzz
Member
Member
Posts: 36
Joined: Sat Oct 30, 2004 11:00 pm
Location: Germany
Contact:

Re: Kernel at end of RAM

Post by frizzz »

You need to proove, where the end of memory is in fact (at runtime)! Every program and not only a kernel can run everywhere, where memory-cells are.
Besides that, You should do a memory test, whenever You boot, because a reliable OS needs to know, where the upper border of memory is. You can find an example in my little OS, which I published at:
www.rcfriz.de
User avatar
smiddy
Member
Member
Posts: 127
Joined: Sun Oct 24, 2004 11:00 pm
Location: In my cube, like a good leming. ;-)

Re: Kernel at end of RAM

Post by smiddy »

As has been pointed out, you need to determine where the top of RAM is located. If the top of RAM is at 4GB then you also need to determine if 4GB is the top, then what is already installed in those locations. One BIOS call, INT 15h AX=E820h, can give you a detailed map of what is installed. Where you do this is argueable, but suffice it to before you move your code to the top of memory. But if E820 isn't available you have to devise a way to determine what is loaded and where. I am using INT 15h E820, then E801, then 88xx (AH=88, AL=doesn't matter), then CMOS, and finally probing RAM. All variations of determination of RAM require you to know where things al loaded usually, except E820. You'll need to read up on those locations near 4GB and figure out how to map them accordingly for your situation. Then right below this area you can load your kernel minus its size of course.
-smiddy
Maniace
Posts: 6
Joined: Wed May 04, 2005 11:00 pm

Re: Kernel at end of RAM

Post by Maniace »

Thanks for replies. I'll think I understand this better now...
But if someone has 4GB RAM, he/she can only use 4GB minus 20MB RAM cause those ROMs begin from 0xFEC00000?
User avatar
smiddy
Member
Member
Posts: 127
Joined: Sun Oct 24, 2004 11:00 pm
Location: In my cube, like a good leming. ;-)

Re: Kernel at end of RAM

Post by smiddy »

This is partially correct. You'll have to determine tha total amount of ROM. Also, you'll need to determine what devices are using what RAM areas. I have a nVIDIA card that takes 64 MB of RAM starting at C0000000h. Also, there are PCI tables that are located way up there too. I'm uncertain of their specific location, but it is attainable. Look up PCI local bus for further details. People have posted the PCI documentation on line...however, a word of caution, these documents are not free.

Also, there may be other areas of RAM that are being used. If at all possible, it would be best to use INT 15h AX=E820 in order to see what is going on...it doesn't require all the needed info as I've just explained.

Though older systems will not have that BIOS call available. :(
-smiddy
Post Reply