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,13 +5,15 @@
#include "matrix.h" #include "matrix.h"
#include "video.h" #include "video.h"
typedef struct triface { typedef struct triface
{
u16 V1; u16 V1;
u16 V2; u16 V2;
u16 V3; u16 V3;
} triface __attribute__ ((packed)); } triface __attribute__ ((packed));
typedef struct model3d { typedef struct model3d
{
u8 name[12]; u8 name[12];
matrix44 view; matrix44 view;
vector4 *vertexlist; vector4 *vertexlist;
@ -20,9 +22,12 @@ typedef struct model3d {
u16 facenb; u16 facenb;
} model3d __attribute__ ((packed)); } model3d __attribute__ ((packed));
typedef struct vertex3d { typedef struct vertex3d
union { {
struct { union
{
struct
{
float x; float x;
float y; float y;
float z; float z;
@ -41,10 +46,12 @@ typedef enum type3D
} 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 */

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

@ -5,41 +5,41 @@
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

@ -13,11 +13,11 @@
#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) */
@ -39,22 +39,25 @@
#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 lim0_15;
u16 base0_15; u16 base0_15;
u8 base16_23; u8 base16_23;
u8 acces; u8 acces;
u8 lim16_19 : 4; u8 lim16_19:4;
u8 flags : 4; u8 flags:4;
u8 base24_31; u8 base24_31;
} gdtdes __attribute__ ((packed)); } gdtdes __attribute__ ((packed));
struct gdtr { struct gdtr
{
u16 limite; u16 limite;
u32 base; u32 base;
} __attribute__ ((packed)); } __attribute__ ((packed));
typedef struct tss { typedef struct tss
{
u16 prevtask, reserved00; u16 prevtask, reserved00;
u32 esp0; u32 esp0;
u16 ss0, reserved0; u16 ss0, reserved0;
@ -76,7 +79,8 @@ typedef struct tss {
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,
gdtdes * desc);
u32 getdesbase(u16 sel); u32 getdesbase(u16 sel);
u8 getdestype(u16 sel); u8 getdestype(u16 sel);
u32 getdessize(u16 sel); u32 getdessize(u16 sel);
@ -85,4 +89,4 @@ bool isdesvalid(u16 sel);
u8 getdesbit3(u16 sel); u8 getdesbit3(u16 sel);
u32 getdesdpl(u16 sel); u32 getdesdpl(u16 sel);
u16 getdesalign(u16 sel); u16 getdesalign(u16 sel);
void setTSS(u32 ss,u32 sp); 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_8086 0x01 /* 8086/88 (MCS-80/85) mode */
#define ICW4_AUTO 0x02 /* Auto EOI ou normal */ # define ICW4_AUTO 0x02 /* Auto EOI ou normal */
#define ICW4_BUF_SLAVE 0x08 /* mode/slave avec tampon*/ # define ICW4_BUF_SLAVE 0x08 /* mode/slave avec tampon */
#define ICW4_BUF_MASTER 0x0C /* mode/master avec tampon*/ # define ICW4_BUF_MASTER 0x0C /* mode/master avec tampon */
#define ICW4_SFNM 0x10 /* Complètement lié ou non */ # define ICW4_SFNM 0x10 /* Complètement lié ou non */
#define INTGATE 0x0E00 /* utilise pour gerer les interruptions */ # define INTGATE 0x0E00 /* utilise pour gerer les interruptions */
#define TRAPGATE 0x0F00 /* utilise pour faire des appels systemes */ # define TRAPGATE 0x0F00 /* utilise pour faire des appels systemes */
#define TASKGATE 0x0500 /* utilise pour commuter des taches */ # define TASKGATE 0x0500 /* utilise pour commuter des taches */
#define CALLGATE 0x0C00 /* utilise pour appeler du code */ # define CALLGATE 0x0C00 /* utilise pour appeler du code */
#define LDTDES 0x0200 /* utilise pour pointer une LDT */ # define LDTDES 0x0200 /* utilise pour pointer une LDT */
#define ENTRY_PRESENT 0b1000000000000000 /* Segment défini (obligatoire) */ # define ENTRY_PRESENT 0b1000000000000000 /* Segment défini (obligatoire) */
#define ENTRY_STORAGE 0b0001000000000000 /* Segment défini (obligatoire) */ # define ENTRY_STORAGE 0b0001000000000000 /* Segment défini (obligatoire) */
#define ENTRY_RING0 0b0000000000000000 /* Segment anneau 0 */ # define ENTRY_RING0 0b0000000000000000 /* Segment anneau 0 */
#define ENTRY_RING1 0b0010000000000000 /* Segment anneau 1 */ # define ENTRY_RING1 0b0010000000000000 /* Segment anneau 1 */
#define ENTRY_RING2 0b0100000000000000 /* Segment anneau 2 */ # define ENTRY_RING2 0b0100000000000000 /* Segment anneau 2 */
#define ENTRY_RING3 0b0110000000000000 /* Segment anneau 3 */ # 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,7 +211,8 @@ lors d'un iret en mode kernel:
/* save pile */ /* save pile */
typedef struct regs { typedef struct regs
{
u64 efer; u64 efer;
u32 dr7; u32 dr7;
u32 dr6; u32 dr6;
@ -241,7 +243,8 @@ typedef struct regs {
} 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 error_code;
u32 eip; u32 eip;
u32 cs; u32 cs;
@ -249,14 +252,16 @@ typedef struct exception_stack {
} 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 eip;
u32 cs; u32 cs;
u32 eflags; 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 error_code;
u32 eip; u32 eip;
u32 cs; u32 cs;
@ -266,7 +271,8 @@ typedef struct exception_stack_user {
} 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 eip;
u32 cs; u32 cs;
u32 eflags; u32 eflags;
@ -276,7 +282,8 @@ typedef struct exception_stack_noerror_user {
/* descripteur de segment */ /* descripteur de segment */
typedef struct idtdes { typedef struct idtdes
{
u16 offset0_15; u16 offset0_15;
u16 select; u16 select;
u16 type; u16 type;
@ -284,19 +291,19 @@ typedef struct idtdes {
} idtdes __attribute__ ((packed)); } idtdes __attribute__ ((packed));
struct idtr { struct idtr
{
u16 limite; u16 limite;
u32 base; 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

@ -35,4 +35,4 @@ 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

@ -25,6 +25,7 @@ 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);
unsigned long long __umoddi3(unsigned long long n, unsigned long long d);
u32 pow(u32 a, u8 n); u32 pow(u32 a, u8 n);

View File

@ -5,9 +5,12 @@
#ifndef MATRIX #ifndef MATRIX
# define MATRIX # define MATRIX
typedef struct vector4{ typedef struct vector4
union { {
struct { union
{
struct
{
float x; float x;
float y; float y;
float z; float z;
@ -17,9 +20,12 @@ typedef struct vector4{
}; };
} vector4 __attribute__ ((packed)); } vector4 __attribute__ ((packed));
typedef struct matrix44{ typedef struct matrix44
union { {
struct { union
{
struct
{
vector4 V[4]; vector4 V[4];
}; };
float v[16]; float v[16];
@ -27,50 +33,49 @@ typedef struct matrix44{
} 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,68 +5,77 @@
#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 size:31;
u32 used:1; 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 *vaddr;
u8 *paddr; u8 *paddr;
TAILQ_ENTRY(page) tailq; TAILQ_ENTRY(page) tailq;
@ -75,53 +84,56 @@ typedef struct 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 *addr;
page_t page_head; page_t page_head;
} __attribute__ ((packed)) pd; } __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 *vaddrlow;
u8 *vaddrhigh; u8 *vaddrhigh;
TAILQ_ENTRY(vrange) tailq; TAILQ_ENTRY(vrange) tailq;
} __attribute__ ((packed)) vrange; } __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

@ -4,75 +4,75 @@
#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. */ /* The magic field should contain this. */
#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6 # define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
/* This should be in %eax. */ /* This should be in %eax. */
#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289 # define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289
/* Alignment of multiboot modules. */ /* Alignment of multiboot modules. */
#define MULTIBOOT_MOD_ALIGN 0x00001000 # define MULTIBOOT_MOD_ALIGN 0x00001000
/* Alignment of the multiboot info structure. */ /* Alignment of the multiboot info structure. */
#define MULTIBOOT_INFO_ALIGN 0x00000008 # define MULTIBOOT_INFO_ALIGN 0x00000008
/* Flags set in the 'flags' member of the multiboot header. */ /* Flags set in the 'flags' member of the multiboot header. */
#define MULTIBOOT_TAG_ALIGN 8 # define MULTIBOOT_TAG_ALIGN 8
#define MULTIBOOT_TAG_TYPE_END 0 # define MULTIBOOT_TAG_TYPE_END 0
#define MULTIBOOT_TAG_TYPE_CMDLINE 1 # define MULTIBOOT_TAG_TYPE_CMDLINE 1
#define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2 # define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2
#define MULTIBOOT_TAG_TYPE_MODULE 3 # define MULTIBOOT_TAG_TYPE_MODULE 3
#define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4 # define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4
#define MULTIBOOT_TAG_TYPE_BOOTDEV 5 # define MULTIBOOT_TAG_TYPE_BOOTDEV 5
#define MULTIBOOT_TAG_TYPE_MMAP 6 # define MULTIBOOT_TAG_TYPE_MMAP 6
#define MULTIBOOT_TAG_TYPE_VBE 7 # define MULTIBOOT_TAG_TYPE_VBE 7
#define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8 # define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8
#define MULTIBOOT_TAG_TYPE_ELF_SECTIONS 9 # define MULTIBOOT_TAG_TYPE_ELF_SECTIONS 9
#define MULTIBOOT_TAG_TYPE_APM 10 # define MULTIBOOT_TAG_TYPE_APM 10
#define MULTIBOOT_TAG_TYPE_EFI32 11 # define MULTIBOOT_TAG_TYPE_EFI32 11
#define MULTIBOOT_TAG_TYPE_EFI64 12 # define MULTIBOOT_TAG_TYPE_EFI64 12
#define MULTIBOOT_TAG_TYPE_SMBIOS 13 # define MULTIBOOT_TAG_TYPE_SMBIOS 13
#define MULTIBOOT_TAG_TYPE_ACPI_OLD 14 # define MULTIBOOT_TAG_TYPE_ACPI_OLD 14
#define MULTIBOOT_TAG_TYPE_ACPI_NEW 15 # define MULTIBOOT_TAG_TYPE_ACPI_NEW 15
#define MULTIBOOT_TAG_TYPE_NETWORK 16 # define MULTIBOOT_TAG_TYPE_NETWORK 16
#define MULTIBOOT_TAG_TYPE_EFI_MMAP 17 # define MULTIBOOT_TAG_TYPE_EFI_MMAP 17
#define MULTIBOOT_TAG_TYPE_EFI_BS 18 # define MULTIBOOT_TAG_TYPE_EFI_BS 18
#define MULTIBOOT_TAG_TYPE_EFI32_IH 19 # define MULTIBOOT_TAG_TYPE_EFI32_IH 19
#define MULTIBOOT_TAG_TYPE_EFI64_IH 20 # define MULTIBOOT_TAG_TYPE_EFI64_IH 20
#define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR 21 # define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR 21
#define MULTIBOOT_HEADER_TAG_END 0 # define MULTIBOOT_HEADER_TAG_END 0
#define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1 # define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1
#define MULTIBOOT_HEADER_TAG_ADDRESS 2 # define MULTIBOOT_HEADER_TAG_ADDRESS 2
#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS 3 # define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS 3
#define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS 4 # define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS 4
#define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5 # define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5
#define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6 # define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6
#define MULTIBOOT_HEADER_TAG_EFI_BS 7 # define MULTIBOOT_HEADER_TAG_EFI_BS 7
#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI32 8 # define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI32 8
#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9 # define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9
#define MULTIBOOT_HEADER_TAG_RELOCATABLE 10 # define MULTIBOOT_HEADER_TAG_RELOCATABLE 10
#define MULTIBOOT_ARCHITECTURE_I386 0 # define MULTIBOOT_ARCHITECTURE_I386 0
#define MULTIBOOT_ARCHITECTURE_MIPS32 4 # define MULTIBOOT_ARCHITECTURE_MIPS32 4
#define MULTIBOOT_HEADER_TAG_OPTIONAL 1 # define MULTIBOOT_HEADER_TAG_OPTIONAL 1
#define MULTIBOOT_LOAD_PREFERENCE_NONE 0 # define MULTIBOOT_LOAD_PREFERENCE_NONE 0
#define MULTIBOOT_LOAD_PREFERENCE_LOW 1 # define MULTIBOOT_LOAD_PREFERENCE_LOW 1
#define MULTIBOOT_LOAD_PREFERENCE_HIGH 2 # define MULTIBOOT_LOAD_PREFERENCE_HIGH 2
#define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1 # define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1
#define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2 # define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2
struct multiboot_header struct multiboot_header
{ {
/* Must be MULTIBOOT_MAGIC - see above. */ /* Must be MULTIBOOT_MAGIC - see above. */
u32 magic; u32 magic;
@ -84,25 +84,25 @@
/* The above fields plus this one must equal 0 mod 2^32. */ /* The above fields plus this one must equal 0 mod 2^32. */
u32 checksum; u32 checksum;
}; };
struct multiboot_header_tag struct multiboot_header_tag
{ {
u16 type; u16 type;
u16 flags; u16 flags;
u32 size; u32 size;
}; };
struct multiboot_header_tag_information_request struct multiboot_header_tag_information_request
{ {
u16 type; u16 type;
u16 flags; u16 flags;
u32 size; u32 size;
u32 requests[0]; u32 requests[0];
}; };
struct multiboot_header_tag_address struct multiboot_header_tag_address
{ {
u16 type; u16 type;
u16 flags; u16 flags;
u32 size; u32 size;
@ -110,43 +110,43 @@
u32 load_addr; u32 load_addr;
u32 load_end_addr; u32 load_end_addr;
u32 bss_end_addr; u32 bss_end_addr;
}; };
struct multiboot_header_tag_entry_address struct multiboot_header_tag_entry_address
{ {
u16 type; u16 type;
u16 flags; u16 flags;
u32 size; u32 size;
u32 entry_addr; u32 entry_addr;
}; };
struct multiboot_header_tag_console_flags struct multiboot_header_tag_console_flags
{ {
u16 type; u16 type;
u16 flags; u16 flags;
u32 size; u32 size;
u32 console_flags; u32 console_flags;
}; };
struct multiboot_header_tag_framebuffer struct multiboot_header_tag_framebuffer
{ {
u16 type; u16 type;
u16 flags; u16 flags;
u32 size; u32 size;
u32 width; u32 width;
u32 height; u32 height;
u32 depth; u32 depth;
}; };
struct multiboot_header_tag_module_align struct multiboot_header_tag_module_align
{ {
u16 type; u16 type;
u16 flags; u16 flags;
u32 size; u32 size;
}; };
struct multiboot_header_tag_relocatable struct multiboot_header_tag_relocatable
{ {
u16 type; u16 type;
u16 flags; u16 flags;
u32 size; u32 size;
@ -154,89 +154,89 @@
u32 max_addr; u32 max_addr;
u32 align; u32 align;
u32 preference; u32 preference;
}; };
struct multiboot_color struct multiboot_color
{ {
u8 red; u8 red;
u8 green; u8 green;
u8 blue; u8 blue;
}; };
struct multiboot_mmap_entry struct multiboot_mmap_entry
{ {
u64 addr; u64 addr;
u64 len; u64 len;
#define MULTIBOOT_MEMORY_AVAILABLE 1 # define MULTIBOOT_MEMORY_AVAILABLE 1
#define MULTIBOOT_MEMORY_RESERVED 2 # define MULTIBOOT_MEMORY_RESERVED 2
#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3 # define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
#define MULTIBOOT_MEMORY_NVS 4 # define MULTIBOOT_MEMORY_NVS 4
#define MULTIBOOT_MEMORY_BADRAM 5 # define MULTIBOOT_MEMORY_BADRAM 5
u32 type; u32 type;
u32 zero; u32 zero;
}; };
typedef struct multiboot_mmap_entry multiboot_memory_map_t; typedef struct multiboot_mmap_entry multiboot_memory_map_t;
struct multiboot_tag struct multiboot_tag
{ {
u32 type; u32 type;
u32 size; u32 size;
}; };
struct multiboot_tag_string struct multiboot_tag_string
{ {
u32 type; u32 type;
u32 size; u32 size;
u8 string[0]; u8 string[0];
}; };
struct multiboot_tag_module struct multiboot_tag_module
{ {
u32 type; u32 type;
u32 size; u32 size;
u32 mod_start; u32 mod_start;
u32 mod_end; u32 mod_end;
u8 cmdline[0]; u8 cmdline[0];
}; };
struct multiboot_tag_basic_meminfo struct multiboot_tag_basic_meminfo
{ {
u32 type; u32 type;
u32 size; u32 size;
u32 mem_lower; u32 mem_lower;
u32 mem_upper; u32 mem_upper;
}; };
struct multiboot_tag_bootdev struct multiboot_tag_bootdev
{ {
u32 type; u32 type;
u32 size; u32 size;
u32 biosdev; u32 biosdev;
u32 slice; u32 slice;
u32 part; u32 part;
}; };
struct multiboot_tag_mmap struct multiboot_tag_mmap
{ {
u32 type; u32 type;
u32 size; u32 size;
u32 entry_size; u32 entry_size;
u32 entry_version; u32 entry_version;
struct multiboot_mmap_entry entries[0]; struct multiboot_mmap_entry entries[0];
}; };
struct multiboot_vbe_info_block struct multiboot_vbe_info_block
{ {
u8 external_specification[512]; u8 external_specification[512];
}; };
struct multiboot_vbe_mode_info_block struct multiboot_vbe_mode_info_block
{ {
u8 external_specification[256]; u8 external_specification[256];
}; };
struct multiboot_tag_vbe struct multiboot_tag_vbe
{ {
u32 type; u32 type;
u32 size; u32 size;
@ -247,10 +247,10 @@
struct multiboot_vbe_info_block vbe_control_info; struct multiboot_vbe_info_block vbe_control_info;
struct multiboot_vbe_mode_info_block vbe_mode_info; struct multiboot_vbe_mode_info_block vbe_mode_info;
}; };
struct multiboot_tag_framebuffer_common struct multiboot_tag_framebuffer_common
{ {
u32 type; u32 type;
u32 size; u32 size;
@ -259,15 +259,15 @@
u32 framebuffer_width; u32 framebuffer_width;
u32 framebuffer_height; u32 framebuffer_height;
u8 framebuffer_bpp; u8 framebuffer_bpp;
#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0 # define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1 # define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2 # define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
u8 framebuffer_type; u8 framebuffer_type;
u16 reserved; u16 reserved;
}; };
struct multiboot_tag_framebuffer struct multiboot_tag_framebuffer
{ {
struct multiboot_tag_framebuffer_common common; struct multiboot_tag_framebuffer_common common;
union union
@ -287,20 +287,20 @@
u8 framebuffer_blue_mask_size; u8 framebuffer_blue_mask_size;
}; };
}; };
}; };
struct multiboot_tag_elf_sections struct multiboot_tag_elf_sections
{ {
u32 type; u32 type;
u32 size; u32 size;
u32 num; u32 num;
u32 entsize; u32 entsize;
u32 shndx; u32 shndx;
u8 sections[0]; u8 sections[0];
}; };
struct multiboot_tag_apm struct multiboot_tag_apm
{ {
u32 type; u32 type;
u32 size; u32 size;
u16 version; u16 version;
@ -312,82 +312,82 @@
u16 cseg_len; u16 cseg_len;
u16 cseg_16_len; u16 cseg_16_len;
u16 dseg_len; u16 dseg_len;
}; };
struct multiboot_tag_efi32 struct multiboot_tag_efi32
{ {
u32 type; u32 type;
u32 size; u32 size;
u32 pointer; u32 pointer;
}; };
struct multiboot_tag_efi64 struct multiboot_tag_efi64
{ {
u32 type; u32 type;
u32 size; u32 size;
u64 pointer; u64 pointer;
}; };
struct multiboot_tag_smbios struct multiboot_tag_smbios
{ {
u32 type; u32 type;
u32 size; u32 size;
u8 major; u8 major;
u8 minor; u8 minor;
u8 reserved[6]; u8 reserved[6];
u8 tables[0]; u8 tables[0];
}; };
struct multiboot_tag_old_acpi struct multiboot_tag_old_acpi
{ {
u32 type; u32 type;
u32 size; u32 size;
u8 rsdp[0]; u8 rsdp[0];
}; };
struct multiboot_tag_new_acpi struct multiboot_tag_new_acpi
{ {
u32 type; u32 type;
u32 size; u32 size;
u8 rsdp[0]; u8 rsdp[0];
}; };
struct multiboot_tag_network struct multiboot_tag_network
{ {
u32 type; u32 type;
u32 size; u32 size;
u8 dhcpack[0]; u8 dhcpack[0];
}; };
struct multiboot_tag_efi_mmap struct multiboot_tag_efi_mmap
{ {
u32 type; u32 type;
u32 size; u32 size;
u32 descr_size; u32 descr_size;
u32 descr_vers; u32 descr_vers;
u8 efi_mmap[0]; u8 efi_mmap[0];
}; };
struct multiboot_tag_efi32_ih struct multiboot_tag_efi32_ih
{ {
u32 type; u32 type;
u32 size; u32 size;
u32 pointer; u32 pointer;
}; };
struct multiboot_tag_efi64_ih struct multiboot_tag_efi64_ih
{ {
u32 type; u32 type;
u32 size; u32 size;
u64 pointer; u64 pointer;
}; };
struct multiboot_tag_load_base_addr struct multiboot_tag_load_base_addr
{ {
u32 type; u32 type;
u32 size; u32 size;
u32 load_base_addr; u32 load_base_addr;
}; };
u32 getgrubinfo(u8 type); u32 getgrubinfo(u8 type);
u8 *getgrubinfo_cmdline(void); u8 *getgrubinfo_cmdline(void);

View File

@ -4,7 +4,8 @@
typedef struct pciclass { typedef struct pciclass
{
u16 number; u16 number;
u8 *name; u8 *name;
} pciclass __attribute__ ((packed)); } pciclass __attribute__ ((packed));
@ -26,9 +27,12 @@ typedef struct pcidev
} pcidev __attribute__ ((packed)); } pcidev __attribute__ ((packed));
typedef struct pcidevmini { typedef struct pcidevmini
union { {
struct { union
{
struct
{
u16 vendor_id; u16 vendor_id;
u16 device_id; u16 device_id;
}; };
@ -36,9 +40,11 @@ typedef struct pcidevmini {
}; };
} pcidevmini __attribute__ ((packed)); } 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,
const u8 offset);
void scanPCImini(void); 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,
const u8 function);
void scanPCI(void); void scanPCI(void);
u8 * pcigetclassname( const pcidev *device); u8 *pcigetclassname(const pcidev * device);

View File

@ -88,12 +88,13 @@
#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]; u8 e_ident[EI_NIDENT];
u16 e_type; u16 e_type;
u16 e_machine; u16 e_machine;
u32 e_version; u32 e_version;
u8* e_entry; u8 *e_entry;
u32 e_phoff; u32 e_phoff;
u32 e_shoff; u32 e_shoff;
u32 e_flags; u32 e_flags;
@ -105,11 +106,12 @@ typedef struct elf32 {
u16 e_shstrndx; u16 e_shstrndx;
} elf32; } elf32;
typedef struct elf32p{ typedef struct elf32p
{
u32 p_type; u32 p_type;
u32 p_offset; u32 p_offset;
u8* p_vaddr; u8 *p_vaddr;
u8* p_paddr; u8 *p_paddr;
u32 p_filesz; u32 p_filesz;
u32 p_memsz; u32 p_memsz;
u32 p_flags; u32 p_flags;
@ -117,13 +119,15 @@ typedef struct elf32p{
} elf32p; } elf32p;
typedef struct stackdef { typedef struct stackdef
{
u32 esp0; u32 esp0;
u16 ss0; u16 ss0;
} stackdef __attribute__ ((packed)); } stackdef __attribute__ ((packed));
typedef struct process { typedef struct process
{
u32 pid; u32 pid;
bool kernel; bool kernel;
regs dump; regs dump;
@ -141,11 +145,11 @@ typedef struct process {
} 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 lastline;
unsigned long prevline; unsigned long prevline;
const char *lastfile; const char *lastfile;
const char *prevfile; 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

@ -3,10 +3,9 @@
/* */ /* */
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();
@ -21,10 +20,10 @@ 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();

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

@ -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

@ -36,35 +36,35 @@ 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,22 +8,22 @@
/* 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,

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,11 +23,13 @@
#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 Reset_Register;
u8 Clocking_Mode_Register; u8 Clocking_Mode_Register;
u8 Map_Mask_Register; u8 Map_Mask_Register;
@ -35,7 +37,8 @@ typedef struct sequencer_regs {
u8 Sequencer_Memory_Mode_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 Horizontal_Total_Register;
u8 End_Horizontal_Display_Register; u8 End_Horizontal_Display_Register;
u8 Start_Horizontal_Blanking_Register; u8 Start_Horizontal_Blanking_Register;
@ -63,7 +66,8 @@ typedef struct crtc_regs {
u8 Line_Compare_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 Set_Reset_Register;
u8 Enable_Set_Reset_Register; u8 Enable_Set_Reset_Register;
u8 Color_Compare_Register; u8 Color_Compare_Register;
@ -75,7 +79,8 @@ typedef struct graphics_regs {
u8 Bit_Mask_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 Palette_Registers[16];
u8 Attribute_Mode_Control_Register; u8 Attribute_Mode_Control_Register;
u8 Overscan_Color_Register; u8 Overscan_Color_Register;
@ -84,7 +89,8 @@ typedef struct attributs_regs {
u8 Color_Select_Register; u8 Color_Select_Register;
} attributs_regs __attribute__ ((packed)); } attributs_regs __attribute__ ((packed));
typedef struct vgamode { typedef struct vgamode
{
misc_regs misc; misc_regs misc;
sequencer_regs sequencer; sequencer_regs sequencer;
crtc_regs ctrc; crtc_regs ctrc;
@ -94,30 +100,29 @@ typedef struct vgamode {
/* 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,

View File

@ -5,23 +5,26 @@
#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 x;
s16 y; s16 y;
} vertex2d __attribute__ ((packed)); } vertex2d __attribute__ ((packed));
typedef struct rgbcolor { typedef struct rgbcolor
{
u8 R; u8 R;
u8 G; u8 G;
u8 B; u8 B;
} rgbcolor __attribute__ ((packed)); } rgbcolor __attribute__ ((packed));
typedef struct videoinfos { typedef struct videoinfos
{
u8 currentmode; u8 currentmode;
u16 currentwidth; u16 currentwidth;
u16 currentheight; u16 currentheight;
@ -41,16 +44,17 @@ typedef struct videoinfos {
u32 baseaddress; 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(*setvideo_mode) ();
u8 *(*getvideo_drivername) (); u8 *(*getvideo_drivername) ();
u8 *(*getvideo_capabilities) (); u8 *(*getvideo_capabilities) ();
videoinfos *(*getvideo_info) (); videoinfos *(*getvideo_info) ();
u32 (*mem_to_video) (); u32(*mem_to_video) ();
u32 (*video_to_mem) (); u32(*video_to_mem) ();
u32 (*video_to_video) (); u32(*video_to_video) ();
void (*wait_vretrace) (); void (*wait_vretrace) ();
void (*wait_hretrace) (); void (*wait_hretrace) ();
void (*page_set) (); void (*page_set) ();
@ -59,26 +63,29 @@ typedef struct videofonction {
void (*cursor_enable) (); void (*cursor_enable) ();
void (*cursor_disable) (); void (*cursor_disable) ();
void (*cursor_set) (); void (*cursor_set) ();
u32 (*font_load) (); u32(*font_load) ();
void (*font1_set) (); void (*font1_set) ();
void (*font2_set) (); void (*font2_set) ();
void (*blink_enable) (); void (*blink_enable) ();
void (*blink_disable) (); 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 nom[8];
u8* pointer; u8 *pointer;
u8 width; u8 width;
u8 height; u8 height;
} font __attribute__ ((packed)); } font __attribute__ ((packed));
typedef struct capabilities { typedef struct capabilities
{
u8 modenumber; u8 modenumber;
u16 width; u16 width;
u16 height; u16 height;
@ -87,7 +94,8 @@ typedef struct capabilities {
u8 refresh; u8 refresh;
} capabilities __attribute__ ((packed)); } capabilities __attribute__ ((packed));
typedef struct console { typedef struct console
{
u8 attrib; u8 attrib;
s16 cursX; s16 cursX;
s16 cursY; s16 cursY;
@ -101,22 +109,23 @@ typedef struct console {
/* 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);
@ -124,42 +133,44 @@ 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);
@ -167,8 +178,8 @@ 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);

51342
lib/3D/man.c

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

319
lib/3d.c
View File

@ -8,117 +8,132 @@
/*******************************************************************************/ /*******************************************************************************/
/* 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: case TYPE3D_POINTS:
for(i=0;i<model->vertexnb;i++) { for (i = 0; i < model->vertexnb; i++)
{
v_writepxl(&plane[i], egatorgb(4)); v_writepxl(&plane[i], egatorgb(4));
} }
break; break;
case TYPE3D_LINES: case TYPE3D_LINES:
for(i=0;i<model->facenb;i++) { for (i = 0; i < model->facenb; i++)
v_line(&plane[model->facelist[i].V1], &plane[model->facelist[i].V2], egatorgb(4)); {
v_line(&plane[model->facelist[i].V1], &plane[model->facelist[i].V3], egatorgb(4)); v_line(&plane[model->facelist[i].V1],
v_line(&plane[model->facelist[i].V2], &plane[model->facelist[i].V3], egatorgb(4)); &plane[model->facelist[i].V2],
egatorgb(4));
v_line(&plane[model->facelist[i].V1],
&plane[model->facelist[i].V3],
egatorgb(4));
v_line(&plane[model->facelist[i].V2],
&plane[model->facelist[i].V3],
egatorgb(4));
} }
break; break;
case TYPE3D_FACES: case TYPE3D_FACES:
@ -133,117 +148,128 @@ void show3dmodel(model3d *model, matrix44 *transformation, vector4 origin[], flo
/*******************************************************************************/ /*******************************************************************************/
/* 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);
state = DS_READ_CHUNK_ID;
break; break;
} }
break; break;
case DS_READ_OBJECT_NAME: case DS_READ_OBJECT_NAME:
strcpy(ptr, model->name); strcpy(ptr, model->name);
ptr+=(strlen(ptr)+1); ptr += (strlen(ptr) + 1);
state=DS_READ_CHUNK_ID; state = DS_READ_CHUNK_ID;
break; break;
case DS_SKIP_CHUNK: case DS_SKIP_CHUNK:
break; break;
case DS_READ_POINT_COUNT: case DS_READ_POINT_COUNT:
model->vertexnb=*((u16*) ptr); model->vertexnb = *((u16 *) ptr);
state=DS_READ_POINTS; state = DS_READ_POINTS;
ptr+=2; ptr += 2;
break; break;
case DS_READ_POINTS: case DS_READ_POINTS:
i=0; i = 0;
listfloat=ptr; listfloat = ptr;
model->vertexlist=0x00300000; model->vertexlist = 0x00300000;
while(i<model->vertexnb) while (i < model->vertexnb)
{ {
model->vertexlist[i].x=*(listfloat++); model->vertexlist[i].x =
model->vertexlist[i].y=*(listfloat++); *(listfloat++);
model->vertexlist[i].z=*(listfloat++); model->vertexlist[i].y =
model->vertexlist[i++].w=1.0; *(listfloat++);
model->vertexlist[i].z =
*(listfloat++);
model->vertexlist[i++].w = 1.0;
} }
ptr=listfloat; ptr = listfloat;
state=DS_READ_CHUNK_ID; state = DS_READ_CHUNK_ID;
break; break;
case DS_READ_FACE_COUNT: case DS_READ_FACE_COUNT:
model->facenb=*((u16*) ptr); model->facenb = *((u16 *) ptr);
state=DS_READ_FACES; state = DS_READ_FACES;
ptr+=2; ptr += 2;
break; break;
case DS_READ_FACES: case DS_READ_FACES:
i=0; i = 0;
listunsigned=ptr; listunsigned = ptr;
model->facelist=0x00400000; model->facelist = 0x00400000;
while(i<model->facenb) while (i < model->facenb)
{ {
model->facelist[i].V1=*(listunsigned++); model->facelist[i].V1 =
model->facelist[i].V2=*(listunsigned++); *(listunsigned++);
model->facelist[i++].V3=*(listunsigned++); model->facelist[i].V2 =
*(listunsigned++);
model->facelist[i++].V3 =
*(listunsigned++);
listunsigned++; listunsigned++;
} }
ptr=listunsigned; ptr = listunsigned;
state=DS_READ_CHUNK_ID; state = DS_READ_CHUNK_ID;
break; break;
case DS_READ_MATRIX: case DS_READ_MATRIX:
i=0; i = 0;
listfloat=ptr; listfloat = ptr;
while(i<4) while (i < 4)
{ {
model->view.V[i].x=*(listfloat++); model->view.V[i].x =
model->view.V[i].y=*(listfloat++); *(listfloat++);
model->view.V[i].z=*(listfloat++); model->view.V[i].y =
model->view.V[i++].w=0.0f; *(listfloat++);
model->view.V[i].z =
*(listfloat++);
model->view.V[i++].w = 0.0f;
} }
model->view.V[3].w=1.0f; model->view.V[3].w = 1.0f;
ptr=listfloat; ptr = listfloat;
state=DS_READ_CHUNK_ID; state = DS_READ_CHUNK_ID;
break; break;
case DS_READ_DONE: case DS_READ_DONE:
break; break;
@ -252,4 +278,3 @@ int load3ds(u8 *pointer,u32 size, model3d *model)
} }
} }

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

@ -4,192 +4,379 @@ 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

@ -3,272 +3,334 @@
/* */ /* */
/* 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,
0x00,
0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x00, 0x18, 0x3C, 0x7E, 0x18,
0x7E, 0x3C, 0x18, 0xFF,
0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18,
0x00, 0x18, 0x7E, 0x3C, 0x18,
0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x30, 0x60, 0xFE, 0x60, 0x30, 0x00,
0x00, 0x00, 0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x30, 0x60,
0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xFE, 0x00, 0x00, 0x00, 0x24, 0x66, 0xFF, 0x66, 0xFE, 0x60, 0x30,
0x24, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x7E, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xFE, 0x00, 0x00, 0x00, 0x24, 0x66,
0x3C, 0x18, 0x00, 0x00, 0xFF, 0x66,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x24, 0x00, 0x00,
0x40, 0x40, 0x00, 0x40, 0x00, 0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF,
0x90, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x50, 0x7E,
0xF8, 0x50, 0xF8, 0x50, 0x50, 0x00, 0x3C, 0x18, 0x00, 0x00,
0x20, 0x78, 0xA0, 0x70, 0x28, 0xF0, 0x20, 0x00, 0xC8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40,
0xC8, 0x10, 0x20, 0x40, 0x98, 0x98, 0x00, 0x40, 0x40, 0x00, 0x40, 0x00,
0x70, 0x88, 0x50, 0x20, 0x54, 0x88, 0x74, 0x00, 0x90, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x50,
0x60, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x50, 0xF8, 0x50, 0x50, 0x00,
0x20, 0x40, 0x80, 0x80, 0x80, 0x40, 0x20, 0x20, 0x78, 0xA0, 0x70, 0x28, 0xF0, 0x20, 0x00, 0xC8,
0x00, 0x20, 0x10, 0x08, 0x08, 0x08, 0x10, 0x20, 0x00, 0xC8, 0x10, 0x20, 0x40, 0x98, 0x98, 0x00,
0x00, 0x20, 0xA8, 0x70, 0x70, 0xA8, 0x70, 0x88, 0x50, 0x20, 0x54, 0x88, 0x74, 0x00,
0x20, 0x00, 0x00, 0x00, 0x20, 0x20, 0xF8, 0x20, 0x20, 0x00, 0x60, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40, 0x80, 0x80, 0x80, 0x40, 0x20,
0x60, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, 0x08, 0x08, 0x10, 0x20, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xA8, 0x70, 0x70, 0xA8,
0x00, 0x60, 0x60, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x20, 0xF8, 0x20, 0x20, 0x00,
0x70, 0x88, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00,
0xA8, 0xC8, 0x88, 0x70, 0x00, 0x40, 0xC0, 0x40, 0x40, 0x40, 0x40, 0xE0, 0x00, 0x60, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00,
0x70, 0x88, 0x00, 0x00, 0x00, 0x00,
0x08, 0x10, 0x20, 0x40, 0xF8, 0x00, 0x70, 0x88, 0x08, 0x10, 0x08, 0x88, 0x70, 0x00, 0x00, 0x60, 0x60, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
0x08, 0x00,
0x18, 0x28, 0x48, 0xFC, 0x08, 0x08, 0x00, 0xF8, 0x80, 0x80, 0xF0, 0x08, 0x88, 0x70, 0x00, 0x70, 0x88, 0x98,
0xA8, 0xC8, 0x88, 0x70, 0x00, 0x40, 0xC0, 0x40, 0x40, 0x40, 0x40,
0xE0, 0x00,
0x70, 0x88,
0x08, 0x10, 0x20, 0x40, 0xF8, 0x00, 0x70, 0x88, 0x08, 0x10, 0x08,
0x88, 0x70, 0x00,
0x08,
0x18, 0x28, 0x48, 0xFC, 0x08, 0x08, 0x00, 0xF8, 0x80, 0x80, 0xF0,
0x08, 0x88, 0x70, 0x00,
0x20, 0x40, 0x80, 0xF0, 0x88, 0x88, 0x70, 0x00, 0xF8, 0x08, 0x10, 0x20, 0x40, 0x40, 0x40, 0x20, 0x40, 0x80, 0xF0, 0x88, 0x88, 0x70, 0x00, 0xF8, 0x08, 0x10,
0x00, 0x20, 0x40, 0x40, 0x40,
0x70, 0x88, 0x88, 0x70, 0x88, 0x88, 0x70, 0x00, 0x70, 0x88, 0x88, 0x78, 0x08, 0x08, 0x00,
0x70, 0x00, 0x70, 0x88, 0x88, 0x70, 0x88, 0x88, 0x70, 0x00, 0x70, 0x88, 0x88,
0x00, 0x00, 0x60, 0x60, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x78, 0x08, 0x08,
0x60, 0x60, 0x20, 0x70, 0x00,
0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x60,
0xF8, 0x00, 0x00, 0x00, 0x60, 0x00,
0x80, 0x40, 0x20, 0x10, 0x20, 0x40, 0x80, 0x00, 0x78, 0x84, 0x04, 0x60, 0x60, 0x20,
0x08, 0x10, 0x00, 0x10, 0x00, 0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10, 0x00, 0x00, 0x00, 0xF8,
0x70, 0x88, 0x88, 0xA8, 0xB8, 0x80, 0x78, 0x00, 0x20, 0x50, 0x00,
0x88, 0x88, 0xF8, 0x88, 0x88, 0x00, 0xF8, 0x00, 0x00, 0x00,
0xF0, 0x88, 0x88, 0xF0, 0x88, 0x88, 0xF0, 0x00, 0x70, 0x80, 0x40, 0x20, 0x10, 0x20, 0x40, 0x80, 0x00, 0x78, 0x84, 0x04,
0x88, 0x80, 0x80, 0x80, 0x88, 0x70, 0x00, 0x08, 0x10, 0x00, 0x10, 0x00,
0xF0, 0x88, 0x88, 0x88, 0x88, 0x88, 0xF0, 0x00, 0x70, 0x88, 0x88, 0xA8, 0xB8, 0x80, 0x78, 0x00, 0x20, 0x50,
0xF8, 0x80, 0x80, 0xE0, 0x80, 0x80, 0xF8, 0x00, 0x88, 0x88, 0xF8, 0x88, 0x88, 0x00,
0xF8, 0x80, 0x80, 0xE0, 0x80, 0x80, 0x80, 0xF0, 0x88, 0x88, 0xF0, 0x88, 0x88, 0xF0, 0x00, 0x70,
0x00, 0x70, 0x88, 0x80, 0x80, 0x98, 0x88, 0x78, 0x00, 0x88, 0x80, 0x80, 0x80, 0x88, 0x70, 0x00,
0x88, 0x88, 0x88, 0xF8, 0x88, 0x88, 0xF0, 0x88, 0x88, 0x88, 0x88, 0x88, 0xF0, 0x00,
0x88, 0x00, 0xE0, 0x40, 0x40, 0x40, 0x40, 0x40, 0xE0, 0x00, 0xF8, 0x80, 0x80, 0xE0, 0x80, 0x80, 0xF8, 0x00,
0x38, 0x10, 0x10, 0x10, 0x10, 0xF8, 0x80, 0x80, 0xE0, 0x80, 0x80, 0x80,
0x90, 0x60, 0x00, 0x88, 0x90, 0xA0, 0xC0, 0xA0, 0x90, 0x88, 0x00, 0x00, 0x70, 0x88, 0x80, 0x80, 0x98, 0x88, 0x78, 0x00,
0x80, 0x80, 0x80, 0x80, 0x88, 0x88, 0x88, 0xF8, 0x88, 0x88,
0x80, 0x80, 0xF8, 0x00, 0x82, 0xC6, 0xAA, 0x92, 0x82, 0x82, 0x82, 0x00, 0x88, 0x00, 0xE0, 0x40, 0x40, 0x40, 0x40, 0x40, 0xE0, 0x00,
0x84, 0xC4, 0xA4, 0x38, 0x10, 0x10, 0x10, 0x10,
0x94, 0x8C, 0x84, 0x84, 0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70, 0x00, 0x90, 0x60, 0x00, 0x88, 0x90, 0xA0, 0xC0, 0xA0, 0x90, 0x88, 0x00,
0xF0, 0x88, 0x80, 0x80, 0x80, 0x80,
0x88, 0xF0, 0x80, 0x80, 0x80, 0x00, 0x70, 0x88, 0x88, 0x88, 0xA8, 0x90, 0x68, 0x00, 0x80, 0x80, 0xF8, 0x00, 0x82, 0xC6, 0xAA, 0x92, 0x82, 0x82, 0x82,
0xF0, 0x00,
0x88, 0x88, 0xF0, 0xA0, 0x90, 0x88, 0x00, 0x70, 0x88, 0x80, 0x70, 0x08, 0x88, 0x70, 0x00, 0x84, 0xC4, 0xA4,
0x94, 0x8C, 0x84, 0x84, 0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x88,
0x70, 0x00,
0xF0, 0x88,
0x88, 0xF0, 0x80, 0x80, 0x80, 0x00, 0x70, 0x88, 0x88, 0x88, 0xA8,
0x90, 0x68, 0x00,
0xF0,
0x88, 0x88, 0xF0, 0xA0, 0x90, 0x88, 0x00, 0x70, 0x88, 0x80, 0x70,
0x08, 0x88, 0x70, 0x00,
0xF8, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70, 0xF8, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x88, 0x88, 0x88,
0x00, 0x88, 0x88, 0x88, 0x70,
0x88, 0x88, 0x88, 0x50, 0x50, 0x20, 0x20, 0x00, 0x82, 0x82, 0x82, 0x82, 0x92, 0x92, 0x00,
0x6C, 0x00, 0x88, 0x88, 0x88, 0x50, 0x50, 0x20, 0x20, 0x00, 0x82, 0x82, 0x82,
0x88, 0x88, 0x50, 0x20, 0x50, 0x88, 0x88, 0x00, 0x88, 0x88, 0x88, 0x50, 0x20, 0x82, 0x92, 0x92,
0x20, 0x20, 0x00, 0x6C, 0x00,
0xF8, 0x08, 0x10, 0x20, 0x40, 0x80, 0xF8, 0x00, 0xE0, 0x80, 0x80, 0x80, 0x88, 0x88, 0x50, 0x20, 0x50, 0x88, 0x88, 0x00, 0x88, 0x88, 0x88,
0x80, 0x80, 0xE0, 0x00, 0x50, 0x20,
0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0xE0, 0x20, 0x20, 0x20, 0x20, 0x00,
0x20, 0x20, 0x20, 0xE0, 0x00, 0xF8, 0x08, 0x10, 0x20, 0x40, 0x80, 0xF8, 0x00, 0xE0, 0x80, 0x80,
0x20, 0x50, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x80, 0x80, 0xE0, 0x00,
0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0xE0, 0x20, 0x20,
0x00, 0x70, 0x08, 0x78, 0x88, 0x74, 0x00, 0x20, 0x20, 0x20, 0xE0, 0x00,
0x80, 0x80, 0xB0, 0xC8, 0x88, 0xC8, 0xB0, 0x00, 0x20, 0x50, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x70, 0x88, 0x80, 0x88, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00,
0x08, 0x08, 0x68, 0x98, 0x88, 0x98, 0x68, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x70, 0x88, 0xF8, 0x80, 0x70, 0x00, 0x00, 0x70, 0x08, 0x78, 0x88, 0x74, 0x00,
0x30, 0x48, 0x40, 0xE0, 0x40, 0x40, 0x80, 0x80, 0xB0, 0xC8, 0x88, 0xC8, 0xB0, 0x00,
0x40, 0x00, 0x00, 0x00, 0x34, 0x48, 0x48, 0x38, 0x08, 0x30, 0x00, 0x00, 0x70, 0x88, 0x80, 0x88, 0x70, 0x00,
0x80, 0x80, 0xB0, 0xC8, 0x88, 0x08, 0x08, 0x68, 0x98, 0x88, 0x98, 0x68,
0x88, 0x88, 0x00, 0x20, 0x00, 0x60, 0x20, 0x20, 0x20, 0x70, 0x00, 0x00, 0x00, 0x00, 0x70, 0x88, 0xF8, 0x80, 0x70, 0x00,
0x10, 0x00, 0x30, 0x10, 0x30, 0x48, 0x40, 0xE0, 0x40, 0x40,
0x10, 0x10, 0x90, 0x60, 0x80, 0x80, 0x88, 0x90, 0xA0, 0xD0, 0x88, 0x00, 0x40, 0x00, 0x00, 0x00, 0x34, 0x48, 0x48, 0x38, 0x08, 0x30,
0xC0, 0x40, 0x40, 0x80, 0x80, 0xB0, 0xC8, 0x88,
0x40, 0x40, 0x40, 0xE0, 0x00, 0x00, 0x00, 0xEC, 0x92, 0x92, 0x92, 0x92, 0x00, 0x88, 0x88, 0x00, 0x20, 0x00, 0x60, 0x20, 0x20, 0x20, 0x70, 0x00,
0x00, 0x00, 0x10, 0x00, 0x30, 0x10,
0xB0, 0xC8, 0x88, 0x88, 0x88, 0x00, 0x00, 0x00, 0x70, 0x88, 0x88, 0x88, 0x70, 0x00, 0x10, 0x10, 0x90, 0x60, 0x80, 0x80, 0x88, 0x90, 0xA0, 0xD0, 0x88,
0x00, 0x00,
0x00, 0xB0, 0xC8, 0xC8, 0xB0, 0x80, 0x80, 0x00, 0x00, 0x68, 0x98, 0x98, 0x68, 0x08, 0x08, 0xC0, 0x40, 0x40,
0x40, 0x40, 0x40, 0xE0, 0x00, 0x00, 0x00, 0xEC, 0x92, 0x92, 0x92,
0x92, 0x00,
0x00, 0x00,
0xB0, 0xC8, 0x88, 0x88, 0x88, 0x00, 0x00, 0x00, 0x70, 0x88, 0x88,
0x88, 0x70, 0x00,
0x00,
0x00, 0xB0, 0xC8, 0xC8, 0xB0, 0x80, 0x80, 0x00, 0x00, 0x68, 0x98,
0x98, 0x68, 0x08, 0x08,
0x00, 0x00, 0xB0, 0xC8, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x78, 0x80, 0x70, 0x08, 0xF0, 0x00, 0x00, 0xB0, 0xC8, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x78,
0x00, 0x80, 0x70, 0x08, 0xF0,
0x40, 0x40, 0xE0, 0x40, 0x40, 0x50, 0x20, 0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0x98, 0x00,
0x68, 0x00, 0x40, 0x40, 0xE0, 0x40, 0x40, 0x50, 0x20, 0x00, 0x00, 0x00, 0x88,
0x00, 0x00, 0x88, 0x88, 0x88, 0x50, 0x20, 0x00, 0x00, 0x00, 0x82, 0x82, 0x92, 0x88, 0x88, 0x98,
0x92, 0x6C, 0x00, 0x68, 0x00,
0x00, 0x00, 0x88, 0x50, 0x20, 0x50, 0x88, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x88, 0x50, 0x20, 0x00, 0x00, 0x00, 0x82,
0x98, 0x68, 0x08, 0x70, 0x82, 0x92,
0x00, 0x00, 0xF8, 0x10, 0x20, 0x40, 0xF8, 0x00, 0x10, 0x20, 0x20, 0x92, 0x6C, 0x00,
0x40, 0x20, 0x20, 0x10, 0x00, 0x00, 0x00, 0x88, 0x50, 0x20, 0x50, 0x88, 0x00, 0x00, 0x00, 0x88,
0x40, 0x40, 0x40, 0x00, 0x40, 0x40, 0x40, 0x00, 0x40, 0x20, 0x88,
0x20, 0x10, 0x20, 0x20, 0x40, 0x00, 0x98, 0x68, 0x08, 0x70,
0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x10, 0x20, 0x40, 0xF8, 0x00, 0x10, 0x20, 0x20,
0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00, 0x40, 0x20, 0x20, 0x10, 0x00,
0x3E, 0x60, 0xC0, 0x60, 0x3E, 0x08, 0x04, 0x18, 0x40, 0x40, 0x40, 0x00, 0x40, 0x40, 0x40, 0x00, 0x40, 0x20,
0x00, 0x48, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x20, 0x10, 0x20, 0x20, 0x40, 0x00,
0x18, 0x20, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x78, 0x10, 0x28, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00,
0x00, 0x48, 0x00, 0x78, 0x0C, 0x7C, 0x3E, 0x60, 0xC0, 0x60, 0x3E, 0x08, 0x04, 0x18,
0xCC, 0x76, 0x30, 0x08, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, 0x48, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76,
0x48, 0x30, 0x00, 0x78, 0x0C, 0x18, 0x20, 0x00, 0x78, 0xCC, 0xFC, 0xC0,
0x7C, 0xCC, 0x76, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x10, 0x08, 0x30, 0x78, 0x10, 0x28, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76,
0x30, 0x48, 0x84, 0x78, 0x00, 0x48, 0x00, 0x78, 0x0C, 0x7C,
0xCC, 0xFC, 0xC0, 0x78, 0x00, 0x48, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0xCC, 0x76, 0x30, 0x08, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76,
0x30, 0x08, 0x00, 0x48, 0x30, 0x00, 0x78, 0x0C,
0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, 0x48, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x7C, 0xCC, 0x76, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x10, 0x08, 0x30,
0x30, 0x48, 0x30, 0x48, 0x84, 0x78,
0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x60, 0x10, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0xCC, 0xFC, 0xC0, 0x78, 0x00, 0x48, 0x00, 0x78, 0xCC, 0xFC, 0xC0,
0x48, 0x78,
0x00, 0x30, 0x78, 0xCC, 0xCC, 0xFC, 0xCC, 0x30, 0x48, 0x30, 0x48, 0x84, 0xFC, 0x84, 0x84, 0x30, 0x08, 0x00,
0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, 0x48, 0x00, 0x30, 0x30, 0x30,
0x30, 0x30,
0x30, 0x48,
0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x60, 0x10, 0x00, 0x30, 0x30,
0x30, 0x30, 0x30,
0x48,
0x00, 0x30, 0x78, 0xCC, 0xCC, 0xFC, 0xCC, 0x30, 0x48, 0x30, 0x48,
0x84, 0xFC, 0x84, 0x84,
0x18, 0x20, 0x00, 0xF8, 0x80, 0xF0, 0x80, 0xF8, 0x00, 0x00, 0x00, 0x66, 0x19, 0x77, 0x88, 0x18, 0x20, 0x00, 0xF8, 0x80, 0xF0, 0x80, 0xF8, 0x00, 0x00, 0x00,
0x77, 0x66, 0x19, 0x77, 0x88,
0x00, 0x00, 0x00, 0x0F, 0x14, 0x3E, 0x44, 0x87, 0x30, 0x48, 0x84, 0x78, 0xCC, 0xCC, 0x77,
0xCC, 0x78, 0x00, 0x00, 0x00, 0x0F, 0x14, 0x3E, 0x44, 0x87, 0x30, 0x48, 0x84,
0x00, 0x48, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x60, 0x10, 0x00, 0x78, 0xCC, 0x78, 0xCC, 0xCC,
0xCC, 0xCC, 0x78, 0xCC, 0x78,
0x30, 0x48, 0x84, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x60, 0x10, 0x00, 0xCC, 0x00, 0x48, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x60, 0x10, 0x00,
0xCC, 0xCC, 0xCC, 0x76, 0x78, 0xCC,
0x48, 0x00, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, 0x44, 0x00, 0x38, 0xCC, 0xCC, 0x78,
0x6C, 0xC6, 0xC6, 0x6C, 0x38, 0x30, 0x48, 0x84, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x60, 0x10, 0x00,
0x24, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x08, 0xCC,
0x1C, 0x28, 0x28, 0x1C, 0x08, 0x00, 0xCC, 0xCC, 0xCC, 0x76,
0x1C, 0x22, 0x20, 0x70, 0x20, 0x22, 0x5C, 0x00, 0x44, 0x48, 0x00, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, 0x44, 0x00, 0x38,
0x28, 0x10, 0x10, 0x38, 0x10, 0x38, 0x10, 0x6C, 0xC6, 0xC6, 0x6C, 0x38,
0xF0, 0x88, 0x8A, 0xF7, 0x82, 0x82, 0x83, 0x00, 0x24, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x08,
0x06, 0x08, 0x08, 0x3C, 0x10, 0x10, 0x60, 0x00, 0x1C, 0x28, 0x28, 0x1C, 0x08, 0x00,
0x18, 0x20, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x1C, 0x22, 0x20, 0x70, 0x20, 0x22, 0x5C, 0x00, 0x44,
0x76, 0x18, 0x20, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x28, 0x10, 0x10, 0x38, 0x10, 0x38, 0x10,
0x18, 0x20, 0x00, 0x78, 0xCC, 0xCC, 0xF0, 0x88, 0x8A, 0xF7, 0x82, 0x82, 0x83, 0x00,
0xCC, 0x78, 0x18, 0x20, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x06, 0x08, 0x08, 0x3C, 0x10, 0x10, 0x60, 0x00,
0x80, 0x78, 0x04, 0xF8, 0xCC, 0x18, 0x20, 0x00, 0x78, 0x0C, 0x7C, 0xCC,
0xCC, 0xCC, 0xCC, 0x80, 0x7E, 0x01, 0xC6, 0xE6, 0xD6, 0xCE, 0xC6, 0x76, 0x18, 0x20, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30,
0x00, 0x78, 0x0C, 0x7C, 0x18, 0x20, 0x00, 0x78, 0xCC, 0xCC,
0xCC, 0x76, 0x00, 0xFE, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00, 0xFC, 0xCC, 0x78, 0x18, 0x20, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76,
0x00, 0x00, 0x18, 0x80, 0x78, 0x04, 0xF8, 0xCC,
0x18, 0x30, 0x60, 0x66, 0x3C, 0xFF, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x80, 0x7E, 0x01, 0xC6, 0xE6, 0xD6, 0xCE, 0xC6,
0xFF, 0x01, 0x00, 0x78, 0x0C, 0x7C,
0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x40, 0xC4, 0x48, 0x50, 0x26, 0x49, 0x82, 0x07, 0xCC, 0x76, 0x00, 0xFE, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00,
0x40, 0xFC,
0xC4, 0x48, 0x50, 0x26, 0x4A, 0x9F, 0x02, 0x00, 0x30, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x18,
0x18, 0x30, 0x60, 0x66, 0x3C, 0xFF, 0x80, 0x80, 0x80, 0x00, 0x00,
0x00, 0x00,
0xFF, 0x01,
0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x40, 0xC4, 0x48, 0x50, 0x26,
0x49, 0x82, 0x07,
0x40,
0xC4, 0x48, 0x50, 0x26, 0x4A, 0x9F, 0x02, 0x00, 0x30, 0x00, 0x30,
0x30, 0x30, 0x30, 0x30,
0x00, 0x12, 0x24, 0x48, 0x90, 0x48, 0x24, 0x12, 0x00, 0x48, 0x24, 0x12, 0x09, 0x12, 0x24, 0x00, 0x12, 0x24, 0x48, 0x90, 0x48, 0x24, 0x12, 0x00, 0x48, 0x24,
0x48, 0x12, 0x09, 0x12, 0x24,
0x49, 0x00, 0x92, 0x00, 0x49, 0x00, 0x92, 0x00, 0x6D, 0x00, 0xB6, 0x00, 0x6D, 0x00, 0x48,
0xB6, 0x00, 0x49, 0x00, 0x92, 0x00, 0x49, 0x00, 0x92, 0x00, 0x6D, 0x00, 0xB6,
0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x6D, 0x00,
0x10, 0x10, 0x10, 0xB6, 0x00,
0x10, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xF0, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0x10, 0x10, 0x10,
0x10, 0xF0, 0x10, 0x10, 0x10, 0x10,
0x28, 0x28, 0x28, 0x28, 0xE8, 0x28, 0x28, 0x28, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10,
0x00, 0xF8, 0x28, 0x28, 0x28, 0x10, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x00, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x10, 0x10, 0x28, 0x28, 0xF0,
0x28, 0xE8, 0x08, 0xE8, 0x28, 0x28, 0x10, 0xF0, 0x10, 0x10,
0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x00, 0x28, 0x28, 0x28, 0x28, 0xE8, 0x28, 0x28, 0x28, 0x00, 0x00, 0x00,
0x00, 0x00, 0xF8, 0x08, 0xE8, 0x28, 0x28, 0x00, 0xF8, 0x28, 0x28, 0x28,
0x28, 0x28, 0x28, 0xE8, 0x08, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x10, 0x10, 0x28, 0x28,
0x28, 0x28, 0x28, 0x28, 0xF8, 0x00, 0x00, 0x00, 0x28, 0xE8, 0x08, 0xE8, 0x28, 0x28,
0x10, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0x10, 0x10, 0x00, 0x00, 0xF8, 0x08, 0xE8, 0x28, 0x28,
0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x28, 0x28, 0x28, 0xE8, 0x08, 0xF8, 0x00, 0x00,
0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x00, 0x00, 0x28, 0x28, 0x28, 0x28, 0xF8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0x10, 0x10,
0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00,
0xFF, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x00, 0x00,
0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x1F, 0x10, 0x1F, 0x10, 0x10, 0x28, 0x28, 0x28, 0x28, 0x3F, 0x28, 0x28, 0x28, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x10, 0x10, 0x10,
0x28, 0x28, 0x00, 0x00, 0x00, 0x00,
0x28, 0x2F, 0x20, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x20, 0x2F, 0x28, 0x28, 0xFF, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x10,
0x28, 0x10,
0x28, 0x28, 0xEF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xEF, 0x28, 0x28, 0x10, 0x10, 0x10,
0x1F, 0x10, 0x1F, 0x10, 0x10, 0x28, 0x28, 0x28, 0x28, 0x3F, 0x28,
0x28, 0x28,
0x28, 0x28,
0x28, 0x2F, 0x20, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x20,
0x2F, 0x28, 0x28,
0x28,
0x28, 0x28, 0xEF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x00, 0xEF, 0x28, 0x28,
0x28, 0x28, 0x28, 0x2F, 0x20, 0x2F, 0x28, 0x28, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x28, 0x28, 0x28, 0x2F, 0x20, 0x2F, 0x28, 0x28, 0x00, 0x00, 0x00,
0x00, 0xFF, 0x00, 0xFF, 0x00,
0x28, 0x28, 0x28, 0xEF, 0x00, 0xEF, 0x28, 0x28, 0x10, 0x10, 0x10, 0xFF, 0x00, 0xFF, 0x00,
0x00, 0x00, 0x28, 0x28, 0x28, 0xEF, 0x00, 0xEF, 0x28, 0x28, 0x10, 0x10, 0x10,
0x28, 0x28, 0x28, 0x28, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF,
0xFF, 0x10, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3F, 0x00, 0x00, 0x00, 0xFF, 0x00,
0x10, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10,
0x1F, 0x10, 0x1F, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
0x00, 0x00, 0x00, 0x00, 0x3F, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
0x28, 0x28, 0xFF, 0x28, 0x28, 0x28, 0x3F, 0x00, 0x00, 0x00,
0x10, 0x10, 0x10, 0xFF, 0x10, 0xFF, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x1F, 0x10, 0x10,
0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x28, 0x28, 0x28, 0x28, 0x28,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x28, 0x28, 0xFF, 0x28, 0x28, 0x28,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x10, 0x10, 0x10, 0xFF, 0x10, 0xFF, 0x10, 0x10, 0x10,
0x00, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10,
0x07, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0x00, 0x00, 0x02, 0x34, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
0x4C, 0x4C, 0x32, 0x00, 0x5C, 0x22, 0x22, 0x3C, 0x44, 0x44, 0x78, 0x00, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0,
0x7E, 0x42, 0x42, 0x40, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x02, 0x7C, 0xA8, 0x28, 0x28, 0x44, 0x07, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7E, 0x61, 0x00, 0x00, 0x00, 0x02, 0x34,
0x30, 0x18, 0x08, 0x10, 0x20, 0x00, 0x00, 0x08, 0x7F, 0x88, 0x88, 0x88, 0x70, 0x4C, 0x4C, 0x32, 0x00, 0x5C, 0x22, 0x22, 0x3C, 0x44, 0x44, 0x78,
0x00, 0x00, 0x7E, 0x42, 0x42, 0x40,
0x00, 0x22, 0x44, 0x44, 0x7A, 0x80, 0x00, 0x00, 0x00, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x02, 0x7C, 0xA8, 0x28, 0x28,
0x00, 0x44,
0x1C, 0x08, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x00, 0x38, 0x44, 0x44, 0x7C, 0x44, 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, 0x3C, 0x66, 0xC3, 0xC3, 0xC3, 0x66, 0x24, 0x66, 0x0C, 0x10, 0x08,
0x1C, 0x1C, 0x22, 0x22, 0x22,
0x00, 0x00, 0x00, 0x00, 0x6C, 0x92, 0x92, 0x6C, 0x00, 0x01, 0x1A, 0x26, 0x2A, 0x32, 0x1C,
0x2C, 0x40, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x92, 0x92, 0x6C, 0x00, 0x01, 0x1A,
0x00, 0x18, 0x20, 0x20, 0x30, 0x20, 0x20, 0x18, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x26, 0x2A, 0x32,
0x42, 0x42, 0x42, 0x2C, 0x40,
0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x08, 0x08, 0x3E, 0x00, 0x18, 0x20, 0x20, 0x30, 0x20, 0x20, 0x18, 0x00, 0x3C, 0x42,
0x08, 0x08, 0x00, 0x3E, 0x42, 0x42,
0x00, 0x10, 0x08, 0x04, 0x08, 0x10, 0x00, 0x3E, 0x00, 0x04, 0x08, 0x42, 0x42, 0x42,
0x10, 0x08, 0x04, 0x00, 0x3E, 0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x08, 0x08,
0x00, 0x06, 0x09, 0x09, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x3E,
0x08, 0x08, 0x08, 0x48, 0x48, 0x30, 0x08, 0x08, 0x00, 0x3E,
0x00, 0x00, 0x08, 0x00, 0x3E, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x08, 0x04, 0x08, 0x10, 0x00, 0x3E, 0x00, 0x04, 0x08,
0x60, 0x92, 0x0C, 0x60, 0x92, 0x0C, 0x00, 0x10, 0x08, 0x04, 0x00, 0x3E,
0x60, 0x90, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x09, 0x09, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x30, 0x78, 0x30, 0x00, 0x00, 0x08, 0x08, 0x08, 0x48, 0x48, 0x30,
0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3E, 0x00, 0x08, 0x00, 0x00,
0x00, 0x00, 0x03, 0x04, 0x04, 0xC8, 0x28, 0x10, 0x00, 0x60, 0x92, 0x0C, 0x60, 0x92, 0x0C, 0x00,
0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x60, 0x90, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
0x42, 0x00, 0x18, 0x24, 0x08, 0x10, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x78, 0x30, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3E, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
0x3E, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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},
}; };
@ -27,7 +27,8 @@ static vgamode modes[] = {
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,
0x3B,
0x3C, 0x3D, 0x3E, 0x3F, 0x3C, 0x3D, 0x3E, 0x3F,
0x0C, 0x00, 0x0F, 0x08, 0x00}}, 0x0C, 0x00, 0x0F, 0x08, 0x00}},
@ -38,7 +39,8 @@ static vgamode modes[] = {
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,
0x3B,
0x3C, 0x3D, 0x3E, 0x3F, 0x3C, 0x3D, 0x3E, 0x3F,
0x0C, 0x00, 0x0F, 0x00, 0x00}}, 0x0C, 0x00, 0x0F, 0x00, 0x00}},
@ -49,7 +51,8 @@ static vgamode modes[] = {
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,
0x3B,
0x3C, 0x3D, 0x3E, 0x3F, 0x3C, 0x3D, 0x3E, 0x3F,
0x01, 0x00, 0x0F, 0x00, 0x00}}, 0x01, 0x00, 0x0F, 0x00, 0x00}},
@ -60,7 +63,8 @@ static vgamode modes[] = {
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,
0x3B,
0x3C, 0x3D, 0x3E, 0x3F, 0x3C, 0x3D, 0x3E, 0x3F,
0x01, 0x00, 0x03, 0x00, 0x00}}, 0x01, 0x00, 0x03, 0x00, 0x00}},
@ -71,7 +75,8 @@ static vgamode modes[] = {
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,
0x3B,
0x3C, 0x3D, 0x3E, 0x3F, 0x3C, 0x3D, 0x3E, 0x3F,
0x01, 0x00, 0x0F, 0x00, 0x00}}, 0x01, 0x00, 0x0F, 0x00, 0x00}},
@ -82,7 +87,8 @@ static vgamode modes[] = {
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,
0x0B,
0x0C, 0x0D, 0x0E, 0x0F, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00}}, 0x41, 0x00, 0x0F, 0x00, 0x00}},
@ -93,7 +99,8 @@ static vgamode modes[] = {
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,
0x0B,
0x0C, 0x0D, 0x0E, 0x0F, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00}}, 0x41, 0x00, 0x0F, 0x00, 0x00}},
@ -104,7 +111,8 @@ static vgamode modes[] = {
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,
0x0B,
0x0C, 0x0D, 0x0E, 0x0F, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00}}, 0x41, 0x00, 0x0F, 0x00, 0x00}},
@ -115,7 +123,8 @@ static vgamode modes[] = {
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,
0x0B,
0x0C, 0x0D, 0x0E, 0x0F, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00}}, 0x41, 0x00, 0x0F, 0x00, 0x00}},
}; };

238
lib/cpu.c
View File

@ -56,7 +56,8 @@ 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,
regecx, regedx;
bool *boolean; bool *boolean;
if (!cansetflag(0x00040000)) if (!cansetflag(0x00040000))
@ -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; int i;
for (i = 0; i < 3; 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,64 +139,77 @@ 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",
stack->cs, stack->ds, stack->ss, stack->es, stack->fs,
stack->gs);
printf("CR0=%Y CR2=%Y CR3=%Y CR4=%Y\r\n\r\n\r\n", stack->cr0,
stack->cr2, stack->cr3, stack->cr4);
u8* size; u8 *size;
u8* pointer; u8 *pointer;
for(i=20;i<50;i++) { for (i = 20; i < 50; i++)
pointer=stack->eip-i;
size=pointer;
size+=50;
while(pointer<size) {
pointer+=disasm(pointer, NULL, false);
if (pointer==stack->eip) break;
}
if (pointer==stack->eip) break;
}
if (pointer==stack->eip)
pointer=stack->eip-i;
else
pointer=stack->eip;
size=pointer;
size+=50;
while(pointer<size)
{ {
if (pointer==stack->eip) pointer = stack->eip - i;
size = pointer;
size += 50;
while (pointer < size)
{
pointer += disasm(pointer, NULL, false);
if (pointer == stack->eip)
break;
}
if (pointer == stack->eip)
break;
}
if (pointer == stack->eip)
pointer = stack->eip - i;
else
pointer = stack->eip;
size = pointer;
size += 50;
while (pointer < size)
{
if (pointer == stack->eip)
print("\33[41m\33[1m"); print("\33[41m\33[1m");
else else
print("\33[40m\33[0m"); print("\33[40m\33[0m");
pointer+=disasm(pointer, NULL, true); 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) {
if (i > 0 && i % 10 == 0)
print("\033[10A");
if (i >= 10)
print("\033[25C"); print("\033[25C");
printf("+%d:%Y - %Y\r\n", i++, pointer, (u32)(*pointer)); printf("+%d:%Y - %Y\r\n", i++, pointer,
(u32) (*pointer));
} }
for(u32 j=0;j<10-(i % 10);j++) for (u32 j = 0; j < 10 - (i % 10); j++)
print("\033[01B"); print("\033[01B");
} }
} }
@ -194,52 +217,93 @@ void show_lightcpu(regs *stack)
/******************************************************************************/ /******************************************************************************/
/* 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),
getdesbit2(stack->cs), getdesbit1(stack->cs),
getdesalign(stack->cs));
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; u32 tss;
str(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)); 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) {
if (i > 0 && i % 10 == 0)
print("\033[10A");
if (i >= 10)
print("\033[25C"); print("\033[25C");
printf("+%d:%Y - %Y\r\n", i++, pointer, (u32)(*pointer)); printf("+%d:%Y - %Y\r\n", i++, pointer,
(u32) (*pointer));
} }
for(u32 j=0;j<10-(i % 10);j++) for (u32 j = 0; j < 10 - (i % 10); j++)
print("\033[01B"); print("\033[01B");
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@ void initgdt(u32 offset)
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)
&& ((entry[index].acces & 0x08) > 0)
&& ((entry[index].acces & 0x01) > 0)
&& ((entry[index].flags & 0x06) == 0))
return 'T'; return 'T';
else else
return (((entry[index].acces & 0b1000) > 0) ? 'C' : 'D'); 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)
&& ((entry[index].acces & 0x01) > 0)
&& ((entry[index].flags & 0x06) == 0))
return (((entry[index].acces & 0x04) > 0) ? 'B' : '-');
else else
return (((entry[index].acces & 0b1) > 0) ? 'A' : '-'); 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))
return (((entry[index].flags & 0x01) > 0) ? 'U' : '-');
else if ((entry[index].acces & 0x8) > 0)
return (((entry[index].acces & 0x02) > 0) ? 'R' : '-');
else else
return (((entry[index].acces & 0b10) > 0) ? 'W' : 'R'); 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)
&& ((entry[index].acces & 0x08) > 0)
&& ((entry[index].acces & 0x01) > 0)
&& ((entry[index].flags & 0x06) == 0))
return 32; return 32;
else else
return (((entry[index].flags & 0b1000) > 0) ? 32 : 16); 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;
} }
/******************************************************************************/ /******************************************************************************/
@ -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();
}*/ } */
} }
/******************************************************************************/ /******************************************************************************/
@ -182,11 +183,11 @@ void exception0()
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()
@ -198,24 +199,26 @@ void exception1()
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);
else if (ascii == 'S' || ascii == 's')
{ {
changevc(0); changevc(0);
sti(); sti();
@ -234,11 +237,11 @@ void exception2()
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()
@ -249,11 +252,11 @@ void exception3()
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()
@ -264,11 +267,11 @@ void exception4()
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()
@ -279,11 +282,11 @@ void exception5()
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()
@ -294,11 +297,11 @@ void exception6()
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()
@ -309,11 +312,11 @@ void exception7()
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()
@ -324,11 +327,11 @@ void exception8()
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()
@ -339,11 +342,11 @@ void exception9()
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()
@ -354,11 +357,11 @@ void exception10()
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()
@ -369,11 +372,11 @@ void exception11()
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()
@ -384,11 +387,11 @@ void exception12()
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()
@ -399,22 +402,32 @@ void exception13()
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()
{ {
@ -424,17 +437,22 @@ void exception14()
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),
PAGESIZE, PAGE_ALL);
} }
else { else
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); 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(); restdebugcpu();
iret(); iret();
@ -448,11 +466,11 @@ void exception15()
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()
@ -463,11 +481,11 @@ void exception16()
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()
@ -478,11 +496,11 @@ void exception17()
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()
@ -493,11 +511,11 @@ void exception18()
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();
@ -743,49 +761,90 @@ 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);

View File

@ -103,12 +103,16 @@ 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);
} }
@ -123,7 +127,7 @@ 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];
} }
@ -136,7 +140,8 @@ void outkbd(u8 port, u8 data)
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)
@ -154,13 +159,16 @@ 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)
@ -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,41 +210,54 @@ 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; regs dump;
show_cpu(&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 */
@ -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];
@ -329,10 +357,11 @@ void keyboard(void)
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

