Jump to protected mode
Posted: Sun Jan 09, 2011 3:40 am
Hi!
I have a problem. Namely, he wants to jump to protected mode, but here I have a problem. Compiling goes well, but in a virtual machine is not working.
Everything goes well until the A20 line. Then there is nothing
PS. Speak English poorly.
This is the kernel code:
and gtd.inc :
I have a problem. Namely, he wants to jump to protected mode, but here I have a problem. Compiling goes well, but in a virtual machine is not working.
Everything goes well until the A20 line. Then there is nothing
PS. Speak English poorly.
This is the kernel code:
Code: Select all
BITS 16
ORG 0x8000
%include "header.inc"
dw START
%include "realmode/data.asm"
%include "realmode/video.asm"
%include "realmode/procedures.asm"
%include "realmode/a20.asm"
START:
cli
clr ax
mov ax, cs
mov ds, ax ; musimy zainicjować pozostałe rejestry
mov es, ax
sti
; Poczłątkowy napis włączenia się kernela
mov si, loadermsg
call print
; Włączenie A20!
mov si, a20msg
call print
call EnableA20
cli
lgdt [gdtr]
mov eax, cr0
or eax, 1
mov cr0, eax
jmp 0x08:pmode
%include "realmode/gdt.inc" ; dolaczamy plik z tablica gdt
[BITS 32] ; zaczynamy 32 bitowy kod
pmode:
mov ax, 0x10
mov ds, ax
mov es, ax
mov ss, ax
xor ax, ax
mov fs, ax
mov gs, ax
mov esp, 0x200000
call clrscr32
mov esi, welcome ; teraz musimy dawac wiadomosci do ESI
call print32
; call main ; wywolujemy funkcje main z kernela napisanego w C
jmp $ ; petla nieskonczona
clrscr32: ; funkcja czyszczaca ekran
mov edi, [printptr] ; do EDI 0xB8000
mov ecx, 40*25 ; do ECX liczba znakow na ekranie
mov eax, 0x02200220 ; do EAX 0x02 - kolor znaku, 0x20 - spacja ;)
rep stosd ; powtarzamy dopoki ECX != 0
ret
print32: ; funkcja wypisujaca komunikaty w trybie 32 bitowym
mov edi, [printptr] ; do EDI 0xB8000
.pisz:
lodsb
or al, al
jz .napisalem
stosw ; tym razem powtarzamy po 2 bajty dopoki nie napotkamy
konca ciagu, czyli 0
jmp .pisz
.napisalem:
mov [printptr], edi ; do printptr aktualna pozycja na ekranie
ret
printptr dd 0xB8000
welcome db "Witam w trybie chronionym ;)", 0
VISION_END:
Code: Select all
gdtr:
dw gdt - gdtend - 1
dd gdt
gdt:
dd 0x00000000, 0x00000000
dd 0x0000FFFF, 0x00CF9A00
dd 0x0000FFFF, 0x00CF9200
dd 0x0000FFFF, 0x00CFFA00
dd 0x0000FFFF, 0x00CFF200
gdtend: