From ccf3ae1dd14573fd0d6fb758c3ddc76bd93273e6 Mon Sep 17 00:00:00 2001 From: Frater <13979047+saintfrater@users.noreply.github.com> Date: Thu, 15 Jan 2026 08:58:56 +0100 Subject: [PATCH] update --- .gitignore | 5 +++ src/bda.asm | 32 +++++++++++++++++-- src/boot.asm | 62 +++++++++++++++++++++++------------- src/drivers/debug.asm | 52 ++++++++++++++++++++++++++++++ src/drivers/keyboard_ps2.asm | 20 ++++++++++-- src/drivers/mouse_ps2.asm | 12 +------ 6 files changed, 144 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index cde4e12..f65926b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,14 @@ build/ .vscode .vscode/tasks.json +roms/qemu-vgabios.bin +roms/vgabios.bin build-elf.bat build.bat build.sh run.bat .gdbinit .gdb_history +link.ld +.gitignore + diff --git a/src/bda.asm b/src/bda.asm index 8eddf60..9be7bb5 100644 --- a/src/bda.asm +++ b/src/bda.asm @@ -70,8 +70,6 @@ %define BDA_CURSOR_PTR 0x001B ; pointeur vers l'image du curseur %define BDA_CURSOR_BG 0x0020 ; 48 bytes max (3*16) - - ; ----------------------------------------------------------------------------------- ; PC components I/O ports ; ----------------------------------------------------------------------------------- @@ -84,4 +82,32 @@ %define i8259_MASTER_CMD 0x20 %define i8259_MASTER_DATA 0x21 %define i8259_SLAVE_CMD 0xA0 -%define i8259_SLAVE_DATA 0xA1 \ No newline at end of file +%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 \ No newline at end of file diff --git a/src/boot.asm b/src/boot.asm index 99058ad..bef61d4 100644 --- a/src/boot.asm +++ b/src/boot.asm @@ -28,7 +28,6 @@ bits 16 ; --------------------------------------------------------------------------- %define DEBUG_PORT 0xe9 ; 0x402 ou 0xe9 - ; initial stack %define STACK_SEG 0x0030 ; compatible avec le BMM (Bios Memory Maps) %define STACK_TOP 0x0100 ; choix commun en RAM basse (pile descendante) @@ -46,7 +45,6 @@ bits 16 %include "./bda.asm" %include "./services/macros.asm" - %include "./drivers/debug.asm" %include "./drivers/gfx_cgam.asm" %include "./drivers/mouse_ps2.asm" @@ -54,7 +52,7 @@ bits 16 %include "./services/generic.asm" err_vganok db 'VGA Not Initialized',0 -err_end db 'code completed successfully',0 +;err_end db 'code completed successfully',0 reset: cli @@ -71,6 +69,9 @@ reset: mov ss, ax mov sp, 0x1000 ; sommet de pile + ; initialisation du BDA + call bda_setup + ; installé une table d'interruption "dummy" call ivt_setup @@ -78,37 +79,52 @@ reset: call pic_init sti - ; load other Rom + ; load Roms 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 ; on active le mode graphique - call gfx_init + ; call gfx_init + + call kbd_init call mouse_reset 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 ; ------------------------------------------------------------------ diff --git a/src/drivers/debug.asm b/src/drivers/debug.asm index 054715d..87fe27b 100644 --- a/src/drivers/debug.asm +++ b/src/drivers/debug.asm @@ -73,3 +73,55 @@ debug_puthex16: pop ax call debug_puthex8 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 diff --git a/src/drivers/keyboard_ps2.asm b/src/drivers/keyboard_ps2.asm index 81c352f..4057685 100644 --- a/src/drivers/keyboard_ps2.asm +++ b/src/drivers/keyboard_ps2.asm @@ -35,9 +35,9 @@ kbd_map_nomod: db 'q','w','e','r','t','y','u','i','o','p','[',']' db 13 ; 1C Enter 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 '\\','z','x','c','v','b','n','m',',','.','/' + db 0x5c,'z','x','c','v','b','n','m',',','.','/' db 0 ; 36 RShift db '*' ; 37 keypad * db 0 ; 38 Alt @@ -213,6 +213,22 @@ kbd_buf_pop: ; Keyboard ISR (INT 09h) ; ----------------------------------------------------------- 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 pusha diff --git a/src/drivers/mouse_ps2.asm b/src/drivers/mouse_ps2.asm index f84ba8b..56f9085 100644 --- a/src/drivers/mouse_ps2.asm +++ b/src/drivers/mouse_ps2.asm @@ -170,16 +170,6 @@ mouse_init: mov ax, 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 mov dx, 0x00E9 @@ -321,7 +311,7 @@ mouse_handler: ; vider le byte qui a déclenché IRQ12 in al, PS2_PORT_BUFFER - mov dx, 0x00E9 ; debugcon + mov dx, 0xE9 ; debugcon mov al, '*' out dx, al ; imprime directement