@ -8,25 +8,21 @@
/*******************************************************************************/ /*******************************************************************************/
/* 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) while ((long long) den >= 0)
{ {
den <<= 1; den <<= 1;
qbit <<= 1; qbit <<= 1;
} }
while (qbit) while (qbit)
{ {
if (den <= num) if (den <= num)
@ -37,43 +33,57 @@ unsigned long long __udivdi3 (unsigned long long num, unsigned long long den)
den >>= 1; den >>= 1;
qbit >>= 1; qbit >>= 1;
} }
return quot; return quot;
} }
unsigned long long __umoddi3 (unsigned long long n, unsigned long long d) unsigned long long __umoddi3(unsigned long long n, unsigned long long d)
{ {
return n - d * __udivdi3 (n, d); return n - d * __udivdi3(n, d);
} }
/******************************************************************************/ /******************************************************************************/
/* Fonctions qui retournent le sinus et cosinus */ /* Fonctions qui retournent le sinus et cosinus */
double cos(double x){ double cos(double x)
if( x < 0.0 ) {
if (x < 0.0)
x = -x; x = -x;
while( M_PI < x ) while (M_PI < x)
x -= M_2_PI; x -= M_2_PI;
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 ))); 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)));
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){ float cosf(float x)
if( x < 0.0f ) {
if (x < 0.0f)
x = -x; x = -x;
while( M_PI < x ) while (M_PI < x)
x -= M_2_PI; x -= M_2_PI;
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 ))); 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)));
return result; return result;
} }
float sinf(float x){ float sinf(float x)
return cosf(x-M_PI_2); {
return cosf(x - M_PI_2);
} }
/******************************************************************************/ /******************************************************************************/
@ -94,28 +104,26 @@ double fabs(double n)
float sqrtf(float n) float sqrtf(float n)
{ {
float x = n; float x = n;
float y = 1; float y = 1;
double e = 0.000001; double e = 0.000001;
while(x - y > e) while (x - y > e)
{ {
x = (x + y)/2; x = (x + y) / 2;
y = n/x; y = n / x;
} }
return x; return x;
} }
double sqrt(double n) double sqrt(double n)
{ {
double x = n; double x = n;
double y = 1; double y = 1;
double e = 0.000001; double e = 0.000001;
while(x - y > e) while (x - y > e)
{ {
x = (x + y)/2; x = (x + y) / 2;
y = n/x; y = n / x;
} }
return x; return x;
} }
@ -136,9 +144,11 @@ double rsqrt(double n)
/******************************************************************************/ /******************************************************************************/
/* Fonction qui retourne la puissance n de a */ /* Fonction qui retourne la puissance n de a */
u32 pow(u32 a, u8 n) { u32 pow(u32 a, u8 n)
{
u32 r = 1; u32 r = 1;
while (n > 0) { while (n > 0)
{
if (n & 1) if (n & 1)
r *= a; r *= a;
a *= a; a *= a;
@ -152,22 +162,18 @@ u32 pow(u32 a, u8 n) {
u8 log2(u64 n) u8 log2(u64 n)
{ {
if (n == 0)
if (n == 0)
return 0; return 0;
int logValue = -1;
while (n)
{
int logValue = -1; logValue++;
while (n) { n >>= 1;
logValue++;
n >>= 1;
}
return logValue + 1;
}
return logValue + 1;
} }
/******************************************************************************/ /******************************************************************************/
@ -176,15 +182,22 @@ return logValue + 1;
u8 log10(u64 n) u8 log10(u64 n)
{ {
return (n >= 10000000000000000000u) ? 19 : (n >= 100000000000000000u) ? 18 : return (n >= 10000000000000000000u) ? 19 : (n >=
(n >= 100000000000000000u) ? 17 : (n >= 10000000000000000u) ? 16 : 100000000000000000u) ?
(n >= 1000000000000000u) ? 15 : (n >= 100000000000000u) ? 14 : 18 : (n >= 100000000000000000u) ? 17 : (n >=
(n >= 10000000000000u) ? 13 : (n >= 1000000000000u) ? 12 : 10000000000000000u)
(n >= 100000000000u) ? 11 : (n >= 10000000000u) ? 10 : ? 16 : (n >= 1000000000000000u) ? 15 : (n >=
(n >= 1000000000u) ? 9 : (n >= 100000000u) ? 8 : 100000000000000u) ?
(n >= 10000000u) ? 7 : (n >= 1000000u) ? 6 : 14 : (n >= 10000000000000u) ? 13 : (n >=
(n >= 100000u) ? 5 : (n >= 10000u) ? 4 : 1000000000000u) ? 12
(n >= 1000u) ? 3 : (n >= 100u) ? 2 : (n >= 10u) ? 1u : 0u; : (n >= 100000000000u) ? 11 : (n >=
10000000000u) ? 10 : (n >=
1000000000u)
? 9 : (n >= 100000000u) ? 8 : (n >= 10000000u) ? 7 : (n >=
1000000u)
? 6 : (n >= 100000u) ? 5 : (n >= 10000u) ? 4 : (n >=
1000u) ? 3
: (n >= 100u) ? 2 : (n >= 10u) ? 1u : 0u;
} }
@ -194,13 +207,11 @@ return (n >= 10000000000000000000u) ? 19 : (n >= 100000000000000000u) ? 18 :
u32 abs(int x) u32 abs(int x)
{ {
if (x < 0)
if (x < 0) x = -x;
x = -x;
return (u32) x;
return (u32) x;
} }
/******************************************************************************/ /******************************************************************************/
@ -208,12 +219,9 @@ return (u32) x;
static u32 seed = 0x12341234; static u32 seed = 0x12341234;
void randomize(void) void randomize(void)
{ {
seed = gettimer();
seed = gettimer();
} }
@ -222,22 +230,21 @@ seed = gettimer();
u32 rand(void) u32 rand(void)
{ {
u32 next = seed; u32 next = seed;
int result; int result;
next *= 1103515245; next *= 1103515245;
next += 12345; next += 12345;
result = (unsigned int)(next / 65536) % 2048; result = (unsigned int) (next / 65536) % 2048;
next *= 1103515245; next *= 1103515245;
next += 12345; next += 12345;
result <<= 10; result <<= 10;
result ^= (unsigned int)(next / 65536) % 1024; result ^= (unsigned int) (next / 65536) % 1024;
next *= 1103515245; next *= 1103515245;
next += 12345; next += 12345;
result <<= 10; result <<= 10;
result ^= (unsigned int)(next / 65536) % 1024; result ^= (unsigned int) (next / 65536) % 1024;
seed = next; seed = next;
return result; return result;
} }
/******************************************************************************/ /******************************************************************************/
@ -245,7 +252,7 @@ return result;
u32 random(u32 lower, u32 upper) u32 random(u32 lower, u32 upper)
{ {
return (rand() % (upper - lower + 1)) + lower; return (rand() % (upper - lower + 1)) + lower;
} }
/*******************************************************************************/ /*******************************************************************************/

View File

@ -10,13 +10,14 @@
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;
@ -27,7 +28,7 @@ void vector4_create(float x, float y, float z, float w, vector4 *dst)
/*******************************************************************************/ /*******************************************************************************/
/* 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);
} }
@ -35,7 +36,7 @@ void vector4_copy(vector4 src, vector4 *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;
@ -45,7 +46,7 @@ void vector4_add(vector4 v1, vector4 v2, vector4 *dst)
/*******************************************************************************/ /*******************************************************************************/
/* 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;
@ -55,7 +56,7 @@ void vector4_sub(vector4 v1, vector4 v2, vector4 *dst)
/*******************************************************************************/ /*******************************************************************************/
/* 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;
@ -66,7 +67,7 @@ void vector4_scale(vector4 *dst, float 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;
@ -76,7 +77,7 @@ void vector4_crossproduct(vector4 v1, vector4 v2, vector4 *dst)
/*******************************************************************************/ /*******************************************************************************/
/* 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;
@ -94,7 +95,7 @@ void vector4_normalize(vector4 *dst)
/*******************************************************************************/ /*******************************************************************************/
/* 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;
@ -104,7 +105,7 @@ void vector4_divide(vector4 *v1, vector4 v2, vector4 *dst)
/*******************************************************************************/ /*******************************************************************************/
/* 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;
@ -115,7 +116,7 @@ void vector4_perpendicular(vector4 v1, vector4 v2, vector4 *dst)
/*******************************************************************************/ /*******************************************************************************/
/* 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;
@ -131,7 +132,7 @@ void vector4_rotate_x(vector4 *dst, float angle)
/*******************************************************************************/ /*******************************************************************************/
/* 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;
@ -147,7 +148,7 @@ void vector4_rotate_y(vector4 *dst, float angle)
/*******************************************************************************/ /*******************************************************************************/
/* 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;
@ -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));
} }
/*******************************************************************************/ /*******************************************************************************/
@ -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,8 +190,7 @@ 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));
} }
@ -213,7 +209,7 @@ int vector4_isequals(vector4 v1, vector4 v2)
/*******************************************************************************/ /*******************************************************************************/
/* 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);
@ -225,7 +221,7 @@ void vector4_planenormal(vector4 v1, vector4 v2, vector4 v3, vector4 *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]);
@ -236,7 +232,7 @@ void matrix44_homogen(matrix44 *matrix)
/*******************************************************************************/ /*******************************************************************************/
/* 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]);
@ -247,7 +243,7 @@ void matrix44_empty(matrix44 *matrix)
/*******************************************************************************/ /*******************************************************************************/
/* 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;
@ -258,7 +254,7 @@ void matrix44_scaling(vector4 v, matrix44 *dst)
/*******************************************************************************/ /*******************************************************************************/
/* 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;
@ -269,7 +265,7 @@ void matrix44_translation(vector4 v, matrix44 *dst)
/*******************************************************************************/ /*******************************************************************************/
/* 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);
@ -280,7 +276,8 @@ void matrix44_scale(matrix44 *dst, float 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;
@ -294,9 +291,9 @@ void matrix44_scale_translation(vector4 scale, vector4 translation, matrix44 *ds
/*******************************************************************************/ /*******************************************************************************/
/* 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);
@ -311,9 +308,9 @@ void matrix44_rotation_x(float angle, matrix44 *dst)
/*******************************************************************************/ /*******************************************************************************/
/* 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);
@ -328,9 +325,9 @@ void matrix44_rotation_y(float angle, matrix44 *dst)
/*******************************************************************************/ /*******************************************************************************/
/* 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);
@ -345,7 +342,7 @@ void matrix44_rotation_z(float angle, matrix44 *dst)
/*******************************************************************************/ /*******************************************************************************/
/* 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);
@ -377,90 +374,122 @@ void matrix44_rotation(vector4 axis, float angle, matrix44 *dst)
/*******************************************************************************/ /*******************************************************************************/
/* 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].x * m2->V[0].x + m1->V[0].y * m2->V[1].x +
m1->V[0].z * m2->V[2].x + m1->V[0].w * m2->V[3].x); m1->V[0].z * m2->V[2].x + m1->V[0].w * m2->V[3].x);
dst->V[0].y = (m1->V[0].x * m2->V[0].y + m1->V[0].y * m2->V[1].y + 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].y + m1->V[0].w * m2->V[3].y); m1->V[0].z * m2->V[2].y + m1->V[0].w * m2->V[3].y);
dst->V[0].z = (m1->V[0].x * m2->V[0].z + m1->V[0].y * m2->V[1].z + dst->V[0].z =
(m1->V[0].x * m2->V[0].z + m1->V[0].y * m2->V[1].z +
m1->V[0].z * m2->V[2].z + m1->V[0].w * m2->V[3].z); m1->V[0].z * m2->V[2].z + m1->V[0].w * m2->V[3].z);
dst->V[0].w = (m1->V[0].x * m2->V[0].w + m1->V[0].y * m2->V[1].w + dst->V[0].w =
(m1->V[0].x * m2->V[0].w + m1->V[0].y * m2->V[1].w +
m1->V[0].z * m2->V[2].w + m1->V[0].w * m2->V[3].w); m1->V[0].z * m2->V[2].w + m1->V[0].w * m2->V[3].w);
dst->V[1].x = (m1->V[1].x * m2->V[0].x + m1->V[1].y * m2->V[1].x + dst->V[1].x =
(m1->V[1].x * m2->V[0].x + m1->V[1].y * m2->V[1].x +
m1->V[1].z * m2->V[2].x + m1->V[1].w * m2->V[3].x); m1->V[1].z * m2->V[2].x + m1->V[1].w * m2->V[3].x);
dst->V[1].y = (m1->V[1].x * m2->V[0].y + m1->V[1].y * m2->V[1].y + dst->V[1].y =
(m1->V[1].x * m2->V[0].y + m1->V[1].y * m2->V[1].y +
m1->V[1].z * m2->V[2].y + m1->V[1].w * m2->V[3].y); m1->V[1].z * m2->V[2].y + m1->V[1].w * m2->V[3].y);
dst->V[1].z = (m1->V[1].x * m2->V[0].z + m1->V[1].y * m2->V[1].z + dst->V[1].z =
(m1->V[1].x * m2->V[0].z + m1->V[1].y * m2->V[1].z +
m1->V[1].z * m2->V[2].z + m1->V[1].w * m2->V[3].z); m1->V[1].z * m2->V[2].z + m1->V[1].w * m2->V[3].z);
dst->V[1].w = (m1->V[1].x * m2->V[0].w + m1->V[1].y * m2->V[1].w + 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].w + m1->V[1].w * m2->V[3].w); m1->V[1].z * m2->V[2].w + m1->V[1].w * m2->V[3].w);
dst->V[2].x = (m1->V[2].x * m2->V[0].x + m1->V[2].y * m2->V[1].x + dst->V[2].x =
(m1->V[2].x * m2->V[0].x + m1->V[2].y * m2->V[1].x +
m1->V[2].z * m2->V[2].x + m1->V[2].w * m2->V[3].x); m1->V[2].z * m2->V[2].x + m1->V[2].w * m2->V[3].x);
dst->V[2].y = (m1->V[2].x * m2->V[0].y + m1->V[2].y * m2->V[1].y + dst->V[2].y =
(m1->V[2].x * m2->V[0].y + m1->V[2].y * m2->V[1].y +
m1->V[2].z * m2->V[2].y + m1->V[2].w * m2->V[3].y); m1->V[2].z * m2->V[2].y + m1->V[2].w * m2->V[3].y);
dst->V[2].z = (m1->V[2].x * m2->V[0].z + m1->V[2].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[2].z * m2->V[2].z + m1->V[2].w * m2->V[3].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 + 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); 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 + 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); 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 + 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); 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 + 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); 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 + 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); 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,
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; 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,
d4;
a1 = matrix->V[0].x; a1 = matrix->V[0].x;
b1 = matrix->V[0].y; b1 = matrix->V[0].y;
c1 = matrix->V[0].z; c1 = matrix->V[0].z;
@ -482,40 +511,51 @@ void matrix44_adjoint(matrix44 *matrix)
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 =
-todeterminant(a2, a3, a4, c2, c3, c4, d2, d3, d4);
matrix->V[2].x = todeterminant(a2, a3, a4, b2, b3, b4, d2, d3, d4); 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[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 =
-todeterminant(b1, b3, b4, c1, c3, c4, d1, d3, d4);
matrix->V[1].y = todeterminant(a1, a3, a4, c1, c3, c4, d1, d3, d4); matrix->V[1].y = todeterminant(a1, a3, a4, c1, c3, c4, d1, d3, d4);
matrix->V[2].y = -todeterminant(a1, a3, a4, b1, b3, b4, d1, d3, d4); 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[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 =
-todeterminant(a1, a2, a4, c1, c2, c4, d1, d2, d4);
matrix->V[2].z = todeterminant(a1, a2, a4, b1, b2, b4, d1, d2, d4); 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[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 =
-todeterminant(b1, b2, b3, c1, c2, c3, d1, d2, d3);
matrix->V[1].w = todeterminant(a1, a2, a3, c1, c2, c3, d1, d2, d3); matrix->V[1].w = todeterminant(a1, a2, a3, c1, c2, c3, d1, d2, d3);
matrix->V[2].w = -todeterminant(a1, a2, a3, b1, b2, b3, d1, d2, d3); 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); 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);
@ -533,7 +573,7 @@ void matrix44_invert(matrix44 *matrix)
/*******************************************************************************/ /*******************************************************************************/
/* 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;
@ -564,7 +604,8 @@ void matrix44_transpose(matrix44 *matrix)
/*******************************************************************************/ /*******************************************************************************/
/* 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);
@ -595,16 +636,18 @@ void matrix44_lookat(vector4 eye, vector4 dst, vector4 up, matrix44 *matrix)
/*******************************************************************************/ /*******************************************************************************/
/* 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;
} }

View File

@ -7,13 +7,13 @@
#include "queue.h" #include "queue.h"
#include "asm.h" #include "asm.h"
static u8 *kernelcurrentheap=NULL; /* pointeur vers le heap noyau */ static u8 *kernelcurrentheap = NULL; /* pointeur vers le heap noyau */
static u8 bitmap[MAXMEMPAGE / 8]; /* bitmap */ static u8 bitmap[MAXMEMPAGE / 8]; /* bitmap */
static vrange_t vrange_head; static vrange_t vrange_head;
/*******************************************************************************/ /*******************************************************************************/
/* Erreur fatale */ /* Erreur fatale */
void panic(u8 *string) void panic(u8 * string)
{ {
printf("KERNEL PANIC: %s\r\nSysteme arrete...\n"); printf("KERNEL PANIC: %s\r\nSysteme arrete...\n");
halt(); halt();
@ -26,10 +26,10 @@ tmalloc *mallocpage(u64 size)
{ {
tmalloc *chunk; tmalloc *chunk;
u8 *paddr; u8 *paddr;
u16 nbpages=size / PAGESIZE; u16 nbpages = size / PAGESIZE;
u64 realsize=nbpages * PAGESIZE; u64 realsize = nbpages * PAGESIZE;
if (size%PAGESIZE!=0) if (size % PAGESIZE != 0)
realsize+=PAGESIZE; realsize += PAGESIZE;
if ((kernelcurrentheap - KERNEL_HEAP + realsize) > MAXHEAPSIZE) if ((kernelcurrentheap - KERNEL_HEAP + realsize) > MAXHEAPSIZE)
panic("Plus de memoire noyau heap disponible a allouer !\n"); panic("Plus de memoire noyau heap disponible a allouer !\n");
chunk = (tmalloc *) kernelcurrentheap; chunk = (tmalloc *) kernelcurrentheap;
@ -45,12 +45,13 @@ tmalloc *mallocpage(u64 size)
u32 getmallocnb(void) u32 getmallocnb(void)
{ {
u32 realsize=0; u32 realsize = 0;
tmalloc *chunk; tmalloc *chunk;
chunk = KERNEL_HEAP; chunk = KERNEL_HEAP;
while (chunk < (tmalloc *) kernelcurrentheap) { while (chunk < (tmalloc *) kernelcurrentheap)
{
realsize++; realsize++;
chunk = (tmalloc *)((u8 *) chunk + chunk->size); chunk = (tmalloc *) ((u8 *) chunk + chunk->size);
} }
return realsize; return realsize;
} }
@ -61,13 +62,14 @@ u32 getmallocnb(void)
u32 getmallocused(void) u32 getmallocused(void)
{ {
u32 realsize=0; u32 realsize = 0;
tmalloc *chunk; tmalloc *chunk;
chunk = KERNEL_HEAP; chunk = KERNEL_HEAP;
while (chunk < (tmalloc *) kernelcurrentheap) { while (chunk < (tmalloc *) kernelcurrentheap)
{
if (chunk->used) if (chunk->used)
realsize+=chunk->size; realsize += chunk->size;
chunk = (tmalloc *)((u8 *) chunk + chunk->size); chunk = (tmalloc *) ((u8 *) chunk + chunk->size);
} }
return realsize; return realsize;
} }
@ -77,13 +79,14 @@ u32 getmallocused(void)
u32 getmallocfree(void) u32 getmallocfree(void)
{ {
u32 realsize=0; u32 realsize = 0;
tmalloc *chunk; tmalloc *chunk;
chunk = KERNEL_HEAP; chunk = KERNEL_HEAP;
while (chunk < (tmalloc *) kernelcurrentheap) { while (chunk < (tmalloc *) kernelcurrentheap)
{
if (!chunk->used) if (!chunk->used)
realsize+=chunk->size; realsize += chunk->size;
chunk = (tmalloc *)((u8 *) chunk + chunk->size); chunk = (tmalloc *) ((u8 *) chunk + chunk->size);
} }
return realsize; return realsize;
} }
@ -93,7 +96,7 @@ u32 getmallocfree(void)
u32 getmallocnonallocated(void) u32 getmallocnonallocated(void)
{ {
return VESA_FBMEM-((u32) kernelcurrentheap); return VESA_FBMEM - ((u32) kernelcurrentheap);
} }
/*******************************************************************************/ /*******************************************************************************/
@ -107,19 +110,25 @@ void *vmalloc(u32 size)
if (realsize < MALLOC_MINIMUM) if (realsize < MALLOC_MINIMUM)
realsize = MALLOC_MINIMUM; realsize = MALLOC_MINIMUM;
chunk = KERNEL_HEAP; chunk = KERNEL_HEAP;
while (chunk->used || chunk->size < realsize) { while (chunk->used || chunk->size < realsize)
{
if (chunk->size == 0) if (chunk->size == 0)
panic(sprintf("Element du heap %x defectueux avec une taille nulle (heap %x) !",chunk, kernelcurrentheap)); panic(sprintf
chunk = (tmalloc *)((u8 *) chunk + chunk->size); ("Element du heap %x defectueux avec une taille nulle (heap %x) !",
chunk, kernelcurrentheap));
chunk = (tmalloc *) ((u8 *) chunk + chunk->size);
if (chunk == (tmalloc *) kernelcurrentheap) if (chunk == (tmalloc *) kernelcurrentheap)
mallocpage(realsize); mallocpage(realsize);
else if (chunk > (tmalloc *) kernelcurrentheap) else if (chunk > (tmalloc *) kernelcurrentheap)
panic (sprintf("Element du heap %x depassant la limite %x !",chunk, kernelcurrentheap)); panic(sprintf
("Element du heap %x depassant la limite %x !",
chunk, kernelcurrentheap));
} }
if (chunk->size - realsize < MALLOC_MINIMUM) if (chunk->size - realsize < MALLOC_MINIMUM)
chunk->used = 1; chunk->used = 1;
else { else
new = (tmalloc *)((u8 *) chunk + realsize); {
new = (tmalloc *) ((u8 *) chunk + realsize);
new->size = chunk->size - realsize; new->size = chunk->size - realsize;
new->used = 0; new->used = 0;
chunk->size = realsize; chunk->size = realsize;
@ -136,7 +145,8 @@ void vfree(void *vaddr)
tmalloc *chunk, *new; tmalloc *chunk, *new;
chunk = (tmalloc *) (vaddr - sizeof(tmalloc)); chunk = (tmalloc *) (vaddr - sizeof(tmalloc));
chunk->used = 0; chunk->used = 0;
while ((new = (tmalloc *)((u8 *) chunk + chunk->size)) && new < (tmalloc *) kernelcurrentheap && new->used == 0) while ((new = (tmalloc *) ((u8 *) chunk + chunk->size))
&& new < (tmalloc *) kernelcurrentheap && new->used == 0)
chunk->size += new->size; chunk->size += new->size;
} }
@ -145,15 +155,19 @@ void vfree(void *vaddr)
u64 physical_getmemorysize() u64 physical_getmemorysize()
{ {
u64 maxaddr=0; u64 maxaddr = 0;
struct multiboot_tag_mmap *tag=getgrubinfo_mem(); struct multiboot_tag_mmap *tag = getgrubinfo_mem();
multiboot_memory_map_t *mmap; multiboot_memory_map_t *mmap;
for (mmap = ((struct multiboot_tag_mmap *) tag)->entries;(u8 *) mmap < (u8 *) tag + tag->size; mmap = (multiboot_memory_map_t *) for (mmap = ((struct multiboot_tag_mmap *) tag)->entries;
((unsigned long) mmap + ((struct multiboot_tag_mmap *) tag)->entry_size)) (u8 *) mmap < (u8 *) tag + tag->size;
if ((mmap->addr+mmap->len>maxaddr) && mmap->type==1) mmap =
maxaddr=mmap->addr+mmap->len; (multiboot_memory_map_t *) ((unsigned long) mmap +
if (maxaddr>=MAXMEMSIZE) ((struct multiboot_tag_mmap *)
maxaddr=MAXMEMSIZE-1; tag)->entry_size))
if ((mmap->addr + mmap->len > maxaddr) && mmap->type == 1)
maxaddr = mmap->addr + mmap->len;
if (maxaddr >= MAXMEMSIZE)
maxaddr = MAXMEMSIZE - 1;
return maxaddr; return maxaddr;
} }
@ -162,7 +176,7 @@ u64 physical_getmemorysize()
void physical_page_use(u32 page) void physical_page_use(u32 page)
{ {
bitmap[(page/8)] |= (1 << (page%8)); bitmap[(page / 8)] |= (1 << (page % 8));
} }
/*******************************************************************************/ /*******************************************************************************/
@ -170,47 +184,47 @@ void physical_page_use(u32 page)
void physical_page_free(u32 page) void physical_page_free(u32 page)
{ {
bitmap[(page/8)] &= ~(1 << (page%8)); bitmap[(page / 8)] &= ~(1 << (page % 8));
} }
/*******************************************************************************/ /*******************************************************************************/
/* Reserve un espace mémoire physique dans le bitmap */ /* Reserve un espace mémoire physique dans le bitmap */
void physical_range_use(u64 addr,u64 len) void physical_range_use(u64 addr, u64 len)
{ {
u32 nbpage=TOPAGE(len); u32 nbpage = TOPAGE(len);
u32 pagesrc=TOPAGE(addr); u32 pagesrc = TOPAGE(addr);
if (len & 0b1111111111 > 0) if (len & 0x3FF > 0)
nbpage++; nbpage++;
if (addr>=MAXMEMSIZE) if (addr >= MAXMEMSIZE)
return; return;
if (addr+len>=MAXMEMSIZE) if (addr + len >= MAXMEMSIZE)
len=MAXMEMSIZE-addr-1; len = MAXMEMSIZE - addr - 1;
for(u32 page=pagesrc;page<pagesrc+nbpage;page++) for (u32 page = pagesrc; page < pagesrc + nbpage; page++)
physical_page_use(page); physical_page_use(page);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Libère un espace mémoire physique dans le bitmap */ /* Libère un espace mémoire physique dans le bitmap */
void physical_range_free(u64 addr,u64 len) void physical_range_free(u64 addr, u64 len)
{ {
u32 nbpage=TOPAGE(len); u32 nbpage = TOPAGE(len);
u32 pagesrc=TOPAGE(addr); u32 pagesrc = TOPAGE(addr);
if (len & 0b1111111111 > 0) if (len & 0x3FF > 0)
nbpage++; nbpage++;
if (addr>=MAXMEMSIZE) if (addr >= MAXMEMSIZE)
return; return;
if (addr+len>=MAXMEMSIZE) if (addr + len >= MAXMEMSIZE)
len=MAXMEMSIZE-addr-1; len = MAXMEMSIZE - addr - 1;
for(u32 page=pagesrc;page<pagesrc+nbpage;page++) for (u32 page = pagesrc; page < pagesrc + nbpage; page++)
physical_page_free(page); physical_page_free(page);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Retourne une page physique libre */ /* Retourne une page physique libre */
u8* physical_page_getfree(void) u8 *physical_page_getfree(void)
{ {
u32 byte; u32 byte;
u8 bit; u8 bit;
@ -218,7 +232,8 @@ u8* physical_page_getfree(void)
for (byte = 0; byte < sizeof(bitmap); byte++) for (byte = 0; byte < sizeof(bitmap); byte++)
if (bitmap[byte] != 0xFF) if (bitmap[byte] != 0xFF)
for (bit = 0; bit < 8; bit++) for (bit = 0; bit < 8; bit++)
if (!(bitmap[byte] & (1 << bit))) { if (!(bitmap[byte] & (1 << bit)))
{
page = 8 * byte + bit; page = 8 * byte + bit;
physical_page_use(page); physical_page_use(page);
return (u8 *) (page * PAGESIZE); return (u8 *) (page * PAGESIZE);
@ -237,7 +252,7 @@ u64 getmemoryfree(void)
if (bitmap[byte] != 0xFF) if (bitmap[byte] != 0xFF)
for (bit = 0; bit < 8; bit++) for (bit = 0; bit < 8; bit++)
if (!(bitmap[byte] & (1 << bit))) if (!(bitmap[byte] & (1 << bit)))
free+=PAGESIZE; free += PAGESIZE;
return free; return free;
} }
@ -247,17 +262,21 @@ u64 getmemoryfree(void)
void physical_init(void) void physical_init(void)
{ {
u64 page; u64 page;
for (page=0; page < sizeof(bitmap); page++) for (page = 0; page < sizeof(bitmap); page++)
bitmap[page] = 0xFF; bitmap[page] = 0xFF;
struct multiboot_tag_mmap *tag=getgrubinfo_mem(); struct multiboot_tag_mmap *tag = getgrubinfo_mem();
multiboot_memory_map_t *mmap; multiboot_memory_map_t *mmap;
for (mmap = ((struct multiboot_tag_mmap *) tag)->entries;(u8 *) mmap < (u8 *) tag + tag->size; mmap = (multiboot_memory_map_t *) for (mmap = ((struct multiboot_tag_mmap *) tag)->entries;
((unsigned long) mmap + ((struct multiboot_tag_mmap *) tag)->entry_size)) (u8 *) mmap < (u8 *) tag + tag->size;
if (mmap->type==1) mmap =
physical_range_free(mmap->addr,mmap->len); (multiboot_memory_map_t *) ((unsigned long) mmap +
((struct multiboot_tag_mmap *)
tag)->entry_size))
if (mmap->type == 1)
physical_range_free(mmap->addr, mmap->len);
else else
physical_range_use(mmap->addr,mmap->len); physical_range_use(mmap->addr, mmap->len);
physical_range_use(0x0,KERNELSIZE); physical_range_use(0x0, KERNELSIZE);
} }
/*******************************************************************************/ /*******************************************************************************/
@ -270,18 +289,19 @@ page *virtual_page_getfree(void)
u8 *vaddr, *paddr; u8 *vaddr, *paddr;
paddr = physical_page_getfree(); paddr = physical_page_getfree();
if (paddr == NULL) if (paddr == NULL)
panic ("Plus de memoire physique disponible !\n"); panic("Plus de memoire physique disponible !\n");
if (TAILQ_EMPTY(&vrange_head)) if (TAILQ_EMPTY(&vrange_head))
panic("Plus de place disponible dans la reserve de page !\n"); panic("Plus de place disponible dans la reserve de page !\n");
vpages = TAILQ_FIRST(&vrange_head); vpages = TAILQ_FIRST(&vrange_head);
vaddr = vpages->vaddrlow; vaddr = vpages->vaddrlow;
vpages->vaddrlow += PAGESIZE; vpages->vaddrlow += PAGESIZE;
if (vpages->vaddrlow == vpages->vaddrhigh) { if (vpages->vaddrlow == vpages->vaddrhigh)
{
TAILQ_REMOVE(&vrange_head, vpages, tailq); TAILQ_REMOVE(&vrange_head, vpages, tailq);
vfree(vpages); vfree(vpages);
} }
virtual_pd_page_add(NULL,vaddr,paddr, 0); virtual_pd_page_add(NULL, vaddr, paddr, 0);
pg = (page*) vmalloc(sizeof(page)); pg = (page *) vmalloc(sizeof(page));
pg->vaddr = vaddr; pg->vaddr = vaddr;
pg->paddr = paddr; pg->paddr = paddr;
return pg; return pg;
@ -293,7 +313,7 @@ page *virtual_page_getfree(void)
pd *virtual_pd_create() pd *virtual_pd_create()
{ {
pd *new; pd *new;
u32 *pdir,*pd0; u32 *pdir, *pd0;
u32 i; u32 i;
new = (pd *) vmalloc(sizeof(pd)); new = (pd *) vmalloc(sizeof(pd));
new->addr = virtual_page_getfree(); new->addr = virtual_page_getfree();
@ -303,7 +323,8 @@ pd *virtual_pd_create()
pdir[i] = pd0[i]; pdir[i] = pd0[i];
for (i = 256; i < 1023; i++) for (i = 256; i < 1023; i++)
pdir[i] = 0; pdir[i] = 0;
pdir[1023] = ((u32) new->addr->paddr | (PAGE_PRESENT | PAGE_WRITE)); pdir[1023] =
((u32) new->addr->paddr | (PAGE_PRESENT | PAGE_WRITE));
TAILQ_INIT(&new->page_head); TAILQ_INIT(&new->page_head);
return new; return new;
} }
@ -311,27 +332,32 @@ pd *virtual_pd_create()
/*******************************************************************************/ /*******************************************************************************/
/* Attache une page virtuelle de la mémoire dans le directory spécifié */ /* Attache une page virtuelle de la mémoire dans le directory spécifié */
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)
{ {
u32 *pdir; u32 *pdir;
u32 *ptable; u32 *ptable;
u32 *pt; u32 *pt;
page *pg; page *pg;
int i; int i;
if (dst==NULL) if (dst == NULL)
if (vaddr > (u8 *) USER_CODE) { if (vaddr > (u8 *) USER_CODE)
{
print("ERREUR: Adresse %X n'est pas dans l'espace noyau !\n", vaddr); print("ERREUR: Adresse %X n'est pas dans l'espace noyau !\n", vaddr);
return ; return;
} }
pdir = (u32 *) (0xFFFFF000 | (((u32) vaddr & 0xFFC00000) >> 20)); pdir = (u32 *) (0xFFFFF000 | (((u32) vaddr & 0xFFC00000) >> 20));
if ((*pdir & PAGE_PRESENT) == 0) { if ((*pdir & PAGE_PRESENT) == 0)
if (dst==NULL) {
panic(sprintf("Page table introuvable pour l'adresse %x !\r\n", vaddr)); if (dst == NULL)
panic(sprintf
("Page table introuvable pour l'adresse %x !\r\n",
vaddr));
pg = virtual_page_getfree(); pg = virtual_page_getfree();
pt = (u32 *) pg->vaddr; pt = (u32 *) pg->vaddr;
for (i = 1; i < 1024; i++) for (i = 1; i < 1024; i++)
pt[i] = 0; pt[i] = 0;
*pdir = (u32) pg->paddr | (PAGE_PRESENT | PAGE_WRITE | flags); *pdir = (u32) pg->
paddr | (PAGE_PRESENT | PAGE_WRITE | flags);
if (dst) if (dst)
TAILQ_INSERT_TAIL(&dst->page_head, pg, tailq); TAILQ_INSERT_TAIL(&dst->page_head, pg, tailq);
} }
@ -343,11 +369,13 @@ void virtual_pd_page_add(pd *dst, u8* vaddr, u8 * paddr, u32 flags)
/*******************************************************************************/ /*******************************************************************************/
/* Retire une page virtuelle de la mémoire dans le directory spécifié */ /* Retire une page virtuelle de la mémoire dans le directory spécifié */
void virtual_pd_page_remove(u8* vaddr) void virtual_pd_page_remove(u8 * vaddr)
{ {
u32 *ptable; u32 *ptable;
if (virtual_to_physical(vaddr)) { if (virtual_to_physical(vaddr))
ptable = (u32 *) (0xFFC00000 | (((u32) vaddr & 0xFFFFF000) >> 10)); {
ptable = (u32 *) (0xFFC00000 |
(((u32) vaddr & 0xFFFFF000) >> 10));
*ptable = (*ptable & (~PAGE_PRESENT)); *ptable = (*ptable & (~PAGE_PRESENT));
asm("invlpg %0"::"m"(vaddr)); asm("invlpg %0"::"m"(vaddr));
} }
@ -357,16 +385,19 @@ void virtual_pd_page_remove(u8* vaddr)
/*******************************************************************************/ /*******************************************************************************/
/* Renvoie l'adresse physique de la page virtuel */ /* Renvoie l'adresse physique de la page virtuel */
u8* virtual_to_physical(u8 *vaddr) u8 *virtual_to_physical(u8 * vaddr)
{ {
u32 *pdir; u32 *pdir;
u32 *ptable; u32 *ptable;
pdir = (u32 *) (0xFFFFF000 | (((u32) vaddr & 0xFFC00000) >> 20)); pdir = (u32 *) (0xFFFFF000 | (((u32) vaddr & 0xFFC00000) >> 20));
if ((*pdir & PAGE_PRESENT)) { if ((*pdir & PAGE_PRESENT))
ptable = (u32 *) (0xFFC00000 | (((u32) vaddr & 0xFFFFF000) >> 10)); {
ptable = (u32 *) (0xFFC00000 |
(((u32) vaddr & 0xFFFFF000) >> 10));
if ((*ptable & PAGE_PRESENT)) if ((*ptable & PAGE_PRESENT))
return (u8 *) ((*ptable & 0xFFFFF000) + (TOPG((u32) vaddr))); return (u8 *) ((*ptable & 0xFFFFF000) +
(TOPG((u32) vaddr)));
} }
return 0; return 0;
} }
@ -374,25 +405,29 @@ u8* virtual_to_physical(u8 *vaddr)
/*******************************************************************************/ /*******************************************************************************/
/* Détermine une plage virtuelle de mémoire comme étant mappé aux adresses physiques spécifiées GENERIQUE*/ /* Détermine une plage virtuelle de mémoire comme étant mappé aux adresses physiques spécifiées GENERIQUE*/
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,
u32 flags)
{ {
u64 i; u64 i;
u32 realen=len/PAGESIZE; u32 realen = len / PAGESIZE;
page *pg; page *pg;
if (len%PAGESIZE!=0) realen++; if (len % PAGESIZE != 0)
for(i=0;i<realen;i++) realen++;
for (i = 0; i < realen; i++)
{ {
if (dst==NULL) if (dst == NULL)
{ {
virtual_pd_page_add(dst, vaddr+i*PAGESIZE, paddr+i*PAGESIZE, flags); virtual_pd_page_add(dst, vaddr + i * PAGESIZE,
paddr + i * PAGESIZE, flags);
} }
else else
{ {
pg = (page *) vmalloc(sizeof(page)); pg = (page *) vmalloc(sizeof(page));
pg->paddr = paddr+i*PAGESIZE; pg->paddr = paddr + i * PAGESIZE;
pg->vaddr = vaddr+i*PAGESIZE; pg->vaddr = vaddr + i * PAGESIZE;
TAILQ_INSERT_TAIL(&dst->page_head, pg, tailq); TAILQ_INSERT_TAIL(&dst->page_head, pg, tailq);
virtual_pd_page_add(dst, pg->vaddr, pg->paddr, flags); virtual_pd_page_add(dst, pg->vaddr, pg->paddr,
flags);
} }
} }
} }
@ -400,14 +435,15 @@ void virtual_range_use(pd *dst, u8 *vaddr, u8 *paddr, u64 len, u32 flags)
/*******************************************************************************/ /*******************************************************************************/
/* Supprime une plage virtuelle de mémoire GENERIQUE */ /* Supprime une plage virtuelle de mémoire GENERIQUE */
void virtual_range_free(pd *dst, u8 *vaddr, u64 len) void virtual_range_free(pd * dst, u8 * vaddr, u64 len)
{ {
u64 i; u64 i;
u32 realen=len/PAGESIZE; u32 realen = len / PAGESIZE;
if (len%PAGESIZE!=0) realen++; if (len % PAGESIZE != 0)
for(i=0;i<realen;i++) realen++;
for (i = 0; i < realen; i++)
{ {
virtual_pd_page_remove(vaddr+i*PAGESIZE); virtual_pd_page_remove(vaddr + i * PAGESIZE);
virtual_page_free(vaddr); virtual_page_free(vaddr);
} }
} }
@ -415,25 +451,29 @@ void virtual_range_free(pd *dst, u8 *vaddr, u64 len)
/*******************************************************************************/ /*******************************************************************************/
/* Détermine une plage virtuelle de mémoire en attribuant de la mémoire physique GENERIQUE */ /* Détermine une plage virtuelle de mémoire en attribuant de la mémoire physique GENERIQUE */
void virtual_range_new(pd *dst, u8 *vaddr, u64 len, u32 flags) void virtual_range_new(pd * dst, u8 * vaddr, u64 len, u32 flags)
{ {
u64 i; u64 i;
u32 realen=len/PAGESIZE; u32 realen = len / PAGESIZE;
page *pg; page *pg;
if (len%PAGESIZE!=0) realen++; if (len % PAGESIZE != 0)
for(i=0;i<realen;i++) realen++;
for (i = 0; i < realen; i++)
{ {
if (dst==NULL) if (dst == NULL)
{ {
virtual_pd_page_add(dst, vaddr+i*PAGESIZE, physical_page_getfree(), flags); virtual_pd_page_add(dst, vaddr + i * PAGESIZE,
physical_page_getfree(),
flags);
} }
else else
{ {
pg = (page *) vmalloc(sizeof(page)); pg = (page *) vmalloc(sizeof(page));
pg->paddr = physical_page_getfree(); pg->paddr = physical_page_getfree();
pg->vaddr = vaddr+i*PAGESIZE; pg->vaddr = vaddr + i * PAGESIZE;
TAILQ_INSERT_TAIL(&dst->page_head, pg, tailq); TAILQ_INSERT_TAIL(&dst->page_head, pg, tailq);
virtual_pd_page_add(dst, pg->vaddr, pg->paddr, flags); virtual_pd_page_add(dst, pg->vaddr, pg->paddr,
flags);
} }
} }
} }
@ -441,7 +481,7 @@ void virtual_range_new(pd *dst, u8 *vaddr, u64 len, u32 flags)
/*******************************************************************************/ /*******************************************************************************/
/* Détermine une plage virtuelle de mémoire comme étant mappé aux adresses physiques spécifiées pour le noyau*/ /* Détermine une plage virtuelle de mémoire comme étant mappé aux adresses physiques spécifiées pour le noyau*/
void virtual_range_use_kernel(u8 *vaddr, u8 *paddr, u64 *len, u32 flags) void virtual_range_use_kernel(u8 * vaddr, u8 * paddr, u64 * len, u32 flags)
{ {
virtual_range_use(NULL, vaddr, paddr, len, flags); virtual_range_use(NULL, vaddr, paddr, len, flags);
} }
@ -449,7 +489,7 @@ void virtual_range_use_kernel(u8 *vaddr, u8 *paddr, u64 *len, u32 flags)
/*******************************************************************************/ /*******************************************************************************/
/* Supprime une plage virtuelle de mémoire pour le noyau */ /* Supprime une plage virtuelle de mémoire pour le noyau */
void virtual_range_free_kernel(u8 *vaddr, u64 len) void virtual_range_free_kernel(u8 * vaddr, u64 len)
{ {
virtual_range_free(NULL, vaddr, len); virtual_range_free(NULL, vaddr, len);
} }
@ -457,7 +497,7 @@ void virtual_range_free_kernel(u8 *vaddr, u64 len)
/*******************************************************************************/ /*******************************************************************************/
/* Détermine une plage virtuelle de mémoire en attribuant de la mémoire physique pour le noyau */ /* Détermine une plage virtuelle de mémoire en attribuant de la mémoire physique pour le noyau */
void virtual_range_new_kernel(u8 *vaddr, u64 len, u32 flags) void virtual_range_new_kernel(u8 * vaddr, u64 len, u32 flags)
{ {
virtual_range_new(NULL, vaddr, len, flags); virtual_range_new(NULL, vaddr, len, flags);
} }
@ -467,8 +507,8 @@ void virtual_range_new_kernel(u8 *vaddr, u64 len, u32 flags)
u32 virtual_getpagesused() u32 virtual_getpagesused()
{ {
u32 maxpage=((u32) MAXPAGESSIZE)/((u16) PAGESIZE); u32 maxpage = ((u32) MAXPAGESSIZE) / ((u16) PAGESIZE);
return maxpage-virtual_getpagesfree(); return maxpage - virtual_getpagesfree();
} }
/*******************************************************************************/ /*******************************************************************************/
@ -477,9 +517,9 @@ u32 virtual_getpagesused()
u32 virtual_getpagesfree() u32 virtual_getpagesfree()
{ {
vrange *next; vrange *next;
u32 realsize=0; u32 realsize = 0;
TAILQ_FOREACH(next, &vrange_head, tailq) TAILQ_FOREACH(next, &vrange_head, tailq) realsize +=
realsize+=(next->vaddrhigh - next->vaddrlow)/PAGESIZE; (next->vaddrhigh - next->vaddrlow) / PAGESIZE;
return realsize; return realsize;
} }
@ -487,36 +527,43 @@ u32 virtual_getpagesfree()
/*******************************************************************************/ /*******************************************************************************/
/* Libère une page virtuelle de la mémoire */ /* Libère une page virtuelle de la mémoire */
void virtual_page_free(u8 *vaddr) void virtual_page_free(u8 * vaddr)
{ {
vrange *next, *prev, *new; vrange *next, *prev, *new;
u8 *paddr; u8 *paddr;
paddr = virtual_to_physical(vaddr); paddr = virtual_to_physical(vaddr);
if (paddr) if (paddr)
physical_page_free(TOPAGE((u32) paddr)); physical_page_free(TOPAGE((u32) paddr));
else { else
printf("Aucune page associee a l'adresse virtuelle %x\n", vaddr); {
printf("Aucune page associee a l'adresse virtuelle %x\n",
vaddr);
return; return;
} }
virtual_pd_page_remove(vaddr); virtual_pd_page_remove(vaddr);
TAILQ_FOREACH(next, &vrange_head, tailq) { TAILQ_FOREACH(next, &vrange_head, tailq)
{
if (next->vaddrlow > vaddr) if (next->vaddrlow > vaddr)
break; break;
} }
prev = TAILQ_PREV(next, vrange_s, tailq); prev = TAILQ_PREV(next, vrange_s, tailq);
if (prev->vaddrhigh == vaddr) { if (prev->vaddrhigh == vaddr)
{
prev->vaddrhigh += PAGESIZE; prev->vaddrhigh += PAGESIZE;
if (prev->vaddrhigh == next->vaddrlow) { if (prev->vaddrhigh == next->vaddrlow)
{
prev->vaddrhigh = next->vaddrhigh; prev->vaddrhigh = next->vaddrhigh;
TAILQ_REMOVE(&vrange_head, next, tailq); TAILQ_REMOVE(&vrange_head, next, tailq);
vfree(next); vfree(next);
} }
} }
else if (next->vaddrlow == vaddr + PAGESIZE) { else if (next->vaddrlow == vaddr + PAGESIZE)
{
next->vaddrlow = vaddr; next->vaddrlow = vaddr;
} }
else if (next->vaddrlow > vaddr + PAGESIZE) { else if (next->vaddrlow > vaddr + PAGESIZE)
new = (vrange*) vmalloc(sizeof(vrange)); {
new = (vrange *) vmalloc(sizeof(vrange));
new->vaddrlow = vaddr; new->vaddrlow = vaddr;
new->vaddrhigh = vaddr + PAGESIZE; new->vaddrhigh = vaddr + PAGESIZE;
TAILQ_INSERT_BEFORE(prev, new, tailq); TAILQ_INSERT_BEFORE(prev, new, tailq);
@ -529,10 +576,11 @@ void virtual_page_free(u8 *vaddr)
/*******************************************************************************/ /*******************************************************************************/
/* Destruction d'un directory pour la gestion virtuelle de la mémoire */ /* Destruction d'un directory pour la gestion virtuelle de la mémoire */
void virtual_pd_destroy(pd *dst) void virtual_pd_destroy(pd * dst)
{ {
page *pg; page *pg;
TAILQ_FOREACH(pg, &dst->page_head, tailq) { TAILQ_FOREACH(pg, &dst->page_head, tailq)
{
virtual_page_free(pg->vaddr); virtual_page_free(pg->vaddr);
TAILQ_REMOVE(&dst->page_head, pg, tailq); TAILQ_REMOVE(&dst->page_head, pg, tailq);
vfree(pg); vfree(pg);
@ -549,8 +597,9 @@ void malloc_init(void)
{ {
tmalloc *chunk; tmalloc *chunk;
chunk = (tmalloc *) KERNEL_HEAP; chunk = (tmalloc *) KERNEL_HEAP;
virtual_pd_page_add(NULL, KERNEL_HEAP, physical_page_getfree(), PAGE_NOFLAG); virtual_pd_page_add(NULL, KERNEL_HEAP, physical_page_getfree(),
kernelcurrentheap=KERNEL_HEAP+PAGESIZE; PAGE_NOFLAG);
kernelcurrentheap = KERNEL_HEAP + PAGESIZE;
chunk->size = PAGESIZE; chunk->size = PAGESIZE;
chunk->used = 0; chunk->used = 0;
//virtual_range_new_kernel(kernelcurrentheap, chunk->size, PAGE_NOFLAG); //virtual_range_new_kernel(kernelcurrentheap, chunk->size, PAGE_NOFLAG);
@ -562,9 +611,9 @@ void malloc_init(void)
void virtual_init(void) void virtual_init(void)
{ {
vrange *vpages = (vrange*) vmalloc(sizeof(vrange)); vrange *vpages = (vrange *) vmalloc(sizeof(vrange));
vpages->vaddrlow = (u8 *) KERNEL_PAGES+PAGESIZE; vpages->vaddrlow = (u8 *) KERNEL_PAGES + PAGESIZE;
vpages->vaddrhigh = (u8 *) KERNEL_PAGES+MAXPAGESSIZE; vpages->vaddrhigh = (u8 *) KERNEL_PAGES + MAXPAGESSIZE;
TAILQ_INIT(&vrange_head); TAILQ_INIT(&vrange_head);
TAILQ_INSERT_TAIL(&vrange_head, vpages, tailq); TAILQ_INSERT_TAIL(&vrange_head, vpages, tailq);
} }
@ -577,12 +626,12 @@ void identity_init(void)
u32 i; u32 i;
u32 *pd0 = KERNEL_PD_ADDR; u32 *pd0 = KERNEL_PD_ADDR;
u8 *pg0 = (u8 *) 0; u8 *pg0 = (u8 *) 0;
u8 *pg1 = (u8 *) (PAGESIZE*PAGENUMBER); u8 *pg1 = (u8 *) (PAGESIZE * PAGENUMBER);
pd0[0] = ((u32) pg0 | (PAGE_PRESENT | PAGE_WRITE | PAGE_4MB)); pd0[0] = ((u32) pg0 | (PAGE_PRESENT | PAGE_WRITE | PAGE_4MB));
pd0[1] = ((u32) pg1 | (PAGE_PRESENT | PAGE_WRITE | PAGE_4MB)); pd0[1] = ((u32) pg1 | (PAGE_PRESENT | PAGE_WRITE | PAGE_4MB));
for (i = 2; i < 1023; i++) for (i = 2; i < 1023; i++)
pd0[i] = pd0[i] = ((u32) pg1 +
((u32) pg1 + PAGESIZE * i) | (PAGE_PRESENT | PAGE_WRITE); PAGESIZE * i) | (PAGE_PRESENT | PAGE_WRITE);
pd0[1023] = ((u32) pd0 | (PAGE_PRESENT | PAGE_WRITE)); pd0[1023] = ((u32) pd0 | (PAGE_PRESENT | PAGE_WRITE));
} }
@ -591,14 +640,14 @@ void identity_init(void)
void registry_init(void) void registry_init(void)
{ {
asm("mov %[directory_addr], %%eax \n \ asm("mov %[directory_addr], %%eax \n \
mov %%eax, %%cr3 \n \ mov %%eax, %%cr3 \n \
mov %%cr4, %%eax \n \ mov %%cr4, %%eax \n \
or $0x00000010, %%eax \n \ or $0x00000010, %%eax \n \
mov %%eax, %%cr4 \n \ mov %%eax, %%cr4 \n \
mov %%cr0, %%eax \n \ mov %%cr0, %%eax \n \
or $0x80000001, %%eax \n \ or $0x80000001, %%eax \n \
mov %%eax, %%cr0"::[directory_addr]"i"(KERNEL_PD_ADDR)); mov %%eax, %%cr0"::[directory_addr] "i"(KERNEL_PD_ADDR));
} }
/*******************************************************************************/ /*******************************************************************************/
@ -619,10 +668,12 @@ void initpaging(void)
void memset(void *dst, u8 val, u32 count, u32 size) void memset(void *dst, u8 val, u32 count, u32 size)
{ {
u8 *d = (u8 *) dst; u8 *d = (u8 *) dst;
if (size>0) size--; if (size > 0)
for (; count != 0; count--) { size--;
for (; count != 0; count--)
{
*(d++) = val; *(d++) = val;
d+=size; d += size;
} }
} }
@ -633,10 +684,12 @@ void memcpy(void *src, void *dst, u32 count, u32 size)
{ {
u8 *s = (u8 *) src; u8 *s = (u8 *) src;
u8 *d = (u8 *) dst; u8 *d = (u8 *) dst;
if (size>0) size--; if (size > 0)
for (; count != 0; count--) { size--;
for (; count != 0; count--)
{
*(d++) = *(s++); *(d++) = *(s++);
d+=size; d += size;
} }
} }
@ -647,13 +700,15 @@ u32 memcmp(void *src, void *dst, u32 count, u32 size)
{ {
u8 *s = (u8 *) src; u8 *s = (u8 *) src;
u8 *d = (u8 *) dst; u8 *d = (u8 *) dst;
if (size>0) size--; if (size > 0)
for (; count != 0; count--) { size--;
for (; count != 0; count--)
{
if (*(s++) != *(d++)) if (*(s++) != *(d++))
return *d - *s; return *d - *s;
s+= size; s += size;
d+= size; d += size;
} }
} }
/*******************************************************************************/ /*******************************************************************************/

View File

@ -72,8 +72,10 @@ void mouse(void)
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,37 +85,50 @@ 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;

View File

@ -11,7 +11,7 @@ static u32 infobloc;
void initmultiboot(const u32 addr) void initmultiboot(const u32 addr)
{ {
infobloc=addr; infobloc = addr;
} }
/*******************************************************************************/ /*******************************************************************************/
@ -19,12 +19,15 @@ 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;
} }
/*******************************************************************************/ /*******************************************************************************/
@ -32,7 +35,8 @@ for (tag = (struct multiboot_tag *) (infobloc + 8);
u8 *getgrubinfo_cmdline(void) u8 *getgrubinfo_cmdline(void)
{ {
struct multiboot_tag_string *tag=getgrubinfo(MULTIBOOT_TAG_TYPE_CMDLINE); struct multiboot_tag_string *tag =
getgrubinfo(MULTIBOOT_TAG_TYPE_CMDLINE);
return tag->string; return tag->string;
} }
@ -41,7 +45,8 @@ 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 =
getgrubinfo(MULTIBOOT_TAG_TYPE_BASIC_MEMINFO);
return tag->mem_upper; return tag->mem_upper;
} }
@ -50,7 +55,8 @@ 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 =
getgrubinfo(MULTIBOOT_TAG_TYPE_MMAP);
return tag; return tag;
} }
@ -59,7 +65,8 @@ 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 =
getgrubinfo(MULTIBOOT_TAG_TYPE_FRAMEBUFFER);
return tag; return tag;
} }
@ -68,76 +75,82 @@ 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);
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 =
(struct multiboot_tag *) ((u8 *) tag +
((tag->size + 7) & ~7)))
{ {
printf ("--- Tag % hu, Taille % hu\r\n", tag->type, tag->size); printf("--- Tag % hu, Taille % hu\r\n", tag->type,
tag->size);
switch (tag->type) switch (tag->type)
{ {
case MULTIBOOT_TAG_TYPE_CMDLINE: case MULTIBOOT_TAG_TYPE_CMDLINE:
printf (" Ligne de lancement : %s\r\n", printf(" Ligne de lancement : %s\r\n",
((struct multiboot_tag_string *) tag)->string); ((struct multiboot_tag_string *)
tag)->string);
break; break;
case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME: case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME:
printf (" Chargeur de boot : %s\r\n", printf(" Chargeur de boot : %s\r\n",
((struct multiboot_tag_string *) tag)->string); ((struct multiboot_tag_string *)
tag)->string);
break; break;
case MULTIBOOT_TAG_TYPE_MODULE: case MULTIBOOT_TAG_TYPE_MODULE:
printf (" Module %X-%X. Command line %s\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_module *) tag)->mod_start,
((struct multiboot_tag_module *) tag)->mod_end,
((struct multiboot_tag_module *) tag)->cmdline);
break; break;
case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO: case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO:
printf (" Memoire basse : %H, memoire haute = %lH\r\n", 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);
((struct multiboot_tag_basic_meminfo *) tag)->mem_lower<<10,
((u64)((struct multiboot_tag_basic_meminfo *) tag)->mem_upper)<<10);
break; break;
case MULTIBOOT_TAG_TYPE_BOOTDEV: case MULTIBOOT_TAG_TYPE_BOOTDEV:
printf (" Peripherique de demarrage : %Y,%u,%u\r\n\r\n", 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)->biosdev,
((struct multiboot_tag_bootdev *) tag)->slice,
((struct multiboot_tag_bootdev *) tag)->part);
break; break;
case MULTIBOOT_TAG_TYPE_MMAP: case MULTIBOOT_TAG_TYPE_MMAP:
{ {
multiboot_memory_map_t *mmap; multiboot_memory_map_t *mmap;
printf ("*** Plan de memoire ***\r\n"); printf("*** Plan de memoire ***\r\n");
for (mmap = ((struct multiboot_tag_mmap *) tag)->entries;(u8 *) mmap < (u8 *) tag + tag->size; mmap = (multiboot_memory_map_t *) for (mmap =
((unsigned long) mmap + ((struct multiboot_tag_mmap *) tag)->entry_size)) ((struct multiboot_tag_mmap *) tag)->
printf (" adresse: %lY, taille:%lY, type:%Y\r\n", entries;
(u64) (mmap->addr), (u8 *) mmap < (u8 *) tag + tag->size;
(u64) (mmap->len), mmap =
(u32) (mmap->type)); (multiboot_memory_map_t
*) ((unsigned long) mmap +
((struct multiboot_tag_mmap *)
tag)->entry_size))
printf(" adresse: %lY, taille:%lY, type:%Y\r\n", (u64) (mmap->addr), (u64) (mmap->len), (u32) (mmap->type));
break; break;
} }
case MULTIBOOT_TAG_TYPE_FRAMEBUFFER: case MULTIBOOT_TAG_TYPE_FRAMEBUFFER:
{ {
struct multiboot_tag_framebuffer *tagfb = (struct multiboot_tag_framebuffer *) tag; struct multiboot_tag_framebuffer *tagfb =
printf (" Framebuffer, resolution %d*%d*%d adresse: %X, ",tagfb->common.framebuffer_width,tagfb->common.framebuffer_height,tagfb->common.framebuffer_bpp,tagfb->common.framebuffer_addr); (struct multiboot_tag_framebuffer
*) tag;
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) switch (tagfb->common.framebuffer_type)
{ {
case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED: case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED:
printf ("mode graphique indexé\r\n"); printf("mode graphique indexé\r\n");
break; break;
case MULTIBOOT_FRAMEBUFFER_TYPE_RGB: case MULTIBOOT_FRAMEBUFFER_TYPE_RGB:
printf ("mode graphique RGB\r\n"); printf("mode graphique RGB\r\n");
break; break;
case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT: case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT:
printf ("mode texte EGA\r\n"); printf("mode texte EGA\r\n");
break; break;
} }
break; break;
} }
case MULTIBOOT_TAG_TYPE_VBE: case MULTIBOOT_TAG_TYPE_VBE:
{ {
struct multiboot_tag_vbe *tagvbe = (struct multiboot_tag_framebuffer *) tag; struct multiboot_tag_vbe *tagvbe =
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); (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);
} }
} }
} }

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++;
@ -43,8 +48,11 @@ 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)
{
result.device_id =
pciConfigReadWord(bus, dev, function, 0x2);
} }
return result; return result;
} }
@ -52,26 +60,31 @@ pcidevmini getPCImininfo(const u8 bus, const u8 dev, const u8 function)
/*******************************************************************************/ /*******************************************************************************/
/* 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; u16 temp;
device->device_id = pciConfigReadWord(bus,dev,function,0x2); device->device_id =
device->command = pciConfigReadWord(bus,dev,function,0x4); pciConfigReadWord(bus, dev, function, 0x2);
device->status = pciConfigReadWord(bus,dev,function,0x6); device->command =
temp=pciConfigReadWord(bus,dev,function,0x8); pciConfigReadWord(bus, dev, function, 0x4);
device->status =
pciConfigReadWord(bus, dev, function, 0x6);
temp = pciConfigReadWord(bus, dev, function, 0x8);
device->revision_id = temp & 0xFF; device->revision_id = temp & 0xFF;
device->interface = temp>>8; device->interface = temp >> 8;
temp=pciConfigReadWord(bus,dev,function,0xA); temp = pciConfigReadWord(bus, dev, function, 0xA);
device->sub_class = temp & 0xFF; device->sub_class = temp & 0xFF;
device->base_class = temp>>8; device->base_class = temp >> 8;
temp=pciConfigReadWord(bus,dev,function,0xC); temp = pciConfigReadWord(bus, dev, function, 0xC);
device->cache_line_size = temp & 0xFF; device->cache_line_size = temp & 0xFF;
device->latency_timer = temp>>8; device->latency_timer = temp >> 8;
temp=pciConfigReadWord(bus,dev,function,0xE); temp = pciConfigReadWord(bus, dev, function, 0xE);
device->header_type = temp & 0xFF; device->header_type = temp & 0xFF;
device->bist = temp>>8; device->bist = temp >> 8;
return true; return true;
} }
else else
@ -81,12 +94,15 @@ bool getPCInfo(pcidev *device, const u8 bus, const u8 dev, const u8 function)
/*******************************************************************************/ /*******************************************************************************/
/* 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 =
(0x80000000 | (bus << 16) | (dev << 11) | (function << 8) |
(offset & 0xFC));
outd(0xCF8, addr); outd(0xCF8, addr);
tmp = (u16)((ind(0xCFC) >> ((offset & 2) * 8)) & 0xffff); tmp = (u16) ((ind(0xCFC) >> ((offset & 2) * 8)) & 0xffff);
return tmp; return tmp;
} }
@ -95,15 +111,17 @@ 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); result = getPCImininfo(bus, device,
function);
if (result.vendor_id != 0xFFFF) if (result.vendor_id != 0xFFFF)
printf("Bus:%hx Dev:%hx Func:%hx %hx:%hx\r\n",bus, device, function, result.vendor_id, result.device_id); printf("Bus:%hx Dev:%hx Func:%hx %hx:%hx\r\n", bus, device, function, result.vendor_id, result.device_id);
} }
return; 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
(&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; return;
} }
/*******************************************************************************/ /*******************************************************************************/

View File

@ -12,13 +12,15 @@ 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
@ -30,21 +32,24 @@ static u8 *elf_errors[]={&elf_errors1,&elf_errors2,&elf_errors3,&elf_errors4,&el
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
&& header->e_ident[EI_MAG3] == ELFMAG3)
{ {
if (header->e_ident[EI_CLASS]!=ELFCLASS32) if (header->e_ident[EI_CLASS] != ELFCLASS32)
return 2; return 2;
if (header->e_ident[EI_DATA]!=ELFDATA2LSB) if (header->e_ident[EI_DATA] != ELFDATA2LSB)
return 3; return 3;
if (header->e_ident[EI_VERSION]!=EV_CURRENT || header->e_version!=EV_CURRENT) if (header->e_ident[EI_VERSION] != EV_CURRENT
|| header->e_version != EV_CURRENT)
return 4; return 4;
if (header->e_ident[EI_OSABI]!=ELFOSABI_COS2000) if (header->e_ident[EI_OSABI] != ELFOSABI_COS2000)
return 5; return 5;
if (header->e_machine!=EM_386) if (header->e_machine != EM_386)
return 6; return 6;
return 0; return 0;
} }
@ -55,7 +60,7 @@ 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;
@ -66,50 +71,63 @@ u32 elf_load(u8 *src, u32 pid)
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;
@ -131,23 +149,25 @@ 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) if (i >= MAXNUMPROCESS)
i=0; 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;
} }
@ -165,9 +185,9 @@ process *getcurrentprocess()
/*******************************************************************************/ /*******************************************************************************/
/* 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,12 +195,12 @@ 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();
@ -199,10 +219,10 @@ void task_run(u32 pid)
/*******************************************************************************/ /*******************************************************************************/
/* 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;
@ -211,11 +231,12 @@ u32 task_create(u8 *code,bool kerneltask)
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;

View File

@ -21,30 +21,30 @@
#include "syscall.h" #include "syscall.h"
static command commands[] = { static command commands[] = {
{"reboot" , "", &rebootnow}, {"reboot", "", &rebootnow},
{"clear" , "", &clear}, {"clear", "", &clear},
{"mode" , "", &mode}, {"mode", "", &mode},
{"detectcpu" , "", &detectcpu}, {"detectcpu", "", &detectcpu},
{"test2d" , "", &test2d}, {"test2d", "", &test2d},
{"regs" , "", &showregs}, {"regs", "", &showregs},
{"gdt" , "", &showgdt}, {"gdt", "", &showgdt},
{"idt" , "", &showidt}, {"idt", "", &showidt},
{"info" , "", &showinfo}, {"info", "", &showinfo},
{"err" , "", &err}, {"err", "", &err},
{"test" , "", &test}, {"test", "", &test},
{"view" , "", &view}, {"view", "", &view},
{"disasm" , "", &disas}, {"disasm", "", &disas},
{"bpset" , "", &bpset}, {"bpset", "", &bpset},
{"bpclr" , "", &bpclr}, {"bpclr", "", &bpclr},
{"help" , "", &help}, {"help", "", &help},
{"logo" , "", &logo}, {"logo", "", &logo},
{"font" , "", &sfont}, {"font", "", &sfont},
{"test3d" , "", &test3d}, {"test3d", "", &test3d},
{"detectpci" , "", &detectpci}, {"detectpci", "", &detectpci},
{"mem" , "", &showmem}, {"mem", "", &showmem},
{"testmem" , "", &testmem}, {"testmem", "", &testmem},
{"testcall" , "", &testcall}, {"testcall", "", &testcall},
{"testtask" , "", &testtask}, {"testtask", "", &testtask},
}; };
/*******************************************************************************/ /*******************************************************************************/
@ -57,7 +57,8 @@ void shell()
static u8 item[] = " \000"; static u8 item[] = " \000";
int i; int i;
bool found; bool found;
while (true) { while (true)
{
print("\r\n# "); print("\r\n# ");
getstring(&field); getstring(&field);
print("\r\n"); print("\r\n");
@ -66,8 +67,11 @@ void shell()
strgetitem(&field, &item, ' ', 0); strgetitem(&field, &item, ' ', 0);
strtolower(&item); strtolower(&item);
found = false; found = false;
for (i = 0; i < sizeof(commands)/sizeof(commands[0]); i++) { for (i = 0; i < sizeof(commands) / sizeof(commands[0]);
if (strcmp(&item, &commands[i].name) == 0) { i++)
{
if (strcmp(&item, &commands[i].name) == 0)
{
(*commands[i].function) (&field); (*commands[i].function) (&field);
found = true; found = true;
break; break;
@ -92,7 +96,7 @@ int test(void)
int testtask() int testtask()
{ {
print("*** Creation d'une tache"); print("*** Creation d'une tache");
u32 pid=task_create(&programs_test,false); u32 pid = task_create(&programs_test, false);
task_run(pid); task_run(pid);
} }
@ -111,10 +115,10 @@ int testcall()
int testmem() int testmem()
{ {
u8* test; u8 *test;
print("**** AVANT ALLOCATION\r\n"); print("**** AVANT ALLOCATION\r\n");
showmem(); showmem();
test=vmalloc(150*1024*1024); /* 10 pages */ test = vmalloc(150 * 1024 * 1024); /* 10 pages */
print("**** APRES ALLOCATION\r\n"); print("**** APRES ALLOCATION\r\n");
showmem(); showmem();
vfree(test); vfree(test);
@ -127,12 +131,12 @@ int testmem()
int showmem() int showmem()
{ {
u32 libre=getmemoryfree(); u32 libre = getmemoryfree();
u32 total=physical_getmemorysize(); u32 total = physical_getmemorysize();
printf("Memoire physique (TOTAL)\r\n -libre \33[40D\33[15C%H (%.2f%%)\r\n -occupee \33[40D\33[15C%H\r\n -total \33[40D\33[15C%H\r\n\r\n",libre,((float) libre/total*100.0f),total-libre,total); printf("Memoire physique (TOTAL)\r\n -libre \33[40D\33[15C%H (%.2f%%)\r\n -occupee \33[40D\33[15C%H\r\n -total \33[40D\33[15C%H\r\n\r\n", libre, ((float) libre / total * 100.0f), total - libre, total);
printf("Memoire HEAP (NOYAU) - % u blocs\r\n -libre \33[40D\33[15C%H\r\n -occupee \33[40D\33[15C%H\r\n -allouables \33[40D\33[15C%H\r\n\r\n",getmallocnb(),getmallocfree(),getmallocused(),getmallocnonallocated()); printf("Memoire HEAP (NOYAU) - % u blocs\r\n -libre \33[40D\33[15C%H\r\n -occupee \33[40D\33[15C%H\r\n -allouables \33[40D\33[15C%H\r\n\r\n", getmallocnb(), getmallocfree(), getmallocused(), getmallocnonallocated());
printf("Plan de memoire (NOYAU)\r\n -IDT \33[40D\33[15C%X\r\n -GDT \33[40D\33[15C%X\r\n -PGD \33[40D\33[15C%X\r\n -STACK \33[40D\33[15C%X\r\n -CODE \33[40D\33[15C%X\r\n -PAGES \33[40D\33[15C%X\r\n -HEAP \33[40D\33[15C%X\r\n -VESAFB \33[40D\33[15C%X\r\n\r\n",IDT_ADDR,GDT_ADDR,KERNEL_PD_ADDR,KERNEL_STACK_ADDR,KERNEL_CODE_ADDR,KERNEL_PAGES,KERNEL_HEAP,VESA_FBMEM); printf("Plan de memoire (NOYAU)\r\n -IDT \33[40D\33[15C%X\r\n -GDT \33[40D\33[15C%X\r\n -PGD \33[40D\33[15C%X\r\n -STACK \33[40D\33[15C%X\r\n -CODE \33[40D\33[15C%X\r\n -PAGES \33[40D\33[15C%X\r\n -HEAP \33[40D\33[15C%X\r\n -VESAFB \33[40D\33[15C%X\r\n\r\n", IDT_ADDR, GDT_ADDR, KERNEL_PD_ADDR, KERNEL_STACK_ADDR, KERNEL_CODE_ADDR, KERNEL_PAGES, KERNEL_HEAP, VESA_FBMEM);
printf("Memoire Virtuelle (NOYAU)\r\n -pages libres \33[40D\33[16C% u\r\n -pages occupees \33[40D\33[16C% u\r\n",virtual_getpagesfree(),virtual_getpagesused()); printf("Memoire Virtuelle (NOYAU)\r\n -pages libres \33[40D\33[16C% u\r\n -pages occupees \33[40D\33[16C% u\r\n", virtual_getpagesfree(), virtual_getpagesused());
return; return;
} }
@ -147,7 +151,7 @@ int detectpci()
/*******************************************************************************/ /*******************************************************************************/
/* Change la police courante */ /* Change la police courante */
int sfont(u8* commandline) int sfont(u8 * commandline)
{ {
if (strgetnbitems(commandline, ' ') < 2) if (strgetnbitems(commandline, ' ') < 2)
{ {
@ -172,53 +176,55 @@ int logo()
int help() int help()
{ {
print("Commandes disponibles :\r\n\r\n"); print("Commandes disponibles :\r\n\r\n");
for(u32 i=0;i<sizeof(commands)/sizeof(commands[0]);i++) { for (u32 i = 0; i < sizeof(commands) / sizeof(commands[0]); i++)
printf("%s \r\n",&commands[i].name); {
printf("%s \r\n", &commands[i].name);
} }
return 0; return 0;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Met un breakpoint */ /* Met un breakpoint */
int bpset(u8* commandline) int bpset(u8 * commandline)
{ {
u8 arg[] = " \000"; u8 arg[] = " \000";
u8* numero; u8 *numero;
u8* pointer; u8 *pointer;
u8 type=DBG_EXEC; u8 type = DBG_EXEC;
if (strgetnbitems(commandline, ' ') < 3) if (strgetnbitems(commandline, ' ') < 3)
{ {
print("Syntaxe de la commande BPSET\r\nbpset \33[32mnumero address [type]\r\n\r\n \33[32mnumero\33[0m\33[0m\33[25D\33[10C - numero du breakpoint (0-3)\r\n \33[32madresse\33[0m\33[25D\33[10C - adresse du breakpoint\r\n \33[32mtype\33[0m\33[25D\33[10C - type de breakpoint (0-3)\r\n"); print("Syntaxe de la commande BPSET\r\nbpset \33[32mnumero address [type]\r\n\r\n \33[32mnumero\33[0m\33[0m\33[25D\33[10C - numero du breakpoint (0-3)\r\n \33[32madresse\33[0m\33[25D\33[10C - adresse du breakpoint\r\n \33[32mtype\33[0m\33[25D\33[10C - type de breakpoint (0-3)\r\n");
return; return;
} }
strgetitem(commandline, &arg, ' ', 1); strgetitem(commandline, &arg, ' ', 1);
numero=strtoint(&arg); numero = strtoint(&arg);
if (numero>3) { if (numero > 3)
{
print("numero incorrect"); print("numero incorrect");
return; return;
} }
strgetitem(commandline, &arg, ' ', 2); strgetitem(commandline, &arg, ' ', 2);
pointer=strtoint(&arg); pointer = strtoint(&arg);
if (strgetnbitems(commandline, ' ') == 4) if (strgetnbitems(commandline, ' ') == 4)
{ {
strgetitem(commandline, &arg, ' ', 3); strgetitem(commandline, &arg, ' ', 3);
type=strtoint(&arg); type = strtoint(&arg);
} }
if (type>DBG_READWRITE) if (type > DBG_READWRITE)
{ {
print("type incorrect"); print("type incorrect");
return; return;
} }
setdebugreg(numero,pointer,type); setdebugreg(numero, pointer, type);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Retire un breakpoint */ /* Retire un breakpoint */
int bpclr(u8* commandline) int bpclr(u8 * commandline)
{ {
u8 arg[] = " \000"; u8 arg[] = " \000";
u8* numero; u8 *numero;
if (strgetnbitems(commandline, ' ') < 2) if (strgetnbitems(commandline, ' ') < 2)
{ {
@ -226,22 +232,23 @@ int bpclr(u8* commandline)
return; return;
} }
strgetitem(commandline, &arg, ' ', 1); strgetitem(commandline, &arg, ' ', 1);
numero=strtoint(&arg); numero = strtoint(&arg);
if (numero>3) { if (numero > 3)
{
print("numero incorrect"); print("numero incorrect");
return; return;
} }
setdebugreg(numero,0x0,DBG_CLEAR); setdebugreg(numero, 0x0, DBG_CLEAR);
} }
/*******************************************************************************/ /*******************************************************************************/
/* Desassemble une zone de mémoire donnée */ /* Desassemble une zone de mémoire donnée */
int disas(u8* commandline) int disas(u8 * commandline)
{ {
u8 arg[] = " \000"; u8 arg[] = " \000";
u8* size; u8 *size;
u8* pointer; u8 *pointer;
if (strgetnbitems(commandline, ' ') < 3) if (strgetnbitems(commandline, ' ') < 3)
{ {
@ -249,27 +256,27 @@ int disas(u8* commandline)
return; return;
} }
strgetitem(commandline, &arg, ' ', 1); strgetitem(commandline, &arg, ' ', 1);
pointer=strtoint(&arg); pointer = strtoint(&arg);
size=pointer; size = pointer;
strgetitem(commandline, &arg, ' ', 2); strgetitem(commandline, &arg, ' ', 2);
size+=strtoint(&arg); size += strtoint(&arg);
while(pointer<size) while (pointer < size)
{ {
pointer+=disasm(pointer, NULL, true); pointer += disasm(pointer, NULL, true);
} }
} }
/*******************************************************************************/ /*******************************************************************************/
/* Génère des exceptions */ /* Génère des exceptions */
int view(u8* commandline) int view(u8 * commandline)
{ {
u8 arg[] = " \000"; u8 arg[] = " \000";
u32 address; u32 address;
u8 size; u8 size;
u8* pointerb; u8 *pointerb;
u16* pointerw; u16 *pointerw;
u32* pointerd; u32 *pointerd;
u8 format; u8 format;
u8 nbligne; u8 nbligne;
if (strgetnbitems(commandline, ' ') < 3) if (strgetnbitems(commandline, ' ') < 3)
@ -278,67 +285,71 @@ int view(u8* commandline)
return; return;
} }
strgetitem(commandline, &arg, ' ', 1); strgetitem(commandline, &arg, ' ', 1);
address=strtoint(&arg); address = strtoint(&arg);
strgetitem(commandline, &arg, ' ', 2); strgetitem(commandline, &arg, ' ', 2);
size=strtoint(&arg); size = strtoint(&arg);
if (strgetnbitems(commandline, ' ') < 4) if (strgetnbitems(commandline, ' ') < 4)
format='b'; format = 'b';
else { else
{
strgetitem(commandline, &arg, ' ', 3); strgetitem(commandline, &arg, ' ', 3);
format=arg[0]; format = arg[0];
} }
switch (format) { switch (format)
{
case 'c': case 'c':
pointerb=address; pointerb = address;
nbligne=12; nbligne = 12;
break; break;
case 'b': case 'b':
pointerb=address; pointerb = address;
nbligne=22; nbligne = 22;
break; break;
case 'w': case 'w':
pointerw=address; pointerw = address;
nbligne=13; nbligne = 13;
break; break;
case 'd': case 'd':
pointerd=address; pointerd = address;
nbligne=7; nbligne = 7;
break; break;
} }
if (strgetnbitems(commandline, ' ') == 5) if (strgetnbitems(commandline, ' ') == 5)
{ {
strgetitem(commandline, &arg, ' ', 4); strgetitem(commandline, &arg, ' ', 4);
nbligne=strtoint(&arg); nbligne = strtoint(&arg);
} }
printf("Adresse %Y - % hhu",address,size); printf("Adresse %Y - % hhu", address, size);
for(u32 i=0;i<size;i++) for (u32 i = 0; i < size; i++)
switch (format) { switch (format)
{
case 'c': case 'c':
if (i%nbligne==0) if (i % nbligne == 0)
printf("\r\n:%Y - ",pointerb); printf("\r\n:%Y - ", pointerb);
printf("%hhY \33[40C%c\33[41D",*(pointerb),*(pointerb++)); printf("%hhY \33[40C%c\33[41D",
*(pointerb), *(pointerb++));
break; break;
case 'b': case 'b':
if (i%nbligne==0) if (i % nbligne == 0)
printf("\r\n:%Y - ",pointerb); printf("\r\n:%Y - ", pointerb);
printf("%hhY ",*(pointerb++)); printf("%hhY ", *(pointerb++));
break; break;
case 'w': case 'w':
if (i%nbligne==0) if (i % nbligne == 0)
printf("\r\n:%Y - ",pointerw); printf("\r\n:%Y - ", pointerw);
printf("%hY ",*(pointerw++)); printf("%hY ", *(pointerw++));
break; break;
case 'd': case 'd':
if (i%nbligne==0) if (i % nbligne == 0)
printf("\r\n:%Y - ",pointerd); printf("\r\n:%Y - ", pointerd);
printf("%Y ",*(pointerd++)); printf("%Y ", *(pointerd++));
break; break;
} }
} }
/*******************************************************************************/ /*******************************************************************************/
/* Génère des exceptions */ /* Génère des exceptions */
int err(u8* commandline) int err(u8 * commandline)
{ {
u8 arg[] = " \000"; u8 arg[] = " \000";
u32 argint; u32 argint;
@ -348,7 +359,7 @@ int err(u8* commandline)
return; return;
} }
strgetitem(commandline, &arg, ' ', 1); strgetitem(commandline, &arg, ' ', 1);
argint=strtoint(&arg); argint = strtoint(&arg);
switch (argint) switch (argint)
{ {
case 0: case 0:
@ -357,7 +368,7 @@ int err(u8* commandline)
break; break;
case 1: case 1:
print("Creation d'un breakpoint !\r\n"); print("Creation d'un breakpoint !\r\n");
setdebugreg(0,&test, DBG_EXEC); setdebugreg(0, &test, DBG_EXEC);
test(); test();
break; break;
case 2: case 2:
@ -402,11 +413,13 @@ int err(u8* commandline)
asm("mov $0x666, %ax; ltr %ax"); asm("mov $0x666, %ax; ltr %ax");
break; break;
case 14: case 14:
if (random(0, 100)>50) { if (random(0, 100) > 50)
{
print("Creation d'une erreur de page en ecriture !\r\n"); print("Creation d'une erreur de page en ecriture !\r\n");
asm("movl $0x66666666,(0xE0000000)"); asm("movl $0x66666666,(0xE0000000)");
} }
else { else
{
print("Creation d'une erreur de page en lecture !\r\n"); print("Creation d'une erreur de page en lecture !\r\n");
asm("movl (0xD0000000),%eax"); asm("movl (0xD0000000),%eax");
} }
@ -450,7 +463,7 @@ int showregs()
/*******************************************************************************/ /*******************************************************************************/
/* Change le mode */ /* Change le mode */
int mode(u8* commandline) int mode(u8 * commandline)
{ {
u8 arg[] = " \000"; u8 arg[] = " \000";
u32 argint; u32 argint;
@ -460,7 +473,7 @@ int mode(u8* commandline)
return; return;
} }
strgetitem(commandline, &arg, ' ', 1); strgetitem(commandline, &arg, ' ', 1);
argint=strtoint(&arg); argint = strtoint(&arg);
changemode(argint); changemode(argint);
return 0; return 0;
} }
@ -490,15 +503,17 @@ int rebootnow()
int test3d() int test3d()
{ {
videoinfos *vinfo=getvideo_info(); videoinfos *vinfo = getvideo_info();
if (!vinfo->isgraphic) { if (!vinfo->isgraphic)
{
print("Mode graphique necessaire afin de lancer ce programme\r\n"); print("Mode graphique necessaire afin de lancer ce programme\r\n");
return 1; return 1;
} }
model3d model; model3d model;
float factor=100.0f; float factor = 100.0f;
type3D type=TYPE3D_POINTS; type3D type = TYPE3D_POINTS;
matrix44 rotatex,rotatey,rotatez,mrotatex,mrotatey,mrotatez,identity; matrix44 rotatex, rotatey, rotatez, mrotatex, mrotatey, mrotatez,
identity;
matrix44_homogen(&identity); matrix44_homogen(&identity);
matrix44_rotation_x(0.1f, &rotatex); matrix44_rotation_x(0.1f, &rotatex);
matrix44_rotation_y(0.1f, &rotatey); matrix44_rotation_y(0.1f, &rotatey);
@ -506,21 +521,22 @@ int test3d()
matrix44_rotation_x(-0.1f, &mrotatex); matrix44_rotation_x(-0.1f, &mrotatex);
matrix44_rotation_y(-0.1f, &mrotatey); matrix44_rotation_y(-0.1f, &mrotatey);
matrix44_rotation_z(-0.1f, &mrotatez); matrix44_rotation_z(-0.1f, &mrotatez);
matrix44* transformation=&identity; matrix44 *transformation = &identity;
vector4 origin={0.0f,0.0f,0.0f,0.0f}; vector4 origin = { 0.0f, 0.0f, 0.0f, 0.0f };
vector4 cubeorigin={0.0f,0.0f,0.0f,0.0f}; vector4 cubeorigin = { 0.0f, 0.0f, 0.0f, 0.0f };
origin.x=vinfo->currentwidth/2.0f; origin.x = vinfo->currentwidth / 2.0f;
origin.y=vinfo->currentheight/2.0f; origin.y = vinfo->currentheight / 2.0f;
origin.z=70.0f; origin.z = 70.0f;
cube(&model, &cubeorigin, 35.0f); cube(&model, &cubeorigin, 35.0f);
u8 achar=' '; u8 achar = ' ';
u8 i; u8 i;
while(achar!='q' && achar!='Q') while (achar != 'q' && achar != 'Q')
{ {
clearscreen(); clearscreen();
show3dmodel(&model, transformation, &origin, factor, type); show3dmodel(&model, transformation, &origin, factor, type);
achar=waitascii(); achar = waitascii();
switch(achar) { switch (achar)
{
case '1': case '1':
load3ds(&man, sizeof(man), &model); load3ds(&man, sizeof(man), &model);
break; break;
@ -528,36 +544,37 @@ int test3d()
load3ds(&sphere, sizeof(sphere), &model); load3ds(&sphere, sizeof(sphere), &model);
break; break;
case 17: case 17:
transformation=&rotatex; transformation = &rotatex;
break; break;
case 18: case 18:
transformation=&mrotatex; transformation = &mrotatex;
break; break;
case 19: case 19:
transformation=&rotatey; transformation = &rotatey;
break; break;
case 20: case 20:
transformation=&mrotatey; transformation = &mrotatey;
break; break;
case 2: case 2:
transformation=&rotatez; transformation = &rotatez;
break; break;
case 3: case 3:
transformation=&mrotatez; transformation = &mrotatez;
break; break;
case '-': case '-':
factor-=10.0; factor -= 10.0;
break; break;
case '+': case '+':
factor+=10.0; factor += 10.0;
break; break;
case '*': case '*':
switch(type) { switch (type)
{
case TYPE3D_POINTS: case TYPE3D_POINTS:
type=TYPE3D_LINES; type = TYPE3D_LINES;
break; break;
case TYPE3D_LINES: case TYPE3D_LINES:
type=TYPE3D_POINTS; type = TYPE3D_POINTS;
break; break;
} }
break; break;
@ -572,41 +589,44 @@ int test3d()
int test2d() int test2d()
{ {
videoinfos *vinfo=getvideo_info(); videoinfos *vinfo = getvideo_info();
if (!vinfo->isgraphic) { if (!vinfo->isgraphic)
{
print("Mode graphique necessaire afin de lancer ce programme\r\n"); print("Mode graphique necessaire afin de lancer ce programme\r\n");
return 1; return 1;
} }
struct vertex2d a, b, c; struct vertex2d a, b, c;
randomize(); randomize();
u32 color; u32 color;
for (int i = 0; i < 2000; i++) { for (int i = 0; i < 2000; i++)
{
a.x = random(0, vinfo->currentwidth); a.x = random(0, vinfo->currentwidth);
a.y = random(0, vinfo->currentheight); a.y = random(0, vinfo->currentheight);
b.x = random(0, vinfo->currentwidth); b.x = random(0, vinfo->currentwidth);
b.y = random(0, vinfo->currentheight); b.y = random(0, vinfo->currentheight);
if (vinfo->currentdepth>24) if (vinfo->currentdepth > 24)
color=egatorgb(random(0,16)); color = egatorgb(random(0, 16));
else if (vinfo->currentdepth==8) else if (vinfo->currentdepth == 8)
color=random(0,63); color = random(0, 63);
else else
color=random(0,16); color = random(0, 16);
v_line(&a,&b,color); v_line(&a, &b, color);
} }
waitascii(); waitascii();
for (int i = 0; i < 2000; i++) { for (int i = 0; i < 2000; i++)
{
a.x = random(0, vinfo->currentwidth); a.x = random(0, vinfo->currentwidth);
a.y = random(0, vinfo->currentheight); a.y = random(0, vinfo->currentheight);
b.x = random(0, vinfo->currentwidth); b.x = random(0, vinfo->currentwidth);
b.y = random(0, vinfo->currentheight); b.y = random(0, vinfo->currentheight);
c.x = random(0, vinfo->currentwidth); c.x = random(0, vinfo->currentwidth);
c.y = random(0, vinfo->currentheight); c.y = random(0, vinfo->currentheight);
if (vinfo->currentdepth>24) if (vinfo->currentdepth > 24)
color=egatorgb(random(0,16)); color = egatorgb(random(0, 16));
else if (vinfo->currentdepth==8) else if (vinfo->currentdepth == 8)
color=random(0,63); color = random(0, 63);
else else
color=random(0,16); color = random(0, 16);
trianglefilled(&a, &b, &c, color); trianglefilled(&a, &b, &c, color);
triangle(&a, &b, &c, egatorgb(4)); triangle(&a, &b, &c, egatorgb(4));
} }
@ -622,38 +642,42 @@ int showidt()
idtdes *desc; idtdes *desc;
struct idtr idtreg; struct idtr idtreg;
sidt(&idtreg); sidt(&idtreg);
printf("Information sur l'IDT\r\nAdresse:%X Limite:%hX\r\n", idtreg.base, printf("Information sur l'IDT\r\nAdresse:%X Limite:%hX\r\n",
(u32) idtreg.limite); idtreg.base, (u32) idtreg.limite);
desc = idtreg.base; desc = idtreg.base;
for (index = 0; index < idtreg.limite / sizeof(idtdes); index++) { for (index = 0; index < idtreg.limite / sizeof(idtdes); index++)
{
u32 select = desc[index].select; u32 select = desc[index].select;
u32 offset = u32 offset =
desc[index].offset0_15 + (desc[index].offset16_31 << 16); desc[index].offset0_15 +
(desc[index].offset16_31 << 16);
u32 type = desc[index].type & 0x0F00; u32 type = desc[index].type & 0x0F00;
u8 *typestr1, *typestr2; u8 *typestr1, *typestr2;
if (i>=32 & i<=39) if (i >= 32 & i <= 39)
typestr1="IRQ master"; typestr1 = "IRQ master";
else if (i>=96 & i<=103) else if (i >= 96 & i <= 103)
typestr1="IRQ slave "; typestr1 = "IRQ slave ";
else if (i<19) else if (i < 19)
typestr1="EXCEPTION "; typestr1 = "EXCEPTION ";
else else
typestr1="INTERRUPT "; typestr1 = "INTERRUPT ";
if (type == INTGATE) if (type == INTGATE)
typestr2="INTGATE"; typestr2 = "INTGATE";
else if (type == TRAPGATE) else if (type == TRAPGATE)
typestr2="TRAPGATE"; typestr2 = "TRAPGATE";
else if (type == TASKGATE) else if (type == TASKGATE)
typestr2="TASKGATE"; typestr2 = "TASKGATE";
else if (type == CALLGATE) else if (type == CALLGATE)
typestr2="CALLGATE"; typestr2 = "CALLGATE";
else if (type == LDTDES) else if (type == LDTDES)
typestr2="LDTDES"; typestr2 = "LDTDES";
else else
print("inconnu"); print("inconnu");
printf("%s % hu %hY:%Y - %s\r\n", typestr1, i++, select, offset, typestr2); printf("%s % hu %hY:%Y - %s\r\n", typestr1, i++, select,
offset, typestr2);
if (i % 32 == 0) { if (i % 32 == 0)
{
print("\r\n<Appuyez sur une touche>\r\n"); print("\r\n<Appuyez sur une touche>\r\n");
waitascii(); waitascii();
} }
@ -669,11 +693,13 @@ int showgdt()
u32 index; u32 index;
struct gdtr gdtreg; struct gdtr gdtreg;
sgdt(&gdtreg); sgdt(&gdtreg);
printf("Information sur la GDT\r\nAdresse:%X Limite:%hX\r\n", gdtreg.base, gdtreg.limite); printf("Information sur la GDT\r\nAdresse:%X Limite:%hX\r\n",
for (index = 0; index < gdtreg.limite ; index+=sizeof(gdtdes)) { gdtreg.base, gdtreg.limite);
for (index = 0; index < gdtreg.limite; index += sizeof(gdtdes))
{
if (!isdesvalid(index)) if (!isdesvalid(index))
printf("\033[31m"); printf("\033[31m");
printf("SEL =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\033[0m\r\n",index,getdesbase(index),getdeslimit(index),getdesdpl(index),getdestype(index),getdessize(index),getdesbit3(index),getdesbit2(index),getdesbit1(index),getdesalign(index)); printf("SEL =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\033[0m\r\n", index, getdesbase(index), getdeslimit(index), getdesdpl(index), getdestype(index), getdessize(index), getdesbit3(index), getdesbit2(index), getdesbit1(index), getdesalign(index));
} }
return 0; return 0;
} }
@ -687,10 +713,7 @@ int detectcpu()
u8 noproc[] = "\033[31mInconnu\033[0m\000"; u8 noproc[] = "\033[31mInconnu\033[0m\000";
strcpy(&noproc, &cpu.detectedname); strcpy(&noproc, &cpu.detectedname);
getcpuinfos(&cpu); getcpuinfos(&cpu);
printf printf("\r\nDetection du processeur\r\033[1m Revision \t:%d\r Modele \t:%d\r Famille \t:%d\r Nom cpuid\t:%s\rJeux d'instruction\t:%s\033[0m\r\n\000", cpu.stepping, cpu.models, cpu.family, &cpu.detectedname, &cpu.techs);
("\r\nDetection du processeur\r\033[1m Revision \t:%d\r Modele \t:%d\r Famille \t:%d\r Nom cpuid\t:%s\rJeux d'instruction\t:%s\033[0m\r\n\000",
cpu.stepping, cpu.models, cpu.family, &cpu.detectedname,
&cpu.techs);
return 0; return 0;
} }

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;
} }
@ -47,7 +48,7 @@ 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;
} }
@ -56,7 +57,7 @@ u32 strlen(const u8 * src)
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;
} }
@ -66,7 +67,8 @@ u8 *strcpy(const u8 * src, u8 * dest)
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++;
@ -83,7 +85,7 @@ 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';
@ -153,7 +159,8 @@ 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 char1 = *dst;
u8 char2 = *src; u8 char2 = *src;
*dst = char2; *dst = char2;
@ -169,7 +176,8 @@ 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);
} }
@ -217,7 +225,8 @@ 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';
} }
@ -243,9 +252,11 @@ 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; u8 i;
for (i = 0; (*(pos + i) != 0) && (*(pos + i) == delim); 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);
@ -289,7 +300,8 @@ u32 strgetnbitems(u8 * src, u8 delim)
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++;
} }
@ -307,7 +319,8 @@ u8 strgetminbase(u8 * src)
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;
@ -337,19 +350,25 @@ 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;
} }
@ -375,11 +394,12 @@ u32 strtoint(u8 * src)
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');

View File

@ -34,11 +34,11 @@ void sysenter_handler(void)
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;
} }
@ -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

@ -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,36 +11,42 @@
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(); struct multiboot_tag_framebuffer *tagfb = getgrubinfo_fb();
u32 len=infos.pagesize*2; u32 len = infos.pagesize * 2;
u32 paddr=tagfb->common.framebuffer_addr; u32 paddr = tagfb->common.framebuffer_addr;
virtual_range_use_kernel(vaddr, paddr, len, PAGE_NOFLAG); virtual_range_use_kernel(vaddr, paddr, len, PAGE_NOFLAG);
infos.baseaddress=vaddr; 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(); struct multiboot_tag_framebuffer *tagfb = getgrubinfo_fb();
switch (tagfb->common.framebuffer_type) switch (tagfb->common.framebuffer_type)
{ {
case MULTIBOOT_FRAMEBUFFER_TYPE_RGB: case MULTIBOOT_FRAMEBUFFER_TYPE_RGB:
vesacapabilities[0].modenumber=0x0; vesacapabilities[0].modenumber = 0x0;
vesacapabilities[0].width=tagfb->common.framebuffer_width; vesacapabilities[0].width =
vesacapabilities[0].height=tagfb->common.framebuffer_height; tagfb->common.framebuffer_width;
vesacapabilities[0].graphic=true; vesacapabilities[0].height =
vesacapabilities[0].depth=tagfb->common.framebuffer_bpp; tagfb->common.framebuffer_height;
vesacapabilities[0].refresh=0x0; vesacapabilities[0].graphic = true;
infos.baseaddress=tagfb->common.framebuffer_addr; vesacapabilities[0].depth =
infos.currentpitch=tagfb->common.framebuffer_pitch; tagfb->common.framebuffer_bpp;
vesacapabilities[0].refresh = 0x0;
infos.baseaddress = tagfb->common.framebuffer_addr;
infos.currentpitch =
tagfb->common.framebuffer_pitch;
return "LEGACY"; return "LEGACY";
break; break;
default: default:
@ -60,53 +66,61 @@ 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;
infos.pagesize = infos.currentheight * infos.currentpitch;
return; 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 =
infos.baseaddress +
infos.currentactivepage * infos.pagesize + dst;
switch (infos.currentdepth)
{
case 32: case 32:
if (!increment_src) if (!increment_src)
{ {
stosd(src,realdst,size); stosd(src, realdst, size);
} }
else else
{ {
@ -119,20 +133,25 @@ u32 VESA_mem_to_video (void *src,u32 dst, u32 size, bool increment_src) {
/*******************************************************************************/ /*******************************************************************************/
/* 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;
u32 realdst =
infos.baseaddress +
infos.currentactivepage * infos.pagesize + dst;
switch (infos.currentdepth)
{
case 32: case 32:
movsd(realsrc,realdst,size>>2); movsd(realsrc, realdst, size >> 2);
break; break;
} }
} }
@ -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);
} }

258
lib/vga.c
View File

@ -13,13 +13,16 @@ 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";
} }
@ -33,7 +36,8 @@ u32 getbase(void)
base = inb(GRAPHICS + 1); base = inb(GRAPHICS + 1);
base >>= 2; base >>= 2;
base &= 3; base &= 3;
switch (base) { switch (base)
{
case 0: case 0:
case 1: case 1:
base = 0xA0000; base = 0xA0000;
@ -57,55 +61,67 @@ 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)
{
infos.currentmode =
vgacapabilities[index].modenumber;
break; break;
} }
index++; index++;
} }
if (infos.currentmode!=mode) if (infos.currentmode != mode)
return 1; return 1;
infos.currentwidth=vgacapabilities[index].width; infos.currentwidth = vgacapabilities[index].width;
infos.currentheight=vgacapabilities[index].height; infos.currentheight = vgacapabilities[index].height;
infos.currentdepth=vgacapabilities[index].depth; infos.currentdepth = vgacapabilities[index].depth;
infos.currentactivepage=0; infos.currentactivepage = 0;
infos.currentshowedpage=0; infos.currentshowedpage = 0;
infos.currentcursorX=0; infos.currentcursorX = 0;
infos.currentcursorY=0; infos.currentcursorY = 0;
infos.currentfont1=0; infos.currentfont1 = 0;
infos.currentfont2=0; infos.currentfont2 = 0;
infos.isgraphic=vgacapabilities[index].graphic; infos.isgraphic = vgacapabilities[index].graphic;
infos.isblinking=false; infos.isblinking = false;
infos.iscursorvisible=false; infos.iscursorvisible = false;
if (infos.isgraphic) { if (infos.isgraphic)
switch (infos.currentdepth) { {
switch (infos.currentdepth)
{
case 1: case 1:
/* mode N&B */ /* mode N&B */
infos.currentpitch = infos.currentwidth; infos.currentpitch = infos.currentwidth;
realsize=1; realsize = 1;
break; break;
case 2: case 2:
/* mode 4 couleurs */ /* mode 4 couleurs */
infos.currentpitch = (infos.currentwidth << 1); infos.currentpitch =
realsize=2; (infos.currentwidth << 1);
realsize = 2;
break; break;
case 4: case 4:
/* mode 16 couleurs */ /* mode 16 couleurs */
infos.currentpitch = infos.currentwidth; infos.currentpitch = infos.currentwidth;
realsize=4; realsize = 4;
break; break;
case 8: case 8:
/* mode 256 couleurs */ /* mode 256 couleurs */
if (modes[index].sequencer.Sequencer_Memory_Mode_Register == 0x0E) { if (modes[index].sequencer.
Sequencer_Memory_Mode_Register == 0x0E)
{
/* mode chainé (plus rapide mais limité en mémoire) */ /* mode chainé (plus rapide mais limité en mémoire) */
infos.currentpitch = infos.currentwidth; infos.currentpitch =
realsize=8; infos.currentwidth;
} else { realsize = 8;
}
else
{
/* mode non chainé */ /* mode non chainé */
infos.currentpitch = infos.currentwidth >> 2; infos.currentpitch =
realsize=9; infos.currentwidth >> 2;
realsize = 9;
} }
break; break;
default: default:
@ -113,13 +129,16 @@ u8 VGA_setvideo_mode(u8 mode)
} }
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.pagesnumber = (PLANESIZE / infos.pagesize);
infos.baseaddress=(modes[index].ctrc.Cursor_Location_High_Register << 8) + modes[index].ctrc.Cursor_Location_Low_Register + getbase(); 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,38 +164,44 @@ 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; {
u32 realdst =
infos.baseaddress +
infos.currentactivepage * infos.pagesize + dst;
switch (realsize) switch (realsize)
{ {
case 0: case 0:
if (!increment_src) if (!increment_src)
{ {
u8 tmp=(u8) src; u8 tmp = (u8) src;
memset(realdst,tmp,size,2); memset(realdst, tmp, size, 2);
} }
else else
{ {
memcpy(src,realdst,size,2); memcpy(src, realdst, size, 2);
} }
break; break;
case 1: case 1:
@ -191,35 +216,40 @@ u32 VGA_mem_to_video (void *src,u32 dst, u32 size, bool increment_src) {
case 8: case 8:
if (!increment_src) if (!increment_src)
{ {
u8 tmp=(u8) (src); u8 tmp = (u8) (src);
if (size%4 == 0) if (size % 4 == 0)
{ {
u32 pattern = tmp + (tmp<<8) + (tmp<<16) + (tmp<<24); u32 pattern =
stosd(pattern,realdst,(size>>2)); tmp + (tmp << 8) +
(tmp << 16) + (tmp << 24);
stosd(pattern, realdst,
(size >> 2));
} }
else if (size%2 == 0) else if (size % 2 == 0)
{ {
u32 pattern = tmp + (tmp<<8); u32 pattern = tmp + (tmp << 8);
stosw(pattern,realdst,(size>>1)); stosw(pattern, realdst,
(size >> 1));
} }
else else
{ {
u32 pattern = tmp; u32 pattern = tmp;
stosb(pattern,realdst,size); stosb(pattern, realdst, size);
} }
} }
else {
if (size%4 == 0)
{
movsd(src,realdst,size>>2);
}
else if (size%2 == 0)
{
movsw(src,realdst,size>>1);
}
else else
{ {
movsb(src,realdst,size); if (size % 4 == 0)
{
movsd(src, realdst, size >> 2);
}
else if (size % 2 == 0)
{
movsw(src, realdst, size >> 1);
}
else
{
movsb(src, realdst, size);
} }
} }
break; break;
@ -233,13 +263,15 @@ u32 VGA_mem_to_video (void *src,u32 dst, u32 size, bool increment_src) {
/*******************************************************************************/ /*******************************************************************************/
/* 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 =
infos.baseaddress +
infos.currentactivepage * infos.pagesize + src;
switch (realsize) switch (realsize)
{ {
case 0: case 0:
memcpy(realsrc,dst,size,2); memcpy(realsrc, dst, size, 2);
break; break;
case 1: case 1:
@ -263,26 +295,28 @@ u32 VGA_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 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;
u32 realsrc = base + src;
u32 realdst = base + dst;
switch (realsize) switch (realsize)
{ {
case 8: case 8:
case 0: case 0:
if (size%4 == 0) if (size % 4 == 0)
{ {
movsd(realsrc,realdst,size>>2); movsd(realsrc, realdst, size >> 2);
} }
else if (size%2 == 0) else if (size % 2 == 0)
{ {
movsw(realsrc,realdst,size>>1); movsw(realsrc, realdst, size >> 1);
} }
else else
{ {
movsb(realsrc,realdst,size); movsb(realsrc, realdst, size);
} }
break; break;
case 1: case 1:
@ -316,7 +350,8 @@ 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);
@ -330,11 +365,12 @@ 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; u16 addr;
if (!infos.isgraphic) if (!infos.isgraphic)
addr = (y << 3); addr = (y << 3);
@ -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,13 +429,14 @@ void VGA_wait_hretrace(void)
void VGA_cursor_enable(void) void VGA_cursor_enable(void)
{ {
if (!infos.isgraphic) { if (!infos.isgraphic)
{
u8 curs; u8 curs;
/* active le curseur hardware */ /* active le curseur hardware */
outb(CCRT, 10); outb(CCRT, 10);
curs = inb(CCRT + 1) & ~32; curs = inb(CCRT + 1) & ~32;
outb(CCRT + 1, curs); outb(CCRT + 1, curs);
infos.iscursorvisible=true; infos.iscursorvisible = true;
} }
} }
@ -408,13 +445,14 @@ void VGA_cursor_enable(void)
void VGA_cursor_disable(void) void VGA_cursor_disable(void)
{ {
if (!infos.isgraphic) { if (!infos.isgraphic)
{
u8 curs; u8 curs;
/* Desactive le curseur hardware */ /* Desactive le curseur hardware */
outb(CCRT, 10); outb(CCRT, 10);
curs = inb(CCRT + 1) | 32; curs = inb(CCRT + 1) | 32;
outb(CCRT + 1, curs); outb(CCRT + 1, curs);
infos.iscursorvisible=false; infos.iscursorvisible = false;
} }
} }
@ -439,18 +477,20 @@ 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; u16 pos;
if (splitY == 0) if (splitY == 0)
pos = (infos.currentshowedpage * infos.pagesize / 2 + x + y * infos.currentwidth); pos = (infos.currentshowedpage * infos.pagesize /
2 + x + y * infos.currentwidth);
else else
pos = (x + y * infos.currentwidth); pos = (x + y * infos.currentwidth);
outb(CCRT, 0x0F); outb(CCRT, 0x0F);
outb(CCRT + 1, (u8) (pos & 0x00FF)); outb(CCRT + 1, (u8) (pos & 0x00FF));
outb(CCRT, 0x0E); outb(CCRT, 0x0E);
outb(CCRT + 1, (u8) ((pos & 0xFF00) >> 8)); outb(CCRT + 1, (u8) ((pos & 0xFF00) >> 8));
infos.currentcursorX=x; infos.currentcursorX = x;
infos.currentcursorY=y; infos.currentcursorY = y;
} }
} }
@ -470,7 +510,8 @@ u32 VGA_font_load(u8 * def, u8 size, u8 font)
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,13 +554,14 @@ 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; num &= 0x07;
outb(SEQUENCER, 3); outb(SEQUENCER, 3);
outb(SEQUENCER + 1, outb(SEQUENCER + 1,
(inb(SEQUENCER + 1) & 0xEC) | ((num & 0x03) + (inb(SEQUENCER + 1) & 0xEC) | ((num & 0x03) +
((num & 0x04) << 2))); ((num & 0x04) << 2)));
infos.currentfont1=num; infos.currentfont1 = num;
} }
} }
@ -527,13 +570,14 @@ 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; num &= 0x07;
outb(SEQUENCER, 3); outb(SEQUENCER, 3);
outb(SEQUENCER + 1, outb(SEQUENCER + 1,
(inb(SEQUENCER + 1) & 0xD3) | (((num & 0x03) << 2) + (inb(SEQUENCER + 1) & 0xD3) | (((num & 0x03) << 2) +
((num & 0x04) << 3))); ((num & 0x04) << 3)));
infos.currentfont2=num; infos.currentfont2 = num;
} }
} }
@ -542,10 +586,11 @@ 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, 0x10);
outb(CCRT + 1, (inb(SEQUENCER + 1) | 0x04)); outb(CCRT + 1, (inb(SEQUENCER + 1) | 0x04));
infos.isblinking=true; infos.isblinking = true;
} }
} }
@ -554,10 +599,11 @@ 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, 0x10);
outb(CCRT + 1, (inb(SEQUENCER + 1) & ~0x04)); outb(CCRT + 1, (inb(SEQUENCER + 1) & ~0x04));
infos.isblinking=false; infos.isblinking = false;
} }
} }
@ -568,7 +614,8 @@ 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++);
} }
@ -581,7 +628,8 @@ 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++);
@ -595,7 +643,8 @@ 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);
} }
@ -608,7 +657,8 @@ 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

@ -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

@ -36,35 +36,35 @@ 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

@ -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);
@ -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)
@ -105,7 +109,7 @@ int main(u32 magic, u32 addr)
finit(); finit();
ok(); ok();
retry: retry:
sti(); sti();
shell(); shell();
} }