feat: ajout des fonctions de debug par GDB
This commit is contained in:
parent
53b445a652
commit
2a7798dfd3
234
boot/boot12.asm
234
boot/boot12.asm
|
@ -7,138 +7,144 @@ include "..\include\divers.h"
|
||||||
|
|
||||||
org 7C00h
|
org 7C00h
|
||||||
|
|
||||||
jmp boot
|
jmp Boot
|
||||||
|
|
||||||
bootsec bootinfo "COS2000A","COS2000 ","FAT12 "
|
bootsec bootinfo "COS2000A","COS2000 ","FAT12 "
|
||||||
|
|
||||||
errorloading db " [Erreur]",0dh,0ah,0
|
Boot_Message db "Cos2000",0
|
||||||
okloading db "Recherche noyau ",0Dh,0ah," -"
|
Entre_Message db "Search",0
|
||||||
sys db "SYSTEME SYS",0
|
Loading_Message db "Load",0
|
||||||
syst db " [ Ok ]",0dh,0ah,"Chargement ",0
|
System_File db "As",0,"y",0,"s",0,"t",0,"e",0,0x0F,0,0x38,"m",0,"e",0,".",0,"s",0,"y",0,"s",0,0,0,0,0,0xFF,0xFF
|
||||||
dot db ".",0
|
Is_Ok db " [ OK ]",0x0A,0x0D,0
|
||||||
|
Is_Failed db " [ERROR]",0x0A,0x0D,0
|
||||||
|
The_Dot db '.',0
|
||||||
|
|
||||||
errorboot:
|
Boot_Error:
|
||||||
mov si,errorloading
|
mov si,Is_Failed
|
||||||
call showstr
|
call ShowString
|
||||||
mov ah,0
|
xor ax,ax
|
||||||
int 16h
|
int 0x16
|
||||||
int 19h
|
int 0x19
|
||||||
|
|
||||||
boot:
|
Boot_Ok:
|
||||||
mov [bootsec.bootdrive],dl
|
mov si,Is_Ok
|
||||||
cli
|
call ShowString
|
||||||
mov ax,09000h
|
ret
|
||||||
mov ss,ax
|
|
||||||
mov sp,0FFFFh
|
Boot:
|
||||||
sti
|
|
||||||
boot2:
|
|
||||||
push cs
|
push cs
|
||||||
push cs
|
push cs
|
||||||
pop es
|
pop es
|
||||||
pop ds
|
pop ds
|
||||||
|
mov [bootsec.bootdrive],dl
|
||||||
|
cli
|
||||||
|
mov ax,0x9000
|
||||||
|
mov ss,ax
|
||||||
|
mov sp,0xFFFF
|
||||||
|
sti
|
||||||
|
mov si,Boot_Message
|
||||||
|
call ShowString
|
||||||
xor ax,ax
|
xor ax,ax
|
||||||
mov dl,[bootsec.bootdrive]
|
int 0x13
|
||||||
int 13h
|
jc Boot_Error
|
||||||
jc errorboot
|
|
||||||
mov si,okloading
|
|
||||||
call showstr
|
|
||||||
mov cx,[bootsec.reservedsectors]
|
mov cx,[bootsec.reservedsectors]
|
||||||
add cx,[bootsec.hiddensectorsh]
|
add cx,[bootsec.hiddensectorsh]
|
||||||
adc cx,[bootsec.hiddensectorsl]
|
adc cx,[bootsec.hiddensectorsl]
|
||||||
push cx
|
|
||||||
mov bx,[bootsec.sectorsperfat]
|
mov bx,[bootsec.sectorsperfat]
|
||||||
mov di,bufferfat
|
mov di,bufferfat
|
||||||
|
push bx
|
||||||
|
push cx
|
||||||
readfat:
|
readfat:
|
||||||
call readsector
|
call ReadSector
|
||||||
jc errorboot
|
jc Boot_Error
|
||||||
inc cx
|
inc cx
|
||||||
add di,[bootsec.sectorsize]
|
add di,[bootsec.sectorsize]
|
||||||
dec bx
|
dec bx
|
||||||
jnz readfat
|
jnz readfat
|
||||||
pop cx
|
pop cx
|
||||||
|
pop bx
|
||||||
xor ax,ax
|
xor ax,ax
|
||||||
mov al,[bootsec.fatsperdrive]
|
mov al,[bootsec.fatsperdrive]
|
||||||
mov bx,[bootsec.sectorsperfat]
|
|
||||||
mul bx
|
mul bx
|
||||||
add cx,ax
|
add cx,ax
|
||||||
mov ax,32
|
mov ax,32
|
||||||
mul [bootsec.directorysize]
|
mul word [bootsec.directorysize]
|
||||||
div [bootsec.sectorsize]
|
div word [bootsec.sectorsize]
|
||||||
add ax,cx
|
add ax,cx
|
||||||
sub ax,2
|
sub ax,2
|
||||||
mov word [bootsec.reservedfornt],ax
|
mov word [bootsec.reservedfornt],ax
|
||||||
xor dx,dx
|
xor dx,dx
|
||||||
checkroot:
|
call Boot_Ok
|
||||||
|
mov si,Loading_Message
|
||||||
|
call ShowString
|
||||||
|
Find_System:
|
||||||
mov di,buffer
|
mov di,buffer
|
||||||
call readsector
|
call ReadSector
|
||||||
jc errorboot
|
jc Near Boot_Error
|
||||||
xor bx,bx
|
xor bx,bx
|
||||||
findnext:
|
Next_Root_Entrie:
|
||||||
cmp byte [di],0
|
cmp byte [di],0
|
||||||
je errorboot
|
je near Boot_Error
|
||||||
cmp byte [di],0E5h
|
push di
|
||||||
je no
|
push cx
|
||||||
cmp byte [di],041h
|
mov si,System_File
|
||||||
je no
|
mov cx,32
|
||||||
mov si,dot
|
|
||||||
call showstr
|
|
||||||
push di cx
|
|
||||||
mov si,sys
|
|
||||||
mov cx,11
|
|
||||||
rep cmpsb
|
rep cmpsb
|
||||||
pop cx di
|
pop cx
|
||||||
je oksystem
|
pop di
|
||||||
no:
|
je System_Found
|
||||||
add di,32
|
add di,32
|
||||||
add bx,32
|
add bx,32
|
||||||
inc dx
|
inc dx
|
||||||
cmp dx,[bootsec.directorysize]
|
cmp dx,[bootsec.directorysize]
|
||||||
ja errorboot
|
ja near Boot_Error
|
||||||
cmp bx,[bootsec.sectorsize]
|
cmp bx,[bootsec.sectorsize]
|
||||||
jb findnext
|
jb Next_Root_Entrie
|
||||||
inc cx
|
inc cx
|
||||||
jmp checkroot
|
jmp Find_System
|
||||||
oksystem:
|
System_Found:
|
||||||
mov si,syst
|
call Boot_Ok
|
||||||
call showstr
|
mov si,Entre_Message
|
||||||
mov cx,[di+26]
|
call ShowString
|
||||||
mov ax,8000h
|
mov cx,[di+26+32]
|
||||||
|
mov ax,0x8000
|
||||||
mov es,ax
|
mov es,ax
|
||||||
push es
|
push es
|
||||||
mov di,0000h
|
mov di,0x0
|
||||||
push 0010h
|
push 0x10
|
||||||
mov si,dot
|
mov si,The_Dot
|
||||||
xor ax,ax
|
Resume_Loading:
|
||||||
fatagain:
|
cmp cx,0x0FF0
|
||||||
cmp cx,0FF0h
|
jae Finish_Loading
|
||||||
jae finishload
|
|
||||||
push cx
|
push cx
|
||||||
add cx,word [bootsec.reservedfornt]
|
add cx,word [bootsec.reservedfornt]
|
||||||
call readsector
|
call ReadSector
|
||||||
pop cx
|
pop cx
|
||||||
jc errorboot
|
jc near Boot_Error
|
||||||
inc ax
|
call ShowString
|
||||||
call showstr
|
|
||||||
add di,[bootsec.sectorsize]
|
add di,[bootsec.sectorsize]
|
||||||
call getfat
|
call NextFatGroup
|
||||||
jnc fatagain
|
jc near Boot_Error
|
||||||
finishload:
|
jmp Resume_Loading
|
||||||
|
Finish_Loading:
|
||||||
|
call Boot_Ok
|
||||||
retf
|
retf
|
||||||
|
|
||||||
;=============READSECTOR (Fonction 01H)===============
|
;====================READSECTOR=======================
|
||||||
;Lit le secteur CX et le met en es:di
|
;Lit le secteur logique LBA CX et le met en es:di
|
||||||
;-> AH=1
|
;-> CX (limité à 65536 secteurs, soit 32 Mo avec secteur 512 octets)
|
||||||
;<- Flag Carry si erreur
|
;<- Flag Carry si erreur
|
||||||
;=====================================================
|
;=====================================================
|
||||||
readsector:
|
ReadSector:
|
||||||
push ax bx cx dx si
|
pusha
|
||||||
mov ax,cx
|
mov ax,cx
|
||||||
xor dx,dx
|
xor dx,dx
|
||||||
div [bootsec.sectorspertrack]
|
div word [bootsec.sectorspertrack]
|
||||||
inc dl
|
inc dl
|
||||||
mov bl,dl
|
mov bl,dl
|
||||||
xor dx,dx
|
xor dx,dx
|
||||||
div [bootsec.headsperdrive]
|
div word [bootsec.headsperdrive]
|
||||||
|
mov dh, [bootsec.bootdrive]
|
||||||
xchg dl,dh
|
xchg dl,dh
|
||||||
mov cx,ax
|
mov cx,ax
|
||||||
xchg cl,ch
|
xchg cl,ch
|
||||||
|
@ -147,57 +153,68 @@ readsector:
|
||||||
mov bx,di
|
mov bx,di
|
||||||
mov si, 4
|
mov si, 4
|
||||||
mov al, 1
|
mov al, 1
|
||||||
tryagain:
|
Read_Again:
|
||||||
mov ah, 2
|
mov ah, 2
|
||||||
mov dl,[bootsec.bootdrive]
|
int 0x13
|
||||||
int 13h
|
jnc Read_Done
|
||||||
jnc done
|
|
||||||
dec si
|
dec si
|
||||||
jnz tryagain
|
jnz Read_Again
|
||||||
done:
|
Read_Done:
|
||||||
pop si dx cx bx ax
|
popa
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
;===================NEXTFATGROUP======================
|
||||||
getfat:
|
;Renvoie en CX le groupe qui succède dans la FAT le groupe CX
|
||||||
push ax bx dx di
|
;-> CX
|
||||||
mov di,bufferfat
|
;<-
|
||||||
|
;=====================================================
|
||||||
|
NextFatGroup:
|
||||||
|
push bx
|
||||||
|
push dx
|
||||||
|
push di
|
||||||
mov ax,cx
|
mov ax,cx
|
||||||
mov bx,ax
|
mov bx,ax
|
||||||
and bx,0000000000000001b
|
and bx,0000000000000001b
|
||||||
shr ax,1
|
shr ax,1
|
||||||
mov cx,3
|
mov cx,3
|
||||||
mul cx
|
mul cx
|
||||||
|
mov di,bufferfat
|
||||||
add di,ax
|
add di,ax
|
||||||
cmp bx,0h
|
cmp bx,0
|
||||||
jnz evenfat
|
jnz Even_Group
|
||||||
oddfat:
|
Odd_Group:
|
||||||
mov dx,[di]
|
mov dx,[di]
|
||||||
and dx,0FFFh
|
and dx,0x0FFF
|
||||||
mov cx,dx
|
mov cx,dx
|
||||||
jmp endfat
|
jmp Next_Group_Found
|
||||||
evenfat:
|
Even_Group:
|
||||||
mov dx,[di+1]
|
mov dx,[di+1]
|
||||||
and dx,0FFF0h
|
and dx,0xFFF0
|
||||||
shr dx,4
|
shr dx,4
|
||||||
mov cx,dx
|
mov cx,dx
|
||||||
endfat:
|
Next_Group_Found:
|
||||||
pop di dx bx ax
|
pop di
|
||||||
|
pop dx
|
||||||
|
pop bx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
;======================SHOWSTR========================
|
||||||
showstr:
|
;Affiche la chaine de caractère pointé par ds:si à l'écran
|
||||||
push ax bx si
|
;-> DS, SI
|
||||||
again:
|
;<- Flag Carry si erreur
|
||||||
|
;=====================================================
|
||||||
|
ShowString:
|
||||||
|
pusha
|
||||||
|
Next_Char:
|
||||||
lodsb
|
lodsb
|
||||||
or al,al
|
or al,al
|
||||||
jz fin
|
jz End_Show
|
||||||
mov ah,0Eh
|
mov ah,0x0E
|
||||||
mov bx,07h
|
mov bx,0x07
|
||||||
int 10h
|
int 0x10
|
||||||
jmp again
|
jmp Next_Char
|
||||||
fin:
|
End_Show:
|
||||||
pop si bx ax
|
popa
|
||||||
ret
|
ret
|
||||||
|
|
||||||
rb 7C00h+512-2-$
|
rb 7C00h+512-2-$
|
||||||
|
@ -209,4 +226,3 @@ buffer:
|
||||||
rb 7C00h+512+2048-$
|
rb 7C00h+512+2048-$
|
||||||
bufferfat:
|
bufferfat:
|
||||||
rb 7C00h+512+4096-$
|
rb 7C00h+512+4096-$
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
target remote localhost:1234
|
||||||
|
set disassembly-flavor intel
|
||||||
|
set architecture i8086
|
||||||
|
display/20i $pc+$cs*16
|
||||||
|
break *0x7c00
|
||||||
|
cont
|
||||||
|
clear *0x7c00
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
target remote localhost:1234
|
||||||
|
set disassembly-flavor intel
|
||||||
|
set architecture i386
|
||||||
|
display/20i $pc+$cs*16
|
||||||
|
break *0x80010
|
||||||
|
cont
|
||||||
|
clear *0x80010
|
||||||
|
|
||||||
|
|
|
@ -3,14 +3,13 @@ all: cos2000.img
|
||||||
cos2000.img:
|
cos2000.img:
|
||||||
(dd if=/dev/zero of=cos2000.img count=2880 bs=512)
|
(dd if=/dev/zero of=cos2000.img count=2880 bs=512)
|
||||||
(mkfs.msdos -F 12 -n "COS2000" cos2000.img)
|
(mkfs.msdos -F 12 -n "COS2000" cos2000.img)
|
||||||
(fusefat cos2000.img ./mnt -o rw+)
|
(fusermount ./mnt -u;mkdir -p ./mnt;rm -rf ./mnt/*;fusefat cos2000.img ./mnt -o rw+)
|
||||||
(cp ../noyau/systeme.sys ./mnt/)
|
(cp ../noyau/systeme.sys ./mnt/)
|
||||||
(cp ../noyau/systeme.ini ./mnt/)
|
(cp ../noyau/systeme.ini ./mnt/)
|
||||||
(cp ../programs/*.ce ./mnt/)
|
(cp ../programs/*.ce ./mnt/)
|
||||||
(cp ../programs/*.lib ./mnt/)
|
|
||||||
(cp ../programs/*.rip ./mnt/)
|
(cp ../programs/*.rip ./mnt/)
|
||||||
(cp ../lib/*.lib ./mnt/)
|
(cp ../lib/*.lib ./mnt/)
|
||||||
(cp ../system/system.sys ./mnt/;sync)
|
(sync)
|
||||||
(fusermount ./mnt -u)
|
(fusermount ./mnt -u)
|
||||||
(dd if=../boot/boot12.bin of=cos2000.img seek=0 count=1 conv=notrunc;sync)
|
(dd if=../boot/boot12.bin of=cos2000.img seek=0 count=1 conv=notrunc;sync)
|
||||||
|
|
||||||
|
|
8
makefile
8
makefile
|
@ -20,15 +20,15 @@ copy:
|
||||||
|
|
||||||
test: all copy qemu
|
test: all copy qemu
|
||||||
|
|
||||||
view:
|
view: final/cos2000.img
|
||||||
(hexdump -C ./final/cos2000.img|head -c10000)
|
(hexdump -C ./final/cos2000.img|head -c10000)
|
||||||
|
|
||||||
|
view2: boot/boot12.bin
|
||||||
|
(objdump -D -b binary -mi386 -Maddr16,data16 ./boot/boot12.bin)
|
||||||
|
|
||||||
debug-boot: all copy qemu-debug
|
debug-boot: all copy qemu-debug
|
||||||
(sleep 2;cgdb -x ./debug/boot.txt)
|
(sleep 2;cgdb -x ./debug/boot.txt)
|
||||||
|
|
||||||
debug-loader: all copy qemu-debug
|
|
||||||
(sleep 2;cgdb -x ./debug/loader.txt)
|
|
||||||
|
|
||||||
debug-system: all copy qemu-debug
|
debug-system: all copy qemu-debug
|
||||||
(sleep 2;cgdb -x ./debug/system.txt)
|
(sleep 2;cgdb -x ./debug/system.txt)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue