add comment / corrections

This commit is contained in:
Frater 2026-01-08 11:46:04 +01:00
commit 3a7382c761
8 changed files with 247 additions and 41 deletions

View file

@ -4,4 +4,4 @@ cd src
"c:\program files\NASM\nasm" -f bin boot.asm -o ..\build\bios.bin
cd ..
qemu-system-x86_64 -bios build/bios.bin -device loader,file=build/vgabios.bin,addr=0xC0000,force-raw=on -device isa-debugcon,chardev=myconsole -chardev stdio,id=myconsole -k be -display sdl
qemu-system-x86_64 -bios build/bios.bin -device loader,file=roms/vgabios.bin,addr=0xC0000,force-raw=on -device isa-debugcon,chardev=myconsole -chardev stdio,id=myconsole -k be -display sdl

View file

@ -1,6 +1,31 @@
; =============================================================================
; Project : Custom BIOS / ROM
; File : bda.asm
; Author : frater
; Created : 06 jan 2026
;
; License : GNU General Public License v3.0 or later (GPL-3.0+)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <https://www.gnu.org/licenses/>.
;
; =============================================================================
;
; https://wiki.nox-rhea.org/back2root/ibm-pc-ms-dos/hardware/informations/bios_data_area
;
%define BDA_SEGMENT 0x0040 ; segment BDA
; custom var

View file

@ -1,37 +1,56 @@
; =============================================================================
; Project : Custom BIOS / ROM
; File : boot.asm
; Author : frater
; Created : 06 jan 2026
;
; License : GNU General Public License v3.0 or later (GPL-3.0+)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <https://www.gnu.org/licenses/>.
;
; =============================================================================
BITS 16
org 0
; ---------------------------------------------------------------------------
;
; configuration du bios
;
; ---------------------------------------------------------------------------
%define DEBUG_PORT 0xe9 ; 0x402 ou 0xe9
%define VIDEO_SEG 0xB800 ; ou 0xB000
%define VIDEO_ATTR 0x07
; initial stack
%define STACK_SEG 0x0030
%define STACK_TOP 0x0100 ; choix commun en RAM basse (pile descend)
%define STACK_SEG 0x0030 ; compatible avec le BMM (Bios Memory Maps)
%define STACK_TOP 0x0100 ; choix commun en RAM basse (pile descendante)
%define MEM_SEG_DEB 0x0800 ; 0x0800:0000 = 0x8000 (32KB) évite IVT/BDA + stack 7C00
%define MEM_SEG_END 0xA000 ; 0xA000:0000 = 0xA0000 (début zone vidéo)
%define MEM_SEG_STEP 0x0040 ; 1KB = 0x400 bytes = 0x40 paragraphs
jmp reset ; ce jump n'est pas sensé être executer, il est présent uniquement pour le debug
; definition du BDA
%include ".\bda.asm"
jmp reset
%include ".\drivers\debug.asm"
%include ".\drivers\gfx_cgam.asm"
%include ".\drivers\mouse_ps2.asm"
err_novga db 'No VGA Card BIOS',0
err_vganok db 'VGA Not Initialized',0
err_end db 'code completed successfully',0
@ -74,10 +93,10 @@ endless: nop
jmp endless
; ---------------------------------------------------------------------------
; Détection les ROM supplementaires
; Teste la RAM de 0xC000 jusquà 0xE000, par pas de 2KB.
; Test si le vecteur INT 10h à été modifié (par la ROM)
;
; Si une ROM est détectée, le code de la ROM sera appelé.
; Si le vecteur n'a pas été modifiée, on considère que la ROM video n'a pas
; été chargée.
; ---------------------------------------------------------------------------
setup_check_vga:
; vérification de l'offset 0x0000:0x0040 qui DOIT etre différent de @default_isr
@ -91,12 +110,11 @@ setup_check_vga:
; Comparer avec default_isr (offset) et CS (segment)
mov dx, default_isr ; DX = offset default_isr (dans notre CS)
cmp bx, dx
jne .init_ok ; interrupt different
jne .init_ok ; vecteur different, bios initialisé
cmp cx, ax
jne .init_ok
; no VGA init
mov ax,cs
mov ax,cs ; vecteur identique, sans doute pas d'initialisation
mov ds,ax
mov si, err_vganok
@ -112,7 +130,6 @@ setup_check_vga:
; ---------------------------------------------------------------------------
setup_load_rom:
mov bx, 0xC000
mov al,'*'
.scanloop:
mov ds, bx
cmp word[0x0000],0xAA55 ; ROM signature
@ -133,20 +150,11 @@ setup_load_rom:
add bx, 0x80 ; add 2kb
cmp bx, 0xE000
jbe .scanloop
cmp al,'.'
je .end
; no rom found :
mov bx,cs
mov ds,bx
mov si, err_novga
call debug_puts
.end:
ret
; ---------------------------------------------------------------------------
; Détection RAM conventionnelle (8088, BIOS maison) — sans BIOS
; Détection RAM conventionnelle
; Teste la RAM de MEM_SEG_DEB jusquà 0xA000 (640KB), par pas de 1KB.
; Méthode: sauvegarde 1 mot, écrit 2 patterns, relit, restaure.
;
@ -217,9 +225,6 @@ setup_ram:
; ---------------------------------------------------------------------------
; IVT install (8088, mode réel) - remplit les 256 vecteurs avec un handler IRET
; Hypothèses:
; - code en ROM (CS typiquement = 0xF000), handler réside dans ce même segment
; - interruptions désactivées (CLI) pendant l'installation
; ---------------------------------------------------------------------------
setup_ivt:
; installation de la table d'interrupts

