How to map more than 4MB?
Posted: Sun May 06, 2007 9:02 pm
I have this setup for paging, from the tutorial on osdever.net. It's not the best tutorial in the world, because it only really teaches how to map the first 4MB.
I've got this:
The question is, how do I map the other entries in the page directory?
I've got this:
Code: Select all
// initializes paging
void InitPaging()
{
// necessary variables
ulong_t address = 0;
uint_t i;
// map the first 4 MB, first 4K not available
pagetab[0] = address | 2; // not present
address += 4096;
for( i = 1; i < 1024; i++ )
{
pagetab[i] = address | 3; // supervisor, r/w, present
address += 4096; // 4 KB
}
// fill first entry of the page directory
pagedir[0] = (unsigned int) pagetab;
pagedir[0] = pagedir[0] | 3; // supervisor, r/w, present
// null out the rest
for( i = 1; i < 1024; i++ )
pagedir[i] = 0 | 2; // not present
// fill CR3 and CR0
write_cr3( (unsigned int) pagedir ); // put page directory address into cr3
write_cr0( read_cr0() | 0x80000000 ); // set paging bit to 1
}