fix: suppression de la gestion de la disquette, ajout du déboguage avec Bochs, correction initialisation du FPU au démarrage, changement de modèle 3D

This commit is contained in:
Nicolas Hordé 2018-11-29 16:45:40 +01:00
parent 6fa1bd6c2e
commit ed4e577086
14 changed files with 17137 additions and 16947 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -2,4 +2,5 @@
## Copies d'écran de COS2000
![screen](https://github.com/dahut87/cos2000v2/raw/develop/Graphisme/screenshots/28-09-2018.png)
![screen](https://github.com/dahut87/cos2000v2/raw/develop/Graphisme/screenshots/29-11-2018.png)
![screen](https://github.com/dahut87/cos2000v2/raw/develop/Graphisme/screenshots/ansi.png)

View File

@ -1,256 +0,0 @@
;/*******************************************************************************/
;/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
;/* */
[BITS 16]
[ORG 0x7C00]
section .text
start:
jmp near Boot
Disk_ID db "COS2000A" ;Fabricant + n° de série Formatage
Sectors_Size dw 512 ;Nombre d'octets/secteur
Sectors_Per_Cluster db 1 ;Nombre de secteurs/cluster
Reserved_Sectors dw 1 ;Nombre de secteurs réservé
Fats_Number db 2 ;Nombre de copies de la FAT
Fits_Number dw 224 ;Taille du répertoire racine
Sectors_Per_Disk dw 2880 ;Nombre secteurs du volume si < 32 Mo
Media_Descriptor db 0xF0 ;Descripteur de média
Sectors_Per_Fat dw 9 ;Nombre secteurs/FAT
Sectors_Per_Track dw 18 ;Nombre secteurs/piste
Heads_Number dw 2 ;Nombre de tete de lecture/écriture
Sectors_Hidden dd 0 ;Nombre de secteurs cachés
Sectors_Per_Disk2 dd 0 ;Nombre secteurs du volume si > 32 Mo
Boot_Drive db 0 ;Lecteur de démarrage
Reserved db 0 ;NA (pour NT seulement)
Extended_Boot_ID db 0x29 ;Signature Boot étendu 29h
Serial_Number dd 0x01020304 ;N° de série
Disk_Name db "COS2000 " ;Nom de volume
Fat_Type db "FAT12 " ;Type de système de fichiers
Boot_Message db "Cos2000",0
Entre_Message db "Fichier",0
Loading_Message db "Charger",0
System_File db "Al",0,"o",0,"a",0,"d",0,"e",0,0x0F,0,0x38,"r",0,".",0,"s",0,"y",0,"s",0,0,0,0,0,0xFF,0xFF,0xFF,0xFF
Is_Ok db " [ OK ]",0x0A,0x0D,0
Is_Failed db " [ERREUR]",0x0A,0x0D,0
The_Dot db '.',0
Boot_Error:
mov si,Is_Failed
call ShowString
xor ax,ax
int 0x16
int 0x19
Boot_Ok:
mov si,Is_Ok
call ShowString
ret
Boot:
push cs
push cs
pop es
pop ds
mov [Boot_Drive],dl
cli
mov ax,0x9000
mov ss,ax
mov sp,0xFFFF
sti
mov si,Boot_Message
call ShowString
; Initialisation du lecteur de disquette
xor ax,ax
int 0x13
jc Boot_Error
; Calcul de la position de la FAT12
mov cx,[Reserved_Sectors]
add cx,[Sectors_Hidden]
adc cx,[Sectors_Hidden+2]
mov bx,[Sectors_Per_Fat]
mov di,Fat_Buffer
push bx
push cx
; Lecture de la FAT en mémoire
readfat:
call ReadSector
jc Boot_Error
inc cx
add di,[Sectors_Size]
dec bx
jnz readfat
pop cx
pop bx
xor ax,ax
mov al,[Fats_Number]
mul bx
add cx,ax
mov ax,32
mul word [Fits_Number]
div word [Sectors_Size]
add ax,cx
sub ax,2
mov word [Serial_Number],ax
xor dx,dx
call Boot_Ok
mov si,Loading_Message
call ShowString
; Recherche du système dans les entrèes de répertoire
Find_System:
mov di,Buffer
call ReadSector
jc Near Boot_Error
xor bx,bx
Next_Root_Entrie:
cmp byte [di],0
je near Boot_Error
push di
push cx
mov si,System_File
mov cx,32
rep cmpsb
pop cx
pop di
je System_Found
add di,32
add bx,32
inc dx
cmp dx,[Fits_Number]
ja near Boot_Error
cmp bx,[Sectors_Size]
jb Next_Root_Entrie
inc cx
jmp Find_System
System_Found:
; Système trouvé
call Boot_Ok
mov si,Entre_Message
call ShowString
mov cx,[di+26+32]
mov ax,0x0080
mov es,ax
push es
mov di,0x0
push di
mov si,The_Dot
Resume_Loading:
; Chargement des secteur en mémoire à l'adresse 0080:0000
cmp cx,0x0FF0
jae Finish_Loading
push cx
add cx,word [Serial_Number]
call ReadSector
pop cx
jc near Boot_Error
call ShowString
add di,[Sectors_Size]
call NextFatGroup
jc near Boot_Error
jmp Resume_Loading
Finish_Loading:
call Boot_Ok
; Exécution du chargeur ELF
retf
;====================READSECTOR=======================
;Lit le secteur logique LBA CX et le met en es:di
;-> CX (limité à 65536 secteurs, soit 32 Mo avec secteur 512 octets)
;<- Flag Carry si erreur
;=====================================================
ReadSector:
pusha
mov ax,cx
xor dx,dx
div word [Sectors_Per_Track]
inc dl
mov bl,dl
xor dx,dx
div word [Heads_Number]
mov dh, [Boot_Drive]
xchg dl,dh
mov cx,ax
xchg cl,ch
shl cl,6
or cl, bl
mov bx,di
mov si, 4
mov al, 1
Read_Again:
mov ah, 2
int 0x13
jnc Read_Done
dec si
jnz Read_Again
Read_Done:
popa
ret
;===================NEXTFATGROUP======================
;Renvoie en CX le groupe qui succède dans la FAT le groupe CX
;-> CX
;<-
;=====================================================
NextFatGroup:
push bx
push dx
push di
mov ax,cx
mov bx,ax
and bx,0000000000000001b
shr ax,1
mov cx,3
mul cx
mov di,Fat_Buffer
add di,ax
cmp bx,0
jnz Even_Group
Odd_Group:
mov dx,[di]
and dx,0x0FFF
mov cx,dx
jmp Next_Group_Found
Even_Group:
mov dx,[di+1]
and dx,0xFFF0
shr dx,4
mov cx,dx
Next_Group_Found:
pop di
pop dx
pop bx
ret
;======================SHOWSTR========================
;Affiche la chaine de caractère pointé par ds:si à l'écran
;-> DS, SI
;<- Flag Carry si erreur
;=====================================================
ShowString:
pusha
Next_Char:
lodsb
or al,al
jz End_Show
mov ah,0x0E
mov bx,0x07
int 0x10
jmp Next_Char
End_Show:
popa
ret
times 510-($-$$) db ' '
dw 0xAA55
Buffer equ $
Fat_Buffer equ $+512
section .bss
;Buffer resb 512
;Fat_Buffer resb 10000

View File

@ -1,13 +0,0 @@
;/*******************************************************************************/
;/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
;/* */
struc echs
Sizes resb 1
Reserve resb 1
NumSectors resw 1
Adressoff resw 1
Adressseg resw 1
SectorLow resw 1
SectorHigh resw 1
Dummy resq 1
endstuc

View File

@ -1,119 +0,0 @@
;/*******************************************************************************/
;/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
;/* */
struc ELFheader
.Magic resb 1;"0x7F"
.MagicStr resb 3;"ELF"
.Computertype resb 1;1
.Endianness resb 1;1
.Original resb 1;1
.OS resb 1;0
.ABI resb 1;0
.Dummy resb 7;0
.Type resw 1;2
.Target resw 1;3
.Version resd 1;1
.Entrypoint resd 1
.Offsetprogram resd 1
.Offsetsection resd 1
.Flags resd 1
.SizeELFheader resw 1
.Sizeprogram resw 1
.Nbprogram resw 1
.Sizesection resw 1
.Nbsection resw 1
.Index resw 1
.end equ $
endstruc
struc Program
.Type resd 1
.Offset resd 1
.Vadress resd 1
.PAdress resd 1
.Size resd 1
.Memsize resd 1
.Flags resd 1
.Align resd 1
.end equ $
endstruc
struc Sections
.Name resd 1
.Type resd 1
.Flags resd 1
.Vadress resd 1
.Offset resd 1
.Size resd 1
.Link resd 1
.Info resd 1
.Align resd 1
.Entrysize resd 1
.end equ $
endstruc
;type
PT_NULL equ 0
PT_LOAD equ 1
PT_DYNAMIC equ 2
PT_INTERP equ 3
PT_NOTE equ 4
PT_SHLIB equ 5
PT_PHDR equ 6
PT_TLS equ 7
PT_LOOS equ 0x60000000
PT_HIOS equ 0x6fffffff
PT_LOPROC equ 0x70000000
PT_HIPROC equ 0x7fffffff
;flags
PF_WRITE equ 0x1
PF_ALLOC equ 0x2
PF_X equ 0x1 ;Execute
PF_W equ 0x2 ;Write
PF_R equ 0x4 ;Read
PF_MASKOS equ 0x0ff00000 ;Unspecified
PF_MASKPROC equ 0xf0000000 ;Unspecified
;type
ST_EXIT equ 1
ST_NULL equ 0
ST_PROGBITS equ 1
ST_SYMTAB equ 2
ST_STRTAB equ 3
ST_RELA equ 4
ST_HASH equ 5
ST_DYNAMIC equ 6
ST_NOTE equ 7
ST_NOBITS equ 8
ST_REL equ 9
ST_SHLIB equ 10
ST_DYNSYM equ 11
ST_INIT_ARRAY equ 14
ST_FINI_ARRAY equ 15
ST_PREINIT_ARRAY equ 16
ST_GROUP equ 17
ST_SYMTAB_SHNDX equ 18
ST_LOOS equ 0x60000000
ST_HIOS equ 0x6fffffff
ST_LOPROC equ 0x70000000
ST_HIPROC equ 0x7fffffff
ST_LOUSER equ 0x80000000
ST_HIUSER equ 0xffffffff
;flags
SF_WRITE equ 0x1
SF_ALLOC equ 0x2
SF_EXECINSTR equ 0x4
SF_MERGE equ 0x10
SF_STRINGS equ 0x20
SF_INFO_LINK equ 0x40
SF_LINK_ORDER equ 0x80
SF_OS_NONCONFORMING equ 0x100
SF_GROUP equ 0x200
SF_TLS equ 0x400
SF_COMPRESSED equ 0x800
SF_MASKOS equ 0x0ff00000
SF_MASKPROC equ 0xf0000000

View File

@ -1,858 +0,0 @@
;/*******************************************************************************/
;/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
;/* */
[BITS 16]
[ORG 0x0]
SECTION .text
push cs
push cs
pop ds
pop es
mov si,msg0
call showstr
;Projection de la FAT12 en mémoire
mov si,msg1
call showstr
call initfat
call ok
;Recherche du système
mov si,msg2
call showstr
mov si,System_File
call search
call ok
;Activation du BUS A20
mov si,msg3
call showstr
call EnableA20
call ok
;Chargement d'une GDT pour le mode FLAT REAL
mov si,msg4
call showstr
mov eax,cs
shl eax,4
mov [GDT.Entry1+2],ax
mov [GDT.Entry2+2],ax
shr eax,16
mov [GDT.Entry1+4],al
mov [GDT.Entry2+4],al
mov eax,cs
shl eax,4
add eax,gdt0
mov [GDTR.Address],eax
lgdt [GDTR]
call ok
;Passage en mode FLAT REAL
mov si,msg5
call showstr
cli
mov eax,cr0
or al,1
mov cr0,eax
jmp short $+2
mov bx,SYS_DATA_SEL
mov fs,bx
mov ds,bx
mov es,bx
mov gs,bx
and al,0FEh
mov cr0,eax
jmp short $+2
mov bx,cs
mov fs,bx
mov ds,bx
mov es,bx
mov gs,bx
sti
call ok
;Chargement du noyau en 0x30000
mov si,msg6
call showstr
mov ebx,0x300000
call load
call ok
;Chargement du fichier PE
mov si,msg7
call showstr
call initpe
call ok
;suite:
;mov cx,suite
;call debug
mov si,msg8
call showstr
cli
;Passage en mode protégé
mov al,0x80
out 0x70,al
mov eax,cr0
or al,1
mov cr0,eax
;Exécution du code 32 bits
jmp SYS_CODE_SEL:GoPMode32
Boot_Error:
mov si,error
call showstr
xor ax,ax
int 16h
jmp 0xFFFF:0x0
ok:
push si
push cx
mov cl,67
call eol
mov si,okay
call showstr
pop cx
pop si
ret
;======================INITPE========================
;Initialise le PE de l'adresse EBX
;->
;<- Flag Carry si erreur
;=====================================================
initpe:
pusha
push es
xor ax,ax
mov es,ax
mov [begin],ebx
cmp word [es:ebx+ELFheader.Magic],0x457F ; bien l'entete .elf ?
jne near errorelf
cmp word [es:ebx+ELFheader.Magic+2],"LF" ; bien l'entete .elf ?
jne near errorelf
cmp byte [es:ebx+ELFheader.Computertype],0x1 ; type ok ?
jne near errorelf
cmp byte [es:ebx+ELFheader.Endianness],0x1 ; type ok ?
jne near errorelf
cmp byte [es:ebx+ELFheader.Original],0x1 ; type ok ?
jne near errorelf
cmp byte [es:ebx+ELFheader.OS],0x0 ; type ok ?
jne near errorelf
cmp byte [es:ebx+ELFheader.ABI],0x0 ; type ok ?
jne near errorelf
cmp byte [es:ebx+ELFheader.Dummy],0x0 ; type ok ?
jne near errorelf
mov si,info1
call showstr
mov esi,[es:ebx+ELFheader.Entrypoint]
mov [entriepoint],esi
mov esi,[es:ebx+ELFheader.Offsetprogram]
add esi,ebx
mov [offsetheader],esi
mov esi,[es:ebx+ELFheader.Offsetsection]
add esi,ebx
mov [offsetsection],esi
mov cx,[es:ebx+ELFheader.Nbprogram]
mov [cs:nbprogram],cx
mov cx,[es:ebx+ELFheader.Nbsection]
mov [cs:nbsection],cx
xor eax,eax
mov ax,[es:ebx+ELFheader.Index]
xor edx,edx
mov dx,[es:ebx+ELFheader.Sizesection]
mul edx
add eax,esi
mov eax,[es:eax+Sections.Offset]
add eax,ebx
mov [cs:symbol],eax
xor eax,eax
add ax,[es:ebx+ELFheader.Sizesection]
add esi,eax
sections:
mov edi,esi
cmp dword [es:edi+Sections.Type],0x00
jz nothing
mov esi,info2
call showstr
push ds
push es
pop ds
mov esi,[es:edi+Sections.Name]
add esi,[cs:symbol]
call showstr
pop ds
mov esi,info3
call showstr
mov edx,[es:edi+Sections.Offset]
push cx
mov cx,32
call ShowHex
pop cx
mov esi,info4
call showstr
mov edx,[es:edi+Sections.Size]
push cx
mov cx,32
call ShowHex
pop cx
mov esi,info5
call showstr
mov edx,[es:edi+Sections.Vadress]
push cx
mov cx,32
call ShowHex
pop cx
and dword [es:edi+Sections.Flags],SF_ALLOC
jne itsok
mov esi,info6
call showstr
jmp itsok2
itsok:
mov esi,info10
call showstr
call copy2mem
cmp dword [es:edi+Sections.Type],ST_NOBITS
jne itsok2
mov esi,info9
call showstr
mov esi,info10
call showstr
call zero2mem
itsok2:
push cx
xor cx,cx
mov edx,[es:edi+Sections.Align]
mov esi,info8
call showstr
nextpower:
cmp edx,0
je powerok
cmp edx,1
je powerok
cmp cx,32
je powerok
inc cx
shr edx,1
jnc nextpower
powerok:
mov edx,ecx
mov cx,4
call ShowHex
pop cx
call showrtn
mov esi,edi
nothing:
add esi,eax
dec cx
jnz sections
mov esi,info7
call showstr
mov edx,[cs:entriepoint]
mov cx,32
call ShowHex
clc
pop es
popa
ret
errorelf:
stc
pop es
popa
ret
;==========DEBUG===========
;CX adresse
;->CX
;<-
;==========================
debug:
mov esi,info11
call showstr
xor edx,edx
mov dx,cs
shl edx,4
add edx,ecx
mov cx,32
call ShowHex
infini:
jmp infini
;==========COPY2MEM===========
;Copie de es:esi vers es:edi
;->ES:ESI ES:EDI CX
;<- Flag
;=============================
copy2mem:
push eax
push esi
push edi
push ecx
mov esi,[es:edi+Sections.Offset]
add esi,[cs:begin]
mov ecx,[es:edi+Sections.Size]
shr ecx,2
inc ecx
mov edi,[es:edi+Sections.Vadress]
copietomem:
mov eax,[es:esi]
mov [es:edi],eax
add edi,4
add esi,4
dec ecx
jnz copietomem
pop ecx
pop edi
pop esi
pop eax
ret
;==========ZERO2MEM===========
;Remise à zero de es:edi
;->ES:EDI CX
;<- Flag
;=============================
zero2mem:
push eax
push esi
push edi
push ecx
mov esi,[es:edi+Sections.Offset]
add esi,[cs:begin]
mov ecx,[es:edi+Sections.Size]
shr ecx,2
inc ecx
mov edi,[es:edi+Sections.Vadress]
mov eax,0
zerotomem:
mov [es:edi],eax
add edi,4
dec ecx
jnz zerotomem
pop ecx
pop edi
pop esi
pop eax
ret
begin dd 0
entriepoint dd 0
offsetheader dd 0
offsetsection dd 0
nbprogram dw 0
nbsection dw 0
symbol dd 0
;==========SHOWHEX===========
;Affiche un nombre hexadécimal EDX de taille CX aprés le curseur
;-> EDX un entier, CX la taille
;<-
;============================
ShowHex:
push ax
push bx
push cx
push edx
push si
mov ax,cx
shr ax,2
sub cx,32
neg cx
shl edx,cl
xor cx,cx
inc cx
Hexaize:
rol edx,4
mov bx,dx
and bx,0fh
mov si,ax
mov al,[cs:bx+Tab]
xor bx,bx
mov ah,0x09
mov bl,[cs:thecolor]
int 0x10
mov ah,0x0E
int 0x10
mov ax,si
dec al
jnz Hexaize
pop si
pop edx
pop cx
pop bx
pop ax
ret
Tab db '0123456789ABCDEF'
;============EOL=============
;Va en colonne CX
;->
;<- Flag Carry si erreur
;============================
eol:
pusha
mov bp,cx
mov ah,03
xor bx,bx
int 10h
mov ah,02
mov cx,bp
mov dl,cl
int 10h
popa
ret
;============LOAD==============
;Charge le groupe en mémoire en EBX pour le groupe CX
;-> CX
;<- Flag Carry si erreur
;==============================
load:
push ax
push ebx
push ecx
push edx
push esi
push edi
push fs
xor edx,edx
xor ax,ax
mov fs,ax
mov si,The_Dot
mov dx,[Sectors_Size]
Resume_Loading:
cmp cx,0x0FF0
jae Finish_Loading
push cx
add cx,word [data]
mov edi,Buffer
call ReadSector
pop cx
jc near Boot_Error
call showstr
push esi
push ebx
push cx
mov esi,Buffer
mov cx,dx
shr cx,2
copie:
mov eax,[ds:esi]
mov [fs:ebx],eax
add ebx,4
add esi,4
dec cx
jnz copie
pop cx
pop ebx
pop esi
add ebx,edx
call NextFatGroup
jc near Boot_Error
jmp Resume_Loading
Finish_Loading:
pop fs
pop edi
pop esi
pop edx
pop ecx
pop ebx
pop ax
ret
;===========INITFAT=============
;Initialise les variables de la fat
;->
;<- Flag Carry si erreur
;===============================
initfat:
pusha
push ds
xor ax,ax
mov ds,ax
mov si,0x7C0B
mov di,bootsector
mov cx, 512
rep movsb
pop ds
mov cx,[Reserved_Sectors]
add cx,[Sectors_Hidden]
adc cx,[Sectors_Hidden+2]
mov bx,[Sectors_Per_Fat]
mov di,Fat_Buffer
push bx
push cx
readfat:
call ReadSector
jc Boot_Error
inc cx
add di,[Sectors_Size]
dec bx
jnz readfat
pop cx
pop bx
xor ax,ax
mov al,[Fats_Number]
mul bx
add cx,ax
mov [entries],cx
mov ax,32
mul word [Fits_Number]
div word [Sectors_Size]
add cx,ax
sub cx,2
mov word [data],cx
popa
ret
;===========SEARCH============
;Recherche le groupe d'un fichier
;-> si nom du fichier
;<- Flag Carry si erreur CX
;=============================
search:
push bx
push dx
push di
mov cx,[entries]
mov di,Buffer
call ReadSector
jc Boot_Error
xor bx,bx
Next_Root_Entrie:
cmp byte [di],0
je Boot_Error
push si
push di
push cx
mov cx,32
rep cmpsb
pop cx
pop di
pop si
je Found
add di,32
add bx,32
inc dx
cmp dx,[Fits_Number]
ja Boot_Error
cmp bx,[Sectors_Size]
jb Next_Root_Entrie
inc cx
Found:
mov cx,[di+26+32]
pop di
pop dx
pop bx
ret
;============SHOWRTN============
;Affiche la chaine de caractère return
;->
;<- Flag Carry si erreur
;===============================
showrtn:
push ds
push ax
push esi
mov esi,return
mov ax,cs
mov ds,ax
call showstr
pop esi
pop ax
pop ds
ret
;==============SHOWSTR=============
;Affiche la chaine de caractère pointé par ds:esi à l'écran
;-> DS, ESI
;<- Flag Carry si erreur
;==================================
showstr:
pushad
xor bh,bh
nextchar:
mov al,[ds:esi]
inc esi
or al,al
jz endshow
cmp al,' '
jb justchar
cmp al,'#'
jne nocolor
mov al,[ds:esi]
inc esi
sub al,'0'
shl al,3
mov [cs:thecolor],al
shr al,2
add [cs:thecolor],al
mov al,[ds:esi]
inc esi
sub al,'0'
add [cs:thecolor],al
jmp nextchar
nocolor:
cmp al,'@'
jne nocolor2
mov al,[ds:esi]
inc esi
sub al,'0'
shl al,3
mov cl,al
shr al,2
add cl,al
mov al,[ds:esi]
inc esi
sub cl,'0'
add cl,al
call eol
jmp nextchar
nocolor2:
xor bx,bx
mov ah,0x09
mov bl,[cs:thecolor]
xor cx,cx
inc cx
int 0x10
justchar:
mov ah,0x0E
int 0x10
jmp nextchar
endshow:
popad
ret
;==========READSECTOR============
;Lit le secteur logique LBA CX et le met en es:di
;-> CX (limité à 65536 secteurs, soit 32 Mo avec secteur 512 octets)
;<- Flag Carry si erreur
;================================
ReadSector:
pusha
mov ax,cx
xor dx,dx
div word [Sectors_Per_Track]
inc dl
mov bl,dl
xor dx,dx
div word [Heads_Number]
mov dh, [Boot_Drive]
xchg dl,dh
mov cx,ax
xchg cl,ch
shl cl,6
or cl, bl
mov bx,di
mov si, 4
mov al, 1
Read_Again:
mov ah, 2
int 0x13
jnc Read_Done
dec si
jnz Read_Again
Read_Done:
popa
ret
;============NEXTFATGROUP===========
;Renvoie en CX le groupe qui succède dans la FAT le groupe CX
;-> CX
;<- CX
;===================================
NextFatGroup:
push bx
push dx
push di
mov ax,cx
mov bx,ax
and bx,0000000000000001b
shr ax,1
mov cx,3
mul cx
mov di,Fat_Buffer
add di,ax
cmp bx,0
jnz Even_Group
Odd_Group:
mov dx,[di]
and dx,0x0FFF
mov cx,dx
jmp Next_Group_Found
Even_Group:
mov dx,[di+1]
and dx,0xFFF0
shr dx,4
mov cx,dx
Next_Group_Found:
pop di
pop dx
pop bx
ret
;============EnableA20============
;->
;<-
;Ouvre l'autoroute A20
;=================================
EnableA20:
cli
call ClearKeybBuffer
call WaitKeybCommand
mov al,0xd1
out 0x64,al
call WaitKeybCommand
mov al,0xdf
out 0x60,al
call WaitKeybCommand
jmp A20Enabled
WaitKeybCommand:
in al,0x64
test al,0x02
jnz WaitKeybCommand
ret
ClearKeybBuffer:
in al,0x64
test al,0x01
jnz ReadKeyb
ret
ReadKeyb:
in al,0x60
jmp ClearKeybBuffer
A20Enabled:
sti
ret
;=================================
;CODE 32 bits mode protégé
;=================================
GoPMode32:
[BITS 32]
;Initialisation des selecteurs
mov ax,ALL_DATA_SEL
mov es,ax
mov gs,ax
mov fs,ax
mov ss,ax
mov ds,ax
mov esp,0x3fffff
push KERNEL_SEL
push dword [cs:entriepoint]
;Execution du système
retf
section .data
thecolor db 0x07
msg0 db '#12@20-=< Lancement du Chargeur ELF >=-',0x0A,0x0D,0x0A,0x0D,0
msg1 db '#07Initialisation de la FAT',0
msg2 db '#07Recherche du systeme',0
msg3 db '#07Activation adressage 24 bits',0
msg4 db '#07Chargement des descripteurs',0
msg5 db '#07Passage en mode Flat real',0
msg6 db '#07Chargement du systeme',0
msg7 db '#07Mise en place format ELF',0
msg8 db '#07Passage en mode protege',0
info1 db 0x0A,0x0D,'Format ELF i386 reconnu, #08Sections :',0x0A,0x0D,0
info2 db ' ',0
info3 db '@12 | ',0
info4 db ' - ',0
info5 db ' -> ',0
info6 db '@35#12NON ALLOUE #08',0
info7 db 'Point entree en ',0
info8 db '@48 2**',0
info9 db '@15#12 VIDE #08',0
info10 db '@70MEM',0
info11 db 0x0A,0x0D,'#12Arret debug en ',0
return db 0x0A,0x0D,0
okay db ' #15[ #10OK #15]',0x0A,0x0D,0
error db ' #15[#12Erreur#15]',0x0A,0x0D,0x0A,0x0D,' <Appuyez une touche pour redemarrer>',0
The_Dot db '.',0
System_File db "As",0,"y",0,"s",0,"t",0,"e",0,0x0F,0,0xB8,"m",0,".",0,"s",0,"y",0,"s",0,0,0,0,0,0xFF,0xFF,0xFF,0xFF
entries dw 0
data dw 0
xy dw 0
GDTR:
.Size: dw GDT_END
.Address: dd 0
gdt0 equ $ ; null entry
GDT:
.Entry0: dw 0 ; limit 15:0
dw 0 ; base 15:0
db 0 ; base 23:16
db 0 ; type
db 0 ; limit 19:16, flags
db 0 ; base 31:24
SYS_CODE_SEL equ $-gdt0 ; code segment descriptor
.Entry1: dw 0xFFFF
dw 0x0 ; base
db 0x0 ; base
db 0x9A ; present, ring 0, code, non-conforming, readable
db 0xCF ; 32 bit
db 0
SYS_DATA_SEL equ $-gdt0 ; data segment descriptor
.Entry2: dw 0xFFFF
dw 0x0 ; base
db 0x0 ; base
db 0x92 ; present, ring 0, data, expand-up, writable
db 0xCF ; 32 bit
db 0
ALL_DATA_SEL equ $-gdt0 ; 4meg data segment descriptor
.Entry3: dw 0xFFFF
dw 0x0 ; base
db 0x0 ; base
db 0x92 ; present, ring 0, data, expand-up, writable
db 0xCF ; 4k pages, 32 bit
db 0
KERNEL_SEL equ $-gdt0 ; 4g code segment descriptor
.Entry4: dw 0xffff
dw 0x0 ; base
db 0x0 ; base
db 0x9A ; present, ring 0, code, non-conforming, readable
db 0xCF ; 4k pages, 32 bit
db 0
GDT_END equ $-gdt0 -1
bootsector equ $
Sectors_Size dw 0 ;Nombre d'octets/secteur
Sectors_Per_Cluster db 0 ;Nombre de secteurs/cluster
Reserved_Sectors dw 0 ;Nombre de secteurs réservé
Fats_Number db 0 ;Nombre de copies de la FAT
Fits_Number dw 0 ;Taille du répertoire racine
Sectors_Per_Disk dw 0 ;Nombre secteurs du volume si < 32 Mo
Media_Descriptor db 0 ;Descripteur de média
Sectors_Per_Fat dw 0 ;Nombre secteurs/FAT
Sectors_Per_Track dw 0 ;Nombre secteurs/piste
Heads_Number dw 0 ;Nombre de tete de lecture/écriture
Sectors_Hidden dd 0 ;Nombre de secteurs cachés
Sectors_Per_Disk2 dd 0 ;Nombre secteurs du volume si > 32 Mo
Boot_Drive db 0 ;Lecteur de démarrage
Reserved db 0 ;NA (pour NT seulement)
Extended_Boot_ID db 0 ;Signature Boot étendu 29h
Buffer equ $
Fat_Buffer equ $+512
SECTION .bss
%include "elf.h"

View File

@ -1,19 +0,0 @@
CC=nasm -f bin -o
all: makall
makall: boot12.bin loader.sys
boot12.bin: boot12.asm
$(CC) $@ $^
loader.sys: loader.asm
$(CC) $@ $^
clean:
rm -f *.o
rm -f *.bin
rm -f *.sys
rm -f *.com

8
debug/config.bochs Normal file
View File

@ -0,0 +1,8 @@
megs: 1024
romimage: file="/usr/share/bochs/BIOS-bochs-latest", address=0x00000
vgaromimage: file="/usr/share/bochs/VGABIOS-lgpl-latest"
boot: c
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=disk, mode=flat, translation=auto, path="./final/harddisk.img.final", cylinders=0, heads=0, spt=0, biosdetect=auto, model="Generic 1234"
cpu: count=1, ips=20000000
mouse: enabled=1

View File

@ -144,6 +144,9 @@
#define ror(addr) \
asm volatile ("rorb $0x1,%0":"=m" (addr):);
#define finit() \
asm volatile ("finit"::);
/******************************************************************************/
#define outb(port,value) \

32776
lib/3D/man.c

File diff suppressed because it is too large Load Diff

View File

@ -436,8 +436,6 @@ int test3d()
print("Mode graphique necessaire afin de lancer ce programme\r\n");
return 1;
}
line(-100,-50,1800,200,egatorgb(4));
waitascii();
model3d model;
float factor=100.0f;
type3D type=TYPE3D_POINTS;

View File

@ -652,7 +652,7 @@ void showchar(u16 coordx, u16 coordy, u8 thechar, u8 attrib)
writepxl(currentfont->width*coordx + x, currentfont->height*coordy + y, color);
writepxl(currentfont->width*coordx + x + 1, currentfont->height*coordy + y, color);
}
}
}

