Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Starting to develop my own OS, I hit a wall whenever I try to switch to paging mode. The boot loader successfully loads the kernel at address 0x1000, switches to 32-bit protected mode and executes the kernel. However, whenever the kernel tries to switch to paging mode I get the following error (the page fault handler that I registered never gets called):
exception(): 3rd (14) exception with no resolution, shutdown status is 00h, resetting
I tried to reuse the code from http://www.jamesmolloy.co.uk/tutorial_h ... aging.html to make sure that the page directory and interrupt handling was properly configured, but I still get a crash. I suspect that my boot loader is doing something that the processor doesn't like (I tried using grub, but using it seems to be challenging on OS X)
Have you verified your IDT and GDT are setup and valid?
Edit: Also, it's very difficult to tell what's wrong with your code when you're not providing any. I'm not saying "dump your complete source here", but the relevant parts would certainly be helpful.
Last edited by FusT on Tue Dec 22, 2015 1:20 am, edited 1 time in total.
As said above, can you provide some more information, especially the values in CRx registers.
I know a few people have had issues ripping James M's code from the site (the downloaded version is fixed). Anyway, something to check for is CR0 = CR2. If this is the case, make sure you have correctly identity mapped the first 4MB of memory. What happens is (if first 4mb is not mapped) that the processor tries to jump back to the previous instruction, but since all adresses are now virtual, a page fault occurs. The IDT is then inaccesible, which causes another page fault until a triple fault occurs and the processor just gives up and reboots.
After some further debugging (as well as some luck), I was able to get this working, although I am not entirely sure why.
The CR0 registered indicated that the page fault happened when the kernel tried to access the page directory. And the error disappears after I allocate some static data before allocating it. Apparently the page directory must be located above 1 Mb in the address space - at least in my case.
@Octocontrabass: you say that my source for working code is not a good source. Fair enough. Any good source you would recommend?