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
arguments : 0
résultat : oui (0x66666666)
*Description: function to test if the syscall mecanism is running.*
* 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 ?
COS2000 n'a pas pour but d'être utilisé en exploitation, c'est un système en cours de
développement. Vous pouvez néanmoins l'utiliser sur un ordinateur physique ou une machine virtuelle
afin de voir le fonctionnement d'un système d'exploitation rudimentatire. Voir compilation de COS2000...
COS2000 n'a pas pour but d'être utilisé en production. Il s'agit d'un système en cours de
développement que vous pouvez néanmoins tester sur un ordinateur physique ou de préférence sur une machine virtuelle.
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 ?
@ -41,6 +41,10 @@ COS2000 est sous licence LGPL v3.0, en simplifiant un peu :
* REUTILISER - OUI en citant l'auteur
* 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
#### Avant la compilation
@ -57,23 +61,34 @@ Les numéros de version des logiciels sont données à titre indicatif car il es
Compilation:
* NASM version 2.11.08
* gcc version 5.4.0 20160609
* GNU Make version 4.1
* binutils version 2.26-8
Nom | Paquet | Version
--- | --- | ---
NASM | nasm | 2.11.08
gcc | gcc | 5.4.0 20160609
GNU Make | make | 4.1
Outils divers | binutils | 2.26-8
Images disques, débogage & émulation:
* fuse-umfuse-ext2 version 0.4 29
* fusefat version 0.1a-1.1
* CGDB: a curses debugger version 0.6.7
* QEMU emulator version 2.5.0
* OVMF version 0~20160408.ffea0a2c-2
* hexdump (bsdmainutils version 9.0.6)
* dd (coreutils version 8.25-2)
* tar version 1.28-2.1
* GNU indent version 2.2.11
* Bochs (optionnel)
Nom | Paquet | Version
--- | --- | ---
fuse-umfuse-ext2 | fuseext2 | 0.4 29
fusefat | fusefat | 0.1a-1.1
CGDB: a curses debugger | cgdb | 0.6.7
QEMU emulator | qemu | 2.5.0
OVMF | ovmf | 0~20160408.ffea0a2c-2
hexdump | bsdmainutils | 9.0.6
dd | coreutils | 8.25-2
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
@ -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 :
```sudo apt-get install git```
`sudo apt-get install git`
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
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
```make install```
`make install`
#### Compilation
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
* ```make harddisk``` compile la version disque dur
* ```make uefi``` compile la version disque dur UEFI
* ```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 test64``` lance l'émulation QEMU en 64 bits sur disque dur en UEFI
* ```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
* `make harddisk` compile la version disque dur
* `make uefi` compile la version disque dur UEFI
* `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 test64` lance l'émulation QEMU en 64 bits sur disque dur en UEFI
* `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
#### Utilisation
##### 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
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é) :
```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).
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é)
```lsblk```
`lsblk`
##### Usage de COS2000
Pour l'instant quelques commandes seulement sont disponibles:
* REBOOT redémarre le PC,
* CLEAR efface l'écran,
* MODE change le mode video,
* DETECTCPU detecte et affiche les informations CPU,
* DETECTPCI detecte et affiche les périphériques PCI,
* TEST2D teste l'affichage graphique 2D,
* TEST3D teste l'affichage graphique 2D,
* REGS affiche les registres CPU,
* GDT affiche la table des descripteurs,
* IDT affiche la table des interruptions,
* MEM affiche les statistiques d'occupation memoire,
* INFO affiche des informations issues de GRUB,
* ERR génère une exception (ARGUMENTS),
* VIEW visionne la mémoire vive (ARGUMENTS),
* LOGO affiche le logo,
* FONT change la police d'affichage (ARGUMENTS),
* HELP affiche les commandes disponibles,
* BPSET met un point d'arrêt pour le débogueur (ARGUMENTS),
* BPCLR efface un point d'arrêt (ARGUMENTS),
* DISASM désassemble une portion de mémoire (ARGUMENTS),
* `REBOOT` redémarre le PC,
* `CLEAR` efface l'écran,
* `MODE` change le mode video,
* `DETECTCPU` detecte et affiche les informations CPU,
* `DETECTPCI` detecte et affiche les périphériques PCI,
* `TEST2D` teste l'affichage graphique 2D,
* `TEST3D` teste l'affichage graphique 2D,
* `REGS` affiche les registres CPU,
* `GDT` affiche la table des descripteurs,
* `IDT` affiche la table des interruptions,
* `MEM` affiche les statistiques d'occupation memoire,
* `INFO` affiche des informations issues de GRUB,
* `ERR` génère une exception (ARGUMENTS),
* `VIEW` visionne la mémoire vive (ARGUMENTS),
* `LOGO` affiche le logo,
* `FONT` change la police d'affichage (ARGUMENTS),
* `HELP` affiche les commandes disponibles,
* `BPSET` met un point d'arrêt pour le débogueur (ARGUMENTS),
* `BPCLR` efface un point d'arrêt (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)
#### Organisation du dépôt
* debug - fichiers configuration débogueur
* final - img raw utilisables avec un émulateur des 3 versions
* * harddisk.img.final
* * harddiskuefi.img.final
* * floppy.img.final
* Graphisme - fichiers images
* * screenshots - screenshots de l'évolution du système
* * Thème - thème de démarrage COS2000 pour plymouth
* include - fichier d'entête C
* lib - librairies pour le noyau
* makefile - Makefile du projet
* programs - programme pour le domaine utilisateur (en cours)
* README.md - ce que vous lisez
* system - le noyau lui-même
* `debug` - fichiers configuration débogueur
* `final` - img raw utilisables avec un émulateur des 3 versions
* * `harddisk.img.final`
* * `harddiskuefi.img.final`
* * `floppy.img.final`
* `Graphisme` - fichiers images
* * `screenshots` - screenshots de l'évolution du système
* * `Thème` - thème de démarrage COS2000 pour plymouth
* `include` - fichier d'entête C
* `lib` - librairies pour le noyau
* `makefile` - Makefile du projet
* `programs` - programmes pour le domaine utilisateur
* * `include` - fichier d'entête C
* * `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...
@ -201,10 +221,14 @@ Pour l'instant quelques commandes seulement sont disponibles:
* mode protégé limité à 4Go de mémoire vive (32 bits),
* gestion avancée de la mémoire (vmalloc).
#### A faire
#### En cours
* espace utilisateur et appels systèmes,
* ordonnanceur de tâche (par TSS),
* liste d'API automatiquement mise à jour,
#### A faire
* chargeur ELF32,
* pilote IDE/ATA (PIO mode),
* 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)
#### 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
* Version 2.2fr - C en mode protégé Reprise du projet
* Version 2.1fr - C en mode protégé Abandon du projet

View File

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

View File