View file

@ -1,4 +1,25 @@
; =============================================================================
; Project : Custom BIOS / ROM
; File : debug.asm
; Author : frater
; Created : 06 jan 2026
;
; License : GNU General Public License v3.0 or later (GPL-3.0+)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <https://www.gnu.org/licenses/>.
;
; =============================================================================
debug_puts:
.next:

View file

@ -1,3 +1,27 @@
; =============================================================================
; Project : Custom BIOS / ROM
; File : boot.asm
; Author : frater
; Created : 06 jan 2026
;
; License : GNU General Public License v3.0 or later (GPL-3.0+)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <https://www.gnu.org/licenses/>.
;
; =============================================================================
%define GFX_MODE 0x06 ; MCGA HiRes (B/W)
%define GFX_WIDTH 640
%define GFX_HEIGHT 200

View file

@ -1,6 +1,31 @@
; =============================================================================
; Project : Custom BIOS / ROM
; File : gfx_cgam.asm
; Author : frater
; Created : 06 jan 2026
;
; graphics drivers for CGA 640x200x2
; License : GNU General Public License v3.0 or later (GPL-3.0+)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <https://www.gnu.org/licenses/>.
;
; =============================================================================
;
; graphics drivers pour carte video/mode CGA-Mono (640x200x2)
;
%define VIDEO_SEG 0xB800 ; ou 0xB000
%define GFX_MODE 0x06 ; MCGA HiRes (B/W)
%define GFX_WIDTH 640
%define GFX_HEIGHT 200
@ -9,8 +34,12 @@
%define CGA_ODD_BANK 0x2000
%define BG16_SIZE 48
; ce mode est entrelacé, un bit/pixel, 8 pixels par octet
; ------------------------------------------------------------
; initialise le mode graphique (via l'int 10h)
;
; ce mode est entrelacé, un bit/pixel, 8 pixels par octet
; ------------------------------------------------------------
gfx_init:
; init graphics mode
mov ah, 0x00 ; AH=00h set video mode
@ -21,17 +50,72 @@ gfx_init:
ret
; PutPixel(x=cx, y=dx, color=al) sur page bh
; ------------------------------------------------------------
; Dessine un pixel, accès VRAM direct.
;
; In:
; CX = x (0..639)
; DX = y (0..199)
; AL = color (0=black, !=0=white)
;
; ------------------------------------------------------------
gfx_putpixel:
mov ah, 0Ch
;mov al, 0Fh ; couleur (0..15)
;mov bh, 00h ; page
;mov cx, 100 ; x
;mov dx, 50 ; y
int 10h
push bx
push di
push es
mov ax, VIDEO_SEG
mov es, ax
; DI = (y>>1)*80 + (x>>3) + (y&1)*0x2000
mov bx, dx
and bx, 1 ; BX = y&1
mov ax, dx
shr ax, 1 ; AX = y>>1
mov di, ax
mov ax, di
mov di, CGA_STRIDE
mul di ; DX:AX = (y>>1)*80
mov di, ax
test bx, 1
jz .bank_ok
add di, CGA_ODD_BANK
.bank_ok:
mov ax, cx
shr ax, 3 ; AX = x>>3
add di, ax
; masque bit = 0x80 >> (x&7)
mov bl, cl
and bl, 7 ; BL = x&7
mov ah, 080h
mov cl, bl
shr ah, cl ; AH = bitmask
; write
cmp al, 0
je .clear
.set:
or byte [es:di], ah
jmp .done
.clear:
not ah
and byte [es:di], ah
.done:
pop es
pop di
pop bx
ret
; draw background pattern
; ------------------------------------------------------------
; Dessine un background "check-board", accès VRAM direct.
;
; ------------------------------------------------------------
gfx_background:
mov ax,VIDEO_SEG
mov es,ax

View file

@ -1,5 +1,29 @@
; =============================================================================
; Project : Custom BIOS / ROM
; File : mouse_ps2.asm
; Author : frater
; Created : 06 jan 2026
;
; controlleur de souris via le i8042 (PC Classique)
; License : GNU General Public License v3.0 or later (GPL-3.0+)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <https://www.gnu.org/licenses/>.
;
; =============================================================================
;
; controleur de souris via le i8042 (PC Classique)
;
%define PS2_PORT_BUFFER 0x60

View file

@ -1,3 +1,26 @@
; =============================================================================
; Project : Custom BIOS / ROM
; File : textmode.asm
; Author : frater
; Created : 06 jan 2026
;
; License : GNU General Public License v3.0 or later (GPL-3.0+)
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <https://www.gnu.org/licenses/>.
;
; =============================================================================
;
; text mod functions
;