GDT causes triple fault [SOLVED]
Posted: Mon May 03, 2010 7:18 pm
Edit: I'm an embarrassment to spies everywhere; it turned out it was all because I assumed a
in James' tutorial should have been
so I'm real sorry. I'll leave the rest of the post here so that others that make the same mistake will be able to see it (it is annoying when people delete the content of their posts, eh?).
---
Note: I have searched the forums and the illustrious Internets but to no avail. One of the search phrases I used on Google was "gdt triple fault site:osdev.org" and I also used the forums' inbuilt search function, as well as reading the wiki page on GDT issues, but like I say, nothing doing.
Anyway, I have been working away for a few hours over the past few days (due to a "bank holiday" in England and a day off at school, I've been enjoying a 4 day weekend) and I've gotten a little further than before (the hard disk of the laptop I was using at the time died and I lost all my code) in some ways but I'm stuck on the GDT (again). I once managed to get past the GDT and got to the point of starting up interrupts when all went to hell, but this time I haven't even gotten that far. I've tried several different things, I've made sure all my structures are correct, my functions do the right thing and what-not (I'm still basing this code James M's tutorial) but regardless, when I try to load the GDT, QEMU triple faults and resets. I've also tried it on my own hardware with the same result (I wasn't going to kid myself it was QEMU's fault anyway). I've actually managed to isolate the triple fault o one line of code -- if I comment it out, no triple fault (but nothing else happens either).
When I comment out the aforementioned line of code:
The offending line of code (it's the far jump) and it's function of residence:
If you want to see any more code, ask and you shall receive. Note: if I comment out a call to gdt_init() (which calls gdt_flush) I can get past loading the IDT but testing interrupts fails (obviously). I've tried many things, including completely rewriting the GDT code. Also, the triple fault still occurs even if gdt_init() is the only function called (even if I call it from plx_start which is the entry function called by GRUB) so that would indicate that it has to be gdt_init() (or a subfunction thatof) causing the triple fault.
Also, before anyone asks, yes, I did steal the message prefixes from Arch Linux (where lines are prefixed with ":: " and continuations of them with " > "). Arch is the gr33test.
Code: Select all
& 0xF0
Code: Select all
& 0x0F
---
Note: I have searched the forums and the illustrious Internets but to no avail. One of the search phrases I used on Google was "gdt triple fault site:osdev.org" and I also used the forums' inbuilt search function, as well as reading the wiki page on GDT issues, but like I say, nothing doing.
Anyway, I have been working away for a few hours over the past few days (due to a "bank holiday" in England and a day off at school, I've been enjoying a 4 day weekend) and I've gotten a little further than before (the hard disk of the laptop I was using at the time died and I lost all my code) in some ways but I'm stuck on the GDT (again). I once managed to get past the GDT and got to the point of starting up interrupts when all went to hell, but this time I haven't even gotten that far. I've tried several different things, I've made sure all my structures are correct, my functions do the right thing and what-not (I'm still basing this code James M's tutorial) but regardless, when I try to load the GDT, QEMU triple faults and resets. I've also tried it on my own hardware with the same result (I wasn't going to kid myself it was QEMU's fault anyway). I've actually managed to isolate the triple fault o one line of code -- if I comment it out, no triple fault (but nothing else happens either).
When I comment out the aforementioned line of code:
The offending line of code (it's the far jump) and it's function of residence:
Code: Select all
; gdt_flush: load the Global Descriptor Table
gdt_flush:
; Load the GDT pointer passed on the stack
mov eax, [esp + 4]
lgdt [eax]
; Load segment selectors
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
; Far jump to the code segment
;;;;jmp 0x08:.done
.done:
ret
Also, before anyone asks, yes, I did steal the message prefixes from Arch Linux (where lines are prefixed with ":: " and continuations of them with " > "). Arch is the gr33test.