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.
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
(Well not exactly at the middle but you got the point
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.
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
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.
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?
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.