View File

@ -1,4 +1,4 @@
all: bits32 bits64 floppy harddisk uefi
all: bits32 bits64 harddisk uefi
sync
bits32: ARCH=bits32
@ -9,25 +9,21 @@ bits64: ARCH=bits64
bits64: lib/libs.o system/system.sys
sync
floppy: boot/boot12.bin final/floppy.img.final
harddisk: final/harddisk.img.final
uefi: final/harddiskuefi.img.final
install:
(sudo apt-get install nasm gcc qemu fusefat fuseext2 cgdb ovmf bsdmainutils tar bsdmainutils indent binutils)
(sudo apt-get install nasm gcc qemu fusefat fuseext2 cgdb ovmf bsdmainutils tar bsdmainutils indent binutils bochs bochs-x bochsbios)
clean:
(cd system; make clean)
(cd boot; make clean)
(cd lib;make clean)
(cd final;make clean)
sync
littleclean:
(cd system; make clean)
(cd boot; make clean)
(cd lib;make clean)
(cd final;make littleclean)
sync
@ -48,9 +44,7 @@ retest: littleclean test
retest64: littleclean test64
floppytest: bits32 floppy qemu-floppy
refloppytest: littleclean floppytest
testbochs: bits32 harddisk bochs-debug
view:
(hexdump -C ./final/harddisk.img.final|head -c10000)
@ -75,6 +69,9 @@ debug-system: bits32 harddisk qemu-debug
debug-system64: bits64 uefi qemu-debug64
(sleep 2;cgdb -x ./debug/system.txt)
bochs-debug:
(killall bochs-debug;bochs -f ./debug/config.bochs)
qemu-debug:
(killall qemu-system-i386;qemu-system-i386 -m 1G -drive format=raw,file=./final/harddisk.img.final -s -S &)
@ -87,18 +84,9 @@ qemu:
qemu64:
(killall qemu-system-x86_64;qemu-system-x86_64 -m 5G -drive format=raw,file=./final/harddiskuefi.img.final --bios /usr/share/qemu/OVMF.fd --enable-kvm -cpu host -s &)
qemu-floppy:
(killall qemu-system-i386;qemu-system-i386 -m 1G -fda ./final/floppy.img.final --enable-kvm -cpu host -s &)
system/system.sys:
(cd system; VESA=$(VESA) make)
boot/boot12.bin:
(cd boot; make)
final/floppy.img.final:
(cd final; make floppy.img.final)
final/harddisk.img.final:
(cd final; make harddisk.img.final)

View File

@ -99,8 +99,9 @@ int main(u32 magic, u32 addr)
warning();
else
ok();
printf(" -Installation des appels systemes utilisateur");
printf(" -Installation des appels systemes utilisateur et du FPU");
initsyscall();
finit();
ok();
retry: