InstallGDT function causes triple fault
Posted: Sat Feb 09, 2013 12:02 pm
I am using GRUB2 bootloader in my image.iso file.
GRUB2 boots my C kernel, and my kernel.c calls the asm function InstallGDT, defined as follows:
I am calling it like so:
But when I do this, I get a triple fault, Only if I am using Bochs, QEMU works fine.
Does anyone have any ideas or things I should try?
GRUB2 boots my C kernel, and my kernel.c calls the asm function InstallGDT, defined as follows:
Code: Select all
global InstallGDT
InstallGDT:
cli ; clear interrupts
pusha ; save registers
lgdt [toc] ; load GDT into GDTR
sti ; enable interrupts
popa ; restore registers
ret ; All done!
;*******************************************
; Global Descriptor Table (GDT)
;*******************************************
gdt_data:
dd 0 ; null descriptor
dd 0
; gdt code: ; code descriptor
dw 0FFFFh ; limit low
dw 0 ; base low
db 0 ; base middle
db 10011010b ; access
db 11001111b ; granularity
db 0 ; base high
; gdt data: ; data descriptor
dw 0FFFFh ; limit low (Same as code)
dw 0 ; base low
db 0 ; base middle
db 10010010b ; access
db 11001111b ; granularity
db 0 ; base high
end_of_gdt:
toc:
dw end_of_gdt - gdt_data - 1 ; limit (Size of GDT)
dd gdt_data ; base of GDT
Code: Select all
asm("cli");
InstallGDT();
Does anyone have any ideas or things I should try?