I've problem. Last days I'm playing with GDT, A20 and protected mode. I have this simple code for GDT:
gdt_start:
gdt_null:
dd 00000000h
dd 00000000h
gdt_code:
dw 0xFFFF
dw 0
db 0
db 10011010b
db 11001111b
db 00000000b
gdt_data:
dw 0xFFFF
dw 0
db 0
db 10010010b
db 11001111b
db 0
gdt_end:
gdt_ptr:
dw gdt_end - gdt_data - 1
dd gdt_start
install_gdt:
cli;
pusha
lgdt [gdt_ptr]
sti
popa
ret
As you can see it's very simple. Here's my A20 enabling:
ena20:
mov al, 0xDD
out 0x64, al
ret
And part of second stage code:
call install_gdt
call ena20
cli
mov eax, cr0
or eax, 1
mov cr0, eax
jmp 0x8:stage3
;-------------------------------------------
;STAGE3
;-------------------------------------------
BITS 32
stage3:
;mov ax, 0x10
;mov ds, ax
;mov ss, ax
;mov es, ax
;mov esp, 90000h
;mov edi, 0xB8000
;mov byte [edi], 'A'
jmp $
I tried to go step-by-step. I can successfuly load GDT into it's register, enable A20 and go to protected mode. But when I'm trying to jmp 0x8:stage3
, I'm getting error from VirtualBox:
A critical error has occurred while running the virtual machine and
the machine execution has been stopped.
(virtual machine state is now 'Guru Meditation') Does anybody know where is problem? What should I do to make it working? Please help.