Code: Select all
void paging_install()
{
unsigned long *page_dir = (unsigned long *) 0x9C000;
unsigned long *page_table = (unsigned long *) 0x9D000;
unsigned long address = 0;
unsigned int i;
for (i=0; i<1024; i++)
{
page_table[i] = address | 3;
address = address + 4096;
}
page_dir[0] = ((unsigned long) page_table) | 3;
for (i= 1; i<1024; i++)
{
page_dir[i] = 0 | 2;
}
unsigned long *page_table2 = (unsigned long *) 0x9E000;
address = 0xB8000;
for (i=0; i<1024; i++)
{
page_table2[i] = address | 3;
address = address + 4096;
}
page_dir[896] = ((unsigned long) page_table2) | 3;
write_cr3(page_dir);
write_cr0( read_cr0() | 0x80000000);
}
In short, I put a page table for that at 0x9E000, mark all entries in it with the right address and as present read/write.
Then I enter that table into the page directory at entry 896 which is 1110000000 in binary (first 10 bits of E0000000).
After looking through every tutorial and guide to paging I could find, I finally gave up. I can see no problems in that code. Still outputing text to 0xE0000000 doesn't work while outputing to 0xB8000 does.
Edit.
Cleaned up the code a bit.