Problem moving to protected mode...
Posted: Thu Jun 29, 2006 9:51 pm
After enabling protected mode, with A20 gate already open (don't know if it's important), I reloaded segment registers... it worked well (I used the QEMU command "info registers" to see the values in the Internal Descriptor Cache and they are in agreement with the GDT)...
But when reloading CS (i.e., far jump), QEMU stops responding with no error message... I had to kill it! On real hardware (I used a 486SX, but tomorrow I tell you what appened on my other computer, if needed: 686/AMDAthlon), the CPU just reseted...
Here is the relevant code:
-----------------------------------------------------------------
;CS = 0x1000
;Offsets origin = 0x0000
;Interrupts already disabled...
;Enabling A20 gate
call A20_enable
;Enabling protected Mode: Loading Global Descriptor Table
lgdt [cs:GDT_SIZE]
;Enabling protected Mode: Setting PE
mov eax, cr0
or eax, 1
mov cr0, eax
;Now in Protected Mode; Loading Segment Registers
mov ax, 0x0010
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
[BITS 32]
jmp 0x8:0x10000+start32
start32: jmp $
GDT db 0x00, 0x00, 0x00, 0x00, 0x00, 00000000b, 00000000b, 0x00 ;NULL entry
db 0xFF, 0xFF, 0x00, 0x00, 0x00, 10011010b, 01001111b, 0x00 ;Kernel Code
db 0xFF, 0xFF, 0x00, 0x00, 0x00, 10010010b, 01001111b, 0x00 ;Kernel Data
GDT_SIZE dw GDT_SIZE-GDT
GDT_BASE dd 0x10000+GDT
------------------------------------------------------------------------
A not-handled exception, parhaps? It's impossible to handle it now if I can't even load a code segment...
I've tried a bunch of bit patterns in some of the first selector (code) flags, none corrected the problem!
Tks in advance,
Jo?o Jer?nimo
But when reloading CS (i.e., far jump), QEMU stops responding with no error message... I had to kill it! On real hardware (I used a 486SX, but tomorrow I tell you what appened on my other computer, if needed: 686/AMDAthlon), the CPU just reseted...
Here is the relevant code:
-----------------------------------------------------------------
;CS = 0x1000
;Offsets origin = 0x0000
;Interrupts already disabled...
;Enabling A20 gate
call A20_enable
;Enabling protected Mode: Loading Global Descriptor Table
lgdt [cs:GDT_SIZE]
;Enabling protected Mode: Setting PE
mov eax, cr0
or eax, 1
mov cr0, eax
;Now in Protected Mode; Loading Segment Registers
mov ax, 0x0010
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
[BITS 32]
jmp 0x8:0x10000+start32
start32: jmp $
GDT db 0x00, 0x00, 0x00, 0x00, 0x00, 00000000b, 00000000b, 0x00 ;NULL entry
db 0xFF, 0xFF, 0x00, 0x00, 0x00, 10011010b, 01001111b, 0x00 ;Kernel Code
db 0xFF, 0xFF, 0x00, 0x00, 0x00, 10010010b, 01001111b, 0x00 ;Kernel Data
GDT_SIZE dw GDT_SIZE-GDT
GDT_BASE dd 0x10000+GDT
------------------------------------------------------------------------
A not-handled exception, parhaps? It's impossible to handle it now if I can't even load a code segment...
I've tried a bunch of bit patterns in some of the first selector (code) flags, none corrected the problem!
Tks in advance,
Jo?o Jer?nimo