Qemu shows no problem, on real PC triple fault in initPaging
Posted: Thu Mar 26, 2009 10:58 am
Hi everybody
I followed James tutorials for paging (Nicely done).
Well problem is when i am trying to come out of the routine that changes cr0 to enable paging.
The thing that confuses me is that if routine for Identity mapping, PD or PT are incorrect then *t='A' and for(;;); should triple fault too.
This means there is something wrong with call and ret, hence wrong with SS and ESP.
I searched forum and found fixes to James paging.c but even after adding those snippets could get rid off it.
I am not creating an elf file rather a pure binary using gcc and fc7 to be loaded by my Second Stage Bootloader.
Please help!
I followed James tutorials for paging (Nicely done).
Well problem is when i am trying to come out of the routine that changes cr0 to enable paging.
Code: Select all
void switch_page_directory(page_directory_t *dir)
{
unsigned short *t= (unsigned short *)0xB8000;//added for testing
current_directory = dir;
asm volatile("mov %0, %%cr3":: "r"(&dir->tablesPhysical));
u32int cr0;
asm volatile("mov %%cr0, %0": "=r"(cr0));
cr0 |= 0x80000000; // Enable paging!
asm volatile("mov %0, %%cr0":: "r"(cr0));
goto down;//short jump to flush queue
for(;;);
down:
*t='A';//This works fine both on Qemu and on real machine
//puts("Paging Set\n");//If this is uncommented, works on qemu, triple faults on real PC
for(;;);//If this is commented works fine on qemu but triple faults on real machine
}
This means there is something wrong with call and ret, hence wrong with SS and ESP.
I searched forum and found fixes to James paging.c but even after adding those snippets could get rid off it.
I am not creating an elf file rather a pure binary using gcc and fc7 to be loaded by my Second Stage Bootloader.
Please help!