update
This commit is contained in:
parent
ae921df0de
commit
ccf3ae1dd1
6 changed files with 144 additions and 39 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -1,9 +1,14 @@
|
||||||
build/
|
build/
|
||||||
.vscode
|
.vscode
|
||||||
.vscode/tasks.json
|
.vscode/tasks.json
|
||||||
|
roms/qemu-vgabios.bin
|
||||||
|
roms/vgabios.bin
|
||||||
build-elf.bat
|
build-elf.bat
|
||||||
build.bat
|
build.bat
|
||||||
build.sh
|
build.sh
|
||||||
run.bat
|
run.bat
|
||||||
.gdbinit
|
.gdbinit
|
||||||
.gdb_history
|
.gdb_history
|
||||||
|
link.ld
|
||||||
|
.gitignore
|
||||||
|
|
||||||
|
|
|
||||||
32
src/bda.asm
32
src/bda.asm
|
|
@ -70,8 +70,6 @@
|
||||||
%define BDA_CURSOR_PTR 0x001B ; pointeur vers l'image du curseur
|
%define BDA_CURSOR_PTR 0x001B ; pointeur vers l'image du curseur
|
||||||
%define BDA_CURSOR_BG 0x0020 ; 48 bytes max (3*16)
|
%define BDA_CURSOR_BG 0x0020 ; 48 bytes max (3*16)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; -----------------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------------
|
||||||
; PC components I/O ports
|
; PC components I/O ports
|
||||||
; -----------------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------------
|
||||||
|
|
@ -84,4 +82,32 @@
|
||||||
%define i8259_MASTER_CMD 0x20
|
%define i8259_MASTER_CMD 0x20
|
||||||
%define i8259_MASTER_DATA 0x21
|
%define i8259_MASTER_DATA 0x21
|
||||||
%define i8259_SLAVE_CMD 0xA0
|
%define i8259_SLAVE_CMD 0xA0
|
||||||
%define i8259_SLAVE_DATA 0xA1
|
%define i8259_SLAVE_DATA 0xA1
|
||||||
|
|
||||||
|
; -----------------------------------------------------------------------------------
|
||||||
|
; bda_setup
|
||||||
|
; Initialise la BDA à zéro
|
||||||
|
; -----------------------------------------------------------------------------------
|
||||||
|
bda_setup:
|
||||||
|
pusha
|
||||||
|
push ds
|
||||||
|
|
||||||
|
mov ax, BDA_SEGMENT
|
||||||
|
mov es, ax
|
||||||
|
|
||||||
|
mov ax, 0
|
||||||
|
mov cx,0xFF
|
||||||
|
xor di, di
|
||||||
|
rep stosb ; clear BDA area
|
||||||
|
|
||||||
|
mov ax, BDA_MOUSE_SEG
|
||||||
|
mov es, ax
|
||||||
|
|
||||||
|
mov ax, 0
|
||||||
|
mov cx,0xFF
|
||||||
|
xor di, di
|
||||||
|
rep stosb ; clear BDA area
|
||||||
|
|
||||||
|
pop ds
|
||||||
|
popa
|
||||||
|
ret
|
||||||
62
src/boot.asm
62
src/boot.asm
|
|
@ -28,7 +28,6 @@ bits 16
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
%define DEBUG_PORT 0xe9 ; 0x402 ou 0xe9
|
%define DEBUG_PORT 0xe9 ; 0x402 ou 0xe9
|
||||||
|
|
||||||
|
|
||||||
; initial stack
|
; initial stack
|
||||||
%define STACK_SEG 0x0030 ; compatible avec le BMM (Bios Memory Maps)
|
%define STACK_SEG 0x0030 ; compatible avec le BMM (Bios Memory Maps)
|
||||||
%define STACK_TOP 0x0100 ; choix commun en RAM basse (pile descendante)
|
%define STACK_TOP 0x0100 ; choix commun en RAM basse (pile descendante)
|
||||||
|
|
@ -46,7 +45,6 @@ bits 16
|
||||||
%include "./bda.asm"
|
%include "./bda.asm"
|
||||||
|
|
||||||
%include "./services/macros.asm"
|
%include "./services/macros.asm"
|
||||||
|
|
||||||
%include "./drivers/debug.asm"
|
%include "./drivers/debug.asm"
|
||||||
%include "./drivers/gfx_cgam.asm"
|
%include "./drivers/gfx_cgam.asm"
|
||||||
%include "./drivers/mouse_ps2.asm"
|
%include "./drivers/mouse_ps2.asm"
|
||||||
|
|
@ -54,7 +52,7 @@ bits 16
|
||||||
%include "./services/generic.asm"
|
%include "./services/generic.asm"
|
||||||
|
|
||||||
err_vganok db 'VGA Not Initialized',0
|
err_vganok db 'VGA Not Initialized',0
|
||||||
err_end db 'code completed successfully',0
|
;err_end db 'code completed successfully',0
|
||||||
|
|
||||||
reset:
|
reset:
|
||||||
cli
|
cli
|
||||||
|
|
@ -71,6 +69,9 @@ reset:
|
||||||
mov ss, ax
|
mov ss, ax
|
||||||
mov sp, 0x1000 ; sommet de pile
|
mov sp, 0x1000 ; sommet de pile
|
||||||
|
|
||||||
|
; initialisation du BDA
|
||||||
|
call bda_setup
|
||||||
|
|
||||||
; installé une table d'interruption "dummy"
|
; installé une table d'interruption "dummy"
|
||||||
call ivt_setup
|
call ivt_setup
|
||||||
|
|
||||||
|
|
@ -78,37 +79,52 @@ reset:
|
||||||
call pic_init
|
call pic_init
|
||||||
sti
|
sti
|
||||||
|
|
||||||
; load other Rom
|
; load Roms
|
||||||
call setup_load_rom
|
call setup_load_rom
|
||||||
|
|
||||||
; on vérifie que le BIOS VGA a installer l'INT 10h
|
; on vérifie que le BIOS VGA a installé une INT 10h
|
||||||
call setup_check_vga
|
call setup_check_vga
|
||||||
|
|
||||||
; on active le mode graphique
|
; on active le mode graphique
|
||||||
call gfx_init
|
; call gfx_init
|
||||||
|
|
||||||
|
call kbd_init
|
||||||
|
|
||||||
call mouse_reset
|
call mouse_reset
|
||||||
call mouse_init
|
call mouse_init
|
||||||
|
|
||||||
|
|
||||||
; test a line
|
|
||||||
; mov cx,50
|
|
||||||
;.bcl: ; mov dx,cx
|
|
||||||
; mov bl,0
|
|
||||||
; push cx
|
|
||||||
; call gfx_putpixel
|
|
||||||
; pop cx
|
|
||||||
; inc cx
|
|
||||||
; cmp cx,150
|
|
||||||
; jle .bcl
|
|
||||||
;
|
|
||||||
; mov ax,cs
|
|
||||||
; mov ds,ax
|
|
||||||
;
|
|
||||||
; mov si, err_end
|
|
||||||
; call debug_puts
|
|
||||||
|
|
||||||
endless: nop
|
; on initialise le mode texte 80x25 par défaut DEBUG
|
||||||
|
mov ax, 0x0003
|
||||||
|
int 10h
|
||||||
|
|
||||||
|
endless:
|
||||||
|
mov dx,0
|
||||||
|
call scr_gotoxy
|
||||||
|
|
||||||
|
mov ax,BDA_MOUSE_SEG
|
||||||
|
mov ds,ax
|
||||||
|
|
||||||
|
mov ax,0 ; adresse début dump
|
||||||
|
mov si,ax
|
||||||
|
mov cx, 0x10
|
||||||
|
.dump:
|
||||||
|
mov al,[ds:si]
|
||||||
|
inc si
|
||||||
|
|
||||||
|
push ds
|
||||||
|
push si
|
||||||
|
|
||||||
|
call scr_puthex8
|
||||||
|
mov al,' '
|
||||||
|
call scr_putc
|
||||||
|
|
||||||
|
pop si
|
||||||
|
pop ds
|
||||||
|
|
||||||
|
loop .dump
|
||||||
|
|
||||||
jmp endless
|
jmp endless
|
||||||
|
|
||||||
; ------------------------------------------------------------------
|
; ------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -73,3 +73,55 @@ debug_puthex16:
|
||||||
pop ax
|
pop ax
|
||||||
call debug_puthex8
|
call debug_puthex8
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
; --- screen text functions ---
|
||||||
|
; AH = page
|
||||||
|
; DH = row
|
||||||
|
; DL = column
|
||||||
|
scr_gotoxy:
|
||||||
|
mov ah, 02h
|
||||||
|
mov bh, 0 ; page 0
|
||||||
|
int 10h
|
||||||
|
ret
|
||||||
|
|
||||||
|
scr_putc:
|
||||||
|
mov ah, 0x0E
|
||||||
|
int 10h
|
||||||
|
ret
|
||||||
|
|
||||||
|
; AL = 0..15 -> print hex digit
|
||||||
|
scr_puthex4:
|
||||||
|
and al, 0Fh ; mask 4 bits low
|
||||||
|
cmp al, 9 ; is it 0..9 ?
|
||||||
|
jbe .num ; yes
|
||||||
|
add al, 'A' - 10 ; convert to 'A'..'F'
|
||||||
|
jmp .pout
|
||||||
|
.num:
|
||||||
|
add al, '0' ; convert to '0'..'9'
|
||||||
|
.pout:
|
||||||
|
mov ah, 0x0E
|
||||||
|
int 10h
|
||||||
|
ret
|
||||||
|
|
||||||
|
; AL = byte -> print 2 hex digits
|
||||||
|
scr_puthex8:
|
||||||
|
push ax
|
||||||
|
push bx
|
||||||
|
mov bl, al ; save al
|
||||||
|
shr al, 4 ; 4 bits plus significatifs
|
||||||
|
call scr_puthex4
|
||||||
|
mov al, bl ; restore al
|
||||||
|
call scr_puthex4
|
||||||
|
pop bx
|
||||||
|
pop ax
|
||||||
|
ret
|
||||||
|
|
||||||
|
; AX = word -> print 4 hex digits
|
||||||
|
scr_puthex16:
|
||||||
|
push ax
|
||||||
|
mov al, ah
|
||||||
|
call scr_puthex8
|
||||||
|
pop ax
|
||||||
|
call scr_puthex8
|
||||||
|
ret
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,9 @@ kbd_map_nomod:
|
||||||
db 'q','w','e','r','t','y','u','i','o','p','[',']'
|
db 'q','w','e','r','t','y','u','i','o','p','[',']'
|
||||||
db 13 ; 1C Enter
|
db 13 ; 1C Enter
|
||||||
db 0 ; 1D Ctrl
|
db 0 ; 1D Ctrl
|
||||||
db 'a','s','d','f','g','h','j','k','l',';','\'', '`'
|
db 'a','s','d','f','g','h','j','k','l',';',0x27, 0x60
|
||||||
db 0 ; 2A LShift
|
db 0 ; 2A LShift
|
||||||
db '\\','z','x','c','v','b','n','m',',','.','/'
|
db 0x5c,'z','x','c','v','b','n','m',',','.','/'
|
||||||
db 0 ; 36 RShift
|
db 0 ; 36 RShift
|
||||||
db '*' ; 37 keypad *
|
db '*' ; 37 keypad *
|
||||||
db 0 ; 38 Alt
|
db 0 ; 38 Alt
|
||||||
|
|
@ -213,6 +213,22 @@ kbd_buf_pop:
|
||||||
; Keyboard ISR (INT 09h)
|
; Keyboard ISR (INT 09h)
|
||||||
; -----------------------------------------------------------
|
; -----------------------------------------------------------
|
||||||
kbd_isr:
|
kbd_isr:
|
||||||
|
pusha
|
||||||
|
|
||||||
|
in al, 0x60 ; consomme scancode (obligatoire)
|
||||||
|
|
||||||
|
mov dx, 0x00E9 ; debugcon
|
||||||
|
mov al, '*'
|
||||||
|
out dx, al
|
||||||
|
|
||||||
|
mov al, 0x20 ; EOI master
|
||||||
|
out 0x20, al
|
||||||
|
|
||||||
|
popa
|
||||||
|
iret
|
||||||
|
|
||||||
|
|
||||||
|
; kbd_isr:
|
||||||
push ds
|
push ds
|
||||||
pusha
|
pusha
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -170,16 +170,6 @@ mouse_init:
|
||||||
mov ax, cs
|
mov ax, cs
|
||||||
mov word [ds:si], cs
|
mov word [ds:si], cs
|
||||||
|
|
||||||
; test: aussi installer sur 0x2C (si PIC remappé base 0x28)
|
|
||||||
;mov si, 0x2C*4
|
|
||||||
;xor ax, ax
|
|
||||||
;mov ds, ax
|
|
||||||
;mov word [ds:si], mouse_handler
|
|
||||||
;add si, 2
|
|
||||||
;mov ax, cs
|
|
||||||
;mov word [ds:si], ax
|
|
||||||
|
|
||||||
|
|
||||||
sti
|
sti
|
||||||
|
|
||||||
mov dx, 0x00E9
|
mov dx, 0x00E9
|
||||||
|
|
@ -321,7 +311,7 @@ mouse_handler:
|
||||||
; vider le byte qui a déclenché IRQ12
|
; vider le byte qui a déclenché IRQ12
|
||||||
in al, PS2_PORT_BUFFER
|
in al, PS2_PORT_BUFFER
|
||||||
|
|
||||||
mov dx, 0x00E9 ; debugcon
|
mov dx, 0xE9 ; debugcon
|
||||||
mov al, '*'
|
mov al, '*'
|
||||||
out dx, al ; imprime directement
|
out dx, al ; imprime directement
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue