Triple fault when jumping to p-mode
Posted: Sun Jul 27, 2008 4:37 pm
Hi,
I'm having a brutal hand to CPU fight, which I am losing at the moment. I'm trying to jump to p-mode, but something with the gtd is messed up so bochs triple faults and resets.
This piece of code comes from the second stage boot loader, which is loaded at 0x1000:0x0000.
And this is the output from bochs:
Help is very welcome 
I'm having a brutal hand to CPU fight, which I am losing at the moment. I'm trying to jump to p-mode, but something with the gtd is messed up so bochs triple faults and resets.
This piece of code comes from the second stage boot loader, which is loaded at 0x1000:0x0000.
Code: Select all
PMODE:
; go to protected mode
cli
lgdt [gdtr + 0x1000] ;Load GDT
mov eax, cr0
or eax, 1
mov cr0, eax
jmp 0x08 : PMODEMAIN + 0x1000 ; <- fatal
; running in pmode now
[BITS 32]
PMODEMAIN:
; setup segements
mov ax, 10h
mov ds, ax ; Move a valid data segment into the data segment register
mov ss, ax ; Move a valid data segment into the stack segment register
mov esp, 090000h ; Move the stack pointer to 090000h
Code: Select all
[BITS 16]
gdt: ; Address for the GDT
gdt_null: ; Null Segment
dd 0
dd 0
gdt_code: ; Code segment, read/execute, nonconforming
dw 0FFFFh
dw 0
db 0
db 10011010b
db 11001111b
db 0
gdt_data: ; Data segment, read/write, expand down
dw 0FFFFh
dw 0
db 0
db 10010010b
db 11001111b
db 0
gdt_end:
gdtr: ; GDT descriptor
dw gdt_end - gdt - 1 ; Limit (size)
dd gdt + 0x1000 ; Address of the GDT
Code: Select all
00039059350i[BIOS ] Booting from 0000:7c00
00041317348e[CPU ] fetch_raw_descriptor: GDT: index (f)1 > limit (0)
00041317348i[CPU ] CPU is in protected mode (active)
00041317348i[CPU ] CS.d_b = 16 bit
00041317348i[CPU ] SS.d_b = 16 bit
00041317348i[CPU ] | EAX=60000011 EBX=00000007 ECX=00000027 EDX=00000fff
00041317348i[CPU ] | ESP=0000fff7 EBP=00000000 ESI=ffff041a EDI=00080005
00041317348i[CPU ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf zf af PF cf
00041317348i[CPU ] | SEG selector base limit G D
00041317348i[CPU ] | SEG sltr(index|ti|rpl) base limit G D
00041317348i[CPU ] | CS:0100( 0004| 0| 0) 00001000 0000ffff 0 0
00041317348i[CPU ] | DS:0100( 0005| 0| 0) 00001000 0000ffff 0 0
00041317348i[CPU ] | SS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00041317348i[CPU ] | ES:2000( 0005| 0| 0) 00020000 0000ffff 0 0
00041317348i[CPU ] | FS:0100( 0005| 0| 0) 00001000 0000ffff 0 0
00041317348i[CPU ] | GS:0100( 0005| 0| 0) 00001000 0000ffff 0 0
00041317348i[CPU ] | EIP=0000002f (0000002f)
00041317348i[CPU ] | CR0=0x60000011 CR1=0 CR2=0x00000000
00041317348i[CPU ] | CR3=0x00000000 CR4=0x00000000
00041317348i[CPU ] >> jmp far 0008:1034 : EA34100800
00041317348e[CPU ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00041317348i[SYS ] bx_pc_system_c::Reset(SOFTWARE) called
00041317348i[CPU ] cpu software reset