Page 1 of 1
Reserved Memory in RAM
Posted: Tue Feb 04, 2003 1:22 pm
by amirsadig
I would like to write my memory management for my OS, which it now only let me write to screen - keyboard interupt and small video driver-.
Now I try to write MM, therefore I need to know where is the reserved memory for DMA or IO devices or others which use the memory to save their data, so these memory wil not allacated with my MM and so my application will never use this memory.
Did someone know where I found these information or you could tell me directly here.
Re:Reserved Memory in RAM
Posted: Tue Feb 04, 2003 3:17 pm
by Therx
Below 1 meg has lots of holes (see
http://my.execpc.com/~geezer/osd/mem/index.htm) I think from 1 meg up to 3 gig to all continuous but there are certainly holes above that. When you initialize all the hardware (PCI or whatever) add the mem addresses to a holes array or something. Thats my advice.
Re:Reserved Memory in RAM
Posted: Wed Feb 05, 2003 2:35 am
by drizzt
Another advice: remember that DMA can access only to the first 16M, due to the 24bit address bus...
So if you have to realize your memory manager you must manage 2 memory area (the first one below the 16MB for your DMA buffers and the other one above 16MB)
I suggest to you to read the 2 Tim Robinson's memory manager tutorials; you can find them to the following link:
http://www.cyberscriptorium.com/osjourn ... ic&topic=2
Re:Reserved Memory in RAM
Posted: Wed Feb 05, 2003 3:53 am
by amirsadig
Thank you for you good informations.
with you advice, I will try to move my kernel image to address above 16MB and then start the kernel from there.
as bootloader I use grup which run in pmode and load my kernel above 1MB (0x100000). how could I move my kernel from this address to the address above 16MB, therefore I need the size of my kernel image size.
Re:Reserved Memory in RAM
Posted: Wed Feb 05, 2003 4:06 am
by Pype.Clicker
keep some free space in the 16MB, but do not reserve it exclusively to DMA buffering. Do also think that if you send your kernel to 16M+, this means no machine with less than 32MB will load it successfully (oh, maybe 24MB if you find some

, which might not be whishable (at its early stages of its life-cycle, your OS will be run on pretty old crash-hardware ... only then on ca$h hardware

Re:Reserved Memory in RAM
Posted: Wed Feb 05, 2003 12:00 pm
by amirsadig
that is good notice ;D.
what happend when I enable paging and try to access video memory to type something, will the CPU use paging also as address translation?
Re:Reserved Memory in RAM
Posted: Wed Feb 05, 2003 3:11 pm
by amirsadig
after some test, I have found it.
the CPU use paging anywhere after enable paging, but because I have used a segment descriptor with 0 base address the virstual address when we translate it to linear address (base + virtual address) and the to physical address is equal to virstual address ;D.
note that i have used only one page directory entry which govered 4MB for test purpose and understandig paging.
when I try to use page over 4MB i receive page fault exception ;D
Re:Reserved Memory in RAM
Posted: Thu Feb 06, 2003 2:33 am
by amirsadig
hi, this a part from my init_paging function:
for(i=0; i<1024; i++)
{
page_table = address ;
address = address + 4096;
};
page_directory[ 0 ] = page_table;
page_directory[ 0 ] = page_directory[ 0 ] | 3;
// fill the rest of the page directory
for(i=1; i<1024; i++)
{
page_directory = 0 | 2; };
my page directory begin at 0x200000 and table at 0x201000.
as above the cpu will bring page fault exception when I try to access memmory > 0x3FFFFF, but does not do that. cpu bring me a page fault exeception with memory > 0x3FFFFC. that mean it reference only 4092 byte at the last page table entry. why it does so?
Re:Reserved Memory in RAM
Posted: Fri Feb 07, 2003 11:49 am
by amirsadig
is there no answer :-[? nobody has this situation !
Re:Reserved Memory in RAM
Posted: Fri Feb 07, 2003 12:08 pm
by Curufir
With newer BIOS use int 15h, E820h (
http://www.ctyme.com/intr/rb-1741.htm) to determine the free areas of the memory space.
With older BIOS you simply have to rely on whatever information you can dredge up about standard memory mapped areas/devices.
Re:Reserved Memory in RAM
Posted: Fri Feb 07, 2003 1:22 pm
by amirsadig
in protect mode you can not use bios interupt ;D
Re:Reserved Memory in RAM
Posted: Fri Feb 07, 2003 3:05 pm
by Tim
Right, so you obtain the memory map in your boot loader, before you enter protected mode.
Re:Reserved Memory in RAM
Posted: Sat Feb 08, 2003 6:57 am
by Pype.Clicker
as above the cpu will bring page fault exception when I try to access memmory > 0x3FFFFF, but does not do that. cpu bring me a page fault exeception with memory > 0x3FFFFC. that mean it reference only 4092 byte at the last page table entry. why it does so?
You should check the ASM code generated. If the code tryes to read an integer from 0x3FFFFC, that integer actually uses bytes [0x3FFFFC .. 0x3FFFFF] ... if you read from 0x3FFFFD, it will span until 0x400000 and you're out of your valid paging region

Re:Reserved Memory in RAM
Posted: Sat Feb 08, 2003 7:24 am
by amirsadig
that is a good notice from you. yes I tried to access a integer ( 4 byte long ) ;D.
thanks!