Whenever I run the following code to switch to long mode in qemu, it triple faults (by way of #GP). I've tried changing the GDT entry for the code segment, but I haven't had success so far. Any ideas would be much appreciated.
Links to file for the code to switch from the 32-bit environment grub loads the bootstrapper in to 64-bit long mode (fault is on the far jump), the gdt, and the overall repository.
Triple Fault on Far Jump To Long Mode
-
- Posts: 4
- Joined: Mon Jun 04, 2018 6:37 am
Re: Triple Fault on Far Jump To Long Mode
This (most likely) won't fix your triple fault, but just a quick look at your early.asm and I noticed you've labeled (and set up) your stack backwards. Remember: On x86 The stack grows downwards. From the wiki: Although written for 32 bit protected mode, it should apply to you. I could also be completely wrong, because I am new to OSDev, but being proven wrong is an opportunity to learn
EDIT: Sorry, I goofed. I misread your code and had a dyslexic moment. Your stack is set up properly.
Code: Select all
To set up a stack, we set the esp register to point to the top of our
stack (as it grows downwards on x86 systems). This is necessarily done
in assembly as languages such as C cannot function without a stack.
EDIT: Sorry, I goofed. I misread your code and had a dyslexic moment. Your stack is set up properly.
"You’re free to praise Microsoft Windows on your own if you want, but please don’t do this in GNU packages." - GNU C Portability Standards
Re: Triple Fault on Far Jump To Long Mode
1. Perhaps I'm missing something, but I couldn't see a long jump in your code.
2. You don't appear to set up a page table.
2. You don't appear to set up a page table.