Initial commit.
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
dist
|
||||
travail
|
12
Makefile
Normal file
|
@ -0,0 +1,12 @@
|
|||
SHELL = /bin/sh
|
||||
|
||||
REP_MAKEFILES := src/makefiles/
|
||||
|
||||
MAKEFILES := affichage.makefile \
|
||||
fichiersDossiers.makefile \
|
||||
commandes.makefile \
|
||||
regles.makefile
|
||||
|
||||
MAKEFILES := $(patsubst %,$(REP_MAKEFILES)/%,$(MAKEFILES))
|
||||
|
||||
include $(MAKEFILES)
|
5
src/demarrage/grub/menu.lst
Normal file
|
@ -0,0 +1,5 @@
|
|||
default 0
|
||||
timeout 0
|
||||
title gruntnetwork
|
||||
kernel /boot/gruntnetwork.elf
|
||||
module /donnees/police.fnt
|
BIN
src/demarrage/grub/stage1
Normal file
BIN
src/demarrage/grub/stage2
Normal file
BIN
src/demarrage/grub/stage2_eltorito
Normal file
BIN
src/demarrage/grub/stage2_eltorito_vbe
Normal file
36
src/inclusions/algo/math/math.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#ifndef ALGO_MATH_MATH_H
|
||||
#define ALGO_MATH_MATH_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
#define abs(x) (((x) >= 0) ? (x) : -(x))
|
||||
|
||||
#define sign(x) (((x) >= 0) \
|
||||
? (((x) == 0) ? 0 : 1) \
|
||||
: -1)
|
||||
|
||||
#define sinRapide_(a, sgn) ((((a) * 4) \
|
||||
- ((a)*(a) >> 13)) \
|
||||
* sgn)
|
||||
|
||||
#define sinRapide(a) sinRapide_(abs((int32)(a)) % 32768, (((a) & 32768) ? 1 : -1))
|
||||
|
||||
#define cosRapide(a) sinRapide((a)+16384)
|
||||
|
||||
#define clip(x, min_, max_) min(max_, max((x),min_))
|
||||
|
||||
typedef struct Div64 {
|
||||
uint64 quotient;
|
||||
uint64 reste;
|
||||
} Div64;
|
||||
|
||||
typedef struct EtatMath {
|
||||
} EtatMath;
|
||||
|
||||
Div64 div64 (uint64 numerateur, uint64 denominateur);
|
||||
|
||||
#endif
|
244
src/inclusions/demarrage/multiboot/multiboot.h
Normal file
|
@ -0,0 +1,244 @@
|
|||
#ifndef DEMARRAGE_MULTIBOOT_MULTIBOOT_H
|
||||
#define DEMARRAGE_MULTIBOOT_MULTIBOOT_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
/**
|
||||
* @brief Informations récupérées par grub
|
||||
*
|
||||
* D'abord les sous-structures, puis la structure principale.
|
||||
*/
|
||||
|
||||
/* FIXME : De quoi s'agit-il réellement ? */
|
||||
typedef uint32 pointeurLointain;
|
||||
|
||||
/**
|
||||
* @brief Disponibilité des informations.
|
||||
*/
|
||||
typedef struct MultibootInfoFlags {
|
||||
bool mem:1;
|
||||
bool bootDevice:1;
|
||||
bool cmdline:1;
|
||||
bool mods:1;
|
||||
bool aout:1;
|
||||
bool elf:1;
|
||||
bool mmap:1;
|
||||
bool drives:1;
|
||||
bool configTable:1;
|
||||
bool bootLoaderName:1;
|
||||
bool apmTable:1;
|
||||
bool vbe:1;
|
||||
uint32 PADDING:20;
|
||||
} PACKED MultibootInfoFlags;
|
||||
|
||||
/**
|
||||
* @brief Média de stockage utilisé lors du démarrage.
|
||||
*/
|
||||
typedef struct MultibootInfoBootDevice {
|
||||
uint8 part1;
|
||||
uint8 part2;
|
||||
uint8 part3;
|
||||
uint8 drive;
|
||||
} PACKED MultibootInfoBootDevice;
|
||||
|
||||
/**
|
||||
* @brief Modules chargés par le chargeur de démarrage.
|
||||
*/
|
||||
typedef struct MultibootInfoModule {
|
||||
void* modStart;
|
||||
void* modEnd;
|
||||
|
||||
StringZ string;
|
||||
|
||||
uint32 reserved;
|
||||
} PACKED MultibootInfoModule;
|
||||
|
||||
/**
|
||||
* @brief Table des symboles a.out .
|
||||
*/
|
||||
typedef struct MultibootInfoAout {
|
||||
uint32 aoutTabSize;
|
||||
uint32 aoutStrSize;
|
||||
|
||||
/* le type de aoutAddr devrait être nlist (cf. standard
|
||||
* multiboot), mais de quoi s'agit-t-il ? */
|
||||
void* aoutAddr;
|
||||
|
||||
uint32 reserved;
|
||||
} PACKED MultibootInfoAout;
|
||||
|
||||
/**
|
||||
* @brief Table des en-têtes de section pour ELF.
|
||||
*/
|
||||
typedef struct MultibootInfoElf {
|
||||
uint32 num;
|
||||
uint32 size;
|
||||
|
||||
void* addr;
|
||||
|
||||
StringZ* shndx; /* Tableau de StringZ ou de String ? */
|
||||
} PACKED MultibootInfoElf;
|
||||
|
||||
/**
|
||||
* @brief Cartographie de la mémoire.
|
||||
*
|
||||
* Si type != MultibootInfoMmapRam alors cette mémoire est réservée
|
||||
* (mémoire vidéo, etc.)
|
||||
*/
|
||||
#define MultibootInfoMmapRam = 1;
|
||||
typedef struct MultibootInfoMmap {
|
||||
/* Attention, mmapAddr tel que fourni par grub pointe sur le 2e
|
||||
* champ (baseAddr), il faut donc enlever 4 octets à
|
||||
* l'adresse. */
|
||||
uint32 size;
|
||||
|
||||
/* Avec 32_low suivi de 32_high, je peux en faire 64. Ne me
|
||||
* seais-je pas trompé dans l'endianisme ? */
|
||||
uint64 baseAddr;
|
||||
uint64 length;
|
||||
uint32 type;
|
||||
} PACKED MultibootInfoMmap;
|
||||
|
||||
/**
|
||||
* @brief Média de stockage.
|
||||
*/
|
||||
typedef enum { CHS = 0, LBA = 1 } MultibootInfoDriveMode;
|
||||
typedef struct MultibootInfoDrive {
|
||||
uint32 size;
|
||||
|
||||
uint8 driveNumber;
|
||||
|
||||
/* Cela permet-il de contraindre la taille d'un enum ? */
|
||||
MultibootInfoDriveMode driveMode:8;
|
||||
|
||||
|
||||
uint16 driveCylinders;
|
||||
uint8 driveHeads;
|
||||
uint8 driveSectors;
|
||||
|
||||
/* Et comment je gère cette horreur moi ? */
|
||||
uint16 drivePorts;
|
||||
} PACKED MultibootInfoDrive;
|
||||
|
||||
/**
|
||||
* @brief Fonction GET CONFIGURATION du BIOS.
|
||||
*/
|
||||
typedef struct MultibootInfoConfigTable {
|
||||
/* Chercher le format de retour de l'appel au BIOS nommé
|
||||
* GET CONFIGURATION */
|
||||
} PACKED MultibootInfoConfigTable;
|
||||
|
||||
/**
|
||||
* @brief Advanced Power Management.
|
||||
*/
|
||||
typedef struct MultibootInfoApmTable {
|
||||
/* Voir le standard apm pour les types...
|
||||
* http://www.micr.../hwdev/busbios/amp_12.htm
|
||||
* Soit dit en passant, sympa la référence à micr... dans un
|
||||
* standard libre (très mal écrit le standard au fait...) */
|
||||
uint16 version;
|
||||
uint16 cseg;
|
||||
uint32 offset;
|
||||
uint16 cseg16;
|
||||
uint16 dseg;
|
||||
uint16 flags;
|
||||
uint16 csegLen;
|
||||
uint16 cseg16Len;
|
||||
uint16 dsegLen;
|
||||
} PACKED MultibootInfoApmTable;
|
||||
|
||||
/**
|
||||
* @brief Contrôleur VESA Bios Extension
|
||||
*/
|
||||
typedef struct MultibootInfoVbeControllerInfo{
|
||||
char signature[4]; /* == "VESA" */
|
||||
union {
|
||||
uint16 version;
|
||||
struct {
|
||||
uint8 versionMajeure; /* 2 pour VBE 2.* */
|
||||
uint8 versionMineure; /* 0 pour VBE *.0 */
|
||||
};
|
||||
};
|
||||
/* pointeurLointain ??? */
|
||||
uint16 oemString[2]; /* Nom du périphérique, donné par le constructeur */
|
||||
uint32 capabilities; /* Fonctionnalités offertes */
|
||||
/* pointeurLointain ??? */
|
||||
uint16 videomodes[2]; /* Liste de modes vidéo */
|
||||
uint16 totalMemory; /* nombre de blocs de 64ko */
|
||||
} PACKED MultibootInfoVbeControllerInfo;
|
||||
|
||||
/**
|
||||
* @brief Mode vidéo VESA Bios Extension
|
||||
*/
|
||||
typedef struct MultibootInfoVbeModeInfo {
|
||||
uint16 attributes;
|
||||
uint8 winA,winB;
|
||||
uint16 granularity;
|
||||
uint16 winsize;
|
||||
uint16 segmentA, segmentB;
|
||||
pointeurLointain winFunc;
|
||||
uint16 pitch; /* octets par scanline */
|
||||
|
||||
uint16 Xres, Yres;
|
||||
uint8 Wchar, Ychar, planes, bpp, banks;
|
||||
uint8 memory_model, bank_size, image_pages;
|
||||
uint8 reserved;
|
||||
|
||||
struct {
|
||||
uint8 maskSize;
|
||||
uint8 fieldPos;
|
||||
} red, green, blue, reservedChannel;
|
||||
uint8 directcolor_attributes;
|
||||
|
||||
void* linearAddress; /* L'adresse du framebuffer linéaire :) */
|
||||
void* offscreenAddress;
|
||||
uint16 offscreenSizeKB;
|
||||
} PACKED MultibootInfoVbeModeInfo;
|
||||
|
||||
/**
|
||||
* @brief Informations récupérées par grub
|
||||
*/
|
||||
typedef struct MultibootInfo {
|
||||
MultibootInfoFlags flags;
|
||||
|
||||
uint32 memLower;
|
||||
uint32 memUpper;
|
||||
|
||||
MultibootInfoBootDevice bootDevice;
|
||||
|
||||
StringZ cmdline;
|
||||
|
||||
uint32 modsCount;
|
||||
MultibootInfoModule* modsAddr;
|
||||
|
||||
union {
|
||||
MultibootInfoAout aout;
|
||||
MultibootInfoElf elf;
|
||||
} PACKED syms;
|
||||
|
||||
uint32 mmapLength;
|
||||
MultibootInfoMmap* mmapAddr;
|
||||
|
||||
uint32 drivesLength;
|
||||
MultibootInfoDrive* drivesAddr;
|
||||
|
||||
MultibootInfoConfigTable* configTable;
|
||||
|
||||
StringZ bootLoaderName;
|
||||
|
||||
MultibootInfoApmTable* apmTable;
|
||||
|
||||
MultibootInfoVbeControllerInfo* vbeControlInfo;
|
||||
MultibootInfoVbeModeInfo* vbeModeInfo;
|
||||
uint16 vbeMode;
|
||||
uint16 vbeInterfaceSeg;
|
||||
uint16 vbeInterfaceOff;
|
||||
uint16 vbeInterfaceLen;
|
||||
} PACKED MultibootInfo;
|
||||
|
||||
typedef struct EtatMultiboot {
|
||||
MultibootInfo* InfoMultiboot;
|
||||
uint32 magicMultiboot;
|
||||
} EtatMultiboot;
|
||||
|
||||
#endif
|
7
src/inclusions/interfaceUtilisateur/clavier/clavier.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#ifndef INTERFACE_UTILISATEUR_CLAVIER_CLAVIER_H
|
||||
#define INTERFACE_UTILISATEUR_CLAVIER_CLAVIER_H
|
||||
|
||||
typedef char EtatClavier;
|
||||
|
||||
#endif
|
||||
|
116
src/inclusions/interfaceUtilisateur/console/console.h
Normal file
|
@ -0,0 +1,116 @@
|
|||
#ifndef INTERFACE_UTILISATEUR_CONSOLE_CONSOLE_H
|
||||
#define INTERFACE_UTILISATEUR_CONSOLE_CONSOLE_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
typedef struct CouleurComposantes {
|
||||
uint8 bleu;
|
||||
uint8 vert;
|
||||
uint8 rouge;
|
||||
uint8 alpha;
|
||||
} CouleurComposantes;
|
||||
|
||||
typedef uint32 Couleur;
|
||||
|
||||
typedef struct CouleurAvAr {
|
||||
Couleur av;
|
||||
Couleur ar;
|
||||
} CouleurAvAr;
|
||||
|
||||
typedef struct Position {
|
||||
uint32 x;
|
||||
uint32 y;
|
||||
} Position;
|
||||
|
||||
typedef void (*FonctionAffichage) (char caractere, uint32 couleurAv, uint32 couleurAr, uint32 x, uint32 y);
|
||||
|
||||
typedef struct Console {
|
||||
uint32 x;
|
||||
uint32 y;
|
||||
uint32 largeur;
|
||||
uint32 hauteur;
|
||||
FonctionAffichage fonctionAffichage;
|
||||
} Console;
|
||||
|
||||
typedef struct EtatConsole {
|
||||
Console* consoleActive;
|
||||
uint32 x;
|
||||
uint32 y;
|
||||
uint32 couleurAv;
|
||||
uint32 couleurAr;
|
||||
bool consolePrete;
|
||||
} EtatConsole;
|
||||
|
||||
|
||||
Console* definirConsoleActive(Console* console);
|
||||
|
||||
CouleurAvAr getConsoleCouleur();
|
||||
CouleurAvAr consoleCouleur(Couleur couleurAv, Couleur couleurAr);
|
||||
|
||||
Position getConsolePosition();
|
||||
Position consolePosition(uint32 x, uint32 y);
|
||||
void consolePositionAvancerX();
|
||||
void consolePositionAvancerY();
|
||||
|
||||
void afficherCaractereCouleurPositionBrut(char caractere, uint32 couleurAv, uint32 couleurAr, uint32 x, uint32 y);
|
||||
void afficherCaractereCouleurPosition(char caractere, uint32 couleurAv, uint32 couleurAr, uint32 x, uint32 y);
|
||||
void afficherCaractere(char caractere);
|
||||
void afficherCaractereBrut(char caractere);
|
||||
void afficherCaractereCouleur(char caractere, uint32 couleurAv, uint32 couleurAr);
|
||||
void afficherCaractereCouleurBrut(char caractere, uint32 couleurAv, uint32 couleurAr);
|
||||
void afficherCaracterePosition(char caractere, uint32 x, uint32 y);
|
||||
void afficherCaracterePositionBrut(char caractere, uint32 x, uint32 y);
|
||||
|
||||
void effacerConsole();
|
||||
void afficherChaineZ(char* chaine);
|
||||
void afficherChaine(char* chaine, int longueur);
|
||||
void afficherEntierVirguleEnDecimal(uint32 entier, int32 nbDecimales);
|
||||
void afficherEntierEnDecimal(uint32 entier);
|
||||
void afficherEntierEnHexa(uint32 entier);
|
||||
void afficherEntierEnBinaire(uint32 entier);
|
||||
void afficherTableCaracteres();
|
||||
|
||||
bool consolePrete();
|
||||
|
||||
#define STR_Ccedil "\200"
|
||||
#define STR_uuml "\201"
|
||||
#define STR_eacute "\202"
|
||||
#define STR_acirc "\203"
|
||||
#define STR_auml "\204"
|
||||
#define STR_agrave "\205"
|
||||
#define STR_aring "\206"
|
||||
#define STR_ccedil "\207"
|
||||
#define STR_ecirc "\210"
|
||||
#define STR_euml "\211"
|
||||
#define STR_egrave "\212"
|
||||
#define STR_iuml "\213"
|
||||
#define STR_icirc "\214"
|
||||
#define STR_igrave "\215"
|
||||
#define STR_Auml "\216"
|
||||
#define STR_Aring "\217"
|
||||
#define STR_Eacute "\220"
|
||||
#define STR_aelig "\221"
|
||||
#define STR_AElig "\222"
|
||||
#define STR_ocirc "\223"
|
||||
#define STR_ouml "\224"
|
||||
#define STR_ograve "\225"
|
||||
#define STR_ucirc "\226"
|
||||
#define STR_ugrave "\227"
|
||||
#define STR_yuml "\230"
|
||||
#define STR_Ouml "\231"
|
||||
#define STR_Uuml "\232"
|
||||
#define STR_cent "\233"
|
||||
#define STR_pound "\234"
|
||||
#define STR_yen "\235"
|
||||
#define STR_xxxxxxxx "\236"
|
||||
#define STR_fonction "\237"
|
||||
#define STR_aacute "\240"
|
||||
#define STR_iacute "\241"
|
||||
#define STR_oacute "\242"
|
||||
#define STR_uacute "\243"
|
||||
#define STR_ntilde "\244"
|
||||
#define STR_Ntilde "\245"
|
||||
#define STR_ordm "\246"
|
||||
#define STR_degr "\247"
|
||||
|
||||
#endif
|
6
src/inclusions/interfaceUtilisateur/demo/demo.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef INTERFACE_UTILISATEUR_DEMO_DEMO_H
|
||||
#define INTERFACE_UTILISATEUR_DEMO_DEMO_H
|
||||
|
||||
typedef char EtatDemo;
|
||||
|
||||
#endif
|
10
src/inclusions/interfaceUtilisateur/police/police.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef INTERFACE_UTILISATEUR_POLICE_POLICE_H
|
||||
#define INTERFACE_UTILISATEUR_POLICE_POLICE_H
|
||||
|
||||
typedef struct EtatPolice {
|
||||
uint8* tableCaracteres;
|
||||
} EtatPolice;
|
||||
|
||||
void policeAfficherCaractereCouleurPosition(char caractere, uint32 couleurAv, uint32 couleurAr, uint32 x, uint32 y);
|
||||
|
||||
#endif
|
6
src/inclusions/math.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef MATH_H
|
||||
#define MATH_H
|
||||
|
||||
#include <algo/math/math.h>
|
||||
|
||||
#endif
|
7
src/inclusions/modeleModule.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#ifndef MODELE_MODULE_H
|
||||
#define MODELE_MODULE_H
|
||||
|
||||
typedef struct EtatModeleModule {
|
||||
} EtatModeleModule;
|
||||
|
||||
#endif
|
62
src/inclusions/module.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
#ifndef MODULE_H
|
||||
#define MODULE_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
typedef enum {
|
||||
ETAPE_MODULE_CHARGE = 0,
|
||||
ETAPE_MODULE_INITIALISE = 1,
|
||||
} EtapeChargementModule;
|
||||
|
||||
|
||||
typedef struct InfoModule {
|
||||
char* nom;
|
||||
void (*init) (void** etat);
|
||||
void (*deinit) (void** etat);
|
||||
EtapeChargementModule etapeChargementModule;
|
||||
void* etat;
|
||||
struct DependanceModule* dependances;
|
||||
struct InfoModule* suivant;
|
||||
struct InfoModule* suivantRecursionDependances;
|
||||
int nbDependances;
|
||||
} PACKED ALIGNED(32) InfoModule;
|
||||
|
||||
typedef struct DependanceModule {
|
||||
InfoModule* module;
|
||||
InfoModule* dependance;
|
||||
} PACKED DependanceModule;
|
||||
|
||||
|
||||
#define MODULE(nom) \
|
||||
Etat ## nom _etat ## nom USED; \
|
||||
Etat ## nom* etat ## nom USED = &_etat ## nom; \
|
||||
\
|
||||
void (init ## nom) (void** etat); \
|
||||
void (deinit ## nom) (void** etat); \
|
||||
InfoModule __infoModule_ ## nom \
|
||||
SECTION(.modules) \
|
||||
USED \
|
||||
= { \
|
||||
(#nom), \
|
||||
(init ## nom), \
|
||||
(deinit ## nom), \
|
||||
ETAPE_MODULE_CHARGE, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
0 \
|
||||
}
|
||||
|
||||
#define DEPENDANCE_MODULE(module, dependance) \
|
||||
extern InfoModule __infoModule_ ## module; \
|
||||
extern InfoModule __infoModule_ ## dependance; \
|
||||
DependanceModule __dependanceModule ## module ## _ ## dependance \
|
||||
__attribute__ ((section(".dependancesModules"))) \
|
||||
USED \
|
||||
= { \
|
||||
& __infoModule_ ## module, \
|
||||
& __infoModule_ ## dependance \
|
||||
}
|
||||
|
||||
#endif
|
96
src/inclusions/pc/gdt/gdt.h
Normal file
|
@ -0,0 +1,96 @@
|
|||
#ifndef PC_GDT_GDT_H
|
||||
#define PC_GDT_GDT_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
typedef enum {
|
||||
SEGMENT_DONNEES = 0,
|
||||
SEGMENT_CODE = 1
|
||||
} TypeSegmentCodeDonnees;
|
||||
|
||||
typedef enum {
|
||||
DESCRIPTEUR_SEGMENT_SYSTEME = 0,
|
||||
DESCRIPTEUR_SEGMENT_CODE_DONNEES = 1
|
||||
} TypeDescripteurSegment;
|
||||
|
||||
typedef enum {
|
||||
TAILLE_OPERATION_16 = 0,
|
||||
TAILLE_OPERATION_32 = 1
|
||||
} TailleOperationSegment;
|
||||
|
||||
/* Union avec TailleOperationSegment */
|
||||
typedef enum {
|
||||
LIMITE_HAUTE_64Ko = 0,
|
||||
LIMITE_HAUTE_4Go = 1
|
||||
} LimiteHauteSegment;
|
||||
|
||||
typedef enum {
|
||||
GRANULARITE_1octet = 0,
|
||||
GRANULARITE_4Ko = 1
|
||||
} GranulariteSegment;
|
||||
|
||||
/* x86-doc-vol3.pdf section 3.4.5, fig 3-8 */
|
||||
typedef struct DescripteurSegment {
|
||||
uint16 limite_15_0;
|
||||
|
||||
uint16 base_15_0;
|
||||
|
||||
uint8 base_23_16;
|
||||
bool accede:1;
|
||||
bool lecture_ecriture:1;
|
||||
bool expansionBas_conforme:1;
|
||||
TypeSegmentCodeDonnees codeDonnees:1;
|
||||
|
||||
TypeDescripteurSegment typeDescripteur:1;
|
||||
uint8 niveauPrivilegeDescripteur:2;
|
||||
bool present:1;
|
||||
|
||||
uint8 limite_19_16:4;
|
||||
uint8 _disponible:1;
|
||||
uint8 _reserve:1; /* Segment de code 64 bits (IA32 seulement) */
|
||||
TailleOperationSegment tailleOperation:1;
|
||||
/* union avec ci-dessus : LimiteHauteSegment limiteHaute:1; */
|
||||
GranulariteSegment granularite:1;
|
||||
uint8 base_31_24;
|
||||
} PACKED ALIGNED(8) DescripteurSegment;
|
||||
|
||||
#define descripteurSegmentNULL { \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
|
||||
}
|
||||
|
||||
#define descripteurSegmentBasicFlatModel(_codeDonnees) \
|
||||
{ \
|
||||
.limite_15_0 = 0xFFFF, \
|
||||
.base_15_0 = 0x0000, \
|
||||
.base_23_16 = 0x00, \
|
||||
.accede = FALSE, \
|
||||
.lecture_ecriture = TRUE, \
|
||||
.expansionBas_conforme = FALSE, \
|
||||
.codeDonnees = _codeDonnees, \
|
||||
.typeDescripteur = DESCRIPTEUR_SEGMENT_CODE_DONNEES, \
|
||||
.niveauPrivilegeDescripteur = 0, \
|
||||
.present = 1, \
|
||||
.limite_19_16 = 0xF, \
|
||||
._disponible = 0, \
|
||||
._reserve = 0, \
|
||||
.tailleOperation = TAILLE_OPERATION_32, \
|
||||
.granularite = GRANULARITE_4Ko, \
|
||||
.base_31_24 = 0 \
|
||||
}
|
||||
|
||||
|
||||
/* x86-doc-vol3.pdf section 2.4.1, fig 2.5 */
|
||||
typedef struct RegistreGDTR {
|
||||
uint16 limite;
|
||||
DescripteurSegment* base;
|
||||
} PACKED ALIGNED (4) RegistreGDTR;
|
||||
/* TODO : Vérifier le ALIGNED 4 :
|
||||
* x86-doc-vol3.pdf section 3.5.1, 2e page */
|
||||
|
||||
|
||||
typedef struct EtatGdt {
|
||||
DescripteurSegment* tableDescripteursSegment;
|
||||
RegistreGDTR registreGDTR;
|
||||
} EtatGdt;
|
||||
|
||||
#endif
|
64
src/inclusions/pc/idt/idt.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
#ifndef PC_IDT_IDT_H
|
||||
#define PC_IDT_IDT_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
typedef enum {
|
||||
DESCRIPTEUR_PORTE_TACHE = 1,
|
||||
DESCRIPTEUR_PORTE_INTERRUPTION = 2,
|
||||
DESCRIPTEUR_PORTE_TRAPPE = 3
|
||||
} TypeDescripteurInterruption;
|
||||
|
||||
typedef enum {
|
||||
TAILLE_PORTE_16 = 0,
|
||||
TAILLE_PORTE_32 = 1
|
||||
} TaillePorte;
|
||||
|
||||
/* x86-doc-vol3.pdf section 5.11, fig 5-2 */
|
||||
typedef struct DescripteurInterruption {
|
||||
uint16 offset_15_0;
|
||||
|
||||
uint16 selecteurSegment;
|
||||
|
||||
uint8 _zero_a;
|
||||
/* TypeDescripteurInterruption type:2;
|
||||
uint8 _un:1;
|
||||
TaillePorte taillePorte:1;
|
||||
uint8 _zero_b:1; */
|
||||
uint8 type:5;
|
||||
|
||||
uint8 niveauPrivilegeDescripteur:2;
|
||||
bool present:1;
|
||||
|
||||
uint16 offset_31_16;
|
||||
} PACKED ALIGNED(8) DescripteurInterruption;
|
||||
|
||||
|
||||
/* x86-doc-vol3.pdf section 2.4.1, fig 2.5 */
|
||||
typedef struct RegistreIDTR {
|
||||
uint16 limite;
|
||||
DescripteurInterruption* base;
|
||||
} PACKED ALIGNED (8) RegistreIDTR;
|
||||
/* TODO : Vérifier le ALIGNED 4 :
|
||||
* x86-doc-vol3.pdf section 3.5.1, 2e page */
|
||||
|
||||
|
||||
typedef void (*EnregistreurContexteInterruption) ();
|
||||
typedef void (*GestionnaireInterruption) ();
|
||||
|
||||
|
||||
typedef struct EtatIdt {
|
||||
DescripteurInterruption tableDescripteursInterruption[256];
|
||||
int interruptionsDesactivees;
|
||||
int nombreDescripteursInterruption;
|
||||
RegistreIDTR registreIDTR;
|
||||
} EtatIdt;
|
||||
|
||||
|
||||
int desactiverInterruptions();
|
||||
int activerInterruptions();
|
||||
void definirGestionnaireInterruption(int numeroInterruption, GestionnaireInterruption gestionnaire);
|
||||
void activerInterruption(int numeroInterruption);
|
||||
void desactiverInterruption(int numeroInterruption);
|
||||
|
||||
#endif
|
20
src/inclusions/pc/io/io.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef PC_IO_IO_H
|
||||
#define PC_IO_IO_H
|
||||
|
||||
#define inb(port) \
|
||||
({ \
|
||||
uint8 ret; \
|
||||
asm volatile ("inb %w1,%0" \
|
||||
: "=a" (ret) \
|
||||
: "i" (port) ); \
|
||||
ret; \
|
||||
})
|
||||
|
||||
#define outb(port, val) \
|
||||
asm volatile ("outb %b0,%w1" \
|
||||
: \
|
||||
: "a" (val), "i" (port) )
|
||||
|
||||
typedef char EtatIo;
|
||||
|
||||
#endif
|
107
src/inclusions/pc/irq/irq.h
Normal file
|
@ -0,0 +1,107 @@
|
|||
#ifndef PC_IRQ_IRQ_H
|
||||
#define PC_IRQ_IRQ_H
|
||||
|
||||
#define PORT_PIC_MAITRE_COMMANDE 0x0020
|
||||
#define PORT_PIC_MAITRE_DONNEES 0x0021
|
||||
#define PORT_PIC_ESCLAVE_COMMANDE 0x00A0
|
||||
#define PORT_PIC_ESCLAVE_DONNEES 0x00A1
|
||||
|
||||
/* 8259A page 10-12 (fig 7) */
|
||||
typedef enum {
|
||||
PIC_ICW1_SEUL = 1,
|
||||
PIC_ICW1_CASCADE = 0
|
||||
} PIC_ICW1_SNGL;
|
||||
|
||||
typedef enum {
|
||||
PIC_ICW1_INTERVALLE_4 = 1,
|
||||
PIC_ICW1_INTERVALLE_8 = 0
|
||||
} PIC_ICW1_ADI;
|
||||
|
||||
typedef enum {
|
||||
PIC_ICW1_LEVEL_TRIGGERED_MODE = 1,
|
||||
PIC_ICW1_EDGE_TRIGGERED_MODE = 0
|
||||
} PIC_ICW1_LTIM;
|
||||
|
||||
typedef struct PicICW1 {
|
||||
bool ICW4_present:1;
|
||||
PIC_ICW1_SNGL single:1;
|
||||
PIC_ICW1_ADI adi:1;
|
||||
PIC_ICW1_LTIM ltim:1;
|
||||
uint8 init:1;
|
||||
/* MCS-80/85 seulement :
|
||||
* uint8 adresseVecteurInterruption_7_5:3; */
|
||||
uint8 _zero:4;
|
||||
} PicICW1;
|
||||
|
||||
|
||||
typedef struct PicICW2 {
|
||||
/* MCS-80/85 seulement :
|
||||
* uint8 adresseVecteurInterruption_15_8; */
|
||||
uint8 _zero:3;
|
||||
uint8 adresseVecteurInterruption_7_3:5;
|
||||
} PicICW2;
|
||||
/* typedef uint8 PicICW2; */
|
||||
|
||||
|
||||
#define ESCLAVE_CONNECTE_SUR_MAITRE_PATTE(patteConnexionMaitre) (1<<(patteConnexionMaitre))
|
||||
typedef uint8 PicICW3_Maitre;
|
||||
|
||||
typedef struct PicICW3_Esclave {
|
||||
uint8 patteConnexionMaitre:3;
|
||||
uint8 _zero:5;
|
||||
} PicICW3_Esclave;
|
||||
|
||||
|
||||
typedef enum {
|
||||
PIC_ICW4_MODE_8086_8088 = 1,
|
||||
PIC_ICW4_MODE_MCS_80_85 = 0
|
||||
} PIC_ICW4_MICRO_PM;
|
||||
|
||||
typedef enum {
|
||||
PIC_ICW4_MODE_SANS_TAMPON = (0 | 0),
|
||||
PIC_ICW4_TAMPON_ESCLAVE = (2 | 0),
|
||||
PIC_ICW4_TAMPON_MAITRE = (2 | 1)
|
||||
} PIC_ICW4_BUF_MS;
|
||||
|
||||
typedef struct PicICW4 {
|
||||
PIC_ICW4_MICRO_PM microPM:1;
|
||||
bool autoEOI:1;
|
||||
PIC_ICW4_BUF_MS tampon:2;
|
||||
bool specialFullyNestedMode:1;
|
||||
uint8 _zero:3;
|
||||
} PicICW4;
|
||||
|
||||
|
||||
typedef void (*FonctionEnvoiFinInterruption) ();
|
||||
typedef void (*GestionnaireRequeteInterruption) ();
|
||||
|
||||
typedef struct EtatIrq {
|
||||
FonctionEnvoiFinInterruption* tableFonctionsEnvoiFinInterruption;
|
||||
GestionnaireRequeteInterruption* tableGestionnairesRequeteInterruption;
|
||||
|
||||
uint8 adresseVecteurInterruptionMaitre;
|
||||
uint8 adresseVecteurInterruptionEsclave;
|
||||
|
||||
PicICW1 ICW1_Maitre;
|
||||
PicICW2 ICW2_Maitre;
|
||||
PicICW3_Maitre ICW3_Maitre;
|
||||
PicICW4 ICW4_Maitre;
|
||||
|
||||
PicICW1 ICW1_Esclave;
|
||||
PicICW2 ICW2_Esclave;
|
||||
PicICW3_Esclave ICW3_Esclave;
|
||||
PicICW4 ICW4_Esclave;
|
||||
|
||||
uint8 masqueMaitre;
|
||||
uint8 masqueEsclave;
|
||||
|
||||
uint8 ancienMasqueMaitre;
|
||||
uint8 ancienMasqueEsclave;
|
||||
} EtatIrq;
|
||||
|
||||
|
||||
void definirGestionnaireRequeteInterruption(int ligne, GestionnaireRequeteInterruption gestionnaire);
|
||||
void activerLigneRequeteInterruption(int ligne);
|
||||
void desactiverLigneRequeteInterruption(int ligne);
|
||||
|
||||
#endif
|
35
src/inclusions/pc/kbc/kbc.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
#ifndef PC_KBC_KBC_H
|
||||
#define PC_KBC_KBC_H
|
||||
|
||||
/* TODO : Vérifier ces informations dans la doc Intel. */
|
||||
|
||||
#define LIGNE_IRQ_CLAVIER 1
|
||||
#define LIGNE_IRQ_SOURIS 12
|
||||
|
||||
#define PORT_KBC_DONNEES 0x60
|
||||
#define PORT_KBC_SCANCODE PORT_KBC_DONNEES
|
||||
#define PORT_KBC_SOURIS PORT_KBC_DONNEES
|
||||
#define PORT_KBC_COMMANDE_SOURIS PORT_KBC_DONNEES
|
||||
#define PORT_KBC_PPI 0x61
|
||||
#define PORT_KBC_COMMANDE 0x64
|
||||
|
||||
#define KBC_DEMMANDE_ECRITURE_CLAVIER 0xd1
|
||||
#define KBC_DEMMANDE_ECRITURE_SOURIS 0xd4
|
||||
#define KBC_DEMMANDE_LECTURE_COMPAQ_STATUS_BYTE 0x20
|
||||
#define KBC_DEMMANDE_ECRITURE_COMPAQ_STATUS_BYTE 0x60
|
||||
#define KBC_RESET_CPU 0xfe
|
||||
|
||||
typedef void (*GestionnaireClavier) (uint8 scancode);
|
||||
|
||||
typedef struct EtatKbc {
|
||||
GestionnaireClavier gestionnaireClavier;
|
||||
} EtatKbc;
|
||||
|
||||
void attenteKbc();
|
||||
void attenteLectureKbc();
|
||||
void activerClavier();
|
||||
void desactiverClavier();
|
||||
void resetCpu();
|
||||
void definirGestionnaireClavier(GestionnaireClavier gestionnaireClavier);
|
||||
|
||||
#endif
|
84
src/inclusions/pc/pit/pit.h
Normal file
|
@ -0,0 +1,84 @@
|
|||
#ifndef PC_PIT_PIT_H
|
||||
#define PC_PIT_PIT_H
|
||||
|
||||
#define LIGNE_IRQ_PIT 0
|
||||
#define PORT_PIT_CANAUX 0x40
|
||||
#define PORT_PIT_CANAL_0 PORT_PIT_CANAUX + 0
|
||||
#define PORT_PIT_CANAL_1 PORT_PIT_CANAUX + 1
|
||||
#define PORT_PIT_CANAL_2 PORT_PIT_CANAUX + 2
|
||||
#define PORT_PIT_COMMANDE 0x43
|
||||
|
||||
#define FREQUENCE_PIT_MILI_HZ 1193181667
|
||||
|
||||
typedef enum {
|
||||
PIT_CANAL_0 = 0,
|
||||
PIT_CANAL_1 = 1,
|
||||
PIT_CANAL_2 = 2,
|
||||
PIT_COMMANDE_LECTURE = 3,
|
||||
} PitCanal;
|
||||
|
||||
typedef enum {
|
||||
PIT_COMMANDE_VERROU = 0,
|
||||
PIT_OCTET_BAS = 1,
|
||||
PIT_OCTET_HAUT = 2,
|
||||
PIT_OCTETS_HAUT_BAS = 3,
|
||||
} PitModeAcces;
|
||||
|
||||
typedef enum {
|
||||
/* Mauvaises traductions... */
|
||||
PIT_MODE_INTERRUPTION_FIN_COMPTEUR = 0,
|
||||
PIT_MODE_UN_COUP_RE_ACTIVABLE = 1,
|
||||
PIT_MODE_GENERATEUR_FREQUENCE = 2,
|
||||
PIT_MODE_GENERATEUR_ONDE_CARREE = 3,
|
||||
PIT_MODE_SIGNAL_A_DECLENCHEMENT_LOGICIEL = 4,
|
||||
PIT_MODE_SIGNAL_A_DECLENCHEMENT_MATERIEL = 5,
|
||||
} PitModeCanal;
|
||||
|
||||
typedef struct PitCommandeMode {
|
||||
bool bcd:1;
|
||||
PitModeCanal mode:3;
|
||||
PitModeAcces acces:2;
|
||||
PitCanal canal:2;
|
||||
} PACKED PitCommandeMode;
|
||||
|
||||
typedef struct PitCommandeVerrou {
|
||||
PitCanal canal:2;
|
||||
uint8 zero:6;
|
||||
} PitCommandeVerrou;
|
||||
|
||||
typedef struct PitCommandeLecture {
|
||||
uint8 un:2;
|
||||
bool nePasVerouillerCompteur:1;
|
||||
bool nePasVerouillerEtat:1;
|
||||
bool lectureCanal0:1;
|
||||
bool lectureCanal1:1;
|
||||
bool lectureCanal2:1;
|
||||
uint8 zero:1;
|
||||
} PitCommandeLecture;
|
||||
|
||||
typedef struct PitEtatCanal {
|
||||
bool bcd:1;
|
||||
PitModeCanal mode:3;
|
||||
PitModeAcces acces:2;
|
||||
bool attenteCopieRechargeCompteur:1;
|
||||
bool etatSortie:1;
|
||||
} PitEtatCanal;
|
||||
|
||||
typedef void (*GestionnairePit) ();
|
||||
|
||||
typedef struct EtatPit {
|
||||
PitModeCanal modeCanal0;
|
||||
PitModeCanal modeCanal1;
|
||||
PitModeCanal modeCanal2;
|
||||
PitModeAcces modeAcces;
|
||||
|
||||
GestionnairePit gestionnairePit;
|
||||
} EtatPit;
|
||||
|
||||
uint32 definirFrequenceCanal(uint32 freq, PitCanal canal);
|
||||
uint32 definirDelaiCanal(uint32 delai, PitCanal canal);
|
||||
void definirCompteurCanal(uint16 compteur, PitCanal canal);
|
||||
void definirModeCanal(PitModeCanal mode, PitCanal canal);
|
||||
void definirGestionnairePit(GestionnairePit gestionnairePit);
|
||||
|
||||
#endif
|
146
src/inclusions/pc/sourisPS2/sourisPS2.h
Normal file
|
@ -0,0 +1,146 @@
|
|||
#ifndef PC_SOURIS_PS2_SOURIS_PS2_H
|
||||
#define PC_SOURIS_PS2_SOURIS_PS2_H
|
||||
|
||||
#include <pc/kbc/kbc.h>
|
||||
|
||||
#define SOURIS_PS2_DEFINIR_RESOLUTION 0xe8
|
||||
#define SOURIS_PS2_DEMANDER_PAQUET 0xeb
|
||||
#define SOURIS_PS2_OBTENIR_MOUSE_ID 0xf2
|
||||
#define SOURIS_PS2_DEFINIR_FREQUENCE 0xf3
|
||||
#define SOURIS_PS2_AUTO_PAQUETS 0xf4
|
||||
#define SOURIS_PS2_DESACTIVER_PAQUETS 0xf5
|
||||
#define SOURIS_PS2_RESET 0xff
|
||||
|
||||
#define SOURIS_PS2_ACK 0xfa
|
||||
#define SOURIS_PS2_RESET_1 0xaa
|
||||
#define SOURIS_PS2_RESET_2 0x00
|
||||
|
||||
#define ENVOYER 1
|
||||
#define RECEVOIR 2
|
||||
#define ENVOYER_V 3
|
||||
#define RECEVOIR_V 4
|
||||
#define RECEVOIR_OU_PAS 42 /* Que la force soit avec la souris */
|
||||
#define COMMANDE 5
|
||||
|
||||
|
||||
|
||||
static const uint8 DialogueDefinirResolution[] = {
|
||||
ENVOYER, SOURIS_PS2_DEFINIR_RESOLUTION,
|
||||
RECEVOIR, SOURIS_PS2_ACK,
|
||||
ENVOYER_V, 0,
|
||||
RECEVOIR, SOURIS_PS2_ACK
|
||||
};
|
||||
|
||||
static const uint8 DialogueDemanderPaquet[] = {
|
||||
ENVOYER, SOURIS_PS2_DEMANDER_PAQUET,
|
||||
RECEVOIR, SOURIS_PS2_ACK
|
||||
};
|
||||
|
||||
static const uint8 DialogueObtenirMouseID[] = {
|
||||
ENVOYER, SOURIS_PS2_OBTENIR_MOUSE_ID,
|
||||
RECEVOIR, SOURIS_PS2_ACK,
|
||||
RECEVOIR_V, 0
|
||||
};
|
||||
|
||||
static const uint8 DialogueDefinirFrequence[] = {
|
||||
ENVOYER, SOURIS_PS2_DEFINIR_FREQUENCE,
|
||||
RECEVOIR, SOURIS_PS2_ACK,
|
||||
ENVOYER_V, 0,
|
||||
RECEVOIR, SOURIS_PS2_ACK
|
||||
};
|
||||
|
||||
static const uint8 DialogueAutoPaquets[] = {
|
||||
ENVOYER, SOURIS_PS2_AUTO_PAQUETS,
|
||||
RECEVOIR, SOURIS_PS2_ACK
|
||||
};
|
||||
|
||||
static const uint8 DialogueDesactiverPaquets[] = {
|
||||
ENVOYER, SOURIS_PS2_DESACTIVER_PAQUETS,
|
||||
RECEVOIR, SOURIS_PS2_ACK
|
||||
};
|
||||
|
||||
static const uint8 DialogueReset[] = {
|
||||
ENVOYER, SOURIS_PS2_RESET,
|
||||
RECEVOIR_OU_PAS, SOURIS_PS2_ACK,
|
||||
RECEVOIR, SOURIS_PS2_RESET_1,
|
||||
RECEVOIR, SOURIS_PS2_RESET_2
|
||||
};
|
||||
|
||||
static const uint8 DialogueObtenirCompaqStatusByte[] = {
|
||||
COMMANDE, KBC_DEMMANDE_LECTURE_COMPAQ_STATUS_BYTE,
|
||||
RECEVOIR_V, 0
|
||||
/* RECEVOIR_OU_PAS, 0xd8 Certaines versions de Bochs envoient mystérieusement cet octet. */
|
||||
};
|
||||
|
||||
static const uint8 DialogueDefinirCompaqStatusByte[] = {
|
||||
COMMANDE, KBC_DEMMANDE_ECRITURE_COMPAQ_STATUS_BYTE,
|
||||
ENVOYER_V, 0
|
||||
/* RECEVOIR_OU_PAS, SOURIS_PS2_ACK */
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef struct PaquetSourisPS2_1 {
|
||||
uint8 boutonGauche:1;
|
||||
uint8 boutonDroite:1;
|
||||
uint8 boutonMilieu:1;
|
||||
uint8 un:1;
|
||||
uint8 xNegatif:1;
|
||||
uint8 yNegatif:1;
|
||||
uint8 xOverflow:1;
|
||||
uint8 yOverflow:1;
|
||||
} PaquetSourisPS2_1;
|
||||
|
||||
typedef enum {
|
||||
MOLETTE_DEFILEMENT_AUCUN = 0,
|
||||
MOLETTE_DEFILEMENT_HAUT = 1,
|
||||
MOLETTE_DEFILEMENT_BAS = 0xf,
|
||||
MOLETTE_DEFILEMENT_GAUCHE = 0xe,
|
||||
MOLETTE_DEFILEMENT_DROITE = 2
|
||||
} ModeDefilementSourisPS2;
|
||||
|
||||
typedef struct PaquetSourisPS2_4 {
|
||||
uint8 ignorer:2;
|
||||
uint8 bouton5:1;
|
||||
uint8 bouton4:1;
|
||||
ModeDefilementSourisPS2 modeDefilement:4;
|
||||
} PaquetSourisPS2_4;
|
||||
|
||||
|
||||
typedef enum {
|
||||
ETAT_GESTIONNAIRE_SOURIS_PS2_ATTENTE,
|
||||
ETAT_GESTIONNAIRE_SOURIS_PS2_PAQUET,
|
||||
ETAT_GESTIONNAIRE_SOURIS_PS2_DIALOGUE
|
||||
} EtatGestionnaireSourisPS2;
|
||||
|
||||
typedef void (*FonctionRappelSourisPS2) (bool erreur);
|
||||
|
||||
typedef struct DialogueSourisPS2 {
|
||||
const uint8* sequence;
|
||||
int longueur;
|
||||
uint8* parametre;
|
||||
FonctionRappelSourisPS2 rappel;
|
||||
} DialogueSourisPS2;
|
||||
|
||||
|
||||
typedef struct EtatSourisPS2 {
|
||||
uint8 resolution;
|
||||
uint8 frequence;
|
||||
uint8 mouseID;
|
||||
uint8 compaqStatusByte;
|
||||
bool resetPotentiel;
|
||||
uint8 paquets[4];
|
||||
int paquet;
|
||||
bool paquetsDoiventEtreZero;
|
||||
bool debordementXY;
|
||||
DialogueSourisPS2 dialogue;
|
||||
int etapeDialogue;
|
||||
EtatGestionnaireSourisPS2 etatGestionnaireSourisPS2;
|
||||
|
||||
/* DEBUG */
|
||||
int32 curseur_x;
|
||||
int32 curseur_y;
|
||||
uint32 couleur;
|
||||
} EtatSourisPS2;
|
||||
|
||||
#endif
|
22
src/inclusions/pc/vesaGraphique/vesaGraphique.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef PC_VESA_GRAPHIQUE_VESA_GRAPHIQUE_H
|
||||
#define PC_VESA_GRAPHIQUE_VESA_GRAPHIQUE_H
|
||||
|
||||
#include <interfaceUtilisateur/console/console.h>
|
||||
|
||||
typedef struct Pixel {
|
||||
uint32 rvb:24;
|
||||
} PACKED Pixel;
|
||||
|
||||
typedef struct EtatVesaGraphique {
|
||||
Pixel* memoireVideo;
|
||||
Console console;
|
||||
} EtatVesaGraphique;
|
||||
|
||||
|
||||
void setPixel32 (uint32 x, uint32 y, uint32 couleur);
|
||||
void ligne (uint32 x1, uint32 y1, uint32 x2, uint32 y2, uint32 couleur);
|
||||
void rectanglePlein (uint32 x1, uint32 x2, uint32 y1, uint32 y2, uint32 couleur);
|
||||
void rectangleContour (uint32 x1, uint32 x2, uint32 y1, uint32 y2, uint32 couleur);
|
||||
void vesaGraphiqueAfficherCaractereCouleurPosition(char caractere, uint32 couleurAv, uint32 couleurAr, uint32 x, uint32 y);
|
||||
|
||||
#endif
|
38
src/inclusions/pc/vgaTexte/vgaTexte.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
#ifndef PC_VGA_TEXTE_VGA_TEXTE_H
|
||||
#define PC_VGA_TEXTE_VGA_TEXTE_H
|
||||
|
||||
#include <interfaceUtilisateur/console/console.h>
|
||||
|
||||
typedef struct CouleurVgaTexte {
|
||||
uint8 avClair:1;
|
||||
uint8 avRouge:1;
|
||||
uint8 avVert:1;
|
||||
uint8 avBleu:1;
|
||||
uint8 _reserve:1;
|
||||
uint8 arRouge:1;
|
||||
uint8 arVert:1;
|
||||
uint8 arBleu:1;
|
||||
} CouleurVgaTexte;
|
||||
|
||||
typedef struct CaractereVgaTexte {
|
||||
char caractere;
|
||||
CouleurVgaTexte couleur;
|
||||
} PACKED CaractereVgaTexte;
|
||||
|
||||
|
||||
typedef struct EtatVgaTexte {
|
||||
CaractereVgaTexte* memoireVideo;
|
||||
Console console;
|
||||
} EtatVgaTexte;
|
||||
|
||||
|
||||
void vgaTexteEffacerConsole();
|
||||
void vgaTexteAfficherCaractereCouleurPosition(char caractere, uint32 couleurAv, uint32 couleurAr, uint32 x, uint32 y);
|
||||
uint32 vgaTexteConsoleCouleur(uint32 couleur);
|
||||
void vgaTexteConsolePosition(int position);
|
||||
|
||||
void consoleNL();
|
||||
void afficherCaractereBrut(char caractere);
|
||||
void afficherCaractere(char caractere);
|
||||
|
||||
#endif
|
9
src/inclusions/recherche/dichotomique/dichotomique.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#ifndef RECHERCHE_DICHOTOMIQUE_DICHOTOMIQUE_H
|
||||
#define RECHERCHE_DICHOTOMIQUE_DICHOTOMIQUE_H
|
||||
|
||||
typedef char EtatRechercheDichotomique;
|
||||
|
||||
int rechercheDichotomiquePremier(void* e, void* t, int taille, AccesseurIndex get, ComparaisonStricte comparer);
|
||||
int rechercheDichotomiqueDernier(void* e, void* t, int taille, AccesseurIndex get, ComparaisonStricte comparer);
|
||||
|
||||
#endif
|
53
src/inclusions/stockage/ata/ata.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
#ifndef STOCKAGE_ATA_ATA_H
|
||||
#define STOCKAGE_ATA_ATA_H
|
||||
|
||||
#define PORT_ATA 0x1f0
|
||||
|
||||
#define PORT_ATA_DONNEES PORT_ATA + 0
|
||||
|
||||
#define PORT_ATA_ERREUR PORT_ATA + 1
|
||||
|
||||
#define PORT_ATA_NOMBRE_SECTEURS PORT_ATA + 2
|
||||
|
||||
#define PORT_ATA_ADRESSE_PARTIELLE_SECTEUR PORT_ATA + 3
|
||||
#define PORT_ATA_ADRESSE_PARTIELLE_SECTEUR_1 PORT_ATA_ADRESSE_PARTIELLE_SECTEUR + 0
|
||||
#define PORT_ATA_ADRESSE_PARTIELLE_SECTEUR_2 PORT_ATA_ADRESSE_PARTIELLE_SECTEUR + 1
|
||||
#define PORT_ATA_ADRESSE_PARTIELLE_SECTEUR_3 PORT_ATA_ADRESSE_PARTIELLE_SECTEUR + 2
|
||||
|
||||
|
||||
#define PORT_ATA_DIVERS PORT_ATA + 6
|
||||
#define PORT_ATA_SELECTION_LECTEUR PORT_ATA_DIVERS
|
||||
#define PORT_ATA_DRAPEAUX PORT_ATA_DIVERS
|
||||
#define PORT_ATA_FIN_ADRESSE_SECTEUR PORT_ATA_DIVERS
|
||||
|
||||
#define PORT_ATA_COMMANDE_ETAT PORT_ATA + 7
|
||||
#define PORT_ATA_COMMANDE PORT_ATA_COMMANDE_ETAT
|
||||
#define PORT_ATA_ETAT PORT_ATA_COMMANDE_ETAT
|
||||
|
||||
#define PORT_ATA_CONTROLE_ETAT_ALTERNATIF 0x3f6
|
||||
#define PORT_ATA_CONTROLE PORT_ATA_CONTROLE_ETAT_ALTERNATIF
|
||||
#define PORT_ATA_ETAT_ALTERNATIF PORT_ATA_CONTROLE_ETAT_ALTERNATIF
|
||||
|
||||
typedef struct AtaOctetEtat {
|
||||
bool srv:1; /* TODO : traduire "Overlapped mode service request" */
|
||||
bool erreurDisque:1;
|
||||
bool pret:1;
|
||||
bool occupe:1;
|
||||
bool transfertPret:1;
|
||||
uint8 reserve:2;
|
||||
bool erreur;
|
||||
} AtaOctetEtat;
|
||||
|
||||
typedef struct AtaControle {
|
||||
uint8 reserve_b:1;
|
||||
bool interruptions:1;
|
||||
bool reInitialisation:1;
|
||||
uint8 reserve_a:4;
|
||||
bool octetHaut:1;
|
||||
} AtaControle;
|
||||
|
||||
|
||||
typedef struct EtatAta {
|
||||
} EtatAta;
|
||||
|
||||
#endif
|
23
src/inclusions/string.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef STRING_H
|
||||
#define STRING_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
int strcmp(StringZ s1, StringZ s2) {
|
||||
while (*s1 == *s2 && *s1 != 0) {
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
if (*s1 == *s2)
|
||||
return 0;
|
||||
else if (*s1 < *s2)
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool streq(StringZ s1, StringZ s2) {
|
||||
return (strcmp(s1,s2) == 0);
|
||||
}
|
||||
|
||||
#endif
|
26
src/inclusions/temps/temps/temps.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef TEMPS_TEMPS_TEMPS_H
|
||||
#define TEMPS_TEMPS_TEMPS_H
|
||||
|
||||
typedef void (*FonctionRappel) ();
|
||||
|
||||
typedef struct Echeance {
|
||||
uint64 dateEcheance;
|
||||
FonctionRappel fonction;
|
||||
struct Echeance* echeanceSuivante;
|
||||
} Echeance;
|
||||
|
||||
typedef struct EtatTemps {
|
||||
uint32 increments; /* 1..10^9 Nombre de nanosecondes entre chaque 'tic' d'horloge. */
|
||||
|
||||
uint32 nanosec; /* nanosecondes depuis la dernière seconde entière. */
|
||||
uint64 sec; /* secondes depuis le 01/01/1970 à 00h00 . */
|
||||
uint64 delta; /* Décalage connu à rattrapper / ralentir progressivement . */
|
||||
uint64 etapesDelta; /* Rattrapper le décalage en combien de nanosecondes ? */
|
||||
|
||||
Echeance* listeEcheancesDate; /* Tiennent compte immédiatement (ou pas ?) de delta */
|
||||
Echeance* listeEcheancesDelai; /* Ne tiennent pas compte de delta */
|
||||
|
||||
uint64 debug; /* DEBUG */
|
||||
} EtatTemps;
|
||||
|
||||
#endif
|
8
src/inclusions/tri/tas/tas.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef TRI_TAS_TAS_H
|
||||
#define TRI_TAS_TAS_H
|
||||
|
||||
typedef char EtatTriParTas;
|
||||
|
||||
void triParTas(void* t, int taille, AccesseurIndex get, AccesseurEchanger echanger, Comparaison comparer);
|
||||
|
||||
#endif
|
59
src/inclusions/types.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
/* Types simples */
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned int uint32;
|
||||
typedef unsigned long long uint64;
|
||||
|
||||
typedef int int32;
|
||||
|
||||
typedef enum {
|
||||
TRUE = 1,
|
||||
FALSE = 0
|
||||
} bool;
|
||||
|
||||
|
||||
/* Types composés */
|
||||
#define CAST_STRUCT_TO_INT(_struct) (*((int*)((void*)(&_struct))))
|
||||
#define CAST_INT_TO_STRUCT(_int, _struct_t) (*((_struct_t*)((void*)(&_int))))
|
||||
|
||||
typedef struct Liste {
|
||||
void* car;
|
||||
struct Liste* cdr;
|
||||
} Liste;
|
||||
|
||||
typedef char* String;
|
||||
typedef String StringZ;
|
||||
|
||||
#define LONGUEUR(t) (sizeof (t) / sizeof (*(t)))
|
||||
|
||||
|
||||
/* Attributs */
|
||||
#define ALIGNED(alignement) __attribute__ ((aligned(alignement)))
|
||||
#define PACKED __attribute__ ((packed))
|
||||
#define USED __attribute__ ((used))
|
||||
#define SECTION(sec) __attribute__ ((section(#sec)))
|
||||
|
||||
|
||||
/* Constantes */
|
||||
#define NULL (void*)0
|
||||
|
||||
|
||||
/* Prototypes de fonctions */
|
||||
|
||||
/* Comparaison ComparaisonStricte
|
||||
* a < b : return <0 <0
|
||||
* a = b : return peu importe =0
|
||||
* a > b : return >=0 >0 */
|
||||
typedef int (Comparaison)(void* a, void* b);
|
||||
|
||||
typedef Comparaison ComparaisonStricte;
|
||||
|
||||
typedef void* (AccesseurIndex)(void* t, uint32 index);
|
||||
|
||||
typedef void (AccesseurEchanger)(void* t, uint32 a, uint32 b);
|
||||
|
||||
|
||||
#endif
|
42
src/makefiles/affichage.makefile
Normal file
|
@ -0,0 +1,42 @@
|
|||
VIDE =
|
||||
|
||||
# Couleurs
|
||||
COULEUR = [$(1)m
|
||||
COULEUR_AUCUNE = $(call COULEUR,)
|
||||
COULEUR_BLEU_CLAIR = $(call COULEUR,1;34)
|
||||
COULEUR_VERT_CLAIR = $(call COULEUR,1;32)
|
||||
COULEUR_GRIS = $(call COULEUR,1;30)
|
||||
COULEUR_JAUNE_CLAIR = $(call COULEUR,1;33)
|
||||
COULEUR_VERT_FONCE = $(call COULEUR,0;32)
|
||||
|
||||
COULEUR_SOURCE = $(COULEUR_BLEU_CLAIR)
|
||||
COULEUR_DEST = $(COULEUR_VERT_FONCE)
|
||||
COULEUR_TAG = $(COULEUR_GRIS)
|
||||
COULEUR_TAG_CC = $(COULEUR_VERT_FONCE)
|
||||
COULEUR_TAG_AS = $(COULEUR_TAG_CC)
|
||||
COULEUR_TAG_LD = $(COULEUR_BLEU_CLAIR)
|
||||
COULEUR_TAG_CD = $(COULEUR_JAUNE_CLAIR)
|
||||
COULEUR_TAG_TT = $(COULEUR_VERT_CLAIR)
|
||||
|
||||
# Apparence
|
||||
FORMAT_TAG = $(COULEUR_TAG)[$(call COULEUR_TAG_$(1))$(1)$(COULEUR_TAG)]$(COULEUR_AUCUNE) $(VIDE)
|
||||
FORMAT_FLECHE = $(VIDE) <- $(VIDE)
|
||||
FORMAT_SOURCE = $(COULEUR_SOURCE)$(call FORMAT_CHEMIN,$(1))$(COULEUR_AUCUNE)
|
||||
FORMAT_DEST = $(COULEUR_DEST)$(call FORMAT_CHEMIN,$(1))$(COULEUR_AUCUNE)
|
||||
|
||||
FORMAT_CHEMIN = $(subst //,/,$(1))
|
||||
|
||||
FORMAT_ACTION_1 = $(call FORMAT_TAG,$(1))$(call FORMAT_DEST,$(2))
|
||||
FORMAT_ACTION_2 = $(call FORMAT_ACTION_1,$(1),$(3))$(FORMAT_FLECHE)$(call FORMAT_SOURCE,$(2))
|
||||
|
||||
# Fonctions d'affichage
|
||||
AFFICHE = echo "$(1)"
|
||||
|
||||
AFFICHE_ACTION = $(call AFFICHE,$(call FORMAT_ACTION_$(1),$(2),$(3),$(4)))
|
||||
|
||||
AFFICHE_CC = $(call AFFICHE_ACTION,2,CC,$(1),$(notdir $(2)))
|
||||
AFFICHE_AS = $(call AFFICHE_ACTION,2,AS,$(1),$(notdir $(2)))
|
||||
AFFICHE_FN = $(call AFFICHE_ACTION,2,FN,$(1),$(notdir $(2)))
|
||||
AFFICHE_LD = $(call AFFICHE_ACTION,2,LD,$(notdir $(1)),$(notdir $(2)))
|
||||
AFFICHE_CD = $(call AFFICHE_ACTION,1,CD,$(1))
|
||||
AFFICHE_TT = $(call AFFICHE_ACTION,1,TT,$(1))
|
37
src/makefiles/commandes.makefile
Normal file
|
@ -0,0 +1,37 @@
|
|||
CC := gcc
|
||||
CC_OPTS := -Werror -Wall -Wextra \
|
||||
-nostdlib -nostdinc -ffreestanding -undef \
|
||||
-O3 -fomit-frame-pointer \
|
||||
-fno-strict-aliasing \
|
||||
-std=gnu99 -fasm \
|
||||
-frandom-seed=1234
|
||||
# -fextended-identifiers ?
|
||||
# -finput-charset=utf-8 ?
|
||||
CC_INCLUSIONS = $(patsubst %,-I%,$(REP_INCLUSIONS))
|
||||
|
||||
LD := ld
|
||||
LD_OPTS := --warn-common --fatal-warnings \
|
||||
-nostdlib
|
||||
|
||||
FN := $(REP_SCRIPTS)/creerPolice.sh
|
||||
FN_OPTS :=
|
||||
|
||||
EMU := qemu
|
||||
EMU_OPTS := -m 4 --full-screen
|
||||
|
||||
GEN_ISO := genisoimage
|
||||
|
||||
GEN_ISO_OPTS := -R -boot-load-size 4 -no-emul-boot -b boot/grub/stage2_eltorito -boot-info-table -c boot/boot.cat \
|
||||
-input-charset utf-8 -quiet \
|
||||
|
||||
RM := rm
|
||||
RM_OPTS :=
|
||||
|
||||
CAT := cat
|
||||
CAT_OPTS :=
|
||||
|
||||
MKDIR := mkdir
|
||||
MKDIR_OPTS := -p
|
||||
|
||||
CREATE_FILE := touch
|
||||
CREATE_FILE_OPTS :=
|
37
src/makefiles/fichiersDossiers.makefile
Normal file
|
@ -0,0 +1,37 @@
|
|||
REP_SOURCES := ./src
|
||||
|
||||
REP_TRAVAIL := ./travail
|
||||
|
||||
REP_DIST := ./dist
|
||||
|
||||
REP_INCLUSIONS := $(REP_SOURCES)/inclusions
|
||||
|
||||
REP_SCRIPTS := $(REP_SOURCES)/scripts
|
||||
|
||||
REP_A_SUPPRIMER := $(REP_TRAVAIL) $(REP_DIST)
|
||||
|
||||
|
||||
|
||||
IMAGE_CDROM := $(REP_DIST)/cdrom/gruntnetwork.iso
|
||||
|
||||
NOYAU_ELF := $(REP_DIST)/noyau.elf
|
||||
|
||||
POLICE_FNT := $(REP_DIST)/police.fnt
|
||||
|
||||
SCRIPT_LD := $(REP_SCRIPTS)/creerImage.lds
|
||||
|
||||
LISTE_FICHIERS_ISO := $(REP_SCRIPTS)/liste-chemins.lst
|
||||
|
||||
|
||||
|
||||
FICHIERS_ISO := $(shell cut -d '=' -f 2- $(LISTE_FICHIERS_ISO))
|
||||
|
||||
SOURCES := $(shell find $(REP_SOURCES) -name '*.c' -or -name '*.S' -or -name '*.fnt')
|
||||
|
||||
OBJETS := $(patsubst %,$(REP_TRAVAIL)/%.o,$(SOURCES))
|
||||
|
||||
OBJETS_LD := $(filter %.c.o %.S.o,$(OBJETS))
|
||||
|
||||
OBJETS_FNT := $(filter %.fnt.o,$(OBJETS))
|
||||
|
||||
DEPENDANCES := $(patsubst %.o,%.d,$(OBJETS))
|
53
src/makefiles/regles.makefile
Normal file
|
@ -0,0 +1,53 @@
|
|||
.PHONY: all
|
||||
all: $(IMAGE_CDROM)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@echo " Suppression..."
|
||||
@$(RM) $(RM_OPTS) -rf $(REP_A_SUPPRIMER)
|
||||
@$(MKDIR) $(MKDIR_OPTS) $(REP_A_SUPPRIMER)
|
||||
rmdir ./travail ./dist
|
||||
mkdir ./travail ./dist
|
||||
|
||||
.PHONY: test
|
||||
test: $(IMAGE_CDROM)
|
||||
@$(call AFFICHE_TT,$<,$@)
|
||||
@sync
|
||||
@$(EMU) $(EMU_OPTS) -cdrom $< -boot d
|
||||
|
||||
|
||||
|
||||
-include $(DEPENDANCES)
|
||||
|
||||
|
||||
|
||||
$(IMAGE_CDROM): $(FICHIERS_ISO)
|
||||
@$(call AFFICHE_CD,$^,$@)
|
||||
@$(MKDIR) $(MKDIR_OPTS) $(dir $@)
|
||||
@$(GEN_ISO) $(GEN_ISO_OPTS) -o $@ -graft-points -path-list $(LISTE_FICHIERS_ISO)
|
||||
|
||||
$(POLICE_FNT): $(OBJETS_FNT)
|
||||
@$(CAT) $(CAT_OPTS) $^ > $@
|
||||
|
||||
$(NOYAU_ELF): $(OBJETS_LD)
|
||||
@$(call AFFICHE_LD,$^,$@)
|
||||
@$(LD) $(LD_OPTS) -o $(NOYAU_ELF) -T $(SCRIPT_LD) $^
|
||||
|
||||
|
||||
|
||||
.PRECIOUS: %.dir
|
||||
%.dir:
|
||||
@$(MKDIR) $(MKDIR_OPTS) $(dir $@)
|
||||
@$(CREATE_FILE) $(CREATE_FILE_OPTS) $@
|
||||
|
||||
$(REP_TRAVAIL)/%.c.o: %.c $(REP_TRAVAIL)/%.dir $(MAKEFILES)
|
||||
@$(call AFFICHE_CC,$<,$@)
|
||||
@$(CC) $(CC_OPTS) -MMD -MF $(@:.o=.d) $(CC_INCLUSIONS) -c $< -o $@
|
||||
|
||||
$(REP_TRAVAIL)/%.S.o: %.S $(REP_TRAVAIL)/%.dir $(MAKEFILES)
|
||||
@$(call AFFICHE_AS,$<,$@)
|
||||
@$(CC) $(CC_OPTS) -MMD -MF $(@:.o=.d) $(CC_INCLUSIONS) -c $< -o $@ -DASM
|
||||
|
||||
$(REP_TRAVAIL)/%.fnt.o: %.fnt $(REP_TRAVAIL)/%.dir $(MAKEFILES) $(FN)
|
||||
@$(call AFFICHE_FN,$<,$@)
|
||||
@$(FN) $(FN_OPTS) $< $@
|
39
src/modules/algo/math/math.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include <module.h>
|
||||
#include <types.h>
|
||||
#include <algo/math/math.h>
|
||||
|
||||
MODULE(Math);
|
||||
|
||||
/* denominateur < 2^63 */
|
||||
Div64 div64 (uint64 numerateur, uint64 denominateur) {
|
||||
uint64 reste = 0;
|
||||
uint64 quotient = 0;
|
||||
Div64 resultat;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 64; i++) {
|
||||
quotient <<= 1;
|
||||
reste <<= 1;
|
||||
reste |= (numerateur & 0x8000000000000000L) ? 1 : 0;
|
||||
numerateur <<= 1;
|
||||
if (reste >= denominateur) {
|
||||
quotient |= 1;
|
||||
reste -= denominateur;
|
||||
}
|
||||
}
|
||||
|
||||
resultat.quotient = quotient;
|
||||
resultat.reste = reste;
|
||||
|
||||
return resultat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void initMath (void** etat) {
|
||||
*etat = etatMath;
|
||||
}
|
||||
|
||||
void deinitMath (void** etat) {
|
||||
*etat = NULL;
|
||||
}
|
31
src/modules/demarrage/multiboot/multiboot.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
.section .multiboot
|
||||
.set magicEnTeteMultiboot, 0x1badb002
|
||||
.set optionsEnTeteMultiboot, 4
|
||||
.set sommeControleEnTeteMultiboot, -(magicEnTeteMultiboot + optionsEnTeteMultiboot)
|
||||
.set taillePile, 4096
|
||||
|
||||
.align 4
|
||||
.long magicEnTeteMultiboot
|
||||
.long optionsEnTeteMultiboot
|
||||
.long sommeControleEnTeteMultiboot
|
||||
.long 0
|
||||
.long 0
|
||||
.long 0
|
||||
.long 0
|
||||
.long 0
|
||||
.long 0
|
||||
.long 1024
|
||||
.long 768
|
||||
.long 24
|
||||
|
||||
.section .text
|
||||
.globl _start
|
||||
_start:
|
||||
mov $(stack+taillePile), %esp
|
||||
|
||||
push %eax
|
||||
push %ebx
|
||||
|
||||
call pointEntreeNoyau
|
||||
|
||||
.comm stack, taillePile, 4
|
214
src/modules/demarrage/multiboot/multiboot.c
Normal file
|
@ -0,0 +1,214 @@
|
|||
#include <module.h>
|
||||
#include <types.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <tri/tas/tas.h>
|
||||
#include <demarrage/multiboot/multiboot.h>
|
||||
#include <interfaceUtilisateur/console/console.h>
|
||||
#include <recherche/dichotomique/dichotomique.h>
|
||||
|
||||
MODULE(Multiboot);
|
||||
|
||||
DEPENDANCE_MODULE(Multiboot, Console);
|
||||
|
||||
/* __listeModule et __finListeModules sont définis dans modules/creerImage.lds */
|
||||
|
||||
extern InfoModule __listeModules;
|
||||
extern InfoModule __finListeModules;
|
||||
|
||||
extern DependanceModule __listeDependancesModules;
|
||||
extern DependanceModule __finListeDependancesModules;
|
||||
|
||||
|
||||
void afficherNomModule(InfoModule* module) {
|
||||
CouleurAvAr ancienneCouleur = consoleCouleur(0x00ff00ff, 0);
|
||||
afficherChaineZ(module->nom);
|
||||
afficherChaineZ("\n");
|
||||
consoleCouleur(ancienneCouleur.av, ancienneCouleur.ar);
|
||||
}
|
||||
|
||||
void afficherNomsModulesManques(InfoModule* listeModules) {
|
||||
// effacerConsole(); /* Seulement en mode texte, en mode graphique, l'écran est déjà noir... */
|
||||
InfoModule* module = listeModules;
|
||||
|
||||
while (module != NULL) {
|
||||
if (module->etapeChargementModule == ETAPE_MODULE_INITIALISE)
|
||||
afficherNomModule(module);
|
||||
module = module->suivant;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void* triDependancesGet(void* t, uint32 index) {
|
||||
return ((DependanceModule*)t) + index;
|
||||
}
|
||||
|
||||
void triDependancesEchange(void* t, uint32 a, uint32 b) {
|
||||
DependanceModule* tt = t;
|
||||
DependanceModule c;
|
||||
|
||||
c = tt[a];
|
||||
tt[a] = tt[b];
|
||||
tt[b] = c;
|
||||
}
|
||||
|
||||
int triDependancesCmp(void* a, void* b) {
|
||||
void* aa = ((DependanceModule*)a)->module;
|
||||
void* bb = ((DependanceModule*)b)->module;
|
||||
|
||||
if (aa < bb)
|
||||
return -1;
|
||||
else if (aa == bb)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
void pointEntreeNoyau(void* addrInfoMultiboot, uint32 magicMultiboot) {
|
||||
asm volatile ("cli");
|
||||
|
||||
int nbModules = 0;
|
||||
InfoModule* module;
|
||||
InfoModule* moduleTemp;
|
||||
InfoModule* listeModules = &__listeModules;
|
||||
InfoModule* finListeModules = &__finListeModules;
|
||||
|
||||
int i;
|
||||
int nbDependancesModules;
|
||||
int premiereDependanceModule;
|
||||
int derniereDependanceModule;
|
||||
DependanceModule dependanceRecherchee;
|
||||
DependanceModule* dependanceModule;
|
||||
DependanceModule* listeDependancesModules = &__listeDependancesModules;
|
||||
DependanceModule* finListeDependancesModules = &__finListeDependancesModules;
|
||||
|
||||
/* Pré-initialisation de l'état du module multiboot */
|
||||
etatMultiboot->InfoMultiboot = addrInfoMultiboot;
|
||||
etatMultiboot->magicMultiboot = magicMultiboot;
|
||||
|
||||
|
||||
/* Tri de la liste de dépendances */
|
||||
nbDependancesModules = ((int)finListeDependancesModules - (int)listeDependancesModules) / sizeof(DependanceModule);
|
||||
triParTas(
|
||||
listeDependancesModules,
|
||||
nbDependancesModules,
|
||||
triDependancesGet,
|
||||
triDependancesEchange,
|
||||
triDependancesCmp
|
||||
);
|
||||
|
||||
/* Chaînage des modules */
|
||||
nbModules = ((int)finListeModules - (int)listeModules) / sizeof(InfoModule);
|
||||
module = listeModules;
|
||||
while (module < finListeModules) {
|
||||
module->suivant = module + 1;
|
||||
|
||||
dependanceRecherchee = (DependanceModule){ module, NULL };
|
||||
premiereDependanceModule = rechercheDichotomiquePremier(
|
||||
&dependanceRecherchee,
|
||||
listeDependancesModules,
|
||||
nbDependancesModules,
|
||||
triDependancesGet,
|
||||
triDependancesCmp
|
||||
);
|
||||
|
||||
if (premiereDependanceModule < 0) {
|
||||
module->dependances = NULL;
|
||||
module->nbDependances = -1;
|
||||
} else {
|
||||
derniereDependanceModule = rechercheDichotomiqueDernier(
|
||||
&dependanceRecherchee,
|
||||
listeDependancesModules,
|
||||
nbDependancesModules,
|
||||
triDependancesGet,
|
||||
triDependancesCmp
|
||||
);
|
||||
module->dependances = listeDependancesModules + premiereDependanceModule;
|
||||
module->nbDependances = derniereDependanceModule - premiereDependanceModule + 1;
|
||||
}
|
||||
|
||||
module++;
|
||||
}
|
||||
if (nbModules != 0)
|
||||
(module-1)->suivant = NULL;
|
||||
|
||||
|
||||
/* Initialisation des modules */
|
||||
module = (nbModules != 0) ? listeModules : NULL;
|
||||
bool consoleDisponible = FALSE;
|
||||
/* GCC BUG :
|
||||
*
|
||||
* while ((void*)module != (void*)NULL) {
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* Lorsqu'on regarde la sortie assembleur de GCC, on voit qu'il teste
|
||||
* avant l'entrée dans la boucle s'il doit l'éviter, après quoi aucune
|
||||
* instruction ne permet d'en sortir. Ce qui explique le fonctionnement
|
||||
* incorrect du programme à l'exécution. De plus, on se rend compte
|
||||
* avec des comparaisons ( < , = , > ) qu'il semble considérer que
|
||||
* 1 < module < 2 (donc on a un pointeur flottant \o/ ). Vu qu'il y a
|
||||
* très peu de chances pour que l'info sur un module soit située à 1 (!),
|
||||
* on utilise ((void*)module > (void*)(1)) . */
|
||||
|
||||
while ((void*)module > (void*)(1)) {
|
||||
if (module->etapeChargementModule != ETAPE_MODULE_INITIALISE) {
|
||||
dependanceModule = module->dependances;
|
||||
|
||||
for (i = 0; i < module->nbDependances; i++) {
|
||||
if (dependanceModule->dependance->etapeChargementModule != ETAPE_MODULE_INITIALISE) {
|
||||
dependanceModule->dependance->suivantRecursionDependances = module;
|
||||
module = dependanceModule->dependance;
|
||||
goto finBoucleInitialisationModules;
|
||||
}
|
||||
dependanceModule++;
|
||||
}
|
||||
|
||||
|
||||
if (consoleDisponible)
|
||||
afficherNomModule(module);
|
||||
|
||||
|
||||
(*(module->init)) (module->etat);
|
||||
module->etapeChargementModule = ETAPE_MODULE_INITIALISE;
|
||||
|
||||
if (!consoleDisponible && consolePrete()) {
|
||||
consoleDisponible = TRUE;
|
||||
afficherNomsModulesManques(listeModules);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (module->suivantRecursionDependances != NULL) {
|
||||
moduleTemp = module->suivantRecursionDependances;
|
||||
module->suivantRecursionDependances = NULL;
|
||||
module = moduleTemp;
|
||||
} else {
|
||||
module = module->suivant;
|
||||
}
|
||||
|
||||
finBoucleInitialisationModules:
|
||||
{} /* Fausse instruction pour éviter un "error: label at end of compound statement" */
|
||||
}
|
||||
|
||||
|
||||
/* Fin */
|
||||
afficherChaineZ("\n\n");
|
||||
|
||||
for (;;) asm volatile ("hlt;");
|
||||
}
|
||||
|
||||
|
||||
void initMultiboot(void** etat) {
|
||||
*etat = etatMultiboot;
|
||||
|
||||
/* if (etatMultiboot->InfoMultiboot->flags.bootLoaderName) {
|
||||
afficherChaineZ("Charg" STR_eacute " par ");
|
||||
afficherChaineZ(etatMultiboot->InfoMultiboot->bootLoaderName);
|
||||
afficherChaineZ(".\n");
|
||||
} */
|
||||
}
|
||||
|
||||
void deinitMultiboot(void** etat) {
|
||||
*etat = NULL;
|
||||
}
|
26
src/modules/interfaceUtilisateur/clavier/clavier.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include <module.h>
|
||||
#include <types.h>
|
||||
#include <pc/kbc/kbc.h>
|
||||
#include <interfaceUtilisateur/clavier/clavier.h>
|
||||
#include <interfaceUtilisateur/console/console.h>
|
||||
|
||||
MODULE(Clavier);
|
||||
|
||||
DEPENDANCE_MODULE(Clavier, Kbc);
|
||||
DEPENDANCE_MODULE(Clavier, Console);
|
||||
|
||||
|
||||
void gestionnaireClavier(uint8 scancode) {
|
||||
afficherEntierEnHexa(scancode);
|
||||
afficherChaineZ("\n");
|
||||
}
|
||||
|
||||
void initClavier (void** etat) {
|
||||
*etat = NULL;
|
||||
|
||||
definirGestionnaireClavier(gestionnaireClavier);
|
||||
}
|
||||
|
||||
void deinitClavier (void** etat) {
|
||||
*etat = NULL;
|
||||
}
|
245
src/modules/interfaceUtilisateur/console/console.c
Normal file
|
@ -0,0 +1,245 @@
|
|||
#include <types.h>
|
||||
#include <module.h>
|
||||
#include <interfaceUtilisateur/console/console.h>
|
||||
|
||||
MODULE(Console);
|
||||
|
||||
/* Cette variable risque d'être utilisée avant l'apel de initConsole(),
|
||||
* donc on la déclare à l'extérieur de etatConsole, dont la valeur est
|
||||
* indéfinie tant que initConsole n'a pas été apellée. */
|
||||
static bool _consolePrete;
|
||||
|
||||
|
||||
Console* definirConsoleActive(Console* console) {
|
||||
Console* ancienneConsole = etatConsole->consoleActive;
|
||||
|
||||
ancienneConsole->x = etatConsole->x;
|
||||
ancienneConsole->y = etatConsole->y;
|
||||
|
||||
etatConsole->x = console->x;
|
||||
etatConsole->y = console->y;
|
||||
|
||||
etatConsole->consoleActive = console;
|
||||
|
||||
_consolePrete = TRUE;
|
||||
return ancienneConsole;
|
||||
}
|
||||
|
||||
|
||||
CouleurAvAr getConsoleCouleur() {
|
||||
CouleurAvAr couleurs;
|
||||
couleurs.av = etatConsole->couleurAv;
|
||||
couleurs.ar = etatConsole->couleurAr;
|
||||
return couleurs;
|
||||
}
|
||||
|
||||
CouleurAvAr consoleCouleur(Couleur couleurAv, Couleur couleurAr) {
|
||||
CouleurAvAr couleurs = getConsoleCouleur();
|
||||
|
||||
etatConsole->couleurAv = couleurAv;
|
||||
etatConsole->couleurAr = couleurAr;
|
||||
|
||||
return couleurs;
|
||||
}
|
||||
|
||||
|
||||
Position getConsolePosition() {
|
||||
Position pos;
|
||||
pos.x = etatConsole->x;
|
||||
pos.y = etatConsole->y;
|
||||
return pos;
|
||||
}
|
||||
|
||||
Position consolePosition(uint32 x, uint32 y) {
|
||||
Position pos = getConsolePosition();
|
||||
|
||||
if (x >= etatConsole->consoleActive->largeur) {
|
||||
x %= etatConsole->consoleActive->largeur;
|
||||
y++;
|
||||
}
|
||||
|
||||
if (y >= etatConsole->consoleActive->hauteur) {
|
||||
y %= etatConsole->consoleActive->hauteur;
|
||||
}
|
||||
|
||||
etatConsole->x = x;
|
||||
etatConsole->y = y;
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
void consolePositionAvancerX() {
|
||||
consolePosition(etatConsole->x + 1, etatConsole->y);
|
||||
}
|
||||
|
||||
void consolePositionAvancerY() {
|
||||
consolePosition(etatConsole->x, etatConsole->y + 1);
|
||||
}
|
||||
|
||||
|
||||
void afficherCaractereCouleurPositionBrut(char caractere, uint32 couleurAv, uint32 couleurAr, uint32 x, uint32 y) {
|
||||
etatConsole->consoleActive->fonctionAffichage(caractere, couleurAv, couleurAr, x, y);
|
||||
|
||||
consolePositionAvancerX();
|
||||
|
||||
consoleCouleur(couleurAv, couleurAr);
|
||||
}
|
||||
|
||||
void afficherCaractereCouleurPosition(char caractere, uint32 couleurAv, uint32 couleurAr, uint32 x, uint32 y) {
|
||||
if (caractere == '\n')
|
||||
consolePosition(0, etatConsole->y + 1);
|
||||
else
|
||||
afficherCaractereCouleurPositionBrut(caractere, couleurAv, couleurAr, x, y);
|
||||
}
|
||||
|
||||
|
||||
void afficherCaractere(char caractere) {
|
||||
afficherCaractereCouleurPosition(caractere, etatConsole->couleurAv, etatConsole->couleurAr, etatConsole->x, etatConsole->y);
|
||||
}
|
||||
|
||||
void afficherCaractereBrut(char caractere) {
|
||||
afficherCaractereCouleurPositionBrut(caractere, etatConsole->couleurAv, etatConsole->couleurAr, etatConsole->x, etatConsole->y);
|
||||
}
|
||||
|
||||
|
||||
void afficherCaractereCouleur(char caractere, uint32 couleurAv, uint32 couleurAr) {
|
||||
afficherCaractereCouleurPosition(caractere, couleurAv, couleurAr, etatConsole->x, etatConsole->y);
|
||||
}
|
||||
|
||||
void afficherCaractereCouleurBrut(char caractere, uint32 couleurAv, uint32 couleurAr) {
|
||||
afficherCaractereCouleurPositionBrut(caractere, couleurAv, couleurAr, etatConsole->x, etatConsole->y);
|
||||
}
|
||||
|
||||
|
||||
void afficherCaracterePosition(char caractere, uint32 x, uint32 y) {
|
||||
afficherCaractereCouleurPosition(caractere, etatConsole->couleurAv, etatConsole->couleurAr, x, y);
|
||||
}
|
||||
|
||||
void afficherCaracterePositionBrut(char caractere, uint32 x, uint32 y) {
|
||||
afficherCaractereCouleurPositionBrut(caractere, etatConsole->couleurAv, etatConsole->couleurAr, x, y);
|
||||
}
|
||||
|
||||
|
||||
void effacerConsole() {
|
||||
uint32 x, y;
|
||||
consoleCouleur(0xffffffff, 0);
|
||||
for (x=0; x < etatConsole->consoleActive->largeur; x++)
|
||||
for (y=0; y < etatConsole->consoleActive->hauteur; y++)
|
||||
afficherCaracterePosition(' ', x, y);
|
||||
consolePosition(0, 0);
|
||||
}
|
||||
|
||||
void afficherChaineZ(char* chaine) {
|
||||
while (*chaine)
|
||||
afficherCaractere(*(chaine++));
|
||||
}
|
||||
|
||||
void afficherChaine(char* chaine, int longueur) {
|
||||
while (longueur-- > 0)
|
||||
afficherCaractere(*(chaine++));
|
||||
}
|
||||
|
||||
void afficherEntierVirguleEnDecimal(uint32 entier, int32 nbDecimales) {
|
||||
int pos, nbChar = sizeof(int)*4 + 1;
|
||||
char chiffres[nbChar];
|
||||
|
||||
for (pos = 0; (pos < nbChar) && ((nbDecimales >= 0) || (entier != 0)); nbDecimales--, pos++) {
|
||||
if (nbDecimales == 0)
|
||||
chiffres[pos++]='.';
|
||||
chiffres[pos] = 48 + (entier % 10);
|
||||
entier /= 10;
|
||||
}
|
||||
|
||||
if (pos == 0)
|
||||
afficherCaractere('0');
|
||||
else
|
||||
for (pos--; pos >= 0; pos--)
|
||||
afficherCaractere(chiffres[pos]);
|
||||
}
|
||||
|
||||
void afficherEntierEnDecimal(uint32 entier) {
|
||||
int pos, nbChar = sizeof(int)*4;
|
||||
char chiffres[nbChar];
|
||||
|
||||
for (pos = 0; (pos < nbChar) && (entier != 0); pos++) {
|
||||
chiffres[pos] = 48 + (entier % 10);
|
||||
entier /= 10;
|
||||
}
|
||||
|
||||
if (pos == 0)
|
||||
afficherCaractere('0');
|
||||
else
|
||||
for (pos--; pos >= 0; pos--)
|
||||
afficherCaractere(chiffres[pos]);
|
||||
}
|
||||
|
||||
void afficherEntierEnHexa(uint32 entier) {
|
||||
afficherCaractere('0');
|
||||
afficherCaractere('x');
|
||||
|
||||
int pos, nbChar = sizeof(entier)*2;
|
||||
char hexa[nbChar];
|
||||
|
||||
for (pos = 0; pos < nbChar; pos++) {
|
||||
if ((entier % 16) < 10)
|
||||
hexa[pos] = 48 + (entier % 16);
|
||||
else
|
||||
hexa[pos] = 87 + (entier % 16);
|
||||
entier /= 16;
|
||||
}
|
||||
|
||||
for (pos--; pos >= 0; pos--)
|
||||
afficherCaractere(hexa[pos]);
|
||||
}
|
||||
|
||||
void afficherEntierEnBinaire(uint32 entier) {
|
||||
int pos = 0;
|
||||
for (pos = 0; pos < 32; pos++) {
|
||||
if (entier & 0x80000000)
|
||||
afficherChaineZ("1");
|
||||
else
|
||||
afficherChaineZ("0");
|
||||
entier = entier << 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void afficherTableCaracteres() {
|
||||
int i;
|
||||
for (i = 0; i < 256; i++)
|
||||
afficherCaractereBrut(i);
|
||||
}
|
||||
|
||||
|
||||
void fonctionAffichageVide (char caractere, uint32 couleurAv, uint32 couleurAr, uint32 x, uint32 y) {
|
||||
caractere = caractere;
|
||||
couleurAv = couleurAv;
|
||||
couleurAr = couleurAr;
|
||||
x = x;
|
||||
y = y;
|
||||
}
|
||||
|
||||
Console consoleVide = {
|
||||
.largeur = 80,
|
||||
.hauteur = 25,
|
||||
.fonctionAffichage = fonctionAffichageVide
|
||||
};
|
||||
|
||||
bool consolePrete() {
|
||||
return _consolePrete;
|
||||
}
|
||||
|
||||
void initConsole(void** etat) {
|
||||
*etat = etatConsole;
|
||||
|
||||
etatConsole->x = 0;
|
||||
etatConsole->y = 0;
|
||||
etatConsole->couleurAv = 0xffffffff;
|
||||
etatConsole->couleurAr = 0x00000000;
|
||||
definirConsoleActive(&consoleVide);
|
||||
_consolePrete = FALSE;
|
||||
}
|
||||
|
||||
void deinitConsole(void** etat) {
|
||||
*etat = NULL;
|
||||
}
|
278
src/modules/interfaceUtilisateur/demo/demo.c
Normal file
|
@ -0,0 +1,278 @@
|
|||
#include <module.h>
|
||||
#include <types.h>
|
||||
#include <math.h>
|
||||
#include <interfaceUtilisateur/demo/demo.h>
|
||||
#include <interfaceUtilisateur/console/console.h>
|
||||
#include <pc/vesaGraphique/vesaGraphique.h>
|
||||
#include <interfaceUtilisateur/police/police.h>
|
||||
|
||||
MODULE(Demo);
|
||||
|
||||
DEPENDANCE_MODULE(Demo, Police);
|
||||
DEPENDANCE_MODULE(Demo, VesaGraphique);
|
||||
DEPENDANCE_MODULE(Demo, VgaTexte);
|
||||
DEPENDANCE_MODULE(Demo, Clavier);
|
||||
|
||||
void demoAffiche(uint32 x1, uint32 y1) {
|
||||
uint32 fg1 = 0x00880044;
|
||||
uint32 fg2 = 0x00770055;
|
||||
uint32 fg3 = 0x00550077;
|
||||
uint32 fg4 = 0x00440088;
|
||||
uint32 bg = 0x00ffcccc;
|
||||
uint32 ctr = 0x00886666;
|
||||
|
||||
policeAfficherCaractereCouleurPosition('L', fg1, bg, x1, y1);
|
||||
policeAfficherCaractereCouleurPosition('y', fg2, bg, x1 + 8, y1);
|
||||
policeAfficherCaractereCouleurPosition('r', fg3, bg, x1 + 2*8, y1);
|
||||
policeAfficherCaractereCouleurPosition('a', fg4, bg, x1 + 3*8, y1);
|
||||
|
||||
rectangleContour (x1 - 1, y1 - 2, x1+(4*8) + 2, y1+15 + 1, ctr);
|
||||
}
|
||||
|
||||
void faireDemo () {
|
||||
int32 x1 = 1024/2-8*2;
|
||||
int32 y1 = 768/2-15/2;
|
||||
|
||||
int32 ac1 = 0x00ff0000;
|
||||
int32 ac2 = 0x000000ff;
|
||||
int32 dc1 = 50;
|
||||
int32 dc2 = 50;
|
||||
int32 c = ac1;
|
||||
int32 x2 = 0;
|
||||
int32 y2 = 768 / 2;
|
||||
int32 x3 = x2;
|
||||
int32 y3 = y2;
|
||||
int32 dx = 3;
|
||||
int32 dy = 7;
|
||||
int32 ddx = 1;
|
||||
int32 ddy = 1;
|
||||
|
||||
while (FALSE) {
|
||||
demoAffiche(x1, y1);
|
||||
asm volatile ("hlt");
|
||||
asm volatile ("hlt");
|
||||
rectanglePlein (x1 - 1, y1 - 2, x1+(4*8) + 2, y1+15 + 1, 0);
|
||||
|
||||
x1 = ((x1 + x1*x1*y1 + y1*3 + 7) % (1024 - 4*8 + 3)) + 1;
|
||||
y1 = ((y1 + y1*y1*x1 + x1*3 + 42) % (768 - 15 + 3)) + 2;
|
||||
|
||||
dc1 = dc1 + dy / 10;
|
||||
dc2 = dc1 + dx / 5;
|
||||
c = dc1 * ac1 + dc2 * ac2;
|
||||
x3 = x2 + dx;
|
||||
y3 = y2 + dy;
|
||||
dx += abs(ddx - 3) - 1;
|
||||
dy += abs(ddy - 5) - 2;
|
||||
ddx = (ddx + 1) % 6;
|
||||
ddy = (ddy + 1) % 10;
|
||||
|
||||
if (x3 >= 1024) {
|
||||
x3 = 1024 - (x3 % 1024);
|
||||
dx = -dx;
|
||||
}
|
||||
if (y3 >= 768) {
|
||||
y3 = 768 - (y3 % 768);
|
||||
dy = -dy;
|
||||
}
|
||||
|
||||
if (x3 < 0) {
|
||||
x3 = abs(x3) % 1024;
|
||||
dx = -dx;
|
||||
}
|
||||
if (y3 < 0) {
|
||||
y3 = abs(y3) % 768;
|
||||
dy = -dy;
|
||||
}
|
||||
|
||||
ligne(x2, y2, x3, y3, c);
|
||||
|
||||
x2 = x3;
|
||||
y2 = y3;
|
||||
}
|
||||
|
||||
{
|
||||
int32 alx1 = 1024/2-8*2;
|
||||
int32 aly1 = 768/2-15/2;
|
||||
int32 lx1 = alx1;
|
||||
int32 ly1 = aly1;
|
||||
int32 lx2 = lx1;
|
||||
int32 ly2 = ly1;
|
||||
|
||||
uint32 i, compteur = 0, compteur2 = 0;
|
||||
int32 angle=0;
|
||||
int32 dangle=3;
|
||||
int32 ddangle=0;
|
||||
int32 x1 = 100;
|
||||
int32 y1 = 768/2;
|
||||
int32 x2 = x1;
|
||||
int32 y2 = y1;
|
||||
int32 ax = lx2; // 1024-100;
|
||||
int32 ay = ly2; // 768/2;
|
||||
int32 v = 15;
|
||||
int32 dx, dy, adx1, ady1, adx2, ady2;
|
||||
int32 cx1 = 9;
|
||||
int32 cy1 = 9;
|
||||
int32 colmod;
|
||||
|
||||
|
||||
|
||||
int32 noiralx1 = 1024/2-8*2;
|
||||
int32 noiraly1 = 768/2-15/2;
|
||||
int32 noirlx1 = noiralx1;
|
||||
int32 noirly1 = noiraly1;
|
||||
int32 noirlx2 = noirlx1;
|
||||
int32 noirly2 = noirly1;
|
||||
|
||||
uint32 noiri, noircompteur = 0, noirprecompteur = 0, noircompteur2 = 0;
|
||||
int32 noirangle=0;
|
||||
int32 noirdangle=3;
|
||||
int32 noirddangle=0;
|
||||
int32 noirx1 = 100;
|
||||
int32 noiry1 = 768/2;
|
||||
int32 noirx2 = noirx1;
|
||||
int32 noiry2 = noiry1;
|
||||
int32 noirax = noirlx2; // 1024-100;
|
||||
int32 noiray = noirly2; // 768/2;
|
||||
int32 noirv = 15;
|
||||
int32 noirdx, noirdy, noiradx1, noirady1, noiradx2, noirady2;
|
||||
int32 noircx1 = 9;
|
||||
int32 noircy1 = 9;
|
||||
|
||||
while (TRUE) {
|
||||
// demoAffiche(lx2, ly2);
|
||||
compteur2++;
|
||||
compteur = compteur2 / 4;
|
||||
|
||||
// if (compteur2 % 4 == 0)
|
||||
// asm volatile ("hlt");
|
||||
// else
|
||||
{ int t; for (t = 0; t < 1000000; t++) asm volatile ("nop"); }
|
||||
|
||||
// lx2 += sign(alx1-lx2);
|
||||
// ly2 += sign(aly1-ly2);
|
||||
lx2 = alx1;
|
||||
ly2 = aly1;
|
||||
|
||||
rectanglePlein (lx1 - 1, ly1 - 2, lx1+(4*8) + 2, ly1+15 + 1, 0);
|
||||
demoAffiche(lx2, ly2);
|
||||
|
||||
lx1 = lx2;
|
||||
ly1 = ly2;
|
||||
|
||||
alx1 = (1024 - 96)/2 + 32 + (1024 - 64) * sinRapide(compteur2 * (2<<7) ) / (2<<15);
|
||||
aly1 = (768 - 80)/2 + 32 + (768 - 48) * cosRapide(compteur2 * (2<<4)*3) / (2<<15);
|
||||
|
||||
|
||||
for (i = 0; i < 2000; i += dx*dx + dy*dy) {
|
||||
ax = alx1;
|
||||
ay = aly1;
|
||||
|
||||
adx1 = v * cosRapide(angle) / (2<<15);
|
||||
ady1 = v * sinRapide(angle) / (2<<15);
|
||||
|
||||
adx2 = (ax-x2) / 100;
|
||||
ady2 = (ay-y2) / 100;
|
||||
|
||||
dx = (cx1*adx1 + (10-cx1)*adx2) / 10;
|
||||
dy = (cy1*ady1 + (10-cy1)*ady2) / 10;
|
||||
|
||||
x2 += dx;
|
||||
y2 += dy;
|
||||
|
||||
dangle += abs(ddangle - 4) - 2;
|
||||
// dangle++;
|
||||
angle += dangle*16;
|
||||
|
||||
colmod = 0xcc / 2 + (0xcc * sinRapide(compteur * (2<<4)*15) / (2<<15));
|
||||
if ((x1 > 0) && (x1 < 1024) &&
|
||||
(x2 > 0) && (x2 < 1024) &&
|
||||
(y1 > 0) && (y1 < 768) &&
|
||||
(y2 > 0) && (y2 < 768))
|
||||
ligne(x1,y1,x2,y2,0x00ff0000 | (colmod << 8) | colmod);
|
||||
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
}
|
||||
if (compteur2 % 4 == 0)
|
||||
ddangle = (ddangle + 1) % 8;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (noirprecompteur <= 15) {
|
||||
noirprecompteur++;
|
||||
} else {
|
||||
|
||||
noircompteur2++;
|
||||
noircompteur = noircompteur2 / 4;
|
||||
|
||||
// noirlx2 += sign(noiralx1-noirlx2);
|
||||
// noirly2 += sign(noiraly1-noirly2);
|
||||
noirlx2 = noiralx1;
|
||||
noirly2 = noiraly1;
|
||||
|
||||
//// rectanglePlein (noirlx1 - 1, noirly1 - 2, noirlx1+(4*8) + 2, noirly1+15 + 1, 0);
|
||||
//// demoAffiche(noirlx2, noirly2);
|
||||
|
||||
noirlx1 = noirlx2;
|
||||
noirly1 = noirly2;
|
||||
|
||||
noiralx1 = (1024 - 96)/2 + 32 + (1024 - 64) * sinRapide(noircompteur2 * (2<<7) ) / (2<<15);
|
||||
noiraly1 = (768 - 80)/2 + 32 + (768 - 48) * cosRapide(noircompteur2 * (2<<4)*3) / (2<<15);
|
||||
|
||||
|
||||
for (noiri = 0; noiri < 2000; noiri += noirdx*noirdx + noirdy*noirdy) {
|
||||
noirax = noiralx1;
|
||||
noiray = noiraly1;
|
||||
|
||||
noiradx1 = noirv * cosRapide(noirangle) / (2<<15);
|
||||
noirady1 = noirv * sinRapide(noirangle) / (2<<15);
|
||||
|
||||
noiradx2 = (noirax-noirx2) / 100;
|
||||
noirady2 = (noiray-noiry2) / 100;
|
||||
|
||||
noirdx = (noircx1*noiradx1 + (10-noircx1)*noiradx2) / 10;
|
||||
noirdy = (noircy1*noirady1 + (10-noircy1)*noirady2) / 10;
|
||||
|
||||
noirx2 += noirdx;
|
||||
noiry2 += noirdy;
|
||||
|
||||
noirdangle += abs(noirddangle - 4) - 2;
|
||||
// dangle++;
|
||||
noirangle += noirdangle*16;
|
||||
|
||||
if ((noirx1 > 0) && (noirx1 < 1024) &&
|
||||
(noirx2 > 0) && (noirx2 < 1024) &&
|
||||
(noiry1 > 0) && (noiry1 < 768) &&
|
||||
(noiry2 > 0) && (noiry2 < 768))
|
||||
ligne(noirx1,noiry1,noirx2,noiry2,0);
|
||||
|
||||
noirx1 = noirx2;
|
||||
noiry1 = noiry2;
|
||||
}
|
||||
if (noircompteur2 % 4 == 0)
|
||||
noirddangle = (noirddangle + 1) % 8;
|
||||
|
||||
} // if noirprecompteur <= 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void demoNombres() {
|
||||
int i;
|
||||
for (i = 0; i <= 10; i++) {
|
||||
afficherEntierEnDecimal(i);
|
||||
afficherChaineZ(" ");
|
||||
}
|
||||
afficherChaineZ("\n");
|
||||
}
|
||||
|
||||
|
||||
void initDemo(void** etat) {
|
||||
*etat = NULL;
|
||||
}
|
||||
|
||||
void deinitDemo(void** etat) {
|
||||
*etat = NULL;
|
||||
}
|
BIN
src/modules/interfaceUtilisateur/police/8x15/,.png
Normal file
After Width: | Height: | Size: 98 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/..png
Normal file
After Width: | Height: | Size: 96 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/0.png
Normal file
After Width: | Height: | Size: 113 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/1.png
Normal file
After Width: | Height: | Size: 105 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/2.png
Normal file
After Width: | Height: | Size: 119 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/3.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/4.png
Normal file
After Width: | Height: | Size: 110 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/5.png
Normal file
After Width: | Height: | Size: 115 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/6.png
Normal file
After Width: | Height: | Size: 118 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/7.png
Normal file
After Width: | Height: | Size: 110 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/8.png
Normal file
After Width: | Height: | Size: 108 B |
256
src/modules/interfaceUtilisateur/police/8x15/8x15.fnt
Normal file
|
@ -0,0 +1,256 @@
|
|||
0 curseur.png
|
||||
1 espace.png
|
||||
2 espace.png
|
||||
3 espace.png
|
||||
4 espace.png
|
||||
5 espace.png
|
||||
6 espace.png
|
||||
7 espace.png
|
||||
8 espace.png
|
||||
9 espace.png
|
||||
10 espace.png
|
||||
11 espace.png
|
||||
12 espace.png
|
||||
13 espace.png
|
||||
14 espace.png
|
||||
15 espace.png
|
||||
16 espace.png
|
||||
17 espace.png
|
||||
18 espace.png
|
||||
19 espace.png
|
||||
20 espace.png
|
||||
21 espace.png
|
||||
22 espace.png
|
||||
23 espace.png
|
||||
24 espace.png
|
||||
25 espace.png
|
||||
26 espace.png
|
||||
27 espace.png
|
||||
28 espace.png
|
||||
29 espace.png
|
||||
30 espace.png
|
||||
31 espace.png
|
||||
32 espace.png
|
||||
33 espace.png
|
||||
34 espace.png
|
||||
35 espace.png
|
||||
36 espace.png
|
||||
37 espace.png
|
||||
38 espace.png
|
||||
39 espace.png
|
||||
40 ,.png
|
||||
41 espace.png
|
||||
42 espace.png
|
||||
43 espace.png
|
||||
44 espace.png
|
||||
45 espace.png
|
||||
46 ..png
|
||||
47 espace.png
|
||||
48 0.png
|
||||
49 1.png
|
||||
50 2.png
|
||||
51 3.png
|
||||
52 4.png
|
||||
53 5.png
|
||||
54 6.png
|
||||
55 7.png
|
||||
56 8.png
|
||||
57 9.png
|
||||
58 espace.png
|
||||
59 espace.png
|
||||
60 espace.png
|
||||
61 espace.png
|
||||
62 espace.png
|
||||
63 espace.png
|
||||
64 espace.png
|
||||
65 A.png
|
||||
66 B.png
|
||||
67 C.png
|
||||
68 D.png
|
||||
69 E.png
|
||||
70 F.png
|
||||
71 G.png
|
||||
72 H.png
|
||||
73 I.png
|
||||
74 J.png
|
||||
75 K.png
|
||||
76 L.png
|
||||
77 M.png
|
||||
78 N.png
|
||||
79 O.png
|
||||
80 P.png
|
||||
81 Q.png
|
||||
82 R.png
|
||||
83 S.png
|
||||
84 T.png
|
||||
85 U.png
|
||||
86 V.png
|
||||
87 W.png
|
||||
88 X.png
|
||||
89 Y.png
|
||||
90 Z.png
|
||||
91 espace.png
|
||||
92 espace.png
|
||||
93 espace.png
|
||||
94 espace.png
|
||||
95 espace.png
|
||||
96 espace.png
|
||||
97 a.png
|
||||
98 b.png
|
||||
99 c.png
|
||||
100 d.png
|
||||
101 e.png
|
||||
102 f.png
|
||||
103 g.png
|
||||
104 h.png
|
||||
105 i.png
|
||||
106 j.png
|
||||
107 k.png
|
||||
108 l.png
|
||||
109 m.png
|
||||
110 n.png
|
||||
111 o.png
|
||||
112 p.png
|
||||
113 q.png
|
||||
114 r.png
|
||||
115 s.png
|
||||
116 t.png
|
||||
117 u.png
|
||||
118 v.png
|
||||
119 w.png
|
||||
120 x.png
|
||||
121 y.png
|
||||
122 z.png
|
||||
123 espace.png
|
||||
124 espace.png
|
||||
125 espace.png
|
||||
126 espace.png
|
||||
127 espace.png
|
||||
128 espace.png
|
||||
129 espace.png
|
||||
130 espace.png
|
||||
131 espace.png
|
||||
132 espace.png
|
||||
133 espace.png
|
||||
134 espace.png
|
||||
135 espace.png
|
||||
136 espace.png
|
||||
137 espace.png
|
||||
138 espace.png
|
||||
139 espace.png
|
||||
140 espace.png
|
||||
141 espace.png
|
||||
142 espace.png
|
||||
143 espace.png
|
||||
144 espace.png
|
||||
145 espace.png
|
||||
146 espace.png
|
||||
147 espace.png
|
||||
148 espace.png
|
||||
149 espace.png
|
||||
150 espace.png
|
||||
151 espace.png
|
||||
152 espace.png
|
||||
153 espace.png
|
||||
154 espace.png
|
||||
155 espace.png
|
||||
156 espace.png
|
||||
157 espace.png
|
||||
158 espace.png
|
||||
159 espace.png
|
||||
160 espace.png
|
||||
161 espace.png
|
||||
162 espace.png
|
||||
163 espace.png
|
||||
164 espace.png
|
||||
165 espace.png
|
||||
166 espace.png
|
||||
167 espace.png
|
||||
168 espace.png
|
||||
169 espace.png
|
||||
170 espace.png
|
||||
171 espace.png
|
||||
172 espace.png
|
||||
173 espace.png
|
||||
174 espace.png
|
||||
175 espace.png
|
||||
176 espace.png
|
||||
177 espace.png
|
||||
178 espace.png
|
||||
179 espace.png
|
||||
180 espace.png
|
||||
181 espace.png
|
||||
182 espace.png
|
||||
183 espace.png
|
||||
184 espace.png
|
||||
185 espace.png
|
||||
186 espace.png
|
||||
187 espace.png
|
||||
188 espace.png
|
||||
189 espace.png
|
||||
190 espace.png
|
||||
191 espace.png
|
||||
192 espace.png
|
||||
193 espace.png
|
||||
194 espace.png
|
||||
195 espace.png
|
||||
196 espace.png
|
||||
197 espace.png
|
||||
198 espace.png
|
||||
199 espace.png
|
||||
200 espace.png
|
||||
201 espace.png
|
||||
202 espace.png
|
||||
203 espace.png
|
||||
204 espace.png
|
||||
205 espace.png
|
||||
206 espace.png
|
||||
207 espace.png
|
||||
208 espace.png
|
||||
209 espace.png
|
||||
210 espace.png
|
||||
211 espace.png
|
||||
212 espace.png
|
||||
213 espace.png
|
||||
214 espace.png
|
||||
215 espace.png
|
||||
216 espace.png
|
||||
217 espace.png
|
||||
218 espace.png
|
||||
219 espace.png
|
||||
220 espace.png
|
||||
221 espace.png
|
||||
222 espace.png
|
||||
223 espace.png
|
||||
224 espace.png
|
||||
225 espace.png
|
||||
226 espace.png
|
||||
227 espace.png
|
||||
228 espace.png
|
||||
229 espace.png
|
||||
230 espace.png
|
||||
231 espace.png
|
||||
232 espace.png
|
||||
233 espace.png
|
||||
234 espace.png
|
||||
235 espace.png
|
||||
236 espace.png
|
||||
237 espace.png
|
||||
238 espace.png
|
||||
239 espace.png
|
||||
240 espace.png
|
||||
241 espace.png
|
||||
242 espace.png
|
||||
243 espace.png
|
||||
244 espace.png
|
||||
245 espace.png
|
||||
246 espace.png
|
||||
247 espace.png
|
||||
248 espace.png
|
||||
249 espace.png
|
||||
250 espace.png
|
||||
251 espace.png
|
||||
252 espace.png
|
||||
253 espace.png
|
||||
254 espace.png
|
||||
255 espace.png
|
BIN
src/modules/interfaceUtilisateur/police/8x15/9.png
Normal file
After Width: | Height: | Size: 116 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/A.png
Normal file
After Width: | Height: | Size: 108 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/B.png
Normal file
After Width: | Height: | Size: 113 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/C.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/D.png
Normal file
After Width: | Height: | Size: 113 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/E.png
Normal file
After Width: | Height: | Size: 109 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/F.png
Normal file
After Width: | Height: | Size: 106 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/G.png
Normal file
After Width: | Height: | Size: 117 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/H.png
Normal file
After Width: | Height: | Size: 101 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/I.png
Normal file
After Width: | Height: | Size: 104 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/J.png
Normal file
After Width: | Height: | Size: 107 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/K.png
Normal file
After Width: | Height: | Size: 116 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/L.png
Normal file
After Width: | Height: | Size: 98 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/M.png
Normal file
After Width: | Height: | Size: 109 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/N.png
Normal file
After Width: | Height: | Size: 109 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/O.png
Normal file
After Width: | Height: | Size: 107 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/P.png
Normal file
After Width: | Height: | Size: 108 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/Q.png
Normal file
After Width: | Height: | Size: 110 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/R.png
Normal file
After Width: | Height: | Size: 112 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/S.png
Normal file
After Width: | Height: | Size: 117 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/T.png
Normal file
After Width: | Height: | Size: 102 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/U.png
Normal file
After Width: | Height: | Size: 101 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/V.png
Normal file
After Width: | Height: | Size: 105 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/W.png
Normal file
After Width: | Height: | Size: 103 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/X.png
Normal file
After Width: | Height: | Size: 109 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/Y.png
Normal file
After Width: | Height: | Size: 103 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/Z.png
Normal file
After Width: | Height: | Size: 112 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/a.png
Normal file
After Width: | Height: | Size: 113 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/b.png
Normal file
After Width: | Height: | Size: 110 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/c.png
Normal file
After Width: | Height: | Size: 107 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/curseur.png
Normal file
After Width: | Height: | Size: 121 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/d.png
Normal file
After Width: | Height: | Size: 109 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/e.png
Normal file
After Width: | Height: | Size: 110 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/espace.png
Normal file
After Width: | Height: | Size: 90 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/f.png
Normal file
After Width: | Height: | Size: 108 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/g.png
Normal file
After Width: | Height: | Size: 108 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/h.png
Normal file
After Width: | Height: | Size: 104 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/i.png
Normal file
After Width: | Height: | Size: 100 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/j.png
Normal file
After Width: | Height: | Size: 101 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/k.png
Normal file
After Width: | Height: | Size: 109 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/l.png
Normal file
After Width: | Height: | Size: 97 B |
BIN
src/modules/interfaceUtilisateur/police/8x15/m.png
Normal file
After Width: | Height: | Size: 99 B |