Triple Fault while paging
Posted: Fri May 09, 2008 2:40 am
#include<paging.h>
#include<io.h>
#include<textmode.h>
#include<types.h>
unsigned long *page_directory = (unsigned long *) 0xAA0000;
unsigned long *page_table = (unsigned long *) 0xAB0000; // the page table comes right after the page directory
void paging_install()
{
unsigned long address=0; // holds the physical address of where a page is
unsigned int i,j,d;
kprint("Installing PAGING \n");
for(i=0;i<1024;i++)
{
for(j=0;j<1024;j++)
{
page_table[1024*i+j] = address | 3; // attribute set to: supervisor level, read/write, present(011 in binary)
address = address + 4096; // 4096 = 4kb
}
if(i==0)
{
page_directory[0] = cast_ulong(page_table);
page_directory[0] = page_directory[0] | 3;
}
if(i==1)
{
page_directory[1] = page_directory[1] | 2;
}
else
{
page_directory = cast_ulong(page_table[1024*i]);
page_directory = page_directory | 3;
}
replace_int((1024*i+j)*4);
}
kprint(" Kilo Bytes.");
// write_cr3, read_cr3, write_cr0, and read_cr0 all come from the assembly functions
write_cr3(cast_ulong(page_directory)); // put that page directory address into CR3
write_cr0(read_cr0() | 0x80000000); // set the paging bit in CR0 to 1
kprint(" DONE\n");
}
bochs just quit when paging is installed?/