Can't jump to 32 bits, gdt problem?
Posted: Sun Oct 11, 2009 9:03 am
Dear thread reader,
Seeing that the tutorials have progressed quite far since the last time I checked them I finally began with my own os. Using the tutorials as a guide. I got the bootloader done and I'm working on the second stage right now. But when I try to jump to the 32 bit code my os triple faults. Here is what bochs tells me:
So here is the code, in the hope that some bright mind can solve my error.
The gdt table:
The gdt init code:
And finally the pmode code:
If I hang the os with 'jmp $' just after I enabled pmode there is no crash. So the jump (just as bochs indicated) is the problem. There is a other thread on this forum regarding a similar problem. Although the fix proposed there doesn't work for me. It keeps giving the exact same error msg.
If I change 'jmp code:xboot2_32' into 'jmp xboot2_32' it works. But something tells me that I need to make a far jump into the 32 bit code section. But since the other jump works I suspect there is something wrong with the gdt (just as indicated by google).
Thanks in advance for any time someone may spend on helping me out!
Seeing that the tutorials have progressed quite far since the last time I checked them I finally began with my own os. Using the tutorials as a guide. I got the bootloader done and I'm working on the second stage right now. But when I try to jump to the 32 bit code my os triple faults. Here is what bochs tells me:
I searched the web with this error (jump_protected: gate type 0 unsuporrted) and got a bunch of results of people who are trying to jump to 32 bit code, all reactions seem to indicate that its a gdt problem. I tried all the solutions posted on those forms but they didn't solve it.00015706189e[CPU0 ] jump_protected: gate type 0 unsupported
00015706189i[CPU0 ] CPU is in protected mode (active)
....
00015706189i[CPU0 ] >> jmp far 0008:0679 : EA79060800
So here is the code, in the hope that some bright mind can solve my error.
The gdt table:
Code: Select all
;;gdt table
gdt_start:
dd 0
dd 0
code equ $-gdt_start
dw 0xFFFF
dw 0
db 0
db 10011010b
db 11001111b
db 0
data equ $-gdt_start
dw 0xFFFF
dw 0
db 0
db 10010010b
db 11001111b
db 0
gdt_table:
dw gdt_table - gdt_start - 1
dw gdt_start
Code: Select all
;;setup gdt
gdt_init:
;;got this from one of the forums. But it doesn't solve anything. It sets the base of the code descriptor to the contents of cs
;;mov eax, 0
;;mov ax, cs
;;and eax, 0xFFFF
;;shl eax, 4
;;mov word [code+2], ax
;;shr eax, 16
;;mov byte [code+4], al
;;mov byte [code+7], ah
;;set gdt
cli
pusha
lgdt [gdt_table]
popa
sti
ret
Code: Select all
;;the 32 bit setup part
bits 16
bits32_init:
;;disable interupts and enable pmode
cli
mov eax, cr0
or eax, 1
mov cr0, eax
;;jump to the 32 bit part
jmp code:xboot2_32
;;the 32 bit part
bits 32
xboot2_32:
jmp $
;;set registers
mov ax, data
mov ds, ax
mov ss, ax
mov es, ax
mov esp, 0xFFFF
;;hang
jmp $
If I change 'jmp code:xboot2_32' into 'jmp xboot2_32' it works. But something tells me that I need to make a far jump into the 32 bit code section. But since the other jump works I suspect there is something wrong with the gdt (just as indicated by google).
Thanks in advance for any time someone may spend on helping me out!