Reserved Memory in RAM
-
amirsadig
Reserved Memory in RAM
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.
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.
-
Therx
Re:Reserved Memory in RAM
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.
-
drizzt
Re:Reserved Memory in RAM
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
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
-
amirsadig
Re:Reserved Memory in RAM
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.
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.
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Reserved Memory in RAM
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 
-
amirsadig
Re:Reserved Memory in RAM
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?
what happend when I enable paging and try to access video memory to type something, will the CPU use paging also as address translation?
-
amirsadig
Re:Reserved Memory in RAM
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
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
-
amirsadig
Re:Reserved Memory in RAM
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?
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?
-
Curufir
Re:Reserved Memory in RAM
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.
With older BIOS you simply have to rely on whatever information you can dredge up about standard memory mapped areas/devices.
-
Tim
Re:Reserved Memory in RAM
Right, so you obtain the memory map in your boot loader, before you enter protected mode.
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Reserved Memory in RAM
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 regionas 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?
-
amirsadig
Re:Reserved Memory in RAM
that is a good notice from you. yes I tried to access a integer ( 4 byte long ) ;D.
thanks!
thanks!