add comment / corrections
This commit is contained in:
parent
73ac87884a
commit
3a7382c761
8 changed files with 247 additions and 41 deletions
|
|
@ -4,4 +4,4 @@ cd src
|
||||||
"c:\program files\NASM\nasm" -f bin boot.asm -o ..\build\bios.bin
|
"c:\program files\NASM\nasm" -f bin boot.asm -o ..\build\bios.bin
|
||||||
cd ..
|
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
|
||||||
|
|
|
||||||
25
src/bda.asm
25
src/bda.asm
|
|
@ -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
|
; https://wiki.nox-rhea.org/back2root/ibm-pc-ms-dos/hardware/informations/bios_data_area
|
||||||
;
|
;
|
||||||
|
|
||||||
%define BDA_SEGMENT 0x0040 ; segment BDA
|
%define BDA_SEGMENT 0x0040 ; segment BDA
|
||||||
|
|
||||||
; custom var
|
; custom var
|
||||||
|
|
|
||||||
61
src/boot.asm
61
src/boot.asm
|
|
@ -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
|
BITS 16
|
||||||
org 0
|
org 0
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
;
|
;
|
||||||
; configuration du bios
|
; configuration du bios
|
||||||
;
|
;
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
%define DEBUG_PORT 0xe9 ; 0x402 ou 0xe9
|
%define DEBUG_PORT 0xe9 ; 0x402 ou 0xe9
|
||||||
|
|
||||||
%define VIDEO_SEG 0xB800 ; ou 0xB000
|
|
||||||
%define VIDEO_ATTR 0x07
|
|
||||||
|
|
||||||
; initial stack
|
; initial stack
|
||||||
%define STACK_SEG 0x0030
|
%define STACK_SEG 0x0030 ; compatible avec le BMM (Bios Memory Maps)
|
||||||
%define STACK_TOP 0x0100 ; choix commun en RAM basse (pile descend)
|
%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_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_END 0xA000 ; 0xA000:0000 = 0xA0000 (début zone vidéo)
|
||||||
%define MEM_SEG_STEP 0x0040 ; 1KB = 0x400 bytes = 0x40 paragraphs
|
%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
|
; definition du BDA
|
||||||
%include ".\bda.asm"
|
%include ".\bda.asm"
|
||||||
|
|
||||||
|
|
||||||
jmp reset
|
|
||||||
|
|
||||||
%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"
|
||||||
|
|
||||||
err_novga db 'No VGA Card BIOS',0
|
|
||||||
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
|
||||||
|
|
||||||
|
|
@ -74,10 +93,10 @@ endless: nop
|
||||||
jmp endless
|
jmp endless
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; Détection les ROM supplementaires
|
; Test si le vecteur INT 10h à été modifié (par la ROM)
|
||||||
; Teste la RAM de 0xC000 jusqu’à 0xE000, par pas de 2KB.
|
|
||||||
;
|
;
|
||||||
; 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:
|
setup_check_vga:
|
||||||
; vérification de l'offset 0x0000:0x0040 qui DOIT etre différent de @default_isr
|
; 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)
|
; Comparer avec default_isr (offset) et CS (segment)
|
||||||
mov dx, default_isr ; DX = offset default_isr (dans notre CS)
|
mov dx, default_isr ; DX = offset default_isr (dans notre CS)
|
||||||
cmp bx, dx
|
cmp bx, dx
|
||||||
jne .init_ok ; interrupt different
|
jne .init_ok ; vecteur different, bios initialisé
|
||||||
cmp cx, ax
|
cmp cx, ax
|
||||||
jne .init_ok
|
jne .init_ok
|
||||||
|
|
||||||
; no VGA init
|
mov ax,cs ; vecteur identique, sans doute pas d'initialisation
|
||||||
mov ax,cs
|
|
||||||
mov ds,ax
|
mov ds,ax
|
||||||
|
|
||||||
mov si, err_vganok
|
mov si, err_vganok
|
||||||
|
|
@ -112,7 +130,6 @@ setup_check_vga:
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
setup_load_rom:
|
setup_load_rom:
|
||||||
mov bx, 0xC000
|
mov bx, 0xC000
|
||||||
mov al,'*'
|
|
||||||
.scanloop:
|
.scanloop:
|
||||||
mov ds, bx
|
mov ds, bx
|
||||||
cmp word[0x0000],0xAA55 ; ROM signature
|
cmp word[0x0000],0xAA55 ; ROM signature
|
||||||
|
|
@ -133,20 +150,11 @@ setup_load_rom:
|
||||||
add bx, 0x80 ; add 2kb
|
add bx, 0x80 ; add 2kb
|
||||||
cmp bx, 0xE000
|
cmp bx, 0xE000
|
||||||
jbe .scanloop
|
jbe .scanloop
|
||||||
|
|
||||||
cmp al,'.'
|
|
||||||
je .end
|
|
||||||
; no rom found :
|
|
||||||
mov bx,cs
|
|
||||||
mov ds,bx
|
|
||||||
|
|
||||||
mov si, err_novga
|
|
||||||
call debug_puts
|
|
||||||
.end:
|
.end:
|
||||||
ret
|
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.
|
; Teste la RAM de MEM_SEG_DEB jusqu’à 0xA000 (640KB), par pas de 1KB.
|
||||||
; Méthode: sauvegarde 1 mot, écrit 2 patterns, relit, restaure.
|
; 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
|
; 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:
|
setup_ivt:
|
||||||
; installation de la table d'interrupts
|
; installation de la table d'interrupts
|
||||||
|
|
|
||||||
|
|
@ -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:
|
debug_puts:
|
||||||
.next:
|
.next:
|
||||||
|
|
|
||||||
|
|
@ -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_MODE 0x06 ; MCGA HiRes (B/W)
|
||||||
%define GFX_WIDTH 640
|
%define GFX_WIDTH 640
|
||||||
%define GFX_HEIGHT 200
|
%define GFX_HEIGHT 200
|
||||||
|
|
|
||||||
|
|
@ -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_MODE 0x06 ; MCGA HiRes (B/W)
|
||||||
%define GFX_WIDTH 640
|
%define GFX_WIDTH 640
|
||||||
%define GFX_HEIGHT 200
|
%define GFX_HEIGHT 200
|
||||||
|
|
@ -9,8 +34,12 @@
|
||||||
%define CGA_ODD_BANK 0x2000
|
%define CGA_ODD_BANK 0x2000
|
||||||
%define BG16_SIZE 48
|
%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:
|
gfx_init:
|
||||||
; init graphics mode
|
; init graphics mode
|
||||||
mov ah, 0x00 ; AH=00h set video mode
|
mov ah, 0x00 ; AH=00h set video mode
|
||||||
|
|
@ -21,17 +50,72 @@ gfx_init:
|
||||||
|
|
||||||
ret
|
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:
|
gfx_putpixel:
|
||||||
mov ah, 0Ch
|
push bx
|
||||||
;mov al, 0Fh ; couleur (0..15)
|
push di
|
||||||
;mov bh, 00h ; page
|
push es
|
||||||
;mov cx, 100 ; x
|
|
||||||
;mov dx, 50 ; y
|
mov ax, VIDEO_SEG
|
||||||
int 10h
|
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
|
ret
|
||||||
|
|
||||||
; draw background pattern
|
; ------------------------------------------------------------
|
||||||
|
; Dessine un background "check-board", accès VRAM direct.
|
||||||
|
;
|
||||||
|
; ------------------------------------------------------------
|
||||||
gfx_background:
|
gfx_background:
|
||||||
mov ax,VIDEO_SEG
|
mov ax,VIDEO_SEG
|
||||||
mov es,ax
|
mov es,ax
|
||||||
|
|
|
||||||
|
|
@ -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
|
%define PS2_PORT_BUFFER 0x60
|
||||||
|
|
|
||||||
|
|
@ -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
|
; text mod functions
|
||||||
;
|
;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue