refactor: ajout d'information dans les fichiers MD, réindentation des fichiers, corrections de bogues

This commit is contained in:
Nicolas Hordé 2018-12-12 15:25:04 +01:00
parent 89ac2cc30f
commit 3c7ddafc2d
63 changed files with 48800 additions and 28101 deletions

23
API.md
View File

@ -1,15 +1,20 @@
## Liste des API ## API List
Bibliothèques disponibles dans COS2000 APIs given by COS2000 libraries
### libc ### LIBC
Fonctions disponibles dans la librairie "libc" All fonction in the "libc" library.
#### test_api ------
u32 test_api(void); `u32 test_api(void);`
syscall id : 0 *Description: function to test if the syscall mecanism is running.*
arguments : 0
résultat : oui (0x66666666) * syscall id : **0**
* arguments : **0**
* * argument 1 : **u32 none** *Afin de documenter un argument*
* results : **yes (always 0x66666666)**
------

28
BUGS.md Normal file
View File

@ -0,0 +1,28 @@
## Liste de BUGS à corriger
### VIDEO
* Interpolation des droites lorsques les coordonnées sortent de l'écran : erreur les coefficient directeur sont faux.
* Les modes VGA ne fonctionnent pas tous.
* Ralentissement lors du défilemment de la console en VESA.
### MEMOIRE
La commande mem plante parfois ?!
### 3D
La 3D utiliser sauvagement la mémoire sans malloc !!
### 2D
Le remplissage des triangles n'est pas parfais, 2 algo différents entre lignes et remplissage.
### SHELL
* La fonction regs est à reprendre...
* La fonction IDT est à adapter à la taille de l'écran

168
README.md
View File

@ -23,9 +23,9 @@ Sans système d'exploitation votre ordinateur est inopérant: c'est une boite vi
#### Comment utiliser COS2000 ? #### Comment utiliser COS2000 ?
COS2000 n'a pas pour but d'être utilisé en exploitation, c'est un système en cours de COS2000 n'a pas pour but d'être utilisé en production. Il s'agit d'un système en cours de
développement. Vous pouvez néanmoins l'utiliser sur un ordinateur physique ou une machine virtuelle développement que vous pouvez néanmoins tester sur un ordinateur physique ou de préférence sur une machine virtuelle.
afin de voir le fonctionnement d'un système d'exploitation rudimentatire. Voir compilation de COS2000... Il est nécessaire de compiler le système avant de démarrer celui-ci à partir d'un périphérique amovible (clé usb).
#### Sur quel ordinateur fonctionne t'il ? #### Sur quel ordinateur fonctionne t'il ?
@ -41,6 +41,10 @@ COS2000 est sous licence LGPL v3.0, en simplifiant un peu :
* REUTILISER - OUI en citant l'auteur * REUTILISER - OUI en citant l'auteur
* VENDRE - NON * VENDRE - NON
Les détails se trouvent dans le fichier `LICENSE.md`
![logo](https://www.gnu.org/graphics/lgplv3-with-text-154x68.png)
### Compilation de COS2000 ### Compilation de COS2000
#### Avant la compilation #### Avant la compilation
@ -57,23 +61,34 @@ Les numéros de version des logiciels sont données à titre indicatif car il es
Compilation: Compilation:
* NASM version 2.11.08 Nom | Paquet | Version
* gcc version 5.4.0 20160609 --- | --- | ---
* GNU Make version 4.1 NASM | nasm | 2.11.08
* binutils version 2.26-8 gcc | gcc | 5.4.0 20160609
GNU Make | make | 4.1
Outils divers | binutils | 2.26-8
Images disques, débogage & émulation: Images disques, débogage & émulation:
* fuse-umfuse-ext2 version 0.4 29 Nom | Paquet | Version
* fusefat version 0.1a-1.1 --- | --- | ---
* CGDB: a curses debugger version 0.6.7 fuse-umfuse-ext2 | fuseext2 | 0.4 29
* QEMU emulator version 2.5.0 fusefat | fusefat | 0.1a-1.1
* OVMF version 0~20160408.ffea0a2c-2 CGDB: a curses debugger | cgdb | 0.6.7
* hexdump (bsdmainutils version 9.0.6) QEMU emulator | qemu | 2.5.0
* dd (coreutils version 8.25-2) OVMF | ovmf | 0~20160408.ffea0a2c-2
* tar version 1.28-2.1 hexdump | bsdmainutils | 9.0.6
* GNU indent version 2.2.11 dd | coreutils | 8.25-2
* Bochs (optionnel) tar | tar | 1.28-2.1
Bochs | bochs | 2.6
Suivi et développement:
Nom | Paquet | Version
--- | --- | ---
GNU indent | indent | 2.2.11
GIT | git | 2.7.4
Dos2unix | dos2unix| 6.0.4
##### Téléchargement de COS2000 ##### Téléchargement de COS2000
@ -81,107 +96,112 @@ Afin de faciliter la mise à jour et le suivi des version de COS2000, GIT est ut
Si vous n'avez pas GIT, installez le avec la commande suivante : Si vous n'avez pas GIT, installez le avec la commande suivante :
```sudo apt-get install git``` `sudo apt-get install git`
Puis cloner le source chez vous avec la commande : Puis cloner le source chez vous avec la commande :
```git clone https://github.com/dahut87/cos2000.git``` `git clone https://github.com/dahut87/cos2000.git`
##### Installation des paquets nécessaires ##### Installation des paquets nécessaires
Sous linux - Debian & Ubuntu like Sous linux - Debian & Ubuntu like
```sudo apt-get install nasm gcc qemu fusefat fuseext2 cgdb ovmf bsdmainutils tar bsdmainutils indent binutils``` `sudo apt-get install nasm gcc qemu fusefat fuseext2 cgdb ovmf bsdmainutils tar bsdmainutils indent binutils`
ou sinon, depuis un terminal disposé sur le répertoire cos2000 ou sinon, depuis un terminal disposé sur le répertoire cos2000
```make install``` `make install`
#### Compilation #### Compilation
Commande de compilation de base Commande de compilation de base
* ```make all``` compile tout le projet dans sa version disque dur et disque dur en UEFI * `make all` compile tout le projet dans sa version disque dur et disque dur en UEFI
Autres commandes de compilation de COS2000 Autres commandes de compilation de COS2000
* ```make harddisk``` compile la version disque dur * `make harddisk` compile la version disque dur
* ```make uefi``` compile la version disque dur UEFI * `make uefi` compile la version disque dur UEFI
* ```make bochstest``` lance l'émulation BOCHS en 32 bits sur disque dur * `make bochstest` lance l'émulation BOCHS en 32 bits sur disque dur
* ```make test``` lance l'émulation QEMU en 32 bits sur disque dur * `make test` lance l'émulation QEMU en 32 bits sur disque dur
* ```make test64``` lance l'émulation QEMU en 64 bits sur disque dur en UEFI * `make test64` lance l'émulation QEMU en 64 bits sur disque dur en UEFI
* ```make clean``` supprime les fichers compilés * `make clean` supprime les fichers compilés
* ```VESA=no make test``` préfixe à utiliser (VESA=no) pour faire appel au pilote VGA et non pas VESA * `VESA=no make test` préfixe à utiliser (VESA=no) pour faire appel au pilote VGA et non pas VESA
#### Utilisation #### Utilisation
##### Sur un ordinateur émulé ##### Sur un ordinateur émulé
Pour tester l'OS en émulation taper donc la commande ```make test``` qui compilera avant de lancer Qemu. Pour tester l'OS en émulation taper donc la commande `make test` qui compilera avant de lancer Qemu.
##### Sur un ordinateur physique ##### Sur un ordinateur physique
Lancer une compilation du système COS2000 Lancer une compilation du système COS2000
```make all``` `make all`
Puis, il faut copier l'image sur une clé (Attention l'opération effacera le contenu de la clé) : Puis, il faut copier l'image sur une clé (Attention l'opération effacera le contenu de la clé) :
```sudo dd if=./final/harddisk.img.final of=/dev/sdx bs=1M``` (ou sdx est votre périphérique) `sudo dd if=./final/harddisk.img.final of=/dev/sdx bs=1M` (ou sdx est votre périphérique)
Bootez sur votre clé en mode bios (legacy). Bootez sur votre clé en mode bios (legacy).
Pour un boot en mode UEFI Pour un boot en mode UEFI
```sudo dd if=./final/harddiskuefi.img.final of=/dev/sdx bs=1M``` (ou sdx est votre périphérique) `sudo dd if=./final/harddiskuefi.img.final of=/dev/sdx bs=1M` (ou sdx est votre périphérique)
Pour connaitre le numéro de votre périphérique (clé) Pour connaitre le numéro de votre périphérique (clé)
```lsblk``` `lsblk`
##### Usage de COS2000 ##### Usage de COS2000
Pour l'instant quelques commandes seulement sont disponibles: Pour l'instant quelques commandes seulement sont disponibles:
* REBOOT redémarre le PC, * `REBOOT` redémarre le PC,
* CLEAR efface l'écran, * `CLEAR` efface l'écran,
* MODE change le mode video, * `MODE` change le mode video,
* DETECTCPU detecte et affiche les informations CPU, * `DETECTCPU` detecte et affiche les informations CPU,
* DETECTPCI detecte et affiche les périphériques PCI, * `DETECTPCI` detecte et affiche les périphériques PCI,
* TEST2D teste l'affichage graphique 2D, * `TEST2D` teste l'affichage graphique 2D,
* TEST3D teste l'affichage graphique 2D, * `TEST3D` teste l'affichage graphique 2D,
* REGS affiche les registres CPU, * `REGS` affiche les registres CPU,
* GDT affiche la table des descripteurs, * `GDT` affiche la table des descripteurs,
* IDT affiche la table des interruptions, * `IDT` affiche la table des interruptions,
* MEM affiche les statistiques d'occupation memoire, * `MEM` affiche les statistiques d'occupation memoire,
* INFO affiche des informations issues de GRUB, * `INFO` affiche des informations issues de GRUB,
* ERR génère une exception (ARGUMENTS), * `ERR` génère une exception (ARGUMENTS),
* VIEW visionne la mémoire vive (ARGUMENTS), * `VIEW` visionne la mémoire vive (ARGUMENTS),
* LOGO affiche le logo, * `LOGO` affiche le logo,
* FONT change la police d'affichage (ARGUMENTS), * `FONT` change la police d'affichage (ARGUMENTS),
* HELP affiche les commandes disponibles, * `HELP` affiche les commandes disponibles,
* BPSET met un point d'arrêt pour le débogueur (ARGUMENTS), * `BPSET` met un point d'arrêt pour le débogueur (ARGUMENTS),
* BPCLR efface un point d'arrêt (ARGUMENTS), * `BPCLR` efface un point d'arrêt (ARGUMENTS),
* DISASM désassemble une portion de mémoire (ARGUMENTS), * `DISASM` désassemble une portion de mémoire (ARGUMENTS),
![COS2000 le 28-09-2018](https://github.com/dahut87/cos2000v2/raw/develop/Graphisme/screenshots/28-09-2018.png) ![COS2000 le 28-09-2018](https://github.com/dahut87/cos2000v2/raw/develop/Graphisme/screenshots/28-09-2018.png)
#### Organisation du dépôt #### Organisation du dépôt
* debug - fichiers configuration débogueur * `debug` - fichiers configuration débogueur
* final - img raw utilisables avec un émulateur des 3 versions * `final` - img raw utilisables avec un émulateur des 3 versions
* * harddisk.img.final * * `harddisk.img.final`
* * harddiskuefi.img.final * * `harddiskuefi.img.final`
* * floppy.img.final * * `floppy.img.final`
* Graphisme - fichiers images * `Graphisme` - fichiers images
* * screenshots - screenshots de l'évolution du système * * `screenshots` - screenshots de l'évolution du système
* * Thème - thème de démarrage COS2000 pour plymouth * * `Thème` - thème de démarrage COS2000 pour plymouth
* include - fichier d'entête C * `include` - fichier d'entête C
* lib - librairies pour le noyau * `lib` - librairies pour le noyau
* makefile - Makefile du projet * `makefile` - Makefile du projet
* programs - programme pour le domaine utilisateur (en cours) * `programs` - programmes pour le domaine utilisateur
* README.md - ce que vous lisez * * `include` - fichier d'entête C
* system - le noyau lui-même * * `lib` - librairies pour le domaine utilisateur
* `README.md` - ce que vous lisez
* `LICENSE.md` - la licence LGPLv3.0
* `BUGS.md` - bugs rélevés dans le système
* `API.md` - Liste des APIs fournies par le système COS2000
* `system` - le noyau lui-même
### En savoir plus... ### En savoir plus...
@ -201,10 +221,14 @@ Pour l'instant quelques commandes seulement sont disponibles:
* mode protégé limité à 4Go de mémoire vive (32 bits), * mode protégé limité à 4Go de mémoire vive (32 bits),
* gestion avancée de la mémoire (vmalloc). * gestion avancée de la mémoire (vmalloc).
#### A faire #### En cours
* espace utilisateur et appels systèmes, * espace utilisateur et appels systèmes,
* ordonnanceur de tâche (par TSS), * ordonnanceur de tâche (par TSS),
* liste d'API automatiquement mise à jour,
#### A faire
* chargeur ELF32, * chargeur ELF32,
* pilote IDE/ATA (PIO mode), * pilote IDE/ATA (PIO mode),
* fonctions affichage image PNG, * fonctions affichage image PNG,
@ -215,6 +239,12 @@ Pour l'instant quelques commandes seulement sont disponibles:
![COS2000 le 29-11-2018](https://github.com/dahut87/cos2000v2/raw/develop/Graphisme/screenshots/29-11-2018.png) ![COS2000 le 29-11-2018](https://github.com/dahut87/cos2000v2/raw/develop/Graphisme/screenshots/29-11-2018.png)
#### Autres Licences (autres auteurs)
Des fichiers sources utilisés par COS2000 sont sous d'autres licences, parmis ceux-ci figurent :
* `include/queues.h` sous licence Berkeley Software Distribution License
#### Historique du projet #### Historique du projet
* Version 2.2fr - C en mode protégé Reprise du projet * Version 2.2fr - C en mode protégé Reprise du projet
* Version 2.1fr - C en mode protégé Abandon du projet * Version 2.1fr - C en mode protégé Abandon du projet

View File

@ -5,30 +5,35 @@
#include "matrix.h" #include "matrix.h"
#include "video.h" #include "video.h"
typedef struct triface { typedef struct triface
u16 V1; {
u16 V2; u16 V1;
u16 V3; u16 V2;
u16 V3;
} triface __attribute__ ((packed)); } triface __attribute__ ((packed));
typedef struct model3d { typedef struct model3d
u8 name[12]; {
matrix44 view; u8 name[12];
vector4 *vertexlist; matrix44 view;
u16 vertexnb; vector4 *vertexlist;
triface *facelist; u16 vertexnb;
u16 facenb; triface *facelist;
u16 facenb;
} model3d __attribute__ ((packed)); } model3d __attribute__ ((packed));
typedef struct vertex3d { typedef struct vertex3d
union { {
struct { union
float x; {
float y; struct
float z; {
}; float x;
float v[3]; float y;
}; float z;
};
float v[3];
};
} vertex3d __attribute__ ((packed)); } vertex3d __attribute__ ((packed));
typedef enum type3D typedef enum type3D
@ -38,13 +43,15 @@ typedef enum type3D
TYPE3D_FACES, TYPE3D_FACES,
TYPE3D_FLAT, TYPE3D_FLAT,
TYPE3D_TEXTURE, TYPE3D_TEXTURE,
} type3D __attribute__ ((packed)); } type3D __attribute__ ((packed));
void proj(vector4 list[], vertex2d plane[], vector4 origin[], u16 number, float factor); void proj(vector4 list[], vertex2d plane[], vector4 origin[],
void cube(model3d *model, vector4 *origin, u16 size); u16 number, float factor);
int load3ds(u8 *pointer,u32 size, model3d *model); void cube(model3d * model, vector4 * origin, u16 size);
void show3dmodel(model3d *model, matrix44 *transformation, vector4 origin[], float factor, type3D type); int load3ds(u8 * pointer, u32 size, model3d * model);
void show3dmodel(model3d * model, matrix44 * transformation,
vector4 origin[], float factor, type3D type);
/*******************************************************************************/ /*******************************************************************************/
/* Fichier 3DS */ /* Fichier 3DS */
@ -59,17 +66,17 @@ typedef enum dsState
DS_READ_POINTS, DS_READ_POINTS,
DS_READ_FACE_COUNT, DS_READ_FACE_COUNT,
DS_READ_FACES, DS_READ_FACES,
DS_READ_MATRIX, DS_READ_MATRIX,
DS_READ_DONE DS_READ_DONE
} dsState __attribute__ ((packed)); } dsState __attribute__ ((packed));
#define MAIN3DS 0x4D4D #define MAIN3DS 0x4D4D
//>------ Main Chunks //>------ Main Chunks
#define EDIT3DS 0x3D3D // this is the start of the editor config #define EDIT3DS 0x3D3D // this is the start of the editor config
#define KEYF3DS 0xB000 // this is the start of the keyframer config #define KEYF3DS 0xB000 // this is the start of the keyframer config
//>------ sub defines of EDIT3DS //>------ sub defines of EDIT3DS
@ -95,12 +102,12 @@ typedef enum dsState
#define EDIT_UNKNW09 0x2201 #define EDIT_UNKNW09 0x2201
#define EDIT_UNKNW10 0x2210 #define EDIT_UNKNW10 0x2210
#define EDIT_UNKNW11 0x2300 #define EDIT_UNKNW11 0x2300
#define EDIT_UNKNW12 0x2302 // new chunk type #define EDIT_UNKNW12 0x2302 // new chunk type
#define EDIT_UNKNW13 0x3000 #define EDIT_UNKNW13 0x3000
#define EDIT_UNKNW14 0xAFFF #define EDIT_UNKNW14 0xAFFF
//>------ sub defines of EDIT_MATERIAL //>------ sub defines of EDIT_MATERIAL
#define MAT_NAME01 0xA000 //> includes name (see mli doc for materials) #define MAT_NAME01 0xA000 //> includes name (see mli doc for materials)
//>------ sub defines of EDIT_OBJECT //>------ sub defines of EDIT_OBJECT
@ -109,11 +116,11 @@ typedef enum dsState
#define OBJ_CAMERA 0x4700 #define OBJ_CAMERA 0x4700
#define OBJ_UNKNWN01 0x4010 #define OBJ_UNKNWN01 0x4010
#define OBJ_UNKNWN02 0x4012 //>>---- Could be shadow #define OBJ_UNKNWN02 0x4012 //>>---- Could be shadow
//>------ sub defines of OBJ_CAMERA //>------ sub defines of OBJ_CAMERA
#define CAM_UNKNWN01 0x4710 // new chunk type #define CAM_UNKNWN01 0x4710 // new chunk type
#define CAM_UNKNWN02 0x4720 // new chunk type #define CAM_UNKNWN02 0x4720 // new chunk type
//>------ sub defines of OBJ_LIGHT //>------ sub defines of OBJ_LIGHT
#define LIT_OFF 0x4620 #define LIT_OFF 0x4620
@ -122,7 +129,7 @@ typedef enum dsState
//>------ sub defines of OBJ_TRIMESH //>------ sub defines of OBJ_TRIMESH
#define TRI_VERTEXL 0x4110 #define TRI_VERTEXL 0x4110
#define TRI_FACEL2 0x4111 // unknown yet #define TRI_FACEL2 0x4111 // unknown yet
#define TRI_FACEL1 0x4120 #define TRI_FACEL1 0x4120
#define TRI_SMOOTH 0x4150 #define TRI_SMOOTH 0x4150
#define TRI_LOCAL 0x4160 #define TRI_LOCAL 0x4160
@ -139,15 +146,15 @@ typedef enum dsState
#define KEYF_OBJDUMMYNAME 0xB011 #define KEYF_OBJDUMMYNAME 0xB011
#define KEYF_OBJUNKNWN01 0xB013 #define KEYF_OBJUNKNWN01 0xB013
#define KEYF_OBJUNKNWN02 0xB014 #define KEYF_OBJUNKNWN02 0xB014
#define KEYF_OBJUNKNWN03 0xB015 #define KEYF_OBJUNKNWN03 0xB015
#define KEYF_OBJPIVOT 0xB020 #define KEYF_OBJPIVOT 0xB020
#define KEYF_OBJUNKNWN04 0xB021 #define KEYF_OBJUNKNWN04 0xB021
#define KEYF_OBJUNKNWN05 0xB022 #define KEYF_OBJUNKNWN05 0xB022
//>>------ these define the different color chunk types //>>------ these define the different color chunk types
#define COL_RGB 0x0010 #define COL_RGB 0x0010
#define COL_TRU 0x0011 #define COL_TRU 0x0011
#define COL_UNK 0x0013 // unknown #define COL_UNK 0x0013 // unknown
//>>------ defines for viewport chunks //>>------ defines for viewport chunks
@ -158,7 +165,7 @@ typedef enum dsState
#define FRONT 0x0005 #define FRONT 0x0005
#define BACK 0x0006 #define BACK 0x0006
#define USER 0x0007 #define USER 0x0007
#define CAMERA 0x0008 // 0xFFFF is the code read from file #define CAMERA 0x0008 // 0xFFFF is the code read from file
#define LIGHT 0x0009 #define LIGHT 0x0009
#define DISABLED 0x0010 #define DISABLED 0x0010
#define BOGUS 0x0011 #define BOGUS 0x0011

View File

@ -4,113 +4,113 @@
#include "types.h" #include "types.h"
#ifndef _ASM #ifndef _ASM
#define _ASM # define _ASM
/******************************************************************************/ /******************************************************************************/
#define halt() asm("hlt"::) # define halt() asm("hlt"::)
#define sti() asm("sti"::) # define sti() asm("sti"::)
#define cli() asm("cli"::) # define cli() asm("cli"::)
#define nop() asm("nop"::) # define nop() asm("nop"::)
#define pushad() asm("pushal"::) # define pushad() asm("pushal"::)
#define popad() asm("popal"::) # define popad() asm("popal"::)
#define pushf() asm("pushf"::) # define pushf() asm("pushf"::)
#define pop(mem) asm("popl %0":"=m" (mem)) # define pop(mem) asm("popl %0":"=m" (mem))
#define push(mem) asm("pushl %0"::"m" (mem)) # define push(mem) asm("pushl %0"::"m" (mem))
#define popf() asm("popf"::) # define popf() asm("popf"::)
#define iret() asm("iret"::) # define iret() asm("iret"::)
#define leave() asm("leave"::) # define leave() asm("leave"::)
#define irqendmaster() asm("movb $0x20,%al; \ # define irqendmaster() asm("movb $0x20,%al; \
outb %al,$0x20;") outb %al,$0x20;")
#define irqendslave() asm("movb $0x20,%al; \ # define irqendslave() asm("movb $0x20,%al; \
outb %al,$0xA0;") outb %al,$0xA0;")
#define lidt(idtr) asm ("lidtl %0"::"m" (*idtr)) # define lidt(idtr) asm ("lidtl %0"::"m" (*idtr))
#define lgdt(gdtr) asm ("lgdtl %0"::"m" (*gdtr)) # define lgdt(gdtr) asm ("lgdtl %0"::"m" (*gdtr))
#define lldt(ldtr) asm ("lldtl %0"::"m" (*ldtr)) # define lldt(ldtr) asm ("lldtl %0"::"m" (*ldtr))
#define ltr(tss) asm volatile ("ltr %%ax":: "a" (tss)) # define ltr(tss) asm volatile ("ltr %%ax":: "a" (tss))
#define sidt(idtr) asm ("sidtl %0"::"m" (*idtr)) # define sidt(idtr) asm ("sidtl %0"::"m" (*idtr))
#define sgdt(gdtr) asm ("sgdtl %0"::"m" (*gdtr)) # define sgdt(gdtr) asm ("sgdtl %0"::"m" (*gdtr))
#define sldt(ldtr) asm ("sldtl %0"::"m" (*ldtr)) # define sldt(ldtr) asm ("sldtl %0"::"m" (*ldtr))
#define str(tss) asm volatile ("str %%ax;\ # define str(tss) asm volatile ("str %%ax;\
mov %%ax,%0":: "m" (tss)) mov %%ax,%0":: "m" (tss))
#define wrmsr(reg,low,high) asm volatile ("wrmsr" :: "c" (reg), "a" (low), "d" (high)) # define wrmsr(reg,low,high) asm volatile ("wrmsr" :: "c" (reg), "a" (low), "d" (high))
#define rdmsr(reg,low,high) asm volatile ("rdmsr" :: "=a" (low), "=d" (high) : "c" (reg) ) # define rdmsr(reg,low,high) asm volatile ("rdmsr" :: "=a" (low), "=d" (high) : "c" (reg) )
#define movsb(src,dst,count) \ # define movsb(src,dst,count) \
asm volatile ("cld;rep movsb"::"S" (src), "D" (dst), "c" (count)); asm volatile ("cld;rep movsb"::"S" (src), "D" (dst), "c" (count));
#define movsw(src,dst,count) \ # define movsw(src,dst,count) \
asm volatile ("cld;rep movsw"::"S" (src), "D" (dst), "c" (count)); asm volatile ("cld;rep movsw"::"S" (src), "D" (dst), "c" (count));
#define movsd(src,dst,count) \ # define movsd(src,dst,count) \
asm volatile ("cld;rep movsl"::"S" (src), "D" (dst), "c" (count)); asm volatile ("cld;rep movsl"::"S" (src), "D" (dst), "c" (count));
#define stosb(pattern,dst,count) \ # define stosb(pattern,dst,count) \
asm volatile ("cld;rep stosb"::"c" (count), "D" (dst), "a" (pattern)); asm volatile ("cld;rep stosb"::"c" (count), "D" (dst), "a" (pattern));
#define stosw(pattern,dst,count) \ # define stosw(pattern,dst,count) \
asm volatile ("cld;rep stosw"::"c" (count), "D" (dst), "a" (pattern)); asm volatile ("cld;rep stosw"::"c" (count), "D" (dst), "a" (pattern));
#define stosd(pattern,dst,count) \ # define stosd(pattern,dst,count) \
asm volatile ("cld;rep stosl"::"c" (count), "D" (dst), "a" (pattern)); asm volatile ("cld;rep stosl"::"c" (count), "D" (dst), "a" (pattern));
#define rol(addr) \ # define rol(addr) \
asm volatile ("rolb $0x1,%0":"=m" (addr):); asm volatile ("rolb $0x1,%0":"=m" (addr):);
#define ror(addr) \ # define ror(addr) \
asm volatile ("rorb $0x1,%0":"=m" (addr):); asm volatile ("rorb $0x1,%0":"=m" (addr):);
#define finit() \ # define finit() \
asm volatile ("finit"::); asm volatile ("finit"::);
/******************************************************************************/ /******************************************************************************/
#define outb(port,value) \ # define outb(port,value) \
asm volatile ("outb %%al,%%dx"::"d" (port), "a" (value)); asm volatile ("outb %%al,%%dx"::"d" (port), "a" (value));
#define outw(port,value) \ # define outw(port,value) \
asm volatile ("outw %%ax,%%dx"::"d" (port), "a" (value)); asm volatile ("outw %%ax,%%dx"::"d" (port), "a" (value));
#define outd(port,value) \ # define outd(port,value) \
asm volatile ("outl %%eax,%%dx"::"d" (port), "a" (value)); asm volatile ("outl %%eax,%%dx"::"d" (port), "a" (value));
/******************************************************************************/ /******************************************************************************/
#define inb(port) ({ \ # define inb(port) ({ \
u8 _v; \ u8 _v; \
asm volatile ("inb %%dx,%%al" : "=a" (_v) : "d" (port)); \ asm volatile ("inb %%dx,%%al" : "=a" (_v) : "d" (port)); \
_v; \ _v; \
}) })
#define inw(port) ({ \ # define inw(port) ({ \
u16 _v; \ u16 _v; \
asm volatile ("inw %%dx,%%ax" : "=a" (_v) : "d"(port)); \ asm volatile ("inw %%dx,%%ax" : "=a" (_v) : "d"(port)); \
_v; \ _v; \
}) })
#define ind(port) ({ \ # define ind(port) ({ \
u32 _v; \ u32 _v; \
asm volatile ("inl %%dx,%%eax" : "=a" (_v) : "d"(port)); \ asm volatile ("inl %%dx,%%eax" : "=a" (_v) : "d"(port)); \
_v; \ _v; \
@ -120,7 +120,7 @@
/* pas terminé */ /* pas terminé */
#define rolb(input,rotate) ({ \ # define rolb(input,rotate) ({ \
u32 _v; \ u32 _v; \
asm volatile ("roll %1,%0" : "=g" (_v) : "cI" (rotate), "0" (input)); \ asm volatile ("roll %1,%0" : "=g" (_v) : "cI" (rotate), "0" (input)); \
_v; \ _v; \

View File

@ -4,42 +4,42 @@
#include "interrupts.h" #include "interrupts.h"
typedef struct cpuinfo typedef struct cpuinfo
{ {
u8 vendor[13]; u8 vendor[13];
u8 names[32]; u8 names[32];
u8 detectedname[256]; u8 detectedname[256];
u8 techs[256]; u8 techs[256];
u8 stepping; u8 stepping;
u8 models; u8 models;
u8 family; u8 family;
u8 types; u8 types;
u8 emodels; u8 emodels;
u8 efamily; u8 efamily;
u8 apicid; u8 apicid;
u8 count; u8 count;
u8 linesize; u8 linesize;
u8 brandid; u8 brandid;
bool mmx; bool mmx;
bool mmx2; bool mmx2;
bool sse; bool sse;
bool sse2; bool sse2;
bool sse3; bool sse3;
bool fpu; bool fpu;
bool now3d; bool now3d;
bool now3d2; bool now3d2;
bool htt; bool htt;
bool apic; bool apic;
bool bits64; bool bits64;
bool syscall; bool syscall;
bool msr; bool msr;
bool sse4a; bool sse4a;
bool vmx; bool vmx;
bool sse41; bool sse41;
bool sse42; bool sse42;
bool apic2; bool apic2;
} cpuinfo __attribute__ ((packed)); } cpuinfo __attribute__ ((packed));
bool cansetflag (u32 flag); bool cansetflag(u32 flag);
void cpuid(u32 op, u32 *eax, u32 *ebx,u32 *ecx, u32 *edx); void cpuid(u32 op, u32 * eax, u32 * ebx, u32 * ecx, u32 * edx);
u8 getcpuinfos(cpuinfo *inf); u8 getcpuinfos(cpuinfo * inf);
void show_cpu(regs *stack); void show_cpu(regs * stack);

View File

@ -46,6 +46,6 @@
#define DBG_FOURBYTE 0b11 #define DBG_FOURBYTE 0b11
void setdebugreg(u8 number,u8 *address, u8 type); void setdebugreg(u8 number, u8 * address, u8 type);
u8* getdebugreg(u8 number); u8 *getdebugreg(u8 number);
u32 disasm(u8 *a, u8 *string, bool show); u32 disasm(u8 * a, u8 * string, bool show);

View File

@ -1,88 +1,92 @@
#include <types.h> #include <types.h>
/* Ordre imposé par SYSENTER */ /* Ordre imposé par SYSENTER */
#define SEL_KERNEL_CODE 0x8 /* Selecteur code du kernel */ #define SEL_KERNEL_CODE 0x8 /* Selecteur code du kernel */
#define SEL_KERNEL_STACK 0x10 /* Selecteur pile du kernel */ #define SEL_KERNEL_STACK 0x10 /* Selecteur pile du kernel */
#define SEL_USER_CODE 0x18 /* Selecteur code utilisateur */ #define SEL_USER_CODE 0x18 /* Selecteur code utilisateur */
#define SEL_USER_STACK 0x20 /* Selecteur pile utilisateur */ #define SEL_USER_STACK 0x20 /* Selecteur pile utilisateur */
#define SEL_KERNEL_DATA 0x28 /* Selecteur data du kernel */ #define SEL_KERNEL_DATA 0x28 /* Selecteur data du kernel */
#define SEL_USER_DATA 0x30 /* Selecteur data utilisateur */ #define SEL_USER_DATA 0x30 /* Selecteur data utilisateur */
#define SEL_TSS 0x38 /* Selecteur TSR */ #define SEL_TSS 0x38 /* Selecteur TSR */
#define GDT_SIZE 0x8 /* Nombre de descripteurs */ #define GDT_SIZE 0x8 /* Nombre de descripteurs */
/* Drapeau des descripteurs GDT */ /* Drapeau des descripteurs GDT */
#define GRANULARITY_4K 0b00001000 /* Granularité alignement 4096 octet*/ #define GRANULARITY_4K 0b00001000 /* Granularité alignement 4096 octet */
#define GRANULARITY_1B 0b00000000 /* Granularité alignement 1 octet */ #define GRANULARITY_1B 0b00000000 /* Granularité alignement 1 octet */
#define OPSIZE_32B 0b00000100 /* Taille opérandes 32 bits*/ #define OPSIZE_32B 0b00000100 /* Taille opérandes 32 bits */
#define OPSIZE_16B 0b00000000 /* Taille opérandes 16 bits*/ #define OPSIZE_16B 0b00000000 /* Taille opérandes 16 bits */
#define SYS_AVAILABLE 0b00000001 /* Disponible pour le système (à définir)*/ #define SYS_AVAILABLE 0b00000001 /* Disponible pour le système (à définir) */
#define SEG_ACCESSED 0b00000001 /* Segment accédé (code ou data) */ #define SEG_ACCESSED 0b00000001 /* Segment accédé (code ou data) */
#define SEG_DATA 0b00000000 /* Segment de données */ #define SEG_DATA 0b00000000 /* Segment de données */
#define SEG_CODE 0b00001000 /* Segment de données */ #define SEG_CODE 0b00001000 /* Segment de données */
#define SEG_READ_WRITE 0b00000010 /* Segment lecture-ecriture (data) */ #define SEG_READ_WRITE 0b00000010 /* Segment lecture-ecriture (data) */
#define SEG_EXPAND_DOWN 0b00000100 /* Segment avec expand-down (data) */ #define SEG_EXPAND_DOWN 0b00000100 /* Segment avec expand-down (data) */
#define SEG_READ 0b00000010 /* Segment lecture (code) */ #define SEG_READ 0b00000010 /* Segment lecture (code) */
#define SEG_CONFORMING 0b00000100 /* Segment conforming (code) */ #define SEG_CONFORMING 0b00000100 /* Segment conforming (code) */
#define SEG_PRESENT 0b10000000 /* Segment défini (obligatoire) */ #define SEG_PRESENT 0b10000000 /* Segment défini (obligatoire) */
#define SEG_RING0 0b00000000 /* Segment anneau 0 */ #define SEG_RING0 0b00000000 /* Segment anneau 0 */
#define SEG_RING1 0b00100000 /* Segment anneau 1 */ #define SEG_RING1 0b00100000 /* Segment anneau 1 */
#define SEG_RING2 0b01000000 /* Segment anneau 2 */ #define SEG_RING2 0b01000000 /* Segment anneau 2 */
#define SEG_RING3 0b01100000 /* Segment anneau 3 */ #define SEG_RING3 0b01100000 /* Segment anneau 3 */
#define SEG_NORMAL 0b00010000 /* Segment normal pile/data/code (0 pour système) */ #define SEG_NORMAL 0b00010000 /* Segment normal pile/data/code (0 pour système) */
typedef struct gdtdes { typedef struct gdtdes
u16 lim0_15; {
u16 base0_15; u16 lim0_15;
u8 base16_23; u16 base0_15;
u8 acces; u8 base16_23;
u8 lim16_19 : 4; u8 acces;
u8 flags : 4; u8 lim16_19:4;
u8 base24_31; u8 flags:4;
u8 base24_31;
} gdtdes __attribute__ ((packed)); } gdtdes __attribute__ ((packed));
struct gdtr { struct gdtr
u16 limite; {
u32 base; u16 limite;
u32 base;
} __attribute__ ((packed)); } __attribute__ ((packed));
typedef struct tss { typedef struct tss
u16 prevtask, reserved00; {
u32 esp0; u16 prevtask, reserved00;
u16 ss0, reserved0; u32 esp0;
u32 esp1; u16 ss0, reserved0;
u16 ss1, reserved1; u32 esp1;
u32 esp2; u16 ss1, reserved1;
u16 ss2, reserved2; u32 esp2;
u32 cr3; u16 ss2, reserved2;
u32 eip, eflags, eax, ecx, edx, ebx, esp, ebp, esi, edi; u32 cr3;
u16 es, reserved3; u32 eip, eflags, eax, ecx, edx, ebx, esp, ebp, esi, edi;
u16 cs, reserved4; u16 es, reserved3;
u16 ss, reserved5; u16 cs, reserved4;
u16 ds, reserved6; u16 ss, reserved5;
u16 fs, reserved7; u16 ds, reserved6;
u16 gs, reserved8; u16 fs, reserved7;
u16 ldt_selector, reserved9; u16 gs, reserved8;
u16 trapflag, iomap; u16 ldt_selector, reserved9;
u16 trapflag, iomap;
} __attribute__ ((packed)); } __attribute__ ((packed));
void inittr(void); void inittr(void);
void initgdt(u32 offset); void initgdt(u32 offset);
void makegdtdes(u32 base, u32 limite, u8 acces, u8 flags, gdtdes *desc); void makegdtdes(u32 base, u32 limite, u8 acces, u8 flags,
u32 getdesbase(u16 sel); gdtdes * desc);
u8 getdestype(u16 sel); u32 getdesbase(u16 sel);
u32 getdessize(u16 sel); u8 getdestype(u16 sel);
u32 getdeslimit(u16 sel); u32 getdessize(u16 sel);
bool isdesvalid(u16 sel); u32 getdeslimit(u16 sel);
u8 getdesbit3(u16 sel); bool isdesvalid(u16 sel);
u32 getdesdpl(u16 sel); u8 getdesbit3(u16 sel);
u16 getdesalign(u16 sel); u32 getdesdpl(u16 sel);
void setTSS(u32 ss,u32 sp); u16 getdesalign(u16 sel);
void setTSS(u32 ss, u32 sp);

View File

@ -5,57 +5,58 @@
#include "asm.h" #include "asm.h"
#ifndef _INTERRUPTS #ifndef _INTERRUPTS
#define _INTERRUPTS # define _INTERRUPTS
#define PIC1_CMD 0x20 /*PIC 8259A Commandes n°1 */ # define PIC1_CMD 0x20 /*PIC 8259A Commandes n°1 */
#define PIC1_DATA 0x21 /*PIC 8259A Données n°1 */ # define PIC1_DATA 0x21 /*PIC 8259A Données n°1 */
#define PIC2_CMD 0xa0 /*PIC 8259A Commandes n°2 */ # define PIC2_CMD 0xa0 /*PIC 8259A Commandes n°2 */
#define PIC2_DATA 0xa1 /*PIC 8259A Données n°1 */ # define PIC2_DATA 0xa1 /*PIC 8259A Données n°1 */
#define ICW1_ICW4 0x01 /* ICW4 ou pas*/ # define ICW1_ICW4 0x01 /* ICW4 ou pas */
#define ICW1_SINGLE 0x02 /* mode seul ou cascadé */ # define ICW1_SINGLE 0x02 /* mode seul ou cascadé */
#define ICW1_INTERVAL4 0x04 /* adresses appel d'interval 4 ou 8 */ # define ICW1_INTERVAL4 0x04 /* adresses appel d'interval 4 ou 8 */
#define ICW1_LEVEL 0x08 /* déclenchement sur niveau ou sur front */ # define ICW1_LEVEL 0x08 /* déclenchement sur niveau ou sur front */
#define ICW1_INIT 0x10 /* Initialization */ # define ICW1_INIT 0x10 /* Initialization */
#define ICW4_8086 0x01 /* 8086/88 (MCS-80/85) mode */
#define ICW4_AUTO 0x02 /* Auto EOI ou normal */
#define ICW4_BUF_SLAVE 0x08 /* mode/slave avec tampon*/
#define ICW4_BUF_MASTER 0x0C /* mode/master avec tampon*/
#define ICW4_SFNM 0x10 /* Complètement lié ou non */
#define INTGATE 0x0E00 /* utilise pour gerer les interruptions */ # define ICW4_8086 0x01 /* 8086/88 (MCS-80/85) mode */
#define TRAPGATE 0x0F00 /* utilise pour faire des appels systemes */ # define ICW4_AUTO 0x02 /* Auto EOI ou normal */
#define TASKGATE 0x0500 /* utilise pour commuter des taches */ # define ICW4_BUF_SLAVE 0x08 /* mode/slave avec tampon */
#define CALLGATE 0x0C00 /* utilise pour appeler du code */ # define ICW4_BUF_MASTER 0x0C /* mode/master avec tampon */
#define LDTDES 0x0200 /* utilise pour pointer une LDT */ # define ICW4_SFNM 0x10 /* Complètement lié ou non */
#define ENTRY_PRESENT 0b1000000000000000 /* Segment défini (obligatoire) */ # define INTGATE 0x0E00 /* utilise pour gerer les interruptions */
# define TRAPGATE 0x0F00 /* utilise pour faire des appels systemes */
# define TASKGATE 0x0500 /* utilise pour commuter des taches */
# define CALLGATE 0x0C00 /* utilise pour appeler du code */
# define LDTDES 0x0200 /* utilise pour pointer une LDT */
#define ENTRY_STORAGE 0b0001000000000000 /* Segment défini (obligatoire) */ # define ENTRY_PRESENT 0b1000000000000000 /* Segment défini (obligatoire) */
#define ENTRY_RING0 0b0000000000000000 /* Segment anneau 0 */ # define ENTRY_STORAGE 0b0001000000000000 /* Segment défini (obligatoire) */
#define ENTRY_RING1 0b0010000000000000 /* Segment anneau 1 */
#define ENTRY_RING2 0b0100000000000000 /* Segment anneau 2 */ # define ENTRY_RING0 0b0000000000000000 /* Segment anneau 0 */
#define ENTRY_RING3 0b0110000000000000 /* Segment anneau 3 */ # define ENTRY_RING1 0b0010000000000000 /* Segment anneau 1 */
# define ENTRY_RING2 0b0100000000000000 /* Segment anneau 2 */
# define ENTRY_RING3 0b0110000000000000 /* Segment anneau 3 */
/* 00-11-010-0 : Compteur 0 - LSB puis MSB - generateur taux - binaire */ /* 00-11-010-0 : Compteur 0 - LSB puis MSB - generateur taux - binaire */
#define TIMER0 0x40 /* port E/S pour le timer canal 0 */ # define TIMER0 0x40 /* port E/S pour le timer canal 0 */
#define TIMER_MODE 0x43 /* port E/S pour le mode controle du timer */ # define TIMER_MODE 0x43 /* port E/S pour le mode controle du timer */
#define RATE_GENERATOR 0x34 /* générateur de fréquence */ # define RATE_GENERATOR 0x34 /* générateur de fréquence */
#define SQUARE_WAVE 0x36 /* générateur d'onde carrée */ # define SQUARE_WAVE 0x36 /* générateur d'onde carrée */
#define TIMER_FREQ 1193180 /* fréquence pour timer dans un PC ou AT */ # define TIMER_FREQ 1193180
#define HZ 100 /* Fréquence d'horloge (ajutste logiciellement sur IBM-PC) */ /* fréquence pour timer dans un PC ou AT */
# define HZ 100 /* Fréquence d'horloge (ajutste logiciellement sur IBM-PC) */
#define getESP(mem) ({ \ # define getESP(mem) ({ \
asm volatile ("movl %%esp,%[tomem];":: [tomem] "m" (mem)); \ asm volatile ("movl %%esp,%[tomem];":: [tomem] "m" (mem)); \
}) })
#define getEBP(mem) ({ \ # define getEBP(mem) ({ \
asm volatile ("movl %%ebp,%[tomem];":: [tomem] "m" (mem)); \ asm volatile ("movl %%ebp,%[tomem];":: [tomem] "m" (mem)); \
}) })
#define createdump(dump) ({ \ # define createdump(dump) ({ \
push(dump.ss);\ push(dump.ss);\
push(dump.esp);\ push(dump.esp);\
push(dump.eflags);\ push(dump.eflags);\
@ -88,7 +89,7 @@
push(eferhigh);\ push(eferhigh);\
}) })
#define dumpcpu() ({ \ # define dumpcpu() ({ \
asm("\ asm("\
pushl %%ss\n \ pushl %%ss\n \
pushl %%esp\n \ pushl %%esp\n \
@ -132,7 +133,7 @@
pushl %%eax":::);\ pushl %%eax":::);\
}) })
#define restcpu() ({\ # define restcpu() ({\
asm("\ asm("\
popl %%eax \n \ popl %%eax \n \
popl %%edx \n \ popl %%edx \n \
@ -168,7 +169,7 @@
popl %%ds\n \"::);\ popl %%ds\n \"::);\
}) })
#define restdebugcpu() ({\ # define restdebugcpu() ({\
asm("\ asm("\
popl %%eax \n \ popl %%eax \n \
popl %%edx \n \ popl %%edx \n \
@ -210,93 +211,99 @@ lors d'un iret en mode kernel:
/* save pile */ /* save pile */
typedef struct regs { typedef struct regs
u64 efer; {
u32 dr7; u64 efer;
u32 dr6; u32 dr7;
u32 dr3; u32 dr6;
u32 dr2; u32 dr3;
u32 dr1; u32 dr2;
u32 dr0; u32 dr1;
u32 cr4; u32 dr0;
u32 cr3; u32 cr4;
u32 cr2; u32 cr3;
u32 cr0; u32 cr2;
u32 ebp; u32 cr0;
u32 edi; u32 ebp;
u32 esi; u32 edi;
u32 edx; u32 esi;
u32 ecx; u32 edx;
u32 ebx; u32 ecx;
u32 eax; u32 ebx;
u32 gs; u32 eax;
u32 fs; u32 gs;
u32 es; u32 fs;
u32 ds; u32 es;
u32 eip; u32 ds;
u32 cs; u32 eip;
u32 eflags; u32 cs;
u32 esp; u32 eflags;
u32 ss; u32 esp;
u32 ss;
} regs __attribute__ ((packed)); } regs __attribute__ ((packed));
/* exception pile depuis code kernel*/ /* exception pile depuis code kernel*/
typedef struct exception_stack { typedef struct exception_stack
u32 error_code; {
u32 eip; u32 error_code;
u32 cs; u32 eip;
u32 eflags; u32 cs;
u32 eflags;
} exception_stack __attribute__ ((packed)); } exception_stack __attribute__ ((packed));
/* sans code erreur depuis code kernel*/ /* sans code erreur depuis code kernel*/
typedef struct exception_stack_noerror { typedef struct exception_stack_noerror
u32 eip; {
u32 cs; u32 eip;
u32 eflags; u32 cs;
u32 eflags;
} exception_stack_noerror __attribute__ ((packed)); } exception_stack_noerror __attribute__ ((packed));
/* exception pile depuis code user */ /* exception pile depuis code user */
typedef struct exception_stack_user { typedef struct exception_stack_user
u32 error_code; {
u32 eip; u32 error_code;
u32 cs; u32 eip;
u32 eflags; u32 cs;
u32 esp; u32 eflags;
u32 ss; u32 esp;
u32 ss;
} exception_stack_user __attribute__ ((packed)); } exception_stack_user __attribute__ ((packed));
/* sans code erreu depuis code user */ /* sans code erreu depuis code user */
typedef struct exception_stack_noerror_user { typedef struct exception_stack_noerror_user
u32 eip; {
u32 cs; u32 eip;
u32 eflags; u32 cs;
u32 esp; u32 eflags;
u32 ss; u32 esp;
u32 ss;
} exception_stack_noerror_user __attribute__ ((packed)); } exception_stack_noerror_user __attribute__ ((packed));
/* descripteur de segment */ /* descripteur de segment */
typedef struct idtdes { typedef struct idtdes
u16 offset0_15; {
u16 select; u16 offset0_15;
u16 type; u16 select;
u16 offset16_31; u16 type;
} idtdes __attribute__ ((packed)); u16 offset16_31;
} idtdes __attribute__ ((packed));
struct idtr { struct idtr
u16 limite; {
u32 base; u16 limite;
u32 base;
} __attribute__ ((packed)); } __attribute__ ((packed));
void initretry(u32 address); void initretry(u32 address);
void initidt(void); void initidt(void);
u32 getinitretry(void); u32 getinitretry(void);
void setidt(u32 offset, u16 select, u16 type,u16 index); void setidt(u32 offset, u16 select, u16 type, u16 index);
void makeidtdes(u32 offset, u16 select, u16 type, idtdes* desc); void makeidtdes(u32 offset, u16 select, u16 type, idtdes * desc);
void initpic(void); void initpic(void);
void enableirq(u8 irq); void enableirq(u8 irq);
void disableirq(u8 irq); void disableirq(u8 irq);
void cpuerror(const u8 * src, const regs *stack); void cpuerror(const u8 * src, const regs * stack);
#endif #endif

View File

@ -1,7 +1,7 @@
/*******************************************************************************/ /*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */ /* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */ /* */
#define SCAN_CTRL 0x1D #define SCAN_CTRL 0x1D
#define SCAN_LEFTSHIFT 0x2A #define SCAN_LEFTSHIFT 0x2A
#define SCAN_RIGHTSHIFT 0x36 #define SCAN_RIGHTSHIFT 0x36
#define SCAN_ALT 0x38 #define SCAN_ALT 0x38
@ -23,16 +23,16 @@
/* bit de statut /* bit de statut
0x0100 est reservé pour les touches non-ASCII */ 0x0100 est reservé pour les touches non-ASCII */
#define STATUS_ALT 0x0200 #define STATUS_ALT 0x0200
#define STATUS_CTRL 0x0400 #define STATUS_CTRL 0x0400
#define STATUS_SHIFT 0x0800 #define STATUS_SHIFT 0x0800
#define STATUS_ANY (STATUS_ALT | STATUS_CTRL | STATUS_SHIFT) #define STATUS_ANY (STATUS_ALT | STATUS_CTRL | STATUS_SHIFT)
#define STATUS_CAPS 0x1000 #define STATUS_CAPS 0x1000
#define STATUS_NUM 0x2000 #define STATUS_NUM 0x2000
#define STATUS_SCRL 0x4000 #define STATUS_SCRL 0x4000
void keyboard(void); void keyboard(void);
void reboot(void); void reboot(void);
void outkbd(u8 port, u8 data); void outkbd(u8 port, u8 data);
u8 waitascii(void); u8 waitascii(void);
u8* getstring(u8* temp); u8 *getstring(u8 * temp);

View File

@ -2,29 +2,30 @@
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */ /* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */ /* */
#define sgn(x) ((x<0)?-1:((x>0)?1:0)); #define sgn(x) ((x<0)?-1:((x>0)?1:0));
#define M_PI 3.14159265358979323846 //Pi #define M_PI 3.14159265358979323846 //Pi
#define M_2_PI 0.636619772367581343076 //2 fois la réciproque de Pi #define M_2_PI 0.636619772367581343076 //2 fois la réciproque de Pi
#define M_PI_2 1.57079632679489661923 //Pi divisé par two #define M_PI_2 1.57079632679489661923 //Pi divisé par two
#define EPSILON 1E-40 #define EPSILON 1E-40
#define degtorad(deg) (deg * PI / 180.0) #define degtorad(deg) (deg * PI / 180.0)
#define radtodeg(rad) (rad * 180.0 / PI) #define radtodeg(rad) (rad * 180.0 / PI)
double cos(double x); double cos(double x);
double sin(double x); double sin(double x);
float cosf(float x); float cosf(float x);
float sinf(float x); float sinf(float x);
float fabsf(float n); float fabsf(float n);
double fabs(double n); double fabs(double n);
float sqrtf(float n); float sqrtf(float n);
float rsqrtf(float n); float rsqrtf(float n);
double sqrt(double n); double sqrt(double n);
double rsqrt(double n); double rsqrt(double n);
u32 abs(int x); u32 abs(int x);
u32 random(u32 lower, u32 upper); u32 random(u32 lower, u32 upper);
u32 rand(void); u32 rand(void);
void randomize(void); void randomize(void);
u8 log2(u64 n); u8 log2(u64 n);
u8 log10(u64 n); u8 log10(u64 n);
unsigned long long __udivdi3 (unsigned long long num, unsigned long long den); unsigned long long __udivdi3(unsigned long long num,
unsigned long long __umoddi3 (unsigned long long n, unsigned long long d); unsigned long long den);
u32 pow(u32 a, u8 n); unsigned long long __umoddi3(unsigned long long n, unsigned long long d);
u32 pow(u32 a, u8 n);

View File

@ -3,74 +3,79 @@
/* */ /* */
#ifndef MATRIX #ifndef MATRIX
# define MATRIX # define MATRIX
typedef struct vector4{ typedef struct vector4
union { {
struct { union
float x; {
float y; struct
float z; {
float w; float x;
}; float y;
float v[4]; float z;
}; float w;
};
float v[4];
};
} vector4 __attribute__ ((packed)); } vector4 __attribute__ ((packed));
typedef struct matrix44{ typedef struct matrix44
union { {
struct { union
vector4 V[4]; {
}; struct
float v[16]; {
}; vector4 V[4];
};
float v[16];
};
} matrix44 __attribute__ ((packed)); } matrix44 __attribute__ ((packed));
void vector4_show(vector4 src); void vector4_show(vector4 src);
void vector4_create(float x, float y, float z, float w, vector4 *dst); void vector4_create(float x, float y, float z, float w, vector4 * dst);
void vector4_copy(vector4 src, vector4 *dst); void vector4_copy(vector4 src, vector4 * dst);
void vector4_add(vector4 v1, vector4 v2, vector4 *dst); void vector4_add(vector4 v1, vector4 v2, vector4 * dst);
void vector4_sub(vector4 v1, vector4 v2, vector4 *dst); void vector4_sub(vector4 v1, vector4 v2, vector4 * dst);
void vector4_scale(vector4 *dst, float factor); void vector4_scale(vector4 * dst, float factor);
void vector4_crossproduct(vector4 v1, vector4 v2, vector4 *dst); void vector4_crossproduct(vector4 v1, vector4 v2, vector4 * dst);
void vector4_normalize(vector4 *dst); void vector4_normalize(vector4 * dst);
void vector4_divide(vector4 *v1, vector4 v2, vector4 *dst); void vector4_divide(vector4 * v1, vector4 v2, vector4 * dst);
void vector4_perpendicular(vector4 v1, vector4 v2, vector4 *dst); void vector4_perpendicular(vector4 v1, vector4 v2, vector4 * dst);
void vector4_rotate_x(vector4 *dst, float angle); void vector4_rotate_x(vector4 * dst, float angle);
void vector4_rotate_y(vector4 *dst, float angle); void vector4_rotate_y(vector4 * dst, float angle);
void vector4_rotate_z(vector4 *dst, float angle); void vector4_rotate_z(vector4 * dst, float angle);
float vector4_len(vector4 src); float vector4_len(vector4 src);
float vector4_dotproduct(vector4 v1, vector4 v2); float vector4_dotproduct(vector4 v1, vector4 v2);
float vector4_norm(vector4 src); float vector4_norm(vector4 src);
float vector4_distance(vector4 v1, vector4 v2); float vector4_distance(vector4 v1, vector4 v2);
int vector4_isequals(vector4 v1, vector4 v2); int vector4_isequals(vector4 v1, vector4 v2);
void vector4_planenormal(vector4 v1, vector4 v2, vector4 v3, vector4 *dst); void vector4_planenormal(vector4 v1, vector4 v2, vector4 v3,
vector4 * dst);
void matrix44_homogen(matrix44 *matrix); void matrix44_homogen(matrix44 * matrix);
void matrix44_empty(matrix44 *matrix); void matrix44_empty(matrix44 * matrix);
void matrix44_scaling(vector4 v, matrix44 *dst); void matrix44_scaling(vector4 v, matrix44 * dst);
void matrix44_translation(vector4 v, matrix44 *dst); void matrix44_translation(vector4 v, matrix44 * dst);
void matrix44_scale(matrix44 *dst, float factor); void matrix44_scale(matrix44 * dst, float factor);
void matrix44_scale_translation(vector4 scale, vector4 translation, matrix44 *dst); void matrix44_scale_translation(vector4 scale, vector4 translation,
void matrix44_rotation_x(float angle, matrix44 *dst); matrix44 * dst);
void matrix44_rotation_y(float angle, matrix44 *dst); void matrix44_rotation_x(float angle, matrix44 * dst);
void matrix44_rotation_z(float angle, matrix44 *dst); void matrix44_rotation_y(float angle, matrix44 * dst);
void matrix44_rotation(vector4 axis, float angle, matrix44 *dst); void matrix44_rotation_z(float angle, matrix44 * dst);
void matrix44_multiply(matrix44 *m1, matrix44 *m2, matrix44 *dst); void matrix44_rotation(vector4 axis, float angle, matrix44 * dst);
void matrix44_transform(matrix44 *matrix, vector4 *dst); void matrix44_multiply(matrix44 * m1, matrix44 * m2, matrix44 * dst);
float matrix44_determinant(matrix44 *matrix); void matrix44_transform(matrix44 * matrix, vector4 * dst);
float todeterminant(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3); float matrix44_determinant(matrix44 * matrix);
void matrix44_adjoint(matrix44 *matrix); float todeterminant(float a1, float a2, float a3, float b1, float b2,
void matrix44_show(matrix44 *matrix); float b3, float c1, float c2, float c3);
void matrix44_invert(matrix44 *matrix); void matrix44_adjoint(matrix44 * matrix);
void matrix44_transpose(matrix44 *matrix); void matrix44_show(matrix44 * matrix);
void matrix44_lookat(vector4 eye, vector4 dst, vector4 up, matrix44 *matrix); void matrix44_invert(matrix44 * matrix);
int matrix44_isequals(matrix44 *m1, matrix44 *m2); void matrix44_transpose(matrix44 * matrix);
float *toarray(matrix44 *m); void matrix44_lookat(vector4 eye, vector4 dst, vector4 up,
matrix44 * matrix);
int matrix44_isequals(matrix44 * m1, matrix44 * m2);
float *toarray(matrix44 * m);
#endif #endif

View File

@ -5,123 +5,135 @@
#include "queue.h" #include "queue.h"
#ifndef _MEMORY #ifndef _MEMORY
#define _MEMORY # define _MEMORY
#define TOPAGE(addr) (addr) >> 12 # define TOPAGE(addr) (addr) >> 12
#define TOPD(addr) ((addr) & 0xFFC00000) >> 22 # define TOPD(addr) ((addr) & 0xFFC00000) >> 22
#define TOPT(addr) ((addr) & 0x003FF000) >> 12 # define TOPT(addr) ((addr) & 0x003FF000) >> 12
#define TOPG(addr) (addr) & 0x00000FFF # define TOPG(addr) (addr) & 0x00000FFF
#define PAGESIZE 4096 /* Taille d'une page */ # define PAGESIZE 4096
#define PAGENUMBER 1024 /* Nombre de pages */ /* Taille d'une page */
#define KERNELSIZE PAGESIZE*PAGENUMBER*2 /* 2 pages de 4mo en identity mapping */ # define PAGENUMBER 1024
/* Nombre de pages */
# define KERNELSIZE PAGESIZE*PAGENUMBER*2 /* 2 pages de 4mo en identity mapping */
#define IDT_ADDR 0x00000000 /* adresse de la IDT */ # define IDT_ADDR 0x00000000 /* adresse de la IDT */
#define GDT_ADDR 0x00000800 /* adresse de la GDT */ # define GDT_ADDR 0x00000800 /* adresse de la GDT */
#define KERNEL_PD_ADDR 0x00001000 /* adresse de la page directory */ # define KERNEL_PD_ADDR 0x00001000
#define KERNEL_STACK_ADDR 0x0009FFFF /* adresse de la pile du kernel */ /* adresse de la page directory */
#define KERNEL_CODE_ADDR 0x00100000 /* adresse du code du noyau */ # define KERNEL_STACK_ADDR 0x0009FFFF
#define KERNEL_PAGES 0x00800000 /* adresse des pages */ /* adresse de la pile du kernel */
#define KERNEL_HEAP 0x10000000 /* adresse du heap */ # define KERNEL_CODE_ADDR 0x00100000
#define VESA_FBMEM 0x38000000 /* adresse du framebuffer VESA */ /* adresse du code du noyau */
#define USER_CODE 0x40000000 /* adresse du code utilisateur */ # define KERNEL_PAGES 0x00800000 /* adresse des pages */
#define USER_STACK 0xE0000000 /* adresse de la pile utilisateur */ # define KERNEL_HEAP 0x10000000 /* adresse du heap */
# define VESA_FBMEM 0x38000000 /* adresse du framebuffer VESA */
# define USER_CODE 0x40000000
/* adresse du code utilisateur */
# define USER_STACK 0xE0000000
/* adresse de la pile utilisateur */
/* limites de la mémoire 32 bits */ /* limites de la mémoire 32 bits */
#define MAXMEMSIZE 0x100000000 # define MAXMEMSIZE 0x100000000
#define MAXMEMPAGE 1024*1024 # define MAXMEMPAGE 1024*1024
#define MAXHEAPSIZE VESA_FBMEM-KERNEL_HEAP # define MAXHEAPSIZE VESA_FBMEM-KERNEL_HEAP
#define MAXPAGESSIZE KERNEL_HEAP-KERNEL_PAGES # define MAXPAGESSIZE KERNEL_HEAP-KERNEL_PAGES
/* page directory */ /* page directory */
#define PAGE_NOFLAG 0x0 # define PAGE_NOFLAG 0x0
#define PAGE_PRESENT 0b000000001/* page directory / table */ # define PAGE_PRESENT 0b000000001 /* page directory / table */
#define PAGE_WRITE 0b000000010 /* page lecture ecriture */ # define PAGE_WRITE 0b000000010 /* page lecture ecriture */
#define PAGE_ALL 0b000000100 /* accessible user & supervisor */ # define PAGE_ALL 0b000000100 /* accessible user & supervisor */
#define PAGE_WTROUGH 0b000001000 /* write-through cache */ # define PAGE_WTROUGH 0b000001000 /* write-through cache */
#define PAGE_NOCACHE 0b000010000 /* cache desactivé */ # define PAGE_NOCACHE 0b000010000 /* cache desactivé */
#define PAGE_ACCESS 0b000100000 /* page accedée */ # define PAGE_ACCESS 0b000100000 /* page accedée */
#define PAGE_4MB 0b010000000 /* page de 4mb au lieu de 4k (NECESSITE PSE)*/ # define PAGE_4MB 0b010000000 /* page de 4mb au lieu de 4k (NECESSITE PSE) */
/* page table */ /* page table */
#define PAGE_CACHE 0b000010000 /* page en cache */ # define PAGE_CACHE 0b000010000 /* page en cache */
#define PAGE_DIRTY 0b001000000 /* page écrite */ # define PAGE_DIRTY 0b001000000 /* page écrite */
#define PAGE_GLOBAL 0b100000000 /* évite que le TLB mette à jour l'adresse dans le cache si CR4 est remis à zéro (NECESSITE CR4) */ # define PAGE_GLOBAL 0b100000000 /* évite que le TLB mette à jour l'adresse dans le cache si CR4 est remis à zéro (NECESSITE CR4) */
/* Selecteur RPL */ /* Selecteur RPL */
#define RPL_RING0 0b00 /* Anneau 0 */ # define RPL_RING0 0b00 /* Anneau 0 */
#define RPL_RING1 0b01 /* Anneau 1 */ # define RPL_RING1 0b01 /* Anneau 1 */
#define RPL_RING2 0b01 /* Anneau 2 */ # define RPL_RING2 0b01 /* Anneau 2 */
#define RPL_RING3 0b11 /* Anneau 3 */ # define RPL_RING3 0b11 /* Anneau 3 */
#define MALLOC_MINIMUM 16 # define MALLOC_MINIMUM 16
#define setcr3(addr) \ # define setcr3(addr) \
asm volatile ("mov %[memaddr], %%eax; mov %%eax, %%cr3"::[memaddr] "m" (addr) ); asm volatile ("mov %[memaddr], %%eax; mov %%eax, %%cr3"::[memaddr] "m" (addr) );
/* Malloc, pour l'attribution de mémoire en heap */ /* Malloc, pour l'attribution de mémoire en heap */
typedef struct tmalloc { typedef struct tmalloc
u32 size:31; {
u32 used:1; u32 size:31;
u32 used:1;
} __attribute__ ((packed)) tmalloc; } __attribute__ ((packed)) tmalloc;
/* Page, pour la gestion de la mémoire virtuelle */ /* Page, pour la gestion de la mémoire virtuelle */
typedef struct page { typedef struct page
u8 *vaddr; {
u8 *paddr; u8 *vaddr;
TAILQ_ENTRY(page) tailq; u8 *paddr;
} __attribute__ ((packed)) page; TAILQ_ENTRY(page) tailq;
} __attribute__ ((packed)) page;
typedef TAILQ_HEAD(page_s, page) page_t; typedef TAILQ_HEAD(page_s, page) page_t;
/* Page directory, pour la gestion de la mémoire virtuelle */ /* Page directory, pour la gestion de la mémoire virtuelle */
typedef struct pd { typedef struct pd
page *addr; {
page_t page_head; page *addr;
} __attribute__ ((packed)) pd; page_t page_head;
} __attribute__ ((packed)) pd;
/* vaddrrange, pour la gestion des pages de la mémoire virtuelle */ /* vaddrrange, pour la gestion des pages de la mémoire virtuelle */
typedef struct vrange { typedef struct vrange
u8 *vaddrlow; {
u8 *vaddrhigh; u8 *vaddrlow;
TAILQ_ENTRY(vrange) tailq; u8 *vaddrhigh;
} __attribute__ ((packed)) vrange; TAILQ_ENTRY(vrange) tailq;
} __attribute__ ((packed)) vrange;
typedef TAILQ_HEAD(vrange_s, vrange) vrange_t; typedef TAILQ_HEAD(vrange_s, vrange) vrange_t;
void panic(u8 *string); void panic(u8 * string);
void memset(void *dst, u8 val, u32 count,u32 size); void memset(void *dst, u8 val, u32 count, u32 size);
void memcpy(void *src, void *dst, u32 count, u32 size); void memcpy(void *src, void *dst, u32 count, u32 size);
u32 memcmp(void *src, void *dst, u32 count, u32 size); u32 memcmp(void *src, void *dst, u32 count, u32 size);
u64 getmemoryfree(void); u64 getmemoryfree(void);
u64 physical_getmemorysize(); u64 physical_getmemorysize();
void physical_page_use(u32 page); void physical_page_use(u32 page);
void physical_page_free(u32 page); void physical_page_free(u32 page);
void physical_range_use(u64 addr,u64 len); void physical_range_use(u64 addr, u64 len);
void physical_range_free(u64 addr,u64 len); void physical_range_free(u64 addr, u64 len);
u8* physical_page_getfree(void); u8 *physical_page_getfree(void);
void physical_init(void); void physical_init(void);
void initpaging(void); void initpaging(void);
void virtual_init(void); void virtual_init(void);
tmalloc *mallocpage(u64 size); tmalloc *mallocpage(u64 size);
void *vmalloc(u32 size); void *vmalloc(u32 size);
void vfree(void *vaddr); void vfree(void *vaddr);
page *virtual_page_getfree(void); page *virtual_page_getfree(void);
pd *virtual_pd_create(); pd *virtual_pd_create();
void virtual_pd_destroy(pd *dst); void virtual_pd_destroy(pd * dst);
void virtual_page_free(u8* vaddr); void virtual_page_free(u8 * vaddr);
u8* virtual_to_physical(u8 *vaddr); u8 *virtual_to_physical(u8 * vaddr);
void virtual_pd_page_remove(u8* vaddr); void virtual_pd_page_remove(u8 * vaddr);
void virtual_pd_page_add(pd *dst, u8* vaddr, u8 * paddr, u32 flags); void virtual_pd_page_add(pd * dst, u8 * vaddr, u8 * paddr, u32 flags);
void virtual_range_use(pd *dst, u8 *vaddr, u8 *paddr, u64 len, u32 flags); void virtual_range_use(pd * dst, u8 * vaddr, u8 * paddr, u64 len,
void virtual_range_free(pd *dst, u8 *vaddr, u64 len); u32 flags);
void virtual_range_new(pd *dst, u8 *vaddr, u64 len, u32 flags); void virtual_range_free(pd * dst, u8 * vaddr, u64 len);
void malloc_init(void); void virtual_range_new(pd * dst, u8 * vaddr, u64 len, u32 flags);
void identity_init(void); void malloc_init(void);
void registry_init(void); void identity_init(void);
u32 getmallocused(void); void registry_init(void);
u32 getmallocfree(void); u32 getmallocused(void);
u32 getmallocnonallocated(void); u32 getmallocfree(void);
u32 virtual_getpagesfree(); u32 getmallocnonallocated(void);
u32 virtual_getpagesfree();
#endif #endif

View File

@ -1,7 +1,7 @@
/*******************************************************************************/ /*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */ /* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */ /* */
bool initmouse(void); bool initmouse(void);
void mouse(void); void mouse(void);
void outmseack(u8 value); void outmseack(u8 value);
void outmsecmd(u8 command); void outmsecmd(u8 command);

View File

@ -2,399 +2,399 @@
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */ /* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */ /* */
#include "types.h" #include "types.h"
#ifndef MULTIBOOT #ifndef MULTIBOOT
#define MULTIBOOT # define MULTIBOOT
/* How many bytes from the start of the file we search for the header. */ /* How many bytes from the start of the file we search for the header. */
#define MULTIBOOT_SEARCH 32768 # define MULTIBOOT_SEARCH 32768
#define MULTIBOOT_HEADER_ALIGN 8 # define MULTIBOOT_HEADER_ALIGN 8
/* The magic field should contain this. */
#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
/* This should be in %eax. */
#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289
/* Alignment of multiboot modules. */
#define MULTIBOOT_MOD_ALIGN 0x00001000
/* Alignment of the multiboot info structure. */
#define MULTIBOOT_INFO_ALIGN 0x00000008
/* Flags set in the 'flags' member of the multiboot header. */
#define MULTIBOOT_TAG_ALIGN 8
#define MULTIBOOT_TAG_TYPE_END 0
#define MULTIBOOT_TAG_TYPE_CMDLINE 1
#define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2
#define MULTIBOOT_TAG_TYPE_MODULE 3
#define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4
#define MULTIBOOT_TAG_TYPE_BOOTDEV 5
#define MULTIBOOT_TAG_TYPE_MMAP 6
#define MULTIBOOT_TAG_TYPE_VBE 7
#define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8
#define MULTIBOOT_TAG_TYPE_ELF_SECTIONS 9
#define MULTIBOOT_TAG_TYPE_APM 10
#define MULTIBOOT_TAG_TYPE_EFI32 11
#define MULTIBOOT_TAG_TYPE_EFI64 12
#define MULTIBOOT_TAG_TYPE_SMBIOS 13
#define MULTIBOOT_TAG_TYPE_ACPI_OLD 14
#define MULTIBOOT_TAG_TYPE_ACPI_NEW 15
#define MULTIBOOT_TAG_TYPE_NETWORK 16
#define MULTIBOOT_TAG_TYPE_EFI_MMAP 17
#define MULTIBOOT_TAG_TYPE_EFI_BS 18
#define MULTIBOOT_TAG_TYPE_EFI32_IH 19
#define MULTIBOOT_TAG_TYPE_EFI64_IH 20
#define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR 21
#define MULTIBOOT_HEADER_TAG_END 0
#define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1
#define MULTIBOOT_HEADER_TAG_ADDRESS 2
#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS 3
#define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS 4
#define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5
#define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6
#define MULTIBOOT_HEADER_TAG_EFI_BS 7
#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI32 8
#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9
#define MULTIBOOT_HEADER_TAG_RELOCATABLE 10
#define MULTIBOOT_ARCHITECTURE_I386 0
#define MULTIBOOT_ARCHITECTURE_MIPS32 4
#define MULTIBOOT_HEADER_TAG_OPTIONAL 1
#define MULTIBOOT_LOAD_PREFERENCE_NONE 0
#define MULTIBOOT_LOAD_PREFERENCE_LOW 1
#define MULTIBOOT_LOAD_PREFERENCE_HIGH 2
#define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1
#define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2
struct multiboot_header
{
/* Must be MULTIBOOT_MAGIC - see above. */
u32 magic;
/* ISA */
u32 architecture;
/* Total header length. */
u32 header_length;
/* The above fields plus this one must equal 0 mod 2^32. */
u32 checksum;
};
struct multiboot_header_tag
{
u16 type;
u16 flags;
u32 size;
};
struct multiboot_header_tag_information_request
{
u16 type;
u16 flags;
u32 size;
u32 requests[0];
};
struct multiboot_header_tag_address
{
u16 type;
u16 flags;
u32 size;
u32 header_addr;
u32 load_addr;
u32 load_end_addr;
u32 bss_end_addr;
};
struct multiboot_header_tag_entry_address
{
u16 type;
u16 flags;
u32 size;
u32 entry_addr;
};
struct multiboot_header_tag_console_flags
{
u16 type;
u16 flags;
u32 size;
u32 console_flags;
};
struct multiboot_header_tag_framebuffer
{
u16 type;
u16 flags;
u32 size;
u32 width;
u32 height;
u32 depth;
};
struct multiboot_header_tag_module_align
{
u16 type;
u16 flags;
u32 size;
};
struct multiboot_header_tag_relocatable
{
u16 type;
u16 flags;
u32 size;
u32 min_addr;
u32 max_addr;
u32 align;
u32 preference;
};
struct multiboot_color
{
u8 red;
u8 green;
u8 blue;
};
struct multiboot_mmap_entry
{
u64 addr;
u64 len;
#define MULTIBOOT_MEMORY_AVAILABLE 1
#define MULTIBOOT_MEMORY_RESERVED 2
#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
#define MULTIBOOT_MEMORY_NVS 4
#define MULTIBOOT_MEMORY_BADRAM 5
u32 type;
u32 zero;
};
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
struct multiboot_tag
{
u32 type;
u32 size;
};
struct multiboot_tag_string
{
u32 type;
u32 size;
u8 string[0];
};
struct multiboot_tag_module
{
u32 type;
u32 size;
u32 mod_start;
u32 mod_end;
u8 cmdline[0];
};
struct multiboot_tag_basic_meminfo
{
u32 type;
u32 size;
u32 mem_lower;
u32 mem_upper;
};
struct multiboot_tag_bootdev
{
u32 type;
u32 size;
u32 biosdev;
u32 slice;
u32 part;
};
struct multiboot_tag_mmap
{
u32 type;
u32 size;
u32 entry_size;
u32 entry_version;
struct multiboot_mmap_entry entries[0];
};
struct multiboot_vbe_info_block
{
u8 external_specification[512];
};
struct multiboot_vbe_mode_info_block
{
u8 external_specification[256];
};
struct multiboot_tag_vbe
{
u32 type;
u32 size;
u16 vbe_mode;
u16 vbe_interface_seg;
u16 vbe_interface_off;
u16 vbe_interface_len;
struct multiboot_vbe_info_block vbe_control_info;
struct multiboot_vbe_mode_info_block vbe_mode_info;
};
struct multiboot_tag_framebuffer_common
{
u32 type;
u32 size;
u64 framebuffer_addr;
u32 framebuffer_pitch;
u32 framebuffer_width;
u32 framebuffer_height;
u8 framebuffer_bpp;
#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
u8 framebuffer_type;
u16 reserved;
};
struct multiboot_tag_framebuffer
{
struct multiboot_tag_framebuffer_common common;
union
{
struct
{
u16 framebuffer_palette_num_colors;
struct multiboot_color framebuffer_palette[0];
};
struct
{
u8 framebuffer_red_field_position;
u8 framebuffer_red_mask_size;
u8 framebuffer_green_field_position;
u8 framebuffer_green_mask_size;
u8 framebuffer_blue_field_position;
u8 framebuffer_blue_mask_size;
};
};
};
struct multiboot_tag_elf_sections
{
u32 type;
u32 size;
u32 num;
u32 entsize;
u32 shndx;
u8 sections[0];
};
struct multiboot_tag_apm
{
u32 type;
u32 size;
u16 version;
u16 cseg;
u32 offset;
u16 cseg_16;
u16 dseg;
u16 flags;
u16 cseg_len;
u16 cseg_16_len;
u16 dseg_len;
};
struct multiboot_tag_efi32
{
u32 type;
u32 size;
u32 pointer;
};
struct multiboot_tag_efi64
{
u32 type;
u32 size;
u64 pointer;
};
struct multiboot_tag_smbios
{
u32 type;
u32 size;
u8 major;
u8 minor;
u8 reserved[6];
u8 tables[0];
};
struct multiboot_tag_old_acpi
{
u32 type;
u32 size;
u8 rsdp[0];
};
struct multiboot_tag_new_acpi
{
u32 type;
u32 size;
u8 rsdp[0];
};
struct multiboot_tag_network
{
u32 type;
u32 size;
u8 dhcpack[0];
};
struct multiboot_tag_efi_mmap
{
u32 type;
u32 size;
u32 descr_size;
u32 descr_vers;
u8 efi_mmap[0];
};
struct multiboot_tag_efi32_ih
{
u32 type;
u32 size;
u32 pointer;
};
struct multiboot_tag_efi64_ih
{
u32 type;
u32 size;
u64 pointer;
};
struct multiboot_tag_load_base_addr
{
u32 type;
u32 size;
u32 load_base_addr;
};
u32 getgrubinfo(u8 type); /* The magic field should contain this. */
u8 *getgrubinfo_cmdline(void); # define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
u32 getgrubinfo_ram(void);
/* This should be in %eax. */
# define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289
/* Alignment of multiboot modules. */
# define MULTIBOOT_MOD_ALIGN 0x00001000
/* Alignment of the multiboot info structure. */
# define MULTIBOOT_INFO_ALIGN 0x00000008
/* Flags set in the 'flags' member of the multiboot header. */
# define MULTIBOOT_TAG_ALIGN 8
# define MULTIBOOT_TAG_TYPE_END 0
# define MULTIBOOT_TAG_TYPE_CMDLINE 1
# define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2
# define MULTIBOOT_TAG_TYPE_MODULE 3
# define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4
# define MULTIBOOT_TAG_TYPE_BOOTDEV 5
# define MULTIBOOT_TAG_TYPE_MMAP 6
# define MULTIBOOT_TAG_TYPE_VBE 7
# define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8
# define MULTIBOOT_TAG_TYPE_ELF_SECTIONS 9
# define MULTIBOOT_TAG_TYPE_APM 10
# define MULTIBOOT_TAG_TYPE_EFI32 11
# define MULTIBOOT_TAG_TYPE_EFI64 12
# define MULTIBOOT_TAG_TYPE_SMBIOS 13
# define MULTIBOOT_TAG_TYPE_ACPI_OLD 14
# define MULTIBOOT_TAG_TYPE_ACPI_NEW 15
# define MULTIBOOT_TAG_TYPE_NETWORK 16
# define MULTIBOOT_TAG_TYPE_EFI_MMAP 17
# define MULTIBOOT_TAG_TYPE_EFI_BS 18
# define MULTIBOOT_TAG_TYPE_EFI32_IH 19
# define MULTIBOOT_TAG_TYPE_EFI64_IH 20
# define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR 21
# define MULTIBOOT_HEADER_TAG_END 0
# define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1
# define MULTIBOOT_HEADER_TAG_ADDRESS 2
# define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS 3
# define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS 4
# define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5
# define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6
# define MULTIBOOT_HEADER_TAG_EFI_BS 7
# define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI32 8
# define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9
# define MULTIBOOT_HEADER_TAG_RELOCATABLE 10
# define MULTIBOOT_ARCHITECTURE_I386 0
# define MULTIBOOT_ARCHITECTURE_MIPS32 4
# define MULTIBOOT_HEADER_TAG_OPTIONAL 1
# define MULTIBOOT_LOAD_PREFERENCE_NONE 0
# define MULTIBOOT_LOAD_PREFERENCE_LOW 1
# define MULTIBOOT_LOAD_PREFERENCE_HIGH 2
# define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1
# define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2
struct multiboot_header
{
/* Must be MULTIBOOT_MAGIC - see above. */
u32 magic;
/* ISA */
u32 architecture;
/* Total header length. */
u32 header_length;
/* The above fields plus this one must equal 0 mod 2^32. */
u32 checksum;
};
struct multiboot_header_tag
{
u16 type;
u16 flags;
u32 size;
};
struct multiboot_header_tag_information_request
{
u16 type;
u16 flags;
u32 size;
u32 requests[0];
};
struct multiboot_header_tag_address
{
u16 type;
u16 flags;
u32 size;
u32 header_addr;
u32 load_addr;
u32 load_end_addr;
u32 bss_end_addr;
};
struct multiboot_header_tag_entry_address
{
u16 type;
u16 flags;
u32 size;
u32 entry_addr;
};
struct multiboot_header_tag_console_flags
{
u16 type;
u16 flags;
u32 size;
u32 console_flags;
};
struct multiboot_header_tag_framebuffer
{
u16 type;
u16 flags;
u32 size;
u32 width;
u32 height;
u32 depth;
};
struct multiboot_header_tag_module_align
{
u16 type;
u16 flags;
u32 size;
};
struct multiboot_header_tag_relocatable
{
u16 type;
u16 flags;
u32 size;
u32 min_addr;
u32 max_addr;
u32 align;
u32 preference;
};
struct multiboot_color
{
u8 red;
u8 green;
u8 blue;
};
struct multiboot_mmap_entry
{
u64 addr;
u64 len;
# define MULTIBOOT_MEMORY_AVAILABLE 1
# define MULTIBOOT_MEMORY_RESERVED 2
# define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
# define MULTIBOOT_MEMORY_NVS 4
# define MULTIBOOT_MEMORY_BADRAM 5
u32 type;
u32 zero;
};
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
struct multiboot_tag
{
u32 type;
u32 size;
};
struct multiboot_tag_string
{
u32 type;
u32 size;
u8 string[0];
};
struct multiboot_tag_module
{
u32 type;
u32 size;
u32 mod_start;
u32 mod_end;
u8 cmdline[0];
};
struct multiboot_tag_basic_meminfo
{
u32 type;
u32 size;
u32 mem_lower;
u32 mem_upper;
};
struct multiboot_tag_bootdev
{
u32 type;
u32 size;
u32 biosdev;
u32 slice;
u32 part;
};
struct multiboot_tag_mmap
{
u32 type;
u32 size;
u32 entry_size;
u32 entry_version;
struct multiboot_mmap_entry entries[0];
};
struct multiboot_vbe_info_block
{
u8 external_specification[512];
};
struct multiboot_vbe_mode_info_block
{
u8 external_specification[256];
};
struct multiboot_tag_vbe
{
u32 type;
u32 size;
u16 vbe_mode;
u16 vbe_interface_seg;
u16 vbe_interface_off;
u16 vbe_interface_len;
struct multiboot_vbe_info_block vbe_control_info;
struct multiboot_vbe_mode_info_block vbe_mode_info;
};
struct multiboot_tag_framebuffer_common
{
u32 type;
u32 size;
u64 framebuffer_addr;
u32 framebuffer_pitch;
u32 framebuffer_width;
u32 framebuffer_height;
u8 framebuffer_bpp;
# define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
# define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
# define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
u8 framebuffer_type;
u16 reserved;
};
struct multiboot_tag_framebuffer
{
struct multiboot_tag_framebuffer_common common;
union
{
struct
{
u16 framebuffer_palette_num_colors;
struct multiboot_color framebuffer_palette[0];
};
struct
{
u8 framebuffer_red_field_position;
u8 framebuffer_red_mask_size;
u8 framebuffer_green_field_position;
u8 framebuffer_green_mask_size;
u8 framebuffer_blue_field_position;
u8 framebuffer_blue_mask_size;
};
};
};
struct multiboot_tag_elf_sections
{
u32 type;
u32 size;
u32 num;
u32 entsize;
u32 shndx;
u8 sections[0];
};
struct multiboot_tag_apm
{
u32 type;
u32 size;
u16 version;
u16 cseg;
u32 offset;
u16 cseg_16;
u16 dseg;
u16 flags;
u16 cseg_len;
u16 cseg_16_len;
u16 dseg_len;
};
struct multiboot_tag_efi32
{
u32 type;
u32 size;
u32 pointer;
};
struct multiboot_tag_efi64
{
u32 type;
u32 size;
u64 pointer;
};
struct multiboot_tag_smbios
{
u32 type;
u32 size;
u8 major;
u8 minor;
u8 reserved[6];
u8 tables[0];
};
struct multiboot_tag_old_acpi
{
u32 type;
u32 size;
u8 rsdp[0];
};
struct multiboot_tag_new_acpi
{
u32 type;
u32 size;
u8 rsdp[0];
};
struct multiboot_tag_network
{
u32 type;
u32 size;
u8 dhcpack[0];
};
struct multiboot_tag_efi_mmap
{
u32 type;
u32 size;
u32 descr_size;
u32 descr_vers;
u8 efi_mmap[0];
};
struct multiboot_tag_efi32_ih
{
u32 type;
u32 size;
u32 pointer;
};
struct multiboot_tag_efi64_ih
{
u32 type;
u32 size;
u64 pointer;
};
struct multiboot_tag_load_base_addr
{
u32 type;
u32 size;
u32 load_base_addr;
};
u32 getgrubinfo(u8 type);
u8 *getgrubinfo_cmdline(void);
u32 getgrubinfo_ram(void);
struct multiboot_tag_mmap *getgrubinfo_mem(void); struct multiboot_tag_mmap *getgrubinfo_mem(void);
struct multiboot_tag_framebuffer *getgrubinfo_fb(void); struct multiboot_tag_framebuffer *getgrubinfo_fb(void);
void getgrubinfo_all(void); void getgrubinfo_all(void);
void initmultiboot(const u32 addr); void initmultiboot(const u32 addr);
#endif #endif

View File

@ -4,41 +4,47 @@
typedef struct pciclass { typedef struct pciclass
u16 number; {
u8 *name; u16 number;
} pciclass __attribute__ ((packed)); u8 *name;
} pciclass __attribute__ ((packed));
typedef struct pcidev typedef struct pcidev
{ {
u16 vendor_id; u16 vendor_id;
u16 device_id; u16 device_id;
u16 command; u16 command;
u16 status; u16 status;
u8 revision_id; u8 revision_id;
u8 interface; u8 interface;
u8 sub_class; u8 sub_class;
u8 base_class; u8 base_class;
u8 cache_line_size; u8 cache_line_size;
u8 latency_timer; u8 latency_timer;
u8 header_type; u8 header_type;
u8 bist; u8 bist;
} pcidev __attribute__ ((packed)); } pcidev __attribute__ ((packed));
typedef struct pcidevmini { typedef struct pcidevmini
union { {
struct { union
u16 vendor_id; {
u16 device_id; struct
}; {
u32 dword; u16 vendor_id;
}; u16 device_id;
} pcidevmini __attribute__ ((packed)); };
u32 dword;
};
} pcidevmini __attribute__ ((packed));
u16 pciConfigReadWord(const u8 bus, const u8 dev, const u8 function, const u8 offset); u16 pciConfigReadWord(const u8 bus, const u8 dev, const u8 function,
void scanPCImini(void); const u8 offset);
void scanPCImini(void);
pcidevmini getPCImininfo(const u8 bus, const u8 dev, const u8 function); pcidevmini getPCImininfo(const u8 bus, const u8 dev, const u8 function);
bool getPCInfo(pcidev *device, const u8 bus, const u8 dev, const u8 function); bool getPCInfo(pcidev * device, const u8 bus, const u8 dev,
void scanPCI(void); const u8 function);
u8 * pcigetclassname( const pcidev *device); void scanPCI(void);
u8 *pcigetclassname(const pcidev * device);

View File

@ -16,39 +16,39 @@
#define STATUS_SLEEP 0x2 #define STATUS_SLEEP 0x2
/* ELF type */ /* ELF type */
#define ET_NONE 0 //No file type #define ET_NONE 0 //No file type
#define ET_REL 1 //Relocatable file #define ET_REL 1 //Relocatable file
#define ET_EXEC 2 //Executable file #define ET_EXEC 2 //Executable file
#define ET_DYN 3 //Shared object file #define ET_DYN 3 //Shared object file
#define ET_CORE 4 //Core file #define ET_CORE 4 //Core file
#define ET_LOOS 0xfe00 //Operating system-specific #define ET_LOOS 0xfe00 //Operating system-specific
#define ET_HIOS 0xfeff //Operating system-specific #define ET_HIOS 0xfeff //Operating system-specific
#define ET_LOPROC 0xff00 //Processor-specific #define ET_LOPROC 0xff00 //Processor-specific
#define ET_HIPROC 0xffff //Processor-specific #define ET_HIPROC 0xffff //Processor-specific
/* ELF identification */ /* ELF identification */
#define EI_MAG0 0 //File identification #define EI_MAG0 0 //File identification
#define EI_MAG1 1 //File identification #define EI_MAG1 1 //File identification
#define EI_MAG2 2 //File identification #define EI_MAG2 2 //File identification
#define EI_MAG3 3 //File identification #define EI_MAG3 3 //File identification
#define EI_CLASS 4 //File class #define EI_CLASS 4 //File class
#define EI_DATA 5 //Data encoding #define EI_DATA 5 //Data encoding
#define EI_VERSION 6 //File version #define EI_VERSION 6 //File version
#define EI_OSABI 7 //Operating system/ABI identification #define EI_OSABI 7 //Operating system/ABI identification
#define EI_ABIVERSION 8 //ABI version #define EI_ABIVERSION 8 //ABI version
#define EI_PAD 9 //Start of padding bytes #define EI_PAD 9 //Start of padding bytes
#define EI_NIDENT 16 //Size of e_ident[] #define EI_NIDENT 16 //Size of e_ident[]
/* ELF version */ /* ELF version */
#define EV_NONE 0 //Invalid version #define EV_NONE 0 //Invalid version
#define EV_CURRENT 1 //Current version #define EV_CURRENT 1 //Current version
/* ELF machine type */ /* ELF machine type */
#define EM_NONE 0 //No machine #define EM_NONE 0 //No machine
#define EM_386 3 //Intel 80386 #define EM_386 3 //Intel 80386
#define EM_IA_64 50 //Intel IA-64 processor architecture #define EM_IA_64 50 //Intel IA-64 processor architecture
#define EM_X86_64 62 //AMD x86-64 architecture #define EM_X86_64 62 //AMD x86-64 architecture
/* EI signature */ /* EI signature */
#define ELFMAG0 0x7f #define ELFMAG0 0x7f
@ -83,69 +83,73 @@
#define PF_R 0x4 #define PF_R 0x4
/* OS identification */ /* OS identification */
#define ELFOSABI_NONE 0 //No extensions or unspecified #define ELFOSABI_NONE 0 //No extensions or unspecified
#define ELFOSABI_LINUX 3 //Linux #define ELFOSABI_LINUX 3 //Linux
#define ELFOSABI_COS2000 16 //COS2000 #define ELFOSABI_COS2000 16 //COS2000
/* ELF header */ /* ELF header */
typedef struct elf32 { typedef struct elf32
u8 e_ident[EI_NIDENT]; {
u16 e_type; u8 e_ident[EI_NIDENT];
u16 e_machine; u16 e_type;
u32 e_version; u16 e_machine;
u8* e_entry; u32 e_version;
u32 e_phoff; u8 *e_entry;
u32 e_shoff; u32 e_phoff;
u32 e_flags; u32 e_shoff;
u16 e_ehsize; u32 e_flags;
u16 e_phentsize; u16 e_ehsize;
u16 e_phnum; u16 e_phentsize;
u16 e_shentsize; u16 e_phnum;
u16 e_shnum; u16 e_shentsize;
u16 e_shstrndx; u16 e_shnum;
u16 e_shstrndx;
} elf32; } elf32;
typedef struct elf32p{ typedef struct elf32p
u32 p_type; {
u32 p_offset; u32 p_type;
u8* p_vaddr; u32 p_offset;
u8* p_paddr; u8 *p_vaddr;
u32 p_filesz; u8 *p_paddr;
u32 p_memsz; u32 p_filesz;
u32 p_flags; u32 p_memsz;
u32 p_align; u32 p_flags;
u32 p_align;
} elf32p; } elf32p;
typedef struct stackdef { typedef struct stackdef
u32 esp0; {
u16 ss0; u32 esp0;
} stackdef __attribute__ ((packed)); u16 ss0;
} stackdef __attribute__ ((packed));
typedef struct process { typedef struct process
u32 pid; {
bool kernel; u32 pid;
regs dump; bool kernel;
stackdef kstack; regs dump;
pd *pdd; stackdef kstack;
u32 result; pd *pdd;
u8 status; u32 result;
u8 *exec_low; u8 status;
u8 *exec_high; u8 *exec_low;
u8 *bss_low; u8 *exec_high;
u8 *bss_high; u8 *bss_low;
struct process *parent; u8 *bss_high;
page_t page_head; struct process *parent;
u32 entry; page_t page_head;
u32 entry;
} process __attribute__ ((packed)); } process __attribute__ ((packed));
void task_init(); void task_init();
u32 task_getfreePID (); u32 task_getfreePID();
u32 task_usePID (u32 pid); u32 task_usePID(u32 pid);
u32 task_create(u8 *code,bool kerneltask); u32 task_create(u8 * code, bool kerneltask);
u32 elf_test(u8 *src); u32 elf_test(u8 * src);
u32 elf_load(u8 *src, u32 pid); u32 elf_load(u8 * src, u32 pid);
void task_switch(u32 pid, bool fromkernelmode); void task_switch(u32 pid, bool fromkernelmode);
process *getcurrentprocess(); process *getcurrentprocess();
void task_run(u32 pid); void task_run(u32 pid);

View File

@ -31,7 +31,7 @@
*/ */
#ifndef _SYS_QUEUE_H_ #ifndef _SYS_QUEUE_H_
#define _SYS_QUEUE_H_ # define _SYS_QUEUE_H_
//#include <sys/cdefs.h> //#include <sys/cdefs.h>
@ -106,55 +106,57 @@
* _SWAP + + + + * _SWAP + + + +
* *
*/ */
#ifdef QUEUE_MACRO_DEBUG # ifdef QUEUE_MACRO_DEBUG
/* Store the last 2 places the queue element or head was altered */ /* Store the last 2 places the queue element or head was altered */
struct qm_trace { struct qm_trace
unsigned long lastline; {
unsigned long prevline; unsigned long lastline;
const char *lastfile; unsigned long prevline;
const char *prevfile; const char *lastfile;
const char *prevfile;
}; };
#define TRACEBUF struct qm_trace trace; # define TRACEBUF struct qm_trace trace;
#define TRACEBUF_INITIALIZER { __FILE__, __LINE__, NULL, 0 } , # define TRACEBUF_INITIALIZER { __FILE__, __LINE__, NULL, 0 } ,
#define TRASHIT(x) do {(x) = (void *)-1;} while (0) # define TRASHIT(x) do {(x) = (void *)-1;} while (0)
#define QMD_SAVELINK(name, link) void **name = (void *)&(link) # define QMD_SAVELINK(name, link) void **name = (void *)&(link)
#define QMD_TRACE_HEAD(head) do { \ # define QMD_TRACE_HEAD(head) do { \
(head)->trace.prevline = (head)->trace.lastline; \ (head)->trace.prevline = (head)->trace.lastline; \
(head)->trace.prevfile = (head)->trace.lastfile; \ (head)->trace.prevfile = (head)->trace.lastfile; \
(head)->trace.lastline = __LINE__; \ (head)->trace.lastline = __LINE__; \
(head)->trace.lastfile = __FILE__; \ (head)->trace.lastfile = __FILE__; \
} while (0) } while (0)
#define QMD_TRACE_ELEM(elem) do { \ # define QMD_TRACE_ELEM(elem) do { \
(elem)->trace.prevline = (elem)->trace.lastline; \ (elem)->trace.prevline = (elem)->trace.lastline; \
(elem)->trace.prevfile = (elem)->trace.lastfile; \ (elem)->trace.prevfile = (elem)->trace.lastfile; \
(elem)->trace.lastline = __LINE__; \ (elem)->trace.lastline = __LINE__; \
(elem)->trace.lastfile = __FILE__; \ (elem)->trace.lastfile = __FILE__; \
} while (0) } while (0)
#else # else
#define QMD_TRACE_ELEM(elem) # define QMD_TRACE_ELEM(elem)
#define QMD_TRACE_HEAD(head) # define QMD_TRACE_HEAD(head)
#define QMD_SAVELINK(name, link) # define QMD_SAVELINK(name, link)
#define TRACEBUF # define TRACEBUF
#define TRACEBUF_INITIALIZER # define TRACEBUF_INITIALIZER
#define TRASHIT(x) # define TRASHIT(x)
#endif /* QUEUE_MACRO_DEBUG */ # endif
/* QUEUE_MACRO_DEBUG */
/* /*
* Singly-linked List declarations. * Singly-linked List declarations.
*/ */
#define SLIST_HEAD(name, type) \ # define SLIST_HEAD(name, type) \
struct name { \ struct name { \
struct type *slh_first; /* first element */ \ struct type *slh_first; /* first element */ \
} }
#define SLIST_HEAD_INITIALIZER(head) \ # define SLIST_HEAD_INITIALIZER(head) \
{ NULL } { NULL }
#define SLIST_ENTRY(type) \ # define SLIST_ENTRY(type) \
struct { \ struct { \
struct type *sle_next; /* next element */ \ struct type *sle_next; /* next element */ \
} }
@ -162,52 +164,52 @@ struct { \
/* /*
* Singly-linked List functions. * Singly-linked List functions.
*/ */
#define SLIST_EMPTY(head) ((head)->slh_first == NULL) # define SLIST_EMPTY(head) ((head)->slh_first == NULL)
#define SLIST_FIRST(head) ((head)->slh_first) # define SLIST_FIRST(head) ((head)->slh_first)
#define SLIST_FOREACH(var, head, field) \ # define SLIST_FOREACH(var, head, field) \
for ((var) = SLIST_FIRST((head)); \ for ((var) = SLIST_FIRST((head)); \
(var); \ (var); \
(var) = SLIST_NEXT((var), field)) (var) = SLIST_NEXT((var), field))
#define SLIST_FOREACH_FROM(var, head, field) \ # define SLIST_FOREACH_FROM(var, head, field) \
for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \
(var); \ (var); \
(var) = SLIST_NEXT((var), field)) (var) = SLIST_NEXT((var), field))
#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ # define SLIST_FOREACH_SAFE(var, head, field, tvar) \
for ((var) = SLIST_FIRST((head)); \ for ((var) = SLIST_FIRST((head)); \
(var) && ((tvar) = SLIST_NEXT((var), field), 1); \ (var) && ((tvar) = SLIST_NEXT((var), field), 1); \
(var) = (tvar)) (var) = (tvar))
#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ # define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \
(var) && ((tvar) = SLIST_NEXT((var), field), 1); \ (var) && ((tvar) = SLIST_NEXT((var), field), 1); \
(var) = (tvar)) (var) = (tvar))
#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \ # define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
for ((varp) = &SLIST_FIRST((head)); \ for ((varp) = &SLIST_FIRST((head)); \
((var) = *(varp)) != NULL; \ ((var) = *(varp)) != NULL; \
(varp) = &SLIST_NEXT((var), field)) (varp) = &SLIST_NEXT((var), field))
#define SLIST_INIT(head) do { \ # define SLIST_INIT(head) do { \
SLIST_FIRST((head)) = NULL; \ SLIST_FIRST((head)) = NULL; \
} while (0) } while (0)
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ # define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \
SLIST_NEXT((slistelm), field) = (elm); \ SLIST_NEXT((slistelm), field) = (elm); \
} while (0) } while (0)
#define SLIST_INSERT_HEAD(head, elm, field) do { \ # define SLIST_INSERT_HEAD(head, elm, field) do { \
SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \
SLIST_FIRST((head)) = (elm); \ SLIST_FIRST((head)) = (elm); \
} while (0) } while (0)
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) # define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
#define SLIST_REMOVE(head, elm, type, field) do { \ # define SLIST_REMOVE(head, elm, type, field) do { \
QMD_SAVELINK(oldnext, (elm)->field.sle_next); \ QMD_SAVELINK(oldnext, (elm)->field.sle_next); \
if (SLIST_FIRST((head)) == (elm)) { \ if (SLIST_FIRST((head)) == (elm)) { \
SLIST_REMOVE_HEAD((head), field); \ SLIST_REMOVE_HEAD((head), field); \
@ -221,16 +223,16 @@ struct { \
TRASHIT(*oldnext); \ TRASHIT(*oldnext); \
} while (0) } while (0)
#define SLIST_REMOVE_AFTER(elm, field) do { \ # define SLIST_REMOVE_AFTER(elm, field) do { \
SLIST_NEXT(elm, field) = \ SLIST_NEXT(elm, field) = \
SLIST_NEXT(SLIST_NEXT(elm, field), field); \ SLIST_NEXT(SLIST_NEXT(elm, field), field); \
} while (0) } while (0)
#define SLIST_REMOVE_HEAD(head, field) do { \ # define SLIST_REMOVE_HEAD(head, field) do { \
SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
} while (0) } while (0)
#define SLIST_SWAP(head1, head2, type) do { \ # define SLIST_SWAP(head1, head2, type) do { \
struct type *swap_first = SLIST_FIRST(head1); \ struct type *swap_first = SLIST_FIRST(head1); \
SLIST_FIRST(head1) = SLIST_FIRST(head2); \ SLIST_FIRST(head1) = SLIST_FIRST(head2); \
SLIST_FIRST(head2) = swap_first; \ SLIST_FIRST(head2) = swap_first; \
@ -239,16 +241,16 @@ struct { \
/* /*
* Singly-linked Tail queue declarations. * Singly-linked Tail queue declarations.
*/ */
#define STAILQ_HEAD(name, type) \ # define STAILQ_HEAD(name, type) \
struct name { \ struct name { \
struct type *stqh_first;/* first element */ \ struct type *stqh_first;/* first element */ \
struct type **stqh_last;/* addr of last next element */ \ struct type **stqh_last;/* addr of last next element */ \
} }
#define STAILQ_HEAD_INITIALIZER(head) \ # define STAILQ_HEAD_INITIALIZER(head) \
{ NULL, &(head).stqh_first } { NULL, &(head).stqh_first }
#define STAILQ_ENTRY(type) \ # define STAILQ_ENTRY(type) \
struct { \ struct { \
struct type *stqe_next; /* next element */ \ struct type *stqe_next; /* next element */ \
} }
@ -256,7 +258,7 @@ struct { \
/* /*
* Singly-linked Tail queue functions. * Singly-linked Tail queue functions.
*/ */
#define STAILQ_CONCAT(head1, head2) do { \ # define STAILQ_CONCAT(head1, head2) do { \
if (!STAILQ_EMPTY((head2))) { \ if (!STAILQ_EMPTY((head2))) { \
*(head1)->stqh_last = (head2)->stqh_first; \ *(head1)->stqh_last = (head2)->stqh_first; \
(head1)->stqh_last = (head2)->stqh_last; \ (head1)->stqh_last = (head2)->stqh_last; \
@ -264,60 +266,60 @@ struct { \
} \ } \
} while (0) } while (0)
#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) # define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
#define STAILQ_FIRST(head) ((head)->stqh_first) # define STAILQ_FIRST(head) ((head)->stqh_first)
#define STAILQ_FOREACH(var, head, field) \ # define STAILQ_FOREACH(var, head, field) \
for((var) = STAILQ_FIRST((head)); \ for((var) = STAILQ_FIRST((head)); \
(var); \ (var); \
(var) = STAILQ_NEXT((var), field)) (var) = STAILQ_NEXT((var), field))
#define STAILQ_FOREACH_FROM(var, head, field) \ # define STAILQ_FOREACH_FROM(var, head, field) \
for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \
(var); \ (var); \
(var) = STAILQ_NEXT((var), field)) (var) = STAILQ_NEXT((var), field))
#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ # define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
for ((var) = STAILQ_FIRST((head)); \ for ((var) = STAILQ_FIRST((head)); \
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
(var) = (tvar)) (var) = (tvar))
#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ # define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
(var) = (tvar)) (var) = (tvar))
#define STAILQ_INIT(head) do { \ # define STAILQ_INIT(head) do { \
STAILQ_FIRST((head)) = NULL; \ STAILQ_FIRST((head)) = NULL; \
(head)->stqh_last = &STAILQ_FIRST((head)); \ (head)->stqh_last = &STAILQ_FIRST((head)); \
} while (0) } while (0)
#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ # define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
(head)->stqh_last = &STAILQ_NEXT((elm), field); \ (head)->stqh_last = &STAILQ_NEXT((elm), field); \
STAILQ_NEXT((tqelm), field) = (elm); \ STAILQ_NEXT((tqelm), field) = (elm); \
} while (0) } while (0)
#define STAILQ_INSERT_HEAD(head, elm, field) do { \ # define STAILQ_INSERT_HEAD(head, elm, field) do { \
if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
(head)->stqh_last = &STAILQ_NEXT((elm), field); \ (head)->stqh_last = &STAILQ_NEXT((elm), field); \
STAILQ_FIRST((head)) = (elm); \ STAILQ_FIRST((head)) = (elm); \
} while (0) } while (0)
#define STAILQ_INSERT_TAIL(head, elm, field) do { \ # define STAILQ_INSERT_TAIL(head, elm, field) do { \
STAILQ_NEXT((elm), field) = NULL; \ STAILQ_NEXT((elm), field) = NULL; \
*(head)->stqh_last = (elm); \ *(head)->stqh_last = (elm); \
(head)->stqh_last = &STAILQ_NEXT((elm), field); \ (head)->stqh_last = &STAILQ_NEXT((elm), field); \
} while (0) } while (0)
#define STAILQ_LAST(head, type, field) \ # define STAILQ_LAST(head, type, field) \
(STAILQ_EMPTY((head)) ? NULL : \ (STAILQ_EMPTY((head)) ? NULL : \
__containerof((head)->stqh_last, struct type, field.stqe_next)) __containerof((head)->stqh_last, struct type, field.stqe_next))
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) # define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
#define STAILQ_REMOVE(head, elm, type, field) do { \ # define STAILQ_REMOVE(head, elm, type, field) do { \
QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \ QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \
if (STAILQ_FIRST((head)) == (elm)) { \ if (STAILQ_FIRST((head)) == (elm)) { \
STAILQ_REMOVE_HEAD((head), field); \ STAILQ_REMOVE_HEAD((head), field); \
@ -331,19 +333,19 @@ struct { \
TRASHIT(*oldnext); \ TRASHIT(*oldnext); \
} while (0) } while (0)
#define STAILQ_REMOVE_AFTER(head, elm, field) do { \ # define STAILQ_REMOVE_AFTER(head, elm, field) do { \
if ((STAILQ_NEXT(elm, field) = \ if ((STAILQ_NEXT(elm, field) = \
STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \ STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \
(head)->stqh_last = &STAILQ_NEXT((elm), field); \ (head)->stqh_last = &STAILQ_NEXT((elm), field); \
} while (0) } while (0)
#define STAILQ_REMOVE_HEAD(head, field) do { \ # define STAILQ_REMOVE_HEAD(head, field) do { \
if ((STAILQ_FIRST((head)) = \ if ((STAILQ_FIRST((head)) = \
STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \
(head)->stqh_last = &STAILQ_FIRST((head)); \ (head)->stqh_last = &STAILQ_FIRST((head)); \
} while (0) } while (0)
#define STAILQ_SWAP(head1, head2, type) do { \ # define STAILQ_SWAP(head1, head2, type) do { \
struct type *swap_first = STAILQ_FIRST(head1); \ struct type *swap_first = STAILQ_FIRST(head1); \
struct type **swap_last = (head1)->stqh_last; \ struct type **swap_last = (head1)->stqh_last; \
STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \ STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \
@ -360,15 +362,15 @@ struct { \
/* /*
* List declarations. * List declarations.
*/ */
#define LIST_HEAD(name, type) \ # define LIST_HEAD(name, type) \
struct name { \ struct name { \
struct type *lh_first; /* first element */ \ struct type *lh_first; /* first element */ \
} }
#define LIST_HEAD_INITIALIZER(head) \ # define LIST_HEAD_INITIALIZER(head) \
{ NULL } { NULL }
#define LIST_ENTRY(type) \ # define LIST_ENTRY(type) \
struct { \ struct { \
struct type *le_next; /* next element */ \ struct type *le_next; /* next element */ \
struct type **le_prev; /* address of previous next element */ \ struct type **le_prev; /* address of previous next element */ \
@ -378,60 +380,61 @@ struct { \
* List functions. * List functions.
*/ */
#if (defined(_KERNEL) && defined(INVARIANTS)) # if (defined(_KERNEL) && defined(INVARIANTS))
#define QMD_LIST_CHECK_HEAD(head, field) do { \ # define QMD_LIST_CHECK_HEAD(head, field) do { \
if (LIST_FIRST((head)) != NULL && \ if (LIST_FIRST((head)) != NULL && \
LIST_FIRST((head))->field.le_prev != \ LIST_FIRST((head))->field.le_prev != \
&LIST_FIRST((head))) \ &LIST_FIRST((head))) \
panic("Bad list head %p first->prev != head", (head)); \ panic("Bad list head %p first->prev != head", (head)); \
} while (0) } while (0)
#define QMD_LIST_CHECK_NEXT(elm, field) do { \ # define QMD_LIST_CHECK_NEXT(elm, field) do { \
if (LIST_NEXT((elm), field) != NULL && \ if (LIST_NEXT((elm), field) != NULL && \
LIST_NEXT((elm), field)->field.le_prev != \ LIST_NEXT((elm), field)->field.le_prev != \
&((elm)->field.le_next)) \ &((elm)->field.le_next)) \
panic("Bad link elm %p next->prev != elm", (elm)); \ panic("Bad link elm %p next->prev != elm", (elm)); \
} while (0) } while (0)
#define QMD_LIST_CHECK_PREV(elm, field) do { \ # define QMD_LIST_CHECK_PREV(elm, field) do { \
if (*(elm)->field.le_prev != (elm)) \ if (*(elm)->field.le_prev != (elm)) \
panic("Bad link elm %p prev->next != elm", (elm)); \ panic("Bad link elm %p prev->next != elm", (elm)); \
} while (0) } while (0)
#else # else
#define QMD_LIST_CHECK_HEAD(head, field) # define QMD_LIST_CHECK_HEAD(head, field)
#define QMD_LIST_CHECK_NEXT(elm, field) # define QMD_LIST_CHECK_NEXT(elm, field)
#define QMD_LIST_CHECK_PREV(elm, field) # define QMD_LIST_CHECK_PREV(elm, field)
#endif /* (_KERNEL && INVARIANTS) */ # endif
/* (_KERNEL && INVARIANTS) */
#define LIST_EMPTY(head) ((head)->lh_first == NULL) # define LIST_EMPTY(head) ((head)->lh_first == NULL)
#define LIST_FIRST(head) ((head)->lh_first) # define LIST_FIRST(head) ((head)->lh_first)
#define LIST_FOREACH(var, head, field) \ # define LIST_FOREACH(var, head, field) \
for ((var) = LIST_FIRST((head)); \ for ((var) = LIST_FIRST((head)); \
(var); \ (var); \
(var) = LIST_NEXT((var), field)) (var) = LIST_NEXT((var), field))
#define LIST_FOREACH_FROM(var, head, field) \ # define LIST_FOREACH_FROM(var, head, field) \
for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ for ((var) = ((var) ? (var) : LIST_FIRST((head))); \
(var); \ (var); \
(var) = LIST_NEXT((var), field)) (var) = LIST_NEXT((var), field))
#define LIST_FOREACH_SAFE(var, head, field, tvar) \ # define LIST_FOREACH_SAFE(var, head, field, tvar) \
for ((var) = LIST_FIRST((head)); \ for ((var) = LIST_FIRST((head)); \
(var) && ((tvar) = LIST_NEXT((var), field), 1); \ (var) && ((tvar) = LIST_NEXT((var), field), 1); \
(var) = (tvar)) (var) = (tvar))
#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ # define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ for ((var) = ((var) ? (var) : LIST_FIRST((head))); \
(var) && ((tvar) = LIST_NEXT((var), field), 1); \ (var) && ((tvar) = LIST_NEXT((var), field), 1); \
(var) = (tvar)) (var) = (tvar))
#define LIST_INIT(head) do { \ # define LIST_INIT(head) do { \
LIST_FIRST((head)) = NULL; \ LIST_FIRST((head)) = NULL; \
} while (0) } while (0)
#define LIST_INSERT_AFTER(listelm, elm, field) do { \ # define LIST_INSERT_AFTER(listelm, elm, field) do { \
QMD_LIST_CHECK_NEXT(listelm, field); \ QMD_LIST_CHECK_NEXT(listelm, field); \
if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
LIST_NEXT((listelm), field)->field.le_prev = \ LIST_NEXT((listelm), field)->field.le_prev = \
@ -440,7 +443,7 @@ struct { \
(elm)->field.le_prev = &LIST_NEXT((listelm), field); \ (elm)->field.le_prev = &LIST_NEXT((listelm), field); \
} while (0) } while (0)
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ # define LIST_INSERT_BEFORE(listelm, elm, field) do { \
QMD_LIST_CHECK_PREV(listelm, field); \ QMD_LIST_CHECK_PREV(listelm, field); \
(elm)->field.le_prev = (listelm)->field.le_prev; \ (elm)->field.le_prev = (listelm)->field.le_prev; \
LIST_NEXT((elm), field) = (listelm); \ LIST_NEXT((elm), field) = (listelm); \
@ -448,7 +451,7 @@ struct { \
(listelm)->field.le_prev = &LIST_NEXT((elm), field); \ (listelm)->field.le_prev = &LIST_NEXT((elm), field); \
} while (0) } while (0)
#define LIST_INSERT_HEAD(head, elm, field) do { \ # define LIST_INSERT_HEAD(head, elm, field) do { \
QMD_LIST_CHECK_HEAD((head), field); \ QMD_LIST_CHECK_HEAD((head), field); \
if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
@ -456,13 +459,13 @@ struct { \
(elm)->field.le_prev = &LIST_FIRST((head)); \ (elm)->field.le_prev = &LIST_FIRST((head)); \
} while (0) } while (0)
#define LIST_NEXT(elm, field) ((elm)->field.le_next) # define LIST_NEXT(elm, field) ((elm)->field.le_next)
#define LIST_PREV(elm, head, type, field) \ # define LIST_PREV(elm, head, type, field) \
((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \ ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \
__containerof((elm)->field.le_prev, struct type, field.le_next)) __containerof((elm)->field.le_prev, struct type, field.le_next))
#define LIST_REMOVE(elm, field) do { \ # define LIST_REMOVE(elm, field) do { \
QMD_SAVELINK(oldnext, (elm)->field.le_next); \ QMD_SAVELINK(oldnext, (elm)->field.le_next); \
QMD_SAVELINK(oldprev, (elm)->field.le_prev); \ QMD_SAVELINK(oldprev, (elm)->field.le_prev); \
QMD_LIST_CHECK_NEXT(elm, field); \ QMD_LIST_CHECK_NEXT(elm, field); \
@ -475,7 +478,7 @@ struct { \
TRASHIT(*oldprev); \ TRASHIT(*oldprev); \
} while (0) } while (0)
#define LIST_SWAP(head1, head2, type, field) do { \ # define LIST_SWAP(head1, head2, type, field) do { \
struct type *swap_tmp = LIST_FIRST((head1)); \ struct type *swap_tmp = LIST_FIRST((head1)); \
LIST_FIRST((head1)) = LIST_FIRST((head2)); \ LIST_FIRST((head1)) = LIST_FIRST((head2)); \
LIST_FIRST((head2)) = swap_tmp; \ LIST_FIRST((head2)) = swap_tmp; \
@ -488,17 +491,17 @@ struct { \
/* /*
* Tail queue declarations. * Tail queue declarations.
*/ */
#define TAILQ_HEAD(name, type) \ # define TAILQ_HEAD(name, type) \
struct name { \ struct name { \
struct type *tqh_first; /* first element */ \ struct type *tqh_first; /* first element */ \
struct type **tqh_last; /* addr of last next element */ \ struct type **tqh_last; /* addr of last next element */ \
TRACEBUF \ TRACEBUF \
} }
#define TAILQ_HEAD_INITIALIZER(head) \ # define TAILQ_HEAD_INITIALIZER(head) \
{ NULL, &(head).tqh_first, TRACEBUF_INITIALIZER } { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER }
#define TAILQ_ENTRY(type) \ # define TAILQ_ENTRY(type) \
struct { \ struct { \
struct type *tqe_next; /* next element */ \ struct type *tqe_next; /* next element */ \
struct type **tqe_prev; /* address of previous next element */ \ struct type **tqe_prev; /* address of previous next element */ \
@ -508,38 +511,39 @@ struct { \
/* /*
* Tail queue functions. * Tail queue functions.
*/ */
#if (defined(_KERNEL) && defined(INVARIANTS)) # if (defined(_KERNEL) && defined(INVARIANTS))
#define QMD_TAILQ_CHECK_HEAD(head, field) do { \ # define QMD_TAILQ_CHECK_HEAD(head, field) do { \
if (!TAILQ_EMPTY(head) && \ if (!TAILQ_EMPTY(head) && \
TAILQ_FIRST((head))->field.tqe_prev != \ TAILQ_FIRST((head))->field.tqe_prev != \
&TAILQ_FIRST((head))) \ &TAILQ_FIRST((head))) \
panic("Bad tailq head %p first->prev != head", (head)); \ panic("Bad tailq head %p first->prev != head", (head)); \
} while (0) } while (0)
#define QMD_TAILQ_CHECK_TAIL(head, field) do { \ # define QMD_TAILQ_CHECK_TAIL(head, field) do { \
if (*(head)->tqh_last != NULL) \ if (*(head)->tqh_last != NULL) \
panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \ panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \
} while (0) } while (0)
#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \ # define QMD_TAILQ_CHECK_NEXT(elm, field) do { \
if (TAILQ_NEXT((elm), field) != NULL && \ if (TAILQ_NEXT((elm), field) != NULL && \
TAILQ_NEXT((elm), field)->field.tqe_prev != \ TAILQ_NEXT((elm), field)->field.tqe_prev != \
&((elm)->field.tqe_next)) \ &((elm)->field.tqe_next)) \
panic("Bad link elm %p next->prev != elm", (elm)); \ panic("Bad link elm %p next->prev != elm", (elm)); \
} while (0) } while (0)
#define QMD_TAILQ_CHECK_PREV(elm, field) do { \ # define QMD_TAILQ_CHECK_PREV(elm, field) do { \
if (*(elm)->field.tqe_prev != (elm)) \ if (*(elm)->field.tqe_prev != (elm)) \
panic("Bad link elm %p prev->next != elm", (elm)); \ panic("Bad link elm %p prev->next != elm", (elm)); \
} while (0) } while (0)
#else # else
#define QMD_TAILQ_CHECK_HEAD(head, field) # define QMD_TAILQ_CHECK_HEAD(head, field)
#define QMD_TAILQ_CHECK_TAIL(head, headname) # define QMD_TAILQ_CHECK_TAIL(head, headname)
#define QMD_TAILQ_CHECK_NEXT(elm, field) # define QMD_TAILQ_CHECK_NEXT(elm, field)
#define QMD_TAILQ_CHECK_PREV(elm, field) # define QMD_TAILQ_CHECK_PREV(elm, field)
#endif /* (_KERNEL && INVARIANTS) */ # endif
/* (_KERNEL && INVARIANTS) */
#define TAILQ_CONCAT(head1, head2, field) do { \ # define TAILQ_CONCAT(head1, head2, field) do { \
if (!TAILQ_EMPTY(head2)) { \ if (!TAILQ_EMPTY(head2)) { \
*(head1)->tqh_last = (head2)->tqh_first; \ *(head1)->tqh_last = (head2)->tqh_first; \
(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
@ -550,57 +554,57 @@ struct { \
} \ } \
} while (0) } while (0)
#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) # define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
#define TAILQ_FIRST(head) ((head)->tqh_first) # define TAILQ_FIRST(head) ((head)->tqh_first)
#define TAILQ_FOREACH(var, head, field) \ # define TAILQ_FOREACH(var, head, field) \
for ((var) = TAILQ_FIRST((head)); \ for ((var) = TAILQ_FIRST((head)); \
(var); \ (var); \
(var) = TAILQ_NEXT((var), field)) (var) = TAILQ_NEXT((var), field))
#define TAILQ_FOREACH_FROM(var, head, field) \ # define TAILQ_FOREACH_FROM(var, head, field) \
for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \
(var); \ (var); \
(var) = TAILQ_NEXT((var), field)) (var) = TAILQ_NEXT((var), field))
#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ # define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
for ((var) = TAILQ_FIRST((head)); \ for ((var) = TAILQ_FIRST((head)); \
(var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
(var) = (tvar)) (var) = (tvar))
#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ # define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \
(var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
(var) = (tvar)) (var) = (tvar))
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ # define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
for ((var) = TAILQ_LAST((head), headname); \ for ((var) = TAILQ_LAST((head), headname); \
(var); \ (var); \
(var) = TAILQ_PREV((var), headname, field)) (var) = TAILQ_PREV((var), headname, field))
#define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \ # define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \
for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
(var); \ (var); \
(var) = TAILQ_PREV((var), headname, field)) (var) = TAILQ_PREV((var), headname, field))
#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ # define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
for ((var) = TAILQ_LAST((head), headname); \ for ((var) = TAILQ_LAST((head), headname); \
(var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
(var) = (tvar)) (var) = (tvar))
#define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar) \ # define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar) \
for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
(var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
(var) = (tvar)) (var) = (tvar))
#define TAILQ_INIT(head) do { \ # define TAILQ_INIT(head) do { \
TAILQ_FIRST((head)) = NULL; \ TAILQ_FIRST((head)) = NULL; \
(head)->tqh_last = &TAILQ_FIRST((head)); \ (head)->tqh_last = &TAILQ_FIRST((head)); \
QMD_TRACE_HEAD(head); \ QMD_TRACE_HEAD(head); \
} while (0) } while (0)
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ # define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
QMD_TAILQ_CHECK_NEXT(listelm, field); \ QMD_TAILQ_CHECK_NEXT(listelm, field); \
if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
TAILQ_NEXT((elm), field)->field.tqe_prev = \ TAILQ_NEXT((elm), field)->field.tqe_prev = \
@ -615,7 +619,7 @@ struct { \
QMD_TRACE_ELEM(&listelm->field); \ QMD_TRACE_ELEM(&listelm->field); \
} while (0) } while (0)
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ # define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
QMD_TAILQ_CHECK_PREV(listelm, field); \ QMD_TAILQ_CHECK_PREV(listelm, field); \
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
TAILQ_NEXT((elm), field) = (listelm); \ TAILQ_NEXT((elm), field) = (listelm); \
@ -625,7 +629,7 @@ struct { \
QMD_TRACE_ELEM(&listelm->field); \ QMD_TRACE_ELEM(&listelm->field); \
} while (0) } while (0)
#define TAILQ_INSERT_HEAD(head, elm, field) do { \ # define TAILQ_INSERT_HEAD(head, elm, field) do { \
QMD_TAILQ_CHECK_HEAD(head, field); \ QMD_TAILQ_CHECK_HEAD(head, field); \
if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \
TAILQ_FIRST((head))->field.tqe_prev = \ TAILQ_FIRST((head))->field.tqe_prev = \
@ -638,7 +642,7 @@ struct { \
QMD_TRACE_ELEM(&(elm)->field); \ QMD_TRACE_ELEM(&(elm)->field); \
} while (0) } while (0)
#define TAILQ_INSERT_TAIL(head, elm, field) do { \ # define TAILQ_INSERT_TAIL(head, elm, field) do { \
QMD_TAILQ_CHECK_TAIL(head, field); \ QMD_TAILQ_CHECK_TAIL(head, field); \
TAILQ_NEXT((elm), field) = NULL; \ TAILQ_NEXT((elm), field) = NULL; \
(elm)->field.tqe_prev = (head)->tqh_last; \ (elm)->field.tqe_prev = (head)->tqh_last; \
@ -648,15 +652,15 @@ struct { \
QMD_TRACE_ELEM(&(elm)->field); \ QMD_TRACE_ELEM(&(elm)->field); \
} while (0) } while (0)
#define TAILQ_LAST(head, headname) \ # define TAILQ_LAST(head, headname) \
(*(((struct headname *)((head)->tqh_last))->tqh_last)) (*(((struct headname *)((head)->tqh_last))->tqh_last))
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) # define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
#define TAILQ_PREV(elm, headname, field) \ # define TAILQ_PREV(elm, headname, field) \
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
#define TAILQ_REMOVE(head, elm, field) do { \ # define TAILQ_REMOVE(head, elm, field) do { \
QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \ QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \
QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \ QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \
QMD_TAILQ_CHECK_NEXT(elm, field); \ QMD_TAILQ_CHECK_NEXT(elm, field); \
@ -674,7 +678,7 @@ struct { \
QMD_TRACE_ELEM(&(elm)->field); \ QMD_TRACE_ELEM(&(elm)->field); \
} while (0) } while (0)
#define TAILQ_SWAP(head1, head2, type, field) do { \ # define TAILQ_SWAP(head1, head2, type, field) do { \
struct type *swap_first = (head1)->tqh_first; \ struct type *swap_first = (head1)->tqh_first; \
struct type **swap_last = (head1)->tqh_last; \ struct type **swap_last = (head1)->tqh_last; \
(head1)->tqh_first = (head2)->tqh_first; \ (head1)->tqh_first = (head2)->tqh_first; \

View File

@ -2,33 +2,32 @@
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */ /* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */ /* */
typedef struct command typedef struct command
{ {
u8 name[64]; u8 name[64];
u8 params[64]; u8 params[64];
int (*function)() int (*function) ()} command __attribute__ ((packed));
} command __attribute__ ((packed));
int rebootnow(); int rebootnow();
int test2d(); int test2d();
int test3d(); int test3d();
int showidt(); int showidt();
int showgdt(); int showgdt();
int detectcpu(); int detectcpu();
int mode(); int mode();
int clear(); int clear();
int showregs(); int showregs();
int showinfo(); int showinfo();
int err(); int err();
int view(); int view();
int test(void); int test(void);
int disas(u8* commandline); int disas(u8 * commandline);
int bpset(u8* commandline); int bpset(u8 * commandline);
int bpclr(u8* commandline); int bpclr(u8 * commandline);
int sfont(u8* commandline); int sfont(u8 * commandline);
int help(); int help();
int logo(); int logo();
int detectpci(); int detectpci();
int showmem(); int showmem();
int testmem(); int testmem();
int testcall(); int testcall();
int testtask(); int testtask();

View File

@ -2,22 +2,22 @@
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */ /* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */ /* */
#ifndef _VA_LIST_T_H #ifndef _VA_LIST_T_H
#define _VA_LIST_T_H # define _VA_LIST_T_H
#define __GNUC_VA_LIST # define __GNUC_VA_LIST
typedef void *__gnuc_va_list; typedef void *__gnuc_va_list;
#define __va_rounded_size(TYPE) (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) # define __va_rounded_size(TYPE) (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
#define va_start(AP, LASTARG) (AP = ((__gnuc_va_list) __builtin_next_arg (LASTARG))) # define va_start(AP, LASTARG) (AP = ((__gnuc_va_list) __builtin_next_arg (LASTARG)))
void va_end (__gnuc_va_list); void va_end(__gnuc_va_list);
#define va_end(AP) ((void)0) # define va_end(AP) ((void)0)
#define va_arg(AP, TYPE) (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE)))) # define va_arg(AP, TYPE) (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE))))
#define __va_copy(dest, src) (dest) = (src) # define __va_copy(dest, src) (dest) = (src)
typedef __gnuc_va_list va_list; typedef __gnuc_va_list va_list;

View File

@ -3,27 +3,27 @@
/* */ /* */
#include "types.h" #include "types.h"
s8 strcmp(const u8 *src,const u8 *des); s8 strcmp(const u8 * src, const u8 * des);
u32 strlen(const u8 *src); u32 strlen(const u8 * src);
u8 *strchr(const u8 *src, u8 achar); u8 *strchr(const u8 * src, u8 achar);
u8 *strncpy(const u8 *src,u8 *des,u32 count); u8 *strncpy(const u8 * src, u8 * des, u32 count);
u8 *strcat(const u8 *src,u8 *des); u8 *strcat(const u8 * src, u8 * des);
u8 *strcpy(const u8 *src, u8 *des); u8 *strcpy(const u8 * src, u8 * des);
void strtolower(u8 *src); void strtolower(u8 * src);
void strtoupper(u8 *src); void strtoupper(u8 * src);
void stronecase(u8 *src); void stronecase(u8 * src);
void strsetlen(u8 *src, u32 size); void strsetlen(u8 * src, u32 size);
void strinvert(u8 *src); void strinvert(u8 * src);
void strreplace(u8 *src, u8 search, u8 replaced); void strreplace(u8 * src, u8 search, u8 replaced);
u8 *strfill(u8 *dst, u8 pattern, u32 size); u8 *strfill(u8 * dst, u8 pattern, u32 size);
void strright(u8 *src, u8 *dest, u32 size); void strright(u8 * src, u8 * dest, u32 size);
void strleft(u8 *src, u8 *dest, u32 size); void strleft(u8 * src, u8 * dest, u32 size);
void strdelete(u8 *src, u32 index, u32 size); void strdelete(u8 * src, u32 index, u32 size);
void strcompressdelimiter(u8 *src, u8 delim); void strcompressdelimiter(u8 * src, u8 delim);
void strinsert(u8 *src, u8 *dest, u32 index); void strinsert(u8 * src, u8 * dest, u32 index);
u8 *strgetitem(u8 *src, u8 *dest, u8 delim, u32 index); u8 *strgetitem(u8 * src, u8 * dest, u8 delim, u32 index);
u8* strgetpointeritem(u8 *src, u8 delim, u32 index); u8 *strgetpointeritem(u8 * src, u8 delim, u32 index);
u32 strgetnbitems(u8 *src, u8 delim); u32 strgetnbitems(u8 * src, u8 delim);
u8 strgetminbase(u8 *src); u8 strgetminbase(u8 * src);
u8 strgetbase(u8 *src); u8 strgetbase(u8 * src);
u32 strtoint(u8 *src); u32 strtoint(u8 * src);

View File

@ -46,5 +46,5 @@
}) })
/* Vers 6 arguments maximum */ /* Vers 6 arguments maximum */
void initsyscall(void); void initsyscall(void);
void sysenter_handler(void); void sysenter_handler(void);

View File

@ -1,3 +1,4 @@
/*******************************************************************************/ /*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */ /* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */extern restart; /* */
extern restart;

View File

@ -1,4 +1,4 @@
/*******************************************************************************/ /*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */ /* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */ /* */
void timer(void); void timer(void);

View File

@ -1,70 +1,70 @@
/*******************************************************************************/ /*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */ /* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */ /* */
#ifndef ALLTYPES #ifndef ALLTYPES
# define ALLTYPES # define ALLTYPES
typedef char int8; typedef char int8;
typedef short int16; typedef short int16;
typedef int int32; typedef int int32;
typedef long long int64; typedef long long int64;
typedef char BYTE; typedef char BYTE;
typedef short WORD; typedef short WORD;
typedef long DWORD; typedef long DWORD;
typedef long long QWORD; typedef long long QWORD;
typedef signed char SBYTE; typedef signed char SBYTE;
typedef signed short SWORD; typedef signed short SWORD;
typedef signed long SDWORD; typedef signed long SDWORD;
typedef signed long long SQWORD; typedef signed long long SQWORD;
typedef unsigned char UBYTE; typedef unsigned char UBYTE;
typedef unsigned short UWORD; typedef unsigned short UWORD;
typedef unsigned long UDWORD; typedef unsigned long UDWORD;
typedef unsigned long long UQWORD; typedef unsigned long long UQWORD;
typedef unsigned char u8; typedef unsigned char u8;
typedef unsigned short u16; typedef unsigned short u16;
typedef unsigned int u32; typedef unsigned int u32;
typedef unsigned long long int u64; typedef unsigned long long int u64;
typedef char s8; typedef char s8;
typedef short s16; typedef short s16;
typedef int s32; typedef int s32;
typedef long int s64; typedef long int s64;
typedef int bool; typedef int bool;
extern char ctype[]; extern char ctype[];
#define true 1 # define true 1
#define false 0 # define false 0
#define NULL 0x0000 # define NULL 0x0000
#define CT_UP 0x01 /* upper case */ # define CT_UP 0x01 /* upper case */
#define CT_LOW 0x02 /* lower case */ # define CT_LOW 0x02 /* lower case */
#define CT_DIG 0x04 /* digit */ # define CT_DIG 0x04 /* digit */
#define CT_CTL 0x08 /* control */ # define CT_CTL 0x08 /* control */
#define CT_PUN 0x10 /* punctuation */ # define CT_PUN 0x10 /* punctuation */
#define CT_WHT 0x20 /* white space (space/cr/lf/tab) */ # define CT_WHT 0x20 /* white space (space/cr/lf/tab) */
#define CT_HEX 0x40 /* hex digit */ # define CT_HEX 0x40 /* hex digit */
#define CT_SP 0x80 /* hard space (0x20) */ # define CT_SP 0x80 /* hard space (0x20) */
/* without the cast to unsigned, DJGPP complains (using -Wall) */ /* without the cast to unsigned, DJGPP complains (using -Wall) */
#define isalnum(c) ((ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW | CT_DIG)) # define isalnum(c) ((ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW | CT_DIG))
#define isalpha(c) ((ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW)) # define isalpha(c) ((ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW))
#define iscntrl(c) ((ctype + 1)[(unsigned)(c)] & (CT_CTL)) # define iscntrl(c) ((ctype + 1)[(unsigned)(c)] & (CT_CTL))
#define isdigit(c) ((ctype + 1)[(unsigned)(c)] & (CT_DIG)) # define isdigit(c) ((ctype + 1)[(unsigned)(c)] & (CT_DIG))
#define isgraph(c) ((ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG)) # define isgraph(c) ((ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG))
#define islower(c) ((ctype + 1)[(unsigned)(c)] & (CT_LOW)) # define islower(c) ((ctype + 1)[(unsigned)(c)] & (CT_LOW))
#define isprint(c) ((ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG | CT_SP)) # define isprint(c) ((ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG | CT_SP))
#define ispunct(c) ((ctype + 1)[(unsigned)(c)] & (CT_PUN)) # define ispunct(c) ((ctype + 1)[(unsigned)(c)] & (CT_PUN))
#define isspace(c) ((ctype + 1)[(unsigned)(c)] & (CT_WHT)) # define isspace(c) ((ctype + 1)[(unsigned)(c)] & (CT_WHT))
#define isupper(c) ((ctype + 1)[(unsigned)(c)] & (CT_UP)) # define isupper(c) ((ctype + 1)[(unsigned)(c)] & (CT_UP))
#define isxdigit(c) ((ctype + 1)[(unsigned)(c)] & (CT_DIG | CT_HEX)) # define isxdigit(c) ((ctype + 1)[(unsigned)(c)] & (CT_DIG | CT_HEX))
#define isascii(c) ((unsigned)(c) <= 0x7F) # define isascii(c) ((unsigned)(c) <= 0x7F)
#define toascii(c) ((unsigned)(c) & 0x7F) # define toascii(c) ((unsigned)(c) & 0x7F)
#define tolower(c) (isupper(c) ? c + 'a' - 'A' : c) # define tolower(c) (isupper(c) ? c + 'a' - 'A' : c)
#define toupper(c) (islower(c) ? c + 'A' - 'a' : c) # define toupper(c) (islower(c) ? c + 'A' - 'a' : c)
#endif #endif

View File

@ -7,43 +7,43 @@
#define STATE 0x3da #define STATE 0x3da
/* fonction obligatoires */ /* fonction obligatoires */
void VESA_remap_memory(u32 vaddr); void VESA_remap_memory(u32 vaddr);
u8 *VESA_detect_hardware (void); u8 *VESA_detect_hardware(void);
u8 VESA_setvideo_mode (u8 mode); u8 VESA_setvideo_mode(u8 mode);
u8 *VESA_getvideo_drivername (void); u8 *VESA_getvideo_drivername(void);
u8 *VESA_getvideo_capabilities (void); u8 *VESA_getvideo_capabilities(void);
videoinfos *VESA_getvideo_info (void); videoinfos *VESA_getvideo_info(void);
u32 VESA_mem_to_video (void *src,u32 dst, u32 size, bool increment_src); u32 VESA_mem_to_video(void *src, u32 dst, u32 size,
u32 VESA_video_to_mem (u32 src,void *dst, u32 size); bool increment_src);
u32 VESA_video_to_video (u32 src,u32 dst, u32 size); u32 VESA_video_to_mem(u32 src, void *dst, u32 size);
void VESA_wait_vretrace (void); u32 VESA_video_to_video(u32 src, u32 dst, u32 size);
void VESA_wait_hretrace (void); void VESA_wait_vretrace(void);
void VESA_page_set (u8 page); void VESA_wait_hretrace(void);
void VESA_page_show (u8 page); void VESA_page_set(u8 page);
void VESA_dummy (); void VESA_page_show(u8 page);
void VESA_dummy();
static videofonction vesafonctions = static videofonction vesafonctions = {
{ &VESA_remap_memory,
&VESA_remap_memory, &VESA_detect_hardware,
&VESA_detect_hardware, &VESA_setvideo_mode,
&VESA_setvideo_mode, &VESA_getvideo_drivername,
&VESA_getvideo_drivername, &VESA_getvideo_capabilities,
&VESA_getvideo_capabilities, &VESA_getvideo_info,
&VESA_getvideo_info, &VESA_mem_to_video,
&VESA_mem_to_video, &VESA_video_to_mem,
&VESA_video_to_mem, &VESA_video_to_video,
&VESA_video_to_video, &VESA_wait_vretrace,
&VESA_wait_vretrace, &VESA_wait_hretrace,
&VESA_wait_hretrace, &VESA_page_set,
&VESA_page_set, &VESA_page_show,
&VESA_page_show, &VESA_dummy,
&VESA_dummy, &VESA_dummy,
&VESA_dummy, &VESA_dummy,
&VESA_dummy, &VESA_dummy,
&VESA_dummy, &VESA_dummy,
&VESA_dummy, &VESA_dummy,
&VESA_dummy, &VESA_dummy,
&VESA_dummy, &VESA_dummy,
&VESA_dummy, &VESA_dummy
&VESA_dummy
}; };

View File

@ -4,8 +4,8 @@
#include "types.h" #include "types.h"
#include "video.h" #include "video.h"
#define TEXTSCREEN 0xB8000 /* debut de la memoire video texte*/ #define TEXTSCREEN 0xB8000 /* debut de la memoire video texte */
#define GRPHSCREEN 0xA0000 /* debut de la memoire video graphique*/ #define GRPHSCREEN 0xA0000 /* debut de la memoire video graphique */
#define ENDOFVMEM 0xC0000 #define ENDOFVMEM 0xC0000
/* Registres VGAs */ /* Registres VGAs */
@ -23,121 +23,126 @@
#define PLANESIZE 0x10000 #define PLANESIZE 0x10000
/* Registres VGA */ /* Registres VGA */
typedef struct misc_regs { typedef struct misc_regs
u8 Miscellaneous_Output_Register; {
u8 Miscellaneous_Output_Register;
} misc_regs __attribute__ ((packed)); } misc_regs __attribute__ ((packed));
typedef struct sequencer_regs { typedef struct sequencer_regs
u8 Reset_Register; {
u8 Clocking_Mode_Register; u8 Reset_Register;
u8 Map_Mask_Register; u8 Clocking_Mode_Register;
u8 Character_Map_Select_Register; u8 Map_Mask_Register;
u8 Sequencer_Memory_Mode_Register; u8 Character_Map_Select_Register;
u8 Sequencer_Memory_Mode_Register;
} sequencer_regs __attribute__ ((packed)); } sequencer_regs __attribute__ ((packed));
typedef struct crtc_regs { typedef struct crtc_regs
u8 Horizontal_Total_Register; {
u8 End_Horizontal_Display_Register; u8 Horizontal_Total_Register;
u8 Start_Horizontal_Blanking_Register; u8 End_Horizontal_Display_Register;
u8 End_Horizontal_Blanking_Register; u8 Start_Horizontal_Blanking_Register;
u8 Start_Horizontal_Retrace_Register; u8 End_Horizontal_Blanking_Register;
u8 End_Horizontal_Retrace_Register; u8 Start_Horizontal_Retrace_Register;
u8 Vertical_Total_Register; u8 End_Horizontal_Retrace_Register;
u8 Overflow_Register; u8 Vertical_Total_Register;
u8 Preset_Row_Scan_Register; u8 Overflow_Register;
u8 Maximum_Scan_Line_Register; u8 Preset_Row_Scan_Register;
u8 Cursor_Start_Register; u8 Maximum_Scan_Line_Register;
u8 Cursor_End_Register; u8 Cursor_Start_Register;
u8 Start_Address_High_Register; u8 Cursor_End_Register;
u8 Start_Address_Low_Register; u8 Start_Address_High_Register;
u8 Cursor_Location_High_Register; u8 Start_Address_Low_Register;
u8 Cursor_Location_Low_Register; u8 Cursor_Location_High_Register;
u8 Vertical_Retrace_Start_Register; u8 Cursor_Location_Low_Register;
u8 Vertical_Retrace_End_Register; u8 Vertical_Retrace_Start_Register;
u8 Vertical_Display_End_Register; u8 Vertical_Retrace_End_Register;
u8 Offset_Register; u8 Vertical_Display_End_Register;
u8 Underline_Location_Register; u8 Offset_Register;
u8 Start_Vertical_Blanking_Register; u8 Underline_Location_Register;
u8 End_Vertical_Blanking; u8 Start_Vertical_Blanking_Register;
u8 CRTC_Mode_Control_Register; u8 End_Vertical_Blanking;
u8 Line_Compare_Register; u8 CRTC_Mode_Control_Register;
u8 Line_Compare_Register;
} crtc_regs __attribute__ ((packed)); } crtc_regs __attribute__ ((packed));
typedef struct graphics_regs { typedef struct graphics_regs
u8 Set_Reset_Register; {
u8 Enable_Set_Reset_Register; u8 Set_Reset_Register;
u8 Color_Compare_Register; u8 Enable_Set_Reset_Register;
u8 Data_Rotate_Register; u8 Color_Compare_Register;
u8 Read_Map_Select_Register; u8 Data_Rotate_Register;
u8 Graphics_Mode_Register; u8 Read_Map_Select_Register;
u8 Miscellaneous_Graphics_Register; u8 Graphics_Mode_Register;
u8 Color_Dont_Care_Register; u8 Miscellaneous_Graphics_Register;
u8 Bit_Mask_Register; u8 Color_Dont_Care_Register;
u8 Bit_Mask_Register;
} graphics_regs __attribute__ ((packed)); } graphics_regs __attribute__ ((packed));
typedef struct attributs_regs { typedef struct attributs_regs
u8 Palette_Registers[16]; {
u8 Attribute_Mode_Control_Register; u8 Palette_Registers[16];
u8 Overscan_Color_Register; u8 Attribute_Mode_Control_Register;
u8 Color_Plane_Enable_Register; u8 Overscan_Color_Register;
u8 Horizontal_Pixel_Panning_Register; u8 Color_Plane_Enable_Register;
u8 Color_Select_Register; u8 Horizontal_Pixel_Panning_Register;
u8 Color_Select_Register;
} attributs_regs __attribute__ ((packed)); } attributs_regs __attribute__ ((packed));
typedef struct vgamode { typedef struct vgamode
misc_regs misc; {
sequencer_regs sequencer; misc_regs misc;
crtc_regs ctrc; sequencer_regs sequencer;
graphics_regs graphic; crtc_regs ctrc;
attributs_regs attribut; graphics_regs graphic;
attributs_regs attribut;
} vgamode __attribute__ ((packed)); } vgamode __attribute__ ((packed));
/* fonction obligatoires */ /* fonction obligatoires */
void VGA_remap_memory(u32 vaddr); void VGA_remap_memory(u32 vaddr);
u8 *VGA_detect_hardware (void); u8 *VGA_detect_hardware(void);
u8 VGA_setvideo_mode (u8 mode); u8 VGA_setvideo_mode(u8 mode);
u8 *VGA_getvideo_drivername (void); u8 *VGA_getvideo_drivername(void);
u8 *VGA_getvideo_capabilities (void); u8 *VGA_getvideo_capabilities(void);
videoinfos *VGA_getvideo_info (void); videoinfos *VGA_getvideo_info(void);
u32 VGA_mem_to_video (void *src,u32 dst, u32 size, bool increment_src); u32 VGA_mem_to_video(void *src, u32 dst, u32 size, bool increment_src);
u32 VGA_video_to_mem (u32 src,void *dst, u32 size); u32 VGA_video_to_mem(u32 src, void *dst, u32 size);
u32 VGA_video_to_video (u32 src,u32 dst, u32 size); u32 VGA_video_to_video(u32 src, u32 dst, u32 size);
void VGA_wait_vretrace (void); void VGA_wait_vretrace(void);
void VGA_wait_hretrace (void); void VGA_wait_hretrace(void);
void VGA_page_set (u8 page); void VGA_page_set(u8 page);
void VGA_page_show (u8 page); void VGA_page_show(u8 page);
void VGA_page_split (u16 y); void VGA_page_split(u16 y);
void VGA_cursor_enable (void); void VGA_cursor_enable(void);
void VGA_cursor_disable (void); void VGA_cursor_disable(void);
void VGA_cursor_set (u16 x,u16 y); void VGA_cursor_set(u16 x, u16 y);
u32 VGA_font_load (u8 * def, u8 size, u8 font); u32 VGA_font_load(u8 * def, u8 size, u8 font);
void VGA_font1_set (u8 num); void VGA_font1_set(u8 num);
void VGA_font2_set (u8 num); void VGA_font2_set(u8 num);
void VGA_blink_enable (void); void VGA_blink_enable(void);
void VGA_blink_disable (void); void VGA_blink_disable(void);
static videofonction vgafonctions = static videofonction vgafonctions = {
{ &VGA_remap_memory,
&VGA_remap_memory, &VGA_detect_hardware,
&VGA_detect_hardware, &VGA_setvideo_mode,
&VGA_setvideo_mode, &VGA_getvideo_drivername,
&VGA_getvideo_drivername, &VGA_getvideo_capabilities,
&VGA_getvideo_capabilities, &VGA_getvideo_info,
&VGA_getvideo_info, &VGA_mem_to_video,
&VGA_mem_to_video, &VGA_video_to_mem,
&VGA_video_to_mem, &VGA_video_to_video,
&VGA_video_to_video, &VGA_wait_vretrace,
&VGA_wait_vretrace, &VGA_wait_hretrace,
&VGA_wait_hretrace, &VGA_page_set,
&VGA_page_set, &VGA_page_show,
&VGA_page_show, &VGA_page_split,
&VGA_page_split, &VGA_cursor_enable,
&VGA_cursor_enable, &VGA_cursor_disable,
&VGA_cursor_disable, &VGA_cursor_set,
&VGA_cursor_set, &VGA_font_load,
&VGA_font_load, &VGA_font1_set,
&VGA_font1_set, &VGA_font2_set,
&VGA_font2_set, &VGA_blink_enable,
&VGA_blink_enable, &VGA_blink_disable
&VGA_blink_disable
}; };

View File

@ -3,175 +3,186 @@
/* */ /* */
#ifndef VIDEO #ifndef VIDEO
# define VIDEO # define VIDEO
#include "stdarg.h" # include "stdarg.h"
#define MAXDRIVERS 10 # define MAXDRIVERS 10
#define MAXFONTS 10 # define MAXFONTS 10
typedef struct vertex2d{ typedef struct vertex2d
s16 x; {
s16 y; s16 x;
s16 y;
} vertex2d __attribute__ ((packed)); } vertex2d __attribute__ ((packed));
typedef struct rgbcolor { typedef struct rgbcolor
u8 R; {
u8 G; u8 R;
u8 B; u8 G;
u8 B;
} rgbcolor __attribute__ ((packed)); } rgbcolor __attribute__ ((packed));
typedef struct videoinfos { typedef struct videoinfos
u8 currentmode; {
u16 currentwidth; u8 currentmode;
u16 currentheight; u16 currentwidth;
u8 currentdepth; u16 currentheight;
u8 currentactivepage; u8 currentdepth;
u8 currentshowedpage; u8 currentactivepage;
u16 currentcursorX; u8 currentshowedpage;
u16 currentcursorY; u16 currentcursorX;
u8 currentfont1; u16 currentcursorY;
u8 currentfont2; u8 currentfont1;
u16 currentpitch; u8 currentfont2;
bool isgraphic; u16 currentpitch;
bool isblinking; bool isgraphic;
bool iscursorvisible; bool isblinking;
u8 pagesnumber; bool iscursorvisible;
u32 pagesize; u8 pagesnumber;
u32 baseaddress; u32 pagesize;
u32 baseaddress;
} videoinfos __attribute__ ((packed)); } videoinfos __attribute__ ((packed));
typedef struct videofonction { typedef struct videofonction
void (*remap_memory)(); {
u8 *(*detect_hardware)(); void (*remap_memory) ();
u8 (*setvideo_mode) (); u8 *(*detect_hardware) ();
u8 *(*getvideo_drivername) (); u8(*setvideo_mode) ();
u8 *(*getvideo_capabilities) (); u8 *(*getvideo_drivername) ();
videoinfos *(*getvideo_info) (); u8 *(*getvideo_capabilities) ();
u32 (*mem_to_video) (); videoinfos *(*getvideo_info) ();
u32 (*video_to_mem) (); u32(*mem_to_video) ();
u32 (*video_to_video) (); u32(*video_to_mem) ();
void (*wait_vretrace) (); u32(*video_to_video) ();
void (*wait_hretrace) (); void (*wait_vretrace) ();
void (*page_set) (); void (*wait_hretrace) ();
void (*page_show) (); void (*page_set) ();
void (*page_split) (); void (*page_show) ();
void (*cursor_enable) (); void (*page_split) ();
void (*cursor_disable) (); void (*cursor_enable) ();
void (*cursor_set) (); void (*cursor_disable) ();
u32 (*font_load) (); void (*cursor_set) ();
void (*font1_set) (); u32(*font_load) ();
void (*font2_set) (); void (*font1_set) ();
void (*blink_enable) (); void (*font2_set) ();
void (*blink_disable) (); void (*blink_enable) ();
void (*blink_disable) ();
} videofonction __attribute__ ((packed)); } videofonction __attribute__ ((packed));
typedef struct drivers { typedef struct drivers
u8* nom; {
videofonction* pointer; u8 *nom;
videofonction *pointer;
} drivers __attribute__ ((packed)); } drivers __attribute__ ((packed));
typedef struct font { typedef struct font
u8 nom[8]; {
u8* pointer; u8 nom[8];
u8 width; u8 *pointer;
u8 height; u8 width;
u8 height;
} font __attribute__ ((packed)); } font __attribute__ ((packed));
typedef struct capabilities { typedef struct capabilities
u8 modenumber; {
u16 width; u8 modenumber;
u16 height; u16 width;
bool graphic; u16 height;
u8 depth; bool graphic;
u8 refresh; u8 depth;
u8 refresh;
} capabilities __attribute__ ((packed)); } capabilities __attribute__ ((packed));
typedef struct console { typedef struct console
u8 attrib; {
s16 cursX; u8 attrib;
s16 cursY; s16 cursX;
u8 ansi; s16 cursY;
u8 param1; u8 ansi;
u8 param2; u8 param1;
u8 param3; u8 param2;
u8 page; u8 param3;
bool scroll; u8 page;
} console __attribute__ ((packed)); bool scroll;
} console __attribute__ ((packed));
/* Fonctions de bas niveau */ /* Fonctions de bas niveau */
void fill(u8 attrib); void fill(u8 attrib);
void scroll (u8 lines, u8 attrib); void scroll(u8 lines, u8 attrib);
void scroll_enable(void); void scroll_enable(void);
void scroll_disable(void); void scroll_disable(void);
void showchar (u16 coordx, u16 coordy, u8 thechar, u8 attrib); void showchar(u16 coordx, u16 coordy, u8 thechar, u8 attrib);
u8 getchar (u16 coordx, u16 coordy); u8 getchar(u16 coordx, u16 coordy);
u8 getattrib (u16 coordx, u16 coordy); u8 getattrib(u16 coordx, u16 coordy);
void v_writepxl (vertex2d *A, u32 color); void v_writepxl(vertex2d * A, u32 color);
void writepxl (s16 x, s16 y, u32 color); void writepxl(s16 x, s16 y, u32 color);
void line(s16 x1, s16 y1, s16 x2, s16 y2, u32 color); void line(s16 x1, s16 y1, s16 x2, s16 y2, u32 color);
void hline(s16 x1, s16 x2, s16 y, u32 color); void hline(s16 x1, s16 x2, s16 y, u32 color);
void changemode(u8 mode); void changemode(u8 mode);
u32 egatorgb(u8 ega); u32 egatorgb(u8 ega);
u8 egatovga(u8 ega); u8 egatovga(u8 ega);
void v_line(vertex2d *A, vertex2d *B, u32 color); void v_line(vertex2d * A, vertex2d * B, u32 color);
void trianglefilled(vertex2d *A, vertex2d *B, vertex2d *C, u32 color); void trianglefilled(vertex2d * A, vertex2d * B, vertex2d * C,
void triangle(vertex2d *A, vertex2d *B, vertex2d *C, u32 color); u32 color);
void triangle(vertex2d * A, vertex2d * B, vertex2d * C, u32 color);
/* Fonctions de console */ /* Fonctions de console */
void changevc(u8 vc); void changevc(u8 vc);
void putchar(u8 thechar); void putchar(u8 thechar);
void clearscreen(void); void clearscreen(void);
u16 getwidth(void); u16 getwidth(void);
u16 getheight(void); u16 getheight(void);
void loadfont(u8 *name,font* pointer,u8 width, u8 height); void loadfont(u8 * name, font * pointer, u8 width, u8 height);
void setfont(u8 *fontname); void setfont(u8 * fontname);
/* Fonctions de haut niveau */ /* Fonctions de haut niveau */
u32 print(u8* string); u32 print(u8 * string);
u32 printf (const u8 *string, ...); u32 printf(const u8 * string, ...);
u32 sprintf(u8 *variable, const u8 *string, ...); u32 sprintf(u8 * variable, const u8 * string, ...);
u32 snprintf(u8 *variable, u32 maxsize, const u8 *string, ...); u32 snprintf(u8 * variable, u32 maxsize, const u8 * string, ...);
u32 vprintf(const u8 * string, va_list args); u32 vprintf(const u8 * string, va_list args);
u32 vsprintf(u8 *variable, const u8 *string, va_list args); u32 vsprintf(u8 * variable, const u8 * string, va_list args);
u32 vsnprintf(u8 *variable, u32 maxsize, const u8 *string, va_list args); u32 vsnprintf(u8 * variable, u32 maxsize, const u8 * string,
va_list args);
u8* itoa(u64 num, u8* str, u8 base, u64 dim, u8 achar); u8 *itoa(u64 num, u8 * str, u8 base, u64 dim, u8 achar);
u8* sitoa(u64 num, u8 * str, u64 dim); u8 *sitoa(u64 num, u8 * str, u64 dim);
u8* rtoadouble(double num, u8 * str, u8 precisioni , u8 precisionf); u8 *rtoadouble(double num, u8 * str, u8 precisioni, u8 precisionf);
u8* rtoasingle(float num, u8 * str, u8 precisioni , u8 precisionf); u8 *rtoasingle(float num, u8 * str, u8 precisioni, u8 precisionf);
u32 format(const u8 * string, va_list args, u32 maxsize, u32 (*fonction)(u8* src, u8** dest, u32 len), u8* dest); u32 format(const u8 * string, va_list args, u32 maxsize,
u32(*fonction) (u8 * src, u8 ** dest, u32 len), u8 * dest);
/* Fonction pour gérer le pilote */ /* Fonction pour gérer le pilote */
void initdriver(); void initdriver();
void registerdriver(videofonction *pointer); void registerdriver(videofonction * pointer);
void apply_bestdriver(void); void apply_bestdriver(void);
void apply_nextdriver(void); void apply_nextdriver(void);
void apply_driver(u8* name); void apply_driver(u8 * name);
void apply_nextvideomode(void); void apply_nextvideomode(void);
/* Fonctions du pilote */ /* Fonctions du pilote */
void (*remap_memory) (u32 vaddr); void (*remap_memory) (u32 vaddr);
u8 *(*detect_hardware) (void); u8 *(*detect_hardware) (void);
u8 (*setvideo_mode) (u8 mode); u8(*setvideo_mode) (u8 mode);
u8 *(*getvideo_drivername) (void); u8 *(*getvideo_drivername) (void);
u8 *(*getvideo_capabilities) (void); u8 *(*getvideo_capabilities) (void);
videoinfos *(*getvideo_info) (void); videoinfos *(*getvideo_info) (void);
u32 (*mem_to_video) (void *src,u32 dst, u32 size, bool increment_src); u32(*mem_to_video) (void *src, u32 dst, u32 size, bool increment_src);
u32 (*video_to_mem) (u32 src,void *dst, u32 size); u32(*video_to_mem) (u32 src, void *dst, u32 size);
u32 (*video_to_video) (u32 src,u32 dst, u32 size); u32(*video_to_video) (u32 src, u32 dst, u32 size);
void (*wait_vretrace) (void); void (*wait_vretrace) (void);
void (*wait_hretrace) (void); void (*wait_hretrace) (void);
void (*page_set) (u8 page); void (*page_set) (u8 page);
void (*page_show) (u8 page); void (*page_show) (u8 page);
void (*page_split) (u16 y); void (*page_split) (u16 y);
void (*cursor_enable) (void); void (*cursor_enable) (void);
void (*cursor_disable) (void); void (*cursor_disable) (void);
void (*cursor_set) (u16 x,u16 y); void (*cursor_set) (u16 x, u16 y);
u32 (*font_load) (u8 * def, u8 size, u8 font); u32(*font_load) (u8 * def, u8 size, u8 font);
void (*font1_set) (u8 num); void (*font1_set) (u8 num);
void (*font2_set) (u8 num); void (*font2_set) (u8 num);
void (*blink_enable) (void); void (*blink_enable) (void);
void (*blink_disable) (void); void (*blink_disable) (void);
#endif #endif

51344
lib/3D/man.c

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

473
lib/3d.c
View File

@ -8,248 +8,273 @@
/*******************************************************************************/ /*******************************************************************************/
/* Crée une projection simple pour test */ /* Crée une projection simple pour test */
void proj(vector4 list[], vertex2d plane[], vector4 origin[], u16 number, float factor) void proj(vector4 list[], vertex2d plane[], vector4 origin[], u16 number,
float factor)
{ {
for (u32 i=0;i<number;i++) for (u32 i = 0; i < number; i++)
{ {
plane[i].x=(int)((list[i].x*factor)/(list[i].z+origin->z)+origin->x); plane[i].x =
plane[i].y=(int)((list[i].y*factor)/(list[i].z+origin->z)+origin->y); (int) ((list[i].x * factor) /
} (list[i].z + origin->z) + origin->x);
plane[i].y =
(int) ((list[i].y * factor) /
(list[i].z + origin->z) + origin->y);
}
} }
/*******************************************************************************/ /*******************************************************************************/
/* Crée une liste de vertex3D pour un cube */ /* Crée une liste de vertex3D pour un cube */
void cube(model3d *model, vector4 *origin, u16 size) void cube(model3d * model, vector4 * origin, u16 size)
{ {
strcpy("cube",model->name); strcpy("cube", model->name);
model->vertexnb=8; model->vertexnb = 8;
model->vertexlist=0x00300000; model->vertexlist = 0x00300000;
model->vertexlist[0].x=origin->x; model->vertexlist[0].x = origin->x;
model->vertexlist[0].y=origin->y; model->vertexlist[0].y = origin->y;
model->vertexlist[0].z=origin->z; model->vertexlist[0].z = origin->z;
model->vertexlist[0].w=1.0f; model->vertexlist[0].w = 1.0f;
model->vertexlist[1].x=origin->x+size; model->vertexlist[1].x = origin->x + size;
model->vertexlist[1].y=origin->y; model->vertexlist[1].y = origin->y;
model->vertexlist[1].z=origin->z; model->vertexlist[1].z = origin->z;
model->vertexlist[1].w=1.0f; model->vertexlist[1].w = 1.0f;
model->vertexlist[2].x=origin->x; model->vertexlist[2].x = origin->x;
model->vertexlist[2].y=origin->y+size; model->vertexlist[2].y = origin->y + size;
model->vertexlist[2].z=origin->z; model->vertexlist[2].z = origin->z;
model->vertexlist[2].w=1.0f; model->vertexlist[2].w = 1.0f;
model->vertexlist[3].x=origin->x+size; model->vertexlist[3].x = origin->x + size;
model->vertexlist[3].y=origin->y+size; model->vertexlist[3].y = origin->y + size;
model->vertexlist[3].z=origin->z; model->vertexlist[3].z = origin->z;
model->vertexlist[3].w=1.0f; model->vertexlist[3].w = 1.0f;
model->vertexlist[4].x=origin->x; model->vertexlist[4].x = origin->x;
model->vertexlist[4].y=origin->y; model->vertexlist[4].y = origin->y;
model->vertexlist[4].z=origin->z+size; model->vertexlist[4].z = origin->z + size;
model->vertexlist[4].w=1.0f; model->vertexlist[4].w = 1.0f;
model->vertexlist[5].x=origin->x+size; model->vertexlist[5].x = origin->x + size;
model->vertexlist[5].y=origin->y; model->vertexlist[5].y = origin->y;
model->vertexlist[5].z=origin->z+size; model->vertexlist[5].z = origin->z + size;
model->vertexlist[5].w=1.0f; model->vertexlist[5].w = 1.0f;
model->vertexlist[6].x=origin->x; model->vertexlist[6].x = origin->x;
model->vertexlist[6].y=origin->y+size; model->vertexlist[6].y = origin->y + size;
model->vertexlist[6].z=origin->z+size; model->vertexlist[6].z = origin->z + size;
model->vertexlist[6].w=1.0f; model->vertexlist[6].w = 1.0f;
model->vertexlist[7].x=origin->x+size; model->vertexlist[7].x = origin->x + size;
model->vertexlist[7].y=origin->y+size; model->vertexlist[7].y = origin->y + size;
model->vertexlist[7].z=origin->z+size; model->vertexlist[7].z = origin->z + size;
model->vertexlist[7].w=1.0f; model->vertexlist[7].w = 1.0f;
model->facelist=0x00310000; model->facelist = 0x00310000;
model->facelist[0].V1=0; model->facelist[0].V1 = 0;
model->facelist[0].V2=1; model->facelist[0].V2 = 1;
model->facelist[0].V3=3; model->facelist[0].V3 = 3;
model->facelist[1].V1=0; model->facelist[1].V1 = 0;
model->facelist[1].V2=2; model->facelist[1].V2 = 2;
model->facelist[1].V3=3; model->facelist[1].V3 = 3;
model->facelist[2].V1=4; model->facelist[2].V1 = 4;
model->facelist[2].V2=5; model->facelist[2].V2 = 5;
model->facelist[2].V3=7; model->facelist[2].V3 = 7;
model->facelist[3].V1=4; model->facelist[3].V1 = 4;
model->facelist[3].V2=6; model->facelist[3].V2 = 6;
model->facelist[3].V3=7; model->facelist[3].V3 = 7;
model->facelist[4].V1=0; model->facelist[4].V1 = 0;
model->facelist[4].V2=1; model->facelist[4].V2 = 1;
model->facelist[4].V3=5; model->facelist[4].V3 = 5;
model->facelist[5].V1=0; model->facelist[5].V1 = 0;
model->facelist[5].V2=1; model->facelist[5].V2 = 1;
model->facelist[5].V3=4; model->facelist[5].V3 = 4;
model->facelist[6].V1=0; model->facelist[6].V1 = 0;
model->facelist[6].V2=0; model->facelist[6].V2 = 0;
model->facelist[6].V3=0; model->facelist[6].V3 = 0;
model->facelist[7].V1=0; model->facelist[7].V1 = 0;
model->facelist[7].V2=0; model->facelist[7].V2 = 0;
model->facelist[7].V3=0; model->facelist[7].V3 = 0;
model->facelist[8].V1=0; model->facelist[8].V1 = 0;
model->facelist[8].V2=0; model->facelist[8].V2 = 0;
model->facelist[8].V3=0; model->facelist[8].V3 = 0;
model->facelist[9].V1=0; model->facelist[9].V1 = 0;
model->facelist[9].V2=0; model->facelist[9].V2 = 0;
model->facelist[9].V3=0; model->facelist[9].V3 = 0;
model->facelist[10].V1=0; model->facelist[10].V1 = 0;
model->facelist[10].V2=0; model->facelist[10].V2 = 0;
model->facelist[10].V3=0; model->facelist[10].V3 = 0;
model->facelist[11].V1=0; model->facelist[11].V1 = 0;
model->facelist[11].V2=0; model->facelist[11].V2 = 0;
model->facelist[11].V3=0; model->facelist[11].V3 = 0;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Affiche un modèle 3D */ /* Affiche un modèle 3D */
void show3dmodel(model3d *model, matrix44 *transformation, vector4 origin[], float factor, type3D type) void show3dmodel(model3d * model, matrix44 * transformation,
vector4 origin[], float factor, type3D type)
{ {
u16 i; u16 i;
vertex2d *plane=0x00250000; vertex2d *plane = 0x00250000;
for (i = 0; i < model->vertexnb; i++) for (i = 0; i < model->vertexnb; i++)
{ {
matrix44_transform(transformation, &model->vertexlist[i]); matrix44_transform(transformation, &model->vertexlist[i]);
} }
proj(model->vertexlist, plane, origin, model->vertexnb, factor); proj(model->vertexlist, plane, origin, model->vertexnb, factor);
switch (type) { switch (type)
case TYPE3D_POINTS: {
for(i=0;i<model->vertexnb;i++) { case TYPE3D_POINTS:
v_writepxl(&plane[i], egatorgb(4)); for (i = 0; i < model->vertexnb; i++)
} {
break; v_writepxl(&plane[i], egatorgb(4));
case TYPE3D_LINES: }
for(i=0;i<model->facenb;i++) { break;
v_line(&plane[model->facelist[i].V1], &plane[model->facelist[i].V2], egatorgb(4)); case TYPE3D_LINES:
v_line(&plane[model->facelist[i].V1], &plane[model->facelist[i].V3], egatorgb(4)); for (i = 0; i < model->facenb; i++)
v_line(&plane[model->facelist[i].V2], &plane[model->facelist[i].V3], egatorgb(4)); {
} v_line(&plane[model->facelist[i].V1],
break; &plane[model->facelist[i].V2],
case TYPE3D_FACES: egatorgb(4));
break; v_line(&plane[model->facelist[i].V1],
case TYPE3D_FLAT: &plane[model->facelist[i].V3],
break; egatorgb(4));
case TYPE3D_TEXTURE: v_line(&plane[model->facelist[i].V2],
break; &plane[model->facelist[i].V3],
} egatorgb(4));
}
break;
case TYPE3D_FACES:
break;
case TYPE3D_FLAT:
break;
case TYPE3D_TEXTURE:
break;
}
} }
/*******************************************************************************/ /*******************************************************************************/
/* Charge un fichier 3DS */ /* Charge un fichier 3DS */
int load3ds(u8 *pointer,u32 size, model3d *model) int load3ds(u8 * pointer, u32 size, model3d * model)
{ {
u8 *ptr=pointer; u8 *ptr = pointer;
u16 chunk_id; u16 chunk_id;
u32 chunk_size; u32 chunk_size;
u16 i; u16 i;
float *listfloat; float *listfloat;
u16 *listunsigned; u16 *listunsigned;
dsState state=DS_READ_CHUNK_ID; dsState state = DS_READ_CHUNK_ID;
bool dsfile=false; bool dsfile = false;
while(ptr-pointer<size) { while (ptr - pointer < size)
switch(state) {
switch (state)
{ {
case DS_READ_CHUNK_ID: case DS_READ_CHUNK_ID:
chunk_id=*((u16*) ptr); chunk_id = *((u16 *) ptr);
ptr+=2; ptr += 2;
state=DS_READ_CHUNK_LENGTH; state = DS_READ_CHUNK_LENGTH;
break; break;
case DS_READ_CHUNK_LENGTH: case DS_READ_CHUNK_LENGTH:
chunk_size=*((u32*) ptr); chunk_size = *((u32 *) ptr);
ptr+=4; ptr += 4;
switch(chunk_id) switch (chunk_id)
{ {
case MAIN3DS: case MAIN3DS:
dsfile=true; dsfile = true;
ptr+=10; ptr += 10;
state=DS_READ_CHUNK_ID; state = DS_READ_CHUNK_ID;
break; break;
case EDIT3DS: case EDIT3DS:
state=DS_READ_CHUNK_ID; state = DS_READ_CHUNK_ID;
break; break;
case OBJ_TRIMESH: case OBJ_TRIMESH:
state=DS_READ_CHUNK_ID; state = DS_READ_CHUNK_ID;
break; break;
case EDIT_OBJECT: case EDIT_OBJECT:
state=DS_READ_OBJECT_NAME; state = DS_READ_OBJECT_NAME;
break; break;
case TRI_VERTEXL: case TRI_VERTEXL:
state=DS_READ_POINT_COUNT; state = DS_READ_POINT_COUNT;
break; break;
case TRI_FACEL1: case TRI_FACEL1:
state=DS_READ_FACE_COUNT; state = DS_READ_FACE_COUNT;
break; break;
case TRI_LOCAL: case TRI_LOCAL:
state=DS_READ_MATRIX; state = DS_READ_MATRIX;
break; break;
default: default:
if (!dsfile) return 1; if (!dsfile)
ptr+=(chunk_size-6); return 1;
state=DS_READ_CHUNK_ID; ptr += (chunk_size - 6);
break; state = DS_READ_CHUNK_ID;
} break;
break; }
case DS_READ_OBJECT_NAME: break;
strcpy(ptr, model->name); case DS_READ_OBJECT_NAME:
ptr+=(strlen(ptr)+1); strcpy(ptr, model->name);
state=DS_READ_CHUNK_ID; ptr += (strlen(ptr) + 1);
break; state = DS_READ_CHUNK_ID;
case DS_SKIP_CHUNK: break;
break; case DS_SKIP_CHUNK:
case DS_READ_POINT_COUNT: break;
model->vertexnb=*((u16*) ptr); case DS_READ_POINT_COUNT:
state=DS_READ_POINTS; model->vertexnb = *((u16 *) ptr);
ptr+=2; state = DS_READ_POINTS;
break; ptr += 2;
case DS_READ_POINTS: break;
i=0; case DS_READ_POINTS:
listfloat=ptr; i = 0;
model->vertexlist=0x00300000; listfloat = ptr;
while(i<model->vertexnb) model->vertexlist = 0x00300000;
{ while (i < model->vertexnb)
model->vertexlist[i].x=*(listfloat++); {
model->vertexlist[i].y=*(listfloat++); model->vertexlist[i].x =
model->vertexlist[i].z=*(listfloat++); *(listfloat++);
model->vertexlist[i++].w=1.0; model->vertexlist[i].y =
} *(listfloat++);
ptr=listfloat; model->vertexlist[i].z =
state=DS_READ_CHUNK_ID; *(listfloat++);
break; model->vertexlist[i++].w = 1.0;
case DS_READ_FACE_COUNT: }
model->facenb=*((u16*) ptr); ptr = listfloat;
state=DS_READ_FACES; state = DS_READ_CHUNK_ID;
ptr+=2; break;
break; case DS_READ_FACE_COUNT:
case DS_READ_FACES: model->facenb = *((u16 *) ptr);
i=0; state = DS_READ_FACES;
listunsigned=ptr; ptr += 2;
model->facelist=0x00400000; break;
while(i<model->facenb) case DS_READ_FACES:
{ i = 0;
model->facelist[i].V1=*(listunsigned++); listunsigned = ptr;
model->facelist[i].V2=*(listunsigned++); model->facelist = 0x00400000;
model->facelist[i++].V3=*(listunsigned++); while (i < model->facenb)
listunsigned++; {
} model->facelist[i].V1 =
ptr=listunsigned; *(listunsigned++);
state=DS_READ_CHUNK_ID; model->facelist[i].V2 =
break; *(listunsigned++);
case DS_READ_MATRIX: model->facelist[i++].V3 =
i=0; *(listunsigned++);
listfloat=ptr; listunsigned++;
while(i<4) }
{ ptr = listunsigned;
model->view.V[i].x=*(listfloat++); state = DS_READ_CHUNK_ID;
model->view.V[i].y=*(listfloat++); break;
model->view.V[i].z=*(listfloat++); case DS_READ_MATRIX:
model->view.V[i++].w=0.0f; i = 0;
} listfloat = ptr;
model->view.V[3].w=1.0f; while (i < 4)
ptr=listfloat; {
state=DS_READ_CHUNK_ID; model->view.V[i].x =
break; *(listfloat++);
case DS_READ_DONE: model->view.V[i].y =
break; *(listfloat++);
model->view.V[i].z =
} *(listfloat++);
model->view.V[i++].w = 0.0f;
} }
} model->view.V[3].w = 1.0f;
ptr = listfloat;
state = DS_READ_CHUNK_ID;
break;
case DS_READ_DONE:
break;
}
}
}

View File

@ -1,173 +1,176 @@
static pciclass old[] = { static pciclass old[] = {
{ 0x0, "Pre-2.0 PCI Specification Device, Non-VGA" }, {0x0, "Pre-2.0 PCI Specification Device, Non-VGA"},
{ 0x1, "Pre-2.0 PCI Specification Device, VGA Compatible" }, {0x1, "Pre-2.0 PCI Specification Device, VGA Compatible"},
{ 0, NULL } {0, NULL}
}; };
static pciclass storage[] = { static pciclass storage[] = {
{ 0x00, "Mass Storage Controller, SCSI" }, {0x00, "Mass Storage Controller, SCSI"},
{ 0x01, "Mass Storage Controller, IDE" }, {0x01, "Mass Storage Controller, IDE"},
{ 0x02, "Mass Storage Controller, Floppy" }, {0x02, "Mass Storage Controller, Floppy"},
{ 0x03, "Mass Storage Controller, IPI" }, {0x03, "Mass Storage Controller, IPI"},
{ 0x04, "Mass Storage Controller, RAID" }, {0x04, "Mass Storage Controller, RAID"},
{ 0x05, "Mass Storage Controller, ATA controller with single DMA" }, {0x05, "Mass Storage Controller, ATA controller with single DMA"},
{ 0x06, "Mass Storage Controller, SATA" }, {0x06, "Mass Storage Controller, SATA"},
{ 0x07, "Mass Storage Controller, SAS" }, {0x07, "Mass Storage Controller, SAS"},
{ 0x08, "Mass Storage Controller, NVM" }, {0x08, "Mass Storage Controller, NVM"},
{ 0x80, "Mass Storage Controller, Other" }, {0x80, "Mass Storage Controller, Other"},
{ 0, NULL } {0, NULL}
}; };
static pciclass network[] = { static pciclass network[] = {
{ 0x00, "Network Controller, Ethernet" }, {0x00, "Network Controller, Ethernet"},
{ 0x01, "Network Controller, Token Ring" }, {0x01, "Network Controller, Token Ring"},
{ 0x02, "Network Controller, FDDI" }, {0x02, "Network Controller, FDDI"},
{ 0x03, "Network Controller, ATM" }, {0x03, "Network Controller, ATM"},
{ 0x04, "Network Controller, ISDN" }, {0x04, "Network Controller, ISDN"},
{ 0x80, "Network Controller, Other" }, {0x80, "Network Controller, Other"},
{ 0, NULL } {0, NULL}
}; };
static pciclass display[] = { static pciclass display[] = {
{ 0x00, "Display Controller, VGA" }, {0x00, "Display Controller, VGA"},
{ 0x01, "Display Controller, XGA" }, {0x01, "Display Controller, XGA"},
{ 0x02, "Display Controller, 3D" }, {0x02, "Display Controller, 3D"},
{ 0x80, "Display Controller, Other" }, {0x80, "Display Controller, Other"},
{ 0, NULL } {0, NULL}
}; };
static pciclass multimedia[] = { static pciclass multimedia[] = {
{ 0x00, "Multimedia Device, Video" }, {0x00, "Multimedia Device, Video"},
{ 0x01, "Multimedia Device, Audio" }, {0x01, "Multimedia Device, Audio"},
{ 0x02, "Multimedia Device, Telephony" }, {0x02, "Multimedia Device, Telephony"},
{ 0x03, "Multimedia Device, HDA" }, {0x03, "Multimedia Device, HDA"},
{ 0x80, "Multimedia Device, Other" }, {0x80, "Multimedia Device, Other"},
{ 0, NULL } {0, NULL}
}; };
static pciclass memory[] = { static pciclass memory[] = {
{ 0x00, "Memory Controller, RAM" }, {0x00, "Memory Controller, RAM"},
{ 0x01, "Memory Controller, Flash" }, {0x01, "Memory Controller, Flash"},
{ 0x80, "Memory Controller, Other" }, {0x80, "Memory Controller, Other"},
{ 0, NULL } {0, NULL}
}; };
static pciclass bridge[] = { static pciclass bridge[] = {
{ 0x00, "Bridge Device, Host/PCI" }, {0x00, "Bridge Device, Host/PCI"},
{ 0x01, "Bridge Device, PCI/ISA" }, {0x01, "Bridge Device, PCI/ISA"},
{ 0x02, "Bridge Device, PCI/EISA" }, {0x02, "Bridge Device, PCI/EISA"},
{ 0x03, "Bridge Device, PCI/Micro Channel" }, {0x03, "Bridge Device, PCI/Micro Channel"},
{ 0x04, "Bridge Device, PCI/PCI" }, {0x04, "Bridge Device, PCI/PCI"},
{ 0x05, "Bridge Device, PCI/PCMCIA" }, {0x05, "Bridge Device, PCI/PCMCIA"},
{ 0x06, "Bridge Device, PCI/NuBus" }, {0x06, "Bridge Device, PCI/NuBus"},
{ 0x07, "Bridge Device, PCI/CardBus" }, {0x07, "Bridge Device, PCI/CardBus"},
{ 0x08, "Bridge Device, PCI/RACEway" }, {0x08, "Bridge Device, PCI/RACEway"},
{ 0x09, "Bridge Device, PCI/Transparent" }, {0x09, "Bridge Device, PCI/Transparent"},
{ 0x0a, "Bridge Device, Infiniband" }, {0x0a, "Bridge Device, Infiniband"},
{ 0x80, "Bridge Device, Other" }, {0x80, "Bridge Device, Other"},
{ 0, NULL } {0, NULL}
}; };
static pciclass simplecomm[] = { static pciclass simplecomm[] = {
{ 0x00, "Simple Communications Controller, Serial" }, {0x00, "Simple Communications Controller, Serial"},
{ 0x01, "Simple Communications Controller, Parallel" }, {0x01, "Simple Communications Controller, Parallel"},
{ 0x02, "Simple Communications Controller, Multiport" }, {0x02, "Simple Communications Controller, Multiport"},
{ 0x03, "Simple Communications Controller, Modem" }, {0x03, "Simple Communications Controller, Modem"},
{ 0x04, "Simple Communications Controller, GPIB" }, {0x04, "Simple Communications Controller, GPIB"},
{ 0x05, "Simple Communications Controller, Smart Card" }, {0x05, "Simple Communications Controller, Smart Card"},
{ 0x80, "Simple Communications Controller, Other" }, {0x80, "Simple Communications Controller, Other"},
{ 0, NULL } {0, NULL}
}; };
static pciclass baseperiph[] = { static pciclass baseperiph[] = {
{ 0x00, "Base Systems Peripheral, Interrupt Controller" }, {0x00, "Base Systems Peripheral, Interrupt Controller"},
{ 0x01, "Base Systems Peripheral, DMA" }, {0x01, "Base Systems Peripheral, DMA"},
{ 0x02, "Base Systems Peripheral, System Timer" }, {0x02, "Base Systems Peripheral, System Timer"},
{ 0x03, "Base Systems Peripheral, Real Time Clock" }, {0x03, "Base Systems Peripheral, Real Time Clock"},
{ 0x04, "Base Systems Peripheral, PCI Hot-plug" }, {0x04, "Base Systems Peripheral, PCI Hot-plug"},
{ 0x05, "Base Systems Peripheral, SD Host Controller" }, {0x05, "Base Systems Peripheral, SD Host Controller"},
{ 0x06, "Base Systems Peripheral, IOMMU" }, {0x06, "Base Systems Peripheral, IOMMU"},
{ 0x80, "Base Systems Peripheral, Other" }, {0x80, "Base Systems Peripheral, Other"},
{ 0, NULL } {0, NULL}
}; };
static pciclass input[] = { static pciclass input[] = {
{ 0x00, "Input Device, Keyboard" }, {0x00, "Input Device, Keyboard"},
{ 0x01, "Input Device, Digitizer" }, {0x01, "Input Device, Digitizer"},
{ 0x02, "Input Device, Mouse" }, {0x02, "Input Device, Mouse"},
{ 0x03, "Input Device, Scanner" }, {0x03, "Input Device, Scanner"},
{ 0x04, "Input Device, Game Port" }, {0x04, "Input Device, Game Port"},
{ 0x80, "Input Device, Other" }, {0x80, "Input Device, Other"},
{ 0, NULL } {0, NULL}
}; };
static pciclass docking[] = { static pciclass docking[] = {
{ 0x00, "Docking Station, Generic" }, {0x00, "Docking Station, Generic"},
{ 0x80, "Docking Station, Other" }, {0x80, "Docking Station, Other"},
{ 0, NULL } {0, NULL}
}; };
static pciclass processor[] = { static pciclass processor[] = {
{ 0x00, "Processor, i386" }, {0x00, "Processor, i386"},
{ 0x01, "Processor, i486" }, {0x01, "Processor, i486"},
{ 0x02, "Processor, Pentium" }, {0x02, "Processor, Pentium"},
{ 0x10, "Processor, Alpha" }, {0x10, "Processor, Alpha"},
{ 0x20, "Processor, Power PC" }, {0x20, "Processor, Power PC"},
{ 0x80, "Processor, Co-processor" }, {0x80, "Processor, Co-processor"},
{ 0, NULL } {0, NULL}
}; };
static pciclass serial[] = { static pciclass serial[] = {
{ 0x00, "Serial Bus Controller, Firewire" }, {0x00, "Serial Bus Controller, Firewire"},
{ 0x01, "Serial Bus Controller, ACCESS.bus" }, {0x01, "Serial Bus Controller, ACCESS.bus"},
{ 0x02, "Serial Bus Controller, SSA" }, {0x02, "Serial Bus Controller, SSA"},
{ 0x03, "Serial Bus Controller, USB" }, {0x03, "Serial Bus Controller, USB"},
{ 0x04, "Serial Bus Controller, Fibre Channel" }, {0x04, "Serial Bus Controller, Fibre Channel"},
{ 0x05, "Serial Bus Controller, SMBus" }, {0x05, "Serial Bus Controller, SMBus"},
{ 0x06, "Serial Bus Controller, Inifiniband" }, {0x06, "Serial Bus Controller, Inifiniband"},
{ 0x07, "Serial Bus Controller, IPMI" }, {0x07, "Serial Bus Controller, IPMI"},
{ 0, NULL } {0, NULL}
}; };
static pciclass wireless[] = { static pciclass wireless[] = {
{ 0x00, "Wireless Controller, iRDA" }, {0x00, "Wireless Controller, iRDA"},
{ 0x01, "Wireless Controller, IR" }, {0x01, "Wireless Controller, IR"},
{ 0x10, "Wireless Controller, RF" }, {0x10, "Wireless Controller, RF"},
{ 0x11, "Wireless Controller, Bluetooth" }, {0x11, "Wireless Controller, Bluetooth"},
{ 0x12, "Wireless Controller, Broadband" }, {0x12, "Wireless Controller, Broadband"},
{ 0x20, "Wireless Controller, 802.11a" }, {0x20, "Wireless Controller, 802.11a"},
{ 0x21, "Wireless Controller, 802.11b" }, {0x21, "Wireless Controller, 802.11b"},
{ 0x80, "Wireless Controller, Other" }, {0x80, "Wireless Controller, Other"},
{ 0, NULL } {0, NULL}
}; };
static pciclass intelliio[] = { static pciclass intelliio[] = {
{ 0x00, "Intelligent IO Controller, I2O" }, {0x00, "Intelligent IO Controller, I2O"},
{ 0, NULL } {0, NULL}
}; };
static pciclass satcomm[] = { static pciclass satcomm[] = {
{ 0x00, "Satellite Communication Controller, TV" }, {0x00, "Satellite Communication Controller, TV"},
{ 0x01, "Satellite Communication Controller, Audio" }, {0x01, "Satellite Communication Controller, Audio"},
{ 0x02, "Satellite Communication Controller, Voice" }, {0x02, "Satellite Communication Controller, Voice"},
{ 0x03, "Satellite Communication Controller, Data" }, {0x03, "Satellite Communication Controller, Data"},
{ 0, NULL } {0, NULL}
}; };
static pciclass crypto[] = { static pciclass crypto[] = {
{ 0x00, "Encryption/Decryption Controller, Network/computer" }, {0x00, "Encryption/Decryption Controller, Network/computer"},
{ 0x01, "Encryption/Decryption Controller, Entertainment" }, {0x01, "Encryption/Decryption Controller, Entertainment"},
{ 0x80, "Encryption/Decryption Controller, Other" }, {0x80, "Encryption/Decryption Controller, Other"},
{ 0, NULL } {0, NULL}
}; };
static pciclass dasp[] = { static pciclass dasp[] = {
{ 0x00, "Data Acquisition and Signal Processing Controller, DPIO" }, {0x00, "Data Acquisition and Signal Processing Controller, DPIO"},
{ 0x01, "Data Acquisition and Signal Processing Controller, Performance Counter" }, {0x01,
{ 0x10, "Data Acquisition and Signal Processing Controller, Communications Synchronization" }, "Data Acquisition and Signal Processing Controller, Performance Counter"},
{ 0x20, "Data Acquisition and Signal Processing Controller, Management Card" }, {0x10,
{ 0x80, "Data Acquisition and Signal Processing Controller, Other" }, "Data Acquisition and Signal Processing Controller, Communications Synchronization"},
{ 0, NULL } {0x20,
"Data Acquisition and Signal Processing Controller, Management Card"},
{0x80, "Data Acquisition and Signal Processing Controller, Other"},
{0, NULL}
}; };
static pciclass *classcodes[] = { static pciclass *classcodes[] = {
@ -191,4 +194,3 @@ static pciclass *classcodes[] = {
dasp, dasp,
[255] = NULL [255] = NULL
}; };

View File

@ -3,193 +3,380 @@ Programme de test compilé en mode USER avec SYSCALL, le binaire est intégré a
#include "types.h" #include "types.h"
u8 programs_test[] = { u8 programs_test[] = {
0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0xe4, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x20, 0x00, 0x02, 0x00, 0x28, 0x00, 0x00,
0x0c, 0x00, 0x09, 0x00, 0x01, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0xe4, 0x06, 0x00,
0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x00, 0x00,
0xa0, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x20, 0x00, 0x02, 0x00, 0x28,
0x51, 0xe5, 0x74, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x09, 0x00, 0x01, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x8d, 0x4c, 0x24, 0x04, 0x00,
0x83, 0xe4, 0xf0, 0xff, 0x71, 0xfc, 0x55, 0x89, 0xe5, 0x51, 0x83, 0xec, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0xa0, 0x00, 0x00,
0x04, 0xe8, 0x0a, 0x00, 0x00, 0x00, 0x90, 0x83, 0xc4, 0x04, 0x59, 0x5d, 0x00,
0x8d, 0x61, 0xfc, 0xc3, 0x55, 0x89, 0xe5, 0x83, 0xec, 0x10, 0xb8, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
0x00, 0x00, 0x00, 0x89, 0xe1, 0xba, 0x34, 0x00, 0x00, 0x40, 0x0f, 0x34, 0x00,
0x89, 0x45, 0xfc, 0x90, 0xc9, 0xc3, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x51, 0xe5, 0x74, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x7a, 0x52, 0x00, 0x01, 0x7c, 0x08, 0x01, 0x00,
0x1b, 0x0c, 0x04, 0x04, 0x88, 0x01, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1c, 0x00, 0x00, 0x00, 0xa4, 0xff, 0xff, 0xff, 0x20, 0x00, 0x00, 0x00, 0x00,
0x00, 0x44, 0x0c, 0x01, 0x00, 0x47, 0x10, 0x05, 0x02, 0x75, 0x00, 0x43, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x8d, 0x4c, 0x24,
0x0f, 0x03, 0x75, 0x7c, 0x06, 0x4d, 0xc1, 0x0c, 0x01, 0x00, 0x41, 0xc5, 0x04,
0x43, 0x0c, 0x04, 0x04, 0x1c, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x83, 0xe4, 0xf0, 0xff, 0x71, 0xfc, 0x55, 0x89, 0xe5, 0x51, 0x83,
0x98, 0xff, 0xff, 0xff, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x41, 0x0e, 0x08, 0xec,
0x85, 0x02, 0x42, 0x0d, 0x05, 0x56, 0xc5, 0x0c, 0x04, 0x04, 0x00, 0x00, 0x04, 0xe8, 0x0a, 0x00, 0x00, 0x00, 0x90, 0x83, 0xc4, 0x04, 0x59,
0x80, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x5d,
0x86, 0x00, 0x00, 0x00, 0x0c, 0x38, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x8d, 0x61, 0xfc, 0xc3, 0x55, 0x89, 0xe5, 0x83, 0xec, 0x10, 0xb8,
0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0x01, 0x06, 0x33, 0x00, 0x00, 0x00, 0x02, 0x02, 0x05, 0x3f, 0x00, 0x00, 0x00, 0x89, 0xe1, 0xba, 0x34, 0x00, 0x00, 0x40, 0x0f,
0x00, 0x00, 0x00, 0x03, 0x04, 0x05, 0x69, 0x6e, 0x74, 0x00, 0x02, 0x08, 0x34,
0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x05, 0x05, 0x00, 0x00, 0x00, 0x89, 0x45, 0xfc, 0x90, 0xc9, 0xc3, 0x00, 0x00, 0x14, 0x00, 0x00,
0x02, 0x01, 0x06, 0x2c, 0x00, 0x00, 0x00, 0x02, 0x01, 0x08, 0x2a, 0x00, 0x00,
0x00, 0x00, 0x02, 0x02, 0x07, 0x49, 0x00, 0x00, 0x00, 0x02, 0x04, 0x07, 0x00, 0x00, 0x00, 0x00, 0x01, 0x7a, 0x52, 0x00, 0x01, 0x7c, 0x08,
0x18, 0x00, 0x00, 0x00, 0x02, 0x08, 0x07, 0x13, 0x00, 0x00, 0x00, 0x02, 0x01,
0x04, 0x07, 0x1d, 0x00, 0x00, 0x00, 0x04, 0x0e, 0x00, 0x00, 0x00, 0x01, 0x1b, 0x0c, 0x04, 0x04, 0x88, 0x01, 0x00, 0x00, 0x28, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x01, 0x9c, 0x00, 0x00,
0xa7, 0x00, 0x00, 0x00, 0x04, 0x00, 0x42, 0x00, 0x00, 0x00, 0x04, 0x01, 0x1c, 0x00, 0x00, 0x00, 0xa4, 0xff, 0xff, 0xff, 0x20, 0x00, 0x00,
0xe9, 0x00, 0x00, 0x00, 0x0c, 0x57, 0x01, 0x00, 0x00, 0x67, 0x01, 0x00, 0x00,
0x00, 0x20, 0x00, 0x00, 0x40, 0x1a, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x44, 0x0c, 0x01, 0x00, 0x47, 0x10, 0x05, 0x02, 0x75, 0x00,
0x00, 0x02, 0x01, 0x06, 0x33, 0x00, 0x00, 0x00, 0x02, 0x02, 0x05, 0x3f, 0x43,
0x00, 0x00, 0x00, 0x03, 0x04, 0x05, 0x69, 0x6e, 0x74, 0x00, 0x02, 0x08, 0x0f, 0x03, 0x75, 0x7c, 0x06, 0x4d, 0xc1, 0x0c, 0x01, 0x00, 0x41,
0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x05, 0x05, 0x00, 0x00, 0x00, 0xc5,
0x02, 0x01, 0x06, 0x2c, 0x00, 0x00, 0x00, 0x02, 0x01, 0x08, 0x2a, 0x00, 0x43, 0x0c, 0x04, 0x04, 0x1c, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00,
0x00, 0x00, 0x02, 0x02, 0x07, 0x49, 0x00, 0x00, 0x00, 0x02, 0x04, 0x07, 0x00,
0x18, 0x00, 0x00, 0x00, 0x02, 0x08, 0x07, 0x13, 0x00, 0x00, 0x00, 0x04, 0x98, 0xff, 0xff, 0xff, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x41, 0x0e,
0x75, 0x33, 0x32, 0x00, 0x02, 0x1d, 0x76, 0x00, 0x00, 0x00, 0x02, 0x04, 0x08,
0x07, 0x1d, 0x00, 0x00, 0x00, 0x05, 0x5e, 0x01, 0x00, 0x00, 0x01, 0x09, 0x85, 0x02, 0x42, 0x0d, 0x05, 0x56, 0xc5, 0x0c, 0x04, 0x04, 0x00,
0x6b, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x40, 0x1a, 0x00, 0x00, 0x00, 0x00,
0x01, 0x9c, 0x06, 0x26, 0x00, 0x00, 0x40, 0x11, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
0x5f, 0x76, 0x00, 0x01, 0x0b, 0x6b, 0x00, 0x00, 0x00, 0x02, 0x91, 0x74, 0x01,
0x00, 0x00, 0x00, 0x01, 0x11, 0x01, 0x25, 0x0e, 0x13, 0x0b, 0x03, 0x0e, 0x86, 0x00, 0x00, 0x00, 0x0c, 0x38, 0x00, 0x00, 0x00, 0x5c, 0x00,
0x1b, 0x0e, 0x11, 0x01, 0x12, 0x06, 0x10, 0x17, 0x00, 0x00, 0x02, 0x24, 0x00,
0x00, 0x0b, 0x0b, 0x3e, 0x0b, 0x03, 0x0e, 0x00, 0x00, 0x03, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0b, 0x0b, 0x3e, 0x0b, 0x03, 0x08, 0x00, 0x00, 0x04, 0x2e, 0x00, 0x3f, 0x00,
0x19, 0x03, 0x0e, 0x3a, 0x0b, 0x3b, 0x0b, 0x27, 0x19, 0x11, 0x01, 0x12, 0x00, 0x02, 0x01, 0x06, 0x33, 0x00, 0x00, 0x00, 0x02, 0x02, 0x05,
0x06, 0x40, 0x18, 0x96, 0x42, 0x19, 0x00, 0x00, 0x00, 0x01, 0x11, 0x01, 0x3f,
0x25, 0x0e, 0x13, 0x0b, 0x03, 0x0e, 0x1b, 0x0e, 0x11, 0x01, 0x12, 0x06, 0x00, 0x00, 0x00, 0x03, 0x04, 0x05, 0x69, 0x6e, 0x74, 0x00, 0x02,
0x10, 0x17, 0x00, 0x00, 0x02, 0x24, 0x00, 0x0b, 0x0b, 0x3e, 0x0b, 0x03, 0x08,
0x0e, 0x00, 0x00, 0x03, 0x24, 0x00, 0x0b, 0x0b, 0x3e, 0x0b, 0x03, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x05, 0x05, 0x00, 0x00,
0x00, 0x00, 0x04, 0x16, 0x00, 0x03, 0x08, 0x3a, 0x0b, 0x3b, 0x0b, 0x49, 0x00,
0x13, 0x00, 0x00, 0x05, 0x2e, 0x01, 0x3f, 0x19, 0x03, 0x0e, 0x3a, 0x0b, 0x02, 0x01, 0x06, 0x2c, 0x00, 0x00, 0x00, 0x02, 0x01, 0x08, 0x2a,
0x3b, 0x0b, 0x27, 0x19, 0x49, 0x13, 0x11, 0x01, 0x12, 0x06, 0x40, 0x18, 0x00,
0x97, 0x42, 0x19, 0x00, 0x00, 0x06, 0x0b, 0x01, 0x11, 0x01, 0x12, 0x06, 0x00, 0x00, 0x02, 0x02, 0x07, 0x49, 0x00, 0x00, 0x00, 0x02, 0x04,
0x00, 0x00, 0x07, 0x34, 0x00, 0x03, 0x08, 0x3a, 0x0b, 0x3b, 0x0b, 0x49, 0x07,
0x13, 0x02, 0x18, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x18, 0x00, 0x00, 0x00, 0x02, 0x08, 0x07, 0x13, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x07, 0x1d, 0x00, 0x00, 0x00, 0x04, 0x0e, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x84, 0x00, 0x00, 0x00, 0x01,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x40, 0x1a, 0x00, 0x08, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x01, 0x9c,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00,
0x00, 0x00, 0x02, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x01, 0x01, 0xfb, 0x0e, 0xa7, 0x00, 0x00, 0x00, 0x04, 0x00, 0x42, 0x00, 0x00, 0x00, 0x04,
0x0d, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01,
0x01, 0x00, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x63, 0x00, 0x00, 0x00, 0x00, 0xe9, 0x00, 0x00, 0x00, 0x0c, 0x57, 0x01, 0x00, 0x00, 0x67, 0x01,
0x00, 0x00, 0x05, 0x02, 0x00, 0x00, 0x00, 0x40, 0x1a, 0x08, 0x13, 0x59, 0x00,
0x02, 0x0a, 0x00, 0x01, 0x01, 0x4b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x33, 0x00, 0x20, 0x00, 0x00, 0x40, 0x1a, 0x00, 0x00, 0x00, 0x37, 0x00,
0x00, 0x00, 0x00, 0x01, 0x01, 0xfb, 0x0e, 0x0d, 0x00, 0x01, 0x01, 0x01, 0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x2e, 0x2e, 0x2f, 0x69, 0x00, 0x02, 0x01, 0x06, 0x33, 0x00, 0x00, 0x00, 0x02, 0x02, 0x05,
0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x00, 0x00, 0x6c, 0x69, 0x62, 0x63, 0x3f,
0x2e, 0x63, 0x00, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x00, 0x00, 0x00, 0x03, 0x04, 0x05, 0x69, 0x6e, 0x74, 0x00, 0x02,
0x68, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x05, 0x02, 0x20, 0x00, 0x00, 0x08,
0x40, 0x03, 0x09, 0x01, 0x67, 0x08, 0x13, 0x02, 0x03, 0x00, 0x01, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x05, 0x05, 0x00, 0x00,
0x6c, 0x6f, 0x6e, 0x67, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x20, 0x69, 0x6e, 0x00,
0x74, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x6c, 0x6f, 0x6e, 0x67, 0x20, 0x02, 0x01, 0x06, 0x2c, 0x00, 0x00, 0x00, 0x02, 0x01, 0x08, 0x2a,
0x6c, 0x6f, 0x6e, 0x67, 0x20, 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x00,
0x64, 0x20, 0x69, 0x6e, 0x74, 0x00, 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e, 0x00, 0x00, 0x02, 0x02, 0x07, 0x49, 0x00, 0x00, 0x00, 0x02, 0x04,
0x65, 0x64, 0x20, 0x63, 0x68, 0x61, 0x72, 0x00, 0x74, 0x65, 0x73, 0x74, 0x07,
0x2e, 0x63, 0x00, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x20, 0x69, 0x6e, 0x74, 0x18, 0x00, 0x00, 0x00, 0x02, 0x08, 0x07, 0x13, 0x00, 0x00, 0x00,
0x00, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x20, 0x75, 0x6e, 0x73, 0x69, 0x67, 0x04,
0x6e, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x74, 0x00, 0x2f, 0x68, 0x6f, 0x6d, 0x75, 0x33, 0x32, 0x00, 0x02, 0x1d, 0x76, 0x00, 0x00, 0x00, 0x02,
0x65, 0x2f, 0x68, 0x6f, 0x72, 0x64, 0x65, 0x2f, 0x42, 0x75, 0x72, 0x65, 0x04,
0x61, 0x75, 0x2f, 0x50, 0x45, 0x52, 0x53, 0x4f, 0x2f, 0x63, 0x6f, 0x73, 0x07, 0x1d, 0x00, 0x00, 0x00, 0x05, 0x5e, 0x01, 0x00, 0x00, 0x01,
0x32, 0x30, 0x30, 0x30, 0x2f, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x09,
0x73, 0x00, 0x47, 0x4e, 0x55, 0x20, 0x43, 0x31, 0x31, 0x20, 0x35, 0x2e, 0x6b, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x40, 0x1a, 0x00, 0x00,
0x34, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x31, 0x36, 0x30, 0x36, 0x30, 0x39, 0x00,
0x20, 0x2d, 0x6d, 0x33, 0x32, 0x20, 0x2d, 0x6d, 0x74, 0x75, 0x6e, 0x65, 0x01, 0x9c, 0x06, 0x26, 0x00, 0x00, 0x40, 0x11, 0x00, 0x00, 0x00,
0x3d, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x20, 0x2d, 0x6d, 0x61, 0x07,
0x72, 0x63, 0x68, 0x3d, 0x69, 0x36, 0x38, 0x36, 0x20, 0x2d, 0x67, 0x20, 0x5f, 0x76, 0x00, 0x01, 0x0b, 0x6b, 0x00, 0x00, 0x00, 0x02, 0x91,
0x2d, 0x4f, 0x30, 0x20, 0x2d, 0x66, 0x66, 0x72, 0x65, 0x65, 0x73, 0x74, 0x74,
0x61, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x2d, 0x66, 0x6e, 0x6f, 0x2d, 0x00, 0x00, 0x00, 0x01, 0x11, 0x01, 0x25, 0x0e, 0x13, 0x0b, 0x03,
0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x20, 0x2d, 0x66, 0x6e, 0x6f, 0x0e,
0x2d, 0x70, 0x69, 0x65, 0x00, 0x47, 0x4e, 0x55, 0x20, 0x43, 0x31, 0x31, 0x1b, 0x0e, 0x11, 0x01, 0x12, 0x06, 0x10, 0x17, 0x00, 0x00, 0x02,
0x20, 0x35, 0x2e, 0x34, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x31, 0x36, 0x30, 0x24,
0x36, 0x30, 0x39, 0x20, 0x2d, 0x46, 0x65, 0x6c, 0x66, 0x2d, 0x69, 0x33, 0x00, 0x0b, 0x0b, 0x3e, 0x0b, 0x03, 0x0e, 0x00, 0x00, 0x03, 0x24,
0x38, 0x36, 0x20, 0x2d, 0x6d, 0x33, 0x32, 0x20, 0x2d, 0x6d, 0x74, 0x75, 0x00,
0x6e, 0x65, 0x3d, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x20, 0x2d, 0x0b, 0x0b, 0x3e, 0x0b, 0x03, 0x08, 0x00, 0x00, 0x04, 0x2e, 0x00,
0x6d, 0x61, 0x72, 0x63, 0x68, 0x3d, 0x69, 0x36, 0x38, 0x36, 0x20, 0x2d, 0x3f,
0x67, 0x20, 0x2d, 0x4f, 0x30, 0x20, 0x2d, 0x66, 0x66, 0x72, 0x65, 0x65, 0x19, 0x03, 0x0e, 0x3a, 0x0b, 0x3b, 0x0b, 0x27, 0x19, 0x11, 0x01,
0x73, 0x74, 0x61, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x2d, 0x66, 0x6e, 0x12,
0x6f, 0x2d, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x20, 0x2d, 0x66, 0x06, 0x40, 0x18, 0x96, 0x42, 0x19, 0x00, 0x00, 0x00, 0x01, 0x11,
0x6e, 0x6f, 0x2d, 0x70, 0x69, 0x65, 0x00, 0x6c, 0x69, 0x62, 0x63, 0x2e, 0x01,
0x63, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x70, 0x69, 0x00, 0x2f, 0x25, 0x0e, 0x13, 0x0b, 0x03, 0x0e, 0x1b, 0x0e, 0x11, 0x01, 0x12,
0x68, 0x6f, 0x6d, 0x65, 0x2f, 0x68, 0x6f, 0x72, 0x64, 0x65, 0x2f, 0x42, 0x06,
0x75, 0x72, 0x65, 0x61, 0x75, 0x2f, 0x50, 0x45, 0x52, 0x53, 0x4f, 0x2f, 0x10, 0x17, 0x00, 0x00, 0x02, 0x24, 0x00, 0x0b, 0x0b, 0x3e, 0x0b,
0x63, 0x6f, 0x73, 0x32, 0x30, 0x30, 0x30, 0x2f, 0x70, 0x72, 0x6f, 0x67, 0x03,
0x72, 0x61, 0x6d, 0x73, 0x2f, 0x6c, 0x69, 0x62, 0x00, 0x47, 0x43, 0x43, 0x0e, 0x00, 0x00, 0x03, 0x24, 0x00, 0x0b, 0x0b, 0x3e, 0x0b, 0x03,
0x3a, 0x20, 0x28, 0x55, 0x62, 0x75, 0x6e, 0x74, 0x75, 0x20, 0x35, 0x2e, 0x08,
0x34, 0x2e, 0x30, 0x2d, 0x36, 0x75, 0x62, 0x75, 0x6e, 0x74, 0x75, 0x31, 0x00, 0x00, 0x04, 0x16, 0x00, 0x03, 0x08, 0x3a, 0x0b, 0x3b, 0x0b,
0x7e, 0x31, 0x36, 0x2e, 0x30, 0x34, 0x2e, 0x31, 0x30, 0x29, 0x20, 0x35, 0x49,
0x2e, 0x34, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x31, 0x36, 0x30, 0x36, 0x30, 0x13, 0x00, 0x00, 0x05, 0x2e, 0x01, 0x3f, 0x19, 0x03, 0x0e, 0x3a,
0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x0b, 0x27, 0x19, 0x49, 0x13, 0x11, 0x01, 0x12, 0x06, 0x40,
0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x18,
0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x97, 0x42, 0x19, 0x00, 0x00, 0x06, 0x0b, 0x01, 0x11, 0x01, 0x12,
0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x34, 0x00, 0x03, 0x08, 0x3a, 0x0b, 0x3b, 0x0b,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x04, 0x00, 0x49,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x02, 0x18, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02,
0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0xf1, 0xff, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x84, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0xf1, 0xff, 0x00,
0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x40, 0x1a,
0x12, 0x00, 0x01, 0x00, 0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x40, 0x00,
0x1a, 0x00, 0x00, 0x00, 0x12, 0x00, 0x01, 0x00, 0x00, 0x74, 0x65, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33,
0x74, 0x2e, 0x63, 0x00, 0x6c, 0x69, 0x62, 0x63, 0x2e, 0x63, 0x00, 0x6d, 0x00,
0x61, 0x69, 0x6e, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x70, 0x69, 0x00, 0x00, 0x02, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x01, 0x01, 0xfb,
0x00, 0x00, 0x2e, 0x73, 0x79, 0x6d, 0x74, 0x61, 0x62, 0x00, 0x2e, 0x73, 0x0e,
0x74, 0x72, 0x74, 0x61, 0x62, 0x00, 0x2e, 0x73, 0x68, 0x73, 0x74, 0x72, 0x0d, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
0x74, 0x61, 0x62, 0x00, 0x2e, 0x74, 0x65, 0x78, 0x74, 0x00, 0x2e, 0x65, 0x00,
0x68, 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x00, 0x2e, 0x64, 0x65, 0x62, 0x01, 0x00, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x63, 0x00, 0x00, 0x00,
0x75, 0x67, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x00, 0x2e, 0x64, 0x65, 0x62, 0x00,
0x75, 0x67, 0x5f, 0x61, 0x62, 0x62, 0x72, 0x65, 0x76, 0x00, 0x2e, 0x64, 0x00, 0x00, 0x05, 0x02, 0x00, 0x00, 0x00, 0x40, 0x1a, 0x08, 0x13,
0x65, 0x62, 0x75, 0x67, 0x5f, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x59,
0x00, 0x2e, 0x64, 0x65, 0x62, 0x75, 0x67, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x02, 0x0a, 0x00, 0x01, 0x01, 0x4b, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x2e, 0x64, 0x65, 0x62, 0x75, 0x67, 0x5f, 0x73, 0x74, 0x72, 0x00, 0x33,
0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0xfb, 0x0e, 0x0d, 0x00, 0x01, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x2e, 0x2e, 0x2f,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x69,
0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x00, 0x00, 0x6c, 0x69, 0x62,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x74, 0x00, 0x00, 0x00, 0x63,
0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2e, 0x63, 0x00, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x73,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x2e,
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x40, 0x68, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x05, 0x02, 0x20, 0x00,
0xb0, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x03, 0x09, 0x01, 0x67, 0x08, 0x13, 0x02, 0x03, 0x00, 0x01,
0x2b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x14, 0x01, 0x00, 0x00, 0x2f, 0x01, 0x00, 0x00, 0x6c, 0x6f, 0x6e, 0x67, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x20, 0x69,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6e,
0x00, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x74, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x6c, 0x6f, 0x6e, 0x67,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x02, 0x00, 0x00, 0x20,
0xab, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6f, 0x6e, 0x67, 0x20, 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x65,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x20, 0x69, 0x6e, 0x74, 0x00, 0x75, 0x6e, 0x73, 0x69, 0x67,
0xee, 0x02, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x64, 0x20, 0x63, 0x68, 0x61, 0x72, 0x00, 0x74, 0x65, 0x73,
0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74,
0x00, 0x00, 0x00, 0x00, 0x2e, 0x03, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0x2e, 0x63, 0x00, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x20, 0x69, 0x6e,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x74,
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x20, 0x75, 0x6e, 0x73, 0x69,
0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb4, 0x03, 0x00, 0x00, 0x67,
0x95, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x74, 0x00, 0x2f, 0x68, 0x6f,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x6d,
0x01, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x2f, 0x68, 0x6f, 0x72, 0x64, 0x65, 0x2f, 0x42, 0x75, 0x72,
0x49, 0x05, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x61, 0x75, 0x2f, 0x50, 0x45, 0x52, 0x53, 0x4f, 0x2f, 0x63, 0x6f,
0x11, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73,
0x00, 0x00, 0x00, 0x00, 0x6d, 0x06, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x32, 0x30, 0x30, 0x30, 0x2f, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x61,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6d,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x73, 0x00, 0x47, 0x4e, 0x55, 0x20, 0x43, 0x31, 0x31, 0x20, 0x35,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x05, 0x00, 0x00, 0x2e,
0xd0, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x34, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x31, 0x36, 0x30, 0x36, 0x30,
0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x39,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x2d, 0x6d, 0x33, 0x32, 0x20, 0x2d, 0x6d, 0x74, 0x75, 0x6e,
0x50, 0x06, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 0x3d, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x20, 0x2d, 0x6d,
0x61,
0x72, 0x63, 0x68, 0x3d, 0x69, 0x36, 0x38, 0x36, 0x20, 0x2d, 0x67,
0x20,
0x2d, 0x4f, 0x30, 0x20, 0x2d, 0x66, 0x66, 0x72, 0x65, 0x65, 0x73,
0x74,
0x61, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x2d, 0x66, 0x6e, 0x6f,
0x2d,
0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x20, 0x2d, 0x66, 0x6e,
0x6f,
0x2d, 0x70, 0x69, 0x65, 0x00, 0x47, 0x4e, 0x55, 0x20, 0x43, 0x31,
0x31,
0x20, 0x35, 0x2e, 0x34, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x31, 0x36,
0x30,
0x36, 0x30, 0x39, 0x20, 0x2d, 0x46, 0x65, 0x6c, 0x66, 0x2d, 0x69,
0x33,
0x38, 0x36, 0x20, 0x2d, 0x6d, 0x33, 0x32, 0x20, 0x2d, 0x6d, 0x74,
0x75,
0x6e, 0x65, 0x3d, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x20,
0x2d,
0x6d, 0x61, 0x72, 0x63, 0x68, 0x3d, 0x69, 0x36, 0x38, 0x36, 0x20,
0x2d,
0x67, 0x20, 0x2d, 0x4f, 0x30, 0x20, 0x2d, 0x66, 0x66, 0x72, 0x65,
0x65,
0x73, 0x74, 0x61, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x2d, 0x66,
0x6e,
0x6f, 0x2d, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x20, 0x2d,
0x66,
0x6e, 0x6f, 0x2d, 0x70, 0x69, 0x65, 0x00, 0x6c, 0x69, 0x62, 0x63,
0x2e,
0x63, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x70, 0x69, 0x00,
0x2f,
0x68, 0x6f, 0x6d, 0x65, 0x2f, 0x68, 0x6f, 0x72, 0x64, 0x65, 0x2f,
0x42,
0x75, 0x72, 0x65, 0x61, 0x75, 0x2f, 0x50, 0x45, 0x52, 0x53, 0x4f,
0x2f,
0x63, 0x6f, 0x73, 0x32, 0x30, 0x30, 0x30, 0x2f, 0x70, 0x72, 0x6f,
0x67,
0x72, 0x61, 0x6d, 0x73, 0x2f, 0x6c, 0x69, 0x62, 0x00, 0x47, 0x43,
0x43,
0x3a, 0x20, 0x28, 0x55, 0x62, 0x75, 0x6e, 0x74, 0x75, 0x20, 0x35,
0x2e,
0x34, 0x2e, 0x30, 0x2d, 0x36, 0x75, 0x62, 0x75, 0x6e, 0x74, 0x75,
0x31,
0x7e, 0x31, 0x36, 0x2e, 0x30, 0x34, 0x2e, 0x31, 0x30, 0x29, 0x20,
0x35,
0x2e, 0x34, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x31, 0x36, 0x30, 0x36,
0x30,
0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01,
0x00,
0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0x00,
0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x04,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x07,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x03, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0xf1, 0xff, 0x08, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0xf1,
0xff,
0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00,
0x00,
0x12, 0x00, 0x01, 0x00, 0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
0x40,
0x1a, 0x00, 0x00, 0x00, 0x12, 0x00, 0x01, 0x00, 0x00, 0x74, 0x65,
0x73,
0x74, 0x2e, 0x63, 0x00, 0x6c, 0x69, 0x62, 0x63, 0x2e, 0x63, 0x00,
0x6d,
0x61, 0x69, 0x6e, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x70,
0x69,
0x00, 0x00, 0x2e, 0x73, 0x79, 0x6d, 0x74, 0x61, 0x62, 0x00, 0x2e,
0x73,
0x74, 0x72, 0x74, 0x61, 0x62, 0x00, 0x2e, 0x73, 0x68, 0x73, 0x74,
0x72,
0x74, 0x61, 0x62, 0x00, 0x2e, 0x74, 0x65, 0x78, 0x74, 0x00, 0x2e,
0x65,
0x68, 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x00, 0x2e, 0x64, 0x65,
0x62,
0x75, 0x67, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x00, 0x2e, 0x64, 0x65,
0x62,
0x75, 0x67, 0x5f, 0x61, 0x62, 0x62, 0x72, 0x65, 0x76, 0x00, 0x2e,
0x64,
0x65, 0x62, 0x75, 0x67, 0x5f, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x65,
0x73,
0x00, 0x2e, 0x64, 0x65, 0x62, 0x75, 0x67, 0x5f, 0x6c, 0x69, 0x6e,
0x65,
0x00, 0x2e, 0x64, 0x65, 0x62, 0x75, 0x67, 0x5f, 0x73, 0x74, 0x72,
0x00,
0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x74, 0x00, 0x00,
0x00,
0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00,
0x00,
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00,
0x40,
0xb0, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x2b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x14, 0x01, 0x00, 0x00, 0x2f, 0x01, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x02, 0x00,
0x00,
0xab, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00,
0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0xee, 0x02, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x2e, 0x03, 0x00, 0x00, 0x86, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
0x00,
0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb4, 0x03, 0x00,
0x00,
0x95, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00,
0x00,
0x01, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x49, 0x05, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
0x00,
0x11, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x6d, 0x06, 0x00, 0x00, 0x74, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x05, 0x00,
0x00,
0xd0, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00,
0x00,
0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
0x00,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x50, 0x06, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00
}; };
unsigned int programs_test_len = 2244; unsigned int programs_test_len = 2244;

File diff suppressed because it is too large Load Diff

View File

@ -1,274 +1,336 @@
/*******************************************************************************/ /*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */ /* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */ /* */
/* Police de caractère fine 8x8 */ /* Police de caractère fine 8x8 */
static u8 font8x8[2048] = static u8 font8x8[2048] = {
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x81, 0xA5,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x81, 0xA5, 0x81, 0x81,
0xBD, 0x99, 0x81, 0x7E, 0xBD, 0x99, 0x81, 0x7E,
0x7E, 0xFF, 0xDB, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E, 0x6C, 0xFE, 0xFE, 0x7E, 0xFF, 0xDB, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E, 0x6C, 0xFE, 0xFE,
0xFE, 0x7C, 0x38, 0x10, 0x00, 0xFE, 0x7C, 0x38, 0x10, 0x00,
0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, 0x00, 0x38, 0x7C, 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, 0x00, 0x38, 0x7C,
0x38, 0xFE, 0xFE, 0x7C, 0x38, 0x7C, 0x38, 0xFE, 0xFE, 0x7C, 0x38, 0x7C,
0x10, 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x7C, 0x00, 0x10, 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x7C, 0x00,
0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00,
0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF,
0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00, 0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00,
0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3,
0xFF, 0x0F, 0x07, 0x0F, 0x7D, 0xCC, 0xCC, 0xCC, 0x78, 0xFF, 0x0F, 0x07, 0x0F, 0x7D, 0xCC, 0xCC, 0xCC, 0x78,
0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18,
0x7E, 0x18, 0x3F, 0x33, 0x3F, 0x30, 0x30, 0x70, 0xF0, 0xE0, 0x7E, 0x18, 0x3F, 0x33, 0x3F, 0x30, 0x30, 0x70, 0xF0, 0xE0,
0x7F, 0x63, 0x7F, 0x63, 0x63, 0x7F, 0x63, 0x7F, 0x63, 0x63,
0x67, 0xE6, 0xC0, 0x99, 0x5A, 0x3C, 0xE7, 0xE7, 0x3C, 0x5A, 0x99, 0x67, 0xE6, 0xC0, 0x99, 0x5A, 0x3C, 0xE7, 0xE7, 0x3C, 0x5A, 0x99,
0x80, 0xE0, 0xF8, 0xFE, 0x80, 0xE0, 0xF8, 0xFE,
0xF8, 0xE0, 0x80, 0x00, 0x02, 0x0E, 0x3E, 0xFE, 0x3E, 0x0E, 0x02, 0x00, 0xF8, 0xE0, 0x80, 0x00, 0x02, 0x0E, 0x3E, 0xFE, 0x3E, 0x0E, 0x02,
0x18, 0x3C, 0x7E, 0x00,
0x18, 0x18, 0x7E, 0x3C, 0x18, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00, 0x18, 0x3C, 0x7E,
0x7F, 0xDB, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00,
0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x00, 0x3E, 0x63, 0x38, 0x6C, 0x6C, 0x38, 0xCC, 0x78, 0x66, 0x00,
0x00, 0x7F, 0xDB,
0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x7E, 0x3C, 0x18, 0xFF, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x00, 0x3E, 0x63, 0x38, 0x6C, 0x6C,
0x38, 0xCC, 0x78,
0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x00, 0x18, 0x3C, 0x7E, 0x18,
0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x30, 0x60, 0xFE, 0x60, 0x30, 0x7E, 0x3C, 0x18, 0xFF,
0x00, 0x00,
0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xFE, 0x00, 0x00, 0x00, 0x24, 0x66, 0xFF, 0x66, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18,
0x24, 0x00, 0x00, 0x18, 0x7E, 0x3C, 0x18,
0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x7E, 0x00,
0x3C, 0x18, 0x00, 0x00, 0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x30, 0x60,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0xFE, 0x60, 0x30,
0x40, 0x40, 0x00, 0x40, 0x00, 0x00, 0x00,
0x90, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x50, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xFE, 0x00, 0x00, 0x00, 0x24, 0x66,
0xF8, 0x50, 0xF8, 0x50, 0x50, 0x00, 0xFF, 0x66,
0x20, 0x78, 0xA0, 0x70, 0x28, 0xF0, 0x20, 0x00, 0xC8, 0x24, 0x00, 0x00,
0xC8, 0x10, 0x20, 0x40, 0x98, 0x98, 0x00, 0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF,
0x70, 0x88, 0x50, 0x20, 0x54, 0x88, 0x74, 0x00, 0x7E,
0x60, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x18, 0x00, 0x00,
0x20, 0x40, 0x80, 0x80, 0x80, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40,
0x00, 0x20, 0x10, 0x08, 0x08, 0x08, 0x10, 0x20, 0x00, 0x40, 0x40, 0x00, 0x40, 0x00,
0x00, 0x20, 0xA8, 0x70, 0x70, 0xA8, 0x90, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x50,
0x20, 0x00, 0x00, 0x00, 0x20, 0x20, 0xF8, 0x20, 0x20, 0x00, 0xF8, 0x50, 0xF8, 0x50, 0x50, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x78, 0xA0, 0x70, 0x28, 0xF0, 0x20, 0x00, 0xC8,
0x60, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0xC8, 0x10, 0x20, 0x40, 0x98, 0x98, 0x00,
0x00, 0x00, 0x00, 0x00, 0x70, 0x88, 0x50, 0x20, 0x54, 0x88, 0x74, 0x00,
0x00, 0x60, 0x60, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00, 0x60, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
0x70, 0x88, 0x98, 0x20, 0x40, 0x80, 0x80, 0x80, 0x40, 0x20,
0xA8, 0xC8, 0x88, 0x70, 0x00, 0x40, 0xC0, 0x40, 0x40, 0x40, 0x40, 0xE0, 0x00, 0x00, 0x20, 0x10, 0x08, 0x08, 0x08, 0x10, 0x20, 0x00,
0x70, 0x88, 0x00, 0x20, 0xA8, 0x70, 0x70, 0xA8,
0x08, 0x10, 0x20, 0x40, 0xF8, 0x00, 0x70, 0x88, 0x08, 0x10, 0x08, 0x88, 0x70, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x20, 0xF8, 0x20, 0x20, 0x00,
0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x28, 0x48, 0xFC, 0x08, 0x08, 0x00, 0xF8, 0x80, 0x80, 0xF0, 0x08, 0x88, 0x70, 0x00, 0x60, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x20, 0x40, 0x80, 0xF0, 0x88, 0x88, 0x70, 0x00, 0xF8, 0x08, 0x10, 0x20, 0x40, 0x40, 0x40, 0x00, 0x60, 0x60, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
0x00, 0x00,
0x70, 0x88, 0x88, 0x70, 0x88, 0x88, 0x70, 0x00, 0x70, 0x88, 0x88, 0x78, 0x08, 0x08, 0x70, 0x88, 0x98,
0x70, 0x00, 0xA8, 0xC8, 0x88, 0x70, 0x00, 0x40, 0xC0, 0x40, 0x40, 0x40, 0x40,
0x00, 0x00, 0x60, 0x60, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0xE0, 0x00,
0x60, 0x60, 0x20, 0x70, 0x88,
0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x08, 0x10, 0x20, 0x40, 0xF8, 0x00, 0x70, 0x88, 0x08, 0x10, 0x08,
0xF8, 0x00, 0x00, 0x00, 0x88, 0x70, 0x00,
0x80, 0x40, 0x20, 0x10, 0x20, 0x40, 0x80, 0x00, 0x78, 0x84, 0x04, 0x08,
0x08, 0x10, 0x00, 0x10, 0x00, 0x18, 0x28, 0x48, 0xFC, 0x08, 0x08, 0x00, 0xF8, 0x80, 0x80, 0xF0,
0x70, 0x88, 0x88, 0xA8, 0xB8, 0x80, 0x78, 0x00, 0x20, 0x50, 0x08, 0x88, 0x70, 0x00,
0x88, 0x88, 0xF8, 0x88, 0x88, 0x00,
0xF0, 0x88, 0x88, 0xF0, 0x88, 0x88, 0xF0, 0x00, 0x70, 0x20, 0x40, 0x80, 0xF0, 0x88, 0x88, 0x70, 0x00, 0xF8, 0x08, 0x10,
0x88, 0x80, 0x80, 0x80, 0x88, 0x70, 0x00, 0x20, 0x40, 0x40, 0x40,
0xF0, 0x88, 0x88, 0x88, 0x88, 0x88, 0xF0, 0x00, 0x00,
0xF8, 0x80, 0x80, 0xE0, 0x80, 0x80, 0xF8, 0x00, 0x70, 0x88, 0x88, 0x70, 0x88, 0x88, 0x70, 0x00, 0x70, 0x88, 0x88,
0xF8, 0x80, 0x80, 0xE0, 0x80, 0x80, 0x80, 0x78, 0x08, 0x08,
0x00, 0x70, 0x88, 0x80, 0x80, 0x98, 0x88, 0x78, 0x00, 0x70, 0x00,
0x88, 0x88, 0x88, 0xF8, 0x88, 0x88, 0x00, 0x00, 0x60, 0x60, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x60,
0x88, 0x00, 0xE0, 0x40, 0x40, 0x40, 0x40, 0x40, 0xE0, 0x00, 0x60, 0x00,
0x38, 0x10, 0x10, 0x10, 0x10, 0x60, 0x60, 0x20,
0x90, 0x60, 0x00, 0x88, 0x90, 0xA0, 0xC0, 0xA0, 0x90, 0x88, 0x00, 0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10, 0x00, 0x00, 0x00, 0xF8,
0x80, 0x80, 0x80, 0x80, 0x00,
0x80, 0x80, 0xF8, 0x00, 0x82, 0xC6, 0xAA, 0x92, 0x82, 0x82, 0x82, 0x00, 0xF8, 0x00, 0x00, 0x00,
0x84, 0xC4, 0xA4, 0x80, 0x40, 0x20, 0x10, 0x20, 0x40, 0x80, 0x00, 0x78, 0x84, 0x04,
0x94, 0x8C, 0x84, 0x84, 0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70, 0x00, 0x08, 0x10, 0x00, 0x10, 0x00,
0xF0, 0x88, 0x70, 0x88, 0x88, 0xA8, 0xB8, 0x80, 0x78, 0x00, 0x20, 0x50,
0x88, 0xF0, 0x80, 0x80, 0x80, 0x00, 0x70, 0x88, 0x88, 0x88, 0xA8, 0x90, 0x68, 0x00, 0x88, 0x88, 0xF8, 0x88, 0x88, 0x00,
0xF0, 0xF0, 0x88, 0x88, 0xF0, 0x88, 0x88, 0xF0, 0x00, 0x70,
0x88, 0x88, 0xF0, 0xA0, 0x90, 0x88, 0x00, 0x70, 0x88, 0x80, 0x70, 0x08, 0x88, 0x70, 0x00, 0x88, 0x80, 0x80, 0x80, 0x88, 0x70, 0x00,
0xF0, 0x88, 0x88, 0x88, 0x88, 0x88, 0xF0, 0x00,
0xF8, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70, 0xF8, 0x80, 0x80, 0xE0, 0x80, 0x80, 0xF8, 0x00,
0x00, 0xF8, 0x80, 0x80, 0xE0, 0x80, 0x80, 0x80,
0x88, 0x88, 0x88, 0x50, 0x50, 0x20, 0x20, 0x00, 0x82, 0x82, 0x82, 0x82, 0x92, 0x92, 0x00, 0x70, 0x88, 0x80, 0x80, 0x98, 0x88, 0x78, 0x00,
0x6C, 0x00, 0x88, 0x88, 0x88, 0xF8, 0x88, 0x88,
0x88, 0x88, 0x50, 0x20, 0x50, 0x88, 0x88, 0x00, 0x88, 0x88, 0x88, 0x50, 0x20, 0x88, 0x00, 0xE0, 0x40, 0x40, 0x40, 0x40, 0x40, 0xE0, 0x00,
0x20, 0x20, 0x00, 0x38, 0x10, 0x10, 0x10, 0x10,
0xF8, 0x08, 0x10, 0x20, 0x40, 0x80, 0xF8, 0x00, 0xE0, 0x80, 0x80, 0x80, 0x90, 0x60, 0x00, 0x88, 0x90, 0xA0, 0xC0, 0xA0, 0x90, 0x88, 0x00,
0x80, 0x80, 0xE0, 0x00, 0x80, 0x80, 0x80, 0x80,
0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0xE0, 0x20, 0x20, 0x80, 0x80, 0xF8, 0x00, 0x82, 0xC6, 0xAA, 0x92, 0x82, 0x82, 0x82,
0x20, 0x20, 0x20, 0xE0, 0x00, 0x00,
0x20, 0x50, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0xC4, 0xA4,
0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x94, 0x8C, 0x84, 0x84, 0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x88,
0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00,
0x00, 0x70, 0x08, 0x78, 0x88, 0x74, 0x00, 0xF0, 0x88,
0x80, 0x80, 0xB0, 0xC8, 0x88, 0xC8, 0xB0, 0x00, 0x88, 0xF0, 0x80, 0x80, 0x80, 0x00, 0x70, 0x88, 0x88, 0x88, 0xA8,
0x00, 0x00, 0x70, 0x88, 0x80, 0x88, 0x70, 0x00, 0x90, 0x68, 0x00,
0x08, 0x08, 0x68, 0x98, 0x88, 0x98, 0x68, 0xF0,
0x00, 0x00, 0x00, 0x70, 0x88, 0xF8, 0x80, 0x70, 0x00, 0x88, 0x88, 0xF0, 0xA0, 0x90, 0x88, 0x00, 0x70, 0x88, 0x80, 0x70,
0x30, 0x48, 0x40, 0xE0, 0x40, 0x40, 0x08, 0x88, 0x70, 0x00,
0x40, 0x00, 0x00, 0x00, 0x34, 0x48, 0x48, 0x38, 0x08, 0x30,
0x80, 0x80, 0xB0, 0xC8, 0x88, 0xF8, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x88, 0x88, 0x88,
0x88, 0x88, 0x00, 0x20, 0x00, 0x60, 0x20, 0x20, 0x20, 0x70, 0x00, 0x88, 0x88, 0x88, 0x70,
0x10, 0x00, 0x30, 0x10, 0x00,
0x10, 0x10, 0x90, 0x60, 0x80, 0x80, 0x88, 0x90, 0xA0, 0xD0, 0x88, 0x00, 0x88, 0x88, 0x88, 0x50, 0x50, 0x20, 0x20, 0x00, 0x82, 0x82, 0x82,
0xC0, 0x40, 0x40, 0x82, 0x92, 0x92,
0x40, 0x40, 0x40, 0xE0, 0x00, 0x00, 0x00, 0xEC, 0x92, 0x92, 0x92, 0x92, 0x00, 0x6C, 0x00,
0x00, 0x00, 0x88, 0x88, 0x50, 0x20, 0x50, 0x88, 0x88, 0x00, 0x88, 0x88, 0x88,
0xB0, 0xC8, 0x88, 0x88, 0x88, 0x00, 0x00, 0x00, 0x70, 0x88, 0x88, 0x88, 0x70, 0x00, 0x50, 0x20,
0x00, 0x20, 0x20, 0x00,
0x00, 0xB0, 0xC8, 0xC8, 0xB0, 0x80, 0x80, 0x00, 0x00, 0x68, 0x98, 0x98, 0x68, 0x08, 0x08, 0xF8, 0x08, 0x10, 0x20, 0x40, 0x80, 0xF8, 0x00, 0xE0, 0x80, 0x80,
0x80,
0x00, 0x00, 0xB0, 0xC8, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x78, 0x80, 0x70, 0x08, 0xF0, 0x80, 0x80, 0xE0, 0x00,
0x00, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0xE0, 0x20, 0x20,
0x40, 0x40, 0xE0, 0x40, 0x40, 0x50, 0x20, 0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0x98, 0x20, 0x20, 0x20, 0xE0, 0x00,
0x68, 0x00, 0x20, 0x50, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x88, 0x88, 0x88, 0x50, 0x20, 0x00, 0x00, 0x00, 0x82, 0x82, 0x92, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00,
0x92, 0x6C, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x88, 0x50, 0x20, 0x50, 0x88, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x70, 0x08, 0x78, 0x88, 0x74, 0x00,
0x98, 0x68, 0x08, 0x70, 0x80, 0x80, 0xB0, 0xC8, 0x88, 0xC8, 0xB0, 0x00,
0x00, 0x00, 0xF8, 0x10, 0x20, 0x40, 0xF8, 0x00, 0x10, 0x20, 0x20, 0x00, 0x00, 0x70, 0x88, 0x80, 0x88, 0x70, 0x00,
0x40, 0x20, 0x20, 0x10, 0x00, 0x08, 0x08, 0x68, 0x98, 0x88, 0x98, 0x68,
0x40, 0x40, 0x40, 0x00, 0x40, 0x40, 0x40, 0x00, 0x40, 0x20, 0x00, 0x00, 0x00, 0x70, 0x88, 0xF8, 0x80, 0x70, 0x00,
0x20, 0x10, 0x20, 0x20, 0x40, 0x00, 0x30, 0x48, 0x40, 0xE0, 0x40, 0x40,
0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x34, 0x48, 0x48, 0x38, 0x08, 0x30,
0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00, 0x80, 0x80, 0xB0, 0xC8, 0x88,
0x3E, 0x60, 0xC0, 0x60, 0x3E, 0x08, 0x04, 0x18, 0x88, 0x88, 0x00, 0x20, 0x00, 0x60, 0x20, 0x20, 0x20, 0x70, 0x00,
0x00, 0x48, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x10, 0x00, 0x30, 0x10,
0x18, 0x20, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x10, 0x10, 0x90, 0x60, 0x80, 0x80, 0x88, 0x90, 0xA0, 0xD0, 0x88,
0x78, 0x10, 0x28, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00,
0x00, 0x48, 0x00, 0x78, 0x0C, 0x7C, 0xC0, 0x40, 0x40,
0xCC, 0x76, 0x30, 0x08, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x40, 0x40, 0x40, 0xE0, 0x00, 0x00, 0x00, 0xEC, 0x92, 0x92, 0x92,
0x48, 0x30, 0x00, 0x78, 0x0C, 0x92, 0x00,
0x7C, 0xCC, 0x76, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x10, 0x08, 0x30, 0x00, 0x00,
0x30, 0x48, 0x84, 0x78, 0xB0, 0xC8, 0x88, 0x88, 0x88, 0x00, 0x00, 0x00, 0x70, 0x88, 0x88,
0xCC, 0xFC, 0xC0, 0x78, 0x00, 0x48, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x88, 0x70, 0x00,
0x30, 0x08, 0x00, 0x00,
0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, 0x48, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0xB0, 0xC8, 0xC8, 0xB0, 0x80, 0x80, 0x00, 0x00, 0x68, 0x98,
0x30, 0x48, 0x98, 0x68, 0x08, 0x08,
0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x60, 0x10, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30,
0x48, 0x00, 0x00, 0xB0, 0xC8, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x78,
0x00, 0x30, 0x78, 0xCC, 0xCC, 0xFC, 0xCC, 0x30, 0x48, 0x30, 0x48, 0x84, 0xFC, 0x84, 0x84, 0x80, 0x70, 0x08, 0xF0,
0x00,
0x18, 0x20, 0x00, 0xF8, 0x80, 0xF0, 0x80, 0xF8, 0x00, 0x00, 0x00, 0x66, 0x19, 0x77, 0x88, 0x40, 0x40, 0xE0, 0x40, 0x40, 0x50, 0x20, 0x00, 0x00, 0x00, 0x88,
0x77, 0x88, 0x88, 0x98,
0x00, 0x00, 0x00, 0x0F, 0x14, 0x3E, 0x44, 0x87, 0x30, 0x48, 0x84, 0x78, 0xCC, 0xCC, 0x68, 0x00,
0xCC, 0x78, 0x00, 0x00, 0x88, 0x88, 0x88, 0x50, 0x20, 0x00, 0x00, 0x00, 0x82,
0x00, 0x48, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x60, 0x10, 0x00, 0x78, 0xCC, 0x82, 0x92,
0xCC, 0xCC, 0x78, 0x92, 0x6C, 0x00,
0x30, 0x48, 0x84, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x60, 0x10, 0x00, 0xCC, 0x00, 0x00, 0x88, 0x50, 0x20, 0x50, 0x88, 0x00, 0x00, 0x00, 0x88,
0xCC, 0xCC, 0xCC, 0x76, 0x88,
0x48, 0x00, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, 0x44, 0x00, 0x38, 0x98, 0x68, 0x08, 0x70,
0x6C, 0xC6, 0xC6, 0x6C, 0x38, 0x00, 0x00, 0xF8, 0x10, 0x20, 0x40, 0xF8, 0x00, 0x10, 0x20, 0x20,
0x24, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x08, 0x40, 0x20, 0x20, 0x10, 0x00,
0x1C, 0x28, 0x28, 0x1C, 0x08, 0x00, 0x40, 0x40, 0x40, 0x00, 0x40, 0x40, 0x40, 0x00, 0x40, 0x20,
0x1C, 0x22, 0x20, 0x70, 0x20, 0x22, 0x5C, 0x00, 0x44, 0x20, 0x10, 0x20, 0x20, 0x40, 0x00,
0x28, 0x10, 0x10, 0x38, 0x10, 0x38, 0x10, 0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xF0, 0x88, 0x8A, 0xF7, 0x82, 0x82, 0x83, 0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00,
0x06, 0x08, 0x08, 0x3C, 0x10, 0x10, 0x60, 0x00, 0x3E, 0x60, 0xC0, 0x60, 0x3E, 0x08, 0x04, 0x18,
0x18, 0x20, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x00, 0x48, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76,
0x76, 0x18, 0x20, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x20, 0x00, 0x78, 0xCC, 0xFC, 0xC0,
0x18, 0x20, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x10, 0x28, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76,
0xCC, 0x78, 0x18, 0x20, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x48, 0x00, 0x78, 0x0C, 0x7C,
0x80, 0x78, 0x04, 0xF8, 0xCC, 0xCC, 0x76, 0x30, 0x08, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76,
0xCC, 0xCC, 0xCC, 0x80, 0x7E, 0x01, 0xC6, 0xE6, 0xD6, 0xCE, 0xC6, 0x48, 0x30, 0x00, 0x78, 0x0C,
0x00, 0x78, 0x0C, 0x7C, 0x7C, 0xCC, 0x76, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x10, 0x08, 0x30,
0xCC, 0x76, 0x00, 0xFE, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00, 0xFC, 0x30, 0x48, 0x84, 0x78,
0x00, 0x00, 0x18, 0xCC, 0xFC, 0xC0, 0x78, 0x00, 0x48, 0x00, 0x78, 0xCC, 0xFC, 0xC0,
0x18, 0x30, 0x60, 0x66, 0x3C, 0xFF, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x78,
0xFF, 0x01, 0x30, 0x08, 0x00,
0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x40, 0xC4, 0x48, 0x50, 0x26, 0x49, 0x82, 0x07, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, 0x48, 0x00, 0x30, 0x30, 0x30,
0x40, 0x30, 0x30,
0xC4, 0x48, 0x50, 0x26, 0x4A, 0x9F, 0x02, 0x00, 0x30, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x48,
0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x60, 0x10, 0x00, 0x30, 0x30,
0x00, 0x12, 0x24, 0x48, 0x90, 0x48, 0x24, 0x12, 0x00, 0x48, 0x24, 0x12, 0x09, 0x12, 0x24, 0x30, 0x30, 0x30,
0x48, 0x48,
0x49, 0x00, 0x92, 0x00, 0x49, 0x00, 0x92, 0x00, 0x6D, 0x00, 0xB6, 0x00, 0x6D, 0x00, 0x00, 0x30, 0x78, 0xCC, 0xCC, 0xFC, 0xCC, 0x30, 0x48, 0x30, 0x48,
0xB6, 0x00, 0x84, 0xFC, 0x84, 0x84,
0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x18, 0x20, 0x00, 0xF8, 0x80, 0xF0, 0x80, 0xF8, 0x00, 0x00, 0x00,
0x10, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xF0, 0x66, 0x19, 0x77, 0x88,
0x10, 0xF0, 0x10, 0x10, 0x77,
0x28, 0x28, 0x28, 0x28, 0xE8, 0x28, 0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x14, 0x3E, 0x44, 0x87, 0x30, 0x48, 0x84,
0x00, 0xF8, 0x28, 0x28, 0x28, 0x78, 0xCC, 0xCC,
0x00, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x10, 0x10, 0x28, 0x28, 0xCC, 0x78,
0x28, 0xE8, 0x08, 0xE8, 0x28, 0x28, 0x00, 0x48, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x60, 0x10, 0x00,
0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x00, 0x78, 0xCC,
0x00, 0x00, 0xF8, 0x08, 0xE8, 0x28, 0x28, 0xCC, 0xCC, 0x78,
0x28, 0x28, 0x28, 0xE8, 0x08, 0xF8, 0x00, 0x00, 0x30, 0x48, 0x84, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x60, 0x10, 0x00,
0x28, 0x28, 0x28, 0x28, 0xF8, 0x00, 0x00, 0x00, 0xCC,
0x10, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00, 0xCC, 0xCC, 0xCC, 0x76,
0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0x10, 0x10, 0x48, 0x00, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, 0x44, 0x00, 0x38,
0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x6C, 0xC6, 0xC6, 0x6C, 0x38,
0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x00, 0x00, 0x24, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x08,
0x00, 0x00, 0x00, 0x00, 0xFF, 0x1C, 0x28, 0x28, 0x1C, 0x08, 0x00,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x10, 0x10, 0x10, 0x1C, 0x22, 0x20, 0x70, 0x20, 0x22, 0x5C, 0x00, 0x44,
0x00, 0x00, 0x00, 0x00, 0x28, 0x10, 0x10, 0x38, 0x10, 0x38, 0x10,
0xFF, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x10, 0x10, 0xF0, 0x88, 0x8A, 0xF7, 0x82, 0x82, 0x83, 0x00,
0x10, 0x10, 0x10, 0x06, 0x08, 0x08, 0x3C, 0x10, 0x10, 0x60, 0x00,
0x1F, 0x10, 0x1F, 0x10, 0x10, 0x28, 0x28, 0x28, 0x28, 0x3F, 0x28, 0x28, 0x28, 0x18, 0x20, 0x00, 0x78, 0x0C, 0x7C, 0xCC,
0x28, 0x28, 0x76, 0x18, 0x20, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30,
0x28, 0x2F, 0x20, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x20, 0x2F, 0x28, 0x28, 0x18, 0x20, 0x00, 0x78, 0xCC, 0xCC,
0x28, 0xCC, 0x78, 0x18, 0x20, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76,
0x28, 0x28, 0xEF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xEF, 0x28, 0x28, 0x80, 0x78, 0x04, 0xF8, 0xCC,
0xCC, 0xCC, 0xCC, 0x80, 0x7E, 0x01, 0xC6, 0xE6, 0xD6, 0xCE, 0xC6,
0x28, 0x28, 0x28, 0x2F, 0x20, 0x2F, 0x28, 0x28, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x78, 0x0C, 0x7C,
0x00, 0xCC, 0x76, 0x00, 0xFE, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00,
0x28, 0x28, 0x28, 0xEF, 0x00, 0xEF, 0x28, 0x28, 0x10, 0x10, 0x10, 0xFF, 0x00, 0xFF, 0xFC,
0x00, 0x00, 0x00, 0x00, 0x18,
0x28, 0x28, 0x28, 0x28, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x18, 0x30, 0x60, 0x66, 0x3C, 0xFF, 0x80, 0x80, 0x80, 0x00, 0x00,
0xFF, 0x10, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0xFF, 0x01,
0x3F, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x40, 0xC4, 0x48, 0x50, 0x26,
0x10, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x82, 0x07,
0x1F, 0x10, 0x1F, 0x10, 0x10, 0x40,
0x00, 0x00, 0x00, 0x00, 0x3F, 0x28, 0x28, 0x28, 0x28, 0x28, 0xC4, 0x48, 0x50, 0x26, 0x4A, 0x9F, 0x02, 0x00, 0x30, 0x00, 0x30,
0x28, 0x28, 0xFF, 0x28, 0x28, 0x28, 0x30, 0x30, 0x30, 0x30,
0x10, 0x10, 0x10, 0xFF, 0x10, 0xFF, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x12, 0x24, 0x48, 0x90, 0x48, 0x24, 0x12, 0x00, 0x48, 0x24,
0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x12, 0x09, 0x12, 0x24,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x48,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x49, 0x00, 0x92, 0x00, 0x49, 0x00, 0x92, 0x00, 0x6D, 0x00, 0xB6,
0x00, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x00, 0x6D, 0x00,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xB6, 0x00,
0x07, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0x10, 0x10, 0x10,
0x00, 0x00, 0x00, 0x02, 0x34, 0x10, 0x10,
0x4C, 0x4C, 0x32, 0x00, 0x5C, 0x22, 0x22, 0x3C, 0x44, 0x44, 0x78, 0x10, 0x10, 0x10,
0x7E, 0x42, 0x42, 0x40, 0x10, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x02, 0x7C, 0xA8, 0x28, 0x28, 0x44, 0xF0,
0x00, 0x7E, 0x61, 0x10, 0xF0, 0x10, 0x10,
0x30, 0x18, 0x08, 0x10, 0x20, 0x00, 0x00, 0x08, 0x7F, 0x88, 0x88, 0x88, 0x70, 0x28, 0x28, 0x28, 0x28, 0xE8, 0x28, 0x28, 0x28, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xF8, 0x28, 0x28, 0x28,
0x00, 0x22, 0x44, 0x44, 0x7A, 0x80, 0x00, 0x00, 0x00, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x10, 0x10, 0x28, 0x28,
0x00, 0x28, 0xE8, 0x08, 0xE8, 0x28, 0x28,
0x1C, 0x08, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x00, 0x38, 0x44, 0x44, 0x7C, 0x44, 0x44, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x00,
0x00, 0x00, 0xF8, 0x08, 0xE8, 0x28, 0x28,
0x3C, 0x66, 0xC3, 0xC3, 0xC3, 0x66, 0x24, 0x66, 0x0C, 0x10, 0x08, 0x1C, 0x22, 0x22, 0x22, 0x28, 0x28, 0x28, 0xE8, 0x08, 0xF8, 0x00, 0x00,
0x1C, 0x28, 0x28, 0x28, 0x28, 0xF8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x6C, 0x92, 0x92, 0x6C, 0x00, 0x01, 0x1A, 0x26, 0x2A, 0x32, 0x10, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00,
0x2C, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0x10, 0x10,
0x00, 0x18, 0x20, 0x20, 0x30, 0x20, 0x20, 0x18, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00,
0x42, 0x42, 0x42, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x08, 0x08, 0x3E, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x08, 0x08, 0x00, 0x3E, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x10, 0x10, 0x10,
0x00, 0x10, 0x08, 0x04, 0x08, 0x10, 0x00, 0x3E, 0x00, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
0x10, 0x08, 0x04, 0x00, 0x3E, 0xFF, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x10,
0x00, 0x06, 0x09, 0x09, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x10,
0x08, 0x08, 0x08, 0x48, 0x48, 0x30, 0x10, 0x10, 0x10,
0x00, 0x00, 0x08, 0x00, 0x3E, 0x00, 0x08, 0x00, 0x00, 0x1F, 0x10, 0x1F, 0x10, 0x10, 0x28, 0x28, 0x28, 0x28, 0x3F, 0x28,
0x60, 0x92, 0x0C, 0x60, 0x92, 0x0C, 0x00, 0x28, 0x28,
0x60, 0x90, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x28,
0x00, 0x00, 0x00, 0x30, 0x78, 0x30, 0x00, 0x00, 0x28, 0x2F, 0x20, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x20,
0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x2F, 0x28, 0x28,
0x00, 0x00, 0x03, 0x04, 0x04, 0xC8, 0x28, 0x10, 0x00, 0x28,
0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x28, 0x28, 0xEF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x42, 0x00, 0x18, 0x24, 0x08, 0x10, 0x3C, 0x00, 0x00, 0x00, 0x00, 0xEF, 0x28, 0x28,
0x00, 0x00, 0x00, 0x3E, 0x3E,
0x3E, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 0x28, 0x28, 0x28, 0x2F, 0x20, 0x2F, 0x28, 0x28, 0x00, 0x00, 0x00,
}; 0xFF, 0x00, 0xFF, 0x00,
0x00,
0x28, 0x28, 0x28, 0xEF, 0x00, 0xEF, 0x28, 0x28, 0x10, 0x10, 0x10,
0xFF, 0x00, 0xFF,
0x00, 0x00,
0x28, 0x28, 0x28, 0x28, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0x00,
0xFF, 0x10, 0x10,
0x00, 0x00, 0x00, 0x00, 0xFF, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
0x28,
0x3F, 0x00, 0x00, 0x00,
0x10, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1F, 0x10, 0x1F, 0x10, 0x10,
0x00, 0x00, 0x00, 0x00, 0x3F, 0x28, 0x28, 0x28, 0x28, 0x28,
0x28, 0x28, 0xFF, 0x28, 0x28, 0x28,
0x10, 0x10, 0x10, 0xFF, 0x10, 0xFF, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
0x00, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x02, 0x34,
0x4C, 0x4C, 0x32, 0x00, 0x5C, 0x22, 0x22, 0x3C, 0x44, 0x44, 0x78,
0x7E, 0x42, 0x42, 0x40,
0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x02, 0x7C, 0xA8, 0x28, 0x28,
0x44,
0x00, 0x7E, 0x61,
0x30, 0x18, 0x08, 0x10, 0x20, 0x00, 0x00, 0x08, 0x7F, 0x88, 0x88,
0x88, 0x70,
0x00, 0x00,
0x00, 0x22, 0x44, 0x44, 0x7A, 0x80, 0x00, 0x00, 0x00, 0x7C, 0x10,
0x10, 0x10, 0x10,
0x00,
0x1C, 0x08, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x00, 0x38, 0x44,
0x44, 0x7C, 0x44, 0x44,
0x3C, 0x66, 0xC3, 0xC3, 0xC3, 0x66, 0x24, 0x66, 0x0C, 0x10, 0x08,
0x1C, 0x22, 0x22, 0x22,
0x1C,
0x00, 0x00, 0x00, 0x00, 0x6C, 0x92, 0x92, 0x6C, 0x00, 0x01, 0x1A,
0x26, 0x2A, 0x32,
0x2C, 0x40,
0x00, 0x18, 0x20, 0x20, 0x30, 0x20, 0x20, 0x18, 0x00, 0x3C, 0x42,
0x42, 0x42,
0x42, 0x42, 0x42,
0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x08, 0x08,
0x3E,
0x08, 0x08, 0x00, 0x3E,
0x00, 0x10, 0x08, 0x04, 0x08, 0x10, 0x00, 0x3E, 0x00, 0x04, 0x08,
0x10, 0x08, 0x04, 0x00, 0x3E,
0x00, 0x06, 0x09, 0x09, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00,
0x08, 0x08, 0x08, 0x48, 0x48, 0x30,
0x00, 0x00, 0x08, 0x00, 0x3E, 0x00, 0x08, 0x00, 0x00,
0x60, 0x92, 0x0C, 0x60, 0x92, 0x0C, 0x00,
0x60, 0x90, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x30, 0x78, 0x30, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
0x00, 0x00, 0x03, 0x04, 0x04, 0xC8, 0x28, 0x10, 0x00,
0x00, 0x00, 0x00, 0x7C, 0x42, 0x42,
0x42, 0x00, 0x18, 0x24, 0x08, 0x10, 0x3C, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3E, 0x3E,
0x3E, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

View File

@ -1,4 +1,4 @@
static u8 ansilogo[]="\ static u8 ansilogo[] = "\
\033[0m\033[1m\ \033[0m\033[1m\
\xDA\033[0m\xC4\xC4\033[1;30m\xC4\033[0m\xC4\033[1;30m\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\033[37m \033[0;31mC\033[1;37m \033[31m\x4F\033[37m \033[33mS\033[37m \033[36m2\033[37m \033[0;36m0\033[1;37m \033[34m0\033[37m \033[0;34m0\033[1;37m \033[0mV2.2.1\033[1m \033[30m\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xBF\r\n\ \xDA\033[0m\xC4\xC4\033[1;30m\xC4\033[0m\xC4\033[1;30m\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\033[37m \033[0;31mC\033[1;37m \033[31m\x4F\033[37m \033[33mS\033[37m \033[36m2\033[37m \033[0;36m0\033[1;37m \033[34m0\033[37m \033[0;34m0\033[1;37m \033[0mV2.2.1\033[1m \033[30m\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xBF\r\n\
\033[0m\xB3\033[77C\033[1;30m\xB3\r\n\ \033[0m\xB3\033[77C\033[1;30m\xB3\r\n\

View File

@ -5,16 +5,16 @@
/* definition des registres de la carte VGA pour differents modes */ /* definition des registres de la carte VGA pour differents modes */
static capabilities vgacapabilities[] = { static capabilities vgacapabilities[] = {
{0x00, 80, 25,false, 4, 0}, {0x00, 80, 25, false, 4, 0},
{0x01, 80, 50,false, 4, 0}, {0x01, 80, 50, false, 4, 0},
{0x80,640,480,true , 1, 0}, {0x80, 640, 480, true, 1, 0},
{0x81,320,200,true , 2, 0}, {0x81, 320, 200, true, 2, 0},
{0x82,640,480,true , 4, 0}, {0x82, 640, 480, true, 4, 0},
{0x83,320,200,true , 8, 0}, {0x83, 320, 200, true, 8, 0},
{0x84,320,400,true , 8, 0}, {0x84, 320, 400, true, 8, 0},
{0x85,320,480,true , 8, 0}, {0x85, 320, 480, true, 8, 0},
{0x86,360,480,true , 8, 0}, {0x86, 360, 480, true, 8, 0},
{0xFF,000,000,false, 0, 0}, {0xFF, 000, 000, false, 0, 0},
}; };
@ -23,99 +23,108 @@ static vgamode modes[] = {
/*80*25 16 couleurs mode 0x00 */ /*80*25 16 couleurs mode 0x00 */
{{0x67}, {{0x67},
{0x03, 0x00, 0x03, 0x00, 0x02}, {0x03, 0x00, 0x03, 0x00, 0x02},
{0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00, {0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00,
0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x0E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0xFF}, 0x9C, 0x0E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A,
0x3C, 0x3D, 0x3E, 0x3F, 0x3B,
0x0C, 0x00, 0x0F, 0x08, 0x00}}, 0x3C, 0x3D, 0x3E, 0x3F,
0x0C, 0x00, 0x0F, 0x08, 0x00}},
/*80*50 16 couleurs mode 0x01 */ /*80*50 16 couleurs mode 0x01 */
{{0x63}, {{0x63},
{0x03, 0x01, 0x03, 0x05, 0x02}, {0x03, 0x01, 0x03, 0x05, 0x02},
{0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00, {0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00,
0x47, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, 0x47, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x8E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0xFF}, 0x9C, 0x8E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A,
0x3C, 0x3D, 0x3E, 0x3F, 0x3B,
0x0C, 0x00, 0x0F, 0x00, 0x00}}, 0x3C, 0x3D, 0x3E, 0x3F,
0x0C, 0x00, 0x0F, 0x00, 0x00}},
/*640*480 n&b mode 0x80 */ /*640*480 n&b mode 0x80 */
{{0xE3}, {{0xE3},
{0x03, 0x01, 0x0F, 0x00, 0x06}, {0x03, 0x01, 0x0F, 0x00, 0x06},
{0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00, {0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xEA, 0x0C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF}, 0xEA, 0x0C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B, {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A,
0x3C, 0x3D, 0x3E, 0x3F, 0x3B,
0x01, 0x00, 0x0F, 0x00, 0x00}}, 0x3C, 0x3D, 0x3E, 0x3F,
0x01, 0x00, 0x0F, 0x00, 0x00}},
/*320*200 4 couleurs mode 0x81 */ /*320*200 4 couleurs mode 0x81 */
{{0x63}, {{0x63},
{0x03, 0x09, 0x03, 0x00, 0x02}, {0x03, 0x09, 0x03, 0x00, 0x02},
{0x2D, 0x27, 0x28, 0x90, 0x2B, 0x80, 0xBF, 0x1F, 0x00, {0x2D, 0x27, 0x28, 0x90, 0x2B, 0x80, 0xBF, 0x1F, 0x00,
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x0E, 0x8F, 0x14, 0x00, 0x96, 0xB9, 0xA3, 0xFF}, 0x9C, 0x0E, 0x8F, 0x14, 0x00, 0x96, 0xB9, 0xA3, 0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x02, 0x00, 0xFF}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x02, 0x00, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B, {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A,
0x3C, 0x3D, 0x3E, 0x3F, 0x3B,
0x01, 0x00, 0x03, 0x00, 0x00}}, 0x3C, 0x3D, 0x3E, 0x3F,
0x01, 0x00, 0x03, 0x00, 0x00}},
/*640*480 16 couleurs mode 0x82 */ /*640*480 16 couleurs mode 0x82 */
{{0xE3}, {{0xE3},
{0x03, 0x01, 0x0F, 0x00, 0x06}, {0x03, 0x01, 0x0F, 0x00, 0x06},
{0x5F, 0x4F, 0x50, 0x82, 0x53, 0x9F, 0x0B, 0x3E, 0x00, {0x5F, 0x4F, 0x50, 0x82, 0x53, 0x9F, 0x0B, 0x3E, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xE9, 0x8B, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF}, 0xE9, 0x8B, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B, {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A,
0x3C, 0x3D, 0x3E, 0x3F, 0x3B,
0x01, 0x00, 0x0F, 0x00, 0x00}}, 0x3C, 0x3D, 0x3E, 0x3F,
0x01, 0x00, 0x0F, 0x00, 0x00}},
/*320*200 256 couleurs RAPIDE mode 0x83 */ /*320*200 256 couleurs RAPIDE mode 0x83 */
{{0x63}, {{0x63},
{0x03, 0x01, 0x0F, 0x00, 0x0E}, {0x03, 0x01, 0x0F, 0x00, 0x0E},
{0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00, {0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00,
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x0E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3, 0xFF}, 0x9C, 0x0E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3, 0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0x0C, 0x0D, 0x0E, 0x0F, 0x0B,
0x41, 0x00, 0x0F, 0x00, 0x00}}, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00}},
/*320*400 256 couleurs mode 0x84 */ /*320*400 256 couleurs mode 0x84 */
{{0x63}, {{0x63},
{0x03, 0x01, 0x0F, 0x00, 0x06}, {0x03, 0x01, 0x0F, 0x00, 0x06},
{0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00, {0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x8E, 0x8F, 0x28, 0x00, 0x96, 0xB9, 0xE3, 0xFF}, 0x9C, 0x8E, 0x8F, 0x28, 0x00, 0x96, 0xB9, 0xE3, 0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0x0C, 0x0D, 0x0E, 0x0F, 0x0B,
0x41, 0x00, 0x0F, 0x00, 0x00}}, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00}},
/*320*480 256 couleurs mode 0x85 */ /*320*480 256 couleurs mode 0x85 */
{{0xE3}, {{0xE3},
{0x03, 0x01, 0x0F, 0x00, 0x06}, {0x03, 0x01, 0x0F, 0x00, 0x06},
{0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00, {0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xEA, 0xAC, 0xDF, 0x28, 0x00, 0xE7, 0x06, 0xE3, 0xFF}, 0xEA, 0xAC, 0xDF, 0x28, 0x00, 0xE7, 0x06, 0xE3, 0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0x0C, 0x0D, 0x0E, 0x0F, 0x0B,
0x41, 0x00, 0x0F, 0x00, 0x00}}, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00}},
/*360*480 256 couleurs mode 0x86 */ /*360*480 256 couleurs mode 0x86 */
{{0xE7}, {{0xE7},
{0x03, 0x01, 0x0F, 0x00, 0x06}, {0x03, 0x01, 0x0F, 0x00, 0x06},
{0x6B, 0x59, 0x5A, 0x8E, 0x5E, 0x8A, 0x0D, 0x3E, 0x00, {0x6B, 0x59, 0x5A, 0x8E, 0x5E, 0x8A, 0x0D, 0x3E, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xEA, 0xAC, 0xDF, 0x2D, 0x00, 0xE7, 0x06, 0xE3, 0xFF}, 0xEA, 0xAC, 0xDF, 0x2D, 0x00, 0xE7, 0x06, 0xE3, 0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0x0C, 0x0D, 0x0E, 0x0F, 0x0B,
0x41, 0x00, 0x0F, 0x00, 0x00}}, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00}},
}; };

290
lib/cpu.c
View File

@ -38,8 +38,8 @@ static u8 space[] = " ";
bool cansetflag(u32 flag) bool cansetflag(u32 flag)
{ {
u32 r1, r2; 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; return ((r1 ^ r2) & flag) != 0;
} }
@ -48,7 +48,7 @@ bool cansetflag(u32 flag)
void cpuid(u32 op, u32 * eax, u32 * ebx, u32 * ecx, u32 * edx) 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"); asm("cpuid": "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx): "a"(op):"cc");
} }
/******************************************************************************/ /******************************************************************************/
@ -56,8 +56,9 @@ void cpuid(u32 op, u32 * eax, u32 * ebx, u32 * ecx, u32 * edx)
u8 getcpuinfos(cpuinfo * proc) u8 getcpuinfos(cpuinfo * proc)
{ {
u32 i, maxfunction, maxextended, unused, regeax, regebx, regecx, regedx; u32 i, maxfunction, maxextended, unused, regeax, regebx,
bool *boolean; regecx, regedx;
bool *boolean;
if (!cansetflag(0x00040000)) if (!cansetflag(0x00040000))
return 1; /*386 processor - no cpuid */ return 1; /*386 processor - no cpuid */
@ -68,7 +69,8 @@ u8 getcpuinfos(cpuinfo * proc)
maxfunction &= 0xffff; maxfunction &= 0xffff;
cpuid(0x80000000, &maxextended, &unused, &unused, &unused); cpuid(0x80000000, &maxextended, &unused, &unused, &unused);
maxextended &= 0xffff; maxextended &= 0xffff;
if (maxfunction >= 1) { if (maxfunction >= 1)
{
cpuid(1, &regeax, &regebx, &regecx, &regedx); cpuid(1, &regeax, &regebx, &regecx, &regedx);
proc->stepping = (regeax & 0x0000000F); proc->stepping = (regeax & 0x0000000F);
proc->models = ((regeax >> 4) & 0x0000000F); proc->models = ((regeax >> 4) & 0x0000000F);
@ -93,7 +95,8 @@ u8 getcpuinfos(cpuinfo * proc)
proc->sse42 = ((regecx >> 20) & 0x00000001); proc->sse42 = ((regecx >> 20) & 0x00000001);
proc->apic2 = ((regecx >> 21) & 0x00000001); proc->apic2 = ((regecx >> 21) & 0x00000001);
} }
if (maxextended >= 1) { if (maxextended >= 1)
{
cpuid(0x80000001, &regeax, &regebx, &regecx, &regedx); cpuid(0x80000001, &regeax, &regebx, &regecx, &regedx);
proc->mmx2 = ((regedx >> 22) & 0x00000001); proc->mmx2 = ((regedx >> 22) & 0x00000001);
proc->apic = ((regedx >> 9) & 0x00000001); proc->apic = ((regedx >> 9) & 0x00000001);
@ -104,22 +107,29 @@ u8 getcpuinfos(cpuinfo * proc)
proc->msr = ((regedx >> 5) & 0x00000001); proc->msr = ((regedx >> 5) & 0x00000001);
proc->sse4a = ((regecx >> 6) & 0x00000001); proc->sse4a = ((regecx >> 6) & 0x00000001);
} }
if (maxextended >= 4) { if (maxextended >= 4)
int i; {
for (i = 0; i < 3; i++) { int i;
for (i = 0; i < 3; i++)
{
cpuid(0x80000002 + i, &regeax, &regebx, &regecx, cpuid(0x80000002 + i, &regeax, &regebx, &regecx,
&regedx); &regedx);
memcpy(&regeax, &proc->detectedname[0 + i * 16], 4, 1); memcpy(&regeax, &proc->detectedname[0 + i * 16], 4,
memcpy(&regebx, &proc->detectedname[4 + i * 16], 4, 1); 1);
memcpy(&regecx, &proc->detectedname[8 + i * 16], 4, 1); memcpy(&regebx, &proc->detectedname[4 + i * 16], 4,
memcpy(&regedx, &proc->detectedname[12 + i * 16], 4, 1); 1);
memcpy(&regecx, &proc->detectedname[8 + i * 16], 4,
1);
memcpy(&regedx, &proc->detectedname[12 + i * 16],
4, 1);
} }
} }
boolean = &proc->mmx; boolean = &proc->mmx;
i = 0; i = 0;
proc->techs[0]='\000'; proc->techs[0] = '\000';
for (i = 0; i < sizeof(msg); i++) for (i = 0; i < sizeof(msg); i++)
if (*(boolean++) == 1) { if (*(boolean++) == 1)
{
strcat(msg[i], &proc->techs); strcat(msg[i], &proc->techs);
strcat(space, &proc->techs); strcat(space, &proc->techs);
} }
@ -129,118 +139,172 @@ u8 getcpuinfos(cpuinfo * proc)
/******************************************************************************/ /******************************************************************************/
/* Affiche les registres CPU */ /* Affiche les registres CPU */
void show_lightcpu(regs *stack) void show_lightcpu(regs * stack)
{ {
u32 i; u32 i;
printf("\33[0mEAX=%Y EBX=%Y ECX=%Y EDX=%Y\r\n", stack->eax, stack->ebx, stack->ecx, stack->edx); printf("\33[0mEAX=%Y EBX=%Y ECX=%Y EDX=%Y\r\n", stack->eax,
printf("ESI=%Y EDI=%Y ESP=%Y EBP=%Y\r\n", stack->esi, stack->edi, stack->esp, stack->ebp); stack->ebx, stack->ecx, stack->edx);
printf("EIP=%Y EFL=%Y [%c%c%c%c%c%c%c%c%c]\r\n", stack->eip, stack->eflags, printf("ESI=%Y EDI=%Y ESP=%Y EBP=%Y\r\n", stack->esi, stack->edi,
(stack->eflags & (1 <<11)) ? 'O':'-', stack->esp, stack->ebp);
(stack->eflags & (1 <<10)) ? 'D':'-', printf("EIP=%Y EFL=%Y [%c%c%c%c%c%c%c%c%c]\r\n", stack->eip,
(stack->eflags & (1 << 9)) ? 'I':'-', stack->eflags, (stack->eflags & (1 << 11)) ? 'O' : '-',
(stack->eflags & (1 << 8)) ? 'T':'-', (stack->eflags & (1 << 10)) ? 'D' : '-',
(stack->eflags & (1 << 7)) ? 'S':'-', (stack->eflags & (1 << 9)) ? 'I' : '-',
(stack->eflags & (1 << 6)) ? 'Z':'-', (stack->eflags & (1 << 8)) ? 'T' : '-',
(stack->eflags & (1 << 4)) ? 'A':'-', (stack->eflags & (1 << 7)) ? 'S' : '-',
(stack->eflags & (1 << 2)) ? 'P':'-', (stack->eflags & (1 << 6)) ? 'Z' : '-',
(stack->eflags & (1 << 0)) ? 'C':'-'); (stack->eflags & (1 << 4)) ? 'A' : '-',
printf("CS =%hY DS =%hY SS =%hY ES =%hY FS =%hY GS =%hY\r\n",stack->cs,stack->ds,stack->ss,stack->es,stack->fs,stack->gs); (stack->eflags & (1 << 2)) ? 'P' : '-',
printf("CR0=%Y CR2=%Y CR3=%Y CR4=%Y\r\n\r\n\r\n",stack->cr0,stack->cr2,stack->cr3,stack->cr4); (stack->eflags & (1 << 0)) ? 'C' : '-');
printf("CS =%hY DS =%hY SS =%hY ES =%hY FS =%hY GS =%hY\r\n",
u8* size; stack->cs, stack->ds, stack->ss, stack->es, stack->fs,
u8* pointer; stack->gs);
for(i=20;i<50;i++) { printf("CR0=%Y CR2=%Y CR3=%Y CR4=%Y\r\n\r\n\r\n", stack->cr0,
pointer=stack->eip-i; stack->cr2, stack->cr3, stack->cr4);
size=pointer;
size+=50; u8 *size;
while(pointer<size) { u8 *pointer;
pointer+=disasm(pointer, NULL, false); for (i = 20; i < 50; i++)
if (pointer==stack->eip) break; {
} pointer = stack->eip - i;
if (pointer==stack->eip) break; size = pointer;
} size += 50;
if (pointer==stack->eip) while (pointer < size)
pointer=stack->eip-i; {
else pointer += disasm(pointer, NULL, false);
pointer=stack->eip; if (pointer == stack->eip)
size=pointer; break;
size+=50; }
while(pointer<size) if (pointer == stack->eip)
{ break;
if (pointer==stack->eip) }
print("\33[41m\33[1m"); if (pointer == stack->eip)
else pointer = stack->eip - i;
print("\33[40m\33[0m"); else
pointer+=disasm(pointer, NULL, true); pointer = stack->eip;
} size = pointer;
size += 50;
while (pointer < size)
{
if (pointer == stack->eip)
print("\33[41m\33[1m");
else
print("\33[40m\33[0m");
pointer += disasm(pointer, NULL, true);
}
printf("\33[0m\r\n\r\n\r\nSTACK\r\n"); printf("\33[0m\r\n\r\n\r\nSTACK\r\n");
if (abs(KERNEL_STACK_ADDR-stack->esp)>0x10000) if (abs(KERNEL_STACK_ADDR - stack->esp) > 0x10000)
printf("Pile invalide !"); printf("Pile invalide !");
else else
{ {
i=0; i = 0;
for (u32 *pointer = stack->esp; pointer < KERNEL_STACK_ADDR; pointer ++) { for (u32 * pointer = stack->esp;
if (i>0 && i % 10 == 0) print("\033[10A"); pointer < KERNEL_STACK_ADDR; pointer++)
if (i>=10) {
print("\033[25C"); if (i > 0 && i % 10 == 0)
printf("+%d:%Y - %Y\r\n", i++, pointer, (u32)(*pointer)); print("\033[10A");
} if (i >= 10)
for(u32 j=0;j<10-(i % 10);j++) print("\033[25C");
print("\033[01B"); printf("+%d:%Y - %Y\r\n", i++, pointer,
(u32) (*pointer));
}
for (u32 j = 0; j < 10 - (i % 10); j++)
print("\033[01B");
} }
} }
/******************************************************************************/ /******************************************************************************/
/* Affiche les registres CPU */ /* Affiche les registres CPU */
void show_cpu(regs *stack) void show_cpu(regs * stack)
{ {
printf("EAX=%Y EBX=%Y ECX=%Y EDX=%Y\r\n", stack->eax, stack->ebx, stack->ecx, stack->edx); printf("EAX=%Y EBX=%Y ECX=%Y EDX=%Y\r\n", stack->eax, stack->ebx,
printf("ESI=%Y EDI=%Y ESP=%Y EBP=%Y\r\n", stack->esi, stack->edi, stack->esp, stack->ebp); stack->ecx, stack->edx);
printf("EIP=%Y EFL=%Y [%c%c%c%c%c%c%c%c%c]\r\n", stack->eip, stack->eflags, printf("ESI=%Y EDI=%Y ESP=%Y EBP=%Y\r\n", stack->esi, stack->edi,
(stack->eflags & (1 <<11)) ? 'O':'-', stack->esp, stack->ebp);
(stack->eflags & (1 <<10)) ? 'D':'-', printf("EIP=%Y EFL=%Y [%c%c%c%c%c%c%c%c%c]\r\n", stack->eip,
(stack->eflags & (1 << 9)) ? 'I':'-', stack->eflags, (stack->eflags & (1 << 11)) ? 'O' : '-',
(stack->eflags & (1 << 8)) ? 'T':'-', (stack->eflags & (1 << 10)) ? 'D' : '-',
(stack->eflags & (1 << 7)) ? 'S':'-', (stack->eflags & (1 << 9)) ? 'I' : '-',
(stack->eflags & (1 << 6)) ? 'Z':'-', (stack->eflags & (1 << 8)) ? 'T' : '-',
(stack->eflags & (1 << 4)) ? 'A':'-', (stack->eflags & (1 << 7)) ? 'S' : '-',
(stack->eflags & (1 << 2)) ? 'P':'-', (stack->eflags & (1 << 6)) ? 'Z' : '-',
(stack->eflags & (1 << 0)) ? 'C':'-'); (stack->eflags & (1 << 4)) ? 'A' : '-',
printf("CS =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\r\n",stack->cs,getdesbase(stack->cs),getdeslimit(stack->cs),getdesdpl(stack->cs),getdestype(stack->cs),getdessize(stack->cs),getdesbit3(stack->cs),getdesbit2(stack->cs),getdesbit1(stack->cs),getdesalign(stack->cs)); (stack->eflags & (1 << 2)) ? 'P' : '-',
printf("DS =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\r\n",stack->ds,getdesbase(stack->ds),getdeslimit(stack->ds),getdesdpl(stack->ds),getdestype(stack->ds),getdessize(stack->ds),getdesbit3(stack->ds),getdesbit2(stack->ds),getdesbit1(stack->ds),getdesalign(stack->ds)); (stack->eflags & (1 << 0)) ? 'C' : '-');
printf("SS =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\r\n",stack->ss,getdesbase(stack->ss),getdeslimit(stack->ss),getdesdpl(stack->ss),getdestype(stack->ss),getdessize(stack->ss),getdesbit3(stack->ss),getdesbit2(stack->ss),getdesbit1(stack->ss),getdesalign(stack->ss)); printf("CS =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\r\n", stack->cs,
printf("ES =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\r\n",stack->es,getdesbase(stack->es),getdeslimit(stack->es),getdesdpl(stack->es),getdestype(stack->es),getdessize(stack->es),getdesbit3(stack->es),getdesbit2(stack->es),getdesbit1(stack->es),getdesalign(stack->es)); getdesbase(stack->cs), getdeslimit(stack->cs),
printf("FS =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\r\n",stack->fs,getdesbase(stack->fs),getdeslimit(stack->fs),getdesdpl(stack->fs),getdestype(stack->fs),getdessize(stack->fs),getdesbit3(stack->fs),getdesbit2(stack->fs),getdesbit1(stack->fs),getdesalign(stack->fs)); getdesdpl(stack->cs), getdestype(stack->cs),
printf("GS =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\r\n",stack->gs,getdesbase(stack->gs),getdeslimit(stack->gs),getdesdpl(stack->gs),getdestype(stack->gs),getdessize(stack->gs),getdesbit3(stack->gs),getdesbit2(stack->gs),getdesbit1(stack->gs),getdesalign(stack->gs)); getdessize(stack->cs), getdesbit3(stack->cs),
u32 tss; getdesbit2(stack->cs), getdesbit1(stack->cs),
str(tss); getdesalign(stack->cs));
printf("TR =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\r\n",stack->gs,getdesbase(tss),getdeslimit(tss),getdesdpl(tss),getdestype(tss),getdessize(tss),getdesbit3(tss),getdesbit2(tss),getdesbit1(tss),getdesalign(tss)); printf("DS =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\r\n", stack->ds,
getdesbase(stack->ds), getdeslimit(stack->ds),
getdesdpl(stack->ds), getdestype(stack->ds),
getdessize(stack->ds), getdesbit3(stack->ds),
getdesbit2(stack->ds), getdesbit1(stack->ds),
getdesalign(stack->ds));
printf("SS =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\r\n", stack->ss,
getdesbase(stack->ss), getdeslimit(stack->ss),
getdesdpl(stack->ss), getdestype(stack->ss),
getdessize(stack->ss), getdesbit3(stack->ss),
getdesbit2(stack->ss), getdesbit1(stack->ss),
getdesalign(stack->ss));
printf("ES =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\r\n", stack->es,
getdesbase(stack->es), getdeslimit(stack->es),
getdesdpl(stack->es), getdestype(stack->es),
getdessize(stack->es), getdesbit3(stack->es),
getdesbit2(stack->es), getdesbit1(stack->es),
getdesalign(stack->es));
printf("FS =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\r\n", stack->fs,
getdesbase(stack->fs), getdeslimit(stack->fs),
getdesdpl(stack->fs), getdestype(stack->fs),
getdessize(stack->fs), getdesbit3(stack->fs),
getdesbit2(stack->fs), getdesbit1(stack->fs),
getdesalign(stack->fs));
printf("GS =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\r\n", stack->gs,
getdesbase(stack->gs), getdeslimit(stack->gs),
getdesdpl(stack->gs), getdestype(stack->gs),
getdessize(stack->gs), getdesbit3(stack->gs),
getdesbit2(stack->gs), getdesbit1(stack->gs),
getdesalign(stack->gs));
u32 tss;
str(tss);
printf("TR =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\r\n", stack->gs,
getdesbase(tss), getdeslimit(tss), getdesdpl(tss),
getdestype(tss), getdessize(tss), getdesbit3(tss),
getdesbit2(tss), getdesbit1(tss), getdesalign(tss));
struct gdtr gdtreg; struct gdtr gdtreg;
sgdt(&gdtreg); sgdt(&gdtreg);
printf("GDT= %Y %Y\r\n",gdtreg.base,gdtreg.limite); printf("GDT= %Y %Y\r\n", gdtreg.base, gdtreg.limite);
struct idtr idtreg; struct idtr idtreg;
sidt(&idtreg); sidt(&idtreg);
printf("IDT= %Y %Y\r\n",idtreg.base,idtreg.limite); printf("IDT= %Y %Y\r\n", idtreg.base, idtreg.limite);
printf("CR0=%Y CR2=%Y CR3=%Y CR4=%Y\r\n",stack->cr0,stack->cr2,stack->cr3,stack->cr4); printf("CR0=%Y CR2=%Y CR3=%Y CR4=%Y\r\n", stack->cr0, stack->cr2,
printf("DR0=%Y DR1=%Y DR2=%Y DR3=%Y\r\n",stack->dr0,stack->dr1,stack->dr2,stack->dr3); stack->cr3, stack->cr4);
printf("DR6=%Y DR7=%Y\r\n",stack->dr6,stack->dr7); printf("DR0=%Y DR1=%Y DR2=%Y DR3=%Y\r\n", stack->dr0, stack->dr1,
printf("EFER=%lY\r\n",stack->efer); stack->dr2, stack->dr3);
printf("DR6=%Y DR7=%Y\r\n", stack->dr6, stack->dr7);
printf("EFER=%lY\r\n", stack->efer);
printf("STACK\r\n"); printf("STACK\r\n");
if (abs(KERNEL_STACK_ADDR-stack->esp)>0x10000) if (abs(KERNEL_STACK_ADDR - stack->esp) > 0x10000)
printf("Pile invalide !"); printf("Pile invalide !");
else else
{ {
u32 i=0; u32 i = 0;
for (u32 *pointer = stack->esp; pointer < KERNEL_STACK_ADDR; pointer ++) { for (u32 * pointer = stack->esp;
if (i>0 && i % 10 == 0) print("\033[10A"); pointer < KERNEL_STACK_ADDR; pointer++)
if (i>=10) {
print("\033[25C"); if (i > 0 && i % 10 == 0)
printf("+%d:%Y - %Y\r\n", i++, pointer, (u32)(*pointer)); print("\033[10A");
} if (i >= 10)
for(u32 j=0;j<10-(i % 10);j++) print("\033[25C");
print("\033[01B"); printf("+%d:%Y - %Y\r\n", i++, pointer,
(u32) (*pointer));
}
for (u32 j = 0; j < 10 - (i % 10); j++)
print("\033[01B");
} }
} }
/*******************************************************************************/ /*******************************************************************************/

File diff suppressed because it is too large Load Diff

119
lib/gdt.c
View File

@ -21,19 +21,19 @@ static struct tss tss0;
void initgdt(u32 offset) void initgdt(u32 offset)
{ {
makegdtdes(0x0, 0x00000, 0x00, 0x00, &gdt[0]); /* descripteur nul */ makegdtdes(0x0, 0x00000, 0x00, 0x00, &gdt[0]); /* descripteur nul */
makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_CODE | SEG_RING0 | SEG_READ | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[1]); /* code -> SEL_KERNEL_CODE */ makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_CODE | SEG_RING0 | SEG_READ | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[1]); /* code -> SEL_KERNEL_CODE */
makegdtdes(0x0, 0x00000, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING0 | SEG_EXPAND_DOWN | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[2]); /* pile -> SEL_KERNEL_STACK */ makegdtdes(0x0, 0x00000, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING0 | SEG_EXPAND_DOWN | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[2]); /* pile -> SEL_KERNEL_STACK */
makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_CODE | SEG_RING3 | SEG_CONFORMING | SEG_READ | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[3]); /* code -> SEL_USER_CODE */ makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_CODE | SEG_RING3 | SEG_CONFORMING | SEG_READ | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[3]); /* code -> SEL_USER_CODE */
makegdtdes(0x0, 0x00000, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING3 | SEG_EXPAND_DOWN | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[4]); /* pile -> SEL_USER_STACK */ makegdtdes(0x0, 0x00000, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING3 | SEG_EXPAND_DOWN | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[4]); /* pile -> SEL_USER_STACK */
makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING0 | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[5]); /* data -> SEL_KERNEL_DATA */ makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING0 | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[5]); /* data -> SEL_KERNEL_DATA */
makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING3 | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[6]); /* data -> SEL_USER_DATA */ makegdtdes(0x0, 0xFFFFF, SEG_PRESENT | SEG_NORMAL | SEG_DATA | SEG_RING3 | SEG_READ_WRITE | SEG_ACCESSED, GRANULARITY_4K | OPSIZE_32B | SYS_AVAILABLE, &gdt[6]); /* data -> SEL_USER_DATA */
tss0.trapflag = 0x00; tss0.trapflag = 0x00;
tss0.iomap = 0x00; tss0.iomap = 0x00;
tss0.esp0 = 0x1FFF0; tss0.esp0 = 0x1FFF0;
tss0.ss0 = SEL_TSS; tss0.ss0 = SEL_TSS;
makegdtdes(&tss0, 0x67, SEG_PRESENT | SEG_CODE | SEG_RING3 | SEG_ACCESSED , 0x00, &gdt[7]); /* descripteur de tss */ makegdtdes(&tss0, 0x67, SEG_PRESENT | SEG_CODE | SEG_RING3 | SEG_ACCESSED, 0x00, &gdt[7]); /* descripteur de tss */
/* initialise le registre gdt */ /* initialise le registre gdt */
gdtreg.limite = GDT_SIZE * sizeof(gdtdes); gdtreg.limite = GDT_SIZE * sizeof(gdtdes);
@ -49,7 +49,7 @@ void initgdt(u32 offset)
/*******************************************************************************/ /*******************************************************************************/
/* Change le TSS courant */ /* Change le TSS courant */
void setTSS(u32 ss,u32 sp) void setTSS(u32 ss, u32 sp)
{ {
tss0.esp0 = sp; tss0.esp0 = sp;
tss0.ss0 = ss; tss0.ss0 = ss;
@ -88,9 +88,10 @@ void initselectors(u32 executingoffset)
u32 getdesbase(u16 sel) u32 getdesbase(u16 sel)
{ {
gdtdes *entry=GDT_ADDR; gdtdes *entry = GDT_ADDR;
u8 index=sel/sizeof(gdtdes); u8 index = sel / sizeof(gdtdes);
return (entry[index].base0_15+(entry[index].base16_23<<16)+(entry[index].base24_31<<24)); return (entry[index].base0_15 + (entry[index].base16_23 << 16) +
(entry[index].base24_31 << 24));
} }
/*******************************************************************************/ /*******************************************************************************/
@ -98,9 +99,9 @@ u32 getdesbase(u16 sel)
u32 getdeslimit(u16 sel) u32 getdeslimit(u16 sel)
{ {
gdtdes *entry=GDT_ADDR; gdtdes *entry = GDT_ADDR;
u8 index=sel/sizeof(gdtdes); u8 index = sel / sizeof(gdtdes);
return (entry[index].lim0_15+(entry[index].lim16_19<<16)); return (entry[index].lim0_15 + (entry[index].lim16_19 << 16));
} }
/*******************************************************************************/ /*******************************************************************************/
@ -108,9 +109,9 @@ u32 getdeslimit(u16 sel)
u32 getdesdpl(u16 sel) u32 getdesdpl(u16 sel)
{ {
gdtdes *entry=GDT_ADDR; gdtdes *entry = GDT_ADDR;
u8 index=sel/sizeof(gdtdes); u8 index = sel / sizeof(gdtdes);
return (entry[index].acces>>5 & 0b11); return (entry[index].acces >> 5 & 0x03);
} }
/*******************************************************************************/ /*******************************************************************************/
@ -118,12 +119,15 @@ u32 getdesdpl(u16 sel)
u8 getdestype(u16 sel) u8 getdestype(u16 sel)
{ {
gdtdes *entry=GDT_ADDR; gdtdes *entry = GDT_ADDR;
u8 index=sel/sizeof(gdtdes); u8 index = sel / sizeof(gdtdes);
if (((entry[index].acces & 0b10100) == 0) && ((entry[index].acces & 0b01000) > 0) && ((entry[index].acces & 0b0001) > 0) && ((entry[index].flags & 0b0110) == 0)) if (((entry[index].acces & 0x14) == 0)
return 'T'; && ((entry[index].acces & 0x08) > 0)
else && ((entry[index].acces & 0x01) > 0)
return (((entry[index].acces & 0b1000) > 0) ? 'C' : 'D'); && ((entry[index].flags & 0x06) == 0))
return 'T';
else
return (((entry[index].acces & 0x08) > 0) ? 'C' : 'D');
} }
/*******************************************************************************/ /*******************************************************************************/
@ -131,12 +135,15 @@ u8 getdestype(u16 sel)
u8 getdesbit1(u16 sel) u8 getdesbit1(u16 sel)
{ {
gdtdes *entry=GDT_ADDR; gdtdes *entry = GDT_ADDR;
u8 index=sel/sizeof(gdtdes); u8 index = sel / sizeof(gdtdes);
if (((entry[index].acces & 0b10100) == 0) && ((entry[index].acces & 0b01000) > 0) && ((entry[index].acces & 0b0001) > 0) && ((entry[index].flags & 0b0110) == 0)) if (((entry[index].acces & 0x14) == 0)
return (((entry[index].acces & 0b10) > 0) ? 'B' : '-'); && ((entry[index].acces & 0x08) > 0)
else && ((entry[index].acces & 0x01) > 0)
return (((entry[index].acces & 0b1) > 0) ? 'A' : '-'); && ((entry[index].flags & 0x06) == 0))
return (((entry[index].acces & 0x04) > 0) ? 'B' : '-');
else
return (((entry[index].acces & 0x01) > 0) ? 'A' : '-');
} }
/*******************************************************************************/ /*******************************************************************************/
@ -144,14 +151,17 @@ u8 getdesbit1(u16 sel)
u8 getdesbit2(u16 sel) u8 getdesbit2(u16 sel)
{ {
gdtdes *entry=GDT_ADDR; gdtdes *entry = GDT_ADDR;
u8 index=sel/sizeof(gdtdes); u8 index = sel / sizeof(gdtdes);
if (((entry[index].acces & 0b10100) == 0) && ((entry[index].acces & 0b01000) > 0) && ((entry[index].acces & 0b0001) > 0) && ((entry[index].flags & 0b0110) == 0)) if (((entry[index].acces & 0x20) == 0)
return (((entry[index].flags & 0b1) > 0) ? 'U' : '-'); && ((entry[index].acces & 0x08) > 0)
else if ((entry[index].acces & 0b1000) > 0) && ((entry[index].acces & 0x01) > 0)
return (((entry[index].acces & 0b10) > 0) ? 'R' : '-'); && ((entry[index].flags & 0x06) == 0))
else return (((entry[index].flags & 0x01) > 0) ? 'U' : '-');
return (((entry[index].acces & 0b10) > 0) ? 'W' : 'R'); else if ((entry[index].acces & 0x8) > 0)
return (((entry[index].acces & 0x02) > 0) ? 'R' : '-');
else
return (((entry[index].acces & 0x02) > 0) ? 'W' : 'R');
} }
/*******************************************************************************/ /*******************************************************************************/
@ -159,12 +169,12 @@ u8 getdesbit2(u16 sel)
u8 getdesbit3(u16 sel) u8 getdesbit3(u16 sel)
{ {
gdtdes *entry=GDT_ADDR; gdtdes *entry = GDT_ADDR;
u8 index=sel/sizeof(gdtdes); u8 index = sel / sizeof(gdtdes);
if ((entry[index].acces & 0b1000) > 0) if ((entry[index].acces & 0x08) > 0)
return (((entry[index].acces & 0b100) > 0) ? 'C' : '-'); return (((entry[index].acces & 0x04) > 0) ? 'C' : '-');
else else
return (((entry[index].acces & 0b100) > 0) ? 'D' : 'U'); return (((entry[index].acces & 0x04) > 0) ? 'D' : 'U');
} }
/*******************************************************************************/ /*******************************************************************************/
@ -172,9 +182,9 @@ u8 getdesbit3(u16 sel)
u16 getdesalign(u16 sel) u16 getdesalign(u16 sel)
{ {
gdtdes *entry=GDT_ADDR; gdtdes *entry = GDT_ADDR;
u8 index=sel/sizeof(gdtdes); u8 index = sel / sizeof(gdtdes);
return (((entry[index].flags & 0b1000) > 0) ? 4096: 1); return (((entry[index].flags & 0x08) > 0) ? 4096 : 1);
} }
/*******************************************************************************/ /*******************************************************************************/
@ -182,9 +192,9 @@ u16 getdesalign(u16 sel)
bool isdesvalid(u16 sel) bool isdesvalid(u16 sel)
{ {
gdtdes *entry=GDT_ADDR; gdtdes *entry = GDT_ADDR;
u8 index=sel/sizeof(gdtdes); u8 index = sel / sizeof(gdtdes);
return ((entry[index].acces & 0b10000000) > 0); return ((entry[index].acces & 0x80) > 0);
} }
/*******************************************************************************/ /*******************************************************************************/
@ -192,12 +202,15 @@ bool isdesvalid(u16 sel)
u32 getdessize(u16 sel) u32 getdessize(u16 sel)
{ {
gdtdes *entry=GDT_ADDR; gdtdes *entry = GDT_ADDR;
u8 index=sel/sizeof(gdtdes); u8 index = sel / sizeof(gdtdes);
if (((entry[index].acces & 0b10100) == 0) && ((entry[index].acces & 0b01000) > 0) && ((entry[index].acces & 0b0001) > 0) && ((entry[index].flags & 0b0110) == 0)) if (((entry[index].acces & 0x14) == 0)
return 32; && ((entry[index].acces & 0x08) > 0)
else && ((entry[index].acces & 0x01) > 0)
return (((entry[index].flags & 0b1000) > 0) ? 32 : 16); && ((entry[index].flags & 0x06) == 0))
return 32;
else
return (((entry[index].flags & 0x08) > 0) ? 32 : 16);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Créé un descripteur GDT */ /* Créé un descripteur GDT */

View File

@ -26,7 +26,7 @@ static u32 retry_address;
void initretry(u32 address) void initretry(u32 address)
{ {
retry_address=address; retry_address = address;
} }
/******************************************************************************/ /******************************************************************************/
@ -34,7 +34,7 @@ void initretry(u32 address)
u32 getinitretry(void) u32 getinitretry(void)
{ {
return retry_address; return retry_address;
} }
/******************************************************************************/ /******************************************************************************/
@ -85,7 +85,7 @@ void initpic(void)
void enableirq(u8 irq) void enableirq(u8 irq)
{ {
u16 port; u16 port;
cli(); cli();
port = (((irq & 0x08) << 4) + PIC1_DATA); port = (((irq & 0x08) << 4) + PIC1_DATA);
outb(port, inb(port) & ~(1 << (irq & 7))); outb(port, inb(port) & ~(1 << (irq & 7)));
@ -97,7 +97,7 @@ void enableirq(u8 irq)
void disableirq(u8 irq) void disableirq(u8 irq)
{ {
u16 port; u16 port;
cli(); cli();
port = (((irq & 0x08) << 4) + PIC1_DATA); port = (((irq & 0x08) << 4) + PIC1_DATA);
outb(port, inb(port) | (1 << (irq & 7))); outb(port, inb(port) | (1 << (irq & 7)));
@ -137,7 +137,7 @@ void setidt(u32 offset, u16 select, u16 type, u16 index)
void putidt(u32 offset, u16 select, u16 type, u16 index) void putidt(u32 offset, u16 select, u16 type, u16 index)
{ {
idtdes temp; idtdes temp;
makeidtdes(offset, select, type, &temp); makeidtdes(offset, select, type, &temp);
idt[index] = temp; idt[index] = temp;
} }
@ -145,17 +145,18 @@ void putidt(u32 offset, u16 select, u16 type, u16 index)
/******************************************************************************/ /******************************************************************************/
/* Affiche une erreur CPU et fige l'ordinateur */ /* Affiche une erreur CPU et fige l'ordinateur */
void cpuerror(const u8 * src, const regs *stack) void cpuerror(const u8 * src, const regs * stack)
{ {
printf("\033[31m*** ERREUR CPU : %s *** \r\n", src); printf("\033[31m*** ERREUR CPU : %s *** \r\n", src);
if (stack!=NULL) show_cpu(stack); if (stack != NULL)
show_cpu(stack);
print("<Appuyer une touche pour continuer>\033[0m\r\n"); print("<Appuyer une touche pour continuer>\033[0m\r\n");
sti(); sti();
waitascii(); waitascii();
initselectors(retry_address); initselectors(retry_address);
/*while (true) { /*while (true) {
nop(); nop();
}*/ } */
} }
/******************************************************************************/ /******************************************************************************/
@ -176,328 +177,345 @@ void interruption()
void exception0() void exception0()
{ {
regs *dump; regs *dump;
exception_stack_noerror *current; exception_stack_noerror *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("#DE Divide error",dump); cpuerror("#DE Divide error", dump);
} }
void exception1() void exception1()
{ {
cli(); cli();
regs *dump; regs *dump;
exception_stack_noerror *current; exception_stack_noerror *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
changevc(6); changevc(6);
clearscreen(); clearscreen();
show_lightcpu(dump); show_lightcpu(dump);
printf("\r\n\033[7m[P]\033[0m PAS A PAS \033[7m D \033[0m PAS A PAS DETAILLE \033[7m C \033[0m CONTINUER \033[7m S \033[0m STOPPER \033[7m V \033[0m VOIR \033[7m S \033[0m SCINDER"); printf("\r\n\033[7m[P]\033[0m PAS A PAS \033[7m D \033[0m PAS A PAS DETAILLE \033[7m C \033[0m CONTINUER \033[7m S \033[0m STOPPER \033[7m V \033[0m VOIR \033[7m S \033[0m SCINDER");
sti(); sti();
u8 ascii=waitascii(); u8 ascii = waitascii();
cli(); cli();
if (ascii=='P' || ascii=='p') if (ascii == 'P' || ascii == 'p')
setdebugreg(0,current->eip+disasm(current->eip, NULL, false), DBG_EXEC); setdebugreg(0,
else if (ascii=='D' || ascii=='d') current->eip + disasm(current->eip, NULL,
setdebugreg(0,0, DBG_CLEAR); false), DBG_EXEC);
else if (ascii=='C' || ascii=='c') else if (ascii == 'D' || ascii == 'd')
setdebugreg(0,0, DBG_CLEAR); setdebugreg(0, 0, DBG_CLEAR);
else if (ascii=='S' || ascii=='s') else if (ascii == 'C' || ascii == 'c')
{ setdebugreg(0, 0, DBG_CLEAR);
changevc(0); else if (ascii == 'S' || ascii == 's')
sti(); {
initselectors(retry_address); changevc(0);
} sti();
changevc(0); initselectors(retry_address);
restdebugcpu(); }
iret(); changevc(0);
restdebugcpu();
iret();
} }
void exception2() void exception2()
{ {
regs *dump; regs *dump;
exception_stack_noerror *current; exception_stack_noerror *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("NMI Non-maskable hardware interrupt",dump); cpuerror("NMI Non-maskable hardware interrupt", dump);
} }
void exception3() void exception3()
{ {
regs *dump; regs *dump;
exception_stack_noerror *current; exception_stack_noerror *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("#BP INT3 instruction",dump); cpuerror("#BP INT3 instruction", dump);
} }
void exception4() void exception4()
{ {
regs *dump; regs *dump;
exception_stack_noerror *current; exception_stack_noerror *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("#OF INTO instruction detected overflow",dump); cpuerror("#OF INTO instruction detected overflow", dump);
} }
void exception5() void exception5()
{ {
regs *dump; regs *dump;
exception_stack_noerror *current; exception_stack_noerror *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("#BR BOUND instruction detected overrange",dump); cpuerror("#BR BOUND instruction detected overrange", dump);
} }
void exception6() void exception6()
{ {
regs *dump; regs *dump;
exception_stack_noerror *current; exception_stack_noerror *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("#UD Invalid instruction opcode",dump); cpuerror("#UD Invalid instruction opcode", dump);
} }
void exception7() void exception7()
{ {
regs *dump; regs *dump;
exception_stack_noerror *current; exception_stack_noerror *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("#NM No coprocessor",dump); cpuerror("#NM No coprocessor", dump);
} }
void exception8() void exception8()
{ {
regs *dump; regs *dump;
exception_stack_noerror *current; exception_stack_noerror *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("#DF Double fault",dump); cpuerror("#DF Double fault", dump);
} }
void exception9() void exception9()
{ {
regs *dump; regs *dump;
exception_stack_noerror *current; exception_stack_noerror *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("Coprocessor segment overrun",dump); cpuerror("Coprocessor segment overrun", dump);
} }
void exception10() void exception10()
{ {
regs *dump; regs *dump;
exception_stack_noerror *current; exception_stack_noerror *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("#TS Invalid task state segment (TSS)",dump); cpuerror("#TS Invalid task state segment (TSS)", dump);
} }
void exception11() void exception11()
{ {
regs *dump; regs *dump;
exception_stack *current; exception_stack *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("#NP Segment not present",dump); cpuerror("#NP Segment not present", dump);
} }
void exception12() void exception12()
{ {
regs *dump; regs *dump;
exception_stack_noerror *current; exception_stack_noerror *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("#SS Stack fault",dump); cpuerror("#SS Stack fault", dump);
} }
void exception13() void exception13()
{ {
regs *dump; regs *dump;
exception_stack *current; exception_stack *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("#GP General protection fault (GPF)",dump); cpuerror("#GP General protection fault (GPF)", dump);
} }
static u8 ex14_errors1[]="Supervisory process tried to read a non-present page entry"; static u8 ex14_errors1[] =
static u8 ex14_errors2[]="Supervisory process tried to read a page and caused a protection fault"; "Supervisory process tried to read a non-present page entry";
static u8 ex14_errors3[]="Supervisory process tried to write to a non-present page entry"; static u8 ex14_errors2[] =
static u8 ex14_errors4[]="Supervisory process tried to write a page and caused a protection fault"; "Supervisory process tried to read a page and caused a protection fault";
static u8 ex14_errors5[]="User process tried to read a non-present page entry"; static u8 ex14_errors3[] =
static u8 ex14_errors6[]="User process tried to read a page and caused a protection fault"; "Supervisory process tried to write to a non-present page entry";
static u8 ex14_errors7[]="User process tried to write to a non-present page entry"; static u8 ex14_errors4[] =
static u8 ex14_errors8[]="User process tried to write a page and caused a protection fault"; "Supervisory process tried to write a page and caused a protection fault";
static u8 *ex14_errors[]={&ex14_errors1,&ex14_errors2,&ex14_errors3,&ex14_errors4,&ex14_errors5,&ex14_errors6,&ex14_errors7,&ex14_errors8}; static u8 ex14_errors5[] =
"User process tried to read a non-present page entry";
static u8 ex14_errors6[] =
"User process tried to read a page and caused a protection fault";
static u8 ex14_errors7[] =
"User process tried to write to a non-present page entry";
static u8 ex14_errors8[] =
"User process tried to write a page and caused a protection fault";
static u8 *ex14_errors[] =
{ &ex14_errors1, &ex14_errors2, &ex14_errors3, &ex14_errors4,
&ex14_errors5, &ex14_errors6, &ex14_errors7, &ex14_errors8 };
void exception14() void exception14()
{ {
regs *dump; regs *dump;
exception_stack *current; exception_stack *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
if (dump->cr2 >= USER_CODE && dump->cr2 < USER_STACK) if (dump->cr2 >= USER_CODE && dump->cr2 < USER_STACK)
{ {
virtual_range_new(getcurrentprocess()->pdd, (u8 *) (dump->cr2 & 0xFFFFF000), PAGESIZE, PAGE_ALL); virtual_range_new(getcurrentprocess()->pdd,
} (u8 *) (dump->cr2 & 0xFFFFF000),
else { PAGESIZE, PAGE_ALL);
printf("Page fault - %s at adress %Y cs:eip - %Y:%Y\r\n",ex14_errors[current->error_code & 0xF],dump->cr2,dump->cs,dump->eip);
cpuerror("#PGF Page fault",dump);
} }
restdebugcpu(); else
iret(); {
printf("Page fault - %s at adress %Y cs:eip - %Y:%Y\r\n",
ex14_errors[current->error_code & 0xF], dump->cr2,
dump->cs, dump->eip);
cpuerror("#PGF Page fault", dump);
}
restdebugcpu();
iret();
} }
void exception15() void exception15()
{ {
regs *dump; regs *dump;
exception_stack_noerror *current; exception_stack_noerror *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("(reserved)",dump); cpuerror("(reserved)", dump);
} }
void exception16() void exception16()
{ {
regs *dump; regs *dump;
exception_stack_noerror *current; exception_stack_noerror *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("#MF Coprocessor error",dump); cpuerror("#MF Coprocessor error", dump);
} }
void exception17() void exception17()
{ {
regs *dump; regs *dump;
exception_stack_noerror *current; exception_stack_noerror *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("#AC Alignment check",dump); cpuerror("#AC Alignment check", dump);
} }
void exception18() void exception18()
{ {
regs *dump; regs *dump;
exception_stack_noerror *current; exception_stack_noerror *current;
u32 *oldesp; u32 *oldesp;
getEBP(oldesp); getEBP(oldesp);
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
current=(exception_stack *) (oldesp+1); current = (exception_stack *) (oldesp + 1);
dump->ebp=*oldesp; dump->ebp = *oldesp;
dump->esp=(u32) oldesp+sizeof(exception_stack); dump->esp = (u32) oldesp + sizeof(exception_stack);
dump->eip=current->eip; dump->eip = current->eip;
cpuerror("#MC Machine check",dump); cpuerror("#MC Machine check", dump);
} }
/******************************************************************************/ /******************************************************************************/
@ -523,7 +541,7 @@ void irq1()
pushf(); pushf();
pushad(); pushad();
print("irq 1"); print("irq 1");
while ((inb(0x64) & 1) == 0) ; while ((inb(0x64) & 1) == 0);
inb(0x60); inb(0x60);
irqendmaster(); irqendmaster();
popad(); popad();
@ -683,7 +701,7 @@ void irq12()
pushf(); pushf();
pushad(); pushad();
print("irq 12"); print("irq 12");
while ((inb(0x64) & 1) == 0) ; while ((inb(0x64) & 1) == 0);
inb(0x60); inb(0x60);
irqendslave(); irqendslave();
irqendmaster(); irqendmaster();
@ -742,50 +760,91 @@ void irq15()
void initidt(void) void initidt(void)
{ {
u16 i; u16 i;
putidt((u32) exception0, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 0); putidt((u32) exception0, SEL_KERNEL_CODE,
putidt((u32) exception1, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 1); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 0);
putidt((u32) exception2, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 2); putidt((u32) exception1, SEL_KERNEL_CODE,
putidt((u32) exception3, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 3); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 1);
putidt((u32) exception4, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 4); putidt((u32) exception2, SEL_KERNEL_CODE,
putidt((u32) exception5, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 5); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 2);
putidt((u32) exception6, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 6); putidt((u32) exception3, SEL_KERNEL_CODE,
putidt((u32) exception7, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 7); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 3);
putidt((u32) exception8, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 8); putidt((u32) exception4, SEL_KERNEL_CODE,
putidt((u32) exception9, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 9); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 4);
putidt((u32) exception10, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 10); putidt((u32) exception5, SEL_KERNEL_CODE,
putidt((u32) exception11, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 11); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 5);
putidt((u32) exception12, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 12); putidt((u32) exception6, SEL_KERNEL_CODE,
putidt((u32) exception13, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 13); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 6);
putidt((u32) exception14, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 14); putidt((u32) exception7, SEL_KERNEL_CODE,
putidt((u32) exception15, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 15); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 7);
putidt((u32) exception16, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 16); putidt((u32) exception8, SEL_KERNEL_CODE,
putidt((u32) exception17, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 17); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 8);
putidt((u32) exception18, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 18); putidt((u32) exception9, SEL_KERNEL_CODE,
for (i = 19; i < 32; i++) { ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 9);
putidt((u32) interruption, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING3 | TRAPGATE, i); putidt((u32) exception10, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 10);
putidt((u32) exception11, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 11);
putidt((u32) exception12, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 12);
putidt((u32) exception13, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 13);
putidt((u32) exception14, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 14);
putidt((u32) exception15, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 15);
putidt((u32) exception16, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 16);
putidt((u32) exception17, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 17);
putidt((u32) exception18, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 18);
for (i = 19; i < 32; i++)
{
putidt((u32) interruption, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING3 | TRAPGATE, i);
} }
putidt((u32) irq0, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 32); putidt((u32) irq0, SEL_KERNEL_CODE,
putidt((u32) irq1, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 33); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 32);
putidt((u32) irq2, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 34); putidt((u32) irq1, SEL_KERNEL_CODE,
putidt((u32) irq3, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 35); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 33);
putidt((u32) irq4, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 36); putidt((u32) irq2, SEL_KERNEL_CODE,
putidt((u32) irq5, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 37); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 34);
putidt((u32) irq6, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 38); putidt((u32) irq3, SEL_KERNEL_CODE,
putidt((u32) irq7, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 39); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 35);
for (i = 40; i < 96; i++) { putidt((u32) irq4, SEL_KERNEL_CODE,
putidt((u32) interruption, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING3 | TRAPGATE, i); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 36);
putidt((u32) irq5, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 37);
putidt((u32) irq6, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 38);
putidt((u32) irq7, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 39);
for (i = 40; i < 96; i++)
{
putidt((u32) interruption, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING3 | TRAPGATE, i);
} }
putidt((u32) irq8, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 96); putidt((u32) irq8, SEL_KERNEL_CODE,
putidt((u32) irq9, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 97); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 96);
putidt((u32) irq10, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 98); putidt((u32) irq9, SEL_KERNEL_CODE,
putidt((u32) irq11, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 99); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 97);
putidt((u32) irq12, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 100); putidt((u32) irq10, SEL_KERNEL_CODE,
putidt((u32) irq13, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 101); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 98);
putidt((u32) irq14, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 102); putidt((u32) irq11, SEL_KERNEL_CODE,
putidt((u32) irq15, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 103); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 99);
for (i = 104; i < IDT_SIZE; i++) { putidt((u32) irq12, SEL_KERNEL_CODE,
putidt((u32) interruption, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | TRAPGATE, i); ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 100);
putidt((u32) irq13, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 101);
putidt((u32) irq14, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 102);
putidt((u32) irq15, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 103);
for (i = 104; i < IDT_SIZE; i++)
{
putidt((u32) interruption, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | TRAPGATE, i);
} }
/* initialise le registre idt */ /* initialise le registre idt */
idtreg.limite = IDT_SIZE * sizeof(idtdes); idtreg.limite = IDT_SIZE * sizeof(idtdes);
@ -801,7 +860,7 @@ void initidt(void)
void inittimer(void) void inittimer(void)
{ {
u32 divisor = TIMER_FREQ / HZ; u32 divisor = TIMER_FREQ / HZ;
outb(TIMER_MODE, RATE_GENERATOR); outb(TIMER_MODE, RATE_GENERATOR);
outb(TIMER0, (u8) divisor); outb(TIMER0, (u8) divisor);
outb(TIMER0, (u8) (divisor >> 8)); outb(TIMER0, (u8) (divisor >> 8));

View File

@ -98,17 +98,21 @@ static const u8 set1_ctrl[] = {
/* Attend une chaine de caractère de taille max */ /* Attend une chaine de caractère de taille max */
u8 *getstring(u8 * temp) u8 *getstring(u8 * temp)
{ {
u8 maxwidth = strlen(temp); u8 maxwidth = strlen(temp);
u8 *pointer = temp; u8 *pointer = temp;
u8 ascii = 0; u8 ascii = 0;
while (ascii != '\r') { while (ascii != '\r')
{
ascii = waitascii(); ascii = waitascii();
if (ascii == '\b' && pointer > temp) { if (ascii == '\b' && pointer > temp)
{
pointer--; pointer--;
putchar(ascii); putchar(ascii);
} else if (ascii > 31 && pointer <= temp + 80) { }
else if (ascii > 31 && pointer <= temp + 80)
{
*pointer++ = ascii; *pointer++ = ascii;
putchar(ascii); putchar(ascii);
} }
@ -122,8 +126,8 @@ u8 *getstring(u8 * temp)
u8 waitascii(void) u8 waitascii(void)
{ {
u8 oldptrascii = ptrascii; u8 oldptrascii = ptrascii;
while ((oldptrascii == ptrascii)) ; while ((oldptrascii == ptrascii));
return bufferascii[ptrascii]; return bufferascii[ptrascii];
} }
@ -132,11 +136,12 @@ u8 waitascii(void)
void outkbd(u8 port, u8 data) void outkbd(u8 port, u8 data)
{ {
u32 timeout; u32 timeout;
u8 state; u8 state;
/* timeout */ /* timeout */
for (timeout = 500000L; timeout != 0; timeout--) { for (timeout = 500000L; timeout != 0; timeout--)
{
state = inb(0x64); state = inb(0x64);
/* vide le buffer du 8042 */ /* vide le buffer du 8042 */
if ((state & 0x02) == 0) if ((state & 0x02) == 0)
@ -151,16 +156,19 @@ void outkbd(u8 port, u8 data)
void reboot(void) void reboot(void)
{ {
u8 temp; u8 temp;
cli(); cli();
/* vide le 8042 */ /* vide le 8042 */
do { do
{
temp = inb(0x64); temp = inb(0x64);
if ((temp & 0x01) != 0) { if ((temp & 0x01) != 0)
(void)inb(0x60); {
(void) inb(0x60);
continue; continue;
} }
} while ((temp & 0x02) != 0); }
while ((temp & 0x02) != 0);
/* active le reset CPU */ /* active le reset CPU */
outb(0x64, 0xFE); outb(0x64, 0xFE);
while (1) while (1)
@ -172,7 +180,7 @@ void reboot(void)
unsigned convert(u32 keypressed) unsigned convert(u32 keypressed)
{ {
u8 temp, key, lastscan; u8 temp, key, lastscan;
/* garde le dernier pointeur du buffer scan */ /* garde le dernier pointeur du buffer scan */
lastscan = ptrscan; lastscan = ptrscan;
/* incrémente le pointeur est assigne au buffer le dernier scancode */ /* incrémente le pointeur est assigne au buffer le dernier scancode */
@ -185,13 +193,16 @@ unsigned convert(u32 keypressed)
breakcode = 1; breakcode = 1;
key = (keypressed & 0x7F); key = (keypressed & 0x7F);
/* Mise a jour des flags lors du relachement de touches de controle */ /* Mise a jour des flags lors du relachement de touches de controle */
if (breakcode) { if (breakcode)
if (key == SCAN_ALT) { {
if (key == SCAN_ALT)
{
kbdstatus &= ~STATUS_ALT; kbdstatus &= ~STATUS_ALT;
/* si ALT GR (E01D) alors activer aussi control */ /* si ALT GR (E01D) alors activer aussi control */
if (bufferscan[lastscan] == 0xE0) if (bufferscan[lastscan] == 0xE0)
kbdstatus &= ~STATUS_CTRL; kbdstatus &= ~STATUS_CTRL;
} else if (key == SCAN_CTRL) }
else if (key == SCAN_CTRL)
kbdstatus &= ~STATUS_CTRL; kbdstatus &= ~STATUS_CTRL;
else if (key == SCAN_LEFTSHIFT || key == SCAN_RIGHTSHIFT) else if (key == SCAN_LEFTSHIFT || key == SCAN_RIGHTSHIFT)
kbdstatus &= ~STATUS_SHIFT; kbdstatus &= ~STATUS_SHIFT;
@ -199,43 +210,56 @@ unsigned convert(u32 keypressed)
return 0; return 0;
} }
/* Mise a jour des flags lors de l'appuie de touches de controle */ /* Mise a jour des flags lors de l'appuie de touches de controle */
if (key == SCAN_ALT) { if (key == SCAN_ALT)
{
kbdstatus |= STATUS_ALT; kbdstatus |= STATUS_ALT;
/* si ALT GR (E01D) alors desactiver aussi control */ /* si ALT GR (E01D) alors desactiver aussi control */
if (bufferscan[lastscan] == 0xE0) if (bufferscan[lastscan] == 0xE0)
kbdstatus |= STATUS_CTRL; kbdstatus |= STATUS_CTRL;
return 0; return 0;
} else if (key == SCAN_CTRL) { }
else if (key == SCAN_CTRL)
{
kbdstatus |= STATUS_CTRL; kbdstatus |= STATUS_CTRL;
return 0; return 0;
} else if (key == SCAN_LEFTSHIFT || key == SCAN_RIGHTSHIFT) { }
else if (key == SCAN_LEFTSHIFT || key == SCAN_RIGHTSHIFT)
{
kbdstatus |= STATUS_SHIFT; kbdstatus |= STATUS_SHIFT;
return 0; return 0;
} }
else if ((key >= SCAN_F1) && (key <= SCAN_F8)) { else if ((key >= SCAN_F1) && (key <= SCAN_F8))
{
changevc(key - SCAN_F1); changevc(key - SCAN_F1);
} }
else if (key == SCAN_F9) { else if (key == SCAN_F9)
regs dump; {
show_cpu(&dump); regs dump;
show_cpu(&dump);
} }
else if (key == SCAN_F10) { else if (key == SCAN_F10)
{
apply_nextvideomode(); apply_nextvideomode();
} }
/* Scroll Lock, Num Lock, and Caps Lock mise a jour des leds */ /* Scroll Lock, Num Lock, and Caps Lock mise a jour des leds */
else if (key == SCAN_SCROLLLOCK) { else if (key == SCAN_SCROLLLOCK)
{
kbdstatus ^= STATUS_SCRL; kbdstatus ^= STATUS_SCRL;
goto LEDS; goto LEDS;
} else if (key == SCAN_NUMLOCK) { }
else if (key == SCAN_NUMLOCK)
{
kbdstatus ^= STATUS_NUM; kbdstatus ^= STATUS_NUM;
goto LEDS; goto LEDS;
} else if (key == SCAN_CAPSLOCK) { }
else if (key == SCAN_CAPSLOCK)
{
kbdstatus ^= STATUS_CAPS; kbdstatus ^= STATUS_CAPS;
LEDS: LEDS:
outkbd(0x60, 0xED); /* "mise a jour des LEDS */ outkbd(0x60, 0xED); /* "mise a jour des LEDS */
temp = 0; temp = 0;
if (kbdstatus & STATUS_SCRL) if (kbdstatus & STATUS_SCRL)
@ -248,8 +272,9 @@ unsigned convert(u32 keypressed)
return 0; return 0;
} }
/* Appuie de CRTL + ALT + SUPR ? */ /* Appuie de CRTL + ALT + SUPR ? */
if ((kbdstatus & STATUS_CTRL) && (kbdstatus & STATUS_ALT) && if ((kbdstatus & STATUS_CTRL) && (kbdstatus & STATUS_ALT)
(key == 73)) { && (key == 73))
{
print("redemarrage du systeme"); print("redemarrage du systeme");
reboot(); reboot();
} }
@ -296,14 +321,17 @@ unsigned convert(u32 keypressed)
if (key == 0x4f) if (key == 0x4f)
return 0x19; return 0x19;
return 0x00; return 0x00;
} else { }
else
{
/* detecte les SCANCODES invalides */ /* detecte les SCANCODES invalides */
if (key >= sizeof(set1_normal) / sizeof(set1_normal[0])) if (key >= sizeof(set1_normal) / sizeof(set1_normal[0]))
return 0; return 0;
/* converti le scancode en code ASCII en fonction du statut*/ /* converti le scancode en code ASCII en fonction du statut*/
if (kbdstatus & STATUS_SHIFT || kbdstatus & STATUS_CAPS) if (kbdstatus & STATUS_SHIFT || kbdstatus & STATUS_CAPS)
temp = set1_shift[key]; temp = set1_shift[key];
else if ((kbdstatus & STATUS_ALT) && (kbdstatus & STATUS_CTRL)) else if ((kbdstatus & STATUS_ALT)
&& (kbdstatus & STATUS_CTRL))
temp = set1_altgr[key]; temp = set1_altgr[key];
else if (kbdstatus & STATUS_CTRL) else if (kbdstatus & STATUS_CTRL)
temp = set1_ctrl[key]; temp = set1_ctrl[key];
@ -327,12 +355,13 @@ void keyboard(void)
cli(); cli();
pushf(); pushf();
pushad(); pushad();
u8 scancode, ascii; u8 scancode, ascii;
cli(); cli();
while ((inb(0x64) & 1) == 0) ; while ((inb(0x64) & 1) == 0);
scancode = inb(0x60); scancode = inb(0x60);
ascii = convert(scancode); ascii = convert(scancode);
if (ascii != 0) { if (ascii != 0)
{
ptrascii++; ptrascii++;
if (ptrascii == 255) if (ptrascii == 255)
ptrascii == 0; ptrascii == 0;

View File

@ -1,251 +1,258 @@
/*******************************************************************************/ /*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */ /* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */ /* */
#include "types.h" #include "types.h"
#include "timer.h" #include "timer.h"
#include "math.h" #include "math.h"
/*******************************************************************************/ /*******************************************************************************/
/* Arithmétique 64 bits */ /* Arithmétique 64 bits */
unsigned long long __udivdi3 (unsigned long long num, unsigned long long den) unsigned long long __udivdi3(unsigned long long num,
{ unsigned long long den)
{
unsigned long long quot, qbit; unsigned long long quot, qbit;
quot = 0;
quot = 0; qbit = 1;
qbit = 1; if (den == 0)
{
if (den == 0) return 0;
{ }
return 0; while ((long long) den >= 0)
} {
den <<= 1;
while ((long long) den >= 0) qbit <<= 1;
{ }
den <<= 1; while (qbit)
qbit <<= 1; {
} if (den <= num)
{
while (qbit) num -= den;
{ quot += qbit;
if (den <= num) }
{ den >>= 1;
num -= den; qbit >>= 1;
quot += qbit; }
} return quot;
den >>= 1; }
qbit >>= 1;
} unsigned long long __umoddi3(unsigned long long n, unsigned long long d)
{
return quot; return n - d * __udivdi3(n, d);
}
}
/******************************************************************************/
unsigned long long __umoddi3 (unsigned long long n, unsigned long long d) /* Fonctions qui retournent le sinus et cosinus */
{
return n - d * __udivdi3 (n, d); double cos(double x)
} {
if (x < 0.0)
/******************************************************************************/ x = -x;
/* Fonctions qui retournent le sinus et cosinus */ while (M_PI < x)
x -= M_2_PI;
double cos(double x){ double result =
if( x < 0.0 ) 1.0 - (x * x / 2.0) * (1.0 -
x = -x; (x * x / 12.0) * (1.0 -
while( M_PI < x ) (x * x / 30.0) *
x -= M_2_PI; (1.0 -
double result=1.0 - (x*x/2.0)*( 1.0 - (x*x/12.0) * ( 1.0 - (x*x/30.0) * (1.0 - x*x/56.0 ))); x * x / 56.0)));
return result; return result;
} }
double sin(double x){ double sin(double x)
return cos(x-M_PI_2); {
} return cos(x - M_PI_2);
}
float cosf(float x){
if( x < 0.0f ) float cosf(float x)
x = -x; {
while( M_PI < x ) if (x < 0.0f)
x -= M_2_PI; x = -x;
float result=1.0f - (x*x/2.0f)*( 1.0f - (x*x/12.0f) * ( 1.0f - (x*x/30.0f) * (1.0f - x*x/56.0f ))); while (M_PI < x)
return result; x -= M_2_PI;
} float result =
1.0f - (x * x / 2.0f) * (1.0f -
float sinf(float x){ (x * x / 12.0f) * (1.0f -
return cosf(x-M_PI_2); (x * x /
} 30.0f) *
(1.0f -
/******************************************************************************/ x * x /
/* Fonction qui retourne la valeur absolue */ 56.0f)));
return result;
float fabsf(float n) }
{
return (*((int *) &n) &= 0x7fffffff); float sinf(float x)
} {
return cosf(x - M_PI_2);
double fabs(double n) }
{
return (*(((int *) &n) + 1) &= 0x7fffffff); /******************************************************************************/
} /* Fonction qui retourne la valeur absolue */
/******************************************************************************/ float fabsf(float n)
/* Fonction qui retourne la racine */ {
return (*((int *) &n) &= 0x7fffffff);
float sqrtf(float n) }
{
double fabs(double n)
float x = n; {
float y = 1; return (*(((int *) &n) + 1) &= 0x7fffffff);
double e = 0.000001; }
while(x - y > e)
{ /******************************************************************************/
x = (x + y)/2; /* Fonction qui retourne la racine */
y = n/x;
} float sqrtf(float n)
return x; {
} float x = n;
float y = 1;
double sqrt(double n) double e = 0.000001;
{ while (x - y > e)
{
double x = n; x = (x + y) / 2;
double y = 1; y = n / x;
double e = 0.000001; }
while(x - y > e) return x;
{ }
x = (x + y)/2;
y = n/x; double sqrt(double n)
} {
return x; double x = n;
} double y = 1;
double e = 0.000001;
/******************************************************************************/ while (x - y > e)
/* Fonction qui retourne l'inverse de la racine */ {
x = (x + y) / 2;
float rsqrtf(float n) y = n / x;
{ }
return 1 / sqrt(n); return x;
} }
double rsqrt(double n) /******************************************************************************/
{ /* Fonction qui retourne l'inverse de la racine */
return 1 / sqrt(n);
} float rsqrtf(float n)
{
/******************************************************************************/ return 1 / sqrt(n);
/* Fonction qui retourne la puissance n de a */ }
u32 pow(u32 a, u8 n) { double rsqrt(double n)
u32 r = 1; {
while (n > 0) { return 1 / sqrt(n);
if (n & 1) }
r *= a;
a *= a; /******************************************************************************/
n >>= 1; /* Fonction qui retourne la puissance n de a */
}
return r; u32 pow(u32 a, u8 n)
} {
u32 r = 1;
/******************************************************************************/ while (n > 0)
/* Fonction qui retourne le logarithme 2 */ {
if (n & 1)
u8 log2(u64 n) r *= a;
{ a *= a;
n >>= 1;
if (n == 0) }
return 0; return r;
}
int logValue = -1;
/******************************************************************************/
while (n) { /* Fonction qui retourne le logarithme 2 */
logValue++; u8 log2(u64 n)
{
n >>= 1; if (n == 0)
return 0;
} int logValue = -1;
while (n)
return logValue + 1; {
} logValue++;
/******************************************************************************/ n >>= 1;
/* Fonction qui retourne le logarithme 10 */
}
u8 log10(u64 n) return logValue + 1;
{ }
return (n >= 10000000000000000000u) ? 19 : (n >= 100000000000000000u) ? 18 : /******************************************************************************/
(n >= 100000000000000000u) ? 17 : (n >= 10000000000000000u) ? 16 : /* Fonction qui retourne le logarithme 10 */
(n >= 1000000000000000u) ? 15 : (n >= 100000000000000u) ? 14 :
(n >= 10000000000000u) ? 13 : (n >= 1000000000000u) ? 12 : u8 log10(u64 n)
(n >= 100000000000u) ? 11 : (n >= 10000000000u) ? 10 : {
(n >= 1000000000u) ? 9 : (n >= 100000000u) ? 8 :
(n >= 10000000u) ? 7 : (n >= 1000000u) ? 6 : return (n >= 10000000000000000000u) ? 19 : (n >=
(n >= 100000u) ? 5 : (n >= 10000u) ? 4 : 100000000000000000u) ?
(n >= 1000u) ? 3 : (n >= 100u) ? 2 : (n >= 10u) ? 1u : 0u; 18 : (n >= 100000000000000000u) ? 17 : (n >=
10000000000000000u)
} ? 16 : (n >= 1000000000000000u) ? 15 : (n >=
100000000000000u) ?
14 : (n >= 10000000000000u) ? 13 : (n >=
/******************************************************************************/ 1000000000000u) ? 12
/* Fonction qui retourne la valeur absolue */ : (n >= 100000000000u) ? 11 : (n >=
10000000000u) ? 10 : (n >=
u32 abs(int x) 1000000000u)
{ ? 9 : (n >= 100000000u) ? 8 : (n >= 10000000u) ? 7 : (n >=
1000000u)
if (x < 0) ? 6 : (n >= 100000u) ? 5 : (n >= 10000u) ? 4 : (n >=
1000u) ? 3
x = -x; : (n >= 100u) ? 2 : (n >= 10u) ? 1u : 0u;
return (u32) x; }
}
/******************************************************************************/
/******************************************************************************/ /* Fonction qui retourne la valeur absolue */
/* Fonction qui initialise le générateur de nombre aléatoire */
u32 abs(int x)
static u32 seed = 0x12341234; {
if (x < 0)
void randomize(void) x = -x;
{
return (u32) x;
seed = gettimer(); }
} /******************************************************************************/
/* Fonction qui initialise le générateur de nombre aléatoire */
/******************************************************************************/ static u32 seed = 0x12341234;
/* Fonction qui renvoie un nombre aléatoire */
void randomize(void)
u32 rand(void) {
{ seed = gettimer();
u32 next = seed; }
int result;
next *= 1103515245;
next += 12345; /******************************************************************************/
result = (unsigned int)(next / 65536) % 2048; /* Fonction qui renvoie un nombre aléatoire */
next *= 1103515245;
next += 12345; u32 rand(void)
result <<= 10; {
result ^= (unsigned int)(next / 65536) % 1024; u32 next = seed;
next *= 1103515245; int result;
next += 12345; next *= 1103515245;
result <<= 10; next += 12345;
result ^= (unsigned int)(next / 65536) % 1024; result = (unsigned int) (next / 65536) % 2048;
seed = next; next *= 1103515245;
return result; next += 12345;
result <<= 10;
} result ^= (unsigned int) (next / 65536) % 1024;
next *= 1103515245;
/******************************************************************************/ next += 12345;
/* Fonction qui renvoie un nombre aléatoire borné */ result <<= 10;
result ^= (unsigned int) (next / 65536) % 1024;
u32 random(u32 lower, u32 upper) seed = next;
{ return result;
return (rand() % (upper - lower + 1)) + lower; }
}
/******************************************************************************/
/*******************************************************************************/ /* Fonction qui renvoie un nombre aléatoire borné */
u32 random(u32 lower, u32 upper)
{
return (rand() % (upper - lower + 1)) + lower;
}
/*******************************************************************************/

View File

@ -10,154 +10,155 @@
void vector4_show(vector4 src) void vector4_show(vector4 src)
{ {
printf("vecteur: X=%f Y=%f Z=%f W=%f \r\n", src.x, src.y, src.z, src.w); printf("vecteur: X=%f Y=%f Z=%f W=%f \r\n", src.x, src.y, src.z,
src.w);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Créé un vecteur de 4 composantes */ /* Créé un vecteur de 4 composantes */
void vector4_create(float x, float y, float z, float w, vector4 *dst) void vector4_create(float x, float y, float z, float w, vector4 * dst)
{ {
dst->x = x; dst->x = x;
dst->y = y; dst->y = y;
dst->z = z; dst->z = z;
dst->w = w; dst->w = w;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Copie un vecteur de 4 composantes */ /* Copie un vecteur de 4 composantes */
void vector4_copy(vector4 src, vector4 *dst) void vector4_copy(vector4 src, vector4 * dst)
{ {
vector4_create(src.x, src.y, src.z, src.w, dst); vector4_create(src.x, src.y, src.z, src.w, dst);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Ajoute deux vecteurs de 4 composantes */ /* Ajoute deux vecteurs de 4 composantes */
void vector4_add(vector4 v1, vector4 v2, vector4 *dst) void vector4_add(vector4 v1, vector4 v2, vector4 * dst)
{ {
dst->x = v1.x + v2.x; dst->x = v1.x + v2.x;
dst->y = v1.y + v2.y; dst->y = v1.y + v2.y;
dst->z = v1.z + v2.z; dst->z = v1.z + v2.z;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Soustrait un vecteur de 4 composantes depuis un autre*/ /* Soustrait un vecteur de 4 composantes depuis un autre*/
void vector4_sub(vector4 v1, vector4 v2, vector4 *dst) void vector4_sub(vector4 v1, vector4 v2, vector4 * dst)
{ {
dst->x = v1.x - v2.x; dst->x = v1.x - v2.x;
dst->y = v1.y - v2.y; dst->y = v1.y - v2.y;
dst->z = v1.z - v2.z; dst->z = v1.z - v2.z;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Redimensionne un vecteur de 4 composantes */ /* Redimensionne un vecteur de 4 composantes */
void vector4_scale(vector4 *dst, float factor) void vector4_scale(vector4 * dst, float factor)
{ {
dst->x *= factor; dst->x *= factor;
dst->y *= factor; dst->y *= factor;
dst->z *= factor; dst->z *= factor;
dst->w *= factor; dst->w *= factor;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Calcule le produit vectoriel de deux vecteurs de 4 composantes */ /* Calcule le produit vectoriel de deux vecteurs de 4 composantes */
void vector4_crossproduct(vector4 v1, vector4 v2, vector4 *dst) void vector4_crossproduct(vector4 v1, vector4 v2, vector4 * dst)
{ {
dst->x = v1.y * v2.z - v1.z * v2.y; dst->x = v1.y * v2.z - v1.z * v2.y;
dst->y = v1.z * v2.x - v1.x * v2.z; dst->y = v1.z * v2.x - v1.x * v2.z;
dst->z = v1.x * v2.y - v1.y * v2.x; dst->z = v1.x * v2.y - v1.y * v2.x;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Normalise un vecteur de 4 composantes */ /* Normalise un vecteur de 4 composantes */
void vector4_normalize(vector4 *dst) void vector4_normalize(vector4 * dst)
{ {
float len; float len;
float norm; float norm;
norm = vector4_norm(*dst); norm = vector4_norm(*dst);
if (norm != 0) if (norm != 0)
{ {
len = 1 / norm; len = 1 / norm;
dst->x = dst->x * len; dst->x = dst->x * len;
dst->y = dst->y * len; dst->y = dst->y * len;
dst->z = dst->z * len; dst->z = dst->z * len;
dst->w = 0; dst->w = 0;
} }
} }
/*******************************************************************************/ /*******************************************************************************/
/* Divise un vecteur de 4 composantes depuis un autre*/ /* Divise un vecteur de 4 composantes depuis un autre*/
void vector4_divide(vector4 *v1, vector4 v2, vector4 *dst) void vector4_divide(vector4 * v1, vector4 v2, vector4 * dst)
{ {
dst->x = v1->x / v2.x; dst->x = v1->x / v2.x;
dst->y = v1->y / v2.y; dst->y = v1->y / v2.y;
dst->z = v1->z / v2.z; dst->z = v1->z / v2.z;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Détermine le 3ème vecteur perpendiculaire au 2 autres */ /* Détermine le 3ème vecteur perpendiculaire au 2 autres */
void vector4_perpendicular(vector4 v1, vector4 v2, vector4 *dst) void vector4_perpendicular(vector4 v1, vector4 v2, vector4 * dst)
{ {
float dot = vector4_dotproduct(v1, v2); float dot = vector4_dotproduct(v1, v2);
dst->x = v1.x - dot * v2.x; dst->x = v1.x - dot * v2.x;
dst->y = v1.y - dot * v2.y; dst->y = v1.y - dot * v2.y;
dst->z = v1.z - dot * v2.z; dst->z = v1.z - dot * v2.z;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Tourne un vecteur à 4 composantes autour de X */ /* Tourne un vecteur à 4 composantes autour de X */
void vector4_rotate_x(vector4 *dst, float angle) void vector4_rotate_x(vector4 * dst, float angle)
{ {
vector4 origin; vector4 origin;
float sinus, cosinus; float sinus, cosinus;
sinus = sinf(angle); sinus = sinf(angle);
cosinus = cosf(angle); cosinus = cosf(angle);
origin.x = dst->x; origin.x = dst->x;
origin.y = dst->y; origin.y = dst->y;
origin.z = dst->z; origin.z = dst->z;
dst->y = cosinus * origin.y + sinus * origin.z; dst->y = cosinus * origin.y + sinus * origin.z;
dst->z = cosinus * origin.z - sinus * origin.y; dst->z = cosinus * origin.z - sinus * origin.y;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Tourne un vecteur à 4 composantes autour de Y */ /* Tourne un vecteur à 4 composantes autour de Y */
void vector4_rotate_y(vector4 *dst, float angle) void vector4_rotate_y(vector4 * dst, float angle)
{ {
vector4 origin; vector4 origin;
float sinus, cosinus; float sinus, cosinus;
sinus = sinf(angle); sinus = sinf(angle);
cosinus = cosf(angle); cosinus = cosf(angle);
origin.x = dst->x; origin.x = dst->x;
origin.y = dst->y; origin.y = dst->y;
origin.z = dst->z; origin.z = dst->z;
dst->x = cosinus * origin.x + sinus * origin.z; dst->x = cosinus * origin.x + sinus * origin.z;
dst->z = cosinus * origin.z - sinus * origin.x; dst->z = cosinus * origin.z - sinus * origin.x;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Tourne un vecteur à 4 composantes autour de Z */ /* Tourne un vecteur à 4 composantes autour de Z */
void vector4_rotate_z(vector4 *dst, float angle) void vector4_rotate_z(vector4 * dst, float angle)
{ {
vector4 origin; vector4 origin;
float sinus, cosinus; float sinus, cosinus;
sinus = sinf(angle); sinus = sinf(angle);
cosinus = cosf(angle); cosinus = cosf(angle);
origin.x = dst->x; origin.x = dst->x;
origin.y = dst->y; origin.y = dst->y;
origin.z = dst->z; origin.z = dst->z;
dst->x = cosinus * origin.x + sinus * origin.y; dst->x = cosinus * origin.x + sinus * origin.y;
dst->y = cosinus * origin.y - sinus * origin.x; dst->y = cosinus * origin.y - sinus * origin.x;
} }
/*******************************************************************************/ /*******************************************************************************/
@ -165,9 +166,7 @@ void vector4_rotate_z(vector4 *dst, float angle)
float vector4_len(vector4 src) float vector4_len(vector4 src)
{ {
return sqrtf((src.x * src.x) + return sqrtf((src.x * src.x) + (src.y * src.y) + (src.z * src.z));
(src.y * src.y) +
(src.z * src.z));
} }
/*******************************************************************************/ /*******************************************************************************/
@ -175,7 +174,7 @@ float vector4_len(vector4 src)
float vector4_dotproduct(vector4 v1, vector4 v2) float vector4_dotproduct(vector4 v1, vector4 v2)
{ {
return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z); return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z);
} }
/*******************************************************************************/ /*******************************************************************************/
@ -183,9 +182,7 @@ float vector4_dotproduct(vector4 v1, vector4 v2)
float vector4_norm(vector4 src) float vector4_norm(vector4 src)
{ {
return sqrtf((src.x * src.x) + return sqrtf((src.x * src.x) + (src.y * src.y) + (src.z * src.z));
(src.y * src.y) +
(src.z * src.z));
} }
/*******************************************************************************/ /*******************************************************************************/
@ -193,9 +190,8 @@ float vector4_norm(vector4 src)
float vector4_distance(vector4 v1, vector4 v2) float vector4_distance(vector4 v1, vector4 v2)
{ {
return sqrt(pow(v2.x - v1.x, 2) + return sqrt(pow(v2.x - v1.x, 2) + pow(v2.y - v1.y, 2) +
pow(v2.y - v1.y, 2) + pow(v2.z - v1.z, 2));
pow(v2.z - v1.z, 2));
} }
/*******************************************************************************/ /*******************************************************************************/
@ -203,408 +199,455 @@ float vector4_distance(vector4 v1, vector4 v2)
int vector4_isequals(vector4 v1, vector4 v2) int vector4_isequals(vector4 v1, vector4 v2)
{ {
float x, y, z; float x, y, z;
x = fabsf(v1.x - v2.x); x = fabsf(v1.x - v2.x);
y = fabsf(v1.y - v2.y); y = fabsf(v1.y - v2.y);
z = fabsf(v1.z - v2.z); z = fabsf(v1.z - v2.z);
return (x < 0.000001 && y < 0.000001 && z < 0.000001); return (x < 0.000001 && y < 0.000001 && z < 0.000001);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Définie le plan normal à 3 vecteurs à 4 composantes */ /* Définie le plan normal à 3 vecteurs à 4 composantes */
void vector4_planenormal(vector4 v1, vector4 v2, vector4 v3, vector4 *dst) void vector4_planenormal(vector4 v1, vector4 v2, vector4 v3, vector4 * dst)
{ {
vector4 temp1, temp2; vector4 temp1, temp2;
vector4_sub(v2, v1, &temp1); vector4_sub(v2, v1, &temp1);
vector4_sub(v3, v1, &temp2); vector4_sub(v3, v1, &temp2);
vector4_crossproduct(temp1, temp2, dst); vector4_crossproduct(temp1, temp2, dst);
vector4_normalize(dst); vector4_normalize(dst);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Créé une matrice d'identité */ /* Créé une matrice d'identité */
void matrix44_homogen(matrix44 *matrix) void matrix44_homogen(matrix44 * matrix)
{ {
vector4_create(1, 0, 0, 0, &matrix->V[0]); vector4_create(1, 0, 0, 0, &matrix->V[0]);
vector4_create(0, 1, 0, 0, &matrix->V[1]); vector4_create(0, 1, 0, 0, &matrix->V[1]);
vector4_create(0, 0, 1, 0, &matrix->V[2]); vector4_create(0, 0, 1, 0, &matrix->V[2]);
vector4_create(0, 0, 0, 1, &matrix->V[3]); vector4_create(0, 0, 0, 1, &matrix->V[3]);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Créé une matrice vide */ /* Créé une matrice vide */
void matrix44_empty(matrix44 *matrix) void matrix44_empty(matrix44 * matrix)
{ {
vector4_create(0, 0, 0, 0, &matrix->V[0]); vector4_create(0, 0, 0, 0, &matrix->V[0]);
vector4_create(0, 0, 0, 0, &matrix->V[1]); vector4_create(0, 0, 0, 0, &matrix->V[1]);
vector4_create(0, 0, 0, 0, &matrix->V[2]); vector4_create(0, 0, 0, 0, &matrix->V[2]);
vector4_create(0, 0, 0, 0, &matrix->V[3]); vector4_create(0, 0, 0, 0, &matrix->V[3]);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Créé une matrice de redimensionnement (par un vecteur) */ /* Créé une matrice de redimensionnement (par un vecteur) */
void matrix44_scaling(vector4 v, matrix44 *dst) void matrix44_scaling(vector4 v, matrix44 * dst)
{ {
matrix44_homogen(dst); matrix44_homogen(dst);
dst->V[0].x = v.x; dst->V[0].x = v.x;
dst->V[1].y = v.y; dst->V[1].y = v.y;
dst->V[2].z = v.z; dst->V[2].z = v.z;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Créé une matrice de déplacement */ /* Créé une matrice de déplacement */
void matrix44_translation(vector4 v, matrix44 *dst) void matrix44_translation(vector4 v, matrix44 * dst)
{ {
matrix44_homogen(dst); matrix44_homogen(dst);
dst->V[0].x = v.x; dst->V[0].x = v.x;
dst->V[1].y = v.y; dst->V[1].y = v.y;
dst->V[2].z = v.z; dst->V[2].z = v.z;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Créé une matrice de redimensionnement (par un facteur) */ /* Créé une matrice de redimensionnement (par un facteur) */
void matrix44_scale(matrix44 *dst, float factor) void matrix44_scale(matrix44 * dst, float factor)
{ {
vector4_scale(&dst->V[0], factor); vector4_scale(&dst->V[0], factor);
vector4_scale(&dst->V[1], factor); vector4_scale(&dst->V[1], factor);
vector4_scale(&dst->V[2], factor); vector4_scale(&dst->V[2], factor);
vector4_scale(&dst->V[3], factor); vector4_scale(&dst->V[3], factor);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Créé une matrice de redimensionnement et de déplacement */ /* Créé une matrice de redimensionnement et de déplacement */
void matrix44_scale_translation(vector4 scale, vector4 translation, matrix44 *dst) void matrix44_scale_translation(vector4 scale, vector4 translation,
matrix44 * dst)
{ {
matrix44_homogen(dst); matrix44_homogen(dst);
dst->V[0].x = scale.x; dst->V[0].x = scale.x;
dst->V[1].y = scale.y; dst->V[1].y = scale.y;
dst->V[2].z = scale.z; dst->V[2].z = scale.z;
dst->V[3].x = translation.x; dst->V[3].x = translation.x;
dst->V[3].y = translation.y; dst->V[3].y = translation.y;
dst->V[3].z = translation.z; dst->V[3].z = translation.z;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Créé une matrice de rotation autour de X */ /* Créé une matrice de rotation autour de X */
void matrix44_rotation_x(float angle, matrix44 *dst) void matrix44_rotation_x(float angle, matrix44 * dst)
{ {
float sinus,cosinus; float sinus, cosinus;
cosinus = cosf(angle); cosinus = cosf(angle);
sinus = sinf(angle); sinus = sinf(angle);
matrix44_empty(dst); matrix44_empty(dst);
dst->V[0].x = 1; dst->V[0].x = 1;
dst->V[1].y = cosinus; dst->V[1].y = cosinus;
dst->V[1].z = sinus; dst->V[1].z = sinus;
dst->V[2].y = -1 * sinus; dst->V[2].y = -1 * sinus;
dst->V[2].z = cosinus; dst->V[2].z = cosinus;
dst->V[3].w = 1; dst->V[3].w = 1;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Créé une matrice de rotation autour de Y */ /* Créé une matrice de rotation autour de Y */
void matrix44_rotation_y(float angle, matrix44 *dst) void matrix44_rotation_y(float angle, matrix44 * dst)
{ {
float sinus,cosinus; float sinus, cosinus;
cosinus = cosf(angle); cosinus = cosf(angle);
sinus = sinf(angle); sinus = sinf(angle);
matrix44_empty(dst); matrix44_empty(dst);
dst->V[0].x = cosinus; dst->V[0].x = cosinus;
dst->V[0].z = -1 * sinus; dst->V[0].z = -1 * sinus;
dst->V[1].y = 1; dst->V[1].y = 1;
dst->V[2].x = sinus; dst->V[2].x = sinus;
dst->V[2].z = cosinus; dst->V[2].z = cosinus;
dst->V[3].w = 1; dst->V[3].w = 1;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Créé une matrice de rotation autour de Z */ /* Créé une matrice de rotation autour de Z */
void matrix44_rotation_z(float angle, matrix44 *dst) void matrix44_rotation_z(float angle, matrix44 * dst)
{ {
float sinus,cosinus; float sinus, cosinus;
cosinus = cosf(angle); cosinus = cosf(angle);
sinus = sinf(angle); sinus = sinf(angle);
matrix44_empty(dst); matrix44_empty(dst);
dst->V[0].x = cosinus; dst->V[0].x = cosinus;
dst->V[0].y = sinus; dst->V[0].y = sinus;
dst->V[1].x = -1 * sinus; dst->V[1].x = -1 * sinus;
dst->V[1].y = cosinus; dst->V[1].y = cosinus;
dst->V[2].z = 1; dst->V[2].z = 1;
dst->V[3].w = 1; dst->V[3].w = 1;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Créé une matrice de rotation multiple */ /* Créé une matrice de rotation multiple */
void matrix44_rotation(vector4 axis, float angle, matrix44 *dst) void matrix44_rotation(vector4 axis, float angle, matrix44 * dst)
{ {
float cosinus, sinus, minuscos; float cosinus, sinus, minuscos;
sinus = sinf(angle); sinus = sinf(angle);
cosinus = cosf(angle); cosinus = cosf(angle);
vector4_normalize(&axis); vector4_normalize(&axis);
minuscos = 1 - cosinus; minuscos = 1 - cosinus;
dst->V[0].x = (minuscos * axis.x * axis.x) + cosinus; dst->V[0].x = (minuscos * axis.x * axis.x) + cosinus;
dst->V[0].y = (minuscos * axis.x * axis.y) - (axis.z * sinus); dst->V[0].y = (minuscos * axis.x * axis.y) - (axis.z * sinus);
dst->V[0].z = (minuscos * axis.z * axis.x) + (axis.y * sinus); dst->V[0].z = (minuscos * axis.z * axis.x) + (axis.y * sinus);
dst->V[0].w = 0; dst->V[0].w = 0;
dst->V[1].x = (minuscos * axis.x * axis.y) + (axis.z * sinus); dst->V[1].x = (minuscos * axis.x * axis.y) + (axis.z * sinus);
dst->V[1].y = (minuscos * axis.y * axis.y) + cosinus; dst->V[1].y = (minuscos * axis.y * axis.y) + cosinus;
dst->V[1].z = (minuscos * axis.y * axis.z) - (axis.x * sinus); dst->V[1].z = (minuscos * axis.y * axis.z) - (axis.x * sinus);
dst->V[1].w = 0; dst->V[1].w = 0;
dst->V[2].x = (minuscos * axis.z * axis.x) - (axis.y * sinus); dst->V[2].x = (minuscos * axis.z * axis.x) - (axis.y * sinus);
dst->V[2].y = (minuscos * axis.y * axis.z) + (axis.x * sinus); dst->V[2].y = (minuscos * axis.y * axis.z) + (axis.x * sinus);
dst->V[2].z = (minuscos * axis.z * axis.z) + cosinus; dst->V[2].z = (minuscos * axis.z * axis.z) + cosinus;
dst->V[2].w = 0; dst->V[2].w = 0;
dst->V[3].x = 0; dst->V[3].x = 0;
dst->V[3].y = 0; dst->V[3].y = 0;
dst->V[3].z = 0; dst->V[3].z = 0;
dst->V[3].w = 1; dst->V[3].w = 1;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Multiplie deux matrices */ /* Multiplie deux matrices */
void matrix44_multiply(matrix44 *m1, matrix44 *m2, matrix44 *dst) void matrix44_multiply(matrix44 * m1, matrix44 * m2, matrix44 * dst)
{ {
dst->V[0].x = (m1->V[0].x * m2->V[0].x + m1->V[0].y * m2->V[1].x + dst->V[0].x =
m1->V[0].z * m2->V[2].x + m1->V[0].w * m2->V[3].x); (m1->V[0].x * m2->V[0].x + m1->V[0].y * m2->V[1].x +
dst->V[0].y = (m1->V[0].x * m2->V[0].y + m1->V[0].y * m2->V[1].y + m1->V[0].z * m2->V[2].x + m1->V[0].w * m2->V[3].x);
m1->V[0].z * m2->V[2].y + m1->V[0].w * m2->V[3].y); dst->V[0].y =
dst->V[0].z = (m1->V[0].x * m2->V[0].z + m1->V[0].y * m2->V[1].z + (m1->V[0].x * m2->V[0].y + m1->V[0].y * m2->V[1].y +
m1->V[0].z * m2->V[2].z + m1->V[0].w * m2->V[3].z); m1->V[0].z * m2->V[2].y + m1->V[0].w * m2->V[3].y);
dst->V[0].w = (m1->V[0].x * m2->V[0].w + m1->V[0].y * m2->V[1].w + dst->V[0].z =
m1->V[0].z * m2->V[2].w + m1->V[0].w * m2->V[3].w); (m1->V[0].x * m2->V[0].z + m1->V[0].y * m2->V[1].z +
dst->V[1].x = (m1->V[1].x * m2->V[0].x + m1->V[1].y * m2->V[1].x + m1->V[0].z * m2->V[2].z + m1->V[0].w * m2->V[3].z);
m1->V[1].z * m2->V[2].x + m1->V[1].w * m2->V[3].x); dst->V[0].w =
dst->V[1].y = (m1->V[1].x * m2->V[0].y + m1->V[1].y * m2->V[1].y + (m1->V[0].x * m2->V[0].w + m1->V[0].y * m2->V[1].w +
m1->V[1].z * m2->V[2].y + m1->V[1].w * m2->V[3].y); m1->V[0].z * m2->V[2].w + m1->V[0].w * m2->V[3].w);
dst->V[1].z = (m1->V[1].x * m2->V[0].z + m1->V[1].y * m2->V[1].z + dst->V[1].x =
m1->V[1].z * m2->V[2].z + m1->V[1].w * m2->V[3].z); (m1->V[1].x * m2->V[0].x + m1->V[1].y * m2->V[1].x +
dst->V[1].w = (m1->V[1].x * m2->V[0].w + m1->V[1].y * m2->V[1].w + m1->V[1].z * m2->V[2].x + m1->V[1].w * m2->V[3].x);
m1->V[1].z * m2->V[2].w + m1->V[1].w * m2->V[3].w); dst->V[1].y =
dst->V[2].x = (m1->V[2].x * m2->V[0].x + m1->V[2].y * m2->V[1].x + (m1->V[1].x * m2->V[0].y + m1->V[1].y * m2->V[1].y +
m1->V[2].z * m2->V[2].x + m1->V[2].w * m2->V[3].x); m1->V[1].z * m2->V[2].y + m1->V[1].w * m2->V[3].y);
dst->V[2].y = (m1->V[2].x * m2->V[0].y + m1->V[2].y * m2->V[1].y + dst->V[1].z =
m1->V[2].z * m2->V[2].y + m1->V[2].w * m2->V[3].y); (m1->V[1].x * m2->V[0].z + m1->V[1].y * m2->V[1].z +
dst->V[2].z = (m1->V[2].x * m2->V[0].z + m1->V[2].y * m2->V[1].z + m1->V[1].z * m2->V[2].z + m1->V[1].w * m2->V[3].z);
m1->V[2].z * m2->V[2].z + m1->V[2].w * m2->V[3].z); dst->V[1].w =
dst->V[2].w = (m1->V[2].x * m2->V[0].w + m1->V[2].y * m2->V[1].w + (m1->V[1].x * m2->V[0].w + m1->V[1].y * m2->V[1].w +
m1->V[2].z * m2->V[2].w + m1->V[2].w * m2->V[3].w); m1->V[1].z * m2->V[2].w + m1->V[1].w * m2->V[3].w);
dst->V[3].x = (m1->V[3].x * m2->V[0].x + m1->V[3].y * m2->V[1].x + dst->V[2].x =
m1->V[3].z * m2->V[2].x + m1->V[3].w * m2->V[3].x); (m1->V[2].x * m2->V[0].x + m1->V[2].y * m2->V[1].x +
dst->V[3].y = (m1->V[3].x * m2->V[0].y + m1->V[3].y * m2->V[1].y + m1->V[2].z * m2->V[2].x + m1->V[2].w * m2->V[3].x);
m1->V[3].z * m2->V[2].y + m1->V[3].w * m2->V[3].y); dst->V[2].y =
dst->V[3].z = (m1->V[3].x * m2->V[0].z + m1->V[3].y * m2->V[1].z + (m1->V[2].x * m2->V[0].y + m1->V[2].y * m2->V[1].y +
m1->V[3].z * m2->V[2].z + m1->V[3].w * m2->V[3].z); m1->V[2].z * m2->V[2].y + m1->V[2].w * m2->V[3].y);
dst->V[3].w = (m1->V[3].x * m2->V[0].w + m1->V[3].y * m2->V[1].w + dst->V[2].z =
m1->V[3].z * m2->V[2].w + m1->V[3].w * m2->V[3].w); (m1->V[2].x * m2->V[0].z + m1->V[2].y * m2->V[1].z +
m1->V[2].z * m2->V[2].z + m1->V[2].w * m2->V[3].z);
dst->V[2].w =
(m1->V[2].x * m2->V[0].w + m1->V[2].y * m2->V[1].w +
m1->V[2].z * m2->V[2].w + m1->V[2].w * m2->V[3].w);
dst->V[3].x =
(m1->V[3].x * m2->V[0].x + m1->V[3].y * m2->V[1].x +
m1->V[3].z * m2->V[2].x + m1->V[3].w * m2->V[3].x);
dst->V[3].y =
(m1->V[3].x * m2->V[0].y + m1->V[3].y * m2->V[1].y +
m1->V[3].z * m2->V[2].y + m1->V[3].w * m2->V[3].y);
dst->V[3].z =
(m1->V[3].x * m2->V[0].z + m1->V[3].y * m2->V[1].z +
m1->V[3].z * m2->V[2].z + m1->V[3].w * m2->V[3].z);
dst->V[3].w =
(m1->V[3].x * m2->V[0].w + m1->V[3].y * m2->V[1].w +
m1->V[3].z * m2->V[2].w + m1->V[3].w * m2->V[3].w);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Transforme une matrice avec un vecteur à 4 composantes */ /* Transforme une matrice avec un vecteur à 4 composantes */
void matrix44_transform(matrix44 *matrix, vector4 *dst) void matrix44_transform(matrix44 * matrix, vector4 * dst)
{ {
vector4 origin; vector4 origin;
origin.x = dst->x; origin.x = dst->x;
origin.y = dst->y; origin.y = dst->y;
origin.z = dst->z; origin.z = dst->z;
origin.w = dst->w; origin.w = dst->w;
dst->x = origin.x * matrix->V[0].x + origin.y * matrix->V[1].x + origin.z * matrix->V[2].x + origin.w * matrix->V[3].x; dst->x = origin.x * matrix->V[0].x + origin.y * matrix->V[1].x +
dst->y = origin.x * matrix->V[0].y + origin.y * matrix->V[1].y + origin.z * matrix->V[2].y + origin.w * matrix->V[3].y; origin.z * matrix->V[2].x + origin.w * matrix->V[3].x;
dst->z = origin.x * matrix->V[0].z + origin.y * matrix->V[1].z + origin.z * matrix->V[2].z + origin.w * matrix->V[3].z; dst->y = origin.x * matrix->V[0].y + origin.y * matrix->V[1].y +
dst->w = origin.x * matrix->V[0].w + origin.y * matrix->V[1].w + origin.z * matrix->V[2].w + origin.w * matrix->V[3].w; origin.z * matrix->V[2].y + origin.w * matrix->V[3].y;
dst->z = origin.x * matrix->V[0].z + origin.y * matrix->V[1].z +
origin.z * matrix->V[2].z + origin.w * matrix->V[3].z;
dst->w = origin.x * matrix->V[0].w + origin.y * matrix->V[1].w +
origin.z * matrix->V[2].w + origin.w * matrix->V[3].w;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Calcule le déterminant d'une matrice */ /* Calcule le déterminant d'une matrice */
float matrix44_determinant(matrix44 *matrix) float matrix44_determinant(matrix44 * matrix)
{ {
float a, b, c, d; float a, b, c, d;
a = matrix->V[0].x * todeterminant(matrix->V[1].y, matrix->V[2].y, matrix->V[3].y, a = matrix->V[0].x * todeterminant(matrix->V[1].y, matrix->V[2].y,
matrix->V[1].z, matrix->V[2].z, matrix->V[3].z, matrix->V[3].y, matrix->V[1].z,
matrix->V[1].w, matrix->V[2].w, matrix->V[3].w); matrix->V[2].z, matrix->V[3].z,
b = matrix->V[0].y * todeterminant(matrix->V[1].x, matrix->V[2].x, matrix->V[3].x, matrix->V[1].w, matrix->V[2].w,
matrix->V[1].z, matrix->V[2].z, matrix->V[3].z, matrix->V[3].w);
matrix->V[1].w, matrix->V[2].w, matrix->V[3].w); b = matrix->V[0].y * todeterminant(matrix->V[1].x, matrix->V[2].x,
c = matrix->V[0].z * todeterminant(matrix->V[1].x, matrix->V[2].x, matrix->V[3].x, matrix->V[3].x, matrix->V[1].z,
matrix->V[1].y, matrix->V[2].y, matrix->V[3].y, matrix->V[2].z, matrix->V[3].z,
matrix->V[1].w, matrix->V[2].w, matrix->V[3].w); matrix->V[1].w, matrix->V[2].w,
d = matrix->V[0].w * todeterminant(matrix->V[1].x, matrix->V[2].x, matrix->V[3].x, matrix->V[3].w);
matrix->V[1].y, matrix->V[2].y, matrix->V[3].y, c = matrix->V[0].z * todeterminant(matrix->V[1].x, matrix->V[2].x,
matrix->V[1].z, matrix->V[2].z, matrix->V[3].z); matrix->V[3].x, matrix->V[1].y,
return a - b + c - d; matrix->V[2].y, matrix->V[3].y,
matrix->V[1].w, matrix->V[2].w,
matrix->V[3].w);
d = matrix->V[0].w * todeterminant(matrix->V[1].x, matrix->V[2].x,
matrix->V[3].x, matrix->V[1].y,
matrix->V[2].y, matrix->V[3].y,
matrix->V[1].z, matrix->V[2].z,
matrix->V[3].z);
return a - b + c - d;
} }
float todeterminant(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3) float todeterminant(float a1, float a2, float a3, float b1, float b2,
float b3, float c1, float c2, float c3)
{ {
return (a1 * ((b2 * c3) - (b3 * c2))) - (b1 * ((a2 * c3) - (a3 * c2))) + (c1 * ((a2 * b3) - (a3 * b2))); return (a1 * ((b2 * c3) - (b3 * c2))) -
(b1 * ((a2 * c3) - (a3 * c2))) +
(c1 * ((a2 * b3) - (a3 * b2)));
} }
/*******************************************************************************/ /*******************************************************************************/
/* Crée une matrice adjointe */ /* Crée une matrice adjointe */
void matrix44_adjoint(matrix44 *matrix) void matrix44_adjoint(matrix44 * matrix)
{ {
float a1, a2, a3, a4, b1, b2, b3, b4, c1, c2, c3, c4, d1, d2, d3, d4; float a1, a2, a3, a4, b1, b2, b3, b4, c1, c2, c3, c4, d1, d2, d3,
a1 = matrix->V[0].x; d4;
b1 = matrix->V[0].y; a1 = matrix->V[0].x;
c1 = matrix->V[0].z; b1 = matrix->V[0].y;
d1 = matrix->V[0].w; c1 = matrix->V[0].z;
d1 = matrix->V[0].w;
a2 = matrix->V[1].x; a2 = matrix->V[1].x;
b2 = matrix->V[1].y; b2 = matrix->V[1].y;
c2 = matrix->V[1].z; c2 = matrix->V[1].z;
d2 = matrix->V[1].w; d2 = matrix->V[1].w;
a3 = matrix->V[2].x; a3 = matrix->V[2].x;
b3 = matrix->V[2].y; b3 = matrix->V[2].y;
c3 = matrix->V[2].z; c3 = matrix->V[2].z;
d3 = matrix->V[2].w; d3 = matrix->V[2].w;
a4 = matrix->V[3].x; a4 = matrix->V[3].x;
b4 = matrix->V[3].y; b4 = matrix->V[3].y;
c4 = matrix->V[3].z; c4 = matrix->V[3].z;
d4 = matrix->V[3].w; d4 = matrix->V[3].w;
matrix->V[0].x = todeterminant(b2, b3, b4, c2, c3, c4, d2, d3, d4); matrix->V[0].x = todeterminant(b2, b3, b4, c2, c3, c4, d2, d3, d4);
matrix->V[1].x = -todeterminant(a2, a3, a4, c2, c3, c4, d2, d3, d4); matrix->V[1].x =
matrix->V[2].x = todeterminant(a2, a3, a4, b2, b3, b4, d2, d3, d4); -todeterminant(a2, a3, a4, c2, c3, c4, d2, d3, d4);
matrix->V[3].x = -todeterminant(a2, a3, a4, b2, b3, b4, c2, c3, c4); matrix->V[2].x = todeterminant(a2, a3, a4, b2, b3, b4, d2, d3, d4);
matrix->V[3].x =
-todeterminant(a2, a3, a4, b2, b3, b4, c2, c3, c4);
matrix->V[0].y = -todeterminant(b1, b3, b4, c1, c3, c4, d1, d3, d4); matrix->V[0].y =
matrix->V[1].y = todeterminant(a1, a3, a4, c1, c3, c4, d1, d3, d4); -todeterminant(b1, b3, b4, c1, c3, c4, d1, d3, d4);
matrix->V[2].y = -todeterminant(a1, a3, a4, b1, b3, b4, d1, d3, d4); matrix->V[1].y = todeterminant(a1, a3, a4, c1, c3, c4, d1, d3, d4);
matrix->V[3].y = todeterminant(a1, a3, a4, b1, b3, b4, c1, c3, c4); matrix->V[2].y =
-todeterminant(a1, a3, a4, b1, b3, b4, d1, d3, d4);
matrix->V[3].y = todeterminant(a1, a3, a4, b1, b3, b4, c1, c3, c4);
matrix->V[0].z = todeterminant(b1, b2, b4, c1, c2, c4, d1, d2, d4); matrix->V[0].z = todeterminant(b1, b2, b4, c1, c2, c4, d1, d2, d4);
matrix->V[1].z = -todeterminant(a1, a2, a4, c1, c2, c4, d1, d2, d4); matrix->V[1].z =
matrix->V[2].z = todeterminant(a1, a2, a4, b1, b2, b4, d1, d2, d4); -todeterminant(a1, a2, a4, c1, c2, c4, d1, d2, d4);
matrix->V[3].z = -todeterminant(a1, a2, a4, b1, b2, b4, c1, c2, c4); matrix->V[2].z = todeterminant(a1, a2, a4, b1, b2, b4, d1, d2, d4);
matrix->V[3].z =
-todeterminant(a1, a2, a4, b1, b2, b4, c1, c2, c4);
matrix->V[0].w = -todeterminant(b1, b2, b3, c1, c2, c3, d1, d2, d3); matrix->V[0].w =
matrix->V[1].w = todeterminant(a1, a2, a3, c1, c2, c3, d1, d2, d3); -todeterminant(b1, b2, b3, c1, c2, c3, d1, d2, d3);
matrix->V[2].w = -todeterminant(a1, a2, a3, b1, b2, b3, d1, d2, d3); matrix->V[1].w = todeterminant(a1, a2, a3, c1, c2, c3, d1, d2, d3);
matrix->V[3].w = todeterminant(a1, a2, a3, b1, b2, b3, c1, c2, c3); matrix->V[2].w =
-todeterminant(a1, a2, a3, b1, b2, b3, d1, d2, d3);
matrix->V[3].w = todeterminant(a1, a2, a3, b1, b2, b3, c1, c2, c3);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Affiche une matrice */ /* Affiche une matrice */
void matrix44_show(matrix44 *matrix) void matrix44_show(matrix44 * matrix)
{ {
printf("Matrice: X=%f Y=%f Z=%f W=%f \r\n", matrix->V[0].x, matrix->V[1].y, matrix->V[2].z, matrix->V[3].w); printf("Matrice: X=%f Y=%f Z=%f W=%f \r\n", matrix->V[0].x,
printf(" X=%f Y=%f Z=%f W=%f \r\n", matrix->V[0].x, matrix->V[1].y, matrix->V[2].z, matrix->V[3].w); matrix->V[1].y, matrix->V[2].z, matrix->V[3].w);
printf(" X=%f Y=%f Z=%f W=%f \r\n", matrix->V[0].x, matrix->V[1].y, matrix->V[2].z, matrix->V[3].w); printf(" X=%f Y=%f Z=%f W=%f \r\n", matrix->V[0].x,
matrix->V[1].y, matrix->V[2].z, matrix->V[3].w);
printf(" X=%f Y=%f Z=%f W=%f \r\n", matrix->V[0].x,
matrix->V[1].y, matrix->V[2].z, matrix->V[3].w);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Inverse une matrice */ /* Inverse une matrice */
void matrix44_invert(matrix44 *matrix) void matrix44_invert(matrix44 * matrix)
{ {
float det; float det;
det = matrix44_determinant(matrix); det = matrix44_determinant(matrix);
if (fabs(det) < EPSILON) if (fabs(det) < EPSILON)
{ {
matrix44_homogen(matrix); matrix44_homogen(matrix);
} }
else else
{ {
matrix44_adjoint(matrix); matrix44_adjoint(matrix);
matrix44_scale(matrix, 1.0 / det); matrix44_scale(matrix, 1.0 / det);
} }
} }
/*******************************************************************************/ /*******************************************************************************/
/* Transpose une matrice */ /* Transpose une matrice */
void matrix44_transpose(matrix44 *matrix) void matrix44_transpose(matrix44 * matrix)
{ {
float f; float f;
f = matrix->V[0].y; f = matrix->V[0].y;
matrix->V[0].y = matrix->V[1].x; matrix->V[0].y = matrix->V[1].x;
matrix->V[1].x = f; matrix->V[1].x = f;
f = matrix->V[0].z; f = matrix->V[0].z;
matrix->V[0].z = matrix->V[2].x; matrix->V[0].z = matrix->V[2].x;
matrix->V[2].x = f; matrix->V[2].x = f;
f = matrix->V[0].w; f = matrix->V[0].w;
matrix->V[0].w = matrix->V[3].x; matrix->V[0].w = matrix->V[3].x;
matrix->V[3].x = f; matrix->V[3].x = f;
f = matrix->V[1].z; f = matrix->V[1].z;
matrix->V[1].z = matrix->V[2].y; matrix->V[1].z = matrix->V[2].y;
matrix->V[2].y = f; matrix->V[2].y = f;
f = matrix->V[1].w; f = matrix->V[1].w;
matrix->V[1].w = matrix->V[3].y; matrix->V[1].w = matrix->V[3].y;
matrix->V[3].y = f; matrix->V[3].y = f;
f = matrix->V[2].w; f = matrix->V[2].w;
matrix->V[2].w = matrix->V[3].z; matrix->V[2].w = matrix->V[3].z;
matrix->V[3].z = f; matrix->V[3].z = f;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Crée une matrice de camera */ /* Crée une matrice de camera */
void matrix44_lookat(vector4 eye, vector4 dst, vector4 up, matrix44 *matrix) void matrix44_lookat(vector4 eye, vector4 dst, vector4 up,
matrix44 * matrix)
{ {
vector4 xaxis, yaxis, zaxis, negeye; vector4 xaxis, yaxis, zaxis, negeye;
vector4_sub(dst, eye, &zaxis); vector4_sub(dst, eye, &zaxis);
vector4_normalize(&zaxis); vector4_normalize(&zaxis);
vector4_crossproduct(zaxis, up, &xaxis); vector4_crossproduct(zaxis, up, &xaxis);
vector4_normalize(&xaxis); vector4_normalize(&xaxis);
vector4_crossproduct(xaxis, zaxis, &yaxis); vector4_crossproduct(xaxis, zaxis, &yaxis);
vector4_copy(xaxis, &matrix->V[0]); vector4_copy(xaxis, &matrix->V[0]);
vector4_copy(yaxis, &matrix->V[1]); vector4_copy(yaxis, &matrix->V[1]);
vector4_copy(zaxis, &matrix->V[2]); vector4_copy(zaxis, &matrix->V[2]);
matrix->V[2].x = -matrix->V[2].x; matrix->V[2].x = -matrix->V[2].x;
matrix->V[2].y = -matrix->V[2].y; matrix->V[2].y = -matrix->V[2].y;
matrix->V[2].z = -matrix->V[2].z; matrix->V[2].z = -matrix->V[2].z;
vector4_create(0, 0, 0, 1, &matrix->V[3]); vector4_create(0, 0, 0, 1, &matrix->V[3]);
matrix44_transpose(matrix); matrix44_transpose(matrix);
vector4_create(-eye.x, -eye.y, -eye.z, 1, &negeye); vector4_create(-eye.x, -eye.y, -eye.z, 1, &negeye);
matrix44_transform(matrix, &negeye); matrix44_transform(matrix, &negeye);
vector4_copy(negeye, &matrix->V[3]); vector4_copy(negeye, &matrix->V[3]);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Vérifie que deux matrices sont égales */ /* Vérifie que deux matrices sont égales */
int matrix44_isequals(matrix44 *m1, matrix44 *m2) int matrix44_isequals(matrix44 * m1, matrix44 * m2)
{ {
return vector4_isequals(m1->V[0], m2->V[0]) && vector4_isequals(m1->V[1], m2->V[1]) && return vector4_isequals(m1->V[0], m2->V[0])
vector4_isequals(m1->V[2], m2->V[2]) && vector4_isequals(m1->V[3], m2->V[3]); && vector4_isequals(m1->V[1], m2->V[1])
&& vector4_isequals(m1->V[2], m2->V[2])
&& vector4_isequals(m1->V[3], m2->V[3]);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Transforme une matrice en tableau */ /* Transforme une matrice en tableau */
float *toarray(matrix44 *m) float *toarray(matrix44 * m)
{ {
return &m->v; return &m->v;
} }

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@
bool initmouse(void) bool initmouse(void)
{ {
u16 i = 1024; u16 i = 1024;
outkbd(0x64, 0xA8); /* autorisé Aux */ outkbd(0x64, 0xA8); /* autorisé Aux */
@ -69,11 +69,13 @@ void mouse(void)
cli(); cli();
pushf(); pushf();
pushad(); pushad();
u8 mbyte = inb(0x60); u8 mbyte = inb(0x60);
s8 changex, changey; s8 changex, changey;
if (mousereplies > 0) { if (mousereplies > 0)
if (mbyte == 0xFA) { {
if (mbyte == 0xFA)
{
mousereplies--; mousereplies--;
goto endofint; goto endofint;
} }
@ -83,39 +85,52 @@ void mouse(void)
mpacket[bytepos] = mbyte; mpacket[bytepos] = mbyte;
bytepos++; bytepos++;
if (bytepos == 3) { if (bytepos == 3)
{
bytepos = 0; bytepos = 0;
if (mpacket[1] == 0) { if (mpacket[1] == 0)
{
changex = 0; changex = 0;
} else {
changex = (mpacket[0] & 0x10) ?
mpacket[1] - 256 : mpacket[1];
} }
if (mpacket[2] == 0) { else
{
changex =
(mpacket[0] & 0x10) ? mpacket[1] -
256 : mpacket[1];
}
if (mpacket[2] == 0)
{
changey = 0; changey = 0;
} else { }
changey = -((mpacket[0] & 0x20) ? else
mpacket[2] - 256 : mpacket[2]); {
changey =
-((mpacket[0] & 0x20) ? mpacket[2] -
256 : mpacket[2]);
} }
mousex += (changex << speed); mousex += (changex << speed);
mousey += (changey << speed); mousey += (changey << speed);
if (mousex < 0) { if (mousex < 0)
{
mousex = 0; mousex = 0;
} }
if (mousex >= 65535) { if (mousex >= 65535)
{
mousex = 65535; mousex = 65535;
} }
if (mousey < 0) { if (mousey < 0)
{
mousey = 0; mousey = 0;
} }
if (mousey >= 65535) { if (mousey >= 65535)
{
mousey = 65535; mousey = 65535;
} }
videoinfos *info=getvideo_info(); videoinfos *info = getvideo_info();
u16 newx = (u32) mousex * info->currentwidth / 65536; u16 newx = (u32) mousex * info->currentwidth / 65536;
u16 newy = (u32) mousey * info->currentheight / 65536; u16 newy = (u32) mousey * info->currentheight / 65536;
// Retrieve mouse button status from packet // Retrieve mouse button status from packet
mousebut1 = mpacket[0] & 1; mousebut1 = mpacket[0] & 1;
@ -124,10 +139,10 @@ void mouse(void)
// 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); // 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 (!info->isgraphic) if (!info->isgraphic)
showchar(newx, newy, 0xDB, 0x0F); showchar(newx, newy, 0xDB, 0x0F);
} }
endofint: endofint:
irqendmaster(); irqendmaster();
irqendslave(); irqendslave();
popad(); popad();

View File

@ -11,7 +11,7 @@ static u32 infobloc;
void initmultiboot(const u32 addr) void initmultiboot(const u32 addr)
{ {
infobloc=addr; infobloc = addr;
} }
/*******************************************************************************/ /*******************************************************************************/
@ -19,21 +19,25 @@ void initmultiboot(const u32 addr)
u32 getgrubinfo(u8 type) u32 getgrubinfo(u8 type)
{ {
struct multiboot_tag *tag; struct multiboot_tag *tag;
unsigned size = *(unsigned *) infobloc; unsigned size = *(unsigned *) infobloc;
for (tag = (struct multiboot_tag *) (infobloc + 8); for (tag = (struct multiboot_tag *) (infobloc + 8);
tag->type != MULTIBOOT_TAG_TYPE_END; tag->type != MULTIBOOT_TAG_TYPE_END;
tag = (struct multiboot_tag *) ((u8 *) tag + ((tag->size + 7) & ~7))) tag =
if (tag->type==type) return tag; (struct multiboot_tag *) ((u8 *) tag +
((tag->size + 7) & ~7)))
if (tag->type == type)
return tag;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Renvoie la ligne de commande */ /* Renvoie la ligne de commande */
u8 *getgrubinfo_cmdline(void) u8 *getgrubinfo_cmdline(void)
{ {
struct multiboot_tag_string *tag=getgrubinfo(MULTIBOOT_TAG_TYPE_CMDLINE); struct multiboot_tag_string *tag =
return tag->string; getgrubinfo(MULTIBOOT_TAG_TYPE_CMDLINE);
return tag->string;
} }
/*******************************************************************************/ /*******************************************************************************/
@ -41,8 +45,9 @@ u8 *getgrubinfo_cmdline(void)
u32 getgrubinfo_ram(void) u32 getgrubinfo_ram(void)
{ {
struct multiboot_tag_basic_meminfo *tag=getgrubinfo(MULTIBOOT_TAG_TYPE_BASIC_MEMINFO); struct multiboot_tag_basic_meminfo *tag =
return tag->mem_upper; getgrubinfo(MULTIBOOT_TAG_TYPE_BASIC_MEMINFO);
return tag->mem_upper;
} }
/*******************************************************************************/ /*******************************************************************************/
@ -50,8 +55,9 @@ u32 getgrubinfo_ram(void)
struct multiboot_tag_mmap *getgrubinfo_mem(void) struct multiboot_tag_mmap *getgrubinfo_mem(void)
{ {
struct multiboot_tag_mmap *tag=getgrubinfo(MULTIBOOT_TAG_TYPE_MMAP); struct multiboot_tag_mmap *tag =
return tag; getgrubinfo(MULTIBOOT_TAG_TYPE_MMAP);
return tag;
} }
/*******************************************************************************/ /*******************************************************************************/
@ -59,8 +65,9 @@ struct multiboot_tag_mmap *getgrubinfo_mem(void)
struct multiboot_tag_framebuffer *getgrubinfo_fb(void) struct multiboot_tag_framebuffer *getgrubinfo_fb(void)
{ {
struct multiboot_tag_framebuffer *tag=getgrubinfo(MULTIBOOT_TAG_TYPE_FRAMEBUFFER); struct multiboot_tag_framebuffer *tag =
return tag; getgrubinfo(MULTIBOOT_TAG_TYPE_FRAMEBUFFER);
return tag;
} }
/*******************************************************************************/ /*******************************************************************************/
@ -68,78 +75,84 @@ struct multiboot_tag_framebuffer *getgrubinfo_fb(void)
void getgrubinfo_all(void) void getgrubinfo_all(void)
{ {
struct multiboot_tag *tag; struct multiboot_tag *tag;
u32 size = *(unsigned *) infobloc; u32 size = *(unsigned *) infobloc;
if (infobloc & 7) print("Attention : Bloc non aligne..."); if (infobloc & 7)
printf(" Taille :% 4u\r\n", (u32)size); print("Attention : Bloc non aligne...");
for (tag = (struct multiboot_tag *) (infobloc + 8); printf(" Taille :% 4u\r\n", (u32) size);
tag->type != MULTIBOOT_TAG_TYPE_END; for (tag = (struct multiboot_tag *) (infobloc + 8);
tag = (struct multiboot_tag *) ((u8 *) tag + ((tag->size + 7) & ~7))) tag->type != MULTIBOOT_TAG_TYPE_END;
{ tag =
printf ("--- Tag % hu, Taille % hu\r\n", tag->type, tag->size); (struct multiboot_tag *) ((u8 *) tag +
switch (tag->type) ((tag->size + 7) & ~7)))
{ {
case MULTIBOOT_TAG_TYPE_CMDLINE: printf("--- Tag % hu, Taille % hu\r\n", tag->type,
printf (" Ligne de lancement : %s\r\n", tag->size);
((struct multiboot_tag_string *) tag)->string); switch (tag->type)
break; {
case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME: case MULTIBOOT_TAG_TYPE_CMDLINE:
printf (" Chargeur de boot : %s\r\n", printf(" Ligne de lancement : %s\r\n",
((struct multiboot_tag_string *) tag)->string); ((struct multiboot_tag_string *)
break; tag)->string);
case MULTIBOOT_TAG_TYPE_MODULE: break;
printf (" Module %X-%X. Command line %s\r\n", case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME:
((struct multiboot_tag_module *) tag)->mod_start, printf(" Chargeur de boot : %s\r\n",
((struct multiboot_tag_module *) tag)->mod_end, ((struct multiboot_tag_string *)
((struct multiboot_tag_module *) tag)->cmdline); tag)->string);
break; break;
case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO: case MULTIBOOT_TAG_TYPE_MODULE:
printf (" Memoire basse : %H, memoire haute = %lH\r\n", printf(" Module %X-%X. Command line %s\r\n", ((struct multiboot_tag_module *) tag)->mod_start, ((struct multiboot_tag_module *) tag)->mod_end, ((struct multiboot_tag_module *) tag)->cmdline);
((struct multiboot_tag_basic_meminfo *) tag)->mem_lower<<10, break;
((u64)((struct multiboot_tag_basic_meminfo *) tag)->mem_upper)<<10); case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO:
break; printf(" Memoire basse : %H, memoire haute = %lH\r\n", ((struct multiboot_tag_basic_meminfo *) tag)->mem_lower << 10, ((u64) ((struct multiboot_tag_basic_meminfo *) tag)->mem_upper) << 10);
case MULTIBOOT_TAG_TYPE_BOOTDEV: break;
printf (" Peripherique de demarrage : %Y,%u,%u\r\n\r\n", case MULTIBOOT_TAG_TYPE_BOOTDEV:
((struct multiboot_tag_bootdev *) tag)->biosdev, printf(" Peripherique de demarrage : %Y,%u,%u\r\n\r\n", ((struct multiboot_tag_bootdev *) tag)->biosdev, ((struct multiboot_tag_bootdev *) tag)->slice, ((struct multiboot_tag_bootdev *) tag)->part);
((struct multiboot_tag_bootdev *) tag)->slice, break;
((struct multiboot_tag_bootdev *) tag)->part); case MULTIBOOT_TAG_TYPE_MMAP:
break; {
case MULTIBOOT_TAG_TYPE_MMAP: multiboot_memory_map_t *mmap;
{ printf("*** Plan de memoire ***\r\n");
multiboot_memory_map_t *mmap; for (mmap =
printf ("*** Plan de memoire ***\r\n"); ((struct multiboot_tag_mmap *) tag)->
for (mmap = ((struct multiboot_tag_mmap *) tag)->entries;(u8 *) mmap < (u8 *) tag + tag->size; mmap = (multiboot_memory_map_t *) entries;
((unsigned long) mmap + ((struct multiboot_tag_mmap *) tag)->entry_size)) (u8 *) mmap < (u8 *) tag + tag->size;
printf (" adresse: %lY, taille:%lY, type:%Y\r\n", mmap =
(u64) (mmap->addr), (multiboot_memory_map_t
(u64) (mmap->len), *) ((unsigned long) mmap +
(u32) (mmap->type)); ((struct multiboot_tag_mmap *)
break; tag)->entry_size))
} printf(" adresse: %lY, taille:%lY, type:%Y\r\n", (u64) (mmap->addr), (u64) (mmap->len), (u32) (mmap->type));
case MULTIBOOT_TAG_TYPE_FRAMEBUFFER: break;
{ }
struct multiboot_tag_framebuffer *tagfb = (struct multiboot_tag_framebuffer *) tag; case MULTIBOOT_TAG_TYPE_FRAMEBUFFER:
printf (" Framebuffer, resolution %d*%d*%d adresse: %X, ",tagfb->common.framebuffer_width,tagfb->common.framebuffer_height,tagfb->common.framebuffer_bpp,tagfb->common.framebuffer_addr); {
switch (tagfb->common.framebuffer_type) struct multiboot_tag_framebuffer *tagfb =
{ (struct multiboot_tag_framebuffer
case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED: *) tag;
printf ("mode graphique indexé\r\n"); printf(" Framebuffer, resolution %d*%d*%d adresse: %X, ", tagfb->common.framebuffer_width, tagfb->common.framebuffer_height, tagfb->common.framebuffer_bpp, tagfb->common.framebuffer_addr);
break; switch (tagfb->common.framebuffer_type)
case MULTIBOOT_FRAMEBUFFER_TYPE_RGB: {
printf ("mode graphique RGB\r\n"); case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED:
break; printf("mode graphique indexé\r\n");
case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT: break;
printf ("mode texte EGA\r\n"); case MULTIBOOT_FRAMEBUFFER_TYPE_RGB:
break; printf("mode graphique RGB\r\n");
} break;
break; case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT:
} printf("mode texte EGA\r\n");
case MULTIBOOT_TAG_TYPE_VBE: break;
{ }
struct multiboot_tag_vbe *tagvbe = (struct multiboot_tag_framebuffer *) tag; break;
printf (" VBE 2.0, mode %Y, adresse %hY:%hY-%hY\r\n", tagvbe->vbe_mode,tagvbe->vbe_interface_seg,tagvbe->vbe_interface_off,tagvbe->vbe_interface_len); }
} case MULTIBOOT_TAG_TYPE_VBE:
} {
} struct multiboot_tag_vbe *tagvbe =
(struct multiboot_tag_framebuffer
*) tag;
printf(" VBE 2.0, mode %Y, adresse %hY:%hY-%hY\r\n", tagvbe->vbe_mode, tagvbe->vbe_interface_seg, tagvbe->vbe_interface_off, tagvbe->vbe_interface_len);
}
}
}
} }
/*******************************************************************************/ /*******************************************************************************/

141
lib/pci.c
View File

@ -14,21 +14,26 @@
/*******************************************************************************/ /*******************************************************************************/
/* Retourne une chaine correspondant à l'ID class/subclass PCI */ /* Retourne une chaine correspondant à l'ID class/subclass PCI */
u8 * pcigetclassname( const pcidev *device) u8 *pcigetclassname(const pcidev * device)
{ {
pciclass *class = NULL; pciclass *class = NULL;
if ( device == NULL ) { if (device == NULL)
{
return NULL; return NULL;
} }
if ( device->base_class == 0xff ) { if (device->base_class == 0xff)
{
return "Unassigned class"; return "Unassigned class";
} }
class = classcodes[device->base_class]; class = classcodes[device->base_class];
if (!class) { if (!class)
{
return "Unknowned class"; return "Unknowned class";
} }
while (class->name != NULL) { while (class->name != NULL)
if (class->number == device->sub_class) { {
if (class->number == device->sub_class)
{
return class->name; return class->name;
} }
class++; class++;
@ -42,52 +47,63 @@ u8 * pcigetclassname( const pcidev *device)
pcidevmini getPCImininfo(const u8 bus, const u8 dev, const u8 function) pcidevmini getPCImininfo(const u8 bus, const u8 dev, const u8 function)
{ {
pcidevmini result; pcidevmini result;
if ((result.vendor_id = pciConfigReadWord(bus,dev,function,0x0)) != 0xFFFF) { if ((result.vendor_id =
result.device_id = pciConfigReadWord(bus,dev,function,0x2); pciConfigReadWord(bus, dev, function, 0x0)) != 0xFFFF)
} {
return result; result.device_id =
pciConfigReadWord(bus, dev, function, 0x2);
}
return result;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Récupère toutes les informations du periphérique PCI donnée */ /* Récupère toutes les informations du periphérique PCI donnée */
bool getPCInfo(pcidev *device, const u8 bus, const u8 dev, const u8 function) bool getPCInfo(pcidev * device, const u8 bus, const u8 dev,
const u8 function)
{ {
if ((device->vendor_id = pciConfigReadWord(bus,dev,function,0x0)) != 0xFFFF) if ((device->vendor_id =
{ pciConfigReadWord(bus, dev, function, 0x0)) != 0xFFFF)
u16 temp; {
device->device_id = pciConfigReadWord(bus,dev,function,0x2); u16 temp;
device->command = pciConfigReadWord(bus,dev,function,0x4); device->device_id =
device->status = pciConfigReadWord(bus,dev,function,0x6); pciConfigReadWord(bus, dev, function, 0x2);
temp=pciConfigReadWord(bus,dev,function,0x8); device->command =
device->revision_id = temp & 0xFF; pciConfigReadWord(bus, dev, function, 0x4);
device->interface = temp>>8; device->status =
temp=pciConfigReadWord(bus,dev,function,0xA); pciConfigReadWord(bus, dev, function, 0x6);
device->sub_class = temp & 0xFF; temp = pciConfigReadWord(bus, dev, function, 0x8);
device->base_class = temp>>8; device->revision_id = temp & 0xFF;
temp=pciConfigReadWord(bus,dev,function,0xC); device->interface = temp >> 8;
device->cache_line_size = temp & 0xFF; temp = pciConfigReadWord(bus, dev, function, 0xA);
device->latency_timer = temp>>8; device->sub_class = temp & 0xFF;
temp=pciConfigReadWord(bus,dev,function,0xE); device->base_class = temp >> 8;
device->header_type = temp & 0xFF; temp = pciConfigReadWord(bus, dev, function, 0xC);
device->bist = temp>>8; device->cache_line_size = temp & 0xFF;
return true; device->latency_timer = temp >> 8;
} temp = pciConfigReadWord(bus, dev, function, 0xE);
else device->header_type = temp & 0xFF;
return false; device->bist = temp >> 8;
return true;
}
else
return false;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Récupère les informations sur le periphérique PCI donnée */ /* Récupère les informations sur le periphérique PCI donnée */
u16 pciConfigReadWord(const u8 bus, const u8 dev, const u8 function, const u8 offset) u16 pciConfigReadWord(const u8 bus, const u8 dev, const u8 function,
const u8 offset)
{ {
u16 tmp = 0; u16 tmp = 0;
u32 addr = (0x80000000|(bus << 16)|(dev << 11)|(function << 8)|(offset & 0xFC)); u32 addr =
outd(0xCF8, addr); (0x80000000 | (bus << 16) | (dev << 11) | (function << 8) |
tmp = (u16)((ind(0xCFC) >> ((offset & 2) * 8)) & 0xffff); (offset & 0xFC));
return tmp; outd(0xCF8, addr);
tmp = (u16) ((ind(0xCFC) >> ((offset & 2) * 8)) & 0xffff);
return tmp;
} }
/*******************************************************************************/ /*******************************************************************************/
@ -95,17 +111,19 @@ u16 pciConfigReadWord(const u8 bus, const u8 dev, const u8 function, const u8 of
void scanPCImini(void) void scanPCImini(void)
{ {
u16 bus,device,function; u16 bus, device, function;
pcidevmini result; pcidevmini result;
for (bus=0; bus<MAX_BUS_SCAN; ++bus) for (bus = 0; bus < MAX_BUS_SCAN; ++bus)
for (device=0; device<MAX_DEVICE_SCAN; ++device) for (device = 0; device < MAX_DEVICE_SCAN; ++device)
for (function=0; function<MAX_FUNCTION_SCAN; ++function) for (function = 0; function < MAX_FUNCTION_SCAN;
{ ++function)
result = getPCImininfo(bus,device,function); {
if (result.vendor_id != 0xFFFF) result = getPCImininfo(bus, device,
printf("Bus:%hx Dev:%hx Func:%hx %hx:%hx\r\n",bus, device, function, result.vendor_id, result.device_id); function);
} if (result.vendor_id != 0xFFFF)
return; printf("Bus:%hx Dev:%hx Func:%hx %hx:%hx\r\n", bus, device, function, result.vendor_id, result.device_id);
}
return;
} }
/*******************************************************************************/ /*******************************************************************************/
@ -114,15 +132,16 @@ void scanPCImini(void)
void scanPCI(void) void scanPCI(void)
{ {
u16 bus,device,function; u16 bus, device, function;
pcidev result; pcidev result;
for (bus=0; bus<MAX_BUS_SCAN; ++bus) for (bus = 0; bus < MAX_BUS_SCAN; ++bus)
for (device=0; device<MAX_DEVICE_SCAN; ++device) for (device = 0; device < MAX_DEVICE_SCAN; ++device)
for (function=0; function<MAX_FUNCTION_SCAN; ++function) for (function = 0; function < MAX_FUNCTION_SCAN;
if (getPCInfo(&result,bus,device,function)) ++function)
printf("Bus:%hx Dev:%hx Func:%hx %hx:%hx ->%s\r\n",bus, device, function, result.vendor_id, result.device_id,pcigetclassname(&result)); if (getPCInfo
return; (&result, bus, device, function))
printf("Bus:%hx Dev:%hx Func:%hx %hx:%hx ->%s\r\n", bus, device, function, result.vendor_id, result.device_id, pcigetclassname(&result));
return;
} }
/*******************************************************************************/ /*******************************************************************************/

View File

@ -9,16 +9,18 @@
process *processes; process *processes;
process *current; process *current;
u32 lastpid; u32 lastpid;
static u8 elf_errors1[]="Aucune signature ELF"; static u8 elf_errors1[] = "Aucune signature ELF";
static u8 elf_errors2[]="Fichier au format ELF mais non 32 bits"; static u8 elf_errors2[] = "Fichier au format ELF mais non 32 bits";
static u8 elf_errors3[]="ELF non LSB"; static u8 elf_errors3[] = "ELF non LSB";
static u8 elf_errors4[]="ELF mauvaise version"; static u8 elf_errors4[] = "ELF mauvaise version";
static u8 elf_errors5[]="ELF pour OS ne correspondant pas"; static u8 elf_errors5[] = "ELF pour OS ne correspondant pas";
static u8 elf_errors6[]="Mauvais type de machine"; static u8 elf_errors6[] = "Mauvais type de machine";
static u8 *elf_errors[]={&elf_errors1,&elf_errors2,&elf_errors3,&elf_errors4,&elf_errors5,&elf_errors6}; static u8 *elf_errors[] =
{ &elf_errors1, &elf_errors2, &elf_errors3, &elf_errors4,
&elf_errors5, &elf_errors6 };
/*******************************************************************************/ /*******************************************************************************/
/* Vérifie la signature ELF /* Vérifie la signature ELF
@ -29,25 +31,28 @@ static u8 *elf_errors[]={&elf_errors1,&elf_errors2,&elf_errors3,&elf_errors4,&el
4 - pas bonne version ELF 4 - pas bonne version ELF
5 - pas bon OS 5 - pas bon OS
6 - pas bon type machine */ 6 - pas bon type machine */
u32 elf_test(u8 *src) u32 elf_test(u8 * src)
{ {
elf32 *header=(elf32 *) src; elf32 *header = (elf32 *) src;
if (header->e_ident[EI_MAG0] == ELFMAG0 && header->e_ident[EI_MAG1] == ELFMAG1 if (header->e_ident[EI_MAG0] == ELFMAG0
&& header->e_ident[EI_MAG2] == ELFMAG2 && header->e_ident[EI_MAG3] == ELFMAG3) && header->e_ident[EI_MAG1] == ELFMAG1
{ && header->e_ident[EI_MAG2] == ELFMAG2
if (header->e_ident[EI_CLASS]!=ELFCLASS32) && header->e_ident[EI_MAG3] == ELFMAG3)
return 2; {
if (header->e_ident[EI_DATA]!=ELFDATA2LSB) if (header->e_ident[EI_CLASS] != ELFCLASS32)
return 3; return 2;
if (header->e_ident[EI_VERSION]!=EV_CURRENT || header->e_version!=EV_CURRENT) if (header->e_ident[EI_DATA] != ELFDATA2LSB)
return 4; return 3;
if (header->e_ident[EI_OSABI]!=ELFOSABI_COS2000) if (header->e_ident[EI_VERSION] != EV_CURRENT
return 5; || header->e_version != EV_CURRENT)
if (header->e_machine!=EM_386) return 4;
return 6; if (header->e_ident[EI_OSABI] != ELFOSABI_COS2000)
return 0; return 5;
} if (header->e_machine != EM_386)
return 6;
return 0;
}
else else
return 1; return 1;
} }
@ -55,62 +60,75 @@ u32 elf_test(u8 *src)
/*******************************************************************************/ /*******************************************************************************/
/* Charge le fichier ELF en mémoire et mets à jour les informations sur le processus */ /* Charge le fichier ELF en mémoire et mets à jour les informations sur le processus */
u32 elf_load(u8 *src, u32 pid) u32 elf_load(u8 * src, u32 pid)
{ {
u8 *ptr; u8 *ptr;
u8 code; u8 code;
u32 v_begin, v_end; u32 v_begin, v_end;
elf32 *header; elf32 *header;
elf32p *program; elf32p *program;
u32 i; u32 i;
header = (elf32 *) src; header = (elf32 *) src;
program = (elf32p *) (src + header->e_phoff); program = (elf32p *) (src + header->e_phoff);
code=elf_test(src); code = elf_test(src);
if (code!=0) { if (code != 0)
printf("Erreur de chargement ELF, %s !\r\n",elf_errors[code-1]); {
printf("Erreur de chargement ELF, %s !\r\n",
elf_errors[code - 1]);
return NULL; return NULL;
} }
for (i = 0; i < header->e_phnum; i++, program++) { for (i = 0; i < header->e_phnum; i++, program++)
if (program->p_type == PT_LOAD) { {
if (program->p_type == PT_LOAD)
{
v_begin = program->p_vaddr; v_begin = program->p_vaddr;
v_end = program->p_vaddr + program->p_memsz; v_end = program->p_vaddr + program->p_memsz;
if (v_begin < USER_CODE) { if (v_begin < USER_CODE)
printf ("Ne peut charger l'executable en desssous de l'adresse %X\r\n", USER_CODE); {
printf("Ne peut charger l'executable en desssous de l'adresse %X\r\n", USER_CODE);
return 0; return 0;
} }
if (v_end > USER_STACK) { if (v_end > USER_STACK)
printf ("Ne peut charger l'executable au desssus de l'adresse %X\r\n", USER_STACK); {
printf("Ne peut charger l'executable au desssus de l'adresse %X\r\n", USER_STACK);
return 0; return 0;
} }
if (program->p_flags == PF_X + PF_R) { if (program->p_flags == PF_X + PF_R)
processes[pid].exec_low = (u8*) v_begin; {
processes[pid].exec_high = (u8*) v_end; processes[pid].exec_low = (u8 *) v_begin;
processes[pid].exec_high = (u8 *) v_end;
} }
if (program->p_flags == PF_W + PF_R) { if (program->p_flags == PF_W + PF_R)
processes[pid].bss_low = (u8*) v_begin; {
processes[pid].bss_high = (u8*) v_end; processes[pid].bss_low = (u8 *) v_begin;
processes[pid].bss_high = (u8 *) v_end;
} }
memcpy((u8 *) (src + program->p_offset),(u8 *) v_begin , program->p_filesz,0); memcpy((u8 *) (src + program->p_offset),
(u8 *) v_begin, program->p_filesz, 0);
if (program->p_memsz > program->p_filesz) if (program->p_memsz > program->p_filesz)
for (i = program->p_filesz, ptr = (u8 *) program->p_vaddr; i < program->p_memsz; i++) for (i = program->p_filesz, ptr =
(u8 *) program->p_vaddr;
i < program->p_memsz; i++)
ptr[i] = 0; ptr[i] = 0;
} }
} }
processes[pid].entry=header->e_entry; processes[pid].entry = header->e_entry;
return header->e_entry; return header->e_entry;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Initialise la liste des processus */ /* Initialise la liste des processus */
void task_init() { void task_init()
u32 i=0; {
processes=(process*)vmalloc(sizeof(process)*MAXNUMPROCESS); u32 i = 0;
while (i++ < MAXNUMPROCESS) { processes = (process *) vmalloc(sizeof(process) * MAXNUMPROCESS);
processes[i].pid=NULL; while (i++ < MAXNUMPROCESS)
processes[i].status=STATUS_FREE; {
} processes[i].pid = NULL;
processes[i].status = STATUS_FREE;
}
processes[0].dump.ss = SEL_KERNEL_STACK; processes[0].dump.ss = SEL_KERNEL_STACK;
processes[0].dump.esp = KERNEL_STACK_ADDR; processes[0].dump.esp = KERNEL_STACK_ADDR;
processes[0].dump.eflags = 0x0; processes[0].dump.eflags = 0x0;
@ -131,26 +149,28 @@ void task_init() {
processes[0].result = 0; processes[0].result = 0;
processes[0].status = STATUS_READY; processes[0].status = STATUS_READY;
processes[0].kernel = true; processes[0].kernel = true;
current=&processes[0]; current = &processes[0];
lastpid=NULL; lastpid = NULL;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Récupère un emplacement dans la liste des processus */ /* Récupère un emplacement dans la liste des processus */
u32 task_getfreePID () u32 task_getfreePID()
{ {
u32 i = lastpid; u32 i = lastpid;
u32 parsed = 0; u32 parsed = 0;
while (processes[++i].status != STATUS_FREE && ++parsed < MAXNUMPROCESS) while (processes[++i].status != STATUS_FREE
{ && ++parsed < MAXNUMPROCESS)
if (i>=MAXNUMPROCESS) {
i=0; if (i >= MAXNUMPROCESS)
} i = 0;
if (parsed>MAXNUMPROCESS) { }
if (parsed > MAXNUMPROCESS)
{
printf("PANIC: plus d'emplacement disponible pour un novueau processus\n"); printf("PANIC: plus d'emplacement disponible pour un novueau processus\n");
return NULL; return NULL;
} }
return i; return i;
} }
@ -159,15 +179,15 @@ u32 task_getfreePID ()
process *getcurrentprocess() process *getcurrentprocess()
{ {
return current; return current;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Determine le dernier PID occupé */ /* Determine le dernier PID occupé */
u32 task_usePID (u32 pid) u32 task_usePID(u32 pid)
{ {
lastpid=pid; lastpid = pid;
} }
/*******************************************************************************/ /*******************************************************************************/
@ -175,47 +195,48 @@ u32 task_usePID (u32 pid)
void task_switch(u32 pid, bool fromkernelmode) void task_switch(u32 pid, bool fromkernelmode)
{ {
process *previous=current; process *previous = current;
current = &processes[pid]; current = &processes[pid];
if (!current->kernel) if (!current->kernel)
setTSS(current->kstack.ss0,current->kstack.esp0); setTSS(current->kstack.ss0, current->kstack.esp0);
else else
setTSS(0x0,0x0); setTSS(0x0, 0x0);
current->dump.eflags = (current->dump.eflags | 0x200) & 0xFFFFBFFF; current->dump.eflags = (current->dump.eflags | 0x200) & 0xFFFFBFFF;
createdump(current->dump); createdump(current->dump);
restdebugcpu(); restdebugcpu();
iret(); iret();
} }
/*******************************************************************************/ /*******************************************************************************/
/* Execute une tâche */ /* Execute une tâche */
void task_run(u32 pid) void task_run(u32 pid)
{ {
processes[pid].status = STATUS_RUN; processes[pid].status = STATUS_RUN;
task_switch(pid, false); task_switch(pid, false);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Initialise une tâche */ /* Initialise une tâche */
u32 task_create(u8 *code,bool kerneltask) u32 task_create(u8 * code, bool kerneltask)
{ {
process *previous=current; process *previous = current;
u32 pid=task_getfreePID(); u32 pid = task_getfreePID();
task_usePID(pid); task_usePID(pid);
page *kstack; page *kstack;
processes[pid].pid = pid; processes[pid].pid = pid;
processes[pid].pdd = virtual_pd_create(); processes[pid].pdd = virtual_pd_create();
TAILQ_INIT(&processes[pid].page_head); TAILQ_INIT(&processes[pid].page_head);
if (kerneltask) if (kerneltask)
{ {
processes[pid].dump.ss = SEL_KERNEL_STACK; processes[pid].dump.ss = SEL_KERNEL_STACK;
processes[pid].dump.esp = (u32) kstack->vaddr + PAGESIZE - 16; processes[pid].dump.esp =
(u32) kstack->vaddr + PAGESIZE - 16;
processes[pid].dump.eflags = 0x0; processes[pid].dump.eflags = 0x0;
processes[pid].dump.cs = SEL_KERNEL_CODE; processes[pid].dump.cs = SEL_KERNEL_CODE;
processes[pid].dump.eip = elf_load(code,pid); processes[pid].dump.eip = elf_load(code, pid);
if (processes[pid].dump.eip==NULL) if (processes[pid].dump.eip == NULL)
return NULL; return NULL;
processes[pid].dump.ds = SEL_KERNEL_DATA; processes[pid].dump.ds = SEL_KERNEL_DATA;
processes[pid].dump.es = SEL_KERNEL_DATA; processes[pid].dump.es = SEL_KERNEL_DATA;
@ -240,19 +261,21 @@ u32 task_create(u8 *code,bool kerneltask)
setcr3(processes[pid].pdd->addr->paddr); setcr3(processes[pid].pdd->addr->paddr);
kstack = virtual_page_getfree(); kstack = virtual_page_getfree();
processes[pid].dump.ss = SEL_USER_STACK | RPL_RING3; processes[pid].dump.ss = SEL_USER_STACK | RPL_RING3;
processes[pid].dump.esp = USER_STACK-16; processes[pid].dump.esp = USER_STACK - 16;
processes[pid].dump.eflags = 0x0; processes[pid].dump.eflags = 0x0;
processes[pid].dump.cs = SEL_USER_CODE | RPL_RING3; processes[pid].dump.cs = SEL_USER_CODE | RPL_RING3;
processes[pid].dump.eip = elf_load(code,pid); processes[pid].dump.eip = elf_load(code, pid);
if (processes[pid].dump.eip==NULL) if (processes[pid].dump.eip == NULL)
return NULL; return NULL;
processes[pid].dump.ds = SEL_USER_DATA | RPL_RING3; processes[pid].dump.ds = SEL_USER_DATA | RPL_RING3;
processes[pid].dump.es = SEL_USER_DATA | RPL_RING3; processes[pid].dump.es = SEL_USER_DATA | RPL_RING3;
processes[pid].dump.fs = SEL_USER_DATA | RPL_RING3; processes[pid].dump.fs = SEL_USER_DATA | RPL_RING3;
processes[pid].dump.gs = SEL_USER_DATA | RPL_RING3; processes[pid].dump.gs = SEL_USER_DATA | RPL_RING3;
processes[pid].dump.cr3 = (u32) processes[pid].pdd->addr->paddr; processes[pid].dump.cr3 =
(u32) processes[pid].pdd->addr->paddr;
processes[pid].kstack.ss0 = SEL_KERNEL_STACK; processes[pid].kstack.ss0 = SEL_KERNEL_STACK;
processes[pid].kstack.esp0 = (u32) kstack->vaddr + PAGESIZE - 16; processes[pid].kstack.esp0 =
(u32) kstack->vaddr + PAGESIZE - 16;
processes[pid].dump.eax = 0; processes[pid].dump.eax = 0;
processes[pid].dump.ecx = 0; processes[pid].dump.ecx = 0;
processes[pid].dump.edx = 0; processes[pid].dump.edx = 0;
@ -266,5 +289,5 @@ u32 task_create(u8 *code,bool kerneltask)
current = previous; current = previous;
setcr3(current->dump.cr3); setcr3(current->dump.cr3);
} }
return pid; return pid;
} }

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,8 @@
s8 strcmp(const u8 * src, const u8 * dest) s8 strcmp(const u8 * src, const u8 * dest)
{ {
register s8 result; register s8 result;
do { do
{
if ((result = *src - *dest++) != 0) if ((result = *src - *dest++) != 0)
break; break;
} }
@ -20,7 +21,7 @@ s8 strcmp(const u8 * src, const u8 * dest)
/******************************************************************************/ /******************************************************************************/
/* Trouve la premiere occurence d'un caractère dans une chaine et renvoie un pointeur */ /* Trouve la premiere occurence d'un caractère dans une chaine et renvoie un pointeur */
u8 *strchr(const u8 * src, u8 achar) u8 *strchr(const u8 * src, u8 achar)
{ {
for (; *src != achar; ++src) for (; *src != achar; ++src)
if (*src == 0) if (*src == 0)
@ -33,7 +34,7 @@ u8 *strchr(const u8 * src, u8 achar)
u32 strchrpos(const u8 * src, u8 achar) u32 strchrpos(const u8 * src, u8 achar)
{ {
u32 i; u32 i;
for (i = 0; *(src + i) != achar; ++i) for (i = 0; *(src + i) != achar; ++i)
if (*(src + i) == 0) if (*(src + i) == 0)
return 0; return 0;
@ -45,28 +46,29 @@ u32 strchrpos(const u8 * src, u8 achar)
u32 strlen(const u8 * src) u32 strlen(const u8 * src)
{ {
u32 size; u32 size;
for (size = 0; *(src + size) != 0; size++) ; for (size = 0; *(src + size) != 0; size++);
return size; return size;
} }
/******************************************************************************/ /******************************************************************************/
/* copie une chaine dans une autre */ /* copie une chaine dans une autre */
u8 *strcpy(const u8 * src, u8 * dest) u8 *strcpy(const u8 * src, u8 * dest)
{ {
u8 *temp = dest; u8 *temp = dest;
while ((*dest++ = *src++) != 0) ; while ((*dest++ = *src++) != 0);
return temp; return temp;
} }
/******************************************************************************/ /******************************************************************************/
/* copie une portion limité d'une chaine asciiZ*/ /* copie une portion limité d'une chaine asciiZ*/
u8 *strncpy(const u8 * src, u8 * dest, u32 count) u8 *strncpy(const u8 * src, u8 * dest, u32 count)
{ {
u8 *temp = dest; u8 *temp = dest;
while (count) { while (count)
{
if ((*temp = *src) != 0) if ((*temp = *src) != 0)
src++; src++;
temp++; temp++;
@ -78,12 +80,12 @@ u8 *strncpy(const u8 * src, u8 * dest, u32 count)
/******************************************************************************/ /******************************************************************************/
/* concatene 2 chaines de caractère */ /* concatene 2 chaines de caractère */
u8 *strcat(const u8 * src, u8 * dest) u8 *strcat(const u8 * src, u8 * dest)
{ {
u8 *temp = dest; u8 *temp = dest;
while (*dest != 0) while (*dest != 0)
dest++; dest++;
while ((*dest++ = *src++) != 0) ; while ((*dest++ = *src++) != 0);
return temp; return temp;
} }
@ -92,7 +94,8 @@ u8 *strcat(const u8 * src, u8 * dest)
void strtolower(u8 * src) void strtolower(u8 * src)
{ {
while (*src != 0) { while (*src != 0)
{
if ((*src >= 'A') && (*src <= 'Z')) if ((*src >= 'A') && (*src <= 'Z'))
*src = *src + 'a' - 'A'; *src = *src + 'a' - 'A';
src++; src++;
@ -104,7 +107,8 @@ void strtolower(u8 * src)
void strtoupper(u8 * src) void strtoupper(u8 * src)
{ {
while (*src != 0) { while (*src != 0)
{
if ((*src >= 'a') && (*src <= 'z')) if ((*src >= 'a') && (*src <= 'z'))
*src = *src - ('a' - 'A'); *src = *src - ('a' - 'A');
src++; src++;
@ -116,7 +120,8 @@ void strtoupper(u8 * src)
void strinvertcase(u8 * src) void strinvertcase(u8 * src)
{ {
while (*src != 0) { while (*src != 0)
{
if ((*src >= 'A') && (*src <= 'Z')) if ((*src >= 'A') && (*src <= 'Z'))
*src = *src + 'a' - 'A'; *src = *src + 'a' - 'A';
else if ((*src >= 'a') && (*src <= 'z')) else if ((*src >= 'a') && (*src <= 'z'))
@ -132,7 +137,8 @@ void stronecase(u8 * src)
{ {
if ((*src >= 'a') && (*src <= 'z')) if ((*src >= 'a') && (*src <= 'z'))
*src = *src - ('a' - 'A'); *src = *src - ('a' - 'A');
while (*src != 0) { while (*src != 0)
{
src++; src++;
if ((*src >= 'A') && (*src <= 'Z')) if ((*src >= 'A') && (*src <= 'Z'))
*src = *src + 'a' - 'A'; *src = *src + 'a' - 'A';
@ -152,10 +158,11 @@ void strsetlen(u8 * src, u32 size)
void strinvert(u8 * src) void strinvert(u8 * src)
{ {
u8 *dst = src + strlen(src) - 1; u8 *dst = src + strlen(src) - 1;
while (src < dst) { while (src < dst)
u8 char1 = *dst; {
u8 char2 = *src; u8 char1 = *dst;
u8 char2 = *src;
*dst = char2; *dst = char2;
*src = char1; *src = char1;
src++; src++;
@ -168,8 +175,9 @@ void strinvert(u8 * src)
void strreplace(u8 * src, u8 search, u8 replaced) void strreplace(u8 * src, u8 search, u8 replaced)
{ {
u8 *pos = strchr(src, search); u8 *pos = strchr(src, search);
while (pos != 0) { while (pos != 0)
{
*pos = replaced; *pos = replaced;
pos = strchr(src, search); pos = strchr(src, search);
} }
@ -178,9 +186,9 @@ void strreplace(u8 * src, u8 search, u8 replaced)
/******************************************************************************/ /******************************************************************************/
/* Rempli de caractère */ /* Rempli de caractère */
u8 *strfill(u8 * dst, u8 pattern, u32 size) u8 *strfill(u8 * dst, u8 pattern, u32 size)
{ {
u32 i; u32 i;
for (i = 0; i <= size; i++) for (i = 0; i <= size; i++)
*(dst + i) = pattern; *(dst + i) = pattern;
*(dst + i + 1) = '\000'; *(dst + i + 1) = '\000';
@ -192,7 +200,7 @@ u8 *strfill(u8 * dst, u8 pattern, u32 size)
void strleft(u8 * src, u8 * dest, u32 size) void strleft(u8 * src, u8 * dest, u32 size)
{ {
u32 i; u32 i;
for (i = 0; (*(src + i) != 0) && (i < size); i++) for (i = 0; (*(src + i) != 0) && (i < size); i++)
*dest++ = *(src + i); *dest++ = *(src + i);
*dest++ = '\000'; *dest++ = '\000';
@ -203,8 +211,8 @@ void strleft(u8 * src, u8 * dest, u32 size)
void strright(u8 * src, u8 * dest, u32 size) void strright(u8 * src, u8 * dest, u32 size)
{ {
u32 i; u32 i;
u32 begin = strlen(src) - size; u32 begin = strlen(src) - size;
for (i = 0; (*(src + i + begin) != 0) && (i < size); i++) for (i = 0; (*(src + i + begin) != 0) && (i < size); i++)
*dest++ = *(src + i + begin); *dest++ = *(src + i + begin);
*dest++ = '\000'; *dest++ = '\000';
@ -215,9 +223,10 @@ void strright(u8 * src, u8 * dest, u32 size)
void strdelete(u8 * src, u32 index, u32 size) void strdelete(u8 * src, u32 index, u32 size)
{ {
u32 i; u32 i;
u32 realsize = strlen(src) - index - size; u32 realsize = strlen(src) - index - size;
for (i = 0; (*(src + index + size + i) != 0) && (i < realsize); i++) for (i = 0; (*(src + index + size + i) != 0) && (i < realsize);
i++)
*(src + index + i) = *(src + index + size + i); *(src + index + i) = *(src + index + size + i);
*(src + index + i) = '\000'; *(src + index + i) = '\000';
} }
@ -227,12 +236,12 @@ void strdelete(u8 * src, u32 index, u32 size)
void strinsert(u8 * src, u8 * dest, u32 index) void strinsert(u8 * src, u8 * dest, u32 index)
{ {
u32 i; u32 i;
u32 realsize = strlen(src); u32 realsize = strlen(src);
u32 copysize = strlen(dest) - index; u32 copysize = strlen(dest) - index;
for (i = 0; i <= copysize; i++) for (i = 0; i <= copysize; i++)
*(dest + index + realsize + copysize - i) = *(dest + index + realsize + copysize - i) =
*(dest + index + copysize - i); *(dest + index + copysize - i);
for (i = 0; (*(src + i) != 0); i++) for (i = 0; (*(src + i) != 0); i++)
*(dest + index + i) = *(src + i); *(dest + index + i) = *(src + i);
} }
@ -242,10 +251,12 @@ void strinsert(u8 * src, u8 * dest, u32 index)
void strcompressdelimiter(u8 * src, u8 delim) void strcompressdelimiter(u8 * src, u8 delim)
{ {
u8 *pos = strchr(src, delim); u8 *pos = strchr(src, delim);
while (pos != 0) { while (pos != 0)
u8 i; {
for (i = 0; (*(pos + i) != 0) && (*(pos + i) == delim); i++) ; u8 i;
for (i = 0; (*(pos + i) != 0) && (*(pos + i) == delim);
i++);
if (i > 1) if (i > 1)
strdelete(pos, 1, i - 1); strdelete(pos, 1, i - 1);
pos = strchr(pos + 1, delim); pos = strchr(pos + 1, delim);
@ -255,10 +266,10 @@ void strcompressdelimiter(u8 * src, u8 delim)
/******************************************************************************/ /******************************************************************************/
/* Récupérère l'élément N d'une liste utilisant un délimiteur */ /* Récupérère l'élément N d'une liste utilisant un délimiteur */
u8 *strgetitem(u8 * src, u8 * dest, u8 delim, u32 index) u8 *strgetitem(u8 * src, u8 * dest, u8 delim, u32 index)
{ {
u32 i; u32 i;
u8 *pos = strgetpointeritem(src, delim, index); u8 *pos = strgetpointeritem(src, delim, index);
for (i = 0; (*(pos + i) != 0) && (*(pos + i) != delim); i++) for (i = 0; (*(pos + i) != 0) && (*(pos + i) != delim); i++)
*(dest + i) = *(pos + i); *(dest + i) = *(pos + i);
*(dest + i) = '\000'; *(dest + i) = '\000';
@ -268,10 +279,10 @@ u8 *strgetitem(u8 * src, u8 * dest, u8 delim, u32 index)
/******************************************************************************/ /******************************************************************************/
/* Récupérère un pointeur sur l'élément N d'une liste utilisant un délimiteur */ /* Récupérère un pointeur sur l'élément N d'une liste utilisant un délimiteur */
u8 *strgetpointeritem(u8 * src, u8 delim, u32 index) u8 *strgetpointeritem(u8 * src, u8 delim, u32 index)
{ {
u32 i; u32 i;
u8 *pos = src; u8 *pos = src;
for (i = 0; i < index; i++) for (i = 0; i < index; i++)
pos = strchr(pos + 1, delim); pos = strchr(pos + 1, delim);
if (*pos == delim) if (*pos == delim)
@ -284,12 +295,13 @@ u8 *strgetpointeritem(u8 * src, u8 delim, u32 index)
u32 strgetnbitems(u8 * src, u8 delim) u32 strgetnbitems(u8 * src, u8 delim)
{ {
u32 number = 0; u32 number = 0;
if (*src == 0) if (*src == 0)
return 0; return 0;
number++; number++;
u8 *pos = strchr(src, delim); u8 *pos = strchr(src, delim);
while (pos != 0) { while (pos != 0)
{
pos = strchr(pos + 1, delim); pos = strchr(pos + 1, delim);
number++; number++;
} }
@ -299,16 +311,17 @@ u32 strgetnbitems(u8 * src, u8 delim)
/******************************************************************************/ /******************************************************************************/
/* Renvoie la base minimum du nombre */ /* Renvoie la base minimum du nombre */
u8 base[] = " 0123456789ABCDEF\000"; u8 base[] = " 0123456789ABCDEF\000";
u8 strgetminbase(u8 * src) u8 strgetminbase(u8 * src)
{ {
u8 temp[] = " \000"; u8 temp[] = " \000";
u8 *dst = &temp; u8 *dst = &temp;
strtoupper(strcpy(src, &temp)); strtoupper(strcpy(src, &temp));
u8 max = 0; u8 max = 0;
while (*dst != 0) { while (*dst != 0)
u32 result = strchrpos(&base, *dst++); {
u32 result = strchrpos(&base, *dst++);
if (result == 0) if (result == 0)
return 0; return 0;
if (result > max) if (result > max)
@ -327,29 +340,35 @@ u8 strgetminbase(u8 * src)
/******************************************************************************/ /******************************************************************************/
/* Renvoie la base du nombre */ /* Renvoie la base du nombre */
u8 hexa[] = "0x\000"; u8 hexa[] = "0x\000";
u8 bases[] = " bodh\000"; u8 bases[] = " bodh\000";
u8 basesnum[] = { 0, 2, 8, 10, 16 }; u8 basesnum[] = { 0, 2, 8, 10, 16 };
u8 declaredbase = 10; u8 declaredbase = 10;
u8 minbase = 0; u8 minbase = 0;
u8 strgetbase(u8 * src) u8 strgetbase(u8 * src)
{ {
u8 temp[] = " \000"; u8 temp[] = " \000";
strleft(src, &temp, 2); strleft(src, &temp, 2);
if (strcmp(&temp, &hexa) == 0) { if (strcmp(&temp, &hexa) == 0)
{
declaredbase = 16; declaredbase = 16;
u8 size = strlen(src); u8 size = strlen(src);
strright(src, &temp, size - 2); strright(src, &temp, size - 2);
minbase = strgetminbase(&temp); minbase = strgetminbase(&temp);
} else { }
else
{
strright(src, &temp, 1); strright(src, &temp, 1);
declaredbase = basesnum[strchrpos(&bases, temp[0])]; declaredbase = basesnum[strchrpos(&bases, temp[0])];
if (declaredbase > 0) { if (declaredbase > 0)
u8 size = strlen(src); {
u8 size = strlen(src);
strleft(src, &temp, size - 1); strleft(src, &temp, size - 1);
minbase = strgetminbase(&temp); minbase = strgetminbase(&temp);
} else { }
else
{
minbase = strgetminbase(src); minbase = strgetminbase(src);
declaredbase = minbase; declaredbase = minbase;
} }
@ -365,22 +384,23 @@ u8 strgetbase(u8 * src)
u32 strtoint(u8 * src) u32 strtoint(u8 * src)
{ {
u8 *temp = src; u8 *temp = src;
u32 result = 0; u32 result = 0;
u8 thebase = strgetbase(src); u8 thebase = strgetbase(src);
u32 multi = 1; u32 multi = 1;
u8 shorter = 0; u8 shorter = 0;
if (thebase == 0) if (thebase == 0)
return 0; return 0;
if (*(src + 1) == 'x') if (*(src + 1) == 'x')
shorter = 2; shorter = 2;
while (*++temp != 0) ; while (*++temp != 0);
while (*temp == 0 || *temp == 'b' || *temp == 'o' || *temp == 'd' while (*temp == 0 || *temp == 'b' || *temp == 'o' || *temp == 'd'
|| *temp == 'h') || *temp == 'h')
temp--; temp--;
while (src + shorter <= temp) { while (src + shorter <= temp)
u8 achar = *temp--; {
u8 achar = *temp--;
if ((achar >= 'a') && (achar <= 'z')) if ((achar >= 'a') && (achar <= 'z'))
achar = achar - ('a' - 'A'); achar = achar - ('a' - 'A');
result = result + multi * (strchrpos(&base, achar) - 1); result = result + multi * (strchrpos(&base, achar) - 1);

View File

@ -25,25 +25,25 @@
/* Entrée pour les appels système SYSENTER */ /* Entrée pour les appels système SYSENTER */
void sysenter_handler(void) void sysenter_handler(void)
{ {
cli(); cli();
regs *dump; regs *dump;
dumpcpu(); dumpcpu();
getESP(dump); getESP(dump);
sti(); sti();
switch (dump->eax) switch (dump->eax)
{ {
case 0: case 0:
printf("Test de fonctionnement syscall\r\n -arguments 1:%Y 2:%Y 3:%Y\r\n", dump->ebx,dump->esi,dump->edi); printf("Test de fonctionnement syscall\r\n -arguments 1:%Y 2:%Y 3:%Y\r\n", dump->ebx, dump->esi, dump->edi);
dump->eax=0x6666666; dump->eax = 0x6666666;
break; break;
default: default:
printf("Appel syscall vers fonction inexistante en %Y:%Y", dump->cs,dump->eip); printf("Appel syscall vers fonction inexistante en %Y:%Y", dump->cs, dump->eip);
break; break;
} }
restdebugcpu(); restdebugcpu();
sysexit(); sysexit();
} }
/*******************************************************************************/ /*******************************************************************************/
@ -54,7 +54,7 @@ void initsyscall(void)
{ {
wrmsr(0x174, SEL_KERNEL_CODE, 0x0); wrmsr(0x174, SEL_KERNEL_CODE, 0x0);
wrmsr(0x175, 0x60000, 0x0); wrmsr(0x175, 0x60000, 0x0);
wrmsr(0x176, &sysenter_handler+6, 0x0); wrmsr(0x176, &sysenter_handler + 6, 0x0);
} }
/*******************************************************************************/ /*******************************************************************************/

View File

@ -3,7 +3,7 @@
/* */ /* */
#include <types.h> #include <types.h>
char ctype[] = { char ctype[] = {
0x00, 0x00,
/* 0 */ CT_CTL, CT_CTL, CT_CTL, CT_CTL, /* 0 */ CT_CTL, CT_CTL, CT_CTL, CT_CTL,
CT_CTL, CT_CTL, CT_CTL, CT_CTL, CT_CTL, CT_CTL, CT_CTL, CT_CTL,
@ -29,7 +29,8 @@ char ctype[] = {
CT_UP, CT_UP, CT_UP, CT_UP, CT_UP, CT_UP, CT_UP, CT_UP,
/* 'X' */ CT_UP, CT_UP, CT_UP, CT_PUN, /* 'X' */ CT_UP, CT_UP, CT_UP, CT_PUN,
CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN,
/* '`' */ CT_PUN, CT_LOW | CT_HEX, CT_LOW | CT_HEX, CT_LOW | CT_HEX, /* '`' */ CT_PUN, CT_LOW | CT_HEX, CT_LOW | CT_HEX,
CT_LOW | CT_HEX,
CT_LOW | CT_HEX, CT_LOW | CT_HEX, CT_LOW | CT_HEX, CT_LOW, CT_LOW | CT_HEX, CT_LOW | CT_HEX, CT_LOW | CT_HEX, CT_LOW,
/* h' */ CT_LOW, CT_LOW, CT_LOW, CT_LOW, /* h' */ CT_LOW, CT_LOW, CT_LOW, CT_LOW,
CT_LOW, CT_LOW, CT_LOW, CT_LOW, CT_LOW, CT_LOW, CT_LOW, CT_LOW,

View File

@ -11,44 +11,50 @@
static videoinfos infos; static videoinfos infos;
static capabilities vesacapabilities[] = { static capabilities vesacapabilities[] = {
{0xFF,000,000,false, 0, 0}, {0xFF, 000, 000, false, 0, 0},
}; };
/*******************************************************************************/ /*******************************************************************************/
/* Deplace l'adresse virtuelle en mode paginee */ /* Deplace l'adresse virtuelle en mode paginee */
void VESA_remap_memory(u32 vaddr) { void VESA_remap_memory(u32 vaddr)
struct multiboot_tag_framebuffer *tagfb = getgrubinfo_fb(); {
u32 len=infos.pagesize*2; struct multiboot_tag_framebuffer *tagfb = getgrubinfo_fb();
u32 paddr=tagfb->common.framebuffer_addr; u32 len = infos.pagesize * 2;
virtual_range_use_kernel(vaddr, paddr, len, PAGE_NOFLAG); u32 paddr = tagfb->common.framebuffer_addr;
infos.baseaddress=vaddr; virtual_range_use_kernel(vaddr, paddr, len, PAGE_NOFLAG);
infos.baseaddress = vaddr;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Detecte si le hardware est disponible, return NULL ou pointeur sur le type de pilote */ /* Detecte si le hardware est disponible, return NULL ou pointeur sur le type de pilote */
u8 *VESA_detect_hardware(void) { u8 *VESA_detect_hardware(void)
struct multiboot_tag_framebuffer *tagfb = getgrubinfo_fb(); {
switch (tagfb->common.framebuffer_type) struct multiboot_tag_framebuffer *tagfb = getgrubinfo_fb();
{ switch (tagfb->common.framebuffer_type)
case MULTIBOOT_FRAMEBUFFER_TYPE_RGB: {
vesacapabilities[0].modenumber=0x0; case MULTIBOOT_FRAMEBUFFER_TYPE_RGB:
vesacapabilities[0].width=tagfb->common.framebuffer_width; vesacapabilities[0].modenumber = 0x0;
vesacapabilities[0].height=tagfb->common.framebuffer_height; vesacapabilities[0].width =
vesacapabilities[0].graphic=true; tagfb->common.framebuffer_width;
vesacapabilities[0].depth=tagfb->common.framebuffer_bpp; vesacapabilities[0].height =
vesacapabilities[0].refresh=0x0; tagfb->common.framebuffer_height;
infos.baseaddress=tagfb->common.framebuffer_addr; vesacapabilities[0].graphic = true;
infos.currentpitch=tagfb->common.framebuffer_pitch; vesacapabilities[0].depth =
return "LEGACY"; tagfb->common.framebuffer_bpp;
break; vesacapabilities[0].refresh = 0x0;
default: infos.baseaddress = tagfb->common.framebuffer_addr;
case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED: infos.currentpitch =
case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT: tagfb->common.framebuffer_pitch;
return NULL; return "LEGACY";
break; break;
} default:
case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED:
case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT:
return NULL;
break;
}
} }
/*******************************************************************************/ /*******************************************************************************/
@ -60,81 +66,94 @@ static u8 realsize;
u8 VESA_setvideo_mode(u8 mode) u8 VESA_setvideo_mode(u8 mode)
{ {
if (mode>0) return 1; if (mode > 0)
infos.currentmode=mode; return 1;
infos.currentwidth=vesacapabilities[0].width; infos.currentmode = mode;
infos.currentheight=vesacapabilities[0].height; infos.currentwidth = vesacapabilities[0].width;
infos.currentdepth=vesacapabilities[0].depth; infos.currentheight = vesacapabilities[0].height;
infos.currentactivepage=0; infos.currentdepth = vesacapabilities[0].depth;
infos.currentshowedpage=0; infos.currentactivepage = 0;
infos.currentcursorX=0; infos.currentshowedpage = 0;
infos.currentcursorY=0; infos.currentcursorX = 0;
infos.currentfont1=0; infos.currentcursorY = 0;
infos.currentfont2=0; infos.currentfont1 = 0;
infos.isgraphic=vesacapabilities[0].graphic; infos.currentfont2 = 0;
infos.isblinking=false; infos.isgraphic = vesacapabilities[0].graphic;
infos.iscursorvisible=false; infos.isblinking = false;
infos.pagesnumber=1; infos.iscursorvisible = false;
infos.pagesize=infos.currentheight*infos.currentpitch; infos.pagesnumber = 1;
return; infos.pagesize = infos.currentheight * infos.currentpitch;
return;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Renvoie le nom du driver */ /* Renvoie le nom du driver */
u8 *VESA_getvideo_drivername (void) { u8 *VESA_getvideo_drivername(void)
return "VESA"; {
return "VESA";
} }
/*******************************************************************************/ /*******************************************************************************/
/* Renvoie un pointeur sur la structure des capacités graphiques */ /* Renvoie un pointeur sur la structure des capacités graphiques */
u8 *VESA_getvideo_capabilities (void) { u8 *VESA_getvideo_capabilities(void)
return vesacapabilities; {
return vesacapabilities;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Renvoie un pointeur sur l'état courant de la carte */ /* Renvoie un pointeur sur l'état courant de la carte */
videoinfos *VESA_getvideo_info (void) { videoinfos *VESA_getvideo_info(void)
return &infos; {
return &infos;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Effecture un mouvement de la mémoire centrale vers la mémoire video (linéarisée) */ /* Effecture un mouvement de la mémoire centrale vers la mémoire video (linéarisée) */
u32 VESA_mem_to_video (void *src,u32 dst, u32 size, bool increment_src) { u32 VESA_mem_to_video(void *src, u32 dst, u32 size, bool increment_src)
u32 realdst=infos.baseaddress + infos.currentactivepage * infos.pagesize+dst; {
switch (infos.currentdepth) { u32 realdst =
case 32: infos.baseaddress +
if (!increment_src) infos.currentactivepage * infos.pagesize + dst;
{ switch (infos.currentdepth)
stosd(src,realdst,size); {
} case 32:
else if (!increment_src)
{ {
stosd(src, realdst, size);
}
else
{
} }
break; break;
} }
} }
/*******************************************************************************/ /*******************************************************************************/
/* Effecture un mouvement de la mémoire video (linéarisée) vers la mémoire centrale*/ /* Effecture un mouvement de la mémoire video (linéarisée) vers la mémoire centrale*/
u32 VESA_video_to_mem (u32 src,void *dst, u32 size) u32 VESA_video_to_mem(u32 src, void *dst, u32 size)
{ {
} }
/*******************************************************************************/ /*******************************************************************************/
/* Effecture un mouvement de la mémoire video (linéarisé) vers la mémoire vidéo (linéarisée) */ /* Effecture un mouvement de la mémoire video (linéarisé) vers la mémoire vidéo (linéarisée) */
u32 VESA_video_to_video (u32 src,u32 dst, u32 size) u32 VESA_video_to_video(u32 src, u32 dst, u32 size)
{ {
u32 realsrc=infos.baseaddress + infos.currentactivepage * infos.pagesize+src; u32 realsrc =
u32 realdst=infos.baseaddress + infos.currentactivepage * infos.pagesize+dst; infos.baseaddress +
switch (infos.currentdepth) { infos.currentactivepage * infos.pagesize + src;
case 32: u32 realdst =
movsd(realsrc,realdst,size>>2); infos.baseaddress +
break; infos.currentactivepage * infos.pagesize + dst;
} switch (infos.currentdepth)
{
case 32:
movsd(realsrc, realdst, size >> 2);
break;
}
} }
/*******************************************************************************/ /*******************************************************************************/
@ -142,7 +161,7 @@ u32 VESA_video_to_video (u32 src,u32 dst, u32 size)
void VESA_page_set(u8 page) void VESA_page_set(u8 page)
{ {
return; return;
} }
/*******************************************************************************/ /*******************************************************************************/
@ -150,7 +169,7 @@ void VESA_page_set(u8 page)
void VESA_page_show(u8 page) void VESA_page_show(u8 page)
{ {
return; return;
} }
/*******************************************************************************/ /*******************************************************************************/
@ -158,7 +177,7 @@ void VESA_page_show(u8 page)
void VESA_dummy(void) void VESA_dummy(void)
{ {
return; return;
} }
/*******************************************************************************/ /*******************************************************************************/
@ -166,7 +185,7 @@ void VESA_dummy(void)
void VESA_wait_vretrace(void) void VESA_wait_vretrace(void)
{ {
while ((inb(STATE) & 8) == 0) ; while ((inb(STATE) & 8) == 0);
} }
/*******************************************************************************/ /*******************************************************************************/
@ -174,6 +193,5 @@ void VESA_wait_vretrace(void)
void VESA_wait_hretrace(void) void VESA_wait_hretrace(void)
{ {
while ((inb(STATE) & 1) == 0) ; while ((inb(STATE) & 1) == 0);
} }

672
lib/vga.c
View File

@ -13,14 +13,17 @@ static videoinfos infos;
/*******************************************************************************/ /*******************************************************************************/
/* Deplace l'adresse virtuelle en mode paginee */ /* Deplace l'adresse virtuelle en mode paginee */
void VGA_remap_memory(u32 vaddr) { void VGA_remap_memory(u32 vaddr)
virtual_range_use_kernel(vaddr, GRPHSCREEN, ENDOFVMEM-GRPHSCREEN, PAGE_NOFLAG); {
virtual_range_use_kernel(vaddr, GRPHSCREEN, ENDOFVMEM - GRPHSCREEN,
PAGE_NOFLAG);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Detecte si le hardware est disponible, return NULL ou pointeur sur le type de pilote */ /* Detecte si le hardware est disponible, return NULL ou pointeur sur le type de pilote */
u8 *VGA_detect_hardware(void) { u8 *VGA_detect_hardware(void)
return "LEGACY"; {
return "LEGACY";
} }
/*******************************************************************************/ /*******************************************************************************/
@ -28,22 +31,23 @@ u8 *VGA_detect_hardware(void) {
u32 getbase(void) u32 getbase(void)
{ {
u32 base; u32 base;
outb(GRAPHICS, 6); outb(GRAPHICS, 6);
base = inb(GRAPHICS + 1); base = inb(GRAPHICS + 1);
base >>= 2; base >>= 2;
base &= 3; base &= 3;
switch (base) { switch (base)
case 0: {
case 1: case 0:
base = 0xA0000; case 1:
break; base = 0xA0000;
case 2: break;
base = 0xB0000; case 2:
break; base = 0xB0000;
case 3: break;
base = 0xB8000; case 3:
break; base = 0xB8000;
break;
} }
return base; return base;
} }
@ -57,69 +61,84 @@ static u8 realsize;
u8 VGA_setvideo_mode(u8 mode) u8 VGA_setvideo_mode(u8 mode)
{ {
u32 index=0; u32 index = 0;
while(vgacapabilities[index].modenumber!=0xFF) { while (vgacapabilities[index].modenumber != 0xFF)
if (vgacapabilities[index].modenumber==mode) { {
infos.currentmode=vgacapabilities[index].modenumber; if (vgacapabilities[index].modenumber == mode)
break; {
} infos.currentmode =
index++; vgacapabilities[index].modenumber;
} break;
if (infos.currentmode!=mode) }
return 1; index++;
infos.currentwidth=vgacapabilities[index].width; }
infos.currentheight=vgacapabilities[index].height; if (infos.currentmode != mode)
infos.currentdepth=vgacapabilities[index].depth; return 1;
infos.currentactivepage=0; infos.currentwidth = vgacapabilities[index].width;
infos.currentshowedpage=0; infos.currentheight = vgacapabilities[index].height;
infos.currentcursorX=0; infos.currentdepth = vgacapabilities[index].depth;
infos.currentcursorY=0; infos.currentactivepage = 0;
infos.currentfont1=0; infos.currentshowedpage = 0;
infos.currentfont2=0; infos.currentcursorX = 0;
infos.isgraphic=vgacapabilities[index].graphic; infos.currentcursorY = 0;
infos.isblinking=false; infos.currentfont1 = 0;
infos.iscursorvisible=false; infos.currentfont2 = 0;
if (infos.isgraphic) { infos.isgraphic = vgacapabilities[index].graphic;
switch (infos.currentdepth) { infos.isblinking = false;
case 1: infos.iscursorvisible = false;
/* mode N&B */ if (infos.isgraphic)
infos.currentpitch = infos.currentwidth; {
realsize=1; switch (infos.currentdepth)
break; {
case 2: case 1:
/* mode 4 couleurs */ /* mode N&B */
infos.currentpitch = (infos.currentwidth << 1); infos.currentpitch = infos.currentwidth;
realsize=2; realsize = 1;
break; break;
case 4: case 2:
/* mode 16 couleurs */ /* mode 4 couleurs */
infos.currentpitch = infos.currentwidth; infos.currentpitch =
realsize=4; (infos.currentwidth << 1);
break; realsize = 2;
case 8: break;
/* mode 256 couleurs */ case 4:
if (modes[index].sequencer.Sequencer_Memory_Mode_Register == 0x0E) { /* mode 16 couleurs */
/* mode chainé (plus rapide mais limité en mémoire) */ infos.currentpitch = infos.currentwidth;
infos.currentpitch = infos.currentwidth; realsize = 4;
realsize=8; break;
} else { case 8:
/* mode non chainé */ /* mode 256 couleurs */
infos.currentpitch = infos.currentwidth >> 2; if (modes[index].sequencer.
realsize=9; Sequencer_Memory_Mode_Register == 0x0E)
} {
break; /* mode chainé (plus rapide mais limité en mémoire) */
default: infos.currentpitch =
break; infos.currentwidth;
} realsize = 8;
}
else
{
/* mode non chainé */
infos.currentpitch =
infos.currentwidth >> 2;
realsize = 9;
}
break;
default:
break;
}
infos.pagesize = infos.currentheight * infos.currentpitch; infos.pagesize = infos.currentheight * infos.currentpitch;
} }
else { else
infos.currentpitch= infos.currentwidth * 2; {
infos.pagesize=infos.currentheight * infos.currentpitch; infos.currentpitch = infos.currentwidth * 2;
realsize=0; infos.pagesize = infos.currentheight * infos.currentpitch;
} realsize = 0;
infos.pagesnumber=(PLANESIZE / infos.pagesize); }
infos.baseaddress=(modes[index].ctrc.Cursor_Location_High_Register << 8) + modes[index].ctrc.Cursor_Location_Low_Register + getbase(); infos.pagesnumber = (PLANESIZE / infos.pagesize);
infos.baseaddress =
(modes[index].ctrc.Cursor_Location_High_Register << 8) +
modes[index].ctrc.Cursor_Location_Low_Register + getbase();
/* Initialise les registre "divers" */ /* Initialise les registre "divers" */
outb(MISC_WRITE, modes[index].misc); outb(MISC_WRITE, modes[index].misc);
/* Initialise les registre d'etat */ /* Initialise les registre d'etat */
@ -145,161 +164,176 @@ u8 VGA_setvideo_mode(u8 mode)
/*******************************************************************************/ /*******************************************************************************/
/* Renvoie le nom du driver */ /* Renvoie le nom du driver */
u8 *VGA_getvideo_drivername (void) { u8 *VGA_getvideo_drivername(void)
return "VGA"; {
return "VGA";
} }
/*******************************************************************************/ /*******************************************************************************/
/* Renvoie un pointeur sur la structure des capacités graphiques */ /* Renvoie un pointeur sur la structure des capacités graphiques */
u8 *VGA_getvideo_capabilities (void) { u8 *VGA_getvideo_capabilities(void)
return vgacapabilities; {
return vgacapabilities;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Renvoie un pointeur sur l'état courant de la carte */ /* Renvoie un pointeur sur l'état courant de la carte */
videoinfos *VGA_getvideo_info (void) { videoinfos *VGA_getvideo_info(void)
return &infos; {
return &infos;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Effecture un mouvement de la mémoire centrale vers la mémoire video (linéarisée) */ /* Effecture un mouvement de la mémoire centrale vers la mémoire video (linéarisée) */
u32 VGA_mem_to_video (void *src,u32 dst, u32 size, bool increment_src) { u32 VGA_mem_to_video(void *src, u32 dst, u32 size, bool increment_src)
u32 realdst=infos.baseaddress + infos.currentactivepage * infos.pagesize+dst; {
switch (realsize) u32 realdst =
{ infos.baseaddress +
case 0: infos.currentactivepage * infos.pagesize + dst;
if (!increment_src) switch (realsize)
{ {
u8 tmp=(u8) src; case 0:
memset(realdst,tmp,size,2); if (!increment_src)
} {
else u8 tmp = (u8) src;
{ memset(realdst, tmp, size, 2);
memcpy(src,realdst,size,2); }
} else
break; {
case 1: memcpy(src, realdst, size, 2);
}
break; break;
case 2: case 1:
break; break;
case 4: case 2:
break; break;
case 8: case 4:
if (!increment_src)
{ break;
u8 tmp=(u8) (src); case 8:
if (size%4 == 0) if (!increment_src)
{ {
u32 pattern = tmp + (tmp<<8) + (tmp<<16) + (tmp<<24); u8 tmp = (u8) (src);
stosd(pattern,realdst,(size>>2)); if (size % 4 == 0)
} {
else if (size%2 == 0) u32 pattern =
{ tmp + (tmp << 8) +
u32 pattern = tmp + (tmp<<8); (tmp << 16) + (tmp << 24);
stosw(pattern,realdst,(size>>1)); stosd(pattern, realdst,
} (size >> 2));
else }
{ else if (size % 2 == 0)
u32 pattern = tmp; {
stosb(pattern,realdst,size); u32 pattern = tmp + (tmp << 8);
} stosw(pattern, realdst,
} (size >> 1));
else { }
if (size%4 == 0) else
{ {
movsd(src,realdst,size>>2); u32 pattern = tmp;
} stosb(pattern, realdst, size);
else if (size%2 == 0) }
{ }
movsw(src,realdst,size>>1); else
} {
else if (size % 4 == 0)
{ {
movsb(src,realdst,size); movsd(src, realdst, size >> 2);
} }
} else if (size % 2 == 0)
break; {
case 9: movsw(src, realdst, size >> 1);
}
break; else
{
} movsb(src, realdst, size);
}
}
break;
case 9:
break;
}
} }
/*******************************************************************************/ /*******************************************************************************/
/* Effecture un mouvement de la mémoire video (linéarisée) vers la mémoire centrale*/ /* Effecture un mouvement de la mémoire video (linéarisée) vers la mémoire centrale*/
u32 VGA_video_to_mem (u32 src,void *dst, u32 size) u32 VGA_video_to_mem(u32 src, void *dst, u32 size)
{ {
u32 realsrc=infos.baseaddress + infos.currentactivepage * infos.pagesize+src; u32 realsrc =
switch (realsize) infos.baseaddress +
{ infos.currentactivepage * infos.pagesize + src;
case 0: switch (realsize)
memcpy(realsrc,dst,size,2); {
break; case 0:
case 1: memcpy(realsrc, dst, size, 2);
break;
break; case 1:
case 2:
break;
break; case 2:
case 4:
break;
case 4:
break;
case 8:
break;
case 9:
break;
}
break;
case 8:
break;
case 9:
break;
}
} }
/*******************************************************************************/ /*******************************************************************************/
/* Effecture un mouvement de la mémoire video (linéarisé) vers la mémoire vidéo (linéarisée) */ /* Effecture un mouvement de la mémoire video (linéarisé) vers la mémoire vidéo (linéarisée) */
u32 VGA_video_to_video (u32 src,u32 dst, u32 size) u32 VGA_video_to_video(u32 src, u32 dst, u32 size)
{ {
u32 base=infos.baseaddress + infos.currentactivepage * infos.pagesize; u32 base =
u32 realsrc=base+src; infos.baseaddress +
u32 realdst=base+dst; infos.currentactivepage * infos.pagesize;
switch (realsize) u32 realsrc = base + src;
{ u32 realdst = base + dst;
case 8: switch (realsize)
case 0: {
if (size%4 == 0) case 8:
{ case 0:
movsd(realsrc,realdst,size>>2); if (size % 4 == 0)
} {
else if (size%2 == 0) movsd(realsrc, realdst, size >> 2);
{ }
movsw(realsrc,realdst,size>>1); else if (size % 2 == 0)
} {
else movsw(realsrc, realdst, size >> 1);
{ }
movsb(realsrc,realdst,size); else
} {
break; movsb(realsrc, realdst, size);
case 1: }
break;
break; case 1:
case 2:
break;
break; case 2:
case 4:
break;
break; case 4:
case 9:
break;
break; case 9:
} break;
}
} }
/*******************************************************************************/ /*******************************************************************************/
@ -316,8 +350,9 @@ void VGA_page_set(u8 page)
void VGA_page_show(u8 page) void VGA_page_show(u8 page)
{ {
if (page < infos.pagesnumber) { if (page < infos.pagesnumber)
u16 addr; {
u16 addr;
addr = page * infos.pagesize / 2; addr = page * infos.pagesize / 2;
outb(CCRT, 0x0C); outb(CCRT, 0x0C);
outb(CCRT + 1, (addr >> 8)); outb(CCRT + 1, (addr >> 8));
@ -330,46 +365,47 @@ void VGA_page_show(u8 page)
/*******************************************************************************/ /*******************************************************************************/
/* Sépare l'écran en 2 a partir de la ligne Y */ /* Sépare l'écran en 2 a partir de la ligne Y */
static splitY=0; static splitY = 0;
void VGA_page_split(u16 y) void VGA_page_split(u16 y)
{ {
if (y!=0) { if (y != 0)
u16 addr; {
if (!infos.isgraphic) u16 addr;
addr = (y << 3); if (!infos.isgraphic)
else addr = (y << 3);
addr = y; else
/* line compare pour ligne atteinte */ addr = y;
outb(CCRT, 0x18); /* line compare pour ligne atteinte */
outb(CCRT + 1, (addr & 0xFF)); outb(CCRT, 0x18);
/* overflow pour le bit 8 */ outb(CCRT + 1, (addr & 0xFF));
/* overflow pour le bit 8 */
outb(CCRT, 0x07); outb(CCRT, 0x07);
outb(CCRT + 1, (inb(CCRT + 1) & ~16) | ((addr >> 4) & 16)); outb(CCRT + 1, (inb(CCRT + 1) & ~16) | ((addr >> 4) & 16));
/* Maximum Scan Line pour le bit 9 */ /* Maximum Scan Line pour le bit 9 */
outb(CCRT, 0x09); outb(CCRT, 0x09);
outb(CCRT + 1, (inb(CCRT + 1) & ~64) | ((addr >> 3) & 64)); outb(CCRT + 1, (inb(CCRT + 1) & ~64) | ((addr >> 3) & 64));
splitY = y; splitY = y;
} }
else else
{ {
/* line compare pour ligne atteinte */ /* line compare pour ligne atteinte */
outb(CCRT, 0x18); outb(CCRT, 0x18);
outb(CCRT + 1, 0); outb(CCRT + 1, 0);
/* overflow pour le bit 8 */ /* overflow pour le bit 8 */
outb(CCRT, 0x07); outb(CCRT, 0x07);
outb(CCRT + 1, inb(CCRT + 1) & ~16); outb(CCRT + 1, inb(CCRT + 1) & ~16);
/* Maximum Scan Line pour le bit 9 */ /* Maximum Scan Line pour le bit 9 */
outb(CCRT, 0x09); outb(CCRT, 0x09);
outb(CCRT + 1, inb(CCRT + 1) & ~64); outb(CCRT + 1, inb(CCRT + 1) & ~64);
splitY = 0; splitY = 0;
} }
} }
/*******************************************************************************/ /*******************************************************************************/
@ -377,7 +413,7 @@ void VGA_page_split(u16 y)
void VGA_wait_vretrace(void) void VGA_wait_vretrace(void)
{ {
while ((inb(STATE) & 8) == 0) ; while ((inb(STATE) & 8) == 0);
} }
/*******************************************************************************/ /*******************************************************************************/
@ -385,7 +421,7 @@ void VGA_wait_vretrace(void)
void VGA_wait_hretrace(void) void VGA_wait_hretrace(void)
{ {
while ((inb(STATE) & 1) == 0) ; while ((inb(STATE) & 1) == 0);
} }
/*******************************************************************************/ /*******************************************************************************/
@ -393,14 +429,15 @@ void VGA_wait_hretrace(void)
void VGA_cursor_enable(void) void VGA_cursor_enable(void)
{ {
if (!infos.isgraphic) { if (!infos.isgraphic)
u8 curs; {
/* active le curseur hardware */ u8 curs;
outb(CCRT, 10); /* active le curseur hardware */
curs = inb(CCRT + 1) & ~32; outb(CCRT, 10);
outb(CCRT + 1, curs); curs = inb(CCRT + 1) & ~32;
infos.iscursorvisible=true; outb(CCRT + 1, curs);
} infos.iscursorvisible = true;
}
} }
/*******************************************************************************/ /*******************************************************************************/
@ -408,14 +445,15 @@ void VGA_cursor_enable(void)
void VGA_cursor_disable(void) void VGA_cursor_disable(void)
{ {
if (!infos.isgraphic) { if (!infos.isgraphic)
u8 curs; {
/* Desactive le curseur hardware */ u8 curs;
outb(CCRT, 10); /* Desactive le curseur hardware */
curs = inb(CCRT + 1) | 32; outb(CCRT, 10);
outb(CCRT + 1, curs); curs = inb(CCRT + 1) | 32;
infos.iscursorvisible=false; outb(CCRT + 1, curs);
} infos.iscursorvisible = false;
}
} }
/*******************************************************************************/ /*******************************************************************************/
@ -423,7 +461,7 @@ void VGA_cursor_disable(void)
void useplane(u8 plan) void useplane(u8 plan)
{ {
u8 mask; u8 mask;
plan &= 3; plan &= 3;
mask = 1 << plan; mask = 1 << plan;
/* choisi le plan de lecture */ /* choisi le plan de lecture */
@ -439,19 +477,21 @@ void useplane(u8 plan)
void VGA_cursor_set(u16 x, u16 y) void VGA_cursor_set(u16 x, u16 y)
{ {
if (!infos.isgraphic) { if (!infos.isgraphic)
u16 pos; {
if (splitY == 0) u16 pos;
pos = (infos.currentshowedpage * infos.pagesize / 2 + x + y * infos.currentwidth); if (splitY == 0)
else pos = (infos.currentshowedpage * infos.pagesize /
pos = (x + y * infos.currentwidth); 2 + x + y * infos.currentwidth);
outb(CCRT, 0x0F); else
outb(CCRT + 1, (u8) (pos & 0x00FF)); pos = (x + y * infos.currentwidth);
outb(CCRT, 0x0E); outb(CCRT, 0x0F);
outb(CCRT + 1, (u8) ((pos & 0xFF00) >> 8)); outb(CCRT + 1, (u8) (pos & 0x00FF));
infos.currentcursorX=x; outb(CCRT, 0x0E);
infos.currentcursorY=y; outb(CCRT + 1, (u8) ((pos & 0xFF00) >> 8));
} infos.currentcursorX = x;
infos.currentcursorY = y;
}
} }
/*******************************************************************************/ /*******************************************************************************/
@ -462,15 +502,16 @@ u32 VGA_font_load(u8 * def, u8 size, u8 font)
{ {
if (infos.isgraphic) if (infos.isgraphic)
return 1; return 1;
u8 oldregs[5] = { 0, 0, 0, 0, 0 }; u8 oldregs[5] = { 0, 0, 0, 0, 0 };
u8 *base; u8 *base;
u16 i; u16 i;
if (font > 7) if (font > 7)
return 1; return 1;
if (font < 4) if (font < 4)
base = (u8 *) (getbase() + (font << 14)); base = (u8 *) (getbase() + (font << 14));
else else
base = (u8 *) (getbase() + ((((font - 4) << 1) + 1) << 13)); base = (u8 *) (getbase() +
((((font - 4) << 1) + 1) << 13));
/* sauve les anciens registres */ /* sauve les anciens registres */
outb(SEQUENCER, 2); outb(SEQUENCER, 2);
oldregs[0] = inb(SEQUENCER + 1); oldregs[0] = inb(SEQUENCER + 1);
@ -490,7 +531,8 @@ u32 VGA_font_load(u8 * def, u8 size, u8 font)
outb(GRAPHICS + 1, oldregs[4] & ~0x02); outb(GRAPHICS + 1, oldregs[4] & ~0x02);
/* utilisation du plan N°2 */ /* utilisation du plan N°2 */
useplane(2); useplane(2);
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++)
{
memcpy(def, base + i * 32, size, 1); memcpy(def, base + i * 32, size, 1);
def += size; def += size;
} }
@ -512,14 +554,15 @@ u32 VGA_font_load(u8 * def, u8 size, u8 font)
void VGA_font1_set(u8 num) void VGA_font1_set(u8 num)
{ {
if (!infos.isgraphic) { if (!infos.isgraphic)
num &= 0x07; {
outb(SEQUENCER, 3); num &= 0x07;
outb(SEQUENCER + 1, outb(SEQUENCER, 3);
(inb(SEQUENCER + 1) & 0xEC) | ((num & 0x03) + outb(SEQUENCER + 1,
((num & 0x04) << 2))); (inb(SEQUENCER + 1) & 0xEC) | ((num & 0x03) +
infos.currentfont1=num; ((num & 0x04) << 2)));
} infos.currentfont1 = num;
}
} }
/*******************************************************************************/ /*******************************************************************************/
@ -527,14 +570,15 @@ void VGA_font1_set(u8 num)
void VGA_font2_set(u8 num) void VGA_font2_set(u8 num)
{ {
if (!infos.isgraphic) { if (!infos.isgraphic)
num &= 0x07; {
outb(SEQUENCER, 3); num &= 0x07;
outb(SEQUENCER + 1, outb(SEQUENCER, 3);
(inb(SEQUENCER + 1) & 0xD3) | (((num & 0x03) << 2) + outb(SEQUENCER + 1,
((num & 0x04) << 3))); (inb(SEQUENCER + 1) & 0xD3) | (((num & 0x03) << 2) +
infos.currentfont2=num; ((num & 0x04) << 3)));
} infos.currentfont2 = num;
}
} }
/*******************************************************************************/ /*******************************************************************************/
@ -542,11 +586,12 @@ void VGA_font2_set(u8 num)
void VGA_blink_enable(void) void VGA_blink_enable(void)
{ {
if (!infos.isgraphic) { if (!infos.isgraphic)
outb(CCRT, 0x10); {
outb(CCRT + 1, (inb(SEQUENCER + 1) | 0x04)); outb(CCRT, 0x10);
infos.isblinking=true; outb(CCRT + 1, (inb(SEQUENCER + 1) | 0x04));
} infos.isblinking = true;
}
} }
/*******************************************************************************/ /*******************************************************************************/
@ -554,11 +599,12 @@ void VGA_blink_enable(void)
void VGA_blink_disable(void) void VGA_blink_disable(void)
{ {
if (!infos.isgraphic) { if (!infos.isgraphic)
outb(CCRT, 0x10); {
outb(CCRT + 1, (inb(SEQUENCER + 1) & ~0x04)); outb(CCRT, 0x10);
infos.isblinking=false; outb(CCRT + 1, (inb(SEQUENCER + 1) & ~0x04));
} infos.isblinking = false;
}
} }
/*******************************************************************************/ /*******************************************************************************/
@ -567,8 +613,9 @@ vers le registre sp
void outreg(u16 port, u8 * src, u16 num) void outreg(u16 port, u8 * src, u16 num)
{ {
int i; int i;
for (i = 0; i < num; i++) { for (i = 0; i < num; i++)
{
outb(port, i); outb(port, i);
outb(port + 1, *src++); outb(port + 1, *src++);
} }
@ -580,8 +627,9 @@ vers le registre sp
void outregsame(u16 port, u8 * src, u16 num) void outregsame(u16 port, u8 * src, u16 num)
{ {
int i; int i;
for (i = 0; i < num; i++) { for (i = 0; i < num; i++)
{
inb(port); inb(port);
outb(port, i); outb(port, i);
outb(port, *src++); outb(port, *src++);
@ -594,8 +642,9 @@ vers portion de m
void inreg(u16 port, u8 * src, u16 num) void inreg(u16 port, u8 * src, u16 num)
{ {
int i; int i;
for (i = 0; i < num; i++) { for (i = 0; i < num; i++)
{
outb(port, i); outb(port, i);
*src++ = inb(port + 1); *src++ = inb(port + 1);
} }
@ -607,8 +656,9 @@ vers portion de m
void inregsame(u16 port, u8 * src, u16 num) void inregsame(u16 port, u8 * src, u16 num)
{ {
int i; int i;
for (i = 0; i < num; i++) { for (i = 0; i < num; i++)
{
inb(port); inb(port);
outb(port, i); outb(port, i);
*src++ = inb(port); *src++ = inb(port);

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@ harddisk: final/harddisk.img.final
uefi: final/harddiskuefi.img.final uefi: final/harddiskuefi.img.final
install: install:
(sudo apt-get install nasm gcc qemu fusefat fuseext2 cgdb ovmf bsdmainutils tar bsdmainutils indent binutils bochs bochs-x bochsbios) (sudo apt-get install nasm gcc qemu fusefat fuseext2 cgdb ovmf bsdmainutils tar bsdmainutils indent binutils bochs bochs-x bochsbios dos2unix)
togit: togit:
make -C system togit make -C system togit

View File

@ -4,4 +4,4 @@
#include "types.h"; #include "types.h";
u32 test_api(void); u32 test_api(void);

View File

@ -41,4 +41,3 @@
1:" : "=a" (_v) : "a" (syscall), "b" (arg1), "S" (arg2), "D" (arg3) : "ecx","edx","memory"); \ 1:" : "=a" (_v) : "a" (syscall), "b" (arg1), "S" (arg2), "D" (arg3) : "ecx","edx","memory"); \
_v; \ _v; \
}) })

View File

@ -1,70 +1,70 @@
/*******************************************************************************/ /*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */ /* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */ /* */
#ifndef ALLTYPES #ifndef ALLTYPES
# define ALLTYPES # define ALLTYPES
typedef char int8; typedef char int8;
typedef short int16; typedef short int16;
typedef int int32; typedef int int32;
typedef long long int64; typedef long long int64;
typedef char BYTE; typedef char BYTE;
typedef short WORD; typedef short WORD;
typedef long DWORD; typedef long DWORD;
typedef long long QWORD; typedef long long QWORD;
typedef signed char SBYTE; typedef signed char SBYTE;
typedef signed short SWORD; typedef signed short SWORD;
typedef signed long SDWORD; typedef signed long SDWORD;
typedef signed long long SQWORD; typedef signed long long SQWORD;
typedef unsigned char UBYTE; typedef unsigned char UBYTE;
typedef unsigned short UWORD; typedef unsigned short UWORD;
typedef unsigned long UDWORD; typedef unsigned long UDWORD;
typedef unsigned long long UQWORD; typedef unsigned long long UQWORD;
typedef unsigned char u8; typedef unsigned char u8;
typedef unsigned short u16; typedef unsigned short u16;
typedef unsigned int u32; typedef unsigned int u32;
typedef unsigned long long int u64; typedef unsigned long long int u64;
typedef char s8; typedef char s8;
typedef short s16; typedef short s16;
typedef int s32; typedef int s32;
typedef long int s64; typedef long int s64;
typedef int bool; typedef int bool;
extern char ctype[]; extern char ctype[];
#define true 1 # define true 1
#define false 0 # define false 0
#define NULL 0x0000 # define NULL 0x0000
#define CT_UP 0x01 /* upper case */ # define CT_UP 0x01 /* upper case */
#define CT_LOW 0x02 /* lower case */ # define CT_LOW 0x02 /* lower case */
#define CT_DIG 0x04 /* digit */ # define CT_DIG 0x04 /* digit */
#define CT_CTL 0x08 /* control */ # define CT_CTL 0x08 /* control */
#define CT_PUN 0x10 /* punctuation */ # define CT_PUN 0x10 /* punctuation */
#define CT_WHT 0x20 /* white space (space/cr/lf/tab) */ # define CT_WHT 0x20 /* white space (space/cr/lf/tab) */
#define CT_HEX 0x40 /* hex digit */ # define CT_HEX 0x40 /* hex digit */
#define CT_SP 0x80 /* hard space (0x20) */ # define CT_SP 0x80 /* hard space (0x20) */
/* without the cast to unsigned, DJGPP complains (using -Wall) */ /* without the cast to unsigned, DJGPP complains (using -Wall) */
#define isalnum(c) ((ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW | CT_DIG)) # define isalnum(c) ((ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW | CT_DIG))
#define isalpha(c) ((ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW)) # define isalpha(c) ((ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW))
#define iscntrl(c) ((ctype + 1)[(unsigned)(c)] & (CT_CTL)) # define iscntrl(c) ((ctype + 1)[(unsigned)(c)] & (CT_CTL))
#define isdigit(c) ((ctype + 1)[(unsigned)(c)] & (CT_DIG)) # define isdigit(c) ((ctype + 1)[(unsigned)(c)] & (CT_DIG))
#define isgraph(c) ((ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG)) # define isgraph(c) ((ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG))
#define islower(c) ((ctype + 1)[(unsigned)(c)] & (CT_LOW)) # define islower(c) ((ctype + 1)[(unsigned)(c)] & (CT_LOW))
#define isprint(c) ((ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG | CT_SP)) # define isprint(c) ((ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG | CT_SP))
#define ispunct(c) ((ctype + 1)[(unsigned)(c)] & (CT_PUN)) # define ispunct(c) ((ctype + 1)[(unsigned)(c)] & (CT_PUN))
#define isspace(c) ((ctype + 1)[(unsigned)(c)] & (CT_WHT)) # define isspace(c) ((ctype + 1)[(unsigned)(c)] & (CT_WHT))
#define isupper(c) ((ctype + 1)[(unsigned)(c)] & (CT_UP)) # define isupper(c) ((ctype + 1)[(unsigned)(c)] & (CT_UP))
#define isxdigit(c) ((ctype + 1)[(unsigned)(c)] & (CT_DIG | CT_HEX)) # define isxdigit(c) ((ctype + 1)[(unsigned)(c)] & (CT_DIG | CT_HEX))
#define isascii(c) ((unsigned)(c) <= 0x7F) # define isascii(c) ((unsigned)(c) <= 0x7F)
#define toascii(c) ((unsigned)(c) & 0x7F) # define toascii(c) ((unsigned)(c) & 0x7F)
#define tolower(c) (isupper(c) ? c + 'a' - 'A' : c) # define tolower(c) (isupper(c) ? c + 'a' - 'A' : c)
#define toupper(c) (islower(c) ? c + 'A' - 'a' : c) # define toupper(c) (islower(c) ? c + 'A' - 'a' : c)
#endif #endif

View File

@ -8,5 +8,5 @@
u32 test_api(void) u32 test_api(void)
{ {
syscall0(0x0); syscall0(0x0);
} }

View File

@ -7,5 +7,5 @@
void main(void) void main(void)
{ {
test_api(); test_api();
} }

View File

@ -18,11 +18,11 @@
#include "memory.h" #include "memory.h"
static u8 warnmsg[] = static u8 warnmsg[] =
"\033[150C\033[8D\033[37m\033[1m[ \033[36mNON\033[37m ]\033[0m"; "\033[150C\033[8D\033[37m\033[1m[ \033[36mNON\033[37m ]\033[0m";
static u8 okmsg[] = static u8 okmsg[] =
"\033[150C\033[8D\033[37m\033[1m[ \033[32mOK\033[37m ]\033[0m"; "\033[150C\033[8D\033[37m\033[1m[ \033[32mOK\033[37m ]\033[0m";
static u8 errormsg[] = static u8 errormsg[] =
"\033[150C\033[8D\033[37m\033[1m[\033[31mERREUR\033[37m]\033[0m"; "\033[150C\033[8D\033[37m\033[1m[\033[31mERREUR\033[37m]\033[0m";
static u8 key = 0; static u8 key = 0;
void ok() void ok()
@ -46,7 +46,8 @@ void error()
int main(u32 magic, u32 addr) int main(u32 magic, u32 addr)
{ {
cli(); cli();
if (magic == MULTIBOOT2_BOOTLOADER_MAGIC) initmultiboot(addr); if (magic == MULTIBOOT2_BOOTLOADER_MAGIC)
initmultiboot(addr);
initdriver(); initdriver();
registerdriver(&vgafonctions); registerdriver(&vgafonctions);
registerdriver(&vesafonctions); registerdriver(&vesafonctions);
@ -62,17 +63,17 @@ int main(u32 magic, u32 addr)
print("\033[37m\033[0m -Initilisation de la memoire (GDT)"); print("\033[37m\033[0m -Initilisation de la memoire (GDT)");
initgdt(&&next); initgdt(&&next);
next: next:
ok(); ok();
print("\033[37m\033[0m -Initilisation de la pagination (PAGING)"); print("\033[37m\033[0m -Initilisation de la pagination (PAGING)");
initpaging(); initpaging();
remap_memory(VESA_FBMEM); remap_memory(VESA_FBMEM);
ok(); ok();
print("\033[37m\033[0m -Initilisation des taches (TSR)"); print("\033[37m\033[0m -Initilisation des taches (TSR)");
inittr(); inittr();
task_init(); task_init();
ok(); ok();
print("\033[37m\033[0m -Initilisation des interruptions (IDT/PIC)"); print("\033[37m\033[0m -Initilisation des interruptions (IDT/PIC)");
@ -83,17 +84,20 @@ int main(u32 magic, u32 addr)
ok(); ok();
print(" -Installation du handler timer (IRQ 0)"); print(" -Installation du handler timer (IRQ 0)");
setidt((u32) timer, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 32); setidt((u32) timer, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 32);
enableirq(0); enableirq(0);
ok(); ok();
print(" -Installation du handler clavier (IRQ 1)"); print(" -Installation du handler clavier (IRQ 1)");
setidt((u32) keyboard, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 33); setidt((u32) keyboard, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 33);
enableirq(1); enableirq(1);
ok(); ok();
print(" -Installation du handler souris (IRQ12+Cascade IRQ2)"); print(" -Installation du handler souris (IRQ12+Cascade IRQ2)");
setidt((u32) mouse, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 100); setidt((u32) mouse, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 100);
enableirq(2); enableirq(2);
enableirq(12); enableirq(12);
if (initmouse() != 1) if (initmouse() != 1)
@ -102,10 +106,10 @@ int main(u32 magic, u32 addr)
ok(); ok();
printf(" -Installation des appels systemes utilisateur et du FPU"); printf(" -Installation des appels systemes utilisateur et du FPU");
initsyscall(); initsyscall();
finit(); finit();
ok(); ok();
retry: retry:
sti(); sti();
shell(); shell();
} }