i am developing simple OS, but after moving into PMode I cannot use 0xb8000 memory to write something to te screen.
Till now, ive done
- INT 10H to change video mode to 0 ( 40x25 chars)
- load "kernel" to 0x500:0 (with INT 0x13)
- load simple GDT (code descriptor from 0x0 up to 4gb, same to data descriptor)
- move to PMode (with far jump after this)
- load IDT (filled with zeros at this time )
- configure PIC
- enable A20gate by 0x64 keyboard port
know i tried many various methods, not only with b800 but also a0000, b0000 but nothing happened. I use VMWare 6.5.2, but i tested on VirtualBox with the same result.
Compilator - nasm
bootloader:
Code: Select all
; ==================================== STAGE 1 ====================================
ORG 0x7C00 ; w ktorym miejscu pamieci sie znajdujemy
BITS 16 ; jestesmy w trybie 16 bitowym
MOV ah,0x0
MOV al,0
INT 0x10
; odczytujemy drugi sektor dysku twardego
MOV ah,0x02 ; nr funkcji
MOV al,5 ; liczba sektorow do odczytania
MOV ch,0 ; nr cylindra
MOV cl,2 ; nr sektora
MOV dh,0 ; glowica
MOV dl,0x80 ; numer napedu (0x80 - dysk #0, 0x81 - dysk #1 )
; nasz kod znajdzie sie pod adresem ES:BX - 0x50:0
MOV bx,0x050
MOV es,bx ; wrzucamy adres do es
XOR bx,bx ; zerujemy bx
INT 0x13
JC blad
JMP 0x050:0x0000
blad:
HLT ; zatrzymujemy procesor
times 510-($-$$) db 0
dw 0xAA55 ; standardowa koncowka bootloadera
Code: Select all
ORG 0x500
BITS 16
; ==================================== STAGE 2 ====================================
CLI
XOR ax,ax
MOV ds,ax
MOV es,ax
MOV ax,0x9000
MOV ss,ax
MOV sp,0xFFFF
CLI
LGDT [toc]
JMP far_jump_after_lgdt
far_jump_after_lgdt:
;CALL load_gdt ; ladujemy GDT
MOV ebx,cr0 ; rejestru cr0 nie mozemy bezposrednio modyfikowac
OR ebx,0x1 ; ustawiamy najmlodszy bit
MOV cr0,ebx
JMP Stage3
; ==================================== STAGE 3 ====================================
; witamy w 32bitowym swiecie:)
Stage3:
BITS 32
CLI
MOV ax,0x10
MOV ds,ax
MOV ss,ax
MOV es,ax
MOV esp,0x90000
LIDT[idt_ptr]
MOV al, 0x11
OUT 0x20,al
OUT 0xA0,al
; ICW2
MOV al,0x20
OUT 0x21,al
MOV al,0x28
OUT 0xA1,al
; ICW 3
MOV al,0x4
OUT 0x21,al
;ICW4
MOV al,0x1
OUT 0x21,al
OUT 0xA1,al
MOV al,0x0
OUT 0x21,al
OUT 0xA1,al
; A20
CLI
MOV al,0xDD
OUT 0x64,al
;MOV ebx,0xb8000
; nothing works! cant write to the screen!
MOV byte [es:0xb8000],'A'
MOV byte [es:0xb8001],1
MOV byte [es:0xb0000],'A'
MOV byte [es:0xb0001],1
; instead of HLT
aaa:
JMP aaa
; ================================ INSTRUKCJE GDT =================================
; This is the beginning of the GDT. Because of this, its offset is 0.
gdt_data:
; null descriptor offset 0x0
dd 0 ; null descriptor--just fill 8 bytes with zero
dd 0
; code descriptor offset 0x8
dw 0FFFFh ; limit low
dw 0 ; base low
db 0 ; base middle
db 10011010b ; access
db 11001111b ; granularity
db 0 ; base high
; data descriptor: offset 0x10
dw 0FFFFh ; limit low (Same as code)
dw 0 ; base low
db 0 ; base middle
db 10010010b ; access
db 11001111b ; granularity
db 0 ; base high
end_of_gdt:
toc:
dw end_of_gdt - gdt_data - 1 ; limit (Size of GDT)
dd gdt_data ; base of GDT
end_data:
idt_start: times 256 dq 0
idt_end:
idt_ptr:
.limit dw idt_end - idt_start
.base dd idt_start
sudo dd if=boot_st1.bin of=/dev/sdb/ bs=512 count=1
sudo dd if=boot_st2.bin of=/dev/sdb/ bs=512 count=1 seek=2
and - some comments are in polish