feat: revision des fichiers, ajouts commentaires, ménage & indentation
This commit is contained in:
parent
3aa3adb92c
commit
56da8273e8
|
@ -59,9 +59,11 @@ Boot:
|
|||
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]
|
||||
|
@ -69,6 +71,7 @@ Boot:
|
|||
mov di,Fat_Buffer
|
||||
push bx
|
||||
push cx
|
||||
; Lecture de la FAT en mémoire
|
||||
readfat:
|
||||
call ReadSector
|
||||
jc Boot_Error
|
||||
|
@ -92,6 +95,7 @@ readfat:
|
|||
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
|
||||
|
@ -118,6 +122,7 @@ Next_Root_Entrie:
|
|||
inc cx
|
||||
jmp Find_System
|
||||
System_Found:
|
||||
; Système trouvé
|
||||
call Boot_Ok
|
||||
mov si,Entre_Message
|
||||
call ShowString
|
||||
|
@ -129,6 +134,7 @@ System_Found:
|
|||
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
|
||||
|
@ -143,6 +149,7 @@ Resume_Loading:
|
|||
jmp Resume_Loading
|
||||
Finish_Loading:
|
||||
call Boot_Ok
|
||||
; Exécution du chargeur ELF
|
||||
retf
|
||||
|
||||
;====================READSECTOR=======================
|
||||
|
|
270
boot/boot16.asm
270
boot/boot16.asm
|
@ -1,270 +0,0 @@
|
|||
[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 4 ;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 512 ;Taille du répertoire racine
|
||||
Sectors_Per_Disk dw 2880 ;Nombre secteurs du volume si < 32 Mo
|
||||
Media_Descriptor db 0xF8 ;Descripteur de média
|
||||
Sectors_Per_Fat dw 207 ;Nombre secteurs/FAT
|
||||
Sectors_Per_Track dw 18 ;Nombre secteurs/piste
|
||||
Heads_Number dw 38 ;Nombre de tete de lecture/écriture
|
||||
Sectors_Hidden dd 16 ;Nombre de secteurs cachés
|
||||
Sectors_Per_Disk2 dd 39 ;Nombre secteurs du volume si > 32 Mo
|
||||
Boot_Drive db 0x80 ;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 "FAT16 " ;Type de système de fichiers
|
||||
|
||||
;Cpu_Message db "CPU test",0
|
||||
;Boot_Message db "Booting ",0
|
||||
;Finding_Message db "System ",0
|
||||
;Loading_Message db "Loading ",0
|
||||
System_File db "SYSTEM SYS"
|
||||
Is_Ok db "[ OK ]",0x0A,0x0D,0
|
||||
Is_Failed db "[Failed]",0x0A,0x0D,"Press a key",0x0A,0x0D,0
|
||||
The_Dot db '.',0
|
||||
|
||||
Boot_Error:
|
||||
mov si,Is_Failed
|
||||
call ShowString
|
||||
mov ah,0
|
||||
int 0x16
|
||||
int 0x19
|
||||
|
||||
Boot_Ok:
|
||||
; mov al,[Stage]
|
||||
; cmp al,0
|
||||
; jz No_Ok
|
||||
mov si,Is_Ok
|
||||
call ShowString
|
||||
;No_Ok:
|
||||
; xor ah,ah
|
||||
; mov si,ax
|
||||
; add si,Boot_Message ;Cpu_Message
|
||||
; call ShowString
|
||||
; add byte [Stage],0x09
|
||||
ret
|
||||
;
|
||||
;Stage db 0
|
||||
|
||||
Boot:
|
||||
push cs
|
||||
push cs
|
||||
pop es
|
||||
pop ds
|
||||
mov [Boot_Drive],dl
|
||||
cli
|
||||
mov ax,0x9000
|
||||
mov ss,ax
|
||||
mov sp,0xFFFF
|
||||
sti
|
||||
; call Detect_Cpu
|
||||
; jc Boot_Error
|
||||
; call Boot_Ok
|
||||
xor ax,ax
|
||||
int 0x13
|
||||
; jc Boot_Error
|
||||
xor eax,eax
|
||||
add ax,[Reserved_Sectors]
|
||||
add ecx,eax
|
||||
mov di,Fat_Buffer
|
||||
call ReadSector
|
||||
jc Boot_Error
|
||||
xor eax,eax
|
||||
mov al,[Fats_Number]
|
||||
mov bx,[Sectors_Per_Fat]
|
||||
mul bx
|
||||
add ecx,eax
|
||||
mov ax,32
|
||||
mul word [Fits_Number]
|
||||
div word [Sectors_Size]
|
||||
add eax,ecx
|
||||
mov dword [Serial_Number],eax
|
||||
xor dx,dx
|
||||
; call Boot_Ok
|
||||
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,11
|
||||
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 ecx
|
||||
jmp Find_System
|
||||
System_Found:
|
||||
xor ecx,ecx
|
||||
mov cx,[di+26]
|
||||
mov ax,0x0071
|
||||
mov es,ax
|
||||
push es
|
||||
mov di,0x100
|
||||
push di
|
||||
; call Boot_Ok
|
||||
mov si,The_Dot
|
||||
Resume_Loading:
|
||||
cmp cx,0x0FFF0
|
||||
jae Finish_Loading
|
||||
call ReadGroup
|
||||
jc near Boot_Error
|
||||
call ShowString
|
||||
mov bx,cx
|
||||
shl bx,1
|
||||
mov cx,[bx+Fat_Buffer]
|
||||
jmp Resume_Loading
|
||||
Finish_Loading:
|
||||
call Boot_Ok
|
||||
retf
|
||||
|
||||
;====================READSECTOR=======================
|
||||
;Lit le secteur logique LBA ECX et le met en es:di
|
||||
;-> ECX (limité à 2^32 secteurs, soit 2 To avec secteur 512 octets)
|
||||
;<- Flag Carry si erreur
|
||||
;=====================================================
|
||||
ReadSector:
|
||||
pushad
|
||||
mov ax, cx
|
||||
ror ecx,16
|
||||
mov dx,cx
|
||||
rol ecx,16
|
||||
cmp ecx,4128705
|
||||
ja Extended_CHS
|
||||
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:
|
||||
popad
|
||||
ret
|
||||
Extended_CHS:
|
||||
mov si,ECHS_Block
|
||||
mov byte [si+Sizes],0x10
|
||||
mov byte [si+Reserve],0x01
|
||||
mov byte [si+NumSectors],0x01
|
||||
mov [si+Adressseg],es
|
||||
mov [si+Adressoff],di
|
||||
mov [si+SectorLow],ax
|
||||
mov [si+SectorHigh],dx
|
||||
mov di,4
|
||||
mov dl,[Boot_Drive]
|
||||
Read_AgainX:
|
||||
mov ah, 42h
|
||||
int 13h
|
||||
jnc Read_Done
|
||||
dec di
|
||||
jnz Read_AgainX
|
||||
|
||||
;======================READGROUP======================
|
||||
;lit le groupe cx en es:di et incr‚mente DI
|
||||
;-> cx, es:di
|
||||
;<- di, Flag Carry si erreur
|
||||
;=====================================================
|
||||
ReadGroup:
|
||||
push ax
|
||||
push cx
|
||||
push dx
|
||||
mov al,[Sectors_Per_Cluster]
|
||||
sub cx,2
|
||||
xor ah,ah
|
||||
mul cx
|
||||
mov cx,dx
|
||||
shl ecx,16
|
||||
mov cx,ax
|
||||
add ecx,dword [Serial_Number]
|
||||
mov al,[Sectors_Per_Cluster]
|
||||
read:
|
||||
call ReadSector
|
||||
jc errors
|
||||
inc ecx
|
||||
add di,[Sectors_Size]
|
||||
dec al
|
||||
jnz read
|
||||
clc
|
||||
errors:
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
;======================SHOWSTR========================
|
||||
;Affiche la chaine de caractère pointé par ds:si à l'écran
|
||||
;-> DS, SI
|
||||
;<- Flag Carry si erreur
|
||||
;=====================================================
|
||||
ShowString:
|
||||
;push ax
|
||||
;push bx
|
||||
;push si
|
||||
pusha
|
||||
Next_Char:
|
||||
lodsb
|
||||
or al,al
|
||||
jz End_Show
|
||||
mov ah,0x0E
|
||||
mov bx,0x07
|
||||
int 0x10
|
||||
jmp Next_Char
|
||||
End_Show:
|
||||
;pop si
|
||||
;pop bx
|
||||
;pop ax
|
||||
popa
|
||||
ret
|
||||
|
||||
times 510-($-$$) db ' '
|
||||
|
||||
dw 0xAA55
|
||||
|
||||
ECHS_Block equ $
|
||||
Buffer equ $+26
|
||||
Fat_Buffer equ $+26+512
|
||||
|
||||
section .bss
|
||||
|
||||
%include "echs.h"
|
||||
|
||||
;ECHS_Block resb 24
|
||||
;Buffer resb 512
|
||||
;Fat_Buffer resb 10000
|
|
@ -8,23 +8,23 @@
|
|||
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
|
||||
|
@ -40,7 +40,7 @@
|
|||
mov [GDTR.Address],eax
|
||||
lgdt [GDTR]
|
||||
call ok
|
||||
|
||||
;Passage en mode FLAT REAL
|
||||
mov si,msg5
|
||||
call showstr
|
||||
cli
|
||||
|
@ -63,30 +63,31 @@ call ok
|
|||
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:
|
||||
|
||||
;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
|
||||
|
||||
|
||||
|
@ -258,7 +259,7 @@ errorelf:
|
|||
;CX adresse
|
||||
;->CX
|
||||
;<-
|
||||
;===========================================
|
||||
;==========================
|
||||
debug:
|
||||
mov esi,info11
|
||||
call showstr
|
||||
|
@ -271,12 +272,11 @@ debug:
|
|||
infini:
|
||||
jmp infini
|
||||
|
||||
|
||||
;==========COPY2MEM===========
|
||||
;Copie de es:esi vers es:edi
|
||||
;->ES:ESI ES:EDI CX
|
||||
;<- Flag
|
||||
;===========================================
|
||||
;=============================
|
||||
copy2mem:
|
||||
push eax
|
||||
push esi
|
||||
|
@ -305,7 +305,7 @@ ret
|
|||
;Remise à zero de es:edi
|
||||
;->ES:EDI CX
|
||||
;<- Flag
|
||||
;===========================================
|
||||
;=============================
|
||||
zero2mem:
|
||||
push eax
|
||||
push esi
|
||||
|
@ -341,7 +341,7 @@ symbol dd 0
|
|||
;Affiche un nombre hexadécimal EDX de taille CX aprés le curseur
|
||||
;-> EDX un entier, CX la taille
|
||||
;<-
|
||||
;===========================================
|
||||
;============================
|
||||
ShowHex:
|
||||
push ax
|
||||
push bx
|
||||
|
@ -378,11 +378,11 @@ Hexaize:
|
|||
ret
|
||||
Tab db '0123456789ABCDEF'
|
||||
|
||||
;======================EOL========================
|
||||
;============EOL=============
|
||||
;Va en colonne CX
|
||||
;->
|
||||
;<- Flag Carry si erreur
|
||||
;=====================================================
|
||||
;============================
|
||||
eol:
|
||||
pusha
|
||||
mov bp,cx
|
||||
|
@ -396,12 +396,11 @@ eol:
|
|||
popa
|
||||
ret
|
||||
|
||||
|
||||
;======================LOAD========================
|
||||
;Charge le groupe en mémoire en ebx
|
||||
;->
|
||||
;============LOAD==============
|
||||
;Charge le groupe en mémoire en EBX pour le groupe CX
|
||||
;-> CX
|
||||
;<- Flag Carry si erreur
|
||||
;=====================================================
|
||||
;==============================
|
||||
load:
|
||||
push ax
|
||||
push ebx
|
||||
|
@ -455,11 +454,11 @@ Finish_Loading:
|
|||
pop ax
|
||||
ret
|
||||
|
||||
;======================INITFAT========================
|
||||
;===========INITFAT=============
|
||||
;Initialise les variables de la fat
|
||||
;->
|
||||
;<- Flag Carry si erreur
|
||||
;=====================================================
|
||||
;===============================
|
||||
initfat:
|
||||
pusha
|
||||
push ds
|
||||
|
@ -500,11 +499,11 @@ readfat:
|
|||
popa
|
||||
ret
|
||||
|
||||
;======================SEARCH========================
|
||||
;===========SEARCH============
|
||||
;Recherche le groupe d'un fichier
|
||||
;-> si nom du fichier
|
||||
;<- Flag Carry si erreur CX
|
||||
;=====================================================
|
||||
;=============================
|
||||
search:
|
||||
push bx
|
||||
push dx
|
||||
|
@ -541,11 +540,11 @@ Found:
|
|||
pop bx
|
||||
ret
|
||||
|
||||
;======================SHOWRTN========================
|
||||
;============SHOWRTN============
|
||||
;Affiche la chaine de caractère return
|
||||
;->
|
||||
;<- Flag Carry si erreur
|
||||
;=====================================================
|
||||
;===============================
|
||||
showrtn:
|
||||
push ds
|
||||
push ax
|
||||
|
@ -559,11 +558,11 @@ showrtn:
|
|||
pop ds
|
||||
ret
|
||||
|
||||
;======================SHOWSTR========================
|
||||
;==============SHOWSTR=============
|
||||
;Affiche la chaine de caractère pointé par ds:esi à l'écran
|
||||
;-> DS, SI
|
||||
;-> DS, ESI
|
||||
;<- Flag Carry si erreur
|
||||
;=====================================================
|
||||
;==================================
|
||||
showstr:
|
||||
pushad
|
||||
xor bh,bh
|
||||
|
@ -619,12 +618,11 @@ endshow:
|
|||
popad
|
||||
ret
|
||||
|
||||
|
||||
;====================READSECTOR=======================
|
||||
;==========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
|
||||
|
@ -653,11 +651,11 @@ Read_Done:
|
|||
popa
|
||||
ret
|
||||
|
||||
;===================NEXTFATGROUP======================
|
||||
;============NEXTFATGROUP===========
|
||||
;Renvoie en CX le groupe qui succède dans la FAT le groupe CX
|
||||
;-> CX
|
||||
;<-
|
||||
;=====================================================
|
||||
;<- CX
|
||||
;===================================
|
||||
NextFatGroup:
|
||||
push bx
|
||||
push dx
|
||||
|
@ -688,11 +686,11 @@ Next_Group_Found:
|
|||
pop bx
|
||||
ret
|
||||
|
||||
;***********************EnableA20*******************************
|
||||
;============EnableA20============
|
||||
;->
|
||||
;<-
|
||||
;Ouvre l'autoroute A20
|
||||
;***************************************************************
|
||||
;=================================
|
||||
EnableA20:
|
||||
cli
|
||||
call ClearKeybBuffer
|
||||
|
@ -722,8 +720,12 @@ A20Enabled:
|
|||
ret
|
||||
|
||||
|
||||
;=================================
|
||||
;CODE 32 bits mode protégé
|
||||
;=================================
|
||||
GoPMode32:
|
||||
[BITS 32]
|
||||
;Initialisation des selecteurs
|
||||
mov ax,ALL_DATA_SEL
|
||||
mov es,ax
|
||||
mov gs,ax
|
||||
|
@ -733,6 +735,7 @@ GoPMode32:
|
|||
mov esp,0x3fffff
|
||||
push KERNEL_SEL
|
||||
push dword [cs:entriepoint]
|
||||
;Execution du système
|
||||
retf
|
||||
|
||||
section .data
|
||||
|
|
|
@ -2,14 +2,11 @@ CC=nasm -f bin -o
|
|||
|
||||
all: makall
|
||||
|
||||
makall: boot12.bin boot16.bin loader.sys
|
||||
makall: boot12.bin loader.sys
|
||||
|
||||
boot12.bin: boot12.asm
|
||||
$(CC) $@ $^
|
||||
|
||||
boot16.bin: boot16.asm
|
||||
$(CC) $@ $^
|
||||
|
||||
loader.sys: loader.asm
|
||||
$(CC) $@ $^
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ all: cos2000.img
|
|||
cos2000.img:
|
||||
(dd if=/dev/zero of=cos2000.img count=2880 bs=512)
|
||||
(mkfs.msdos -F 12 -n "COS2000" cos2000.img)
|
||||
(mkdir ./mnt)
|
||||
(fusefat cos2000.img ./mnt -o rw+)
|
||||
(cp ../boot/loader.sys ./mnt/)
|
||||
(cp ../system/system.sys ./mnt/;sync)
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
#include "types.h"
|
||||
|
||||
void line(u32 x1, u32 y1, u32 x2, u32 y2, u8 color);
|
|
@ -0,0 +1 @@
|
|||
#include "types.h"
|
|
@ -1,6 +0,0 @@
|
|||
#include "types.h"
|
||||
|
||||
void outreg(u16 port,u8 *src,u16 num);
|
||||
void outregsame(u16 port,u8 *src,u16 num);
|
||||
void inreg(u16 port,u8 *src,u16 num);
|
||||
void inregsame(u16 port,u8 *src,u16 num);
|
|
@ -35,3 +35,7 @@ void enableblink();
|
|||
void disableblink();
|
||||
u8 (*getchar)(u16 coordx,u16 coordy);
|
||||
u8 (*getattrib)(u16 coordx,u16 coordy);
|
||||
void outreg(u16 port,u8 *src,u16 num);
|
||||
void outregsame(u16 port,u8 *src,u16 num);
|
||||
void inreg(u16 port,u8 *src,u16 num);
|
||||
void inregsame(u16 port,u8 *src,u16 num);
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
#include "types.h"
|
||||
#include "vga.h"
|
||||
#include "video.h"
|
||||
#include "2d.h"
|
||||
#include "math.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Affiche une ligne entre les points spécifiés */
|
||||
|
||||
void line(u32 x1, u32 y1, u32 x2, u32 y2, u8 color)
|
||||
{
|
||||
s32 dx, dy, sdx, sdy;
|
||||
u32 i, dxabs, dyabs, x, y, px, py;
|
||||
|
||||
dx = x2 - x1; /* distance horizontale de la line */
|
||||
dy = y2 - y1; /* distance verticale de la line * */
|
||||
dxabs = abs(dx);
|
||||
dyabs = abs(dy);
|
||||
sdx = sgn(dx);
|
||||
sdy = sgn(dy);
|
||||
x = dyabs >> 1;
|
||||
y = dxabs >> 1;
|
||||
px = x1;
|
||||
py = y1;
|
||||
|
||||
writepxl(px, py, color);
|
||||
|
||||
if (dxabs >= dyabs) { /* la ligne est plus horizontale que verticale */
|
||||
for (i = 0; i < dxabs; i++) {
|
||||
y += dyabs;
|
||||
if (y >= dxabs) {
|
||||
y -= dxabs;
|
||||
py += sdy;
|
||||
}
|
||||
px += sdx;
|
||||
writepxl(px, py, color);
|
||||
}
|
||||
} else { /* la ligne est plus verticale que horizontale */
|
||||
|
||||
for (i = 0; i < dyabs; i++) {
|
||||
x += dxabs;
|
||||
if (x >= dyabs) {
|
||||
x -= dyabs;
|
||||
px += sdx;
|
||||
}
|
||||
py += sdy;
|
||||
writepxl(px, py, color);
|
||||
}
|
||||
}
|
||||
}
|
3
lib/3d.c
3
lib/3d.c
|
@ -1,5 +1,6 @@
|
|||
#include "3d.h"
|
||||
#include "2d.h"
|
||||
#include "vga.h"
|
||||
#include "types.h"
|
||||
#include "video.h"
|
||||
#include "graph.h"
|
||||
|
||||
|
|
|
@ -0,0 +1,219 @@
|
|||
/* definition des registres de la carte VGA pour differents modes */
|
||||
|
||||
#define maxgraphmode 11
|
||||
#define maxtextmode 5
|
||||
|
||||
static mode_def textmodes[maxtextmode] = {
|
||||
|
||||
/*40*25 16 couleurs mode 0x00 */
|
||||
{
|
||||
0x67,
|
||||
0x03, 0x08, 0x03, 0x00, 0x02,
|
||||
0x2D, 0x27, 0x28, 0x90, 0x2B, 0xA0, 0xBF, 0x1F, 0x00,
|
||||
0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x8E, 0x8F, 0x14, 0x1F, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x08, 0x00,
|
||||
45, 25, 4},
|
||||
|
||||
/*80*25 16 couleurs mode 0x01 */
|
||||
{
|
||||
0x67,
|
||||
0x03, 0x00, 0x03, 0x00, 0x02,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00,
|
||||
0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x0E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x08, 0x00,
|
||||
80, 25, 4},
|
||||
|
||||
/*80*50 16 couleurs mode 0x02 */
|
||||
{
|
||||
0x63,
|
||||
0x03, 0x01, 0x03, 0x05, 0x02,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00,
|
||||
0x47, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x8E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x00, 0x00,
|
||||
80, 50, 4},
|
||||
|
||||
/*100*50 16 couleurs mode 0x03 */
|
||||
{
|
||||
0x67,
|
||||
0x03, 0x01, 0x03, 0x05, 0x02,
|
||||
0x70, 0x63, 0x64, 0x85, 0x68, 0x84, 0xBF, 0x1F, 0x00,
|
||||
0x47, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x8E, 0x8F, 0x32, 0x1F, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x00, 0x00,
|
||||
100, 50, 4},
|
||||
|
||||
/*100*60 16 couleurs mode 0x04 */
|
||||
{
|
||||
0xA7,
|
||||
0x03, 0x01, 0x03, 0x05, 0x02,
|
||||
0x70, 0x63, 0x64, 0x85, 0x68, 0x84, 0xFF, 0x1F, 0x00,
|
||||
0x47, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0xE7, 0x8E, 0xDF, 0x32, 0x1F, 0xDF, 0xE5, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x00, 0x00,
|
||||
100, 60, 4}
|
||||
};
|
||||
|
||||
static mode_def graphmodes[maxgraphmode] = {
|
||||
|
||||
/*640*480 n&b mode 0x80 */
|
||||
{
|
||||
0xE3,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xEA, 0x0C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x01, 0x00, 0x0F, 0x00, 0x00,
|
||||
80, 60, 1},
|
||||
|
||||
/*320*200 4 couleurs mode 0x81 */
|
||||
{
|
||||
0x63,
|
||||
0x03, 0x09, 0x03, 0x00, 0x02,
|
||||
0x2D, 0x27, 0x28, 0x90, 0x2B, 0x80, 0xBF, 0x1F, 0x00,
|
||||
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x0E, 0x8F, 0x14, 0x00, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x01, 0x00, 0x03, 0x00, 0x00,
|
||||
40, 25,
|
||||
},
|
||||
|
||||
/*640*480 16 couleurs mode 0x82 */
|
||||
{
|
||||
0xE3,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x53, 0x9F, 0x0B, 0x3E, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xE9, 0x8B, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x01, 0x00, 0x0F, 0x00, 0x00,
|
||||
80, 60, 4},
|
||||
|
||||
/*720*480 16 couleurs mode 0x83 */
|
||||
{
|
||||
0xE7,
|
||||
0x03, 0x01, 0x08, 0x00, 0x06,
|
||||
0x6B, 0x59, 0x5A, 0x82, 0x60, 0x8D, 0x0B, 0x3E, 0x00,
|
||||
0x40, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0xEA, 0x0C, 0xDF, 0x2D, 0x08, 0xE8, 0x05, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x01, 0x00, 0x0F, 0x00, 0x00,
|
||||
90, 60, 4},
|
||||
|
||||
/*800*600 16 couleurs mode 0x84 */
|
||||
{
|
||||
0xE7,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x70, 0x63, 0x64, 0x92, 0x65, 0x82, 0x70, 0xF0, 0x00,
|
||||
0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x5B, 0x8C, 0x57, 0x32, 0x00, 0x58, 0x70, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x01, 0x00, 0x0F, 0x00, 0x00,
|
||||
100, 75, 4},
|
||||
|
||||
/*320*200 256 couleurs RAPIDE mode 0x85 */
|
||||
{
|
||||
0x63,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x0E,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00,
|
||||
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x0E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
40, 25, 8},
|
||||
|
||||
/*320*200 256 couleurs mode 0x86 */
|
||||
{
|
||||
0x63,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00,
|
||||
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x0E, 0x8F, 0x28, 0x00, 0x96, 0xB9, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
40, 25, 8},
|
||||
|
||||
/*320*400 256 couleurs mode 0x87 */
|
||||
{
|
||||
0x63,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x8E, 0x8F, 0x28, 0x00, 0x96, 0xB9, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
40, 50, 8},
|
||||
|
||||
/*320*480 256 couleurs mode 0x88 */
|
||||
{
|
||||
0xE3,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xEA, 0xAC, 0xDF, 0x28, 0x00, 0xE7, 0x06, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
40, 60, 8},
|
||||
|
||||
/*360*480 256 couleurs mode 0x89 */
|
||||
{
|
||||
0xE7,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x6B, 0x59, 0x5A, 0x8E, 0x5E, 0x8A, 0x0D, 0x3E, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xEA, 0xAC, 0xDF, 0x2D, 0x00, 0xE7, 0x06, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
45, 60, 8},
|
||||
|
||||
/*400*600 256 couleurs mode 0x8A */
|
||||
{
|
||||
0xE7,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x74, 0x63, 0x64, 0x97, 0x68, 0x95, 0x86, 0xF0, 0x00,
|
||||
0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x5B, 0x8D, 0x57, 0x32, 0x00, 0x60, 0x80, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
50, 75, 8}
|
||||
};
|
111
lib/cpu.c
111
lib/cpu.c
|
@ -4,10 +4,9 @@
|
|||
#include "memory.h"
|
||||
#include "string.h"
|
||||
|
||||
/* Technologies supportées */
|
||||
|
||||
|
||||
static u8 *msg[] =
|
||||
{
|
||||
static u8 *msg[] = {
|
||||
"mmx",
|
||||
"mmx2",
|
||||
"sse",
|
||||
|
@ -22,44 +21,45 @@ static u8 *msg[] =
|
|||
|
||||
static u8 space[] = " ";
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Annule les FLAGs CPU */
|
||||
|
||||
bool cansetflag(u32 flag)
|
||||
{
|
||||
u32 r1, r2;
|
||||
asm("pushfl\n"
|
||||
"popl %0\n"
|
||||
"movl %0, %1\n"
|
||||
"xorl %2, %0\n"
|
||||
"pushl %0\n"
|
||||
"popfl\n"
|
||||
"pushfl\n"
|
||||
"popl %0\n"
|
||||
"pushl %1\n"
|
||||
"popfl\n"
|
||||
: "=&r" (r1), "=&r" (r2)
|
||||
: "ir" (flag)
|
||||
);
|
||||
asm("pushfl\n" "popl %0\n" "movl %0, %1\n" "xorl %2, %0\n" "pushl %0\n" "popfl\n" "pushfl\n" "popl %0\n" "pushl %1\n" "popfl\n": "=&r"(r1), "=&r"(r2):"ir"(flag));
|
||||
return ((r1 ^ r2) & flag) != 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Lance l'instruction CPUID */
|
||||
|
||||
void cpuid(u32 op, u32 * eax, u32 * ebx, u32 * ecx, u32 * edx)
|
||||
{
|
||||
asm("cpuid": "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx): "a"(op):"cc");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Retourne les informations sur le CPU dans une structure cpuinfo */
|
||||
|
||||
u8 getcpuinfos(cpuinfo * proc)
|
||||
{
|
||||
u32 i, maxfunction, maxextended, unused, regeax, regebx, regecx, regedx;
|
||||
bool *boolean;
|
||||
|
||||
if (!cansetflag (0x00040000)) return 1; /*386 processor - no cpuid*/
|
||||
if (!cansetflag (0x00200000)) return 2; /*486 processor with no cpuid*/
|
||||
if (!cansetflag(0x00040000))
|
||||
return 1; /*386 processor - no cpuid */
|
||||
if (!cansetflag(0x00200000))
|
||||
return 2; /*486 processor with no cpuid */
|
||||
|
||||
cpuid(0, &maxfunction, &unused, &unused, &unused);
|
||||
maxfunction &= 0xffff;
|
||||
cpuid(0x80000000, &maxextended, &unused, &unused, &unused);
|
||||
maxextended &= 0xffff;
|
||||
if (maxfunction >= 1)
|
||||
{
|
||||
if (maxfunction >= 1) {
|
||||
cpuid(1, ®eax, ®ebx, ®ecx, ®edx);
|
||||
proc->stepping = (regeax & 0x0000000F);
|
||||
proc->models = ((regeax >> 4) & 0x0000000F);
|
||||
|
@ -81,20 +81,18 @@ if (!cansetflag (0x00200000)) return 2; /*486 processor with no cpuid*/
|
|||
proc->htt = ((regedx >> 28) & 0x00000001);
|
||||
|
||||
}
|
||||
if (maxextended >= 1)
|
||||
{
|
||||
if (maxextended >= 1) {
|
||||
cpuid(0x80000001, ®eax, ®ebx, ®ecx, ®edx);
|
||||
proc->mmx2 = ((regedx >> 22) & 0x00000001);
|
||||
proc->apic = ((regedx >> 9) & 0x00000001);
|
||||
proc->now3d = ((regedx >> 30) & 0x00000001);
|
||||
proc->now3d2 = ((regedx >> 31) & 0x00000001);
|
||||
}
|
||||
if (maxextended >= 4)
|
||||
{
|
||||
if (maxextended >= 4) {
|
||||
int i;
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
cpuid(0x80000002+i, ®eax, ®ebx, ®ecx, ®edx);
|
||||
for (i = 0; i < 3; i++) {
|
||||
cpuid(0x80000002 + i, ®eax, ®ebx, ®ecx,
|
||||
®edx);
|
||||
memcpy(®eax, &proc->detectedname[0 + i * 16], 4, 1);
|
||||
memcpy(®ebx, &proc->detectedname[4 + i * 16], 4, 1);
|
||||
memcpy(®ecx, &proc->detectedname[8 + i * 16], 4, 1);
|
||||
|
@ -105,28 +103,28 @@ if (!cansetflag (0x00200000)) return 2; /*486 processor with no cpuid*/
|
|||
i = 0;
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
if (*(boolean++)==1)
|
||||
{
|
||||
if (*(boolean++) == 1) {
|
||||
strcat(msg[i], &proc->techs);
|
||||
strcat(space, &proc->techs);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Retourne un élément de la pile */
|
||||
|
||||
u32 viewstack(u32 number)
|
||||
{
|
||||
u32 stack = 0;
|
||||
asm (
|
||||
"movl %[a1],%%esi;"
|
||||
"addl %%esp,%%esi;"
|
||||
"movl (%%esi), %[a1] ;"
|
||||
:[result] "=r" (stack)
|
||||
:[a1] "r" (number)
|
||||
:"%esi"
|
||||
);
|
||||
asm("movl %[a1],%%esi;" "addl %%esp,%%esi;" "movl (%%esi), %[a1] ;": [result] "=r"(stack): [a1] "r"(number):"%esi");
|
||||
return stack;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Affiche les registres CPU */
|
||||
|
||||
void dump_regs()
|
||||
{
|
||||
u32 eax = 0;
|
||||
|
@ -144,37 +142,20 @@ void dump_regs()
|
|||
u16 gs = 0;
|
||||
u16 ss = 0;
|
||||
u32 flags = 0;
|
||||
asm (
|
||||
"movl %%eax, %[a1] ;"
|
||||
"movl %%ebx, %[b1] ;"
|
||||
"movl %%ecx, %[c1] ;"
|
||||
"movl %%edx, %[d1] ;"
|
||||
"movl %%esi, %[e1] ;"
|
||||
"movl %%edi, %[f1] ;"
|
||||
"movl %%esp, %[g1] ;"
|
||||
"movl %%ebp, %[h1] ;"
|
||||
"movw %%cs, %[i1] ;"
|
||||
"movw %%ds, %[j1] ;"
|
||||
"movw %%es, %[k1] ;"
|
||||
"movw %%fs, %[l1] ;"
|
||||
"movw %%gs, %[m1] ;"
|
||||
"movw %%ss, %[n1] ;"
|
||||
:
|
||||
[a1] "=m" (eax), [b1] "=m" (ebx), [c1] "=m" (ecx), [d1] "=m" (edx), [e1] "=m" (esi), [f1] "=m" (edi),
|
||||
[g1] "=m" (ebp), [h1] "=m" (esp), [i1] "=m" (cs), [j1] "=m" (ds), [k1] "=m" (es), [l1] "=m" (fs), [m1] "=m" (gs), [n1] "=m" (ss)
|
||||
);
|
||||
asm("movl %%eax, %[a1] ;" "movl %%ebx, %[b1] ;" "movl %%ecx, %[c1] ;" "movl %%edx, %[d1] ;" "movl %%esi, %[e1] ;" "movl %%edi, %[f1] ;" "movl %%esp, %[g1] ;" "movl %%ebp, %[h1] ;" "movw %%cs, %[i1] ;" "movw %%ds, %[j1] ;" "movw %%es, %[k1] ;" "movw %%fs, %[l1] ;" "movw %%gs, %[m1] ;" "movw %%ss, %[n1] ;":
|
||||
[a1] "=m"(eax),[b1] "=m"(ebx),[c1] "=m"(ecx),[d1] "=m"(edx),[e1] "=m"(esi),
|
||||
[f1] "=m"(edi),[g1] "=m"(ebp),[h1] "=m"(esp),[i1] "=m"(cs),[j1] "=m"(ds),
|
||||
[k1] "=m"(es),[l1] "=m"(fs),[m1] "=m"(gs),[n1] "=m"(ss));
|
||||
|
||||
printf("eax=%x ebx=%x ecx=%x eax=%x\r\n", eax,ebx,ecx,edx);
|
||||
printf("eax=%x ebx=%x ecx=%x eax=%x\r\n", eax, ebx,
|
||||
ecx, edx);
|
||||
printf("esi=%x edi=%x\r\n", esi, edi);
|
||||
printf("cs=%x ds=%x es=%x fs=%x gs=%x\r\n", cs,ds,es,fs,gs);
|
||||
printf("cs=%x ds=%x es=%x fs=%x gs=%x\r\n",
|
||||
cs, ds, es, fs, gs);
|
||||
printf("ss=%x esp=%x ebp=%x\r\n", ss, esp, ebp);
|
||||
|
||||
asm (
|
||||
"pushf ;"
|
||||
"pop %[f1] ;"
|
||||
:
|
||||
[f1] "=m" (flags)
|
||||
);
|
||||
asm("pushf ;" "pop %[f1] ;":
|
||||
[f1] "=m"(flags));
|
||||
|
||||
printf("FLAGS");
|
||||
|
||||
|
@ -212,6 +193,4 @@ void dump_regs()
|
|||
for (u8 i = 0; i < 25; i++)
|
||||
printf("+%d\t\t%x\r\n", i, viewstack(i * 4));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
58
lib/graph.c
58
lib/graph.c
|
@ -1,58 +0,0 @@
|
|||
#include "types.h"
|
||||
#include "vga.h"
|
||||
#include "video.h"
|
||||
#include "graph.h"
|
||||
#include "math.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Affiche une ligne entre les points spécifiés */
|
||||
|
||||
void line(u32 x1, u32 y1, u32 x2, u32 y2, u8 color)
|
||||
{
|
||||
s32 dx,dy,sdx,sdy;
|
||||
u32 i,dxabs,dyabs,x,y,px,py;
|
||||
|
||||
dx=x2-x1; /* distance horizontale de la line */
|
||||
dy=y2-y1; /* distance verticale de la line **/
|
||||
dxabs=abs(dx);
|
||||
dyabs=abs(dy);
|
||||
sdx=sgn(dx);
|
||||
sdy=sgn(dy);
|
||||
x=dyabs>>1;
|
||||
y=dxabs>>1;
|
||||
px=x1;
|
||||
py=y1;
|
||||
|
||||
writepxl(px,py,color);
|
||||
|
||||
if (dxabs>=dyabs) /* la ligne est plus horizontale que verticale */
|
||||
{
|
||||
for(i=0;i<dxabs;i++)
|
||||
{
|
||||
y+=dyabs;
|
||||
if (y>=dxabs)
|
||||
{
|
||||
y-=dxabs;
|
||||
py+=sdy;
|
||||
}
|
||||
px+=sdx;
|
||||
writepxl(px,py,color);
|
||||
}
|
||||
}
|
||||
else /* la ligne est plus verticale que horizontale */
|
||||
{
|
||||
for(i=0;i<dyabs;i++)
|
||||
{
|
||||
x+=dxabs;
|
||||
if (x>=dyabs)
|
||||
{
|
||||
x-=dyabs;
|
||||
px+=sdx;
|
||||
}
|
||||
py+=sdy;
|
||||
writepxl(px,py,color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
511
lib/idt.c
511
lib/idt.c
|
@ -1,511 +0,0 @@
|
|||
#include "idt.h"
|
||||
#include "types.h"
|
||||
#include "asm.h"
|
||||
#include "memory.h"
|
||||
#include "video.h"
|
||||
|
||||
/* registre idt */
|
||||
static struct dtr idtreg;
|
||||
|
||||
/* table de IDT */
|
||||
static idtdes idt[256];
|
||||
|
||||
|
||||
void initpic(void)
|
||||
{
|
||||
/* MASTER */
|
||||
/* Initialisation de ICW1 */
|
||||
outb(0x20,0x11);
|
||||
nop();
|
||||
/* Initialisation de ICW2 - vecteur de depart = 32 */
|
||||
outb(0x21,0x20);
|
||||
nop();
|
||||
/* Initialisation de ICW3 */
|
||||
outb(0x21,0x04);
|
||||
nop();
|
||||
/* Initialisation de ICW4 */
|
||||
outb(0x21,0x01);
|
||||
nop();
|
||||
/* masquage des interruptions */
|
||||
outb(0x21,0xFF);
|
||||
nop();
|
||||
/* SLAVE */
|
||||
/* Initialisation de ICW1 */
|
||||
outb(0xA0,0x11);
|
||||
nop();
|
||||
/* Initialisation de ICW2 - vecteur de depart = 96 */
|
||||
outb(0xA1,0x60);
|
||||
nop();
|
||||
/* Initialisation de ICW3 */
|
||||
outb(0xA1,0x02);
|
||||
nop();
|
||||
/* Initialisation de ICW4 */
|
||||
outb(0xA1,0x01);
|
||||
nop();
|
||||
/* masquage des interruptions */
|
||||
outb(0xA1,0xFF);
|
||||
nop();
|
||||
/* Demasquage des irqs sauf clavier
|
||||
outb(0x21,0xFD);
|
||||
nop();
|
||||
*/
|
||||
}
|
||||
|
||||
void enableirq(u8 irq)
|
||||
{
|
||||
u16 port;
|
||||
cli();
|
||||
port = (((irq & 0x08) << 4) + 0x21);
|
||||
outb(port,inb(port) & ~(1 << (irq & 7)));
|
||||
sti();
|
||||
}
|
||||
|
||||
void disableirq(u8 irq)
|
||||
{
|
||||
u16 port;
|
||||
cli();
|
||||
port = (((irq & 0x08) << 4) + 0x21);
|
||||
outb(port,inb(port) | (1 << (irq & 7)));
|
||||
sti();
|
||||
}
|
||||
|
||||
void makeidtdes(u32 offset, u16 select, u16 type, idtdes* desc)
|
||||
{
|
||||
desc->offset0_15 = (offset & 0xffff);
|
||||
desc->select = select;
|
||||
desc->type = type;
|
||||
desc->offset16_31 = (offset & 0xffff0000) >> 16;
|
||||
return;
|
||||
}
|
||||
|
||||
void setidt(u32 offset, u16 select, u16 type,u16 index)
|
||||
{
|
||||
cli();
|
||||
idtdes *desc;
|
||||
desc=idtreg.base;
|
||||
desc[index].offset0_15 = (offset & 0xffff);
|
||||
desc[index].select = select;
|
||||
desc[index].type = type;
|
||||
desc[index].offset16_31 = (offset & 0xffff0000) >> 16;
|
||||
sti();
|
||||
}
|
||||
|
||||
void putidt(u32 offset, u16 select, u16 type,u16 index)
|
||||
{
|
||||
idtdes temp;
|
||||
makeidtdes(offset,select,type,&temp);
|
||||
idt[index]=temp;
|
||||
}
|
||||
|
||||
void cpuerror(const u8 *src)
|
||||
{
|
||||
print("\033[31m***** ERREUR CPU ****\r\n -");
|
||||
print(src);
|
||||
dump_regs();
|
||||
while(1)
|
||||
{
|
||||
nop();
|
||||
}
|
||||
}
|
||||
|
||||
void interruption()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("Appel d'une interruption\r\n");
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
iret();
|
||||
}
|
||||
|
||||
void exception0()
|
||||
{
|
||||
print("divide error\r\n");
|
||||
}
|
||||
|
||||
void exception1()
|
||||
{
|
||||
cpuerror("debug exception\r\n");
|
||||
}
|
||||
|
||||
void exception2()
|
||||
{
|
||||
cpuerror("non-maskable hardware interrupt\r\n");
|
||||
}
|
||||
|
||||
void exception3()
|
||||
{
|
||||
cpuerror("INT3 instruction\r\n");
|
||||
}
|
||||
|
||||
void exception4()
|
||||
{
|
||||
cpuerror("INTO instruction detected overflow\r\n");
|
||||
}
|
||||
|
||||
void exception5()
|
||||
{
|
||||
print("BOUND instruction detected overrange\r\n");
|
||||
}
|
||||
|
||||
void exception6()
|
||||
{
|
||||
cpuerror("invalid instruction opcode\r\n");
|
||||
}
|
||||
|
||||
void exception7()
|
||||
{
|
||||
cpuerror("no coprocessor\r\n");
|
||||
}
|
||||
|
||||
void exception8()
|
||||
{
|
||||
cpuerror("double fault\r\n");
|
||||
}
|
||||
|
||||
void exception9()
|
||||
{
|
||||
cpuerror("coprocessor segment overrun\r\n");
|
||||
}
|
||||
|
||||
void exception10()
|
||||
{
|
||||
cpuerror("invalid task state segment (TSS)\r\n");
|
||||
}
|
||||
|
||||
void exception11()
|
||||
{
|
||||
cpuerror("segment not present\r\n");
|
||||
}
|
||||
|
||||
void exception12()
|
||||
{
|
||||
cpuerror("stack fault");
|
||||
}
|
||||
|
||||
void exception13()
|
||||
{
|
||||
cpuerror("general protection fault (GPF)\r\n");
|
||||
}
|
||||
|
||||
void exception14()
|
||||
{
|
||||
cpuerror("page fault\r\n");
|
||||
}
|
||||
|
||||
void exception15()
|
||||
{
|
||||
cpuerror("(reserved)\r\n");
|
||||
}
|
||||
|
||||
void exception16()
|
||||
{
|
||||
cpuerror("coprocessor error\r\n");
|
||||
}
|
||||
|
||||
void exception17()
|
||||
{
|
||||
cpuerror("alignment check\r\n");
|
||||
}
|
||||
|
||||
void exception18()
|
||||
{
|
||||
cpuerror("machine check");
|
||||
}
|
||||
|
||||
void irq0()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 0");
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq1()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 1");
|
||||
while ((inb(0x64)&1)==0);
|
||||
inb(0x60);
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq2()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 2");
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq3()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 3");
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq4()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 4");
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq5()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 5");
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq6()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 6");
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq7()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 7");
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq8()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 8");
|
||||
irqendslave();
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq9()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 9");
|
||||
irqendslave();
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq10()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 10");
|
||||
irqendslave();
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq11()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 11");
|
||||
irqendslave();
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq12()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 12");
|
||||
while ((inb(0x64)&1)==0);
|
||||
inb(0x60);
|
||||
irqendslave();
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq13()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 13");
|
||||
irqendslave();
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq14()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 14");
|
||||
irqendslave();
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq15()
|
||||
{
|
||||
cli();
|
||||
print("irq 15");
|
||||
irqendslave();
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void initidt(void)
|
||||
{
|
||||
u16 i;
|
||||
putidt((u32)exception0, 0x20, INTGATE, 0);
|
||||
putidt((u32)exception1, 0x20, INTGATE, 1);
|
||||
putidt((u32)exception2, 0x20, INTGATE, 2);
|
||||
putidt((u32)exception3, 0x20, INTGATE, 3);
|
||||
putidt((u32)exception4, 0x20, INTGATE, 4);
|
||||
putidt((u32)exception5, 0x20, INTGATE, 5);
|
||||
putidt((u32)exception6, 0x20, INTGATE, 6);
|
||||
putidt((u32)exception7, 0x20, INTGATE, 7);
|
||||
putidt((u32)exception8, 0x20, INTGATE, 8);
|
||||
putidt((u32)exception9, 0x20, INTGATE, 9);
|
||||
putidt((u32)exception10, 0x20, INTGATE, 10);
|
||||
putidt((u32)exception11, 0x20, INTGATE, 11);
|
||||
putidt((u32)exception12, 0x20, INTGATE, 12);
|
||||
putidt((u32)exception13, 0x20, INTGATE, 13);
|
||||
putidt((u32)exception14, 0x20, INTGATE, 14);
|
||||
putidt((u32)exception15, 0x20, INTGATE, 15);
|
||||
putidt((u32)exception16, 0x20, INTGATE, 16);
|
||||
putidt((u32)exception17, 0x20, INTGATE, 17);
|
||||
putidt((u32)exception18, 0x20, INTGATE, 18);
|
||||
for(i=19;i<32;i++)
|
||||
{
|
||||
putidt((u32)interruption, 0x20, INTGATE, i);
|
||||
}
|
||||
putidt((u32)irq0, 0x20, INTGATE, 32);
|
||||
putidt((u32)irq1, 0x20, INTGATE, 33);
|
||||
putidt((u32)irq2, 0x20, INTGATE, 34);
|
||||
putidt((u32)irq3, 0x20, INTGATE, 35);
|
||||
putidt((u32)irq4, 0x20, INTGATE, 36);
|
||||
putidt((u32)irq5, 0x20, INTGATE, 37);
|
||||
putidt((u32)irq6, 0x20, INTGATE, 38);
|
||||
putidt((u32)irq7, 0x20, INTGATE, 39);
|
||||
for(i=40;i<96;i++)
|
||||
{
|
||||
putidt((u32)interruption, 0x20, INTGATE, i);
|
||||
}
|
||||
putidt((u32)irq8, 0x20, INTGATE, 96);
|
||||
putidt((u32)irq9, 0x20, INTGATE, 97);
|
||||
putidt((u32)irq10, 0x20, INTGATE, 98);
|
||||
putidt((u32)irq11, 0x20, INTGATE, 99);
|
||||
putidt((u32)irq12, 0x20, INTGATE, 100);
|
||||
putidt((u32)irq13, 0x20, INTGATE, 101);
|
||||
putidt((u32)irq14, 0x20, INTGATE, 102);
|
||||
putidt((u32)irq15, 0x20, INTGATE, 103);
|
||||
for(i=104;i<255;i++)
|
||||
{
|
||||
putidt((u32)interruption, 0x20, INTGATE, i);
|
||||
}
|
||||
/* initialise le registre idt */
|
||||
idtreg.limite = 256*8;
|
||||
idtreg.base = 0x0000000;
|
||||
/* recopie de la IDT a son adresse */
|
||||
memcpy(&idt, (u8*)idtreg.base, idtreg.limite,1);
|
||||
/* chargement du registre IDTR */
|
||||
lidt(&idtreg);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,549 @@
|
|||
#include "interrupts.h"
|
||||
#include "types.h"
|
||||
#include "asm.h"
|
||||
#include "memory.h"
|
||||
#include "video.h"
|
||||
|
||||
/* registre idt */
|
||||
static struct dtr idtreg;
|
||||
|
||||
/* table de IDT */
|
||||
static idtdes idt[256];
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Initialise le controleur d'interruption 8259A */
|
||||
|
||||
void initpic(void)
|
||||
{
|
||||
/* MASTER */
|
||||
/* Initialisation de ICW1 */
|
||||
outb(0x20, 0x11);
|
||||
nop();
|
||||
/* Initialisation de ICW2 - vecteur de depart = 32 */
|
||||
outb(0x21, 0x20);
|
||||
nop();
|
||||
/* Initialisation de ICW3 */
|
||||
outb(0x21, 0x04);
|
||||
nop();
|
||||
/* Initialisation de ICW4 */
|
||||
outb(0x21, 0x01);
|
||||
nop();
|
||||
/* masquage des interruptions */
|
||||
outb(0x21, 0xFF);
|
||||
nop();
|
||||
/* SLAVE */
|
||||
/* Initialisation de ICW1 */
|
||||
outb(0xA0, 0x11);
|
||||
nop();
|
||||
/* Initialisation de ICW2 - vecteur de depart = 96 */
|
||||
outb(0xA1, 0x60);
|
||||
nop();
|
||||
/* Initialisation de ICW3 */
|
||||
outb(0xA1, 0x02);
|
||||
nop();
|
||||
/* Initialisation de ICW4 */
|
||||
outb(0xA1, 0x01);
|
||||
nop();
|
||||
/* masquage des interruptions */
|
||||
outb(0xA1, 0xFF);
|
||||
nop();
|
||||
/* Demasquage des irqs sauf clavier
|
||||
outb(0x21,0xFD);
|
||||
nop();
|
||||
*/
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Active une IRQ */
|
||||
|
||||
void enableirq(u8 irq)
|
||||
{
|
||||
u16 port;
|
||||
cli();
|
||||
port = (((irq & 0x08) << 4) + 0x21);
|
||||
outb(port, inb(port) & ~(1 << (irq & 7)));
|
||||
sti();
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Désactive une IRQ */
|
||||
|
||||
void disableirq(u8 irq)
|
||||
{
|
||||
u16 port;
|
||||
cli();
|
||||
port = (((irq & 0x08) << 4) + 0x21);
|
||||
outb(port, inb(port) | (1 << (irq & 7)));
|
||||
sti();
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Créé un descripteur pour l'IDT */
|
||||
|
||||
void makeidtdes(u32 offset, u16 select, u16 type, idtdes * desc)
|
||||
{
|
||||
desc->offset0_15 = (offset & 0xffff);
|
||||
desc->select = select;
|
||||
desc->type = type;
|
||||
desc->offset16_31 = (offset & 0xffff0000) >> 16;
|
||||
return;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Change une entrée dans l'IDT */
|
||||
|
||||
void setidt(u32 offset, u16 select, u16 type, u16 index)
|
||||
{
|
||||
cli();
|
||||
idtdes *desc;
|
||||
desc = idtreg.base;
|
||||
desc[index].offset0_15 = (offset & 0xffff);
|
||||
desc[index].select = select;
|
||||
desc[index].type = type;
|
||||
desc[index].offset16_31 = (offset & 0xffff0000) >> 16;
|
||||
sti();
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Met une entrée dans l'IDT */
|
||||
|
||||
void putidt(u32 offset, u16 select, u16 type, u16 index)
|
||||
{
|
||||
idtdes temp;
|
||||
makeidtdes(offset, select, type, &temp);
|
||||
idt[index] = temp;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Affiche une erreur CPU et fige l'ordinateur */
|
||||
|
||||
void cpuerror(const u8 * src)
|
||||
{
|
||||
print("\033[31m***** ERREUR CPU ****\r\n -");
|
||||
print(src);
|
||||
dump_regs();
|
||||
while (1) {
|
||||
nop();
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Déclenché lors de l'appel d'une interruption */
|
||||
|
||||
void interruption()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("Appel d'une interruption\r\n");
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
iret();
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Les expections */
|
||||
|
||||
void exception0()
|
||||
{
|
||||
print("divide error\r\n");
|
||||
}
|
||||
|
||||
void exception1()
|
||||
{
|
||||
cpuerror("debug exception\r\n");
|
||||
}
|
||||
|
||||
void exception2()
|
||||
{
|
||||
cpuerror("non-maskable hardware interrupt\r\n");
|
||||
}
|
||||
|
||||
void exception3()
|
||||
{
|
||||
cpuerror("INT3 instruction\r\n");
|
||||
}
|
||||
|
||||
void exception4()
|
||||
{
|
||||
cpuerror("INTO instruction detected overflow\r\n");
|
||||
}
|
||||
|
||||
void exception5()
|
||||
{
|
||||
print("BOUND instruction detected overrange\r\n");
|
||||
}
|
||||
|
||||
void exception6()
|
||||
{
|
||||
cpuerror("invalid instruction opcode\r\n");
|
||||
}
|
||||
|
||||
void exception7()
|
||||
{
|
||||
cpuerror("no coprocessor\r\n");
|
||||
}
|
||||
|
||||
void exception8()
|
||||
{
|
||||
cpuerror("double fault\r\n");
|
||||
}
|
||||
|
||||
void exception9()
|
||||
{
|
||||
cpuerror("coprocessor segment overrun\r\n");
|
||||
}
|
||||
|
||||
void exception10()
|
||||
{
|
||||
cpuerror("invalid task state segment (TSS)\r\n");
|
||||
}
|
||||
|
||||
void exception11()
|
||||
{
|
||||
cpuerror("segment not present\r\n");
|
||||
}
|
||||
|
||||
void exception12()
|
||||
{
|
||||
cpuerror("stack fault");
|
||||
}
|
||||
|
||||
void exception13()
|
||||
{
|
||||
cpuerror("general protection fault (GPF)\r\n");
|
||||
}
|
||||
|
||||
void exception14()
|
||||
{
|
||||
cpuerror("page fault\r\n");
|
||||
}
|
||||
|
||||
void exception15()
|
||||
{
|
||||
cpuerror("(reserved)\r\n");
|
||||
}
|
||||
|
||||
void exception16()
|
||||
{
|
||||
cpuerror("coprocessor error\r\n");
|
||||
}
|
||||
|
||||
void exception17()
|
||||
{
|
||||
cpuerror("alignment check\r\n");
|
||||
}
|
||||
|
||||
void exception18()
|
||||
{
|
||||
cpuerror("machine check");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Les IRQ par défaut */
|
||||
|
||||
void irq0()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 0");
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq1()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 1");
|
||||
while ((inb(0x64) & 1) == 0) ;
|
||||
inb(0x60);
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq2()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 2");
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq3()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 3");
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq4()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 4");
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq5()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 5");
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq6()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 6");
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq7()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 7");
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq8()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 8");
|
||||
irqendslave();
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq9()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 9");
|
||||
irqendslave();
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq10()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 10");
|
||||
irqendslave();
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq11()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 11");
|
||||
irqendslave();
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq12()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 12");
|
||||
while ((inb(0x64) & 1) == 0) ;
|
||||
inb(0x60);
|
||||
irqendslave();
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq13()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 13");
|
||||
irqendslave();
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq14()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
print("irq 14");
|
||||
irqendslave();
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
void irq15()
|
||||
{
|
||||
cli();
|
||||
print("irq 15");
|
||||
irqendslave();
|
||||
irqendmaster();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
asm("addl $0x01C, %esp;");
|
||||
iret();
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Initialise une IDT */
|
||||
|
||||
void initidt(void)
|
||||
{
|
||||
u16 i;
|
||||
putidt((u32) exception0, 0x20, INTGATE, 0);
|
||||
putidt((u32) exception1, 0x20, INTGATE, 1);
|
||||
putidt((u32) exception2, 0x20, INTGATE, 2);
|
||||
putidt((u32) exception3, 0x20, INTGATE, 3);
|
||||
putidt((u32) exception4, 0x20, INTGATE, 4);
|
||||
putidt((u32) exception5, 0x20, INTGATE, 5);
|
||||
putidt((u32) exception6, 0x20, INTGATE, 6);
|
||||
putidt((u32) exception7, 0x20, INTGATE, 7);
|
||||
putidt((u32) exception8, 0x20, INTGATE, 8);
|
||||
putidt((u32) exception9, 0x20, INTGATE, 9);
|
||||
putidt((u32) exception10, 0x20, INTGATE, 10);
|
||||
putidt((u32) exception11, 0x20, INTGATE, 11);
|
||||
putidt((u32) exception12, 0x20, INTGATE, 12);
|
||||
putidt((u32) exception13, 0x20, INTGATE, 13);
|
||||
putidt((u32) exception14, 0x20, INTGATE, 14);
|
||||
putidt((u32) exception15, 0x20, INTGATE, 15);
|
||||
putidt((u32) exception16, 0x20, INTGATE, 16);
|
||||
putidt((u32) exception17, 0x20, INTGATE, 17);
|
||||
putidt((u32) exception18, 0x20, INTGATE, 18);
|
||||
for (i = 19; i < 32; i++) {
|
||||
putidt((u32) interruption, 0x20, INTGATE, i);
|
||||
}
|
||||
putidt((u32) irq0, 0x20, INTGATE, 32);
|
||||
putidt((u32) irq1, 0x20, INTGATE, 33);
|
||||
putidt((u32) irq2, 0x20, INTGATE, 34);
|
||||
putidt((u32) irq3, 0x20, INTGATE, 35);
|
||||
putidt((u32) irq4, 0x20, INTGATE, 36);
|
||||
putidt((u32) irq5, 0x20, INTGATE, 37);
|
||||
putidt((u32) irq6, 0x20, INTGATE, 38);
|
||||
putidt((u32) irq7, 0x20, INTGATE, 39);
|
||||
for (i = 40; i < 96; i++) {
|
||||
putidt((u32) interruption, 0x20, INTGATE, i);
|
||||
}
|
||||
putidt((u32) irq8, 0x20, INTGATE, 96);
|
||||
putidt((u32) irq9, 0x20, INTGATE, 97);
|
||||
putidt((u32) irq10, 0x20, INTGATE, 98);
|
||||
putidt((u32) irq11, 0x20, INTGATE, 99);
|
||||
putidt((u32) irq12, 0x20, INTGATE, 100);
|
||||
putidt((u32) irq13, 0x20, INTGATE, 101);
|
||||
putidt((u32) irq14, 0x20, INTGATE, 102);
|
||||
putidt((u32) irq15, 0x20, INTGATE, 103);
|
||||
for (i = 104; i < 255; i++) {
|
||||
putidt((u32) interruption, 0x20, INTGATE, i);
|
||||
}
|
||||
/* initialise le registre idt */
|
||||
idtreg.limite = 256 * 8;
|
||||
idtreg.base = 0x0000000;
|
||||
/* recopie de la IDT a son adresse */
|
||||
memcpy(&idt, (u8 *) idtreg.base, idtreg.limite, 1);
|
||||
/* chargement du registre IDTR */
|
||||
lidt(&idtreg);
|
||||
|
||||
}
|
156
lib/keyboard.c
156
lib/keyboard.c
|
@ -1,4 +1,4 @@
|
|||
#include "idt.h"
|
||||
#include "interrupts.h"
|
||||
#include "types.h"
|
||||
#include "asm.h"
|
||||
#include "memory.h"
|
||||
|
@ -8,12 +8,16 @@
|
|||
|
||||
static u8 bufferscan[256] = { 0 };
|
||||
static u8 bufferascii[256] = { 0 };
|
||||
|
||||
static u8 ptrscan = 0;
|
||||
static u8 ptrascii = 0;
|
||||
static u16 kbdstatus, breakcode;
|
||||
|
||||
static const u8 set1_normal[] =
|
||||
{
|
||||
/******************************************************************************/
|
||||
|
||||
/* Tables clavier */
|
||||
|
||||
static const u8 set1_normal[] = {
|
||||
0, 0x1B, '&', 'é', '\"', '\'', '(', '-',
|
||||
'è', '_', 'ç', 'à', ')', '=', '\b', '\t',
|
||||
'a', 'z', 'e', 'r', 't', 'y', 'u', 'i',
|
||||
|
@ -28,8 +32,7 @@ static const u8 set1_normal[] =
|
|||
0
|
||||
};
|
||||
|
||||
static const u8 set1_shift[] =
|
||||
{
|
||||
static const u8 set1_shift[] = {
|
||||
0, 0x1B, '1', '2', '3', '4', '5', '6',
|
||||
'7', '8', '9', '0', '°', '+', '\b', '\t',
|
||||
'A', 'Z', 'E', 'R', 'T', 'Y', 'U', 'I',
|
||||
|
@ -44,8 +47,7 @@ static const u8 set1_shift[] =
|
|||
0
|
||||
};
|
||||
|
||||
static const u8 set1_alt[] =
|
||||
{
|
||||
static const u8 set1_alt[] = {
|
||||
0, 0x1B, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
@ -60,9 +62,7 @@ static const u8 set1_alt[] =
|
|||
0
|
||||
};
|
||||
|
||||
|
||||
static const u8 set1_altgr[] =
|
||||
{
|
||||
static const u8 set1_altgr[] = {
|
||||
0, 0x1B, 0, '~', '#', '{', '[', '|',
|
||||
'`', '\\', '^', '@', ']', '}', '\b', '\t',
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
@ -77,8 +77,7 @@ static const u8 set1_altgr[] =
|
|||
0
|
||||
};
|
||||
|
||||
static const u8 set1_ctrl[] =
|
||||
{
|
||||
static const u8 set1_ctrl[] = {
|
||||
0, 0x1B, 0, 0, 0, 0, 0x1B, 0,
|
||||
0, 0x1C, 0, 0, 0x1D, 0, 0, 0x1F,
|
||||
0x01, 0x1A, 0x05, 0x012, 0x14, 0x19, 0x15, 0x09,
|
||||
|
@ -92,45 +91,51 @@ static const u8 set1_ctrl[] =
|
|||
'2', '3', '0', '.', 0, 0, 0, 0,
|
||||
0
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Fonction qui attend l'appuie d'une touche générant un code ASCII puis le retourne */
|
||||
|
||||
u8 waitascii()
|
||||
{
|
||||
u8 oldptrscan = ptrscan;
|
||||
u8 oldptrascii = ptrascii;
|
||||
while((oldptrascii==ptrascii));/*(oldptrscan==ptrscan)&&*/
|
||||
while ((oldptrascii == ptrascii)) ;
|
||||
return bufferascii[ptrascii];
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Envoi d'une commande vers le contrôleur de clavier */
|
||||
|
||||
void outkbd(u8 port, u8 data)
|
||||
{
|
||||
u32 timeout;
|
||||
u8 state;
|
||||
|
||||
/* timeout */
|
||||
for(timeout = 500000L; timeout != 0; timeout--)
|
||||
{
|
||||
for (timeout = 500000L; timeout != 0; timeout--) {
|
||||
state = inb(0x64);
|
||||
/* vide le buffer du 8042 */
|
||||
if((state & 0x02) == 0) break;
|
||||
if ((state & 0x02) == 0)
|
||||
break;
|
||||
}
|
||||
if (timeout != 0)
|
||||
outb(port, data);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Redemarre l'ordinateur */
|
||||
|
||||
static void reboot(void)
|
||||
{
|
||||
u8 temp;
|
||||
cli();
|
||||
/* vide le 8042 */
|
||||
do
|
||||
{
|
||||
do {
|
||||
temp = inb(0x64);
|
||||
if((temp & 0x01) != 0)
|
||||
{
|
||||
if ((temp & 0x01) != 0) {
|
||||
(void)inb(0x60);
|
||||
continue;
|
||||
}
|
||||
|
@ -142,6 +147,9 @@ static void reboot(void)
|
|||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Converti un scancode vers une code ASCII */
|
||||
|
||||
unsigned convert(u32 keypressed)
|
||||
{
|
||||
u8 temp, key, lastscan;
|
||||
|
@ -149,21 +157,21 @@ unsigned convert(u32 keypressed)
|
|||
lastscan = ptrscan;
|
||||
/* incrémente le pointeur est assigne au buffer le dernier scancode */
|
||||
ptrscan++;
|
||||
if (ptrscan==255) ptrscan==0;
|
||||
if (ptrscan == 255)
|
||||
ptrscan == 0;
|
||||
bufferscan[ptrscan] = keypressed;
|
||||
/* break key (touche relaché) ? */
|
||||
if(keypressed >= 0x80) breakcode = 1;
|
||||
if (keypressed >= 0x80)
|
||||
breakcode = 1;
|
||||
key = (keypressed & 0x7F);
|
||||
/* Mise a jour des flags lors du relachement de touches de controle */
|
||||
if(breakcode)
|
||||
{
|
||||
if(key == SCAN_ALT)
|
||||
{
|
||||
if (breakcode) {
|
||||
if (key == SCAN_ALT) {
|
||||
kbdstatus &= ~STATUS_ALT;
|
||||
/* si ALT GR (E01D) alors activer aussi control */
|
||||
if (bufferscan[lastscan]==0xE0) kbdstatus &= ~STATUS_CTRL;
|
||||
}
|
||||
else if(key == SCAN_CTRL)
|
||||
if (bufferscan[lastscan] == 0xE0)
|
||||
kbdstatus &= ~STATUS_CTRL;
|
||||
} else if (key == SCAN_CTRL)
|
||||
kbdstatus &= ~STATUS_CTRL;
|
||||
else if (key == SCAN_LEFTSHIFT || key == SCAN_RIGHTSHIFT)
|
||||
kbdstatus &= ~STATUS_SHIFT;
|
||||
|
@ -171,42 +179,36 @@ unsigned convert(u32 keypressed)
|
|||
return 0;
|
||||
}
|
||||
/* Mise a jour des flags lors de l'appuie de touches de controle */
|
||||
if(key == SCAN_ALT)
|
||||
{
|
||||
if (key == SCAN_ALT) {
|
||||
kbdstatus |= STATUS_ALT;
|
||||
/* si ALT GR (E01D) alors desactiver aussi control */
|
||||
if (bufferscan[lastscan]==0xE0) kbdstatus |= STATUS_CTRL;
|
||||
return 0;
|
||||
}
|
||||
if(key == SCAN_CTRL)
|
||||
{
|
||||
if (bufferscan[lastscan] == 0xE0)
|
||||
kbdstatus |= STATUS_CTRL;
|
||||
return 0;
|
||||
}
|
||||
if(key == SCAN_LEFTSHIFT || key == SCAN_RIGHTSHIFT)
|
||||
{
|
||||
if (key == SCAN_CTRL) {
|
||||
kbdstatus |= STATUS_CTRL;
|
||||
return 0;
|
||||
}
|
||||
if (key == SCAN_LEFTSHIFT || key == SCAN_RIGHTSHIFT) {
|
||||
kbdstatus |= STATUS_SHIFT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((key >= SCAN_F1) && (key <= SCAN_F8))
|
||||
{
|
||||
if ((key >= SCAN_F1) && (key <= SCAN_F8)) {
|
||||
changevc(key - SCAN_F1);
|
||||
}
|
||||
|
||||
/* Scroll Lock, Num Lock, and Caps Lock mise a jour des leds */
|
||||
if(key == SCAN_SCROLLLOCK)
|
||||
{
|
||||
if (key == SCAN_SCROLLLOCK) {
|
||||
kbdstatus ^= STATUS_SCRL;
|
||||
goto LEDS;
|
||||
}
|
||||
if(key == SCAN_NUMLOCK)
|
||||
{
|
||||
if (key == SCAN_NUMLOCK) {
|
||||
kbdstatus ^= STATUS_NUM;
|
||||
goto LEDS;
|
||||
}
|
||||
if(key == SCAN_CAPSLOCK)
|
||||
{
|
||||
if (key == SCAN_CAPSLOCK) {
|
||||
kbdstatus ^= STATUS_CAPS;
|
||||
LEDS:
|
||||
outkbd(0x60, 0xED); /* "mise a jour des LEDS */
|
||||
|
@ -221,39 +223,52 @@ LEDS:
|
|||
return 0;
|
||||
}
|
||||
/* est ce un code etendu */
|
||||
if ((bufferscan[lastscan]==0xE0)||((kbdstatus & STATUS_NUM)&&(key>=0x47)&&(key<=0x53)&&(key!=0x4A)&&(key!=0x4e)))
|
||||
if ((bufferscan[lastscan] == 0xE0)
|
||||
|| ((kbdstatus & STATUS_NUM) && (key >= 0x47) && (key <= 0x53)
|
||||
&& (key != 0x4A) && (key != 0x4e)))
|
||||
/* exceptions */
|
||||
{
|
||||
/* '/' (E035) */
|
||||
if (key==0x35) return '/';
|
||||
if (key == 0x35)
|
||||
return '/';
|
||||
/* '\r' (E01C) 2ème enter numérique */
|
||||
if (key==0x1C) return '\r';
|
||||
if (key == 0x1C)
|
||||
return '\r';
|
||||
/* 0x11 (E048) device control 1) */
|
||||
if (key==0x48) return 0x11;
|
||||
if (key == 0x48)
|
||||
return 0x11;
|
||||
/* 0x12 (E050) device control 2) */
|
||||
if (key==0x50) return 0x12;
|
||||
if (key == 0x50)
|
||||
return 0x12;
|
||||
/* 0x13 (E04b) device control 3) */
|
||||
if (key==0x4b) return 0x13;
|
||||
if (key == 0x4b)
|
||||
return 0x13;
|
||||
/* 0x14 (E04d) device control 4) */
|
||||
if (key==0x4d) return 0x14;
|
||||
if (key == 0x4d)
|
||||
return 0x14;
|
||||
/* 0x02 (E049) start of text) */
|
||||
if (key==0x49) return 0x2;
|
||||
if (key == 0x49)
|
||||
return 0x2;
|
||||
/* 0x03 (E051) end of text) */
|
||||
if (key==0x51) return 0x3;
|
||||
if (key == 0x51)
|
||||
return 0x3;
|
||||
/* 0x10 (E047) Line feed) */
|
||||
if (key==0x47) return '\n';
|
||||
if (key == 0x47)
|
||||
return '\n';
|
||||
/* 0x1A (E052) Substitution) */
|
||||
if (key==0x52) return 0x1A;
|
||||
if (key == 0x52)
|
||||
return 0x1A;
|
||||
/* 0x18 (E053) Cancel) */
|
||||
if (key==0x53) return 0x18;
|
||||
if (key == 0x53)
|
||||
return 0x18;
|
||||
/* 0x19 (E04f) End of medium) */
|
||||
if (key==0x4f) return 0x19;
|
||||
if (key == 0x4f)
|
||||
return 0x19;
|
||||
return 0x00;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* detecte les SCANCODES invalides */
|
||||
if(key >= sizeof(set1_normal) / sizeof(set1_normal[0])) return 0;
|
||||
if (key >= sizeof(set1_normal) / sizeof(set1_normal[0]))
|
||||
return 0;
|
||||
/* converti le scancode en code ASCII en fonction du statut*/
|
||||
if (kbdstatus & STATUS_SHIFT || kbdstatus & STATUS_CAPS)
|
||||
temp = set1_shift[key];
|
||||
|
@ -268,11 +283,11 @@ if ((bufferscan[lastscan]==0xE0)||((kbdstatus & STATUS_NUM)&&(key>=0x47)&&(key<=
|
|||
}
|
||||
|
||||
/* si scancode non reconnu fin de fonction */
|
||||
if(temp == 0) return temp;
|
||||
if (temp == 0)
|
||||
return temp;
|
||||
/* Appuie de CRTL + ALT + SUPR ? */
|
||||
if ((kbdstatus & STATUS_CTRL) && (kbdstatus & STATUS_ALT) &&
|
||||
(key == 76))
|
||||
{
|
||||
(key == 76)) {
|
||||
print("redemarrage du systeme");
|
||||
reboot();
|
||||
}
|
||||
|
@ -280,9 +295,10 @@ if ((bufferscan[lastscan]==0xE0)||((kbdstatus & STATUS_NUM)&&(key>=0x47)&&(key<=
|
|||
return temp;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Handler d'interruption IRQ 1 pour le clavier */
|
||||
|
||||
void keyboard()
|
||||
{
|
||||
cli();
|
||||
|
@ -293,10 +309,10 @@ cli();
|
|||
while ((inb(0x64) & 1) == 0) ;
|
||||
scancode = inb(0x60);
|
||||
ascii = convert(scancode);
|
||||
if(ascii != 0)
|
||||
{
|
||||
if (ascii != 0) {
|
||||
ptrascii++;
|
||||
if (ptrascii==255) ptrascii==0;
|
||||
if (ptrascii == 255)
|
||||
ptrascii == 0;
|
||||
bufferascii[ptrascii] = ascii;
|
||||
}
|
||||
irqendmaster();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
CC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -fomit-frame-pointer -Wall -w -m32 -F pe-i386 -I ../include
|
||||
LINK=ld -m elf_i386 -r -o
|
||||
OBJS=memory.o vga.o port.o video.o mouse.o idt.o timer.o keyboard.o types.o string.o graph.o 3d.o math.o cpu.o
|
||||
OBJS=memory.o vga.o video.o mouse.o interrupts.o timer.o keyboard.o types.o string.o 2d.o 3d.o math.o cpu.o
|
||||
|
||||
all: makeall
|
||||
|
||||
|
|
11
lib/math.c
11
lib/math.c
|
@ -1,7 +1,12 @@
|
|||
#include "types.h"
|
||||
|
||||
u32 abs(int x)
|
||||
{
|
||||
if (x<0) x=-x;
|
||||
/******************************************************************************/
|
||||
|
||||
/* Fonction qui retourne la valeur absolue */
|
||||
|
||||
u32 abs(int x) {
|
||||
if (x < 0)
|
||||
x = -x;
|
||||
return (u32) x;
|
||||
}
|
||||
|
||||
|
|
12
lib/memory.c
12
lib/memory.c
|
@ -3,11 +3,11 @@
|
|||
/*******************************************************************************/
|
||||
|
||||
/* Copie un octet une ou plusieurs fois en mémoire */
|
||||
|
||||
void memset(void *dst, u8 val, u32 count, u32 size)
|
||||
{
|
||||
u8 * temp;
|
||||
for(temp = (u8 *)dst; count != 0; count--)
|
||||
{
|
||||
for (temp = (u8 *) dst; count != 0; count--) {
|
||||
temp += size;
|
||||
*temp = val;
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ void memset(void *dst, u8 val, u32 count,u32 size)
|
|||
/*******************************************************************************/
|
||||
|
||||
/* Copie une portion de mémoire vers une autre */
|
||||
void memcpy(void *src, void *dst, u32 count, u32 size)
|
||||
{
|
||||
|
||||
void memcpy(void *src, void *dst, u32 count, u32 size) {
|
||||
char *s, *d;
|
||||
u32 i;
|
||||
s = (u8 *) src;
|
||||
|
@ -30,12 +30,12 @@ void memcpy(void *src, void *dst, u32 count, u32 size)
|
|||
/*******************************************************************************/
|
||||
|
||||
/* Compare 2 portions de mémoire */
|
||||
|
||||
u32 memcmp(void *src, void *dst, u32 count, u32 size)
|
||||
{
|
||||
const u8 *mem1 = (const u8 *)src;
|
||||
const u8 *mem2 = (const u8 *)dst;
|
||||
for(; count != 0; count--)
|
||||
{
|
||||
for (; count != 0; count--) {
|
||||
if (*mem1 != *mem2)
|
||||
return *mem1 - *mem2;
|
||||
mem1 += size;
|
||||
|
|
225
lib/modes.c
225
lib/modes.c
|
@ -1,225 +0,0 @@
|
|||
/* definition des registres de la carte VGA pour differents modes */
|
||||
|
||||
#define maxgraphmode 11
|
||||
#define maxtextmode 5
|
||||
|
||||
|
||||
static mode_def textmodes[maxtextmode] = {
|
||||
|
||||
|
||||
/*40*25 16 couleurs mode 0x00*/
|
||||
{
|
||||
0x67,
|
||||
0x03, 0x08, 0x03, 0x00, 0x02,
|
||||
0x2D, 0x27, 0x28, 0x90, 0x2B, 0xA0, 0xBF, 0x1F, 0x00,
|
||||
0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x8E, 0x8F, 0x14, 0x1F, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x08, 0x00,
|
||||
45, 25, 4
|
||||
},
|
||||
|
||||
|
||||
/*80*25 16 couleurs mode 0x01*/
|
||||
{
|
||||
0x67,
|
||||
0x03, 0x00, 0x03, 0x00, 0x02,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00,
|
||||
0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x0E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x08, 0x00,
|
||||
80, 25, 4
|
||||
},
|
||||
|
||||
|
||||
/*80*50 16 couleurs mode 0x02*/
|
||||
{
|
||||
0x63,
|
||||
0x03, 0x01, 0x03, 0x05, 0x02,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00,
|
||||
0x47, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x8E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x00, 0x00,
|
||||
80, 50, 4
|
||||
},
|
||||
|
||||
|
||||
/*100*50 16 couleurs mode 0x03*/
|
||||
{
|
||||
0x67,
|
||||
0x03, 0x01, 0x03, 0x05, 0x02,
|
||||
0x70, 0x63, 0x64, 0x85, 0x68, 0x84, 0xBF, 0x1F, 0x00,
|
||||
0x47, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x8E, 0x8F, 0x32, 0x1F, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x00, 0x00,
|
||||
100, 50, 4
|
||||
},
|
||||
|
||||
|
||||
/*100*60 16 couleurs mode 0x04*/
|
||||
{
|
||||
0xA7,
|
||||
0x03, 0x01, 0x03, 0x05, 0x02,
|
||||
0x70, 0x63, 0x64, 0x85, 0x68, 0x84, 0xFF, 0x1F, 0x00,
|
||||
0x47, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0xE7, 0x8E, 0xDF, 0x32, 0x1F, 0xDF, 0xE5, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x00, 0x00,
|
||||
100, 60, 4
|
||||
}
|
||||
};
|
||||
|
||||
static mode_def graphmodes[maxgraphmode] = {
|
||||
|
||||
/*640*480 n&b mode 0x80*/
|
||||
{
|
||||
0xE3,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xEA, 0x0C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x01, 0x00, 0x0F, 0x00, 0x00,
|
||||
80, 60, 1
|
||||
},
|
||||
|
||||
/*320*200 4 couleurs mode 0x81*/
|
||||
{
|
||||
0x63,
|
||||
0x03, 0x09, 0x03, 0x00, 0x02,
|
||||
0x2D, 0x27, 0x28, 0x90, 0x2B, 0x80, 0xBF, 0x1F, 0x00,
|
||||
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x0E, 0x8F, 0x14, 0x00, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x01, 0x00, 0x03, 0x00, 0x00,
|
||||
40, 25,
|
||||
},
|
||||
|
||||
/*640*480 16 couleurs mode 0x82*/
|
||||
{
|
||||
0xE3,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x53, 0x9F, 0x0B, 0x3E, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xE9, 0x8B, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x01, 0x00, 0x0F, 0x00, 0x00,
|
||||
80, 60, 4
|
||||
},
|
||||
|
||||
/*720*480 16 couleurs mode 0x83*/
|
||||
{
|
||||
0xE7,
|
||||
0x03, 0x01, 0x08, 0x00, 0x06,
|
||||
0x6B, 0x59, 0x5A, 0x82, 0x60, 0x8D, 0x0B, 0x3E, 0x00,
|
||||
0x40, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0xEA, 0x0C, 0xDF, 0x2D, 0x08, 0xE8, 0x05, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x01, 0x00, 0x0F, 0x00, 0x00,
|
||||
90, 60, 4
|
||||
},
|
||||
|
||||
/*800*600 16 couleurs mode 0x84*/
|
||||
{
|
||||
0xE7,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x70, 0x63, 0x64, 0x92, 0x65, 0x82, 0x70, 0xF0, 0x00,
|
||||
0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x5B, 0x8C, 0x57, 0x32, 0x00, 0x58, 0x70, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x01, 0x00, 0x0F, 0x00, 0x00,
|
||||
100, 75, 4
|
||||
},
|
||||
|
||||
/*320*200 256 couleurs RAPIDE mode 0x85*/
|
||||
{
|
||||
0x63,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x0E,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00,
|
||||
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x0E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
40, 25, 8
|
||||
},
|
||||
|
||||
/*320*200 256 couleurs mode 0x86*/
|
||||
{
|
||||
0x63,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00,
|
||||
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x0E, 0x8F, 0x28, 0x00, 0x96, 0xB9, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
40, 25, 8
|
||||
},
|
||||
|
||||
/*320*400 256 couleurs mode 0x87*/
|
||||
{
|
||||
0x63,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x8E, 0x8F, 0x28, 0x00, 0x96, 0xB9, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
40, 50, 8
|
||||
},
|
||||
|
||||
/*320*480 256 couleurs mode 0x88*/
|
||||
{
|
||||
0xE3,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xEA, 0xAC, 0xDF, 0x28, 0x00, 0xE7, 0x06, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
40, 60, 8
|
||||
},
|
||||
|
||||
/*360*480 256 couleurs mode 0x89*/
|
||||
{
|
||||
0xE7,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x6B, 0x59, 0x5A, 0x8E, 0x5E, 0x8A, 0x0D, 0x3E, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xEA, 0xAC, 0xDF, 0x2D, 0x00, 0xE7, 0x06, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
45, 60, 8
|
||||
},
|
||||
|
||||
/*400*600 256 couleurs mode 0x8A*/
|
||||
{
|
||||
0xE7,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x74, 0x63, 0x64, 0x97, 0x68, 0x95, 0x86, 0xF0, 0x00,
|
||||
0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x5B, 0x8D, 0x57, 0x32, 0x00, 0x60, 0x80, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
50, 75, 8
|
||||
}
|
||||
};
|
||||
|
84
lib/mouse.c
84
lib/mouse.c
|
@ -5,6 +5,10 @@
|
|||
#include "vga.h"
|
||||
#include "video.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* initialise la souris */
|
||||
|
||||
bool initmouse()
|
||||
{
|
||||
u16 i = 1024;
|
||||
|
@ -23,7 +27,9 @@ outmseack(0xf4); /* Autorise peripherique */
|
|||
|
||||
outmsecmd(0x47); /* Autorise interruption */
|
||||
|
||||
while(i-->0) if (inb(0x60)==250) return 1;
|
||||
while (i-- > 0)
|
||||
if (inb(0x60) == 250)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -35,30 +41,39 @@ static u8 oldchar=0x00,oldattr=0x07;
|
|||
static bool mousebut1 = 0, mousebut2 = 0, mousebut3 = 0;
|
||||
static u8 speed = 6;
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* ecriture vers souris */
|
||||
|
||||
void outmseack(u8 value)
|
||||
{
|
||||
outkbd(0x64,0xD4); /* ecriture vers souris */
|
||||
outkbd(0x64, 0xD4);
|
||||
outb(0x60, value);
|
||||
mousereplies++;
|
||||
}
|
||||
|
||||
/* ecriture vers mode */
|
||||
|
||||
void outmsecmd(u8 command)
|
||||
{
|
||||
outkbd(0x64,0x60); /* ecriture vers mode */
|
||||
outkbd(0x64, 0x60);
|
||||
outb(0x60, command);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Handler d'interruption de la souris IRQ 12 */
|
||||
|
||||
void mouse()
|
||||
{
|
||||
cli();
|
||||
pushf();
|
||||
pushad();
|
||||
u8 mbyte = inb(0x60);
|
||||
s8 changex, changey;
|
||||
cli();
|
||||
|
||||
if (mousereplies > 0)
|
||||
{
|
||||
if (mbyte == 0xFA)
|
||||
{
|
||||
if (mousereplies > 0) {
|
||||
if (mbyte == 0xFA) {
|
||||
mousereplies--;
|
||||
goto endofint;
|
||||
}
|
||||
|
@ -70,34 +85,34 @@ cli();
|
|||
|
||||
if (bytepos == 3) {
|
||||
bytepos = 0;
|
||||
if ( mpacket[1] == 0)
|
||||
{
|
||||
if (mpacket[1] == 0) {
|
||||
changex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
changex = (mpacket[0] & 0x10) ?
|
||||
mpacket[1] - 256 :
|
||||
mpacket[1];
|
||||
mpacket[1] - 256 : mpacket[1];
|
||||
}
|
||||
if (mpacket[2] == 0)
|
||||
{
|
||||
if (mpacket[2] == 0) {
|
||||
changey = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
changey = -((mpacket[0] & 0x20) ?
|
||||
mpacket[2] - 256 :
|
||||
mpacket[2]);
|
||||
mpacket[2] - 256 : mpacket[2]);
|
||||
}
|
||||
|
||||
mousex += (changex << speed);
|
||||
mousey += (changey << speed);
|
||||
|
||||
if(mousex<0) { mousex=0; }
|
||||
if(mousex>=65535) { mousex=65535; }
|
||||
if(mousey<0) { mousey=0; }
|
||||
if(mousey>=65535) { mousey=65535; }
|
||||
if (mousex < 0) {
|
||||
mousex = 0;
|
||||
}
|
||||
if (mousex >= 65535) {
|
||||
mousex = 65535;
|
||||
}
|
||||
if (mousey < 0) {
|
||||
mousey = 0;
|
||||
}
|
||||
if (mousey >= 65535) {
|
||||
mousey = 65535;
|
||||
}
|
||||
|
||||
u16 newx = (u32) mousex * getxres() / 65536;
|
||||
u16 newy = (u32) mousey * getyres() / 65536;
|
||||
|
@ -109,8 +124,7 @@ if ( mpacket[1] == 0)
|
|||
|
||||
// printf("RX:%d\tRY:%d\tX:%d\tY:%d\tB1:%d\tB2:%d\tB3:%d\t\r\n",changex,changey,mousex,mousey,mousebut1,mousebut2,mousebut3);
|
||||
|
||||
if ((newx!=oldx)||(newy!=oldy))
|
||||
{
|
||||
if ((newx != oldx) || (newy != oldy)) {
|
||||
showchar(oldx, oldy, oldchar, oldattr);
|
||||
oldx = newx;
|
||||
oldy = newy;
|
||||
|
@ -122,17 +136,11 @@ if ((newx!=oldx)||(newy!=oldy))
|
|||
endofint:
|
||||
irqendmaster();
|
||||
irqendslave();
|
||||
popad();
|
||||
popf();
|
||||
sti();
|
||||
//asm("movl 0x2C(%esp), %ebx;movl 0x30(%esp), %esi;movl 0x34(%esp), %edi;movl 0x38(%esp), %ebp;addl $0x3C, %esp;iret;");
|
||||
asm(
|
||||
"addl $0x18,%esp;\
|
||||
asm("addl $0x18,%esp;\
|
||||
popl %bx;\
|
||||
iret;");
|
||||
iret();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
68
lib/port.c
68
lib/port.c
|
@ -1,68 +0,0 @@
|
|||
#include "types.h"
|
||||
#include "asm.h"
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
/* Envoie une série d'octet a destination d'une portion de mémoire
|
||||
vers le registre video spécifié */
|
||||
|
||||
void outreg(u16 port,u8 *src,u16 num)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<num;i++)
|
||||
{
|
||||
outb(port,i);
|
||||
outb(port+1,*src++);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
/* Envoie une série d'octet a destination d'une portion de mémoire
|
||||
vers le registre video spécifié (accés data et index confondu) */
|
||||
|
||||
void outregsame(u16 port,u8 *src,u16 num)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<num;i++)
|
||||
{
|
||||
inb(port);
|
||||
outb(port,i);
|
||||
outb(port,*src++);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
/* Récupère une série d'octet en provenance d'un registre video spécifié
|
||||
vers portion de mémoire */
|
||||
|
||||
void inreg(u16 port,u8 *src,u16 num)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<num;i++)
|
||||
{
|
||||
outb(port,i);
|
||||
*src++=inb(port+1);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
/* Récupère une série d'octet en provenance d'un registre video spécifié
|
||||
vers portion de mémoire (accés data et index confondu) */
|
||||
|
||||
void inregsame(u16 port,u8 *src,u16 num)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<num;i++)
|
||||
{
|
||||
inb(port);
|
||||
outb(port,i);
|
||||
*src++=inb(port);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
25
lib/string.c
25
lib/string.c
|
@ -1,27 +1,34 @@
|
|||
#include <string.h>
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Compare 2 chaines de caractère et renvoie la premiere distance (diff) */
|
||||
|
||||
s8 strcmp(const u8 * src, const u8 * des)
|
||||
{
|
||||
register s8 result;
|
||||
do
|
||||
{
|
||||
if ((result = *src - *des++) != 0) break;
|
||||
do {
|
||||
if ((result = *src - *des++) != 0)
|
||||
break;
|
||||
}
|
||||
while (*src++ != 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Trouve la premiere occurence d'un caractère dans une chaine */
|
||||
|
||||
u8 *strchr(const u8 * src, u8 achar)
|
||||
{
|
||||
for (; *src != achar; ++src)
|
||||
if (*src == 0) return 0;
|
||||
if (*src == 0)
|
||||
return 0;
|
||||
return (u8 *) src;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Renvoie la taille de la chaine */
|
||||
|
||||
u32 strlen(const u8 * src)
|
||||
|
@ -32,6 +39,7 @@ u32 strlen(const u8 *src)
|
|||
return size;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* copie une chaine dans une autre */
|
||||
u8 *strcpy(const u8 * src, u8 * des)
|
||||
|
@ -41,6 +49,7 @@ u8* strcpy(const u8 *src, u8 *des)
|
|||
return temp;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* copie une portion limité d'une chaine asciiZ*/
|
||||
|
||||
|
@ -48,18 +57,22 @@ u8 *strncpy(const u8 *src,u8 *des,u32 count)
|
|||
{
|
||||
u8 *temp = des;
|
||||
while (count) {
|
||||
if ((*temp = *src) != 0) src++;
|
||||
if ((*temp = *src) != 0)
|
||||
src++;
|
||||
temp++;
|
||||
count--;
|
||||
}
|
||||
return des;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* concatene 2 chaines de caractère */
|
||||
u8 *strcat(const u8 * src, u8 * des)
|
||||
{
|
||||
u8 *temp = des;
|
||||
while (*des!=0) des++;
|
||||
while (*des != 0)
|
||||
des++;
|
||||
while ((*des++ = *src++) != 0) ;
|
||||
return temp;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
#include "idt.h"
|
||||
#include "interrupts.h"
|
||||
#include "types.h"
|
||||
#include "asm.h"
|
||||
#include "memory.h"
|
||||
#include "timer.h"
|
||||
#include "vga.h"
|
||||
|
||||
|
||||
static u8 curs[4] = { "-\\|/" };
|
||||
|
||||
static u8 curspos = 0;
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Handler d'interruption de la souris IRQ 0 */
|
||||
|
||||
void timer()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include <types.h>
|
||||
|
||||
char ctype[] =
|
||||
{
|
||||
char ctype[] = {
|
||||
0x00,
|
||||
/* 0 */ CT_CTL, CT_CTL, CT_CTL, CT_CTL,
|
||||
CT_CTL, CT_CTL, CT_CTL, CT_CTL,
|
||||
|
|
216
lib/vga.c
216
lib/vga.c
|
@ -1,11 +1,10 @@
|
|||
#include "vga.h"
|
||||
#include "memory.h"
|
||||
#include "asm.h"
|
||||
#include "port.h"
|
||||
#include "types.h"
|
||||
#include "modes.c"
|
||||
#include "8x8fnt.c"
|
||||
#include "8x16fnt.c"
|
||||
#include "VGA/modes.c"
|
||||
#include "VGA/8x8fnt.c"
|
||||
#include "VGA/8x16fnt.c"
|
||||
|
||||
/* Registres VGAs */
|
||||
|
||||
|
@ -70,7 +69,8 @@ return pages;
|
|||
|
||||
void setpage(u8 page)
|
||||
{
|
||||
if (page<pages) activepage=page;
|
||||
if (page < pages)
|
||||
activepage = page;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
@ -88,8 +88,7 @@ return activepage;
|
|||
|
||||
void showpage(u8 page)
|
||||
{
|
||||
if (page<pages)
|
||||
{
|
||||
if (page < pages) {
|
||||
u16 addr;
|
||||
addr = page * pagesize / 2;
|
||||
outb(ccrt, 0x0C);
|
||||
|
@ -99,6 +98,7 @@ u16 addr;
|
|||
showedpage = page;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
/* Sépare l'écran en 2 a partir de la ligne Y */
|
||||
|
@ -124,6 +124,7 @@ else
|
|||
outb(ccrt + 1, (inb(ccrt + 1) & ~64) | ((addr >> 3) & 64));
|
||||
splitY = y;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
/* Sépare l'écran en 2 a partir de la ligne Y */
|
||||
|
@ -194,7 +195,6 @@ void disablecursor (void)
|
|||
/* Active le scrolling en cas de débordement d'écran */
|
||||
|
||||
void enablescroll(void)
|
||||
|
||||
{
|
||||
scrolling = true;
|
||||
}
|
||||
|
@ -236,8 +236,7 @@ u32 getbase(void)
|
|||
base = inb(graphics + 1);
|
||||
base >>= 2;
|
||||
base &= 3;
|
||||
switch(base)
|
||||
{
|
||||
switch (base) {
|
||||
case 0:
|
||||
case 1:
|
||||
base = 0xA0000;
|
||||
|
@ -258,25 +257,26 @@ u32 getbase(void)
|
|||
|
||||
void (*fill) (u8 attrib);
|
||||
|
||||
|
||||
void fill_text(u8 attrib)
|
||||
{
|
||||
memset((u8 *) (basemem + activepage * pagesize), ' ', pagesize / 2, 2);
|
||||
memset((u8 *)(basemem+activepage*pagesize+1),attrib,pagesize/2,2);
|
||||
memset((u8 *) (basemem + activepage * pagesize + 1), attrib,
|
||||
pagesize / 2, 2);
|
||||
}
|
||||
|
||||
void fill_chain(u8 attrib)
|
||||
{
|
||||
memset((u8 *)(basemem+activepage*pagesize),attrib&0x0F,pagesize,1);
|
||||
memset((u8 *) (basemem + activepage * pagesize), attrib & 0x0F,
|
||||
pagesize, 1);
|
||||
}
|
||||
|
||||
void fill_unchain(u8 attrib)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<4;i++)
|
||||
{
|
||||
for (i = 0; i < 4; i++) {
|
||||
useplane(i);
|
||||
memset((u8 *)(basemem+activepage*pagesize),attrib&0x0F,pagesize,1);
|
||||
memset((u8 *) (basemem + activepage * pagesize), attrib & 0x0F,
|
||||
pagesize, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,34 +305,45 @@ void (*scroll)(u8 lines,u8 attrib);
|
|||
|
||||
void scroll_unchain(u8 lines, u8 attrib)
|
||||
{
|
||||
if (scrolling)
|
||||
{
|
||||
if (scrolling) {
|
||||
u8 i;
|
||||
for(i=0;i<4;i++)
|
||||
{
|
||||
for (i = 0; i < 4; i++) {
|
||||
useplane(i);
|
||||
memcpy((u8*)(basemem+activepage*pagesize+linesize*8*lines),(u8*)basemem,pagesize-linesize*8*lines,1);
|
||||
memset((u8*)(basemem+activepage*pagesize+pagesize-linesize*8*lines),attrib&0x0F,linesize*8*lines,1);
|
||||
memcpy((u8 *) (basemem + activepage * pagesize +
|
||||
linesize * 8 * lines), (u8 *) basemem,
|
||||
pagesize - linesize * 8 * lines, 1);
|
||||
memset((u8 *) (basemem + activepage * pagesize +
|
||||
pagesize - linesize * 8 * lines),
|
||||
attrib & 0x0F, linesize * 8 * lines, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void scroll_chain(u8 lines, u8 attrib)
|
||||
{
|
||||
if (scrolling)
|
||||
{
|
||||
memcpy((u8*)basemem+activepage*pagesize+linesize*8*lines,(u8*)basemem+activepage*pagesize,pagesize-linesize*8*lines,1);
|
||||
memset((u8*)(basemem+activepage*pagesize+pagesize-linesize*8*lines),attrib&0x0F,linesize*8*lines,1);
|
||||
if (scrolling) {
|
||||
memcpy((u8 *) basemem + activepage * pagesize +
|
||||
linesize * 8 * lines,
|
||||
(u8 *) basemem + activepage * pagesize,
|
||||
pagesize - linesize * 8 * lines, 1);
|
||||
memset((u8 *) (basemem + activepage * pagesize + pagesize -
|
||||
linesize * 8 * lines), attrib & 0x0F,
|
||||
linesize * 8 * lines, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void scroll_text(u8 lines, u8 attrib)
|
||||
{
|
||||
if (scrolling)
|
||||
{
|
||||
memcpy((u8*)basemem+activepage*pagesize+linesize*lines,(u8*)basemem+activepage*pagesize,pagesize-linesize*lines,1);
|
||||
memset((u8*)(basemem+activepage*pagesize+pagesize-linesize*lines-2),' ',(linesize*lines)/2,2);
|
||||
memset((u8*)(basemem+activepage*pagesize+pagesize-linesize*lines-1),attrib,(linesize*lines)/2,2);
|
||||
if (scrolling) {
|
||||
memcpy((u8 *) basemem + activepage * pagesize +
|
||||
linesize * lines, (u8 *) basemem + activepage * pagesize,
|
||||
pagesize - linesize * lines, 1);
|
||||
memset((u8 *) (basemem + activepage * pagesize + pagesize -
|
||||
linesize * lines - 2), ' ',
|
||||
(linesize * lines) / 2, 2);
|
||||
memset((u8 *) (basemem + activepage * pagesize + pagesize -
|
||||
linesize * lines - 1), attrib,
|
||||
(linesize * lines) / 2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -345,27 +356,26 @@ void (*showchar)(u16 coordx,u16 coordy,u8 thechar,u8 attrib);
|
|||
void showchar_graphic(u16 coordx, u16 coordy, u8 thechar, u8 attrib)
|
||||
{
|
||||
u8 x, y, pattern, set;
|
||||
for(y=0;y<8;y++)
|
||||
{
|
||||
for (y = 0; y < 8; y++) {
|
||||
pattern = font8x8[thechar * 8 + y];
|
||||
for(x=0;x<8;x++)
|
||||
{
|
||||
for (x = 0; x < 8; x++) {
|
||||
set = ((pattern >> (7 - x)) & 0x1); /* mettre un ROL importé depuis asm */
|
||||
if (set == 0)
|
||||
writepxl(coordx*8+x,coordy*8+y,((attrib&0xF0)>>8)*set);
|
||||
writepxl(coordx * 8 + x, coordy * 8 + y,
|
||||
((attrib & 0xF0) >> 8) * set);
|
||||
else
|
||||
writepxl(coordx*8+x,coordy*8+y,(attrib&0x0F)*set);
|
||||
writepxl(coordx * 8 + x, coordy * 8 + y,
|
||||
(attrib & 0x0F) * set);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void showchar_text(u16 coordx, u16 coordy, u8 thechar, u8 attrib)
|
||||
|
||||
{
|
||||
u8 *screen;
|
||||
screen = (u8 *)basemem+activepage*pagesize+2*(coordx+coordy*resX);
|
||||
screen =
|
||||
(u8 *) basemem + activepage * pagesize + 2 * (coordx +
|
||||
coordy * resX);
|
||||
*screen = thechar;
|
||||
*(++screen) = attrib;
|
||||
}
|
||||
|
@ -377,10 +387,11 @@ void showchar_text(u16 coordx,u16 coordy,u8 thechar,u8 attrib)
|
|||
u8(*getchar) (u16 coordx, u16 coordy);
|
||||
|
||||
u8 getchar_text(u16 coordx, u16 coordy)
|
||||
|
||||
{
|
||||
u8 *screen;
|
||||
screen = (u8 *)basemem+activepage*pagesize+2*(coordx+coordy*resX);
|
||||
screen =
|
||||
(u8 *) basemem + activepage * pagesize + 2 * (coordx +
|
||||
coordy * resX);
|
||||
return *screen;
|
||||
}
|
||||
|
||||
|
@ -391,14 +402,14 @@ u8 getchar_text(u16 coordx,u16 coordy)
|
|||
u8(*getattrib) (u16 coordx, u16 coordy);
|
||||
|
||||
u8 getattrib_text(u16 coordx, u16 coordy)
|
||||
|
||||
{
|
||||
u8 *screen;
|
||||
screen = (u8 *)basemem+activepage*pagesize+2*(coordx+coordy*resX)+1;
|
||||
screen =
|
||||
(u8 *) basemem + activepage * pagesize + 2 * (coordx +
|
||||
coordy * resX) + 1;
|
||||
return *screen;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
/* Ecrit un pixel a l'écran */
|
||||
|
@ -435,8 +446,7 @@ void writepxl_4bits(u16 x, u16 y, u32 c)
|
|||
x = (x & 7) * 1;
|
||||
mask = 0x80 >> x;
|
||||
pmask = 1;
|
||||
for(p = 0; p < 4; p++)
|
||||
{
|
||||
for (p = 0; p < 4; p++) {
|
||||
useplane(p);
|
||||
if (pmask & c)
|
||||
*off = ((*off) | mask);
|
||||
|
@ -472,16 +482,15 @@ u32 setvmode(u8 mode)
|
|||
graphique : >0x80
|
||||
text : 0x00 - 0x7F
|
||||
*/
|
||||
if (mode>=0x80)
|
||||
{
|
||||
if (mode >= 0x80) {
|
||||
gmode = mode - 0x80;
|
||||
if (gmode>maxgraphmode) return 1; /* mode inexistant */
|
||||
if (gmode > maxgraphmode)
|
||||
return 1; /* mode inexistant */
|
||||
def = graphmodes[gmode];
|
||||
graphic = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mode>maxtextmode) return 1; /* mode inexistant */
|
||||
} else {
|
||||
if (mode > maxtextmode)
|
||||
return 1; /* mode inexistant */
|
||||
def = textmodes[mode];
|
||||
graphic = false;
|
||||
loadfont(font8x8, 8, 1);
|
||||
|
@ -512,8 +521,7 @@ profondeur (en bits) */
|
|||
color = def[63];
|
||||
/* Initialise l'adresse des procedures de gestion graphique et les differentes
|
||||
variables en fonction de la profondeur et du mode */
|
||||
if (!graphic)
|
||||
{
|
||||
if (!graphic) {
|
||||
/* mode texte */
|
||||
linesize = resX * 2;
|
||||
writepxl = NULL; /* pas d'affichage de pixels */
|
||||
|
@ -523,11 +531,8 @@ variables en fonction de la profondeur et du mode*/
|
|||
pagesize = resY * linesize;
|
||||
getchar = getchar_text;
|
||||
getattrib = getattrib_text;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(color)
|
||||
{
|
||||
} else {
|
||||
switch (color) {
|
||||
case 1:
|
||||
/* mode N&B */
|
||||
linesize = resX;
|
||||
|
@ -551,16 +556,13 @@ variables en fonction de la profondeur et du mode*/
|
|||
break;
|
||||
case 8:
|
||||
/* mode 256 couleurs */
|
||||
if (def[5]==0x0E)
|
||||
{
|
||||
if (def[5] == 0x0E) {
|
||||
/* mode chainé (plus rapide mais limité en mémoire) */
|
||||
linesize = (resX << 3);
|
||||
writepxl = writepxl_8bits;
|
||||
scroll = scroll_chain;
|
||||
fill = fill_chain;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* mode non chainé */
|
||||
linesize = (resX << 1);
|
||||
writepxl = writepxl_8bitsunchain;
|
||||
|
@ -599,13 +601,14 @@ u8 getvmode(void)
|
|||
/* Charge une nouvelle police de caractère */
|
||||
|
||||
u32 loadfont(u8 * def, u8 size, u8 font)
|
||||
|
||||
{
|
||||
if (graphics==1) return 1;
|
||||
if (graphics == 1)
|
||||
return 1;
|
||||
u8 oldregs[5] = { 0, 0, 0, 0, 0 };
|
||||
u8 *base;
|
||||
u16 i;
|
||||
if (font>7) return 1;
|
||||
if (font > 7)
|
||||
return 1;
|
||||
if (font < 4)
|
||||
base = (u8 *) (getbase() + (font << 14));
|
||||
else
|
||||
|
@ -629,8 +632,7 @@ u32 loadfont(u8* def,u8 size,u8 font)
|
|||
outb(graphics + 1, oldregs[4] & ~0x02);
|
||||
/* utilisation du plan N°2 */
|
||||
useplane(2);
|
||||
for(i=0; i < 256; i++)
|
||||
{
|
||||
for (i = 0; i < 256; i++) {
|
||||
memcpy(def, base + i * 32, size, 1);
|
||||
def += size;
|
||||
}
|
||||
|
@ -673,7 +675,6 @@ u8 getfont2()
|
|||
return num;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
/* Fixe le N° de la police de caractère a utiliser */
|
||||
|
@ -682,7 +683,9 @@ void setfont(u8 num)
|
|||
{
|
||||
num &= 0x07;
|
||||
outb(sequencer, 3);
|
||||
outb(sequencer+1,(inb(sequencer+1)&0xEC)|((num&0x03)+((num&0x04)<<2)));
|
||||
outb(sequencer + 1,
|
||||
(inb(sequencer + 1) & 0xEC) | ((num & 0x03) +
|
||||
((num & 0x04) << 2)));
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
@ -693,12 +696,14 @@ void setfont2(u8 num)
|
|||
{
|
||||
num &= 0x07;
|
||||
outb(sequencer, 3);
|
||||
outb(sequencer+1,(inb(sequencer+1)&0xD3)|(((num&0x03)<<2)+((num&0x04)<<3)));
|
||||
outb(sequencer + 1,
|
||||
(inb(sequencer + 1) & 0xD3) | (((num & 0x03) << 2) +
|
||||
((num & 0x04) << 3)));
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
/* Fixe le N° de la police de caractère a utiliser */
|
||||
/* Autorise le clignotement */
|
||||
|
||||
void enableblink()
|
||||
{
|
||||
|
@ -708,7 +713,7 @@ void enableblink()
|
|||
|
||||
/*******************************************************************************/
|
||||
|
||||
/* Fixe le N° de la police de caractère a utiliser */
|
||||
/* Annule le clignotement */
|
||||
|
||||
void disableblink()
|
||||
{
|
||||
|
@ -718,3 +723,60 @@ void disableblink()
|
|||
|
||||
/*******************************************************************************/
|
||||
|
||||
/* Envoie une série d'octet a destination d'une portion de mémoire
|
||||
vers le registre spécifié */
|
||||
|
||||
void outreg(u16 port, u8 * src, u16 num)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num; i++) {
|
||||
outb(port, i);
|
||||
outb(port + 1, *src++);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
/* Envoie une série d'octet a destination d'une portion de mémoire
|
||||
vers le registre spécifié (accés data et index confondu) */
|
||||
|
||||
void outregsame(u16 port, u8 * src, u16 num)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num; i++) {
|
||||
inb(port);
|
||||
outb(port, i);
|
||||
outb(port, *src++);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
/* Récupère une série d'octet en provenance d'un registre spécifié
|
||||
vers portion de mémoire */
|
||||
|
||||
void inreg(u16 port, u8 * src, u16 num)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num; i++) {
|
||||
outb(port, i);
|
||||
*src++ = inb(port + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
/* Récupère une série d'octet en provenance d'un registre spécifié
|
||||
vers portion de mémoire (accés data et index confondu) */
|
||||
|
||||
void inregsame(u16 port, u8 * src, u16 num)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num; i++) {
|
||||
inb(port);
|
||||
outb(port, i);
|
||||
*src++ = inb(port);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
|
179
lib/video.c
179
lib/video.c
|
@ -2,28 +2,33 @@
|
|||
#include "video.h"
|
||||
#include "stdarg.h"
|
||||
|
||||
|
||||
console vc[8] = {
|
||||
{0x07,0,0,0,0,0,0,0},
|
||||
{0x07,0,0,0,0,0,0,0},
|
||||
{0x07,0,0,0,0,0,0,0},
|
||||
{0x07,0,0,0,0,0,0,0},
|
||||
{0x07,0,0,0,0,0,0,0},
|
||||
{0x07,0,0,0,0,0,0,0},
|
||||
{0x07,0,0,0,0,0,0,0},
|
||||
{0x07,0,0,0,0,0,0,0}};
|
||||
{0x07, 0, 0, 0, 0, 0, 0, 0}
|
||||
,
|
||||
{0x07, 0, 0, 0, 0, 0, 0, 0}
|
||||
,
|
||||
{0x07, 0, 0, 0, 0, 0, 0, 0}
|
||||
,
|
||||
{0x07, 0, 0, 0, 0, 0, 0, 0}
|
||||
,
|
||||
{0x07, 0, 0, 0, 0, 0, 0, 0}
|
||||
,
|
||||
{0x07, 0, 0, 0, 0, 0, 0, 0}
|
||||
,
|
||||
{0x07, 0, 0, 0, 0, 0, 0, 0}
|
||||
,
|
||||
{0x07, 0, 0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
u8 usedvc = 0;
|
||||
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
/* Fixe l'attribut courant */
|
||||
|
||||
void setattrib(u8 att)
|
||||
{
|
||||
static const u8 ansitovga[] =
|
||||
{
|
||||
static const u8 ansitovga[] = {
|
||||
0, 4, 2, 6, 1, 5, 3, 7
|
||||
};
|
||||
u8 tempattr;
|
||||
|
@ -39,13 +44,10 @@ void setattrib(u8 att)
|
|||
tempattr = 0;
|
||||
else if (att == 1)
|
||||
tempattr |= 0x08; /* Forte intensité */
|
||||
else if(att >= 30 && att <= 37)
|
||||
{
|
||||
else if (att >= 30 && att <= 37) {
|
||||
att = ansitovga[att - 30];
|
||||
tempattr = (tempattr & ~0x07) | att; /* couleur de premier plan */
|
||||
}
|
||||
else if(att >= 40 && att <= 47)
|
||||
{
|
||||
} else if (att >= 40 && att <= 47) {
|
||||
att = ansitovga[att - 40] << 4;
|
||||
tempattr = (tempattr & ~0x70) | att; /* couleur de fond */
|
||||
}
|
||||
|
@ -59,20 +61,17 @@ void setattrib(u8 att)
|
|||
bool makeansi(u8 c)
|
||||
{
|
||||
/* state machine to handle the escape sequences */
|
||||
switch(vc[usedvc].ansi)
|
||||
{
|
||||
switch (vc[usedvc].ansi) {
|
||||
case 0:
|
||||
/* ESC -- next state */
|
||||
if(c == 0x1B)
|
||||
{
|
||||
if (c == 0x1B) {
|
||||
vc[usedvc].ansi++;
|
||||
return 1; /* "I handled it" */
|
||||
}
|
||||
break;
|
||||
/* ESC */
|
||||
case 1:
|
||||
if(c == '[')
|
||||
{
|
||||
if (c == '[') {
|
||||
vc[usedvc].ansi++;
|
||||
vc[usedvc].param1 = 0;
|
||||
return 1;
|
||||
|
@ -80,22 +79,17 @@ bool makeansi(u8 c)
|
|||
break;
|
||||
/* ESC[ */
|
||||
case 2:
|
||||
if(isdigit(c))
|
||||
{
|
||||
if (isdigit(c)) {
|
||||
vc[usedvc].param1 = vc[usedvc].param1 * 10 + c - '0';
|
||||
return 1;
|
||||
}
|
||||
else if(c == ';')
|
||||
{
|
||||
} else if (c == ';') {
|
||||
vc[usedvc].ansi++;
|
||||
vc[usedvc].param2 = 0;
|
||||
return 1;
|
||||
}
|
||||
/* ESC[2J -- efface l'ecran */
|
||||
else if(c == 'J')
|
||||
{
|
||||
if(vc[usedvc].param1 == 2)
|
||||
{
|
||||
else if (c == 'J') {
|
||||
if (vc[usedvc].param1 == 2) {
|
||||
fill(vc[usedvc].attrib);
|
||||
vc[usedvc].cursX = 0;
|
||||
vc[usedvc].cursY = 0;
|
||||
|
@ -105,44 +99,43 @@ bool makeansi(u8 c)
|
|||
}
|
||||
}
|
||||
/* ESC[num1m -- met l'attribut num1 */
|
||||
else if(c == 'm')
|
||||
{
|
||||
else if (c == 'm') {
|
||||
setattrib(vc[usedvc].param1);
|
||||
vc[usedvc].ansi = 0;
|
||||
return 1;
|
||||
}
|
||||
/* ESC[num1A -- bouge le curseur de num1 vers le haut */
|
||||
else if(c == 'A')
|
||||
{
|
||||
else if (c == 'A') {
|
||||
vc[usedvc].cursY -= vc[usedvc].param1;
|
||||
if (vc[usedvc].cursY<0) vc[usedvc].cursY=0;
|
||||
if (vc[usedvc].cursY < 0)
|
||||
vc[usedvc].cursY = 0;
|
||||
vc[usedvc].ansi = 0;
|
||||
gotoscr(vc[usedvc].cursX, vc[usedvc].cursY);
|
||||
return 1;
|
||||
}
|
||||
/* ESC[num1B -- bouge le curseur de num1 vers le bas */
|
||||
else if(c == 'B')
|
||||
{
|
||||
else if (c == 'B') {
|
||||
vc[usedvc].cursY += vc[usedvc].param1;
|
||||
if (vc[usedvc].cursY>=getyres()-1) vc[usedvc].cursY=getyres();
|
||||
if (vc[usedvc].cursY >= getyres() - 1)
|
||||
vc[usedvc].cursY = getyres();
|
||||
vc[usedvc].ansi = 0;
|
||||
gotoscr(vc[usedvc].cursX, vc[usedvc].cursY);
|
||||
return 1;
|
||||
}
|
||||
/* ESC[num1D -- bouge le curseur de num1 vers la gauche */
|
||||
else if(c == 'D')
|
||||
{
|
||||
else if (c == 'D') {
|
||||
vc[usedvc].cursX -= vc[usedvc].param1;
|
||||
if (vc[usedvc].cursX<0) vc[usedvc].cursX=0;
|
||||
if (vc[usedvc].cursX < 0)
|
||||
vc[usedvc].cursX = 0;
|
||||
vc[usedvc].ansi = 0;
|
||||
gotoscr(vc[usedvc].cursX, vc[usedvc].cursY);
|
||||
return 1;
|
||||
}
|
||||
/* ESC[num1C -- bouge le curseur de num1 vers la droite */
|
||||
else if(c == 'C')
|
||||
{
|
||||
else if (c == 'C') {
|
||||
vc[usedvc].cursX += vc[usedvc].param1;
|
||||
if (vc[usedvc].cursX>=getxres()-1) vc[usedvc].cursX=getxres();
|
||||
if (vc[usedvc].cursX >= getxres() - 1)
|
||||
vc[usedvc].cursX = getxres();
|
||||
vc[usedvc].ansi = 0;
|
||||
gotoscr(vc[usedvc].cursX, vc[usedvc].cursY);
|
||||
return 1;
|
||||
|
@ -150,20 +143,16 @@ bool makeansi(u8 c)
|
|||
break;
|
||||
/* ESC[num1; */
|
||||
case 3:
|
||||
if(isdigit(c))
|
||||
{
|
||||
if (isdigit(c)) {
|
||||
vc[usedvc].param2 = vc[usedvc].param2 * 10 + c - '0';
|
||||
return 1;
|
||||
}
|
||||
else if(c == ';')
|
||||
{
|
||||
} else if (c == ';') {
|
||||
vc[usedvc].ansi++;
|
||||
vc[usedvc].param3 = 0;
|
||||
return 1;
|
||||
}
|
||||
/* ESC[num1;num2H ou ESC[num1;num2f-- bouge le curseur en num1,num2 */
|
||||
else if((c == 'H')||(c == 'f'))
|
||||
{
|
||||
else if ((c == 'H') || (c == 'f')) {
|
||||
/* Remet la position du curseur matériel a num1,num2 */
|
||||
gotoscr(vc[usedvc].param2, vc[usedvc].param1);
|
||||
/* Remet la position du curseur logiciel a num1,num2 */
|
||||
|
@ -173,8 +162,7 @@ bool makeansi(u8 c)
|
|||
return 1;
|
||||
}
|
||||
/* ESC[num1;num2m -- met les attributs num1,num2 */
|
||||
else if(c == 'm')
|
||||
{
|
||||
else if (c == 'm') {
|
||||
setattrib(vc[usedvc].param1);
|
||||
setattrib(vc[usedvc].param2);
|
||||
vc[usedvc].ansi = 0;
|
||||
|
@ -183,14 +171,12 @@ bool makeansi(u8 c)
|
|||
break;
|
||||
/* ESC[num1;num2;num3 */
|
||||
case 4:
|
||||
if(isdigit(c))
|
||||
{
|
||||
if (isdigit(c)) {
|
||||
vc[usedvc].param3 = vc[usedvc].param3 * 10 + c - '0';
|
||||
return 1;
|
||||
}
|
||||
/* ESC[num1;num2;num3m -- met les attributs num1,num2,num3 */
|
||||
else if(c == 'm')
|
||||
{
|
||||
else if (c == 'm') {
|
||||
setattrib(vc[usedvc].param1);
|
||||
setattrib(vc[usedvc].param2);
|
||||
setattrib(vc[usedvc].param3);
|
||||
|
@ -227,20 +213,24 @@ void putchar(u8 thechar)
|
|||
{
|
||||
showpage(usedvc);
|
||||
setpage(usedvc);
|
||||
if(makeansi(thechar)) return;
|
||||
switch (thechar)
|
||||
{
|
||||
if (makeansi(thechar))
|
||||
return;
|
||||
switch (thechar) {
|
||||
case 0x11:
|
||||
if (vc[usedvc].cursY>0) vc[usedvc].cursY--;
|
||||
if (vc[usedvc].cursY > 0)
|
||||
vc[usedvc].cursY--;
|
||||
break;
|
||||
case 0x12:
|
||||
if (vc[usedvc].cursY<getyres()-1) vc[usedvc].cursY++;
|
||||
if (vc[usedvc].cursY < getyres() - 1)
|
||||
vc[usedvc].cursY++;
|
||||
break;
|
||||
case 0x13:
|
||||
if (vc[usedvc].cursX>0) vc[usedvc].cursX--;
|
||||
if (vc[usedvc].cursX > 0)
|
||||
vc[usedvc].cursX--;
|
||||
break;
|
||||
case 0x14:
|
||||
if (vc[usedvc].cursX<getxres()-1) vc[usedvc].cursX++;
|
||||
if (vc[usedvc].cursX < getxres() - 1)
|
||||
vc[usedvc].cursX++;
|
||||
break;
|
||||
case 0x2:
|
||||
vc[usedvc].cursX = 0;
|
||||
|
@ -254,19 +244,16 @@ case 0x19:
|
|||
vc[usedvc].cursX = getxres() - 1;
|
||||
break;
|
||||
case '\b':
|
||||
if (vc[usedvc].cursX==0)
|
||||
{
|
||||
if (vc[usedvc].cursY>0)
|
||||
{
|
||||
if (vc[usedvc].cursX == 0) {
|
||||
if (vc[usedvc].cursY > 0) {
|
||||
vc[usedvc].cursX = getxres() - 1;
|
||||
vc[usedvc].cursY--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
vc[usedvc].cursX--;
|
||||
}
|
||||
showchar(vc[usedvc].cursX,vc[usedvc].cursY,' ',vc[usedvc].attrib);
|
||||
showchar(vc[usedvc].cursX, vc[usedvc].cursY, ' ',
|
||||
vc[usedvc].attrib);
|
||||
break;
|
||||
case '\t':
|
||||
vc[usedvc].cursX = (vc[usedvc].cursX + 8) & ~(8 - 1);
|
||||
|
@ -279,20 +266,18 @@ vc[usedvc].cursX=0;
|
|||
vc[usedvc].cursY++;
|
||||
break;
|
||||
default:
|
||||
if (thechar>=' ')
|
||||
{
|
||||
showchar(vc[usedvc].cursX,vc[usedvc].cursY,thechar,vc[usedvc].attrib);
|
||||
if (thechar >= ' ') {
|
||||
showchar(vc[usedvc].cursX, vc[usedvc].cursY, thechar,
|
||||
vc[usedvc].attrib);
|
||||
vc[usedvc].cursX++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (vc[usedvc].cursX>=getxres())
|
||||
{
|
||||
if (vc[usedvc].cursX >= getxres()) {
|
||||
vc[usedvc].cursX = 0;
|
||||
vc[usedvc].cursY++;
|
||||
}
|
||||
if (vc[usedvc].cursY>=getyres())
|
||||
{
|
||||
if (vc[usedvc].cursY >= getyres()) {
|
||||
scroll(1, vc[usedvc].attrib);
|
||||
vc[usedvc].cursY = getyres() - 1;
|
||||
}
|
||||
|
@ -307,8 +292,7 @@ void print(u8* string)
|
|||
{
|
||||
u8 *source;
|
||||
source = string;
|
||||
while(*source!=0)
|
||||
{
|
||||
while (*source != 0) {
|
||||
putchar(*source++);
|
||||
}
|
||||
}
|
||||
|
@ -327,16 +311,12 @@ void printf (const u8 *string, ...)
|
|||
bool signe;
|
||||
long num;
|
||||
|
||||
|
||||
va_start(ap, string);
|
||||
while(*string!= 0)
|
||||
{
|
||||
while (*string != 0) {
|
||||
if (*string != '%')
|
||||
putchar(*string);
|
||||
else
|
||||
{
|
||||
switch (*++string)
|
||||
{
|
||||
else {
|
||||
switch (*++string) {
|
||||
case 'c':
|
||||
putchar(va_arg(ap, int));
|
||||
break;
|
||||
|
@ -347,13 +327,11 @@ showstring:
|
|||
num = va_arg(ap, int);
|
||||
pointer = buffer + 50 - 1;
|
||||
*pointer = '\0';
|
||||
if ((signe==1)&&(num<0))
|
||||
{
|
||||
if ((signe == 1) && (num < 0)) {
|
||||
num = -num;
|
||||
signe++;
|
||||
}
|
||||
do
|
||||
{
|
||||
do {
|
||||
unsigned long temp;
|
||||
temp = (unsigned long)num % radix;
|
||||
pointer--;
|
||||
|
@ -364,8 +342,10 @@ showstring:
|
|||
num = (unsigned long)num / radix;
|
||||
}
|
||||
while (num != 0);
|
||||
if (signe>1) *(--pointer)='-';
|
||||
while (*pointer!=0) putchar(*pointer++);
|
||||
if (signe > 1)
|
||||
*(--pointer) = '-';
|
||||
while (*pointer != 0)
|
||||
putchar(*pointer++);
|
||||
break;
|
||||
case 'o':
|
||||
radix = 8;
|
||||
|
@ -382,8 +362,10 @@ showstring:
|
|||
goto showstring;
|
||||
case 's':
|
||||
pointer = va_arg(ap, u8 *);
|
||||
if (!pointer) pointer="(null)";
|
||||
while (*pointer!=0) putchar(*pointer++);
|
||||
if (!pointer)
|
||||
pointer = "(null)";
|
||||
while (*pointer != 0)
|
||||
putchar(*pointer++);
|
||||
break;
|
||||
case '%':
|
||||
putchar('%');
|
||||
|
@ -399,4 +381,3 @@ showstring:
|
|||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
FINALCC=gcc -O4 -nostdinc -ffreestanding -fno-builtin -fomit-frame-pointer -Wall -w -I ../include -m32 -c -o
|
||||
GCC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -fomit-frame-pointer -Wall -w -I ../include -m32 -c -o
|
||||
|
||||
LINK=ld -m elf_i386 -T linker.lds -e main -o
|
||||
|
@ -7,9 +6,8 @@ all: system.sys
|
|||
sync
|
||||
|
||||
system.sys:
|
||||
nasm -f elf -o system.o system.asm
|
||||
$(GCC) systemc.o system.c
|
||||
$(LINK) system.sys systemc.o system.o ../lib/libs.o
|
||||
$(GCC) system.o system.c
|
||||
$(LINK) system.sys system.o ../lib/libs.o
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[BITS 32]
|
||||
|
||||
|
||||
SECTION .text
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#include "vga.h"
|
||||
#include "video.h"
|
||||
#include "idt.h"
|
||||
#include "interrupts.h"
|
||||
#include "timer.h"
|
||||
#include "keyboard.h"
|
||||
#include "mouse.h"
|
||||
|
@ -12,7 +12,12 @@
|
|||
|
||||
static cpuinfo cpu;
|
||||
static u8 noproc[] = "\033[31mInconnu\033[0m\000";
|
||||
static u8 okmsg[]="\033[99C\033[8D\033[37m\033[1m[ \033[32mOK\033[37m ]\033[0m\000";
|
||||
static u8 warnmsg[] =
|
||||
"\033[99C\033[8D\033[37m\033[1m[ \033[36mNON\033[37m ]\033[0m\000";
|
||||
static u8 okmsg[] =
|
||||
"\033[99C\033[8D\033[37m\033[1m[ \033[32mOK\033[37m ]\033[0m\000";
|
||||
static u8 errormsg[] =
|
||||
"\033[99C\033[8D\033[37m\033[1m[\033[31mERREUR\033[37m]\033[0m\000";
|
||||
static u8 key = 0;
|
||||
|
||||
void ok()
|
||||
|
@ -21,70 +26,63 @@ void ok()
|
|||
return;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
void warning()
|
||||
{
|
||||
print(warnmsg);
|
||||
return;
|
||||
}
|
||||
|
||||
void error()
|
||||
{
|
||||
print(errormsg);
|
||||
return;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
cli();
|
||||
setvmode(0x02);
|
||||
/* Efface l'ecran */
|
||||
print("\033[2J\000");
|
||||
printf(ansilogo);
|
||||
print("\033[0mNoyau charge en memoire\000");
|
||||
ok();
|
||||
|
||||
print("Initilisation de la table d'interruption\000");
|
||||
print("\033[37m\033[0m -Initilisation des interruptions\000");
|
||||
initidt();
|
||||
ok();
|
||||
|
||||
print("Initialisation du controleur d'interruption\000");
|
||||
initpic();
|
||||
sti();
|
||||
ok();
|
||||
|
||||
print("Installation du handler timer\000");
|
||||
print(" -Installation du handler timer (IRQ 0)\000");
|
||||
setidt((u32) timer, 0x20, INTGATE, 32);
|
||||
ok();
|
||||
|
||||
print("Activation de l'IRQ 0\000");
|
||||
enableirq(0);
|
||||
ok();
|
||||
|
||||
print("Installation du handler clavier\000");
|
||||
print(" -Installation du handler clavier (IRQ 1)\000");
|
||||
setidt((u32) keyboard, 0x20, INTGATE, 33);
|
||||
ok();
|
||||
|
||||
print("Activation de l'IRQ 1\000");
|
||||
enableirq(1);
|
||||
ok();
|
||||
|
||||
print("Installation du handler souris\000");
|
||||
print(" -Installation du handler souris (IRQ12+Cascade IRQ2)\000");
|
||||
setidt((u32) mouse, 0x20, INTGATE, 100);
|
||||
ok();
|
||||
|
||||
print("Initialisation du controleur souris :\000");
|
||||
if (initmouse()==1)
|
||||
print(" \033[1m\033[32mSouris Presente\033[0m\000");
|
||||
else
|
||||
print(" \033[1m\033[31mSouris non detecte\033[0m\000");
|
||||
ok();
|
||||
|
||||
print("Activation de l'IRQ 2 (Controleur esclave)\000");
|
||||
enableirq(2);
|
||||
ok();
|
||||
|
||||
print("Activation de l'IRQ 12\000");
|
||||
enableirq(12);
|
||||
if (initmouse() != 1)
|
||||
warning();
|
||||
else
|
||||
ok();
|
||||
|
||||
strcpy(&noproc, &cpu.detectedname);
|
||||
getcpuinfos(&cpu);
|
||||
|
||||
printf("Processeur detecte\r Revision \t:%d\r Modele \t:%d\r Famille \t:%d\r Nom cpuid\t:%s\rJeux\t:%s\000",cpu.stepping,cpu.models,cpu.family,&cpu.detectedname,&cpu.techs);
|
||||
printf
|
||||
(" -Detection du processeur\r\033[1m Revision \t:%d\r Modele \t:%d\r Famille \t:%d\r Nom cpuid\t:%s\rJeux d'instruction\t:%s\033[0m\000",
|
||||
cpu.stepping, cpu.models, cpu.family, &cpu.detectedname,
|
||||
&cpu.techs);
|
||||
ok();
|
||||
while(1)
|
||||
{
|
||||
while (1) {
|
||||
key = waitascii();
|
||||
putchar(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue