I've got a problem while changing into protected mode with my 2 stage loader.
Bochs is telling me the following message every time when it should do the far jump to finally change into pmode:
That's weird for me because the 0x8 should have been the code descriptor and not a code segment.check_cs(0x0008): not a valid code segment!
I've already used Bochs internal debugger and it told me that the GDT table should have been loaded correctly.
I'm new to protected mode, so every help will be appreciated.
Here are the important parts of my code:
Code: Select all
[BITS 16]
[ORG 0x0000]
MAIN:
MOV AX, CS ; Startsegment des Kernels in AX schreiben... (0x100)
MOV DS, AX ; ... und danach in die folgenden Register
MOV ES, AX
MOV FS, AX
MOV GS, AX
XOR AX, AX
MOV SS, AX
MOV SP, 0xFFFF
MOV SI, AktivatorExec
CALL PRINT_STRING
MOV SI, PModeStart
CALL PRINT_STRING
XOR AX, AX ; AX = 0 -> A20 Gate aktivieren
CALL CheckA20 ; A20 Gate de-/aktivieren
CLI
PUSHA
LGDT [GDT]
POPA
MOV EAX, CR0
OR EAX, 1
MOV CR0, EAX
JMP 0x8:PMode ; 0x8 -> 2. Deskriptor (CODE_Desc)
[...] ; UNimportant parts of my code (variables and funtions like enabling A20 or printing a string)
;************************************************;
;******************** GDT ***********************;
;************************************************;
GDT:
DW GDTEnd - NULL_Desc - 1 ; GDT limit
DD NULL_Desc ; GDT base
NULL_Desc:
DD 0
DD 0
CODE_Desc:
DW 0xFFFF
DW 0x0000
DB 0x00
DB 10011010b
DB 11001111b
DB 0x00
DATA_Desc:
DW 0xFFFF
DW 0x0000
DB 0x00
DB 10011010b
DB 11001111b
DB 0x00
GDTEnd:
[BITS 32]
PMode:
MOV AX, 0x10 ; AX -> 3. Deskriptor (DATA_Desc)
MOV DS, AX
MOV ES, AX
MOV FS, AX
MOV GS, AX
MOV SS, AX
MOV ESP, 0x90000
JMP $
Thanks.