@ -4,113 +4,113 @@
#include "types.h"
#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;")
#define irqendslave() asm("movb $0x20,%al; \
# define irqendslave() asm("movb $0x20,%al; \
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))
#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));
#define movsw(src,dst,count) \
# define movsw(src,dst,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));
#define stosb(pattern,dst,count) \
# define stosb(pattern,dst,count) \
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));
#define stosd(pattern,dst,count) \
# define stosd(pattern,dst,count) \
asm volatile ("cld;rep stosl"::"c" (count), "D" (dst), "a" (pattern));
#define rol(addr) \
# define rol(addr) \
asm volatile ("rolb $0x1,%0":"=m" (addr):);
#define ror(addr) \
# define ror(addr) \
asm volatile ("rorb $0x1,%0":"=m" (addr):);
#define finit() \
# define finit() \
asm volatile ("finit"::);
/******************************************************************************/
#define outb(port,value) \
# define outb(port,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));
#define outd(port,value) \
# define outd(port,value) \
asm volatile ("outl %%eax,%%dx"::"d" (port), "a" (value));
/******************************************************************************/
#define inb(port) ({ \
# define inb(port) ({ \
u8 _v; \
asm volatile ("inb %%dx,%%al" : "=a" (_v) : "d" (port)); \
_v; \
})
#define inw(port) ({ \
# define inw(port) ({ \
u16 _v; \
asm volatile ("inw %%dx,%%ax" : "=a" (_v) : "d"(port)); \
_v; \
})
#define ind(port) ({ \
# define ind(port) ({ \
u32 _v; \
asm volatile ("inl %%dx,%%eax" : "=a" (_v) : "d"(port)); \
_v; \
@ -120,7 +120,7 @@
/* pas terminé */
#define rolb(input,rotate) ({ \
# define rolb(input,rotate) ({ \
u32 _v; \
asm volatile ("roll %1,%0" : "=g" (_v) : "cI" (rotate), "0" (input)); \
_v; \

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,123 +5,135 @@
#include "queue.h"
#ifndef _MEMORY
#define _MEMORY
# define _MEMORY
#define TOPAGE(addr) (addr) >> 12
#define TOPD(addr) ((addr) & 0xFFC00000) >> 22
#define TOPT(addr) ((addr) & 0x003FF000) >> 12
#define TOPG(addr) (addr) & 0x00000FFF
# define TOPAGE(addr) (addr) >> 12
# define TOPD(addr) ((addr) & 0xFFC00000) >> 22
# define TOPT(addr) ((addr) & 0x003FF000) >> 12
# define TOPG(addr) (addr) & 0x00000FFF
#define PAGESIZE 4096 /* Taille d'une page */
#define PAGENUMBER 1024 /* Nombre de pages */
#define KERNELSIZE PAGESIZE*PAGENUMBER*2 /* 2 pages de 4mo en identity mapping */
# define PAGESIZE 4096
/* Taille d'une page */
# 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 GDT_ADDR 0x00000800 /* adresse de la GDT */
#define KERNEL_PD_ADDR 0x00001000 /* adresse de la page directory */
#define KERNEL_STACK_ADDR 0x0009FFFF /* adresse de la pile du kernel */
#define KERNEL_CODE_ADDR 0x00100000 /* adresse du code du noyau */
#define KERNEL_PAGES 0x00800000 /* adresse des pages */
#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 */
# define IDT_ADDR 0x00000000 /* adresse de la IDT */
# define GDT_ADDR 0x00000800 /* adresse de la GDT */
# define KERNEL_PD_ADDR 0x00001000
/* adresse de la page directory */
# define KERNEL_STACK_ADDR 0x0009FFFF
/* adresse de la pile du kernel */
# define KERNEL_CODE_ADDR 0x00100000
/* adresse du code du noyau */
# define KERNEL_PAGES 0x00800000 /* adresse des pages */
# 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 */
#define MAXMEMSIZE 0x100000000
#define MAXMEMPAGE 1024*1024
#define MAXHEAPSIZE VESA_FBMEM-KERNEL_HEAP
#define MAXPAGESSIZE KERNEL_HEAP-KERNEL_PAGES
# define MAXMEMSIZE 0x100000000
# define MAXMEMPAGE 1024*1024
# define MAXHEAPSIZE VESA_FBMEM-KERNEL_HEAP
# define MAXPAGESSIZE KERNEL_HEAP-KERNEL_PAGES
/* page directory */
#define PAGE_NOFLAG 0x0
#define PAGE_PRESENT 0b000000001/* page directory / table */
#define PAGE_WRITE 0b000000010 /* page lecture ecriture */
#define PAGE_ALL 0b000000100 /* accessible user & supervisor */
#define PAGE_WTROUGH 0b000001000 /* write-through cache */
#define PAGE_NOCACHE 0b000010000 /* cache desactivé */
#define PAGE_ACCESS 0b000100000 /* page accedée */
#define PAGE_4MB 0b010000000 /* page de 4mb au lieu de 4k (NECESSITE PSE)*/
# define PAGE_NOFLAG 0x0
# define PAGE_PRESENT 0b000000001 /* page directory / table */
# define PAGE_WRITE 0b000000010 /* page lecture ecriture */
# define PAGE_ALL 0b000000100 /* accessible user & supervisor */
# define PAGE_WTROUGH 0b000001000 /* write-through cache */
# define PAGE_NOCACHE 0b000010000 /* cache desactivé */
# define PAGE_ACCESS 0b000100000 /* page accedée */
# define PAGE_4MB 0b010000000 /* page de 4mb au lieu de 4k (NECESSITE PSE) */
/* page table */
#define PAGE_CACHE 0b000010000 /* page en cache */
#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_CACHE 0b000010000 /* page en cache */
# 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) */
/* Selecteur RPL */
#define RPL_RING0 0b00 /* Anneau 0 */
#define RPL_RING1 0b01 /* Anneau 1 */
#define RPL_RING2 0b01 /* Anneau 2 */
#define RPL_RING3 0b11 /* Anneau 3 */
# define RPL_RING0 0b00 /* Anneau 0 */
# define RPL_RING1 0b01 /* Anneau 1 */
# define RPL_RING2 0b01 /* Anneau 2 */
# 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) );
/* Malloc, pour l'attribution de mémoire en heap */
typedef struct tmalloc {
u32 size:31;
u32 used:1;
typedef struct tmalloc
{
u32 size:31;
u32 used:1;
} __attribute__ ((packed)) tmalloc;
/* Page, pour la gestion de la mémoire virtuelle */
typedef struct page {
u8 *vaddr;
u8 *paddr;
TAILQ_ENTRY(page) tailq;
} __attribute__ ((packed)) page;
typedef struct page
{
u8 *vaddr;
u8 *paddr;
TAILQ_ENTRY(page) tailq;
} __attribute__ ((packed)) page;
typedef TAILQ_HEAD(page_s, page) page_t;
/* Page directory, pour la gestion de la mémoire virtuelle */
typedef struct pd {
page *addr;
page_t page_head;
} __attribute__ ((packed)) pd;
typedef struct pd
{
page *addr;
page_t page_head;
} __attribute__ ((packed)) pd;
/* vaddrrange, pour la gestion des pages de la mémoire virtuelle */
typedef struct vrange {
u8 *vaddrlow;
u8 *vaddrhigh;
TAILQ_ENTRY(vrange) tailq;
} __attribute__ ((packed)) vrange;
typedef struct vrange
{
u8 *vaddrlow;
u8 *vaddrhigh;
TAILQ_ENTRY(vrange) tailq;
} __attribute__ ((packed)) vrange;
typedef TAILQ_HEAD(vrange_s, vrange) vrange_t;
typedef TAILQ_HEAD(vrange_s, vrange) vrange_t;
void panic(u8 *string);
void memset(void *dst, u8 val, u32 count,u32 size);
void memcpy(void *src, void *dst, u32 count, u32 size);
u32 memcmp(void *src, void *dst, u32 count, u32 size);
u64 getmemoryfree(void);
u64 physical_getmemorysize();
void physical_page_use(u32 page);
void physical_page_free(u32 page);
void physical_range_use(u64 addr,u64 len);
void physical_range_free(u64 addr,u64 len);
u8* physical_page_getfree(void);
void physical_init(void);
void initpaging(void);
void virtual_init(void);
tmalloc *mallocpage(u64 size);
void *vmalloc(u32 size);
void vfree(void *vaddr);
page *virtual_page_getfree(void);
pd *virtual_pd_create();
void virtual_pd_destroy(pd *dst);
void virtual_page_free(u8* vaddr);
u8* virtual_to_physical(u8 *vaddr);
void virtual_pd_page_remove(u8* vaddr);
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_free(pd *dst, u8 *vaddr, u64 len);
void virtual_range_new(pd *dst, u8 *vaddr, u64 len, u32 flags);
void malloc_init(void);
void identity_init(void);
void registry_init(void);
u32 getmallocused(void);
u32 getmallocfree(void);
u32 getmallocnonallocated(void);
u32 virtual_getpagesfree();
void panic(u8 * string);
void memset(void *dst, u8 val, u32 count, u32 size);
void memcpy(void *src, void *dst, u32 count, u32 size);
u32 memcmp(void *src, void *dst, u32 count, u32 size);
u64 getmemoryfree(void);
u64 physical_getmemorysize();
void physical_page_use(u32 page);
void physical_page_free(u32 page);
void physical_range_use(u64 addr, u64 len);
void physical_range_free(u64 addr, u64 len);
u8 *physical_page_getfree(void);
void physical_init(void);
void initpaging(void);
void virtual_init(void);
tmalloc *mallocpage(u64 size);
void *vmalloc(u32 size);
void vfree(void *vaddr);
page *virtual_page_getfree(void);
pd *virtual_pd_create();
void virtual_pd_destroy(pd * dst);
void virtual_page_free(u8 * vaddr);
u8 *virtual_to_physical(u8 * vaddr);
void virtual_pd_page_remove(u8 * vaddr);
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_free(pd * dst, u8 * vaddr, u64 len);
void virtual_range_new(pd * dst, u8 * vaddr, u64 len, u32 flags);
void malloc_init(void);
void identity_init(void);
void registry_init(void);
u32 getmallocused(void);
u32 getmallocfree(void);
u32 getmallocnonallocated(void);
u32 virtual_getpagesfree();
#endif

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,22 +2,22 @@
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#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;
#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);
#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_copy(dest, src) (dest) = (src)
void va_end(__gnuc_va_list);
# 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_copy(dest, src) (dest) = (src)
typedef __gnuc_va_list va_list;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

51344
lib/3D/man.c

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

473
lib/3d.c
View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -1,4 +1,4 @@
static u8 ansilogo[]="\
static u8 ansilogo[] = "\
\033[0m\033[1m\
\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\

View File

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

290
lib/cpu.c
View File

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

File diff suppressed because it is too large Load Diff

119
lib/gdt.c
View File

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

View File

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

View File

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

View File

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

View File

@ -10,154 +10,155 @@
void vector4_show(vector4 src)
{
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 */
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->y = y;
dst->z = z;
dst->w = w;
dst->x = x;
dst->y = y;
dst->z = z;
dst->w = w;
}
/*******************************************************************************/
/* Copie un vecteur de 4 composantes */
void vector4_copy(vector4 src, vector4 *dst)
void vector4_copy(vector4 src, vector4 * dst)
{
vector4_create(src.x, src.y, src.z, src.w, dst);
vector4_create(src.x, src.y, src.z, src.w, dst);
}
/*******************************************************************************/
/* Ajoute deux vecteurs de 4 composantes */
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->y = v1.y + v2.y;
dst->z = v1.z + v2.z;
dst->x = v1.x + v2.x;
dst->y = v1.y + v2.y;
dst->z = v1.z + v2.z;
}
/*******************************************************************************/
/* 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->y = v1.y - v2.y;
dst->z = v1.z - v2.z;
dst->x = v1.x - v2.x;
dst->y = v1.y - v2.y;
dst->z = v1.z - v2.z;
}
/*******************************************************************************/
/* Redimensionne un vecteur de 4 composantes */
void vector4_scale(vector4 *dst, float factor)
void vector4_scale(vector4 * dst, float factor)
{
dst->x *= factor;
dst->y *= factor;
dst->z *= factor;
dst->w *= factor;
dst->x *= factor;
dst->y *= factor;
dst->z *= factor;
dst->w *= factor;
}
/*******************************************************************************/
/* 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->y = v1.z * v2.x - v1.x * v2.z;
dst->z = v1.x * v2.y - v1.y * v2.x;
dst->x = v1.y * v2.z - v1.z * v2.y;
dst->y = v1.z * v2.x - v1.x * v2.z;
dst->z = v1.x * v2.y - v1.y * v2.x;
}
/*******************************************************************************/
/* Normalise un vecteur de 4 composantes */
void vector4_normalize(vector4 *dst)
void vector4_normalize(vector4 * dst)
{
float len;
float norm;
norm = vector4_norm(*dst);
if (norm != 0)
{
len = 1 / norm;
dst->x = dst->x * len;
dst->y = dst->y * len;
dst->z = dst->z * len;
dst->w = 0;
}
float len;
float norm;
norm = vector4_norm(*dst);
if (norm != 0)
{
len = 1 / norm;
dst->x = dst->x * len;
dst->y = dst->y * len;
dst->z = dst->z * len;
dst->w = 0;
}
}
/*******************************************************************************/
/* 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->y = v1->y / v2.y;
dst->z = v1->z / v2.z;
dst->x = v1->x / v2.x;
dst->y = v1->y / v2.y;
dst->z = v1->z / v2.z;
}
/*******************************************************************************/
/* 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);
dst->x = v1.x - dot * v2.x;
dst->y = v1.y - dot * v2.y;
dst->z = v1.z - dot * v2.z;
float dot = vector4_dotproduct(v1, v2);
dst->x = v1.x - dot * v2.x;
dst->y = v1.y - dot * v2.y;
dst->z = v1.z - dot * v2.z;
}
/*******************************************************************************/
/* 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;
float sinus, cosinus;
sinus = sinf(angle);
cosinus = cosf(angle);
origin.x = dst->x;
origin.y = dst->y;
origin.z = dst->z;
dst->y = cosinus * origin.y + sinus * origin.z;
dst->z = cosinus * origin.z - sinus * origin.y;
vector4 origin;
float sinus, cosinus;
sinus = sinf(angle);
cosinus = cosf(angle);
origin.x = dst->x;
origin.y = dst->y;
origin.z = dst->z;
dst->y = cosinus * origin.y + sinus * origin.z;
dst->z = cosinus * origin.z - sinus * origin.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;
float sinus, cosinus;
sinus = sinf(angle);
cosinus = cosf(angle);
origin.x = dst->x;
origin.y = dst->y;
origin.z = dst->z;
dst->x = cosinus * origin.x + sinus * origin.z;
dst->z = cosinus * origin.z - sinus * origin.x;
vector4 origin;
float sinus, cosinus;
sinus = sinf(angle);
cosinus = cosf(angle);
origin.x = dst->x;
origin.y = dst->y;
origin.z = dst->z;
dst->x = cosinus * origin.x + sinus * origin.z;
dst->z = cosinus * origin.z - sinus * origin.x;
}
/*******************************************************************************/
/* 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;
float sinus, cosinus;
sinus = sinf(angle);
cosinus = cosf(angle);
origin.x = dst->x;
origin.y = dst->y;
origin.z = dst->z;
dst->x = cosinus * origin.x + sinus * origin.y;
dst->y = cosinus * origin.y - sinus * origin.x;
vector4 origin;
float sinus, cosinus;
sinus = sinf(angle);
cosinus = cosf(angle);
origin.x = dst->x;
origin.y = dst->y;
origin.z = dst->z;
dst->x = cosinus * origin.x + sinus * origin.y;
dst->y = cosinus * origin.y - sinus * origin.x;
}
/*******************************************************************************/
@ -165,9 +166,7 @@ void vector4_rotate_z(vector4 *dst, float angle)
float vector4_len(vector4 src)
{
return sqrtf((src.x * src.x) +
(src.y * src.y) +
(src.z * src.z));
return sqrtf((src.x * src.x) + (src.y * src.y) + (src.z * src.z));
}
/*******************************************************************************/
@ -175,7 +174,7 @@ float vector4_len(vector4 src)
float vector4_dotproduct(vector4 v1, vector4 v2)
{
return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z);
return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z);
}
/*******************************************************************************/
@ -183,9 +182,7 @@ float vector4_dotproduct(vector4 v1, vector4 v2)
float vector4_norm(vector4 src)
{
return sqrtf((src.x * src.x) +
(src.y * src.y) +
(src.z * src.z));
return sqrtf((src.x * src.x) + (src.y * src.y) + (src.z * src.z));
}
/*******************************************************************************/
@ -193,9 +190,8 @@ float vector4_norm(vector4 src)
float vector4_distance(vector4 v1, vector4 v2)
{
return sqrt(pow(v2.x - v1.x, 2) +
pow(v2.y - v1.y, 2) +
pow(v2.z - v1.z, 2));
return sqrt(pow(v2.x - v1.x, 2) + pow(v2.y - v1.y, 2) +
pow(v2.z - v1.z, 2));
}
/*******************************************************************************/
@ -203,408 +199,455 @@ float vector4_distance(vector4 v1, vector4 v2)
int vector4_isequals(vector4 v1, vector4 v2)
{
float x, y, z;
x = fabsf(v1.x - v2.x);
y = fabsf(v1.y - v2.y);
z = fabsf(v1.z - v2.z);
return (x < 0.000001 && y < 0.000001 && z < 0.000001);
float x, y, z;
x = fabsf(v1.x - v2.x);
y = fabsf(v1.y - v2.y);
z = fabsf(v1.z - v2.z);
return (x < 0.000001 && y < 0.000001 && z < 0.000001);
}
/*******************************************************************************/
/* 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_sub(v2, v1, &temp1);
vector4_sub(v3, v1, &temp2);
vector4_crossproduct(temp1, temp2, dst);
vector4_normalize(dst);
vector4 temp1, temp2;
vector4_sub(v2, v1, &temp1);
vector4_sub(v3, v1, &temp2);
vector4_crossproduct(temp1, temp2, dst);
vector4_normalize(dst);
}
/*******************************************************************************/
/* 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(0, 1, 0, 0, &matrix->V[1]);
vector4_create(0, 0, 1, 0, &matrix->V[2]);
vector4_create(0, 0, 0, 1, &matrix->V[3]);
vector4_create(1, 0, 0, 0, &matrix->V[0]);
vector4_create(0, 1, 0, 0, &matrix->V[1]);
vector4_create(0, 0, 1, 0, &matrix->V[2]);
vector4_create(0, 0, 0, 1, &matrix->V[3]);
}
/*******************************************************************************/
/* 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[1]);
vector4_create(0, 0, 0, 0, &matrix->V[2]);
vector4_create(0, 0, 0, 0, &matrix->V[3]);
vector4_create(0, 0, 0, 0, &matrix->V[0]);
vector4_create(0, 0, 0, 0, &matrix->V[1]);
vector4_create(0, 0, 0, 0, &matrix->V[2]);
vector4_create(0, 0, 0, 0, &matrix->V[3]);
}
/*******************************************************************************/
/* 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);
dst->V[0].x = v.x;
dst->V[1].y = v.y;
dst->V[2].z = v.z;
matrix44_homogen(dst);
dst->V[0].x = v.x;
dst->V[1].y = v.y;
dst->V[2].z = v.z;
}
/*******************************************************************************/
/* Créé une matrice de déplacement */
void matrix44_translation(vector4 v, matrix44 *dst)
void matrix44_translation(vector4 v, matrix44 * dst)
{
matrix44_homogen(dst);
dst->V[0].x = v.x;
dst->V[1].y = v.y;
dst->V[2].z = v.z;
matrix44_homogen(dst);
dst->V[0].x = v.x;
dst->V[1].y = v.y;
dst->V[2].z = v.z;
}
/*******************************************************************************/
/* 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[1], factor);
vector4_scale(&dst->V[2], factor);
vector4_scale(&dst->V[3], factor);
vector4_scale(&dst->V[0], factor);
vector4_scale(&dst->V[1], factor);
vector4_scale(&dst->V[2], factor);
vector4_scale(&dst->V[3], factor);
}
/*******************************************************************************/
/* 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);
dst->V[0].x = scale.x;
dst->V[1].y = scale.y;
dst->V[2].z = scale.z;
dst->V[3].x = translation.x;
dst->V[3].y = translation.y;
dst->V[3].z = translation.z;
matrix44_homogen(dst);
dst->V[0].x = scale.x;
dst->V[1].y = scale.y;
dst->V[2].z = scale.z;
dst->V[3].x = translation.x;
dst->V[3].y = translation.y;
dst->V[3].z = translation.z;
}
/*******************************************************************************/
/* 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;
cosinus = cosf(angle);
sinus = sinf(angle);
matrix44_empty(dst);
dst->V[0].x = 1;
dst->V[1].y = cosinus;
dst->V[1].z = sinus;
dst->V[2].y = -1 * sinus;
dst->V[2].z = cosinus;
dst->V[3].w = 1;
float sinus, cosinus;
cosinus = cosf(angle);
sinus = sinf(angle);
matrix44_empty(dst);
dst->V[0].x = 1;
dst->V[1].y = cosinus;
dst->V[1].z = sinus;
dst->V[2].y = -1 * sinus;
dst->V[2].z = cosinus;
dst->V[3].w = 1;
}
/*******************************************************************************/
/* 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;
cosinus = cosf(angle);
sinus = sinf(angle);
matrix44_empty(dst);
dst->V[0].x = cosinus;
dst->V[0].z = -1 * sinus;
dst->V[1].y = 1;
dst->V[2].x = sinus;
dst->V[2].z = cosinus;
dst->V[3].w = 1;
float sinus, cosinus;
cosinus = cosf(angle);
sinus = sinf(angle);
matrix44_empty(dst);
dst->V[0].x = cosinus;
dst->V[0].z = -1 * sinus;
dst->V[1].y = 1;
dst->V[2].x = sinus;
dst->V[2].z = cosinus;
dst->V[3].w = 1;
}
/*******************************************************************************/
/* 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;
cosinus = cosf(angle);
sinus = sinf(angle);
matrix44_empty(dst);
dst->V[0].x = cosinus;
dst->V[0].y = sinus;
dst->V[1].x = -1 * sinus;
dst->V[1].y = cosinus;
dst->V[2].z = 1;
dst->V[3].w = 1;
float sinus, cosinus;
cosinus = cosf(angle);
sinus = sinf(angle);
matrix44_empty(dst);
dst->V[0].x = cosinus;
dst->V[0].y = sinus;
dst->V[1].x = -1 * sinus;
dst->V[1].y = cosinus;
dst->V[2].z = 1;
dst->V[3].w = 1;
}
/*******************************************************************************/
/* 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;
sinus = sinf(angle);
cosinus = cosf(angle);
vector4_normalize(&axis);
minuscos = 1 - cosinus;
float cosinus, sinus, minuscos;
sinus = sinf(angle);
cosinus = cosf(angle);
vector4_normalize(&axis);
minuscos = 1 - cosinus;
dst->V[0].x = (minuscos * axis.x * axis.x) + cosinus;
dst->V[0].y = (minuscos * axis.x * axis.y) - (axis.z * sinus);
dst->V[0].z = (minuscos * axis.z * axis.x) + (axis.y * sinus);
dst->V[0].w = 0;
dst->V[0].x = (minuscos * axis.x * axis.x) + cosinus;
dst->V[0].y = (minuscos * axis.x * axis.y) - (axis.z * sinus);
dst->V[0].z = (minuscos * axis.z * axis.x) + (axis.y * sinus);
dst->V[0].w = 0;
dst->V[1].x = (minuscos * axis.x * axis.y) + (axis.z * sinus);
dst->V[1].y = (minuscos * axis.y * axis.y) + cosinus;
dst->V[1].z = (minuscos * axis.y * axis.z) - (axis.x * sinus);
dst->V[1].w = 0;
dst->V[1].x = (minuscos * axis.x * axis.y) + (axis.z * sinus);
dst->V[1].y = (minuscos * axis.y * axis.y) + cosinus;
dst->V[1].z = (minuscos * axis.y * axis.z) - (axis.x * sinus);
dst->V[1].w = 0;
dst->V[2].x = (minuscos * axis.z * axis.x) - (axis.y * sinus);
dst->V[2].y = (minuscos * axis.y * axis.z) + (axis.x * sinus);
dst->V[2].z = (minuscos * axis.z * axis.z) + cosinus;
dst->V[2].w = 0;
dst->V[2].x = (minuscos * axis.z * axis.x) - (axis.y * sinus);
dst->V[2].y = (minuscos * axis.y * axis.z) + (axis.x * sinus);
dst->V[2].z = (minuscos * axis.z * axis.z) + cosinus;
dst->V[2].w = 0;
dst->V[3].x = 0;
dst->V[3].y = 0;
dst->V[3].z = 0;
dst->V[3].w = 1;
dst->V[3].x = 0;
dst->V[3].y = 0;
dst->V[3].z = 0;
dst->V[3].w = 1;
}
/*******************************************************************************/
/* 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 +
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 +
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 +
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 +
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 +
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 +
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 +
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 +
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 +
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 +
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 +
m1->V[2].z * m2->V[2].z + m1->V[2].w * m2->V[3].z);
dst->V[2].w = (m1->V[2].x * m2->V[0].w + m1->V[2].y * m2->V[1].w +
m1->V[2].z * m2->V[2].w + m1->V[2].w * m2->V[3].w);
dst->V[3].x = (m1->V[3].x * m2->V[0].x + m1->V[3].y * m2->V[1].x +
m1->V[3].z * m2->V[2].x + m1->V[3].w * m2->V[3].x);
dst->V[3].y = (m1->V[3].x * m2->V[0].y + m1->V[3].y * m2->V[1].y +
m1->V[3].z * m2->V[2].y + m1->V[3].w * m2->V[3].y);
dst->V[3].z = (m1->V[3].x * m2->V[0].z + m1->V[3].y * m2->V[1].z +
m1->V[3].z * m2->V[2].z + m1->V[3].w * m2->V[3].z);
dst->V[3].w = (m1->V[3].x * m2->V[0].w + m1->V[3].y * m2->V[1].w +
m1->V[3].z * m2->V[2].w + m1->V[3].w * m2->V[3].w);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
dst->V[2].w =
(m1->V[2].x * m2->V[0].w + m1->V[2].y * m2->V[1].w +
m1->V[2].z * m2->V[2].w + m1->V[2].w * m2->V[3].w);
dst->V[3].x =
(m1->V[3].x * m2->V[0].x + m1->V[3].y * m2->V[1].x +
m1->V[3].z * m2->V[2].x + m1->V[3].w * m2->V[3].x);
dst->V[3].y =
(m1->V[3].x * m2->V[0].y + m1->V[3].y * m2->V[1].y +
m1->V[3].z * m2->V[2].y + m1->V[3].w * m2->V[3].y);
dst->V[3].z =
(m1->V[3].x * m2->V[0].z + m1->V[3].y * m2->V[1].z +
m1->V[3].z * m2->V[2].z + m1->V[3].w * m2->V[3].z);
dst->V[3].w =
(m1->V[3].x * m2->V[0].w + m1->V[3].y * m2->V[1].w +
m1->V[3].z * m2->V[2].w + m1->V[3].w * m2->V[3].w);
}
/*******************************************************************************/
/* Transforme une matrice avec un vecteur à 4 composantes */
void matrix44_transform(matrix44 *matrix, vector4 *dst)
void matrix44_transform(matrix44 * matrix, vector4 * dst)
{
vector4 origin;
origin.x = dst->x;
origin.y = dst->y;
origin.z = dst->z;
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->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;
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;
vector4 origin;
origin.x = dst->x;
origin.y = dst->y;
origin.z = dst->z;
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->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;
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 */
float matrix44_determinant(matrix44 *matrix)
float matrix44_determinant(matrix44 * matrix)
{
float a, b, c, d;
a = matrix->V[0].x * todeterminant(matrix->V[1].y, matrix->V[2].y, matrix->V[3].y,
matrix->V[1].z, matrix->V[2].z, matrix->V[3].z,
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, matrix->V[3].x,
matrix->V[1].z, matrix->V[2].z, matrix->V[3].z,
matrix->V[1].w, matrix->V[2].w, matrix->V[3].w);
c = matrix->V[0].z * 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].w, matrix->V[2].w, matrix->V[3].w);
d = matrix->V[0].w * todeterminant(matrix->V[1].x, matrix->V[2].x, matrix->V[3].x,
matrix->V[1].y, matrix->V[2].y, matrix->V[3].y,
matrix->V[1].z, matrix->V[2].z, matrix->V[3].z);
return a - b + c - d;
float a, b, c, d;
a = matrix->V[0].x * todeterminant(matrix->V[1].y, matrix->V[2].y,
matrix->V[3].y, matrix->V[1].z,
matrix->V[2].z, matrix->V[3].z,
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,
matrix->V[3].x, matrix->V[1].z,
matrix->V[2].z, matrix->V[3].z,
matrix->V[1].w, matrix->V[2].w,
matrix->V[3].w);
c = matrix->V[0].z * 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].w, matrix->V[2].w,
matrix->V[3].w);
d = matrix->V[0].w * todeterminant(matrix->V[1].x, matrix->V[2].x,
matrix->V[3].x, matrix->V[1].y,
matrix->V[2].y, matrix->V[3].y,
matrix->V[1].z, matrix->V[2].z,
matrix->V[3].z);
return a - b + c - d;
}
float todeterminant(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3)
float todeterminant(float a1, float a2, float a3, float b1, float b2,
float b3, float c1, float c2, float c3)
{
return (a1 * ((b2 * c3) - (b3 * c2))) - (b1 * ((a2 * c3) - (a3 * c2))) + (c1 * ((a2 * b3) - (a3 * b2)));
return (a1 * ((b2 * c3) - (b3 * c2))) -
(b1 * ((a2 * c3) - (a3 * c2))) +
(c1 * ((a2 * b3) - (a3 * b2)));
}
/*******************************************************************************/
/* Crée une matrice adjointe */
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;
a1 = matrix->V[0].x;
b1 = matrix->V[0].y;
c1 = matrix->V[0].z;
d1 = matrix->V[0].w;
float a1, a2, a3, a4, b1, b2, b3, b4, c1, c2, c3, c4, d1, d2, d3,
d4;
a1 = matrix->V[0].x;
b1 = matrix->V[0].y;
c1 = matrix->V[0].z;
d1 = matrix->V[0].w;
a2 = matrix->V[1].x;
b2 = matrix->V[1].y;
c2 = matrix->V[1].z;
d2 = matrix->V[1].w;
a2 = matrix->V[1].x;
b2 = matrix->V[1].y;
c2 = matrix->V[1].z;
d2 = matrix->V[1].w;
a3 = matrix->V[2].x;
b3 = matrix->V[2].y;
c3 = matrix->V[2].z;
d3 = matrix->V[2].w;
a3 = matrix->V[2].x;
b3 = matrix->V[2].y;
c3 = matrix->V[2].z;
d3 = matrix->V[2].w;
a4 = matrix->V[3].x;
b4 = matrix->V[3].y;
c4 = matrix->V[3].z;
d4 = matrix->V[3].w;
a4 = matrix->V[3].x;
b4 = matrix->V[3].y;
c4 = matrix->V[3].z;
d4 = matrix->V[3].w;
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[2].x = todeterminant(a2, a3, a4, b2, b3, b4, d2, d3, d4);
matrix->V[3].x = -todeterminant(a2, a3, a4, b2, b3, b4, c2, c3, c4);
matrix->V[0].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[2].x = todeterminant(a2, a3, a4, b2, b3, b4, d2, d3, d4);
matrix->V[3].x =
-todeterminant(a2, a3, a4, b2, b3, b4, c2, c3, c4);
matrix->V[0].y = -todeterminant(b1, b3, b4, c1, c3, c4, d1, d3, d4);
matrix->V[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[3].y = todeterminant(a1, a3, a4, b1, b3, b4, c1, c3, c4);
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[2].y =
-todeterminant(a1, a3, a4, b1, b3, b4, d1, d3, d4);
matrix->V[3].y = todeterminant(a1, a3, a4, b1, b3, b4, c1, c3, c4);
matrix->V[0].z = todeterminant(b1, b2, b4, c1, c2, c4, d1, d2, d4);
matrix->V[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[3].z = -todeterminant(a1, a2, a4, b1, b2, b4, c1, c2, c4);
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[2].z = todeterminant(a1, a2, a4, b1, b2, b4, d1, d2, d4);
matrix->V[3].z =
-todeterminant(a1, a2, a4, b1, b2, b4, c1, c2, c4);
matrix->V[0].w = -todeterminant(b1, b2, b3, c1, c2, c3, d1, d2, d3);
matrix->V[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[3].w = todeterminant(a1, a2, a3, b1, b2, b3, c1, c2, c3);
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[2].w =
-todeterminant(a1, a2, a3, b1, b2, b3, d1, d2, d3);
matrix->V[3].w = todeterminant(a1, a2, a3, b1, b2, b3, c1, c2, c3);
}
/*******************************************************************************/
/* Affiche une matrice */
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(" 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("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(" 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 */
void matrix44_invert(matrix44 *matrix)
void matrix44_invert(matrix44 * matrix)
{
float det;
det = matrix44_determinant(matrix);
if (fabs(det) < EPSILON)
{
matrix44_homogen(matrix);
}
else
{
matrix44_adjoint(matrix);
matrix44_scale(matrix, 1.0 / det);
}
float det;
det = matrix44_determinant(matrix);
if (fabs(det) < EPSILON)
{
matrix44_homogen(matrix);
}
else
{
matrix44_adjoint(matrix);
matrix44_scale(matrix, 1.0 / det);
}
}
/*******************************************************************************/
/* Transpose une matrice */
void matrix44_transpose(matrix44 *matrix)
void matrix44_transpose(matrix44 * matrix)
{
float f;
f = matrix->V[0].y;
matrix->V[0].y = matrix->V[1].x;
matrix->V[1].x = f;
float f;
f = matrix->V[0].y;
matrix->V[0].y = matrix->V[1].x;
matrix->V[1].x = f;
f = matrix->V[0].z;
matrix->V[0].z = matrix->V[2].x;
matrix->V[2].x = f;
f = matrix->V[0].z;
matrix->V[0].z = matrix->V[2].x;
matrix->V[2].x = f;
f = matrix->V[0].w;
matrix->V[0].w = matrix->V[3].x;
matrix->V[3].x = f;
f = matrix->V[0].w;
matrix->V[0].w = matrix->V[3].x;
matrix->V[3].x = f;
f = matrix->V[1].z;
matrix->V[1].z = matrix->V[2].y;
matrix->V[2].y = f;
f = matrix->V[1].z;
matrix->V[1].z = matrix->V[2].y;
matrix->V[2].y = f;
f = matrix->V[1].w;
matrix->V[1].w = matrix->V[3].y;
matrix->V[3].y = f;
f = matrix->V[1].w;
matrix->V[1].w = matrix->V[3].y;
matrix->V[3].y = f;
f = matrix->V[2].w;
matrix->V[2].w = matrix->V[3].z;
matrix->V[3].z = f;
f = matrix->V[2].w;
matrix->V[2].w = matrix->V[3].z;
matrix->V[3].z = f;
}
/*******************************************************************************/
/* 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_sub(dst, eye, &zaxis);
vector4_normalize(&zaxis);
vector4 xaxis, yaxis, zaxis, negeye;
vector4_sub(dst, eye, &zaxis);
vector4_normalize(&zaxis);
vector4_crossproduct(zaxis, up, &xaxis);
vector4_normalize(&xaxis);
vector4_crossproduct(zaxis, up, &xaxis);
vector4_normalize(&xaxis);
vector4_crossproduct(xaxis, zaxis, &yaxis);
vector4_crossproduct(xaxis, zaxis, &yaxis);
vector4_copy(xaxis, &matrix->V[0]);
vector4_copy(yaxis, &matrix->V[1]);
vector4_copy(zaxis, &matrix->V[2]);
vector4_copy(xaxis, &matrix->V[0]);
vector4_copy(yaxis, &matrix->V[1]);
vector4_copy(zaxis, &matrix->V[2]);
matrix->V[2].x = -matrix->V[2].x;
matrix->V[2].y = -matrix->V[2].y;
matrix->V[2].z = -matrix->V[2].z;
matrix->V[2].x = -matrix->V[2].x;
matrix->V[2].y = -matrix->V[2].y;
matrix->V[2].z = -matrix->V[2].z;
vector4_create(0, 0, 0, 1, &matrix->V[3]);
vector4_create(0, 0, 0, 1, &matrix->V[3]);
matrix44_transpose(matrix);
vector4_create(-eye.x, -eye.y, -eye.z, 1, &negeye);
matrix44_transpose(matrix);
vector4_create(-eye.x, -eye.y, -eye.z, 1, &negeye);
matrix44_transform(matrix, &negeye);
vector4_copy(negeye, &matrix->V[3]);
matrix44_transform(matrix, &negeye);
vector4_copy(negeye, &matrix->V[3]);
}
/*******************************************************************************/
/* 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]) &&
vector4_isequals(m1->V[2], m2->V[2]) && vector4_isequals(m1->V[3], m2->V[3]);
return vector4_isequals(m1->V[0], m2->V[0])
&& 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 */
float *toarray(matrix44 *m)
float *toarray(matrix44 * m)
{
return &m->v;
return &m->v;
}

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -11,7 +11,7 @@ static u32 infobloc;
void initmultiboot(const u32 addr)
{
infobloc=addr;
infobloc = addr;
}
/*******************************************************************************/
@ -19,21 +19,25 @@ void initmultiboot(const u32 addr)
u32 getgrubinfo(u8 type)
{
struct multiboot_tag *tag;
unsigned size = *(unsigned *) infobloc;
for (tag = (struct multiboot_tag *) (infobloc + 8);
tag->type != MULTIBOOT_TAG_TYPE_END;
tag = (struct multiboot_tag *) ((u8 *) tag + ((tag->size + 7) & ~7)))
if (tag->type==type) return tag;
struct multiboot_tag *tag;
unsigned size = *(unsigned *) infobloc;
for (tag = (struct multiboot_tag *) (infobloc + 8);
tag->type != MULTIBOOT_TAG_TYPE_END;
tag =
(struct multiboot_tag *) ((u8 *) tag +
((tag->size + 7) & ~7)))
if (tag->type == type)
return tag;
}
/*******************************************************************************/
/* Renvoie la ligne de commande */
u8 *getgrubinfo_cmdline(void)
u8 *getgrubinfo_cmdline(void)
{
struct multiboot_tag_string *tag=getgrubinfo(MULTIBOOT_TAG_TYPE_CMDLINE);
return tag->string;
struct multiboot_tag_string *tag =
getgrubinfo(MULTIBOOT_TAG_TYPE_CMDLINE);
return tag->string;
}
/*******************************************************************************/
@ -41,8 +45,9 @@ u8 *getgrubinfo_cmdline(void)
u32 getgrubinfo_ram(void)
{
struct multiboot_tag_basic_meminfo *tag=getgrubinfo(MULTIBOOT_TAG_TYPE_BASIC_MEMINFO);
return tag->mem_upper;
struct multiboot_tag_basic_meminfo *tag =
getgrubinfo(MULTIBOOT_TAG_TYPE_BASIC_MEMINFO);
return tag->mem_upper;
}
/*******************************************************************************/
@ -50,8 +55,9 @@ u32 getgrubinfo_ram(void)
struct multiboot_tag_mmap *getgrubinfo_mem(void)
{
struct multiboot_tag_mmap *tag=getgrubinfo(MULTIBOOT_TAG_TYPE_MMAP);
return tag;
struct multiboot_tag_mmap *tag =
getgrubinfo(MULTIBOOT_TAG_TYPE_MMAP);
return tag;
}
/*******************************************************************************/
@ -59,8 +65,9 @@ struct multiboot_tag_mmap *getgrubinfo_mem(void)
struct multiboot_tag_framebuffer *getgrubinfo_fb(void)
{
struct multiboot_tag_framebuffer *tag=getgrubinfo(MULTIBOOT_TAG_TYPE_FRAMEBUFFER);
return tag;
struct multiboot_tag_framebuffer *tag =
getgrubinfo(MULTIBOOT_TAG_TYPE_FRAMEBUFFER);
return tag;
}
/*******************************************************************************/
@ -68,78 +75,84 @@ struct multiboot_tag_framebuffer *getgrubinfo_fb(void)
void getgrubinfo_all(void)
{
struct multiboot_tag *tag;
u32 size = *(unsigned *) infobloc;
if (infobloc & 7) print("Attention : Bloc non aligne...");
printf(" Taille :% 4u\r\n", (u32)size);
for (tag = (struct multiboot_tag *) (infobloc + 8);
tag->type != MULTIBOOT_TAG_TYPE_END;
tag = (struct multiboot_tag *) ((u8 *) tag + ((tag->size + 7) & ~7)))
{
printf ("--- Tag % hu, Taille % hu\r\n", tag->type, tag->size);
switch (tag->type)
{
case MULTIBOOT_TAG_TYPE_CMDLINE:
printf (" Ligne de lancement : %s\r\n",
((struct multiboot_tag_string *) tag)->string);
break;
case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME:
printf (" Chargeur de boot : %s\r\n",
((struct multiboot_tag_string *) tag)->string);
break;
case MULTIBOOT_TAG_TYPE_MODULE:
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);
break;
case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO:
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);
break;
case MULTIBOOT_TAG_TYPE_BOOTDEV:
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);
break;
case MULTIBOOT_TAG_TYPE_MMAP:
{
multiboot_memory_map_t *mmap;
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 *)
((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;
}
case MULTIBOOT_TAG_TYPE_FRAMEBUFFER:
{
struct multiboot_tag_framebuffer *tagfb = (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)
{
case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED:
printf ("mode graphique indexé\r\n");
break;
case MULTIBOOT_FRAMEBUFFER_TYPE_RGB:
printf ("mode graphique RGB\r\n");
break;
case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT:
printf ("mode texte EGA\r\n");
break;
}
break;
}
case MULTIBOOT_TAG_TYPE_VBE:
{
struct multiboot_tag_vbe *tagvbe = (struct multiboot_tag_framebuffer *) tag;
printf (" VBE 2.0, mode %Y, adresse %hY:%hY-%hY\r\n", tagvbe->vbe_mode,tagvbe->vbe_interface_seg,tagvbe->vbe_interface_off,tagvbe->vbe_interface_len);
}
}
}
struct multiboot_tag *tag;
u32 size = *(unsigned *) infobloc;
if (infobloc & 7)
print("Attention : Bloc non aligne...");
printf(" Taille :% 4u\r\n", (u32) size);
for (tag = (struct multiboot_tag *) (infobloc + 8);
tag->type != MULTIBOOT_TAG_TYPE_END;
tag =
(struct multiboot_tag *) ((u8 *) tag +
((tag->size + 7) & ~7)))
{
printf("--- Tag % hu, Taille % hu\r\n", tag->type,
tag->size);
switch (tag->type)
{
case MULTIBOOT_TAG_TYPE_CMDLINE:
printf(" Ligne de lancement : %s\r\n",
((struct multiboot_tag_string *)
tag)->string);
break;
case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME:
printf(" Chargeur de boot : %s\r\n",
((struct multiboot_tag_string *)
tag)->string);
break;
case MULTIBOOT_TAG_TYPE_MODULE:
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);
break;
case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO:
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);
break;
case MULTIBOOT_TAG_TYPE_BOOTDEV:
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);
break;
case MULTIBOOT_TAG_TYPE_MMAP:
{
multiboot_memory_map_t *mmap;
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
*) ((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;
}
case MULTIBOOT_TAG_TYPE_FRAMEBUFFER:
{
struct multiboot_tag_framebuffer *tagfb =
(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)
{
case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED:
printf("mode graphique indexé\r\n");
break;
case MULTIBOOT_FRAMEBUFFER_TYPE_RGB:
printf("mode graphique RGB\r\n");
break;
case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT:
printf("mode texte EGA\r\n");
break;
}
break;
}
case MULTIBOOT_TAG_TYPE_VBE:
{
struct multiboot_tag_vbe *tagvbe =
(struct multiboot_tag_framebuffer
*) tag;
printf(" VBE 2.0, mode %Y, adresse %hY:%hY-%hY\r\n", tagvbe->vbe_mode, tagvbe->vbe_interface_seg, tagvbe->vbe_interface_off, tagvbe->vbe_interface_len);
}
}
}
}
/*******************************************************************************/

141
lib/pci.c
View File

@ -14,21 +14,26 @@
/*******************************************************************************/
/* Retourne une chaine correspondant à l'ID class/subclass PCI */
u8 * pcigetclassname( const pcidev *device)
u8 *pcigetclassname(const pcidev * device)
{
pciclass *class = NULL;
if ( device == NULL ) {
pciclass *class = NULL;
if (device == NULL)
{
return NULL;
}
if ( device->base_class == 0xff ) {
if (device->base_class == 0xff)
{
return "Unassigned class";
}
class = classcodes[device->base_class];
if (!class) {
if (!class)
{
return "Unknowned class";
}
while (class->name != NULL) {
if (class->number == device->sub_class) {
while (class->name != NULL)
{
if (class->number == device->sub_class)
{
return class->name;
}
class++;
@ -42,52 +47,63 @@ u8 * pcigetclassname( const pcidev *device)
pcidevmini getPCImininfo(const u8 bus, const u8 dev, const u8 function)
{
pcidevmini result;
if ((result.vendor_id = pciConfigReadWord(bus,dev,function,0x0)) != 0xFFFF) {
result.device_id = pciConfigReadWord(bus,dev,function,0x2);
}
return result;
pcidevmini result;
if ((result.vendor_id =
pciConfigReadWord(bus, dev, function, 0x0)) != 0xFFFF)
{
result.device_id =
pciConfigReadWord(bus, dev, function, 0x2);
}
return result;
}
/*******************************************************************************/
/* 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)
{
u16 temp;
device->device_id = pciConfigReadWord(bus,dev,function,0x2);
device->command = pciConfigReadWord(bus,dev,function,0x4);
device->status = pciConfigReadWord(bus,dev,function,0x6);
temp=pciConfigReadWord(bus,dev,function,0x8);
device->revision_id = temp & 0xFF;
device->interface = temp>>8;
temp=pciConfigReadWord(bus,dev,function,0xA);
device->sub_class = temp & 0xFF;
device->base_class = temp>>8;
temp=pciConfigReadWord(bus,dev,function,0xC);
device->cache_line_size = temp & 0xFF;
device->latency_timer = temp>>8;
temp=pciConfigReadWord(bus,dev,function,0xE);
device->header_type = temp & 0xFF;
device->bist = temp>>8;
return true;
}
else
return false;
if ((device->vendor_id =
pciConfigReadWord(bus, dev, function, 0x0)) != 0xFFFF)
{
u16 temp;
device->device_id =
pciConfigReadWord(bus, dev, function, 0x2);
device->command =
pciConfigReadWord(bus, dev, function, 0x4);
device->status =
pciConfigReadWord(bus, dev, function, 0x6);
temp = pciConfigReadWord(bus, dev, function, 0x8);
device->revision_id = temp & 0xFF;
device->interface = temp >> 8;
temp = pciConfigReadWord(bus, dev, function, 0xA);
device->sub_class = temp & 0xFF;
device->base_class = temp >> 8;
temp = pciConfigReadWord(bus, dev, function, 0xC);
device->cache_line_size = temp & 0xFF;
device->latency_timer = temp >> 8;
temp = pciConfigReadWord(bus, dev, function, 0xE);
device->header_type = temp & 0xFF;
device->bist = temp >> 8;
return true;
}
else
return false;
}
/*******************************************************************************/
/* 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;
u32 addr = (0x80000000|(bus << 16)|(dev << 11)|(function << 8)|(offset & 0xFC));
outd(0xCF8, addr);
tmp = (u16)((ind(0xCFC) >> ((offset & 2) * 8)) & 0xffff);
return tmp;
u16 tmp = 0;
u32 addr =
(0x80000000 | (bus << 16) | (dev << 11) | (function << 8) |
(offset & 0xFC));
outd(0xCF8, addr);
tmp = (u16) ((ind(0xCFC) >> ((offset & 2) * 8)) & 0xffff);
return tmp;
}
/*******************************************************************************/
@ -95,17 +111,19 @@ u16 pciConfigReadWord(const u8 bus, const u8 dev, const u8 function, const u8 of
void scanPCImini(void)
{
u16 bus,device,function;
pcidevmini result;
for (bus=0; bus<MAX_BUS_SCAN; ++bus)
for (device=0; device<MAX_DEVICE_SCAN; ++device)
for (function=0; function<MAX_FUNCTION_SCAN; ++function)
{
result = getPCImininfo(bus,device,function);
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);
}
return;
u16 bus, device, function;
pcidevmini result;
for (bus = 0; bus < MAX_BUS_SCAN; ++bus)
for (device = 0; device < MAX_DEVICE_SCAN; ++device)
for (function = 0; function < MAX_FUNCTION_SCAN;
++function)
{
result = getPCImininfo(bus, device,
function);
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);
}
return;
}
/*******************************************************************************/
@ -114,15 +132,16 @@ void scanPCImini(void)
void scanPCI(void)
{
u16 bus,device,function;
pcidev result;
for (bus=0; bus<MAX_BUS_SCAN; ++bus)
for (device=0; device<MAX_DEVICE_SCAN; ++device)
for (function=0; function<MAX_FUNCTION_SCAN; ++function)
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;
u16 bus, device, function;
pcidev result;
for (bus = 0; bus < MAX_BUS_SCAN; ++bus)
for (device = 0; device < MAX_DEVICE_SCAN; ++device)
for (function = 0; function < MAX_FUNCTION_SCAN;
++function)
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;
}
/*******************************************************************************/

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -25,25 +25,25 @@
/* Entrée pour les appels système SYSENTER */
void sysenter_handler(void)
{
cli();
regs *dump;
dumpcpu();
getESP(dump);
sti();
{
cli();
regs *dump;
dumpcpu();
getESP(dump);
sti();
switch (dump->eax)
{
case 0:
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;
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;
break;
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;
}
restdebugcpu();
sysexit();
restdebugcpu();
sysexit();
}
/*******************************************************************************/
@ -54,7 +54,7 @@ void initsyscall(void)
{
wrmsr(0x174, SEL_KERNEL_CODE, 0x0);
wrmsr(0x175, 0x60000, 0x0);
wrmsr(0x176, &sysenter_handler+6, 0x0);
wrmsr(0x176, &sysenter_handler + 6, 0x0);
}
/*******************************************************************************/

View File

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

View File

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

672
lib/vga.c
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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