Compare commits

..

140 Commits

Author SHA1 Message Date
Nicolas Hordé 5fac391db3 build: correction d'erreur diverses... 2020-09-19 22:28:34 +02:00
Nicolas Hordé 4cf187aabd build: autocompilation avec choix des révisions et configuration de la compilation 2020-09-19 20:40:15 +02:00
Nicolas H 9fb0a7de6d docs: correction d'une erreur dans l'aide README.md 2020-09-18 21:51:42 +02:00
Nicolas H 3097e1ace5 build: mise en place d'un menu de compilation et mise à jour de l'aide 2020-09-18 21:47:25 +02:00
Nicolas Hordé 7e0ffc5f91 build: changement des makefiles pour utilisation de Docker pour la compilation 2020-09-17 16:37:10 +02:00
Nicolas Hordé 349451ba33 build: Correction des makefiles et ajout du disque dur UEFI 2020-09-16 22:32:13 +02:00
Nicolas Hordé 4f7aae792e feat: premier boot opérationnel avec la commande linux16 de GRUB, reste la gestion VESA 2019-01-19 00:17:35 +01:00
Nicolas Hordé 63f7e530cc feat: chargement pmode complet jusqu'à lancement du code pour la décompression 2019-01-15 01:15:58 +01:00
Nicolas Hordé b565d073c7 fix: execution du setup en mode reel fonctionnel, erreur sur A20 2019-01-14 14:54:50 +01:00
Nicolas Hordé d3abee6a74 fix: correction génération code 16bits en C 2019-01-14 11:18:57 +01:00
Nicolas Hordé 0c6b0635ab test: finalisation d'un déboguer efficace 2019-01-12 20:46:00 +01:00
Nicolas Hordé a00965b7a3 docs: ajout d'informations...ERRATA 2019-01-12 01:44:23 +01:00
Nicolas Hordé 705f92ce70 docs: ajout d'informations... 2019-01-12 01:39:05 +01:00
Nicolas Hordé 56a7665e69 test: changement de deboggeur pour GDB+Dashboard modifié 2019-01-11 14:25:48 +01:00
Nicolas Hordé 9da86c9057 feat: première compilation de noyau composite sans l'intégration de la décompression du noyau 2019-01-02 15:47:56 +01:00
Nicolas Hordé e30592d7d4 feat: ajout des informations de déboguage séparée pour les différentes parties du noyau (compressées ou non, mode réel ou non) 2019-01-02 13:59:16 +01:00
Nicolas Hordé fda7fdc711 feat: creation du piggy.o 2019-01-01 19:31:26 +01:00
Nicolas Hordé edaae1d4c2 fix: correction assembler system.S 2019-01-01 13:37:29 +01:00
Nicolas Hordé 32af566aec feat: ajout de mkpiggy du noyau Linux et mise en place d'un noyau composite basé sur Linux 2019-01-01 13:30:06 +01:00
Nicolas Hordé 21bc3d2e3d feat: ajout de code en realmode pour initialisation du pmode et préparation du chargement du noyau 2018-12-30 12:25:20 +01:00
Nicolas Hordé 620f63d101 feat: bascule vers le format de noyau linux afin de bénéficier des outils de chargement qui vont bien 2018-12-27 14:24:47 +01:00
Nicolas Hordé e3d708850d fix: correction du scheduling 2018-12-26 00:54:19 +01:00
Nicolas Hordé 75a8602c5b fix: correction PS pour avoir TOUTES les tâches 2018-12-25 19:39:40 +01:00
Nicolas Hordé c894b99170 fix: pS permettant de visualiser l'ensemble de tâches et processus, corrections asm.h 2018-12-25 19:22:56 +01:00
Nicolas Hordé 6776594ece fix: mise en place d'une commande PS, correction de bogues 2018-12-22 00:19:34 +01:00
Nicolas Hordé 945bca37b5 feat: ajout d'une interruption 20 qui permet de faire un DUMP du cpu sur l'écran 2018-12-20 17:16:51 +01:00
Nicolas Hordé eff52c8853 feat: scheduling opérationnel mais subsiste des bogues inconnus 2018-12-20 16:29:04 +01:00
Nicolas Hordé 74b0b4e2e9 fix: corrections...erreur lors du switch vers la tache de tid 1.1 dans restcpu_kernel 2018-12-19 23:31:13 +01:00
Nicolas Hordé 11428c2415 feat: wrapper pour interruptions et pour l'IRQ0 (Scheduler+Timer) et début d'implémentation du scheduling 2018-12-19 16:13:47 +01:00
Nicolas Hordé dd3e40d53e feat: gestion des processus & tâches, compilation ok mais système figé au démarrage 2018-12-19 12:06:05 +01:00
Nicolas Hordé d2f28e6795 feat: reprise de la gestion des tache / processus et ajout du multithreading, ne compile pas 2018-12-19 07:34:44 +01:00
Nicolas Hordé 0af99c069b feat: ajout de wrappers pour SYSENTER et pour toutes les exceptions. Génération automatique des API par métadonnées dans le source. 2018-12-16 01:50:03 +01:00
Nicolas Hordé 3c3f0bb88e feat: suppression de NASM en tant qu'assembleur et utilisateur de GAS, bascule des handlers sur un nouveau fichier et modification progressive des interruptions/exceptions 2018-12-15 19:13:26 +01:00
Nicolas Hordé ddfba60973 feat: génération semi-automatique des SYSCALL pour le RING3 à partir d'un script python, encore instable 2018-12-14 01:06:37 +01:00
Nicolas Hordé deea5829d3 fix: correction du bogue de memoire dans process.c allocation des processes 2018-12-12 18:49:21 +01:00
Nicolas Hordé 81e7dcaa50 feat: première tâche en mode user totalement fonctionnelle avec préemption par sysenter/sysexit, pas de libération des ressources. Ajout de 2 fonctions API utilisateur 2018-12-12 17:57:23 +01:00
Nicolas Hordé 3c7ddafc2d refactor: ajout d'information dans les fichiers MD, réindentation des fichiers, corrections de bogues 2018-12-12 15:25:04 +01:00
Nicolas Hordé 89ac2cc30f build: correction erreur makefile manquant dans final 2018-12-12 13:47:08 +01:00
Nicolas Hordé c0b832ceed build: correction erreur makefile 2018-12-12 12:37:19 +01:00
Nicolas Hordé 6cdfbcdd28 build: mise à jour des makefile pour indent correct et permissions/format harmonisé 2018-12-12 12:31:30 +01:00
Nicolas Hordé 524af1729c feat: avancement de la création de tâche/processus 2018-12-12 10:14:31 +01:00
Nicolas Hordé 69fa9567a1 feat: fonction task_switch & task_run passe en mode utilisateur RING0 mais plantage lors de l'execution 2018-12-12 00:15:36 +01:00
Nicolas Hordé dd70f75ab8 feat: reprise des fonctions de sauvegarde des registres pour task_switch 2018-12-11 17:00:19 +01:00
Nicolas Hordé 12aacb33f1 fix: correction de la fonction createdump 2018-12-10 19:16:52 +01:00
Nicolas Hordé 44d5634532 fix: préparation au basculement de tâche par la pile fonction task_switch, correction à apporter dans la gestion de la mémoire 2018-12-10 19:12:20 +01:00
Nicolas Hordé a31cf264c3 feat: compilation du noyau en code non relocalisable, commande task_create quasi terminée. Allocation dynamique de page pour les programmes utilisateurs dans exception14 (PGFAULT) 2018-12-10 17:03:52 +01:00
Nicolas Hordé f0f36a0f5c docs: preparation de la compilation de programmes en USER MODE (ring 3), ajout documentation API et librairies 2018-12-09 13:44:32 +01:00
Nicolas Hordé ac537030a3 feat: gestion des tâches, compilation ok, mise en place d'un test par le pseudo-interpréteur, commande : testtask 2018-12-09 11:11:39 +01:00
Nicolas Hordé 11071e5bbd feat: ajout de process.h/c pour la gestion de la création de tâche/processus, non compilable 2018-12-09 00:40:25 +01:00
Nicolas Hordé 8d3da6480a feat: test de syscall, implémentation sous forme de macro et handler opérationnel 2018-12-05 16:42:25 +01:00
Nicolas Hordé 3129b5edcc fix: passage de Frame-omit-pointer à Stack Frame avec EBP, corrections multiple : exceptions ok et deboguage opérationnel 2018-12-05 14:00:43 +01:00
Nicolas Hordé 9041832823 feat: test sans --fomit-frame-pointer, travail sur sysexit 2018-12-04 21:57:44 +01:00
Nicolas Hordé e87aedb02e feat: debut implémentation de sysenter / sysexit et test depuis shell.c 2018-12-04 00:05:55 +01:00
Nicolas Hordé 4ce5c7333c fix: correction fonction bestdriver dans video.c 2018-12-03 23:16:04 +01:00
Nicolas Hordé b8e26a000b fix: correction Xprintf avec %% BIS et augmentation du test avec 150mo de RAM 2018-11-30 19:19:52 +01:00
Nicolas Hordé 73c70d20bd fix: correction gestion mémoire virtuelle & malloc, fonction testmem opérationnelle. Correction Xprintf avec %% 2018-11-30 19:06:22 +01:00
Nicolas Hordé b6e2ead659 fix: correction HEAP de page et ajout d'information concernant les pages et la mémoire utilisée 2018-11-30 11:27:45 +01:00
Nicolas Hordé 4f92e419e2 feat: ajout d'une commande MEM et de plusieurs fonctions donnant des indications sur la mémoire 2018-11-29 21:23:41 +01:00
Nicolas Hordé 4a6b7542fc docs: mise à jour du README.md bis 2018-11-29 17:09:59 +01:00
Nicolas Hordé 5d22ec2d48 docs: mise à jour du README.md 2018-11-29 17:07:08 +01:00
Nicolas Hordé ed4e577086 fix: suppression de la gestion de la disquette, ajout du déboguage avec Bochs, correction initialisation du FPU au démarrage, changement de modèle 3D 2018-11-29 16:45:40 +01:00
Nicolas Hordé 6fa1bd6c2e fix: remapping en mode paginé du Framebuffer dans l'espace noyau, correction diverses malloc...etc 2018-11-29 13:42:07 +01:00
Nicolas Hordé f399a6bf5c feat: compilation réussi des fonctions de pagination, manque FB VESA non paginé 2018-11-27 16:56:21 +01:00
Nicolas Hordé b6f238ff8a feat: gestion mémoire paginée, ajout de nouvelles fonctions 2018-11-25 23:34:38 +01:00
Nicolas Hordé f0a64729ee feat: mémoire paginée... 2018-11-23 09:00:59 +01:00
Nicolas Hordé 6acbddab8d feat: brouillon de gestion de mémoire paginée avec usage de TAILQ de Freebsd, ne fonctionne pas...@ suivre 2018-11-22 17:21:15 +01:00
Nicolas Hordé f04bb66ec8 fix: correction sur la réservation/liberation de mémoire physique (bitmap), limitation à 4Go de RAM en 32 bits 2018-11-21 17:25:00 +01:00
Nicolas Hordé c91c2a1e45 feat: ajout d'un bitmap pour la gestion fine de la mémoire physique libre 2018-11-16 15:57:34 +01:00
Nicolas Hordé 1a28e6ce45 fix: correction du disque UEFI pour test 2018-11-15 15:14:22 +01:00
Nicolas Hordé 812e3c0bed feat: ajustement des fonctions multiboot 2018-11-14 22:23:10 +01:00
Nicolas Hordé 8b2fa6ae68 feat: ajout des class/subclass PCI dans la detection 2018-11-12 09:49:00 +01:00
Nicolas Hordé 852509789d fix: correction detection pci 2018-11-09 16:44:56 +01:00
Nicolas Hordé 42f87229ad fix: ajout detection PCI & correction video.c : fonction line & hline 2018-11-08 22:12:51 +01:00
Nicolas Hordé 35ae3559db feat: ajout 3d fil de fer et fonction show3dmodel, cube utilise model3d 2018-11-01 19:19:29 +01:00
Nicolas Hordé c773880c2e feat: fonction load3ds terminée pour chargement d'un modèle 3D sans texture, à tester 2018-11-01 01:12:30 +01:00
Nicolas Hordé 5f526bf2b7 feat: ajout fichier 3DS, et debut écriture fonction de chargement fichier 3DS 2018-10-30 19:21:18 +01:00
Nicolas Hordé c4e4462313 feat: commentaires dans matrix, réarrangement de 2d.c dans video.c & création de 3d.c : première version cube en point dans test3d 2018-10-26 14:09:43 +02:00
Nicolas Hordé f705b5fe3d fix: correction affichage video et ajout des fonctions matricielles, trigonométriques et mathématiques diverses 2018-10-19 10:13:29 +02:00
Nicolas Hordé ac0bf016eb fix: correction bogues algorithme trianglefilled - hline 2018-10-17 14:09:01 +02:00
Nicolas Hordé f4b3ea6c10 fix: correction couleurs vers 32 bits maximum, mise en place du deboguage pas a pas. 2018-10-16 21:56:39 +02:00
Nicolas Hordé d0d125bbf8 feat: changement de police a chaud en mode graphique et commande shell, reste à implementer le mode texte 2018-10-14 19:14:19 +02:00
Nicolas Hordé 660ce13fdf fix: correction emulation police erreur attribut 2018-10-14 17:11:15 +02:00
Nicolas Hordé 09e4ebbb38 fix: correction conversion EGA->RGB et decodage caractère...Reste bogue 2018-10-14 16:18:51 +02:00
Nicolas Hordé ba7361eae6 feat: adaptation du logo qui est rendu sous forme de string modifiable, affichage correct en VESA 1024x768x32 2018-10-14 12:50:32 +02:00
Nicolas Hordé 8863c798fc fix: correction couleur EGA->VGA->RGB et erreur pilote VESA 2018-10-14 11:14:34 +02:00
Nicolas Hordé 03aa538dc9 fix: framebuffer ok sans UEFI, debogue simplifié 2018-10-14 09:58:34 +02:00
Nicolas Hordé c179f61bff feat: mode vesa balbutiant, mauvaise gestion RGB ajout de modules dans GRUB non uefi 2018-10-13 17:17:40 +02:00
Nicolas Hordé 26faaf8713 feat: preparation du pilote VESA 2018-10-13 13:42:13 +02:00
Nicolas Hordé aac62edd51 feat: mode 320x200 chained fonctionnel 2018-10-13 13:23:00 +02:00
Nicolas Hordé 605953aa3b feat: pilote remanié VGA ok en mode texte 2018-10-13 11:25:55 +02:00
Nicolas Hordé 016b972d97 fix: gestion pilotes video, implantation mode texte, correction scrolling 2018-10-13 05:35:08 +02:00
Nicolas Hordé 1e77ba8c3f feat: gestion pilotes video, compilation ok, reste à implanter fonctions essentielles 2018-10-12 22:31:34 +02:00
Nicolas Hordé 86c4e4550e feat: ajout d'une gestion de pilotes video dans la projection de faire un pilote VBE/VESA 2018-10-12 20:37:26 +02:00
Nicolas Hordé 5683c69311 feat: dumpcpu inline & test concluant err 1 2018-10-10 08:06:39 +02:00
Nicolas Hordé 109738dca3 fix: ajout de fonction de debogueuage et exception 1 2018-10-09 18:13:04 +02:00
Nicolas Hordé bb21e15dc4 feat: ajout de fonction v/s/printf et ajout de fonction de deboguage (desassemblage) 2018-10-08 21:50:40 +02:00
Nicolas Hordé 946355b687 feat: ajout d'une commande view qui permet de voir la mémoire, à rajouter visu ASCII + taille 2018-10-07 14:53:48 +02:00
Nicolas Hordé 5315bb549f fix: gestion de ligne de commande pour le shell, centralisation des erreurs dans une fonction ERR 2018-10-07 14:17:37 +02:00
Nicolas Hordé 02948e1f0f fix: test de sprint dans exception 14, et correction fin de string 2018-10-07 13:11:16 +02:00
Nicolas Hordé 12f395461e fix: ajout d'une fonction sprintf, corrections diverses fonction utilisant printf 2018-10-07 12:57:38 +02:00
Nicolas Hordé c36e8afd62 feat: gestion des exposant et notation scientifique dans printf arg %e et %f 2018-10-05 22:56:58 +02:00
Nicolas Hordé a3d718e69e fix: correction erreur nombres petits...reste gestion des exposants 2018-10-05 09:50:39 +02:00
Nicolas Hordé 9b421fd7cc fix: ajout affichage des Float & Double dans printf, correction makefile et autre... 2018-10-04 21:49:06 +02:00
Nicolas Hordé b72b0c2f11 feat: test des breakpoint par DRx 2018-10-04 16:29:54 +02:00
Nicolas Hordé f07f637447 fix: gestion des erreurs améliorée avec dump de tout les registres, interruption remaniées et fonctions GDT et IDT idem 2018-10-04 14:55:41 +02:00
Nicolas Hordé 72abe00043 feat: gestion d'exception avancé avec dump des registres 2018-10-03 22:50:54 +02:00
Nicolas Hordé baf52f0594 fix: ajout gestion erreur Pagefault plus fin + mécanisme pile exception 2018-10-02 17:16:23 +02:00
Nicolas Hordé 28c831870e fix: reprise du shell après erreur fatale, test avec commande pagefault 2018-10-02 13:49:10 +02:00
Nicolas Hordé 62bd72dfe0 feat: description GDT++, ajout pagination 4k/4m 2018-10-02 02:16:14 +02:00
Nicolas Hordé e137749be8 refactor: information LGPL3 et nom de l'auteur dans les sources, reformatage 2018-09-28 20:35:51 +02:00
Nicolas Hordé 3447694319 docs: correction README.md bis 2018-09-28 19:22:17 +02:00
Nicolas Hordé c8d925b324 docs: correction README.md, images 2018-09-28 17:22:32 +02:00
Nicolas Hordé 60bf48343f fix: ajout de fonctionnalité sur printf (64bits) et corrections 2018-09-28 00:03:45 +02:00
Nicolas Hordé 4a4886886e feat: creation d'une commande multiboot et ajout gestion arithematique sur 64 bits, amelioration de printf 2018-09-27 21:01:02 +02:00
Nicolas Hordé cd9129dc15 style: reindent et correction des makefiles 2018-09-27 17:47:27 +02:00
Nicolas Hordé 25c2ec0fbf fix: correction pour démarrage sans GRUB/multiboot 2018-09-27 17:32:25 +02:00
Nicolas Hordé 31b139ab01 feat: multiboot2 géré à partir d'une routine asm 2018-09-27 17:12:12 +02:00
Nicolas Hordé 48778a7ef6 fix: boot sur disque dur par GRUB en multiboot2 64 bits UEFI - correction multiboot2 à faire sur system.sys 2018-09-27 11:13:27 +02:00
Nicolas Hordé 47e779ea1a feat: boot sur disque dur par GRUB en multiboot2 2018-09-27 07:55:24 +02:00
Nicolas Hordé 87956a41a3 feat: gestion TSS/TSR en cours 2018-09-18 15:11:50 +02:00
Nicolas Hordé a12ddfa03b feat: ajout GDT user, CPUID ajouts, noyaux 0x100000, syscall par sysenter préparation 2018-09-18 14:29:35 +02:00
Nicolas Hordé 93897a6cce feat: structure command et ajout d'un fichier shell.c 2018-09-17 18:17:11 +02:00
Nicolas Hordé c3a153b091 fix: correction keyboard.c 2018-09-17 13:18:05 +02:00
Nicolas Hordé 8e9987ba8a fix: correction initialisation GDT 2018-09-17 13:14:27 +02:00
Nicolas Hordé b1abb2f5a2 feat: gestion chargement d'une nouvelle GDT - non fonctionnel 2018-09-01 22:58:05 +02:00
Nicolas Hordé debba65eba fix: correction de dump_regs 2018-09-01 15:11:54 +02:00
Nicolas Hordé aace138efe feat: gestion GDT + affichage GDT+IDT 2018-08-31 02:48:03 +02:00
Nicolas Hordé 0c8419c91b feat: debogage de printf et modification de dump_regs 2018-08-30 01:07:28 +02:00
Nicolas Hordé ca1f1c18a8 feat: modification de la fonction printf 2018-08-29 10:12:00 +02:00
Nicolas Hordé e3c09a2191 feat: menage dans fichiers inutiles 2018-08-28 15:22:43 +02:00
Nicolas Hordé 647050d22e fix: correction de la fonction trianglefill 2018-08-22 20:43:21 +02:00
Nicolas Hordé 36185af660 fix: debogue de la fonction trianglefill 2018-08-22 18:39:06 +02:00
Nicolas Hordé c76554dd4a feat: ajout fonctions graphiques 2D + math + tick dans le timer 2018-08-22 17:36:30 +02:00
Nicolas Hordé 2ce9d70b48 feat: ajout interpréteur de commande & fonctions clavier essentielles 2018-08-21 08:26:35 +02:00
Nicolas Hordé aeeb371294 fix: correction des interruptions par défaut 2018-08-20 16:35:36 +02:00
Nicolas Hordé b4ba872397 feat: ajout de fonctions dans la librairie string - entiers & listes 2018-08-18 18:37:18 +02:00
Nicolas Hordé 539eeb1d8f feat: ajout de fonctions dans la librairie string 2018-08-17 22:32:09 +02:00
Nicolas Hordé 49a4bd4640 feat: ajout de fonctions dans la librairie string 2018-08-17 18:10:20 +02:00
Nicolas Hordé 56da8273e8 feat: revision des fichiers, ajouts commentaires, ménage & indentation 2018-08-17 16:46:56 +02:00
Nicolas Hordé 3aa3adb92c Merge tag '2.2.0' into develop
Merge avec master 2.2.0
2007-04-02 16:16:24 +00:00
137 changed files with 60766 additions and 5754 deletions

75
API.md Normal file
View File

@ -0,0 +1,75 @@
## API List
APIs given by COS2000 libraries
### LIBSYS
All fonctions in the "libsys" library.
------
`u32 exit(u32 resultcode);`
*Description:End a task for user or kernel domain*
* syscall id : **5**
* arguments : **1**
* * argument 1 : **u32 resultcode** *Code result of the execution*
* results : **u32**
* dump of register cpu: **no**
------
`u32 getticks(void);`
*Description:Return the internal value of the timer*
* syscall id : **4**
* arguments : **0**
* results : **u32**
* dump of register cpu: **no**
------
`u8 waitkey(void);`
*Description:Wait for user to press a key and return the ascii code pressed*
* syscall id : **1**
* arguments : **0**
* results : **u8**
* dump of register cpu: **no**
------
`u32 testapi(u32 arg1, u32 arg2, u32 arg3);`
*Description:Simple function to test if SYSCALL API is correctly running*
* syscall id : **0**
* arguments : **3**
* * argument 1 : **u32 arg1** *first argument of your choice*
* * argument 2 : **u32 arg2** *second argument of your choice*
* * argument 3 : **u32 arg3** *third argument of your choice*
* results : **u32**
* dump of register cpu: **yes**
### LIBVIDEO
All fonctions in the "libvideo" library.
------
`u32 print(u8* string);`
*Description:Show a string on the screen*
* syscall id : **2**
* arguments : **1**
* * argument 1 : **u8* string** *string to show in ascii format*
* results : **u32**
* dump of register cpu: **no**

24
BUGS.md Normal file
View File

@ -0,0 +1,24 @@
## 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.
### 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

BIN
Graphisme/map.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 KiB

1581
Graphisme/map.svg Executable file

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 67 KiB

13
INFORMATIONS.md Normal file
View File

@ -0,0 +1,13 @@
![logo](https://github.com/dahut87/cos2000/raw/master/Graphisme/logo.png)
## Organisation du noyau
### Mémoire
L'organisation de la mémoire de COS2000 répond au schéma suivant:
![logo](https://github.com/dahut87/cos2000/raw/master/Graphisme/map.png)
### API
COS2000 utilise les fonctions SYSENTER/SYSEXIT

128
README.md
View File

@ -1,4 +1,4 @@
![logo](https://github.com/dahut87/cos2000v2/raw/master/Graphisme/logo.png) ![logo](https://github.com/dahut87/cos2000v2/raw/develop/Graphisme/logo.png)
## COS2000 ## COS2000
@ -49,7 +49,7 @@ Les détails se trouvent dans le fichier `LICENSE.md`
#### Logiciels utilisés #### Logiciels utilisés
L'OS a été développé sous Linux afin de disposer d'un maximum d'outils dont GCC/NASM/Docker et l'ensemble des BINUTILS. Je vous conseille donc d'utiliser Linux afin de procéder à la compilation même si celle-ci peut fonctionner depuis Windows grace à Cygwin. Des distributions "Live" existent si vous ne souhaitez pas installer sur votre ordinateur (http://www.linuxmint.com/edition.php?id=259). L'OS a été développé sous Linux afin de disposer d'un maximum d'outils dont GCC/GAS/Docker et l'ensemble des BINUTILS. Je vous conseille donc d'utiliser Linux afin de procéder à la compilation même si celle-ci peut fonctionner depuis Windows grace à Cygwin. Des distributions "Live" existent si vous ne souhaitez pas installer sur votre ordinateur (http://www.linuxmint.com/edition.php?id=259).
Le système de conteneurisation Docker est exploité afin de d'assurer une reproductibilité totale de l'environnement de compilation quelque soit le système d'exploitation utilisé. Le système de conteneurisation Docker est exploité afin de d'assurer une reproductibilité totale de l'environnement de compilation quelque soit le système d'exploitation utilisé.
@ -57,7 +57,7 @@ Le système de conteneurisation Docker est exploité afin de d'assurer une repro
Téléchargez et exécutez le script d'installation automatique et de compilation "menu.sh" Téléchargez et exécutez le script d'installation automatique et de compilation "menu.sh"
`wget https://raw.githubusercontent.com/dahut87/cos2000v2/master/menu.sh` `wget https://raw.githubusercontent.com/dahut87/cos2000v2/develop/menu.sh`
Executez le script et les sources seront ainsi automatiquement téléchargées sur votre ordinateur par le biais de Git. Executez le script et les sources seront ainsi automatiquement téléchargées sur votre ordinateur par le biais de Git.
@ -65,7 +65,7 @@ Executez le script et les sources seront ainsi automatiquement téléchargées s
Un menu s'affiche ensuite qui vous propose de réaliser différentes tâches dont la compilation et/ou le test de COS2000. Un menu s'affiche ensuite qui vous propose de réaliser différentes tâches dont la compilation et/ou le test de COS2000.
![Menu de compilation](https://github.com/dahut87/cos2000v2/raw/master/Graphisme/screenshots/compilation.png) ![Menu de compilation](https://github.com/dahut87/cos2000v2/raw/develop/Graphisme/screenshots/compilation.png)
#### Installation/compilation manuelle #### Installation/compilation manuelle
@ -87,14 +87,17 @@ Docker est utilisé afin de permettre le fonctionnement correcte de la compilati
Commande de compilation de base Commande de compilation de base
* `./make.sh all` compile tout le projet dans sa version disquette * `./make.sh all` compile tout le projet dans sa version disque dur et disque dur en UEFI
Autres commandes de compilation de COS2000 Autres commandes de compilation de COS2000
* `./make.sh test` lance l'émulation QEMU en 32 bits sur disquette
* `./make.sh harddisk` compile la version disque dur
* `./make.sh harddiskuefi` compile la version disque dur UEFI
* `./make.sh test` lance l'émulation QEMU en 32 bits sur disque dur
* `./make.sh test64` lance l'émulation QEMU en 64 bits sur disque dur en UEFI
* `./make.sh clean` supprime les fichers compilés * `./make.sh clean` supprime les fichers compilés
* `./make.sh debug-boot` debogue le système en mode réel depuis le boot * `./make.sh syscall` réactualise les librairies du domaine utilisateur
* `./make.sh debug-loader` debogue le système en mode réel depuis le loader * `./make.sh programs` compile les programmes du domaine utilisateur
* `./make.sh debug-system` debogue le système en mode protégé
* `./make.sh config` change la configuration de la compilation * `./make.sh config` change la configuration de la compilation
### Utilisation ### Utilisation
@ -103,6 +106,26 @@ Autres commandes de compilation de COS2000
Pour tester l'OS en émulation taper donc la commande `./make.sh test` qui compilera avant de lancer Qemu. Pour tester l'OS en émulation taper donc la commande `./make.sh test` qui compilera avant de lancer Qemu.
#### Sur un ordinateur physique
Lancer une compilation du système COS2000
`./make.sh 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)
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)
Pour connaitre le numéro de votre périphérique (clé)
`lsblk`
#### Commandes de COS2000 #### Commandes de COS2000
Pour l'instant quelques commandes seulement sont disponibles: Pour l'instant quelques commandes seulement sont disponibles:
@ -113,12 +136,95 @@ Pour l'instant quelques commandes seulement sont disponibles:
* `DETECTCPU` detecte et affiche les informations CPU, * `DETECTCPU` detecte et affiche les informations CPU,
* `DETECTPCI` detecte et affiche les périphériques PCI, * `DETECTPCI` detecte et affiche les périphériques PCI,
* `TEST2D` teste l'affichage graphique 2D, * `TEST2D` teste l'affichage graphique 2D,
* `HELP` affiche les commandes disponibles. * `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/master/Graphisme/screenshots/ansi.png) ![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
* `docker` - fichiers pour la construction de containers
* `final` - img raw utilisables avec un émulateur des 3 versions
* * `harddisk.img.xz`
* * `harddiskuefi.img.xz`
* `Graphisme` - fichiers images
* * `screenshots` - screenshots de l'évolution du système
* `include` - fichier d'entête C
* `lib` - librairies pour le noyau
* `makefile` - Makefile du projet
* `make.sh` - Script de compilation utilisant Docker
* `menu.sh` - Script du menu d'autocompilation
* `templates` - Modèles utilisés pour générer des libraires du domaine utilisateur
* `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
* `INFORMATIONS.md` - informations sur le développement de COS2000
* `BUGS.md` - bugs rélevés dans le système
* `API.md` - Liste des APIs fournies par le système COS2000
* `system` - le noyau lui-même
### En savoir plus... ### En savoir plus...
#### Avancement du projet
* démarrage tout support grâce à GRUB (disquette, disque dur/SSD, réseau...Etc),
* pilotes souris et clavier,
* pilotes VGA et VESA (framebuffer),
* bibliothèque graphique 2D,
* bibliothèque graphique 3D,
* gestion des interruptions (IDT),
* gestion de la segmentation (GDT),
* gestion de la mémoire paginée,
* débogueur et désassembleur intégré,
* interpréteur de commande,
* affichage de chaîne de caractères (prinfs,sprintf,vsprintf) avec type (bin,hexa,octal,float,double,string,char),
* mode protégé limité à 4Go de mémoire vive (32 bits),
* gestion avancée de la mémoire (vmalloc).
* chargeur ELF32,
* espace utilisateur et appels systèmes,
* ordonnanceur de tâche (par TSS),
#### En cours
* correction de bogues - libération des ressources après destruction processus,
* liste d'API automatiquement mise à jour avec intégration de librairies & header,
* gestion du système de fichier CRAMFS,
* lancement du noyau par kernel et non par multiboot afin de bénéficier de initrd,
#### A faire
* pilote IDE/ATA (PIO mode),
* fonctions affichage image PNG,
* double buffering,
* gestion multiprocessing,
* virtualisation par VMX,
* Gestion du système de fichier EXT2FS.
![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
* `tools/*` sous licence GPL V2.0, fichiers issus du noyau Linux
* `debug/gdbinit`, GDB dashboard - Modular visual interface for GDB in Python Copyright (c) 2015-2017 Andrea Cardaci <cyrus.and@gmail.com>.
#### Historique du projet #### Historique du projet
* Version 2.2fr - C en mode protégé Reprise du projet * Version 2.2fr - C en mode protégé Reprise du projet
* Version 2.1fr - C en mode protégé Abandon du projet * Version 2.1fr - C en mode protégé Abandon du projet

View File

@ -1,4 +1,6 @@
![logo](https://github.com/dahut87/cos2000v2/raw/master/Graphisme/logo.png) ![logo](https://github.com/dahut87/cos2000v2/raw/master/Graphisme/logo.png)
## Copies d'écran de COS2000 ## Copies d'écran de COS2000
![screen](https://github.com/dahut87/cos2000v2/raw/develop/Graphisme/screenshots/28-09-2018.png)
![screen](https://github.com/dahut87/cos2000v2/raw/develop/Graphisme/screenshots/29-11-2018.png)
![screen](https://github.com/dahut87/cos2000v2/raw/develop/Graphisme/screenshots/ansi.png) ![screen](https://github.com/dahut87/cos2000v2/raw/develop/Graphisme/screenshots/ansi.png)

View File

@ -1,245 +0,0 @@
[BITS 16]
[ORG 0x7C00]
section .text
start:
jmp near Boot
Disk_ID db "COS2000A" ;Fabricant + n° de série Formatage
Sectors_Size dw 512 ;Nombre d'octets/secteur
Sectors_Per_Cluster db 1 ;Nombre de secteurs/cluster
Reserved_Sectors dw 1 ;Nombre de secteurs réservé
Fats_Number db 2 ;Nombre de copies de la FAT
Fits_Number dw 224 ;Taille du répertoire racine
Sectors_Per_Disk dw 2880 ;Nombre secteurs du volume si < 32 Mo
Media_Descriptor db 0xF0 ;Descripteur de média
Sectors_Per_Fat dw 9 ;Nombre secteurs/FAT
Sectors_Per_Track dw 18 ;Nombre secteurs/piste
Heads_Number dw 2 ;Nombre de tete de lecture/écriture
Sectors_Hidden dd 0 ;Nombre de secteurs cachés
Sectors_Per_Disk2 dd 0 ;Nombre secteurs du volume si > 32 Mo
Boot_Drive db 0 ;Lecteur de démarrage
Reserved db 0 ;NA (pour NT seulement)
Extended_Boot_ID db 0x29 ;Signature Boot étendu 29h
Serial_Number dd 0x01020304 ;N° de série
Disk_Name db "COS2000 " ;Nom de volume
Fat_Type db "FAT12 " ;Type de système de fichiers
Boot_Message db "Cos2000",0
Entre_Message db "Fichier",0
Loading_Message db "Charger",0
System_File db "Al",0,"o",0,"a",0,"d",0,"e",0,0x0F,0,0x38,"r",0,".",0,"s",0,"y",0,"s",0,0,0,0,0,0xFF,0xFF,0xFF,0xFF
Is_Ok db " [ OK ]",0x0A,0x0D,0
Is_Failed db " [ERREUR]",0x0A,0x0D,0
The_Dot db '.',0
Boot_Error:
mov si,Is_Failed
call ShowString
xor ax,ax
int 0x16
int 0x19
Boot_Ok:
mov si,Is_Ok
call ShowString
ret
Boot:
push cs
push cs
pop es
pop ds
mov [Boot_Drive],dl
cli
mov ax,0x9000
mov ss,ax
mov sp,0xFFFF
sti
mov si,Boot_Message
call ShowString
xor ax,ax
int 0x13
jc Boot_Error
mov cx,[Reserved_Sectors]
add cx,[Sectors_Hidden]
adc cx,[Sectors_Hidden+2]
mov bx,[Sectors_Per_Fat]
mov di,Fat_Buffer
push bx
push cx
readfat:
call ReadSector
jc Boot_Error
inc cx
add di,[Sectors_Size]
dec bx
jnz readfat
pop cx
pop bx
xor ax,ax
mov al,[Fats_Number]
mul bx
add cx,ax
mov ax,32
mul word [Fits_Number]
div word [Sectors_Size]
add ax,cx
sub ax,2
mov word [Serial_Number],ax
xor dx,dx
call Boot_Ok
mov si,Loading_Message
call ShowString
Find_System:
mov di,Buffer
call ReadSector
jc Near Boot_Error
xor bx,bx
Next_Root_Entrie:
cmp byte [di],0
je near Boot_Error
push di
push cx
mov si,System_File
mov cx,32
rep cmpsb
pop cx
pop di
je System_Found
add di,32
add bx,32
inc dx
cmp dx,[Fits_Number]
ja near Boot_Error
cmp bx,[Sectors_Size]
jb Next_Root_Entrie
inc cx
jmp Find_System
System_Found:
call Boot_Ok
mov si,Entre_Message
call ShowString
mov cx,[di+26+32]
mov ax,0x0080
mov es,ax
push es
mov di,0x0
push di
mov si,The_Dot
Resume_Loading:
cmp cx,0x0FF0
jae Finish_Loading
push cx
add cx,word [Serial_Number]
call ReadSector
pop cx
jc near Boot_Error
call ShowString
add di,[Sectors_Size]
call NextFatGroup
jc near Boot_Error
jmp Resume_Loading
Finish_Loading:
call Boot_Ok
retf
;====================READSECTOR=======================
;Lit le secteur logique LBA CX et le met en es:di
;-> CX (limité à 65536 secteurs, soit 32 Mo avec secteur 512 octets)
;<- Flag Carry si erreur
;=====================================================
ReadSector:
pusha
mov ax,cx
xor dx,dx
div word [Sectors_Per_Track]
inc dl
mov bl,dl
xor dx,dx
div word [Heads_Number]
mov dh, [Boot_Drive]
xchg dl,dh
mov cx,ax
xchg cl,ch
shl cl,6
or cl, bl
mov bx,di
mov si, 4
mov al, 1
Read_Again:
mov ah, 2
int 0x13
jnc Read_Done
dec si
jnz Read_Again
Read_Done:
popa
ret
;===================NEXTFATGROUP======================
;Renvoie en CX le groupe qui succède dans la FAT le groupe CX
;-> CX
;<-
;=====================================================
NextFatGroup:
push bx
push dx
push di
mov ax,cx
mov bx,ax
and bx,0000000000000001b
shr ax,1
mov cx,3
mul cx
mov di,Fat_Buffer
add di,ax
cmp bx,0
jnz Even_Group
Odd_Group:
mov dx,[di]
and dx,0x0FFF
mov cx,dx
jmp Next_Group_Found
Even_Group:
mov dx,[di+1]
and dx,0xFFF0
shr dx,4
mov cx,dx
Next_Group_Found:
pop di
pop dx
pop bx
ret
;======================SHOWSTR========================
;Affiche la chaine de caractère pointé par ds:si à l'écran
;-> DS, SI
;<- Flag Carry si erreur
;=====================================================
ShowString:
pusha
Next_Char:
lodsb
or al,al
jz End_Show
mov ah,0x0E
mov bx,0x07
int 0x10
jmp Next_Char
End_Show:
popa
ret
times 510-($-$$) db ' '
dw 0xAA55
Buffer equ $
Fat_Buffer equ $+512
section .bss
;Buffer resb 512
;Fat_Buffer resb 10000

View File

@ -1,270 +0,0 @@
[BITS 16]
[ORG 0x7C00]
section .text
start:
jmp near Boot
Disk_ID db "COS2000A" ;Fabricant + n° de série Formatage
Sectors_Size dw 512 ;Nombre d'octets/secteur
Sectors_Per_Cluster db 4 ;Nombre de secteurs/cluster
Reserved_Sectors dw 1 ;Nombre de secteurs réservé
Fats_Number db 2 ;Nombre de copies de la FAT
Fits_Number dw 512 ;Taille du répertoire racine
Sectors_Per_Disk dw 2880 ;Nombre secteurs du volume si < 32 Mo
Media_Descriptor db 0xF8 ;Descripteur de média
Sectors_Per_Fat dw 207 ;Nombre secteurs/FAT
Sectors_Per_Track dw 18 ;Nombre secteurs/piste
Heads_Number dw 38 ;Nombre de tete de lecture/écriture
Sectors_Hidden dd 16 ;Nombre de secteurs cachés
Sectors_Per_Disk2 dd 39 ;Nombre secteurs du volume si > 32 Mo
Boot_Drive db 0x80 ;Lecteur de démarrage
Reserved db 0 ;NA (pour NT seulement)
Extended_Boot_ID db 0x29 ;Signature Boot étendu 29h
Serial_Number dd 0x01020304 ;N° de série
Disk_Name db "COS2000 " ;Nom de volume
Fat_Type db "FAT16 " ;Type de système de fichiers
;Cpu_Message db "CPU test",0
;Boot_Message db "Booting ",0
;Finding_Message db "System ",0
;Loading_Message db "Loading ",0
System_File db "SYSTEM SYS"
Is_Ok db "[ OK ]",0x0A,0x0D,0
Is_Failed db "[Failed]",0x0A,0x0D,"Press a key",0x0A,0x0D,0
The_Dot db '.',0
Boot_Error:
mov si,Is_Failed
call ShowString
mov ah,0
int 0x16
int 0x19
Boot_Ok:
; mov al,[Stage]
; cmp al,0
; jz No_Ok
mov si,Is_Ok
call ShowString
;No_Ok:
; xor ah,ah
; mov si,ax
; add si,Boot_Message ;Cpu_Message
; call ShowString
; add byte [Stage],0x09
ret
;
;Stage db 0
Boot:
push cs
push cs
pop es
pop ds
mov [Boot_Drive],dl
cli
mov ax,0x9000
mov ss,ax
mov sp,0xFFFF
sti
; call Detect_Cpu
; jc Boot_Error
; call Boot_Ok
xor ax,ax
int 0x13
; jc Boot_Error
xor eax,eax
add ax,[Reserved_Sectors]
add ecx,eax
mov di,Fat_Buffer
call ReadSector
jc Boot_Error
xor eax,eax
mov al,[Fats_Number]
mov bx,[Sectors_Per_Fat]
mul bx
add ecx,eax
mov ax,32
mul word [Fits_Number]
div word [Sectors_Size]
add eax,ecx
mov dword [Serial_Number],eax
xor dx,dx
; call Boot_Ok
Find_System:
mov di,Buffer
call ReadSector
jc near Boot_Error
xor bx,bx
Next_Root_Entrie:
cmp byte [di],0
je near Boot_Error
push di
push cx
mov si,System_File
mov cx,11
rep cmpsb
pop cx
pop di
je System_Found
add di,32
add bx,32
inc dx
cmp dx,[Fits_Number]
ja near Boot_Error
cmp bx,[Sectors_Size]
jb Next_Root_Entrie
inc ecx
jmp Find_System
System_Found:
xor ecx,ecx
mov cx,[di+26]
mov ax,0x0071
mov es,ax
push es
mov di,0x100
push di
; call Boot_Ok
mov si,The_Dot
Resume_Loading:
cmp cx,0x0FFF0
jae Finish_Loading
call ReadGroup
jc near Boot_Error
call ShowString
mov bx,cx
shl bx,1
mov cx,[bx+Fat_Buffer]
jmp Resume_Loading
Finish_Loading:
call Boot_Ok
retf
;====================READSECTOR=======================
;Lit le secteur logique LBA ECX et le met en es:di
;-> ECX (limité à 2^32 secteurs, soit 2 To avec secteur 512 octets)
;<- Flag Carry si erreur
;=====================================================
ReadSector:
pushad
mov ax, cx
ror ecx,16
mov dx,cx
rol ecx,16
cmp ecx,4128705
ja Extended_CHS
div word [Sectors_Per_Track]
inc dl
mov bl, dl
xor dx,dx
div word [Heads_Number]
mov dh, [Boot_Drive]
xchg dl, dh
mov cx, ax
xchg cl, ch
shl cl, 6
or cl, bl
mov bx, di
mov si, 4
mov al, 1
Read_Again:
mov ah, 2
int 0x13
jnc Read_Done
dec si
jnz Read_Again
Read_Done:
popad
ret
Extended_CHS:
mov si,ECHS_Block
mov byte [si+Sizes],0x10
mov byte [si+Reserve],0x01
mov byte [si+NumSectors],0x01
mov [si+Adressseg],es
mov [si+Adressoff],di
mov [si+SectorLow],ax
mov [si+SectorHigh],dx
mov di,4
mov dl,[Boot_Drive]
Read_AgainX:
mov ah, 42h
int 13h
jnc Read_Done
dec di
jnz Read_AgainX
;======================READGROUP======================
;lit le groupe cx en es:di et incrmente DI
;-> cx, es:di
;<- di, Flag Carry si erreur
;=====================================================
ReadGroup:
push ax
push cx
push dx
mov al,[Sectors_Per_Cluster]
sub cx,2
xor ah,ah
mul cx
mov cx,dx
shl ecx,16
mov cx,ax
add ecx,dword [Serial_Number]
mov al,[Sectors_Per_Cluster]
read:
call ReadSector
jc errors
inc ecx
add di,[Sectors_Size]
dec al
jnz read
clc
errors:
pop dx
pop cx
pop ax
ret
;======================SHOWSTR========================
;Affiche la chaine de caractère pointé par ds:si à l'écran
;-> DS, SI
;<- Flag Carry si erreur
;=====================================================
ShowString:
;push ax
;push bx
;push si
pusha
Next_Char:
lodsb
or al,al
jz End_Show
mov ah,0x0E
mov bx,0x07
int 0x10
jmp Next_Char
End_Show:
;pop si
;pop bx
;pop ax
popa
ret
times 510-($-$$) db ' '
dw 0xAA55
ECHS_Block equ $
Buffer equ $+26
Fat_Buffer equ $+26+512
section .bss
%include "echs.h"
;ECHS_Block resb 24
;Buffer resb 512
;Fat_Buffer resb 10000

View File

@ -1,10 +0,0 @@
struc echs
Sizes resb 1
Reserve resb 1
NumSectors resw 1
Adressoff resw 1
Adressseg resw 1
SectorLow resw 1
SectorHigh resw 1
Dummy resq 1
endstuc

View File

@ -1,116 +0,0 @@
struc ELFheader
.Magic resb 1;"0x7F"
.MagicStr resb 3;"ELF"
.Computertype resb 1;1
.Endianness resb 1;1
.Original resb 1;1
.OS resb 1;0
.ABI resb 1;0
.Dummy resb 7;0
.Type resw 1;2
.Target resw 1;3
.Version resd 1;1
.Entrypoint resd 1
.Offsetprogram resd 1
.Offsetsection resd 1
.Flags resd 1
.SizeELFheader resw 1
.Sizeprogram resw 1
.Nbprogram resw 1
.Sizesection resw 1
.Nbsection resw 1
.Index resw 1
.end equ $
endstruc
struc Program
.Type resd 1
.Offset resd 1
.Vadress resd 1
.PAdress resd 1
.Size resd 1
.Memsize resd 1
.Flags resd 1
.Align resd 1
.end equ $
endstruc
struc Sections
.Name resd 1
.Type resd 1
.Flags resd 1
.Vadress resd 1
.Offset resd 1
.Size resd 1
.Link resd 1
.Info resd 1
.Align resd 1
.Entrysize resd 1
.end equ $
endstruc
;type
PT_NULL equ 0
PT_LOAD equ 1
PT_DYNAMIC equ 2
PT_INTERP equ 3
PT_NOTE equ 4
PT_SHLIB equ 5
PT_PHDR equ 6
PT_TLS equ 7
PT_LOOS equ 0x60000000
PT_HIOS equ 0x6fffffff
PT_LOPROC equ 0x70000000
PT_HIPROC equ 0x7fffffff
;flags
PF_WRITE equ 0x1
PF_ALLOC equ 0x2
PF_X equ 0x1 ;Execute
PF_W equ 0x2 ;Write
PF_R equ 0x4 ;Read
PF_MASKOS equ 0x0ff00000 ;Unspecified
PF_MASKPROC equ 0xf0000000 ;Unspecified
;type
ST_EXIT equ 1
ST_NULL equ 0
ST_PROGBITS equ 1
ST_SYMTAB equ 2
ST_STRTAB equ 3
ST_RELA equ 4
ST_HASH equ 5
ST_DYNAMIC equ 6
ST_NOTE equ 7
ST_NOBITS equ 8
ST_REL equ 9
ST_SHLIB equ 10
ST_DYNSYM equ 11
ST_INIT_ARRAY equ 14
ST_FINI_ARRAY equ 15
ST_PREINIT_ARRAY equ 16
ST_GROUP equ 17
ST_SYMTAB_SHNDX equ 18
ST_LOOS equ 0x60000000
ST_HIOS equ 0x6fffffff
ST_LOPROC equ 0x70000000
ST_HIPROC equ 0x7fffffff
ST_LOUSER equ 0x80000000
ST_HIUSER equ 0xffffffff
;flags
SF_WRITE equ 0x1
SF_ALLOC equ 0x2
SF_EXECINSTR equ 0x4
SF_MERGE equ 0x10
SF_STRINGS equ 0x20
SF_INFO_LINK equ 0x40
SF_LINK_ORDER equ 0x80
SF_OS_NONCONFORMING equ 0x100
SF_GROUP equ 0x200
SF_TLS equ 0x400
SF_COMPRESSED equ 0x800
SF_MASKOS equ 0x0ff00000
SF_MASKPROC equ 0xf0000000

View File

@ -1,852 +0,0 @@
[BITS 16]
[ORG 0x0]
SECTION .text
push cs
push cs
pop ds
pop es
mov si,msg0
call showstr
mov si,msg1
call showstr
call initfat
call ok
mov si,msg2
call showstr
mov si,System_File
call search
call ok
mov si,msg3
call showstr
call EnableA20
call ok
mov si,msg4
call showstr
mov eax,cs
shl eax,4
mov [GDT.Entry1+2],ax
mov [GDT.Entry2+2],ax
shr eax,16
mov [GDT.Entry1+4],al
mov [GDT.Entry2+4],al
mov eax,cs
shl eax,4
add eax,gdt0
mov [GDTR.Address],eax
lgdt [GDTR]
call ok
mov si,msg5
call showstr
cli
mov eax,cr0
or al,1
mov cr0,eax
jmp short $+2
mov bx,SYS_DATA_SEL
mov fs,bx
mov ds,bx
mov es,bx
mov gs,bx
and al,0FEh
mov cr0,eax
jmp short $+2
mov bx,cs
mov fs,bx
mov ds,bx
mov es,bx
mov gs,bx
sti
call ok
mov si,msg6
call showstr
mov ebx,0x300000
call load
call ok
mov si,msg7
call showstr
call initpe
call ok
suite:
;mov cx,suite
;call debug
mov si,msg8
call showstr
cli
mov al,0x80
out 0x70,al
mov eax,cr0
or al,1
mov cr0,eax
jmp SYS_CODE_SEL:GoPMode32
Boot_Error:
mov si,error
call showstr
xor ax,ax
int 16h
jmp 0xFFFF:0x0
ok:
push si
push cx
mov cl,67
call eol
mov si,okay
call showstr
pop cx
pop si
ret
;======================INITPE========================
;Initialise le PE de l'adresse EBX
;->
;<- Flag Carry si erreur
;=====================================================
initpe:
pusha
push es
xor ax,ax
mov es,ax
mov [begin],ebx
cmp word [es:ebx+ELFheader.Magic],0x457F ; bien l'entete .elf ?
jne near errorelf
cmp word [es:ebx+ELFheader.Magic+2],"LF" ; bien l'entete .elf ?
jne near errorelf
cmp byte [es:ebx+ELFheader.Computertype],0x1 ; type ok ?
jne near errorelf
cmp byte [es:ebx+ELFheader.Endianness],0x1 ; type ok ?
jne near errorelf
cmp byte [es:ebx+ELFheader.Original],0x1 ; type ok ?
jne near errorelf
cmp byte [es:ebx+ELFheader.OS],0x0 ; type ok ?
jne near errorelf
cmp byte [es:ebx+ELFheader.ABI],0x0 ; type ok ?
jne near errorelf
cmp byte [es:ebx+ELFheader.Dummy],0x0 ; type ok ?
jne near errorelf
mov si,info1
call showstr
mov esi,[es:ebx+ELFheader.Entrypoint]
mov [entriepoint],esi
mov esi,[es:ebx+ELFheader.Offsetprogram]
add esi,ebx
mov [offsetheader],esi
mov esi,[es:ebx+ELFheader.Offsetsection]
add esi,ebx
mov [offsetsection],esi
mov cx,[es:ebx+ELFheader.Nbprogram]
mov [cs:nbprogram],cx
mov cx,[es:ebx+ELFheader.Nbsection]
mov [cs:nbsection],cx
xor eax,eax
mov ax,[es:ebx+ELFheader.Index]
xor edx,edx
mov dx,[es:ebx+ELFheader.Sizesection]
mul edx
add eax,esi
mov eax,[es:eax+Sections.Offset]
add eax,ebx
mov [cs:symbol],eax
xor eax,eax
add ax,[es:ebx+ELFheader.Sizesection]
add esi,eax
sections:
mov edi,esi
cmp dword [es:edi+Sections.Type],0x00
jz nothing
mov esi,info2
call showstr
push ds
push es
pop ds
mov esi,[es:edi+Sections.Name]
add esi,[cs:symbol]
call showstr
pop ds
mov esi,info3
call showstr
mov edx,[es:edi+Sections.Offset]
push cx
mov cx,32
call ShowHex
pop cx
mov esi,info4
call showstr
mov edx,[es:edi+Sections.Size]
push cx
mov cx,32
call ShowHex
pop cx
mov esi,info5
call showstr
mov edx,[es:edi+Sections.Vadress]
push cx
mov cx,32
call ShowHex
pop cx
and dword [es:edi+Sections.Flags],SF_ALLOC
jne itsok
mov esi,info6
call showstr
jmp itsok2
itsok:
mov esi,info10
call showstr
call copy2mem
cmp dword [es:edi+Sections.Type],ST_NOBITS
jne itsok2
mov esi,info9
call showstr
mov esi,info10
call showstr
call zero2mem
itsok2:
push cx
xor cx,cx
mov edx,[es:edi+Sections.Align]
mov esi,info8
call showstr
nextpower:
cmp edx,0
je powerok
cmp edx,1
je powerok
cmp cx,32
je powerok
inc cx
shr edx,1
jnc nextpower
powerok:
mov edx,ecx
mov cx,4
call ShowHex
pop cx
call showrtn
mov esi,edi
nothing:
add esi,eax
dec cx
jnz sections
mov esi,info7
call showstr
mov edx,[cs:entriepoint]
mov cx,32
call ShowHex
clc
pop es
popa
ret
errorelf:
stc
pop es
popa
ret
;==========DEBUG===========
;CX adresse
;->CX
;<-
;===========================================
debug:
mov esi,info11
call showstr
xor edx,edx
mov dx,cs
shl edx,4
add edx,ecx
mov cx,32
call ShowHex
infini:
jmp infini
;==========COPY2MEM===========
;Copie de es:esi vers es:edi
;->ES:ESI ES:EDI CX
;<- Flag
;===========================================
copy2mem:
push eax
push esi
push edi
push ecx
mov esi,[es:edi+Sections.Offset]
add esi,[cs:begin]
mov ecx,[es:edi+Sections.Size]
shr ecx,2
inc ecx
mov edi,[es:edi+Sections.Vadress]
copietomem:
mov eax,[es:esi]
mov [es:edi],eax
add edi,4
add esi,4
dec ecx
jnz copietomem
pop ecx
pop edi
pop esi
pop eax
ret
;==========ZERO2MEM===========
;Remise à zero de es:edi
;->ES:EDI CX
;<- Flag
;===========================================
zero2mem:
push eax
push esi
push edi
push ecx
mov esi,[es:edi+Sections.Offset]
add esi,[cs:begin]
mov ecx,[es:edi+Sections.Size]
shr ecx,2
inc ecx
mov edi,[es:edi+Sections.Vadress]
mov eax,0
zerotomem:
mov [es:edi],eax
add edi,4
dec ecx
jnz zerotomem
pop ecx
pop edi
pop esi
pop eax
ret
begin dd 0
entriepoint dd 0
offsetheader dd 0
offsetsection dd 0
nbprogram dw 0
nbsection dw 0
symbol dd 0
;==========SHOWHEX===========
;Affiche un nombre hexadécimal EDX de taille CX aprés le curseur
;-> EDX un entier, CX la taille
;<-
;===========================================
ShowHex:
push ax
push bx
push cx
push edx
push si
mov ax,cx
shr ax,2
sub cx,32
neg cx
shl edx,cl
xor cx,cx
inc cx
Hexaize:
rol edx,4
mov bx,dx
and bx,0fh
mov si,ax
mov al,[cs:bx+Tab]
xor bx,bx
mov ah,0x09
mov bl,[cs:thecolor]
int 0x10
mov ah,0x0E
int 0x10
mov ax,si
dec al
jnz Hexaize
pop si
pop edx
pop cx
pop bx
pop ax
ret
Tab db '0123456789ABCDEF'
;======================EOL========================
;Va en colonne CX
;->
;<- Flag Carry si erreur
;=====================================================
eol:
pusha
mov bp,cx
mov ah,03
xor bx,bx
int 10h
mov ah,02
mov cx,bp
mov dl,cl
int 10h
popa
ret
;======================LOAD========================
;Charge le groupe en mémoire en ebx
;->
;<- Flag Carry si erreur
;=====================================================
load:
push ax
push ebx
push ecx
push edx
push esi
push edi
push fs
xor edx,edx
xor ax,ax
mov fs,ax
mov si,The_Dot
mov dx,[Sectors_Size]
Resume_Loading:
cmp cx,0x0FF0
jae Finish_Loading
push cx
add cx,word [data]
mov edi,Buffer
call ReadSector
pop cx
jc near Boot_Error
call showstr
push esi
push ebx
push cx
mov esi,Buffer
mov cx,dx
shr cx,2
copie:
mov eax,[ds:esi]
mov [fs:ebx],eax
add ebx,4
add esi,4
dec cx
jnz copie
pop cx
pop ebx
pop esi
add ebx,edx
call NextFatGroup
jc near Boot_Error
jmp Resume_Loading
Finish_Loading:
pop fs
pop edi
pop esi
pop edx
pop ecx
pop ebx
pop ax
ret
;======================INITFAT========================
;Initialise les variables de la fat
;->
;<- Flag Carry si erreur
;=====================================================
initfat:
pusha
push ds
xor ax,ax
mov ds,ax
mov si,0x7C0B
mov di,bootsector
mov cx, 512
rep movsb
pop ds
mov cx,[Reserved_Sectors]
add cx,[Sectors_Hidden]
adc cx,[Sectors_Hidden+2]
mov bx,[Sectors_Per_Fat]
mov di,Fat_Buffer
push bx
push cx
readfat:
call ReadSector
jc Boot_Error
inc cx
add di,[Sectors_Size]
dec bx
jnz readfat
pop cx
pop bx
xor ax,ax
mov al,[Fats_Number]
mul bx
add cx,ax
mov [entries],cx
mov ax,32
mul word [Fits_Number]
div word [Sectors_Size]
add cx,ax
sub cx,2
mov word [data],cx
popa
ret
;======================SEARCH========================
;Recherche le groupe d'un fichier
;-> si nom du fichier
;<- Flag Carry si erreur CX
;=====================================================
search:
push bx
push dx
push di
mov cx,[entries]
mov di,Buffer
call ReadSector
jc Boot_Error
xor bx,bx
Next_Root_Entrie:
cmp byte [di],0
je Boot_Error
push si
push di
push cx
mov cx,32
rep cmpsb
pop cx
pop di
pop si
je Found
add di,32
add bx,32
inc dx
cmp dx,[Fits_Number]
ja Boot_Error
cmp bx,[Sectors_Size]
jb Next_Root_Entrie
inc cx
Found:
mov cx,[di+26+32]
pop di
pop dx
pop bx
ret
;======================SHOWRTN========================
;Affiche la chaine de caractère return
;->
;<- Flag Carry si erreur
;=====================================================
showrtn:
push ds
push ax
push esi
mov esi,return
mov ax,cs
mov ds,ax
call showstr
pop esi
pop ax
pop ds
ret
;======================SHOWSTR========================
;Affiche la chaine de caractère pointé par ds:esi à l'écran
;-> DS, SI
;<- Flag Carry si erreur
;=====================================================
showstr:
pushad
xor bh,bh
nextchar:
mov al,[ds:esi]
inc esi
or al,al
jz endshow
cmp al,' '
jb justchar
cmp al,'#'
jne nocolor
mov al,[ds:esi]
inc esi
sub al,'0'
shl al,3
mov [cs:thecolor],al
shr al,2
add [cs:thecolor],al
mov al,[ds:esi]
inc esi
sub al,'0'
add [cs:thecolor],al
jmp nextchar
nocolor:
cmp al,'@'
jne nocolor2
mov al,[ds:esi]
inc esi
sub al,'0'
shl al,3
mov cl,al
shr al,2
add cl,al
mov al,[ds:esi]
inc esi
sub cl,'0'
add cl,al
call eol
jmp nextchar
nocolor2:
xor bx,bx
mov ah,0x09
mov bl,[cs:thecolor]
xor cx,cx
inc cx
int 0x10
justchar:
mov ah,0x0E
int 0x10
jmp nextchar
endshow:
popad
ret
;====================READSECTOR=======================
;Lit le secteur logique LBA CX et le met en es:di
;-> CX (limité à 65536 secteurs, soit 32 Mo avec secteur 512 octets)
;<- Flag Carry si erreur
;=====================================================
ReadSector:
pusha
mov ax,cx
xor dx,dx
div word [Sectors_Per_Track]
inc dl
mov bl,dl
xor dx,dx
div word [Heads_Number]
mov dh, [Boot_Drive]
xchg dl,dh
mov cx,ax
xchg cl,ch
shl cl,6
or cl, bl
mov bx,di
mov si, 4
mov al, 1
Read_Again:
mov ah, 2
int 0x13
jnc Read_Done
dec si
jnz Read_Again
Read_Done:
popa
ret
;===================NEXTFATGROUP======================
;Renvoie en CX le groupe qui succède dans la FAT le groupe CX
;-> CX
;<-
;=====================================================
NextFatGroup:
push bx
push dx
push di
mov ax,cx
mov bx,ax
and bx,0000000000000001b
shr ax,1
mov cx,3
mul cx
mov di,Fat_Buffer
add di,ax
cmp bx,0
jnz Even_Group
Odd_Group:
mov dx,[di]
and dx,0x0FFF
mov cx,dx
jmp Next_Group_Found
Even_Group:
mov dx,[di+1]
and dx,0xFFF0
shr dx,4
mov cx,dx
Next_Group_Found:
pop di
pop dx
pop bx
ret
;***********************EnableA20*******************************
;->
;<-
;Ouvre l'autoroute A20
;***************************************************************
EnableA20:
cli
call ClearKeybBuffer
call WaitKeybCommand
mov al,0xd1
out 0x64,al
call WaitKeybCommand
mov al,0xdf
out 0x60,al
call WaitKeybCommand
jmp A20Enabled
WaitKeybCommand:
in al,0x64
test al,0x02
jnz WaitKeybCommand
ret
ClearKeybBuffer:
in al,0x64
test al,0x01
jnz ReadKeyb
ret
ReadKeyb:
in al,0x60
jmp ClearKeybBuffer
A20Enabled:
sti
ret
GoPMode32:
[BITS 32]
mov ax,ALL_DATA_SEL
mov es,ax
mov gs,ax
mov fs,ax
mov ss,ax
mov ds,ax
mov esp,0x3fffff
push KERNEL_SEL
push dword [cs:entriepoint]
retf
section .data
thecolor db 0x07
msg0 db '#12@20-=< Lancement du Chargeur ELF >=-',0x0A,0x0D,0x0A,0x0D,0
msg1 db '#07Initialisation de la FAT',0
msg2 db '#07Recherche du systeme',0
msg3 db '#07Activation adressage 24 bits',0
msg4 db '#07Chargement des descripteurs',0
msg5 db '#07Passage en mode Flat real',0
msg6 db '#07Chargement du systeme',0
msg7 db '#07Mise en place format ELF',0
msg8 db '#07Passage en mode protege',0
info1 db 0x0A,0x0D,'Format ELF i386 reconnu, #08Sections :',0x0A,0x0D,0
info2 db ' ',0
info3 db '@12 | ',0
info4 db ' - ',0
info5 db ' -> ',0
info6 db '@35#12NON ALLOUE #08',0
info7 db 'Point entree en ',0
info8 db '@48 2**',0
info9 db '@15#12 VIDE #08',0
info10 db '@70MEM',0
info11 db 0x0A,0x0D,'#12Arret debug en ',0
return db 0x0A,0x0D,0
okay db ' #15[ #10OK #15]',0x0A,0x0D,0
error db ' #15[#12Erreur#15]',0x0A,0x0D,0x0A,0x0D,' <Appuyez une touche pour redemarrer>',0
The_Dot db '.',0
System_File db "As",0,"y",0,"s",0,"t",0,"e",0,0x0F,0,0xB8,"m",0,".",0,"s",0,"y",0,"s",0,0,0,0,0,0xFF,0xFF,0xFF,0xFF
entries dw 0
data dw 0
xy dw 0
GDTR:
.Size: dw GDT_END
.Address: dd 0
gdt0 equ $ ; null entry
GDT:
.Entry0: dw 0 ; limit 15:0
dw 0 ; base 15:0
db 0 ; base 23:16
db 0 ; type
db 0 ; limit 19:16, flags
db 0 ; base 31:24
SYS_CODE_SEL equ $-gdt0 ; code segment descriptor
.Entry1: dw 0xFFFF
dw 0x0 ; base
db 0x0 ; base
db 0x9A ; present, ring 0, code, non-conforming, readable
db 0xCF ; 32 bit
db 0
SYS_DATA_SEL equ $-gdt0 ; data segment descriptor
.Entry2: dw 0xFFFF
dw 0x0 ; base
db 0x0 ; base
db 0x92 ; present, ring 0, data, expand-up, writable
db 0xCF ; 32 bit
db 0
ALL_DATA_SEL equ $-gdt0 ; 4meg data segment descriptor
.Entry3: dw 0xFFFF
dw 0x0 ; base
db 0x0 ; base
db 0x92 ; present, ring 0, data, expand-up, writable
db 0xCF ; 4k pages, 32 bit
db 0
KERNEL_SEL equ $-gdt0 ; 4g code segment descriptor
.Entry4: dw 0xffff
dw 0x0 ; base
db 0x0 ; base
db 0x9A ; present, ring 0, code, non-conforming, readable
db 0xCF ; 4k pages, 32 bit
db 0
GDT_END equ $-gdt0 -1
bootsector equ $
Sectors_Size dw 0 ;Nombre d'octets/secteur
Sectors_Per_Cluster db 0 ;Nombre de secteurs/cluster
Reserved_Sectors dw 0 ;Nombre de secteurs réservé
Fats_Number db 0 ;Nombre de copies de la FAT
Fits_Number dw 0 ;Taille du répertoire racine
Sectors_Per_Disk dw 0 ;Nombre secteurs du volume si < 32 Mo
Media_Descriptor db 0 ;Descripteur de média
Sectors_Per_Fat dw 0 ;Nombre secteurs/FAT
Sectors_Per_Track dw 0 ;Nombre secteurs/piste
Heads_Number dw 0 ;Nombre de tete de lecture/écriture
Sectors_Hidden dd 0 ;Nombre de secteurs cachés
Sectors_Per_Disk2 dd 0 ;Nombre secteurs du volume si > 32 Mo
Boot_Drive db 0 ;Lecteur de démarrage
Reserved db 0 ;NA (pour NT seulement)
Extended_Boot_ID db 0 ;Signature Boot étendu 29h
Buffer equ $
Fat_Buffer equ $+512
SECTION .bss
%include "elf.h"

View File

@ -1,22 +0,0 @@
CC=nasm -f bin -o
all: makall
makall: boot12.bin boot16.bin loader.sys
boot12.bin: boot12.asm
$(CC) $@ $^
boot16.bin: boot16.asm
$(CC) $@ $^
loader.sys: loader.asm
$(CC) $@ $^
clean:
rm -f *.o
rm -f *.bin
rm -f *.sys
rm -f *.com

View File

@ -1,8 +1,10 @@
target remote localhost:1234 target remote localhost:1234
set disassembly-flavor intel set disassembly-flavor att
add-symbol-file ./system/realmode/setup.sym 0x902f6
set architecture i8086 set architecture i8086
break *0x7c00 break *0x90200
cont cont
clear *0x7c00 clear *0x90200
layout asm break main
layout regs ###cont
clear main

26
debug/debug.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/sh
session="debug"
tmux start-server
tmux new-session -d -s $session -n gdb
tmux splitw -h -p 90
tmux splitw -t 0 -v -p 50
tmux splitw -t 2 -h -p 45
tmux splitw -v -p 50
tmux splitw -v -p 50
tmux send-keys -t 5 "gdb --init-command=./debug/gdbinit -x $1" Enter
tmux send-keys -t 3 "telnet 127.0.0.1 6666" Enter
tmux send-keys -t 5 "dashboard stack -output /dev/pts/4" Enter
tmux send-keys -t 5 "dashboard threads -output /dev/null" Enter
tmux send-keys -t 5 "dashboard assembly -output /dev/pts/3" Enter
tmux send-keys -t 5 "dashboard registers -output /dev/pts/2" Enter
tmux send-keys -t 5 "dashboard expressions -output /dev/pts/6" Enter
tmux send-keys -t 5 "dashboard memory -output /dev/pts/6" Enter
tmux send-keys -t 5 "dashboard source -output /dev/pts/3" Enter
tmux send-keys -t 5 "dashboard history -output /dev/pts/7" Enter
tmux send-keys -t 5 "dashboard threads -output /dev/null" Enter
tmux send-keys -t 5 "dashboard stack -output /dev/pts/4" Enter
tmux new-window -t $session:1 -n scratch
tmux select-window -t $session:0
tmux attach-session -t $session

3241
debug/gdbinit Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
target remote localhost:1234
set disassembly-flavor intel
set architecture i8086
break *0x800
cont
display/20i $pc+$cs*16
clear *0x800

View File

@ -1,8 +1,11 @@
target remote localhost:1234 target remote localhost:1234
set disassembly-flavor intel set disassembly-flavor att
set architecture i386 set architecture i386
break *0x50000 symbol-file ./system/system.sym
break start
break *0x100000
cont
clear *0x100000
si
break *0x100000
cont cont
symbol-file ./system/system.sys
clear *0x50000
display/20i $pc

View File

@ -3,6 +3,8 @@ RUN echo "http://alpine.42.fr/v3.12/main" > /etc/apk/repositories
RUN echo "http://alpine.42.fr/v3.12/community" >> /etc/apk/repositories RUN echo "http://alpine.42.fr/v3.12/community" >> /etc/apk/repositories
RUN apk --no-cache update RUN apk --no-cache update
RUN apk --no-cache upgrade RUN apk --no-cache upgrade
RUN apk --no-cache add font-noto git gcc make qemu qemu-system-i386 dosfstools nasm sed gdb tar wget gzip indent binutils hexdump dos2unix xxd tmux git musl-dev gnome-terminal spice-gtk spice-gtk-tools python2 RUN apk --no-cache add font-noto git gcc make qemu qemu-system-i386 qemu-system-x86_64 sed gdb ovmf tar wget gzip indent binutils hexdump dos2unix xxd xz tmux git musl-dev gnome-terminal spice-gtk spice-gtk-tools python2 cramfs
RUN mkdir -p /usr/share/qemu/
RUN ln -s /usr/share/OVMF/OVMF.fd /usr/share/qemu/OVMF.fd
RUN mkdir /data RUN mkdir /data
WORKDIR /data WORKDIR /data

View File

@ -1,7 +1,9 @@
FROM debian:10 FROM debian:10
RUN apt-get update -yq \ RUN apt-get update -yq \
&& apt-get install --no-install-recommends gcc make qemu dosfstools gdb psmisc tmux git libc6-dev bsdmainutils tar wget bsdmainutils indent binutils xxd dos2unix nasm gnome-terminal spice-client-gtk python2.7 qemu-system-x86 -yq \ && apt-get install --no-install-recommends gcc make qemu fusefat fuseext2 gdb ovmf xz-utils psmisc tmux git libc6-dev bsdmainutils tar wget bsdmainutils indent binutils xxd dos2unix gnome-terminal spice-client-gtk python2.7 qemu-system-x86 -yq \
&& apt-get clean -y && apt-get clean -y
RUN wget http://ftp.fr.debian.org/debian/pool/main/c/cramfs/cramfsprogs_1.1-6_amd64.deb -O /tmp/cramfsprogs_1.1-6_amd64.deb
RUN dpkg -i /tmp/cramfsprogs_1.1-6_amd64.deb
RUN mkdir /data RUN mkdir /data
WORKDIR /data WORKDIR /data

BIN
final/harddisk.img.xz Normal file

Binary file not shown.

BIN
final/harddiskuefi.img.xz Normal file

Binary file not shown.

View File

@ -1,13 +1,53 @@
all: cos2000.img REMOVE=rm -f
INSTALL=sudo apt-get install
cos2000.img: COPY=cp
(dd if=/dev/zero of=cos2000.img count=2880 bs=512) DISKCOPY=dd
(mkfs.msdos -F 12 -n "COS2000" cos2000.img;mkdir ./mnt || true) COMPRESS=xz
(mount -t vfat cos2000.img ./mnt -o rw) SYNC=sync
(cp ../boot/loader.sys ./mnt/) CREATEDIR=mkdir
(cp ../system/system.sys ./mnt/;sync) CAT=cat
(umount ./mnt)
(dd if=../boot/boot12.bin of=cos2000.img seek=0 count=1 conv=notrunc;sync) all: harddisk.img.final harddiskuefi.img.final
clean: harddiskuefi.img.before:
rm -f *.img $(COMPRESS) -d -k harddiskuefi.img.xz
$(DISKCOPY) if=harddiskuefi.img of=harddiskuefi.img.part1 skip=13672 bs=512
$(DISKCOPY) if=harddiskuefi.img of=harddiskuefi.img.before count=13672 bs=512
$(SYNC)
$(CREATEDIR) ./mnt -p
harddiskuefi.img.final: harddiskuefi.img.before
mount -t ext2 -o rw harddiskuefi.img.part1 ./mnt
$(COPY) ../system/system.sys ./mnt/boot/
$(SYNC)
umount ./mnt
cat harddiskuefi.img.before > harddiskuefi.img.final
cat harddiskuefi.img.part1 >> harddiskuefi.img.final
$(SYNC)
harddisk.img.before:
$(COMPRESS) -d -k harddisk.img.xz
$(DISKCOPY) if=harddisk.img of=harddisk.img.part1 skip=63 bs=512
$(DISKCOPY) if=harddisk.img of=harddisk.img.before count=63 bs=512
$(SYNC)
$(CREATEDIR) ./mnt -p
harddisk.img.final: harddisk.img.before
mount -t ext2 -o rw harddisk.img.part1 ./mnt
$(COPY) ../system/system.sys ./mnt/boot/
$(SYNC)
umount ./mnt
cat harddisk.img.before > harddisk.img.final
cat harddisk.img.part1 >> harddisk.img.final
$(SYNC)
littleclean:
$(REMOVE) *.final
togit: clean
clean:
$(REMOVE) *.before
$(REMOVE) *.part1
$(REMOVE) *.img
$(REMOVE) *.final

30
final/makeimage Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
dd if=/dev/zero of=harddisk.img count=10 bs=1048576
parted -s -a cylinder harddisk.img mklabel msdos
parted -s -a cylinder harddisk.img mkpart primary ext2 63s 10M
parted -s -a cylinder harddisk.img toggle 1 boot
lo=`losetup -f`
echo ${lo}
losetup -P ${lo} harddisk.img
mkfs.ext2 ${lo}p1
mount ${lo}p1 /mnt
grub-install --no-floppy --install-modules="biosdisk part_msdos ext2 configfile normal linux16 vbe png gfxmenu video video_colors video_cirrus video_fb" --boot-directory=/mnt/boot ${lo} --target=i386-pc
echo -en "\
insmod ext2
insmod biosdisk
insmod part_msdos
insmod linux
insmod vbe
insmod gfxterm
insmod png
insmod font
set timeout=4\n\
set default=0\n\
menuentry "cos2000" {\n\
set root=(hd0,1)\n\
linux16 /boot/system.sys root=hd0,2\n
boot\n\
}" > /mnt/boot/grub/grub.cfg
umount /mnt
losetup -d ${lo}
#xz -c harddisk.img > harddisk.img.xz

41
final/makeimageuefi Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash
dd if=/dev/zero of=harddiskuefi.img count=10 bs=1048576
parted -s harddiskuefi.img mklabel gpt
parted -s -a cylinder harddiskuefi.img mkpart ESP fat16 63s 7M
parted -s -a cylinder harddiskuefi.img mkpart linux ext2 7M 10M
parted -s -a cylinder harddiskuefi.img toggle 1 boot
lo=`losetup -f`
echo ${lo}
losetup -P ${lo} harddiskuefi.img
mkfs.fat -F16 -s1 ${lo}p1
mkfs.ext2 ${lo}p2
mount ${lo}p1 /mnt
mkdir /mnt/grub
echo -en "(hd0) ${lo}\n(hd0,1) ${lo}p1\n(hd0,2) ${lo}p2" > /mnt/grub/device.map
#LS MINICMD pour avoir vision paritions
grub-install --no-floppy --boot-directory=/mnt/ --efi-directory=/mnt/ ${lo} --install-modules="part_gpt ext2 configfile normal linux16 video video_colors video_cirrus video_fb videotest all_video" --locales=fr --target=x86_64-efi --no-nvram
mkdir /mnt/EFI/BOOT
cp /mnt/EFI/ubuntu/grubx64.efi /mnt/EFI/BOOT/bootx64.efi
#grub-mkimage -d /usr/lib/grub/x86_64-efi -o /mnt/EFI/BOOT/bootx64.efi -c /mnt/EFI/ubuntu/grub.cfg -p "(hd0,1)/grub/" -O x86_64-efi part_gpt ext2 configfile normal multiboot2 video video_color video_cirrus video_fb videotest all_video
echo -en "\
insmod ext2
insmod biosdisk
insmod part_msdos
insmod linux
insmod vbe
insmod gfxterm
insmod png
insmod font
set timeout=4\n\
set default=0\n\
menuentry "cos2000" {\n\
set root=(hd0,gpt2)\n\
linux16 /boot/system.sys root=hd0,gpt2\n
boot\n\
}" > /mnt/grub/grub.cfg
umount /mnt
mount ${lo}p2 /mnt
mkdir /mnt/boot/
umount /mnt
losetup -d ${lo}
xz -c harddiskuefi.img > harddiskuefi.img.xz

171
include/3d.h Executable file → Normal file
View File

@ -0,0 +1,171 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "types.h"
#include "matrix.h"
#include "video.h"
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;
} model3d __attribute__ ((packed));
typedef struct vertex3d
{
union
{
struct
{
float x;
float y;
float z;
};
float v[3];
};
} vertex3d __attribute__ ((packed));
typedef enum type3D
{
TYPE3D_POINTS,
TYPE3D_LINES,
TYPE3D_FACES,
TYPE3D_FLAT,
TYPE3D_TEXTURE,
} 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);
/*******************************************************************************/
/* Fichier 3DS */
typedef enum dsState
{
DS_READ_CHUNK_ID,
DS_READ_CHUNK_LENGTH,
DS_READ_OBJECT_NAME,
DS_SKIP_CHUNK,
DS_READ_POINT_COUNT,
DS_READ_POINTS,
DS_READ_FACE_COUNT,
DS_READ_FACES,
DS_READ_MATRIX,
DS_READ_DONE
} 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
//>------ sub defines of EDIT3DS
#define EDIT_MATERIAL 0xAFFF
#define EDIT_CONFIG1 0x0100
#define EDIT_CONFIG2 0x3E3D
#define EDIT_VIEW_P1 0x7012
#define EDIT_VIEW_P2 0x7011
#define EDIT_VIEW_P3 0x7020
#define EDIT_VIEW1 0x7001
#define EDIT_BACKGR 0x1200
#define EDIT_AMBIENT 0x2100
#define EDIT_OBJECT 0x4000
#define EDIT_UNKNW01 0x1100
#define EDIT_UNKNW02 0x1201
#define EDIT_UNKNW03 0x1300
#define EDIT_UNKNW04 0x1400
#define EDIT_UNKNW05 0x1420
#define EDIT_UNKNW06 0x1450
#define EDIT_UNKNW07 0x1500
#define EDIT_UNKNW08 0x2200
#define EDIT_UNKNW09 0x2201
#define EDIT_UNKNW10 0x2210
#define EDIT_UNKNW11 0x2300
#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)
//>------ sub defines of EDIT_OBJECT
#define OBJ_TRIMESH 0x4100
#define OBJ_LIGHT 0x4600
#define OBJ_CAMERA 0x4700
#define OBJ_UNKNWN01 0x4010
#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
//>------ sub defines of OBJ_LIGHT
#define LIT_OFF 0x4620
#define LIT_SPOT 0x4610
#define LIT_UNKNWN01 0x465A
//>------ sub defines of OBJ_TRIMESH
#define TRI_VERTEXL 0x4110
#define TRI_FACEL2 0x4111 // unknown yet
#define TRI_FACEL1 0x4120
#define TRI_SMOOTH 0x4150
#define TRI_LOCAL 0x4160
#define TRI_VISIBLE 0x4165
//>>------ sub defs of KEYF3DS
#define KEYF_UNKNWN01 0xB009
#define KEYF_UNKNWN02 0xB00A
#define KEYF_FRAMES 0xB008
#define KEYF_OBJDES 0xB002
#define KEYF_OBJHIERARCH 0xB010
#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
//>>------ these define the different color chunk types
#define COL_RGB 0x0010
#define COL_TRU 0x0011
#define COL_UNK 0x0013 // unknown
//>>------ defines for viewport chunks
#define TOP 0x0001
#define BOTTOM 0x0002
#define LEFT 0x0003
#define RIGHT 0x0004
#define FRONT 0x0005
#define BACK 0x0006
#define USER 0x0007
#define CAMERA 0x0008 // 0xFFFF is the code read from file
#define LIGHT 0x0009
#define DISABLED 0x0010
#define BOGUS 0x0011

View File

@ -1,26 +0,0 @@
/***********************************/
/* Librairie Kmemory.h */
/* 20 Mars 2007 */
/***********************************/
#ifndef JREKCED_KERNEL_MEMORY
# define JREKCED_KERNEL_MEMORY
# include "type.h"
# define MEMORY_BLOC_SIZE (1024L) /* Taille des blocs */
// Initialise les gestionnaire de memoire.
void Kernel_InitMemory (void *DataMemory, // DataMemory pointe vers la zone de memoire disponible.
UDWORD TotalMemorySize); // TotalMemorySize est la quantite total de memoire disponible.
void * Kernel_mballoc(UDWORD Size); // Alloue SIZE blocs de memoire et retourne un pointeur sur la zone.
// Retourne un pointeur nul si l'allocation est impossible.
int Kernel_mbfree (void *Adresse); // Libere le bloc memoire alloue a l'adresse ADRESSE.
// Retourne -1 si adresse incorrecte et 0 si tout s'est bien deroule.
void * Kernel_mbrealloc (void *Adresse, UDWORD Size); // Redimensionne un bloc, retourne NULL si le bloc
// n'est pas redimensionne.
#endif

View File

@ -1,85 +0,0 @@
/***********************************/
/* Librairie LDT.h */
/* 23 Mars 2007 */
/***********************************/
#ifndef JREKCED_LDT
# define JREKCED_LDT
# include "type.h"
# define LDT_BLOC_SIZE (128) /* Nombre de descripteur LDT dans un bloc */
// Types d'acces
# define GLT_ACCESSED (0x1)
# define LDT_DATA (0x0)
# define LDT_DATA_WRITE (0x2)
# define LDT_DATA_EXPAND (0x4)
# define LDT_CODE (0x8)
# define LDT_CODE_READ (0xA)
# define LDT_CODE_CONFORMING (0xD)
// Granularite
# define LDT_BYTE (0x0)
# define LDT_4KB (0x1)
// Mode du CPU
# define LDT_16BIT (0x0)
# define LDT_32BIT (0x1)
typedef struct
{
UWORD Limite_0_15; // Bit 00-15 : Limite (0-15)
UWORD Adresse_0_15; // Bit 16-31 : Adresse (0-15)
UBYTE Adresse_16_23; // Bit 32-39 : Adresse (16-23)
UBYTE Acces : 1; // 0 = System
// 1 = Code ou data
UBYTE Type : 4; // Bit 41-44 : Type
UBYTE DPL : 2; // Spécifie le niveau de privilège du segment
UBYTE Present : 1; // Indique si le segment est en mémoire (bit a 1) ou non (bit a 0)
UBYTE Limite_16_19 : 4; // Bit 48-51 : Limite (16-19)
UBYTE UserDefine : 1; // Bit 52 : Utilisation libre
UBYTE Unused : 1; // Bit 53 : Non utilise (toujours = 0)
UBYTE CPUMode : 1; // Bit 54 : = 0 -> 16-Bit
// = 1 -> 32-Bit
UBYTE Granularite : 1; // Si = 0 : Limite = 1 octet -> 1 Mo
// Si = 1 : Limite = 4 Ko -> 4 Go
UBYTE Adresse_24_31; // Bit 56-63 : Adresse (24-31)
} T_LDT;
typedef struct
{
UWORD Size; // Taille de la GDT
void * Adresse; // Adresse phisique de la GDT;
UWORD Empty;
} T_LDT_reg;
// T_LDT *GDT_BASE = ((T_LDT*)0x0800L); /* Addresse physique ou reside la GDT, le 1e element est toujours null */
T_LDT * LDT_balloc (UWORD Size); // Alloue un bloc de Size LDT
int LDT_bfree (void * Adresse); // Libere un bloc LDT
T_LDT * LDT_brealloc (T_LDT * OldLDT, UWORD NewSize); // Redimensionne un bloc LDT, retourne NULL en cas d'erreur.
T_LDT * LDT_AllocLDT (T_LDT *BaseLDT); // Cherche un LDT libre dans un bloc precedement
// alloue avec LDT_balloc.
// Retourne NULL si aucun bloc disponible.
// Si un bloc libre est trouve, il est marque comme
// utilise et un pointeur sur ce LDT est retourne.
int LDT_FreeLDT (T_LDT *LDT); // Marque le LDT comme non utilise et le met a NULL.
int LDT_MapMemory (T_LDT *LDT, void * Linear, // Met des donnees dans un LDT.
UDWORD Size, // Cette fonction est a tester.
UBYTE Granularite,
UBYTE DPL, UBYTE Type,
UBYTE CPUMode);
#endif

106
include/asm.h Executable file → Normal file
View File

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

83
include/boot.h Normal file
View File

@ -0,0 +1,83 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
/* Sources modifiées du noyau Linux linux-source-4.15.0/arch/x86/include/uapi/asm/bootparam.h
/* Sources modifiées du noyau Linux linux-source-4.15.0/arch/x86/include/asm/e820/type.h
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _BOOT
#define _BOOT
#include "types.h"
#include "gdt.h"
#define E820_MAX_ENTRIES 128
typedef struct entrye820 {
u64 addr;
u64 size;
u32 type;
} entrye820 __attribute__((packed));
typedef struct bootparams {
entrye820 e820_table[E820_MAX_ENTRIES];
u32 e820_numbers;
u8* cmdline;
u8 kbflag;
} bootparams;
enum e820_type {
E820_TYPE_RAM = 1,
E820_TYPE_RESERVED = 2,
E820_TYPE_ACPI = 3,
E820_TYPE_NVS = 4,
E820_TYPE_UNUSABLE = 5,
E820_TYPE_PMEM = 7,
E820_TYPE_PRAM = 12,
E820_TYPE_RESERVED_KERN = 128,
};
typedef struct header {
u8 setup_sects;
u16 root_flags;
u32 syssize;
u16 ram_size;
u16 vid_mode;
u16 root_dev;
u16 boot_flag;
u16 jump;
u32 header;
u16 version;
u32 realmode_swtch;
u16 start_sys_seg;
u16 kernel_version;
u8 type_of_loader;
u8 loadflags;
u16 setup_move_size;
u32 code32_start;
u32 ramdisk_image;
u32 ramdisk_size;
u32 bootsect_kludge;
u16 heap_end_ptr;
u8 ext_loader_ver;
u8 ext_loader_type;
u32 cmd_line_ptr;
u32 initrd_addr_max;
u32 kernel_alignment;
u8 relocatable_kernel;
u8 min_alignment;
u16 xloadflags;
u32 cmdline_size;
u32 hardware_subarch;
u64 hardware_subarch_data;
u32 payload_offset;
u32 payload_length;
u64 setup_data;
u64 pref_address;
u32 init_size;
u32 handover_offset;
} __attribute__((packed)) header;
#endif

73
include/cpu.h Executable file → Normal file
View File

@ -1,31 +1,46 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "interrupts.h"
typedef struct cpuinfo typedef struct cpuinfo
{ {
u8 vendor[13]; u8 vendor[13];
u8 names[32]; u8 names[32];
u8 detectedname[48]; u8 detectedname[256];
u8 techs[48]; u8 techs[256];
u8 stepping; u8 stepping;
u8 models; u8 models;
u8 family; u8 family;
u8 types; u8 types;
u8 emodels; u8 emodels;
u8 efamily; u8 efamily;
u8 apicid; u8 apicid;
u8 count; u8 count;
u8 linesize; u8 linesize;
u8 brandid; u8 brandid;
bool mmx; bool mmx;
bool mmx2; bool mmx2;
bool sse; bool sse;
bool sse2; bool sse2;
bool sse3; bool sse3;
bool fpu; bool fpu;
bool now3d; bool now3d;
bool now3d2; bool now3d2;
bool htt; bool htt;
bool apic; bool apic;
} cpuinfo __attribute__ ((packed)); bool bits64;
bool syscall;
bool msr;
u8 getcpuinfos(cpuinfo *inf); 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);
void cpuerror(const u8 * src, const regs * dump, bool returnto);

View File

@ -1,6 +0,0 @@
bool cansetflag (u32 flag);
void cpuid(u32 op, u32 *eax, u32 *ebx,u32 *ecx, u32 *edx);
void dump_regs();

View File

@ -1,42 +0,0 @@
#ifndef __TL_CTYPE_H
#define __TL_CTYPE_H
#ifdef __cplusplus
extern "C"
{
#endif
extern char g_ctype[];
#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) ((g_ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW | CT_DIG))
#define isalpha(c) ((g_ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW))
#define iscntrl(c) ((g_ctype + 1)[(unsigned)(c)] & (CT_CTL))
#define isdigit(c) ((g_ctype + 1)[(unsigned)(c)] & (CT_DIG))
#define isgraph(c) ((g_ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG))
#define islower(c) ((g_ctype + 1)[(unsigned)(c)] & (CT_LOW))
#define isprint(c) ((g_ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG | CT_SP))
#define ispunct(c) ((g_ctype + 1)[(unsigned)(c)] & (CT_PUN))
#define isspace(c) ((g_ctype + 1)[(unsigned)(c)] & (CT_WHT))
#define isupper(c) ((g_ctype + 1)[(unsigned)(c)] & (CT_UP))
#define isxdigit(c) ((g_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)
#ifdef __cplusplus
}
#endif
#endif

51
include/debug.h Normal file
View File

@ -0,0 +1,51 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "types.h"
#define opBufSz 32
#define decodeSIB() \
base = r32[*b&0x07]; \
indx = r32[(*b&0x38)>>3]; \
scale = ((*b&0xc0)>>6)*2; \
if(scale && !indx){ \
print("Invalid SIB byte."); \
return; \
}
#define setG() \
reg = (*b&0x38)>>3; \
if(!Gsz){ \
} else if(Gsz == 1){ \
G = r8[reg]; \
} else if(Gsz == 2){ \
G = r16[reg]; \
} else if(Gsz == 3){ \
G = r32[reg]; \
} else if(Gsz == 4){ \
if(reg < 8){ \
G = rseg[reg]; \
} else{ \
print("Invalid Mod R/M byte."); \
return; \
} \
} else{ \
print("Invalid Mod R/M byte."); \
return; \
}
#define DBG_EXEC 0b00
#define DBG_WRITE 0b01
#define DBG_CLEAR 0b10
#define DBG_READWRITE 0b11
#define DBG_ONEBYTE 0b00
#define DBG_TWOBYTE 0b01
#define DBG_FOURBYTE 0b11
void setdebugreg(u8 number, u8 * address, u8 type);
u8 *getdebugreg(u8 number);
u32 disasm(u8 * a, u8 * string, bool show);

99
include/gdt.h Normal file
View File

@ -0,0 +1,99 @@
#ifndef _GDT
#define _GDT
/* 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_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) */
#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_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_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_NORMAL 0b00010000 /* Segment normal pile/data/code (0 pour système) */
#ifndef __ASSEMBLY__
#include "types.h"
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;
} __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;
} __attribute__ ((packed));
void inittr(void);
void initgdt();
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);
#endif
#endif

View File

@ -1 +0,0 @@
void line(u32 x1, u32 y1, u32 x2, u32 y2, u8 color);

41
include/handlers.h Normal file
View File

@ -0,0 +1,41 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "types.h"
__attribute__ ((noreturn)) void exception_handler(regs *dump);
__attribute__((interrupt)) void interruption(exception_stack_noerror *caller);
void exception0();
void exception1();
void exception2();
void exception3();
void exception4();
void exception5();
void exception6();
void exception7();
void exception8();
void exception9();
void exception10();
void exception11();
void exception12();
void exception13();
void exception14();
void exception15();
void exception16();
void exception17();
void exception18();
__attribute__((interrupt)) void irq0(exception_stack_noerror *caller);
__attribute__((interrupt)) void irq1(exception_stack_noerror *caller);
__attribute__((interrupt)) void irq2(exception_stack_noerror *caller);
__attribute__((interrupt)) void irq3(exception_stack_noerror *caller);
__attribute__((interrupt)) void irq4(exception_stack_noerror *caller);
__attribute__((interrupt)) void irq5(exception_stack_noerror *caller);
__attribute__((interrupt)) void irq6(exception_stack_noerror *caller);
__attribute__((interrupt)) void irq7(exception_stack_noerror *caller);
__attribute__((interrupt)) void irq8(exception_stack_noerror *caller);
__attribute__((interrupt)) void irq9(exception_stack_noerror *caller);
__attribute__((interrupt)) void irq10(exception_stack_noerror *caller);
__attribute__((interrupt)) void irq11(exception_stack_noerror *caller);
__attribute__((interrupt)) void irq12(exception_stack_noerror *caller);
__attribute__((interrupt)) void irq13(exception_stack_noerror *caller);
__attribute__((interrupt)) void irq14(exception_stack_noerror *caller);
__attribute__((interrupt)) void irq15(exception_stack_noerror *caller);

View File

@ -1,31 +0,0 @@
#include "types.h"
#define INTGATE 0x8E00 /* utilise pour gerer les interruptions */
#define TRAPGATE 0x8F00 /* utilise pour faire des appels systemes */
#define TASKGATE 0x8500 /* utilise pour commuter des taches */
#define CALLGATE 0x8C00 /* utilise pour appeler du code */
#define LDTDES 0x8200 /* utilise pour pointer une LDT */
/* descripteur de segment */
typedef struct idtdes {
u16 offset0_15;
u16 select;
u16 type;
u16 offset16_31;
} idtdes __attribute__ ((packed));
void initidt(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);

373
include/interrupts.h Normal file
View File

@ -0,0 +1,373 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "types.h"
#include "asm.h"
#ifndef _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 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 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_PRESENT 0b1000000000000000 /* Segment défini (obligatoire) */
# 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 setESP(mem) ({ \
asm volatile ("movl %[frommem],%%esp;":[frommem] "=m" (mem):); \
})
# define savecpu(dump,caller,oldesp) ({\
getEBP(oldesp);\
dumpcpu();\
getESP(dump);\
caller = (exception_stack *) (oldesp + 1);\
dump->ebp = *oldesp;\
dump->eip = caller->eip;\
dump->cs = caller->cs;\
if (caller->cs==SEL_KERNEL_CODE)\
dump->esp = (u32) oldesp + sizeof(exception_stack);\
else\
{\
dump->esp = (u32) ((exception_stack_user*) caller)->esp;\
dump->ss = (u32) ((exception_stack_user*) caller)->ss;\
}\
})
# define savecpu_noerror(dump,caller,oldesp) ({\
getEBP(oldesp);\
dumpcpu();\
getESP(dump);\
caller = (exception_stack_noerror *) (oldesp + 1);\
dump->ebp = *oldesp;\
dump->eip = caller->eip;\
dump->cs = caller->cs;\
if (caller->cs==SEL_KERNEL_CODE)\
dump->esp = (u32) oldesp + sizeof(exception_stack_noerror);\
else\
{\
dump->esp = (u32) ((exception_stack_noerror_user*) caller)->esp;\
dump->ss = (u32) ((exception_stack_noerror_user*) caller)->ss;\
}\
})
# define createdump(dump) ({ \
push(dump.ss);\
push(dump.esp);\
push(dump.eflags);\
push(dump.cs);\
push(dump.eip);\
push(dump.ds);\
push(dump.es);\
push(dump.fs);\
push(dump.gs);\
push(dump.eax);\
push(dump.ebx);\
push(dump.ecx);\
push(dump.edx);\
push(dump.esi);\
push(dump.edi);\
push(dump.ebp);\
push(dump.cr0);\
push(dump.cr2);\
push(dump.cr3);\
push(dump.cr4);\
push(dump.dr0);\
push(dump.dr1);\
push(dump.dr2);\
push(dump.dr3);\
push(dump.dr6);\
push(dump.dr7);\
u32 eferlow=(u32) dump.efer & 0xFFFF;\
u32 eferhigh=(u32) dump.efer >> 32;\
push(eferlow);\
push(eferhigh);\
})
# define dumpcpu() ({ \
asm("\
pushl %%ss\n \
pushl %%esp\n \
pushf \n \
pushl %%cs\n \
pushl $0x0\n \
pushl %%ds\n \
pushl %%es\n \
pushl %%fs\n \
pushl %%gs\n \
pushl %%eax\n \
pushl %%ebx\n \
pushl %%ecx\n \
pushl %%edx\n \
pushl %%esi\n \
pushl %%edi\n \
pushl %%ebp\n \
mov %%cr0, %%eax \n \
pushl %%eax\n \
mov %%cr2, %%eax \n \
pushl %%eax\n \
mov %%cr3, %%eax \n \
pushl %%eax\n \
mov %%cr4, %%eax \n \
pushl %%eax \n \
mov %%dr0, %%eax \n \
pushl %%eax\n \
mov %%dr1, %%eax \n \
pushl %%eax\n \
mov %%dr2, %%eax \n \
pushl %%eax\n \
mov %%dr3, %%eax \n \
pushl %%eax\n \
mov %%dr6, %%eax \n \
pushl %%eax\n \
mov %%dr7, %%eax \n \
pushl %%eax\n \
mov $0xC0000080, %%ecx \n \
rdmsr \n \
pushl %%edx \n \
pushl %%eax":::);\
})
# define restcpu_kernel() ({\
asm("\
popl %%eax \n \
popl %%edx \n \
mov $0xC0000080, %%ecx \n \
wrmsr\n \
popl %%eax\n \
popl %%eax \n \
popl %%eax \n \
popl %%eax \n \
popl %%eax \n \
popl %%eax \n \
popl %%eax \n \
popl %%eax \n \
mov %%eax,%%cr3 \n \
popl %%eax \n \
popl %%eax \n \
popl %%ebp\n \
popl %%edi\n \
popl %%esi\n \
popl %%edx\n \
popl %%ecx\n \
mov 36(%%esp),%%eax\n \
mov 32(%%esp),%%ebx\n \
mov %%ebx,-4(%%eax)\n \
mov 28(%%esp),%%ebx\n \
mov %%ebx,-8(%%eax)\n \
mov 24(%%esp),%%ebx\n \
mov %%ebx,-12(%%eax)\n \
popl %%ebx\n \
popl %%eax\n \
popl %%gs\n \
popl %%fs\n \
popl %%es\n \
popl %%ds\n \
add $12,%%esp\n \
popl %%esp\n \
sub $12,%%esp\n \
iret ":::);\
})
# define restcpu_user() ({\
asm("\
popl %%eax \n \
popl %%edx \n \
mov $0xC0000080, %%ecx \n \
wrmsr\n \
popl %%eax\n \
popl %%eax \n \
popl %%eax \n \
popl %%eax \n \
popl %%eax \n \
popl %%eax \n \
popl %%eax \n \
popl %%eax \n \
mov %%eax,%%cr3 \n \
popl %%eax \n \
popl %%eax \n \
popl %%ebp\n \
popl %%edi\n \
popl %%esi\n \
popl %%edx\n \
popl %%ecx\n \
popl %%ebx\n \
popl %%eax\n \
popl %%gs\n \
popl %%fs\n \
popl %%es\n \
popl %%ds":::);\
})
/*
lors d'un iret en mode user:
pushl %%ss\n \
pushl %%esp\n \
lors d'un iret en mode kernel:
pushf \n \
pushl $cs\n \
pushl $0x0\
*/
/* save pile */
typedef struct regs
{
union {
struct {
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;
};
struct {
u32 efer_low, efer_high;
u32 dummy[13*sizeof(u32)];
u16 dx,hdx;
u16 cx,hcx;
u16 bx,hbx;
u16 ax,hax;
u16 gsl,dummy_gs;
u16 fsl,dummy_fs;
u16 esl,dummy_es;
u16 dsl,dummy_ds;
u16 ip,hip;
u16 csl,dummy_cs;
u16 flags,hflags;
u16 sp,hsp;
u16 ssl,dummy_ss;
};
struct {
u64 dummy2;
u32 dummy3[13*sizeof(u32)];
u8 dl,dh,dx2,hdx2;
u8 cl,ch,cx2,hcx2;
u8 bl,bh,bx2,hbx2;
u8 al,ah,ax2,hax2;
};
}
} regs __attribute__ ((packed));
/* exception pile depuis code kernel*/
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;
} 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;
} 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;
} 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));
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, bool returnto);
#endif

26
include/keyboard.h Executable file → Normal file
View File

@ -1,4 +1,10 @@
#define SCAN_CTRL 0x1D /*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "interrupts.h"
#define SCAN_CTRL 0x1D
#define SCAN_LEFTSHIFT 0x2A #define SCAN_LEFTSHIFT 0x2A
#define SCAN_RIGHTSHIFT 0x36 #define SCAN_RIGHTSHIFT 0x36
#define SCAN_ALT 0x38 #define SCAN_ALT 0x38
@ -20,14 +26,16 @@
/* bit de statut /* bit de statut
0x0100 est reservé pour les touches non-ASCII */ 0x0100 est reservé pour les touches non-ASCII */
#define STATUS_ALT 0x0200 #define STATUS_ALT 0x0200
#define STATUS_CTRL 0x0400 #define STATUS_CTRL 0x0400
#define STATUS_SHIFT 0x0800 #define STATUS_SHIFT 0x0800
#define STATUS_ANY (STATUS_ALT | STATUS_CTRL | STATUS_SHIFT) #define STATUS_ANY (STATUS_ALT | STATUS_CTRL | STATUS_SHIFT)
#define STATUS_CAPS 0x1000 #define STATUS_CAPS 0x1000
#define STATUS_NUM 0x2000 #define STATUS_NUM 0x2000
#define STATUS_SCRL 0x4000 #define STATUS_SCRL 0x4000
void keyboard(); __attribute__((interrupt)) void keyboard_handler(exception_stack_noerror *caller);
void outkbd(u8 port, u8 data); void reboot(void);
u8 waitascii(); void outkbd(u8 port, u8 data);
u8 waitascii(void);
u8 *getstring(u8 * temp);

32
include/math.h Executable file → Normal file
View File

@ -1,3 +1,31 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#define sgn(x) ((x<0)?-1:((x>0)?1:0)); #define sgn(x) ((x<0)?-1:((x>0)?1:0));
#define M_PI 3.14159265358979323846 //Pi
u32 abs(int x); #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);

81
include/matrix.h Normal file
View File

@ -0,0 +1,81 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#ifndef MATRIX
# define MATRIX
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];
};
} 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 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

144
include/memory.h Executable file → Normal file
View File

@ -1,6 +1,144 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#ifndef _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 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 */
/* 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
/* 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) */
/* 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) */
/* 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 MALLOC_MINIMUM 16
# define setCR3(addr) \
asm volatile ("mov %[memaddr], %%eax; mov %%eax, %%cr3"::[memaddr] "m" (addr) );
#ifndef __ASSEMBLY__
#include "types.h" #include "types.h"
#include "queue.h"
#include "boot.h"
void memset(void *dst, u8 val, u32 count,u32 size); /* Malloc, pour l'attribution de mémoire en heap */
void memcpy(void *src, void *dst, u32 count, u32 size); typedef struct tmalloc
u32 memcmp(void *src, void *dst, u32 count, u32 size); {
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 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;
/* 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 TAILQ_HEAD(vrange_s, vrange) vrange_t;
void virtual_pd_show(pd *dst);
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 initpaging();
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
#endif

14
include/mouse.h Executable file → Normal file
View File

@ -1,4 +1,10 @@
bool initmouse(); /*******************************************************************************/
void mouse(); /* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
void outmseack(u8 value); /* */
void outmsecmd(u8 command);
#include "interrupts.h"
bool initmouse(void);
__attribute__((interrupt)) void mouse_handler(exception_stack_noerror *caller);
void outmseack(u8 value);
void outmsecmd(u8 command);

50
include/pci.h Normal file
View File

@ -0,0 +1,50 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
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));
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);
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);

View File

@ -1,6 +0,0 @@
#include "types.h"
void outreg(u16 port,u8 *src,u16 num);
void outregsame(u16 port,u8 *src,u16 num);
void inreg(u16 port,u8 *src,u16 num);
void inregsame(u16 port,u8 *src,u16 num);

226
include/process.h Normal file
View File

@ -0,0 +1,226 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "types.h"
#include "interrupts.h"
#include "memory.h"
#define MAXPIDVALUE 0xFFFF
#define MAXNUMPROCESS 256
#define PROCESS_STATUS_FREE 0x0
#define PROCESS_STATUS_READY 0x1
#define PROCESS_STATUS_RUN 0x2
#define PROCESS_STATUS_SLEEP 0x3
#define PROCESS_STATUS_ALL 0xFF
#define TASK_STATUS_READY 0x0
#define TASK_STATUS_RUN 0x1
#define TASK_STATUS_STOP 0x2
#define TASK_STATUS_ALL 0xFF
/* 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
/* 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[]
/* ELF 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
/* EI signature */
#define ELFMAG0 0x7f
#define ELFMAG1 'E'
#define ELFMAG2 'L'
#define ELFMAG3 'F'
/* EI file class */
#define ELFCLASSNONE 0 /* invalid class */
#define ELFCLASS32 1 /* 32-bit objects */
#define ELFCLASS64 2 /* 64-bit objects */
/* EI data structure */
#define ELFDATANONE 0 /* invalide data encoding */
#define ELFDATA2LSB 1 /* least significant byte first (0x01020304 is 0x04 0x03 0x02 0x01) */
#define ELFDATA2MSB 2 /* most significant byte first (0x01020304 is 0x01 0x02 0x03 0x04) */
/* p type */
#define PT_NULL 0
#define PT_LOAD 1
#define PT_DYNAMIC 2
#define PT_INTERP 3
#define PT_NOTE 4
#define PT_SHLIB 5
#define PT_PHDR 6
#define PT_LOPROC 0x70000000
#define PT_HIPROC 0x7fffffff
/* p flags */
#define PF_X 0x1
#define PF_W 0x2
#define PF_R 0x4
/* OS identification */
#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;
} elf32 __attribute__ ((packed));
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 __attribute__ ((packed));
typedef unsigned int pid_t;
typedef struct tid_t
{
pid_t pid;
u32 number;
} tid_t __attribute__ ((packed));
typedef struct stack
{
u32 esp0;
u16 ss0;
} stack __attribute__ ((packed));
typedef struct task
{
tid_t tid;
stack kernel_stack;
stack syscall_stack;
u32 status;
regs dump;
TAILQ_ENTRY(task) tailq;
} task __attribute__ ((packed));
typedef TAILQ_HEAD(task_s, task) task_t;
typedef struct child
{
pid_t pid;
TAILQ_ENTRY(child) tailq;
} child __attribute__ ((packed));
typedef TAILQ_HEAD(child_s, child) child_t;
typedef struct other
{
pid_t pid;
TAILQ_ENTRY(other) tailq;
} other __attribute__ ((packed));
typedef TAILQ_HEAD(other_s, other) other_t;
typedef struct process
{
pid_t pid;
pid_t parent;
bool iskernel;
pd *pdd;
s8 priority;
u32 result;
u8 status;
u8 *exec_low;
u8 *exec_high;
u8 *bss_low;
u8 *bss_high;
page_t page_head;
task_t task_head;
child_t child_head;
other_t other_head;
u32 entry;
} process __attribute__ ((packed));
pid_t getcurrentpid(void);
pid_t getparentpid(void);
pid_t getfreepid(void);
tid_t getcurrenttid(void);
tid_t maketid(pid_t pid, u32 number);
void stop(void);
void wait(void);
pid_t fork(void);
pid_t clone(void);
pid_t exec(u8* entry, u8* args, bool kerneltask);
void switchtask(tid_t tid);
process* getnextprocess(process *aprocess, u32 status);
task* getnexttask(task* atask, u32 status);
task* getschedule(void);
task* findtask(tid_t tid);
task* findcurrenttask(void);
process* findprocess(pid_t pid);
process* findcurrentprocess(void);
task* findfirsttask(process* aprocess);
tid_t createtask(pid_t pid,u8 *entry, bool kerneltask);
void deletetask(tid_t tid);
void runtask(tid_t tid);
void stoptask(tid_t tid);
pid_t createprocess(u8 *src, bool kerneltask);
void deleteprocess(pid_t pid);
void runprocess(pid_t pid);
void stopprocess(pid_t pid);
void setpriority(pid_t pid,s8 priority);
void initprocesses(void);
u32 iself(u8 * src);
u32 loadelf(u8 * src, pid_t pid);

698
include/queue.h Normal file
View File

@ -0,0 +1,698 @@
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)queue.h 8.5 (Berkeley) 8/20/94
* $FreeBSD$
*/
#ifndef _SYS_QUEUE_H_
# define _SYS_QUEUE_H_
//#include <sys/cdefs.h>
/*
* This file defines four types of data structures: singly-linked lists,
* singly-linked tail queues, lists and tail queues.
*
* A singly-linked list is headed by a single forward pointer. The elements
* are singly linked for minimum space and pointer manipulation overhead at
* the expense of O(n) removal for arbitrary elements. New elements can be
* added to the list after an existing element or at the head of the list.
* Elements being removed from the head of the list should use the explicit
* macro for this purpose for optimum efficiency. A singly-linked list may
* only be traversed in the forward direction. Singly-linked lists are ideal
* for applications with large datasets and few or no removals or for
* implementing a LIFO queue.
*
* A singly-linked tail queue is headed by a pair of pointers, one to the
* head of the list and the other to the tail of the list. The elements are
* singly linked for minimum space and pointer manipulation overhead at the
* expense of O(n) removal for arbitrary elements. New elements can be added
* to the list after an existing element, at the head of the list, or at the
* end of the list. Elements being removed from the head of the tail queue
* should use the explicit macro for this purpose for optimum efficiency.
* A singly-linked tail queue may only be traversed in the forward direction.
* Singly-linked tail queues are ideal for applications with large datasets
* and few or no removals or for implementing a FIFO queue.
*
* A list is headed by a single forward pointer (or an array of forward
* pointers for a hash table header). The elements are doubly linked
* so that an arbitrary element can be removed without a need to
* traverse the list. New elements can be added to the list before
* or after an existing element or at the head of the list. A list
* may be traversed in either direction.
*
* A tail queue is headed by a pair of pointers, one to the head of the
* list and the other to the tail of the list. The elements are doubly
* linked so that an arbitrary element can be removed without a need to
* traverse the list. New elements can be added to the list before or
* after an existing element, at the head of the list, or at the end of
* the list. A tail queue may be traversed in either direction.
*
* For details on the use of these macros, see the queue(3) manual page.
*
*
* SLIST LIST STAILQ TAILQ
* _HEAD + + + +
* _HEAD_INITIALIZER + + + +
* _ENTRY + + + +
* _INIT + + + +
* _EMPTY + + + +
* _FIRST + + + +
* _NEXT + + + +
* _PREV - + - +
* _LAST - - + +
* _FOREACH + + + +
* _FOREACH_FROM + + + +
* _FOREACH_SAFE + + + +
* _FOREACH_FROM_SAFE + + + +
* _FOREACH_REVERSE - - - +
* _FOREACH_REVERSE_FROM - - - +
* _FOREACH_REVERSE_SAFE - - - +
* _FOREACH_REVERSE_FROM_SAFE - - - +
* _INSERT_HEAD + + + +
* _INSERT_BEFORE - + - +
* _INSERT_AFTER + + + +
* _INSERT_TAIL - - + +
* _CONCAT - - + +
* _REMOVE_AFTER + - + -
* _REMOVE_HEAD + - + -
* _REMOVE + + + +
* _SWAP + + + +
*
*/
# 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;
};
# 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 { \
(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 { \
(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 */
/*
* Singly-linked List declarations.
*/
# define SLIST_HEAD(name, type) \
struct name { \
struct type *slh_first; /* first element */ \
}
# define SLIST_HEAD_INITIALIZER(head) \
{ NULL }
# define SLIST_ENTRY(type) \
struct { \
struct type *sle_next; /* next element */ \
}
/*
* Singly-linked List functions.
*/
# define SLIST_EMPTY(head) ((head)->slh_first == NULL)
# define SLIST_FIRST(head) ((head)->slh_first)
# define SLIST_FOREACH(var, head, field) \
for ((var) = SLIST_FIRST((head)); \
(var); \
(var) = SLIST_NEXT((var), 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) \
for ((var) = SLIST_FIRST((head)); \
(var) && ((tvar) = SLIST_NEXT((var), field), 1); \
(var) = (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) \
for ((varp) = &SLIST_FIRST((head)); \
((var) = *(varp)) != NULL; \
(varp) = &SLIST_NEXT((var), field))
# define SLIST_INIT(head) do { \
SLIST_FIRST((head)) = NULL; \
} while (0)
# 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 { \
SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \
SLIST_FIRST((head)) = (elm); \
} while (0)
# define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
# 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); \
} \
else { \
struct type *curelm = SLIST_FIRST((head)); \
while (SLIST_NEXT(curelm, field) != (elm)) \
curelm = SLIST_NEXT(curelm, field); \
SLIST_REMOVE_AFTER(curelm, field); \
} \
TRASHIT(*oldnext); \
} while (0)
# 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 { \
SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
} while (0)
# 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; \
} while (0)
/*
* Singly-linked Tail queue declarations.
*/
# 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) \
{ NULL, &(head).stqh_first }
# define STAILQ_ENTRY(type) \
struct { \
struct type *stqe_next; /* next element */ \
}
/*
* Singly-linked Tail queue functions.
*/
# define STAILQ_CONCAT(head1, head2) do { \
if (!STAILQ_EMPTY((head2))) { \
*(head1)->stqh_last = (head2)->stqh_first; \
(head1)->stqh_last = (head2)->stqh_last; \
STAILQ_INIT((head2)); \
} \
} while (0)
# define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
# define STAILQ_FIRST(head) ((head)->stqh_first)
# define STAILQ_FOREACH(var, head, field) \
for((var) = STAILQ_FIRST((head)); \
(var); \
(var) = STAILQ_NEXT((var), 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) \
for ((var) = STAILQ_FIRST((head)); \
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
(var) = (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 { \
STAILQ_FIRST((head)) = NULL; \
(head)->stqh_last = &STAILQ_FIRST((head)); \
} while (0)
# 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 { \
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 { \
STAILQ_NEXT((elm), field) = NULL; \
*(head)->stqh_last = (elm); \
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
} while (0)
# 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_REMOVE(head, elm, type, field) do { \
QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \
if (STAILQ_FIRST((head)) == (elm)) { \
STAILQ_REMOVE_HEAD((head), field); \
} \
else { \
struct type *curelm = STAILQ_FIRST((head)); \
while (STAILQ_NEXT(curelm, field) != (elm)) \
curelm = STAILQ_NEXT(curelm, field); \
STAILQ_REMOVE_AFTER(head, curelm, field); \
} \
TRASHIT(*oldnext); \
} while (0)
# 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 { \
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 { \
struct type *swap_first = STAILQ_FIRST(head1); \
struct type **swap_last = (head1)->stqh_last; \
STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \
(head1)->stqh_last = (head2)->stqh_last; \
STAILQ_FIRST(head2) = swap_first; \
(head2)->stqh_last = swap_last; \
if (STAILQ_EMPTY(head1)) \
(head1)->stqh_last = &STAILQ_FIRST(head1); \
if (STAILQ_EMPTY(head2)) \
(head2)->stqh_last = &STAILQ_FIRST(head2); \
} while (0)
/*
* List declarations.
*/
# define LIST_HEAD(name, type) \
struct name { \
struct type *lh_first; /* first element */ \
}
# define LIST_HEAD_INITIALIZER(head) \
{ NULL }
# define LIST_ENTRY(type) \
struct { \
struct type *le_next; /* next element */ \
struct type **le_prev; /* address of previous next element */ \
}
/*
* List functions.
*/
# 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 { \
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 { \
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) */
# define LIST_EMPTY(head) ((head)->lh_first == NULL)
# define LIST_FIRST(head) ((head)->lh_first)
# define LIST_FOREACH(var, head, field) \
for ((var) = LIST_FIRST((head)); \
(var); \
(var) = LIST_NEXT((var), 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) \
for ((var) = LIST_FIRST((head)); \
(var) && ((tvar) = LIST_NEXT((var), field), 1); \
(var) = (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 { \
LIST_FIRST((head)) = NULL; \
} while (0)
# 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 = \
&LIST_NEXT((elm), field); \
LIST_NEXT((listelm), field) = (elm); \
(elm)->field.le_prev = &LIST_NEXT((listelm), field); \
} while (0)
# 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); \
*(listelm)->field.le_prev = (elm); \
(listelm)->field.le_prev = &LIST_NEXT((elm), field); \
} while (0)
# 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);\
LIST_FIRST((head)) = (elm); \
(elm)->field.le_prev = &LIST_FIRST((head)); \
} while (0)
# define LIST_NEXT(elm, field) ((elm)->field.le_next)
# 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 { \
QMD_SAVELINK(oldnext, (elm)->field.le_next); \
QMD_SAVELINK(oldprev, (elm)->field.le_prev); \
QMD_LIST_CHECK_NEXT(elm, field); \
QMD_LIST_CHECK_PREV(elm, field); \
if (LIST_NEXT((elm), field) != NULL) \
LIST_NEXT((elm), field)->field.le_prev = \
(elm)->field.le_prev; \
*(elm)->field.le_prev = LIST_NEXT((elm), field); \
TRASHIT(*oldnext); \
TRASHIT(*oldprev); \
} while (0)
# 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; \
if ((swap_tmp = LIST_FIRST((head1))) != NULL) \
swap_tmp->field.le_prev = &LIST_FIRST((head1)); \
if ((swap_tmp = LIST_FIRST((head2))) != NULL) \
swap_tmp->field.le_prev = &LIST_FIRST((head2)); \
} while (0)
/*
* Tail queue declarations.
*/
# 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) \
{ NULL, &(head).tqh_first, TRACEBUF_INITIALIZER }
# define TAILQ_ENTRY(type) \
struct { \
struct type *tqe_next; /* next element */ \
struct type **tqe_prev; /* address of previous next element */ \
TRACEBUF \
}
/*
* Tail queue functions.
*/
# 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 { \
if (*(head)->tqh_last != NULL) \
panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \
} while (0)
# 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 { \
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) */
# 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; \
(head1)->tqh_last = (head2)->tqh_last; \
TAILQ_INIT((head2)); \
QMD_TRACE_HEAD(head1); \
QMD_TRACE_HEAD(head2); \
} \
} while (0)
# define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
# define TAILQ_FIRST(head) ((head)->tqh_first)
# define TAILQ_FOREACH(var, head, field) \
for ((var) = TAILQ_FIRST((head)); \
(var); \
(var) = TAILQ_NEXT((var), 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) \
for ((var) = TAILQ_FIRST((head)); \
(var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
(var) = (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) \
for ((var) = TAILQ_LAST((head), headname); \
(var); \
(var) = TAILQ_PREV((var), 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) \
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) \
for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
(var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
(var) = (tvar))
# 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 { \
QMD_TAILQ_CHECK_NEXT(listelm, field); \
if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
TAILQ_NEXT((elm), field)->field.tqe_prev = \
&TAILQ_NEXT((elm), field); \
else { \
(head)->tqh_last = &TAILQ_NEXT((elm), field); \
QMD_TRACE_HEAD(head); \
} \
TAILQ_NEXT((listelm), field) = (elm); \
(elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \
QMD_TRACE_ELEM(&(elm)->field); \
QMD_TRACE_ELEM(&listelm->field); \
} while (0)
# 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); \
*(listelm)->field.tqe_prev = (elm); \
(listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \
QMD_TRACE_ELEM(&(elm)->field); \
QMD_TRACE_ELEM(&listelm->field); \
} while (0)
# 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 = \
&TAILQ_NEXT((elm), field); \
else \
(head)->tqh_last = &TAILQ_NEXT((elm), field); \
TAILQ_FIRST((head)) = (elm); \
(elm)->field.tqe_prev = &TAILQ_FIRST((head)); \
QMD_TRACE_HEAD(head); \
QMD_TRACE_ELEM(&(elm)->field); \
} while (0)
# 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; \
*(head)->tqh_last = (elm); \
(head)->tqh_last = &TAILQ_NEXT((elm), field); \
QMD_TRACE_HEAD(head); \
QMD_TRACE_ELEM(&(elm)->field); \
} while (0)
# define TAILQ_LAST(head, headname) \
(*(((struct headname *)((head)->tqh_last))->tqh_last))
# define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
# define TAILQ_PREV(elm, headname, field) \
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
# 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); \
QMD_TAILQ_CHECK_PREV(elm, field); \
if ((TAILQ_NEXT((elm), field)) != NULL) \
TAILQ_NEXT((elm), field)->field.tqe_prev = \
(elm)->field.tqe_prev; \
else { \
(head)->tqh_last = (elm)->field.tqe_prev; \
QMD_TRACE_HEAD(head); \
} \
*(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
TRASHIT(*oldnext); \
TRASHIT(*oldprev); \
QMD_TRACE_ELEM(&(elm)->field); \
} while (0)
# 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; \
(head1)->tqh_last = (head2)->tqh_last; \
(head2)->tqh_first = swap_first; \
(head2)->tqh_last = swap_last; \
if ((swap_first = (head1)->tqh_first) != NULL) \
swap_first->field.tqe_prev = &(head1)->tqh_first; \
else \
(head1)->tqh_last = &(head1)->tqh_first; \
if ((swap_first = (head2)->tqh_first) != NULL) \
swap_first->field.tqe_prev = &(head2)->tqh_first; \
else \
(head2)->tqh_last = &(head2)->tqh_first; \
} while (0)
#endif /* !_SYS_QUEUE_H_ */

97
include/setup.h Normal file
View File

@ -0,0 +1,97 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
/* Sources modifiées du noyau Linux linux-source-4.15.0/arch/x86/include/uapi/asm/bootparam.h
/* Sources modifiées du noyau Linux linux-source-4.15.0/arch/x86/include/asm/e820/type.h
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#include "types.h"
#include "gdt.h"
#include "boot.h"
typedef struct miniregs {
union {
struct {
u32 eax;
u32 ebx;
u32 ecx;
u32 edx;
u32 esi;
u32 edi;
u32 ebp;
u32 eflags;
};
struct {
u16 ax, hax;
u16 bx, hbx;
u16 cx, hcx;
u16 dx, hdx;
u16 si, hsi;
u16 di, hdi;
u16 bp, hbp;
u16 flags, hflags;
};
struct {
u8 al, ah, hax2, hax3;
u8 bl, bh, hbx2, hbx3;
u8 cl, ch, hcx2, hcx3;
u8 dl, dh, hdx2, hdx3;
};
};
} miniregs __attribute__ ((packed));
#define STRINGIFY(x) #x
#define MACRO(x) STRINGIFY(x)
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
#define EFLAGS_CF 0x00000001
#define LOOPS_8042 100000
#define FF_8042 32
#define LOOPS_A20_ENABLE 255
#define LOOPS_DELAY 32768
#define SMAP 0x534d4150
#define interrupt(num, regs) ({\
asm("mov %[eflagsregs],%%eax\n\
pushl %%eax\n\
popfl\n\
mov %[eaxregs],%%eax\n\
mov %[ebxregs],%%ebx\n\
mov %[ecxregs],%%ecx\n\
mov %[edxregs],%%edx\n\
mov %[esiregs],%%esi\n\
mov %[ediregs],%%edi\n\
int %[numregs]\n\
pushfl\n\
popl %[eflagsregs]\n\
mov %%eax,%[eaxregs]\n\
mov %%ebx,%[ebxregs]\n\
mov %%ecx,%[ecxregs]\n\
mov %%edx,%[edxregs]\n\
mov %%esi,%[esiregs]\n\
mov %%edi,%[ediregs]":[eaxregs] "+m" (regs.eax),[ebxregs] "+m" (regs.ebx),[ecxregs] "+m" (regs.ecx),[edxregs] "+m" (regs.edx),[esiregs] "+m" (regs.esi),[ediregs] "+m" (regs.edi),[eflagsregs] "+m" (regs.eflags):[numregs] "i" (num):"%eax","%ebx","%ecx","%edx","%esi","%edi");})
void cleanreg(miniregs *reg);
u8 initmemory(void);
void showchar(u8 achar);
void showstr(u8 *str);
u8 gettime(void);
u8 waitchar(void);
void initkeyboard(void);
u8 empty8042(void);
void iodelay(void);
u8 testA20(void);
void enableA20kbc(void);
void enableA20fast(void);
u8 enableA20(void);
void memcpyto(void *src, void *dst, u32 count);
void makegdtdes(u32 base, u32 limite, u8 acces, u8 flags, gdtdes * desc);
void initgdt();
void maskinterrupts(void);
void initcoprocessor(void);
void initpmode();
void main(void);

33
include/shell.h Normal file
View File

@ -0,0 +1,33 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
typedef struct command
{
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 testtask();
int ps();

23
include/stdarg.h Executable file → Normal file
View File

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

33
include/string.h Executable file → Normal file
View File

@ -1,8 +1,29 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "types.h" #include "types.h"
s8 strcmp(const u8 *src,const u8 *des); s8 strcmp(const u8 * src, const u8 * des);
u32 strlen(const u8 *src); u32 strlen(const u8 * src);
u8 *strchr(const u8 *src, u8 achar); u8 *strchr(const u8 * src, u8 achar);
u8 *strncpy(const u8 *src,u8 *des,u32 count); u8 *strncpy(const u8 * src, u8 * des, u32 count);
u8 *strcat(const u8 *src,u8 *des); u8 *strcat(const u8 * src, u8 * des);
u8* strcpy(const u8 *src, u8 *des); u8 *strcpy(const u8 * src, u8 * des);
void strtolower(u8 * src);
void 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);

51
include/syscall.h Normal file
View File

@ -0,0 +1,51 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#define sysexit() asm volatile ("sysexit"::);
#define syscall0(syscall) ({ \
u32 _v; \
asm volatile (\
"mov %%esp,%%ecx;\
mov $1f,%%edx;\
sysenter;\
1:" : "=a" (_v) : "a" (syscall): "ecx","edx","memory"); \
_v; \
})
#define syscall1(syscall,arg1) ({ \
u32 _v; \
asm volatile (\
"mov %%esp,%%ecx;\
mov $1f,%%edx;\
sysenter;\
1:" : "=a" (_v) : "a" (syscall), "b" (arg1) : "ecx","edx","memory"); \
_v; \
})
#define syscall2(syscall,arg1,arg2) ({ \
u32 _v; \
asm volatile (\
"mov %%esp,%%ecx;\
mov $1f,%%edx;\
sysenter;\
1:" : "=a" (_v) : "a" (syscall), "b" (arg1), "S" (arg2) : "ecx","edx","memory"); \
_v; \
})
#define syscall3(syscall,arg1,arg2,arg3) ({ \
u32 _v; \
asm volatile (\
"mov %%esp,%%ecx;\
mov $1f,%%edx;\
sysenter;\
1:" : "=a" (_v) : "a" (syscall), "b" (arg1), "S" (arg2), "D" (arg3) : "ecx","edx","memory"); \
_v; \
})
/* Vers 6 arguments maximum */
void initsyscall(void);
__attribute__ ((noreturn)) void sysenter_handler(regs *dump);

7
include/system.h Normal file
View File

@ -0,0 +1,7 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "boot.h";
extern restart;

8
include/timer.h Executable file → Normal file
View File

@ -1 +1,7 @@
void timer(); /*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "interrupts.h"
__attribute__ ((noreturn)) void timer_handler(regs *dump);

View File

@ -1,31 +0,0 @@
/***********************************/
/* Librairie Type.h */
/* 20 Mars 2007 */
/***********************************/
#ifndef JREKCED_TYPE
# define JREKCED_TYPE
# define NULL (0x0LL)
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;
#endif

110
include/types.h Executable file → Normal file
View File

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

49
include/vesa.h Normal file
View File

@ -0,0 +1,49 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "types.h"
#include "video.h"
#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();
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
};

175
include/vga.h Executable file → Normal file
View File

@ -1,37 +1,148 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "types.h" #include "types.h"
#include "video.h"
#define TEXTSCREEN 0xB8000 /* debut de la memoire video texte*/ #define TEXTSCREEN 0xB8000 /* debut de la memoire video texte */
#define GRPHSCREEN 0xA0000 /* debut de la memoire video graphique*/ #define GRPHSCREEN 0xA0000 /* debut de la memoire video graphique */
#define ENDOFVMEM 0xC0000
typedef u8 mode_def[64]; /* Registres VGAs */
#define SEQUENCER 0x3c4
#define MISC_WRITE 0x3c2
#define MISC_READ 0x3cc
#define CCRT 0x3D4
#define ATTRIBS 0x3c0
#define GRAPHICS 0x3ce
#define STATE 0x3da
u32 setvmode(u8); /* Taille d'un plan de bit */
u32 loadfont(u8* def,u8 size,u8 font);
void gotoscr(u16 x,u16 y); #define PLANESIZE 0x10000
void useplane(u8 plan);
u8 getfont(); /* Registres VGA */
void setfont(u8 num); typedef struct misc_regs
void waitvretrace (void); {
void waithretrace (void); u8 Miscellaneous_Output_Register;
void enablecursor (void); } misc_regs __attribute__ ((packed));
void disablecursor (void);
void enablescroll (void); typedef struct sequencer_regs
void disablescroll (void); {
void (*writepxl)(u16 x, u16 y, u32 c); u8 Reset_Register;
void (*showchar)(u16 coordx,u16 coordy,u8 thechar,u8 attrib); u8 Clocking_Mode_Register;
void (*fill)(u8 attrib); u8 Map_Mask_Register;
void (*scroll)(u8 lines,u8 attrib); u8 Character_Map_Select_Register;
void split(u16 x); u8 Sequencer_Memory_Mode_Register;
void showpage(u8 page); } sequencer_regs __attribute__ ((packed));
u8 getpage();
void setpage(u8 page); typedef struct crtc_regs
u16 getnbpages(); {
u16 getyres(); u8 Horizontal_Total_Register;
u8 getdepth(); u8 End_Horizontal_Display_Register;
u16 getxres(); u8 Start_Horizontal_Blanking_Register;
u8 getfont2(); u8 End_Horizontal_Blanking_Register;
void enableblink(); u8 Start_Horizontal_Retrace_Register;
void disableblink(); u8 End_Horizontal_Retrace_Register;
u8 (*getchar)(u16 coordx,u16 coordy); u8 Vertical_Total_Register;
u8 (*getattrib)(u16 coordx,u16 coordy); 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;
} 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;
} attributs_regs __attribute__ ((packed));
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);
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
};

199
include/video.h Executable file → Normal file
View File

@ -1,19 +1,188 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
typedef struct console { #ifndef VIDEO
u8 attrib; # define VIDEO
s16 cursX;
s16 cursY;
u8 ansi;
u8 param1;
u8 param2;
u8 param3;
u8 page;
} console __attribute__ ((packed));
# include "stdarg.h"
void showhex(u8 src); # define MAXDRIVERS 10
void putchar(u8 thechar); # define MAXFONTS 10
void print(u8* string);
void printf (const u8 *string, ...);
void changevc(u8 vc);
typedef struct vertex2d
{
s16 x;
s16 y;
} vertex2d __attribute__ ((packed));
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;
} 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) ();
} videofonction __attribute__ ((packed));
typedef struct drivers
{
u8 *nom;
videofonction *pointer;
} drivers __attribute__ ((packed));
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;
} 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));
/* 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);
/* 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);
/* 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);
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);
/* 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);
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);
#endif

34231
lib/3D/man.c Normal file

File diff suppressed because it is too large Load Diff

2947
lib/3D/sphere.c Normal file

File diff suppressed because it is too large Load Diff

285
lib/3d.c Executable file → Normal file
View File

@ -1,5 +1,280 @@
#include "3d.h" /*******************************************************************************/
#include "vga.h" /* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
#include "types.h" /* */
#include "video.h" #include "3d.h"
#include "graph.h" #include "types.h"
#include "video.h"
#include "string.h"
/*******************************************************************************/
/* Crée une projection simple pour test */
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);
}
}
/*******************************************************************************/
/* Crée une liste de vertex3D pour un cube */
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;
}
/*******************************************************************************/
/* Affiche un modèle 3D */
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;
}
}
/*******************************************************************************/
/* Charge un fichier 3DS */
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)
{
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,259 +0,0 @@
/* Police de caract鑽e fine 8x16 */
static u8 font8x16 [4096] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7E, 0x81, 0xA5, 0x81, 0x81, 0xBD, 0x99, 0x81, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7E, 0xFF, 0xDB, 0xFF, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x36, 0x7F, 0x7F, 0x7F, 0x7F, 0x3E, 0x1C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x3E, 0x1C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x3C, 0x3C, 0xE7, 0xE7, 0xE7, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x7E, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
0x00, 0x00, 0x0F, 0x07, 0x0D, 0x19, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3F, 0x33, 0x3F, 0x30, 0x30, 0x30, 0x70, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7F, 0x63, 0x7F, 0x63, 0x63, 0x63, 0x67, 0xE7, 0xE6, 0xC0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0xDB, 0x3C, 0xE7, 0x3C, 0xDB, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x40, 0x60, 0x70, 0x7C, 0x7F, 0x7C, 0x70, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x03, 0x07, 0x1F, 0x7F, 0x1F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7F, 0xDB, 0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3E, 0x63, 0x30, 0x1C, 0x36, 0x63, 0x63, 0x36, 0x1C, 0x06, 0x63, 0x3E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x7E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0C, 0x06, 0x7F, 0x06, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x7F, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x60, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x24, 0x66, 0xFF, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x3E, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7F, 0x7F, 0x3E, 0x3E, 0x1C, 0x1C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x24, 0x24, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x42, 0x42, 0x42, 0xFF, 0x42, 0x42, 0x42, 0xFF, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x7E, 0x90, 0x90, 0x90, 0x7C, 0x12, 0x12, 0x12, 0xFC, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x61, 0x91, 0x92, 0x64, 0x08, 0x10, 0x26, 0x49, 0x89, 0x86, 0x00, 0x00, 0x00, 0x00,
0x00, 0x70, 0x88, 0x88, 0x88, 0x50, 0x60, 0x91, 0x8A, 0x84, 0x4A, 0x31, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x18, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x06, 0x18, 0x20, 0x40, 0x40, 0x40, 0x40, 0x40, 0x20, 0x18, 0x06, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x18, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x10, 0x92, 0x54, 0x38, 0xFE, 0x38, 0x54, 0x92, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0xFE, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x10, 0x20, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x83, 0x85, 0x89, 0x91, 0xA1, 0xC1, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x30, 0x50, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x01, 0x02, 0x3C, 0x40, 0x80, 0x80, 0x80, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x01, 0x02, 0x3C, 0x02, 0x01, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0x06, 0x0A, 0x12, 0x22, 0x42, 0x82, 0xFF, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFF, 0x80, 0x80, 0x80, 0xFC, 0x02, 0x01, 0x01, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x80, 0xBC, 0xC2, 0x81, 0x81, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFF, 0x81, 0x01, 0x02, 0x04, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x81, 0x42, 0x3C, 0x42, 0x81, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x81, 0x43, 0x3D, 0x01, 0x01, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x10, 0x20, 0x00, 0x00,
0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x44, 0x82, 0x82, 0x04, 0x08, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x99, 0xA5, 0xA5, 0xA5, 0x9E, 0x80, 0x41, 0x3E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x24, 0x42, 0x81, 0x81, 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFC, 0x42, 0x41, 0x41, 0x42, 0x7C, 0x42, 0x41, 0x41, 0x42, 0xFC, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x81, 0x80, 0x80, 0x80, 0x80, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFC, 0x42, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0xFC, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFF, 0x80, 0x80, 0x80, 0x80, 0xFC, 0x80, 0x80, 0x80, 0x80, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFF, 0x80, 0x80, 0x80, 0x80, 0xFC, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x81, 0x80, 0x9F, 0x81, 0x81, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x82, 0x82, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00,
0x00, 0x81, 0x82, 0x84, 0x88, 0x90, 0xE0, 0x90, 0x88, 0x84, 0x82, 0x81, 0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x81, 0xC3, 0xA5, 0x99, 0x99, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00,
0x00, 0x81, 0xC1, 0xA1, 0x91, 0x89, 0x85, 0x83, 0x81, 0x81, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFC, 0x82, 0x81, 0x81, 0x82, 0xFC, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x81, 0x81, 0x81, 0x81, 0x89, 0x85, 0x42, 0x3D, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFC, 0x82, 0x81, 0x81, 0x82, 0xFC, 0x90, 0x88, 0x84, 0x82, 0x81, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x80, 0x40, 0x3C, 0x02, 0x01, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFE, 0x92, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x81, 0x81, 0x81, 0x81, 0x81, 0x42, 0x42, 0x24, 0x24, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x99, 0x99, 0xA5, 0xA5, 0x42, 0x00, 0x00, 0x00, 0x00,
0x00, 0x81, 0x81, 0x81, 0x42, 0x24, 0x18, 0x24, 0x42, 0x81, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00,
0x00, 0x82, 0x82, 0x82, 0x82, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFF, 0x01, 0x01, 0x02, 0x04, 0x18, 0x20, 0x40, 0x80, 0x80, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7E, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x24, 0x42, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x08, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x02, 0x02, 0x7E, 0x82, 0x82, 0x7D, 0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0x80, 0x80, 0x80, 0xBC, 0xC2, 0x81, 0x81, 0x81, 0xC2, 0xBC, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x80, 0x80, 0x80, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x01, 0x01, 0x01, 0x3D, 0x43, 0x81, 0x81, 0x81, 0x43, 0x3D, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x81, 0xFF, 0x80, 0x40, 0x3E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0E, 0x11, 0x10, 0x10, 0xFE, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3D, 0x43, 0x81, 0x81, 0x43, 0x3D, 0x01, 0x02, 0x7C, 0x00, 0x00,
0x00, 0x80, 0x80, 0x80, 0x80, 0xBC, 0xC2, 0x81, 0x81, 0x81, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x08, 0x08, 0x00, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x02, 0x02, 0x00, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x82, 0x44, 0x38, 0x00, 0x00,
0x00, 0x80, 0x80, 0x80, 0x80, 0x82, 0x84, 0x88, 0x90, 0xA8, 0xC4, 0x82, 0x00, 0x00, 0x00, 0x00,
0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xEC, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xB8, 0xC4, 0x82, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x81, 0x81, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xBC, 0xC2, 0x81, 0x81, 0x81, 0xC2, 0xBC, 0x80, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3D, 0x43, 0x81, 0x81, 0x81, 0x43, 0x3D, 0x01, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xBE, 0xC1, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x81, 0x80, 0x7E, 0x01, 0x81, 0x7E, 0x00, 0x00, 0x00, 0x00,
0x10, 0x10, 0x10, 0x10, 0x10, 0xFE, 0x10, 0x10, 0x10, 0x10, 0x11, 0x0E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x81, 0x81, 0x81, 0x81, 0x43, 0x3D, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x81, 0x81, 0x81, 0x42, 0x24, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x82, 0x92, 0x92, 0x92, 0xAA, 0x44, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x42, 0x24, 0x18, 0x24, 0x42, 0x81, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x81, 0x81, 0x81, 0x43, 0x3D, 0x01, 0x02, 0x7C, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x04, 0x18, 0x20, 0x40, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x04, 0x08, 0x10, 0x10, 0x10, 0x20, 0x10, 0x10, 0x10, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x20, 0x10, 0x10, 0x10, 0x08, 0x10, 0x10, 0x10, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x70, 0x99, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x36, 0x63, 0x63, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1E, 0x33, 0x61, 0x60, 0x60, 0x61, 0x33, 0x1E, 0x06, 0x03, 0x3E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x66, 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x06, 0x0C, 0x18, 0x00, 0x3E, 0x63, 0x7F, 0x60, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x08, 0x1C, 0x36, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x66, 0x66, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0x18, 0x0C, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1C, 0x36, 0x1C, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x60, 0x66, 0x3C, 0x0C, 0x06, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x08, 0x1C, 0x36, 0x00, 0x3E, 0x63, 0x7F, 0x60, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x66, 0x66, 0x00, 0x3E, 0x63, 0x7F, 0x60, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0x18, 0x0C, 0x00, 0x3E, 0x63, 0x7F, 0x60, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x66, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x3C, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x63, 0x63, 0x08, 0x1C, 0x36, 0x63, 0x63, 0x7F, 0x63, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1C, 0x36, 0x1C, 0x00, 0x1C, 0x36, 0x63, 0x63, 0x7F, 0x63, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0C, 0x18, 0x30, 0x00, 0x7F, 0x33, 0x30, 0x3E, 0x30, 0x33, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x6E, 0x3B, 0x1B, 0x7E, 0xD8, 0xDC, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1F, 0x36, 0x66, 0x66, 0x7F, 0x66, 0x66, 0x66, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x08, 0x1C, 0x36, 0x00, 0x3E, 0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x63, 0x63, 0x00, 0x3E, 0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0x18, 0x0C, 0x00, 0x3E, 0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x3C, 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0x18, 0x0C, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x63, 0x63, 0x00, 0x63, 0x63, 0x63, 0x63, 0x3F, 0x03, 0x06, 0x3C, 0x00, 0x00, 0x00,
0x00, 0x63, 0x63, 0x1C, 0x36, 0x63, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x63, 0x63, 0x00, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x18, 0x7E, 0xC3, 0xC0, 0xC0, 0xC3, 0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1C, 0x36, 0x32, 0x30, 0x78, 0x30, 0x30, 0x30, 0x73, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xC3, 0x66, 0x3C, 0x18, 0xFF, 0x18, 0xFF, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFC, 0x66, 0x66, 0x7C, 0x62, 0x66, 0x6F, 0x66, 0x66, 0xF3, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0E, 0x1B, 0x18, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x18, 0x18, 0xD8, 0x70, 0x00, 0x00, 0x00,
0x00, 0x0C, 0x18, 0x30, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0C, 0x18, 0x30, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0C, 0x18, 0x30, 0x00, 0x3E, 0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0C, 0x18, 0x30, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3B, 0x6E, 0x00, 0x6E, 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3B, 0x6E, 0x00, 0x63, 0x73, 0x7B, 0x7F, 0x6F, 0x67, 0x63, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x6C, 0x6C, 0x3E, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x30, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0xE0, 0x63, 0x66, 0x6C, 0x18, 0x30, 0x6E, 0xC3, 0x06, 0x0C, 0x1F, 0x00, 0x00, 0x00,
0x00, 0x60, 0xE0, 0x63, 0x66, 0x6C, 0x18, 0x33, 0x67, 0xCF, 0x1F, 0x03, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x3C, 0x3C, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1B, 0x36, 0x6C, 0x36, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x6C, 0x36, 0x1B, 0x36, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x00, 0x00,
0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x00, 0x00,
0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xF6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x18, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0xF6, 0x06, 0xF6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x06, 0xF6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0xF6, 0x06, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0xF7, 0x00, 0xF7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xFF, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0x18, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00,
0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3B, 0x6E, 0x6C, 0x6C, 0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3E, 0x63, 0x7E, 0x63, 0x63, 0x7E, 0x60, 0x60, 0x20, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7F, 0x63, 0x63, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7F, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7F, 0x63, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x63, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x6C, 0x6C, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3B, 0x6E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7E, 0x18, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1C, 0x36, 0x63, 0x63, 0x7F, 0x63, 0x63, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x36, 0x36, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1E, 0x30, 0x18, 0x0C, 0x3E, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0xDB, 0xDB, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0x06, 0x7E, 0xDB, 0xDB, 0xF3, 0x7E, 0x60, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1C, 0x30, 0x60, 0x60, 0x7C, 0x60, 0x60, 0x30, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3E, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0x18, 0xFF, 0x18, 0x18, 0x18, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x30, 0x18, 0x0C, 0x06, 0x0C, 0x18, 0x30, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0C, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0C, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0E, 0x1B, 0x1B, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xD8, 0xD8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3B, 0x6E, 0x00, 0x3B, 0x6E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0F, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0xEC, 0x6C, 0x3C, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xD8, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x70, 0xD8, 0x30, 0x60, 0xC8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

View File

@ -1,131 +0,0 @@
/* Police de caract鑽e 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,156 +0,0 @@
/***********************************/
/* Librairie Kmemory.c */
/* 20 Mars 2007 */
/***********************************/
#include <type.h>
#include <Kmemory.h>
/* Structure table d'allocation memoire */
typedef struct
{
UBYTE Used : 1; // = 0 -> La zone memoire est libre.
// = 1 -> La zone memoire est utilisee.
UBYTE Expand : 1; // = 0 -> Fin du bloc.
// = 1 -> Le bloc se prolonge sur le bloc suivant.
UBYTE UnUsed : 6; // Zone libre.
} T_KernelMemoryMap;
T_KernelMemoryMap * BlocAllocate = NULL; // Table d'allocation des blocs memoire.
void * BaseDynAlloc = NULL; // Pointeur sur la zone memoire allouable.
UDWORD MaxMemoryBlocs;
// Initialisation du gestionnaire de memoire.
void Kernel_InitMemory (void *DataMemory, UDWORD TotalMemorySize)
{
UDWORD Boucle;
UDWORD TableBlocs;
UDWORD TotalBlocs;
// Alignement des bloc de memoire a un multiple de MEMORY_BLOC_SIZE
if ( (UDWORD)DataMemory % MEMORY_BLOC_SIZE != 0)
{ DataMemory = ((void*) ((((UDWORD)DataMemory) / MEMORY_BLOC_SIZE) * MEMORY_BLOC_SIZE) + MEMORY_BLOC_SIZE ); };
TotalBlocs = (((void*)TotalMemorySize) - DataMemory) / MEMORY_BLOC_SIZE;
TableBlocs = TotalBlocs / MEMORY_BLOC_SIZE;
MaxMemoryBlocs = TotalBlocs - TableBlocs;
BlocAllocate = (T_KernelMemoryMap *)DataMemory;
BaseDynAlloc = DataMemory + (TableBlocs * MEMORY_BLOC_SIZE);
for (Boucle = 0; Boucle < MaxMemoryBlocs; Boucle++)
{
BlocAllocate [Boucle].Used = 0;
BlocAllocate [Boucle].Expand = 0;
}
}
// Alloue SIZE blocs de memoire
void * Kernel_mballoc(UDWORD Size)
{
UDWORD Counter = 0;
UDWORD Base = 0;
UDWORD Boucle, Boucle2;
if (Size == 0) return NULL;
for (Boucle = 0; Boucle < MaxMemoryBlocs; Boucle++)
{
if (BlocAllocate[Boucle].Used == 0) { Counter++; }
else { Counter = 0; Base = Boucle + 1; }
if (Counter >= Size)
{
if (Base+Size > MaxMemoryBlocs) return NULL;
for (Boucle2=Base; Boucle2 < (Base+Size); Boucle2++)
{
BlocAllocate[Boucle2].Used = 1;
if (Boucle2+1 < (Base+Size) ) { BlocAllocate[Boucle2].Expand = 1; }
else { BlocAllocate[Boucle2].Expand = 0; }
}
return ((void*) (BaseDynAlloc + (Base * MEMORY_BLOC_SIZE) ));
}
}
return NULL;
}
// Libere un bloc memoire
int Kernel_mbfree (void *Adresse)
{
UDWORD Bloc;
if (((Adresse - BaseDynAlloc) % MEMORY_BLOC_SIZE) != 0) return -1;
if ((((UDWORD)Adresse) % MEMORY_BLOC_SIZE) != 0) return -1;
Bloc = (Adresse - BaseDynAlloc) / MEMORY_BLOC_SIZE;
for (; BlocAllocate[Bloc].Expand == 1; Bloc++)
{
BlocAllocate[Bloc].Used = 0;
BlocAllocate[Bloc].Expand = 0;
}
BlocAllocate[Bloc].Used = 0;
BlocAllocate[Bloc].Expand = 0;
return 0;
};
void * Kernel_mbrealloc (void *Adresse, UDWORD Size)
{
UDWORD Bloc, Boucle, OldSize, CopySize;
void * NewAdresse;
if (((Adresse - BaseDynAlloc) % MEMORY_BLOC_SIZE) != 0) return NULL;
Bloc = (Adresse - BaseDynAlloc) / MEMORY_BLOC_SIZE;
if (BlocAllocate[Bloc].Used == 0) return NULL;
for (Boucle = Bloc; BlocAllocate[Boucle].Expand == 1; Boucle++)
{ if (Boucle >= MaxMemoryBlocs) break; };
OldSize = Boucle - Bloc + 1;
// Si pas de changement de taille de bloc, ...
if ( Size == OldSize) return Adresse;
// Si on reduit le nombre de bloc, ...
if ( Size < OldSize)
{
for (Boucle = (Bloc + Size); Boucle < (Bloc + OldSize) ; Boucle++)
{
BlocAllocate[Boucle].Used = 0;
BlocAllocate[Boucle].Expand = 0;
}
BlocAllocate[Size-1].Expand = 0;
return Adresse;
}
// Si on augmente le nombre de bloc
for (Boucle = (Bloc + OldSize); Boucle < (Bloc + Size) ; Boucle++)
{
// Si le bloc ne peut etre simplement agrandit, ...
if ( BlocAllocate[Boucle].Used == 1 )
{
NewAdresse = Kernel_mballoc (Size);
if (NewAdresse == NULL) return NULL;
CopySize = (OldSize * MEMORY_BLOC_SIZE) / sizeof (int64);
for (Boucle = 0; Boucle < CopySize; Boucle++)
{ ((int64*) NewAdresse)[Boucle] = ((int64*) Adresse)[Boucle]; };
Kernel_mbfree (Adresse);
return NewAdresse;
}
}
// Le bloc est simplement agrandit
for (Boucle = (Bloc + OldSize - 1); Boucle < (Bloc + Size) ; Boucle++)
{
BlocAllocate[Boucle].Used = 1;
BlocAllocate[Boucle].Expand = 1;
}
BlocAllocate[Size-1].Expand = 0;
return Adresse;
}
#undef MAX_MEMORY_BLOCS

236
lib/LDT.c
View File

@ -1,236 +0,0 @@
/***********************************/
/* Librairie LDT.c */
/* 23 Mars 2007 */
/***********************************/
#include "LDT.h"
#include "Kmemory.h"
# define LDT_MANAGER_SIZE (127)
typedef struct // Structure de gestion des bloc LDT
{
void * Next; // Pointeur de chainage
UDWORD Empty;
T_LDT_reg LDTdesc [LDT_MANAGER_SIZE]; // Nombre de blocs LDT
} T_LDT_Manager;
void LDT_initalloc (void *AllocTable, UDWORD Index, UDWORD SetSize, UDWORD TotalSize);
T_LDT_Manager * LDT_mballoc (UWORD Size);
/////////////////////////////////////////////////////////////////////////
T_LDT_Manager * LDT_Manager = NULL;
/////////////////////////////////////////////////////////////////////////
T_LDT * LDT_balloc (UWORD Size) // Alloue un bloc de Size LDT
{
UWORD Boucle;
UDWORD Blocs, Boucle2;
T_LDT_Manager * * ptr_Manager = &LDT_Manager;
T_LDT_Manager * Manager = LDT_Manager;
do
{
if (* ptr_Manager == NULL)
{
* ptr_Manager = Kernel_mballoc (1);
Manager = * ptr_Manager;
Manager->Next = NULL;
for (Boucle = 0; Boucle < LDT_MANAGER_SIZE; Boucle++)
{
Manager->LDTdesc [Boucle].Adresse = NULL;
Manager->LDTdesc [Boucle].Size = NULL;
}
}
for (Boucle = 0; Boucle < LDT_MANAGER_SIZE; Boucle++)
{
if (Manager->LDTdesc [Boucle].Adresse == NULL)
{
Blocs = Size * sizeof(T_LDT);
if (Blocs % MEMORY_BLOC_SIZE == 0)
{ Blocs /= MEMORY_BLOC_SIZE; } else { Blocs = (Blocs / MEMORY_BLOC_SIZE) + 1; }
Manager->LDTdesc [Boucle].Adresse = Kernel_mballoc (Blocs);
if (Manager->LDTdesc [Boucle].Adresse == NULL) return NULL;
Manager->LDTdesc [Boucle].Size = (Blocs * MEMORY_BLOC_SIZE) / sizeof(T_LDT);
// Mise a zero de la LDT
for (Boucle2 = 0; Boucle2 < Manager->LDTdesc [Boucle].Size; Boucle2++)
{ ((int64*) Manager->LDTdesc [Boucle].Adresse)[Boucle2] = NULL; }
return Manager->LDTdesc [Boucle].Adresse;
}
}
*ptr_Manager = Manager;
Manager = Manager->Next;
} while (1);
}
int LDT_bfree (void * Adresse) // Libere un bloc LDT
{
UWORD Boucle, Boucle2;
int RetVal;
T_LDT_Manager * * ptr_Manager = &LDT_Manager;
T_LDT_Manager * Manager = LDT_Manager;
do
{
if (*ptr_Manager == NULL) { return -1; }
for (Boucle = 0; Boucle < LDT_MANAGER_SIZE; Boucle++)
{
if (Manager->LDTdesc [Boucle].Adresse == Adresse)
{
RetVal = Kernel_mbfree(Manager->LDTdesc [Boucle].Adresse);
if (Boucle == 0)
{
Kernel_mbfree (*ptr_Manager);
*ptr_Manager = NULL;
return RetVal;
}
else
{
for (Boucle2 = Boucle; Boucle2 < LDT_MANAGER_SIZE-1; Boucle2++)
{ Manager->LDTdesc [Boucle2] = Manager->LDTdesc [Boucle2+1]; }
Manager->LDTdesc [Boucle2+1].Size = NULL;
Manager->LDTdesc [Boucle2+1].Adresse = NULL;
}
Manager->LDTdesc [LDT_MANAGER_SIZE-1].Size = NULL;
Manager->LDTdesc [LDT_MANAGER_SIZE-1].Adresse = NULL;
return RetVal;
}
}
*ptr_Manager = Manager;
Manager = Manager->Next;
} while (1);
}
T_LDT * LDT_brealloc (T_LDT * OldLDT, UWORD NewSize)
{
T_LDT * NewLDT;
UDWORD Blocs;
UWORD Boucle;
T_LDT_Manager * * ptr_Manager = &LDT_Manager;
T_LDT_Manager * Manager = LDT_Manager;
Blocs = NewSize * sizeof(T_LDT);
if (Blocs % MEMORY_BLOC_SIZE == 0)
{ Blocs /= MEMORY_BLOC_SIZE; } else { Blocs = (Blocs / MEMORY_BLOC_SIZE) + 1; }
do
{
if (*ptr_Manager == NULL) { return NULL; }
for (Boucle = 0; Boucle < LDT_MANAGER_SIZE; Boucle++)
{
if (Manager->LDTdesc [Boucle].Adresse == OldLDT)
{
NewLDT = Kernel_mbrealloc (OldLDT, Blocs);
if (NewLDT == NULL) return NULL;
Manager->LDTdesc [Boucle].Adresse = NewLDT;
Manager->LDTdesc [Boucle].Size = NewSize;
return NewLDT;
}
}
*ptr_Manager = Manager;
Manager = Manager->Next;
} while (1);
}
///////////////////////////////////////////////////////////////////////
T_LDT * LDT_AllocLDT (T_LDT *BaseLDT)
{
UWORD Boucle;
UDWORD Boucle2;
UDWORD Size;
T_LDT_Manager * Manager = LDT_Manager;
if (BaseLDT == NULL) return NULL;
do
{
if (Manager == NULL) { return NULL; }
for (Boucle = 0; Boucle < LDT_MANAGER_SIZE; Boucle++)
{
Size = Manager->LDTdesc [Boucle].Size;
if (Manager->LDTdesc [Boucle].Adresse == ((void*)BaseLDT) )
{
for (Boucle2 = 1; Boucle2 < Size; Boucle2++) // Le 1e LDT reste null
{
if ( BaseLDT[Boucle2].UserDefine == 0 )
{
BaseLDT[Boucle2].UserDefine = 1;
return BaseLDT+Boucle2;
};
}
return NULL;
}
}
Manager = Manager->Next;
} while (1);
}
int LDT_FreeLDT (T_LDT *LDT) // Marque le LDT comme non utilise et le met a NULL
{
if ( ((UDWORD)LDT & 0x07L) != NULL) { return -2; }
if (LDT->UserDefine == 0) { return -1; }
*((int64*)LDT) = NULL;
return 0;
}
///////////////////////////////////////////////////////////////////////
int LDT_MapMemory (T_LDT *LDT, void * Linear, UDWORD Size, UBYTE Granularite, UBYTE DPL, UBYTE Type, UBYTE CPUMode)
{
if ( ((UDWORD)LDT & 0x07L) != NULL) { return -2; }
LDT->Adresse_0_15 = (DWORD)Linear & 0x0000FFFFL;
LDT->Adresse_16_23 = ((DWORD)Linear >> 16) & 0x000000FFL;
LDT->Adresse_24_31 = ((DWORD)Linear >> 24) & 0x000000FFL;
LDT->Limite_0_15 = Size & 0x0000FFFFL;
LDT->Limite_16_19 = (Size >> 16) & 0x0000000FL;
LDT->Granularite = Granularite;
LDT->Type = Type;
LDT->DPL = DPL;
LDT->CPUMode = CPUMode;
LDT->Present = 1;
LDT->UserDefine = 1;
return 0;
}
int LDT_load (T_LDT *LDT)
{
UWORD Boucle;
T_LDT_Manager * * ptr_Manager = &LDT_Manager;
T_LDT_Manager * Manager = LDT_Manager;
do
{
if (*ptr_Manager == NULL) { return -1; }
for (Boucle = 0; Boucle < LDT_MANAGER_SIZE; Boucle++)
{
if (Manager->LDTdesc [Boucle].Adresse == LDT)
{
asm("lgdt %0\n" : : "m" (Manager->LDTdesc [Boucle]));
return 0;
}
}
*ptr_Manager = Manager;
Manager = Manager->Next;
} while (1);
}

196
lib/PCI/class.c Normal file
View File

@ -0,0 +1,196 @@
static pciclass old[] = {
{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}
};
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}
};
static pciclass display[] = {
{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}
};
static pciclass memory[] = {
{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}
};
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}
};
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}
};
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}
};
static pciclass docking[] = {
{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}
};
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}
};
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}
};
static pciclass intelliio[] = {
{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}
};
static pciclass crypto[] = {
{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}
};
static pciclass *classcodes[] = {
old,
storage,
network,
display,
multimedia,
memory,
bridge,
simplecomm,
baseperiph,
input,
docking,
processor,
serial,
wireless,
intelliio,
satcomm,
crypto,
dasp,
[255] = NULL
};

0
lib/keymap.c → lib/TEST/NE PAS DETRUIRE Executable file → Normal file
View File

673
lib/VGA/8x16fnt.c Normal file
View File

@ -0,0 +1,673 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
/* Police de caractère fine 8x16 */
static u8 font8x16[4096] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7E, 0x81, 0xA5, 0x81, 0x81, 0xBD, 0x99, 0x81, 0x7E,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7E, 0xFF, 0xDB, 0xFF, 0xFF, 0xC3, 0xE7, 0xFF,
0x7E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x36, 0x7F, 0x7F, 0x7F, 0x7F, 0x3E,
0x1C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x3E,
0x1C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x3C, 0x3C, 0xE7, 0xE7,
0xE7, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x3C, 0x7E, 0xFF,
0xFF, 0x7E, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
0x00,
0x00, 0x00, 0x00,
0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
0xFF, 0xFF,
0xFF, 0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF, 0xFF, 0xFF,
0xFF, 0x00, 0x00,
0x00,
0x00, 0x0F, 0x07, 0x0D, 0x19, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x3F, 0x33, 0x3F, 0x30, 0x30, 0x30, 0x70, 0xF0, 0xE0,
0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x7F, 0x63, 0x7F, 0x63, 0x63, 0x63, 0x67, 0xE7, 0xE6,
0xC0, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0xDB, 0x3C, 0xE7, 0x3C, 0xDB, 0x18, 0x18,
0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x40, 0x60, 0x70, 0x7C, 0x7F, 0x7C, 0x70, 0x60, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x03, 0x07, 0x1F, 0x7F, 0x1F, 0x07, 0x03,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x7E,
0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
0x00, 0x33, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7F, 0xDB, 0xDB, 0xDB, 0x7B,
0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3E, 0x63, 0x30, 0x1C, 0x36,
0x63, 0x63, 0x36, 0x1C, 0x06, 0x63, 0x3E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x3C,
0x7E, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x7E, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x18,
0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x0C, 0x06, 0x7F, 0x06, 0x0C, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x7F, 0x30, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x60, 0x7F, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x24, 0x66, 0xFF, 0x66, 0x24, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x3E, 0x7F, 0x7F, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7F, 0x7F, 0x3E, 0x3E, 0x1C, 0x1C, 0x08, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00,
0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x24, 0x24, 0x24, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x42, 0x42, 0x42, 0xFF, 0x42, 0x42,
0x42, 0xFF, 0x42, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x7E, 0x90, 0x90, 0x90,
0x7C, 0x12, 0x12, 0x12, 0xFC, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x61, 0x91, 0x92,
0x64, 0x08, 0x10, 0x26, 0x49, 0x89, 0x86, 0x00, 0x00, 0x00, 0x00,
0x00, 0x70, 0x88, 0x88,
0x88, 0x50, 0x60, 0x91, 0x8A, 0x84, 0x4A, 0x31, 0x00, 0x00, 0x00,
0x00,
0x00, 0x18, 0x18,
0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x06,
0x18, 0x20, 0x40, 0x40, 0x40, 0x40, 0x40, 0x20, 0x18, 0x06, 0x00,
0x00, 0x00, 0x00,
0x00,
0x60, 0x18, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, 0x18, 0x60,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x10, 0x92, 0x54, 0x38, 0xFE, 0x38, 0x54, 0x92, 0x10,
0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0xFE, 0x10, 0x10, 0x10, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
0x18, 0x10,
0x20, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40,
0x80, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x83, 0x85, 0x89, 0x91, 0xA1, 0xC1,
0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x30, 0x50, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x7C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x01, 0x02, 0x3C,
0x40, 0x80, 0x80, 0x80, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x01, 0x02,
0x3C, 0x02, 0x01, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0x06, 0x0A, 0x12,
0x22, 0x42, 0x82, 0xFF, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFF, 0x80, 0x80,
0x80, 0xFC, 0x02, 0x01, 0x01, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00,
0x00,
0x00, 0x3C, 0x42,
0x81, 0x80, 0xBC, 0xC2, 0x81, 0x81, 0x81, 0x42, 0x3C, 0x00, 0x00,
0x00, 0x00,
0x00, 0xFF,
0x81, 0x01, 0x02, 0x04, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00,
0x00, 0x00, 0x00,
0x00,
0x3C, 0x42, 0x81, 0x81, 0x42, 0x3C, 0x42, 0x81, 0x81, 0x42, 0x3C,
0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x81, 0x43, 0x3D, 0x01, 0x01, 0x81, 0x42,
0x3C, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18,
0x18, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18,
0x18, 0x10,
0x20, 0x00, 0x00,
0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, 0x04,
0x02,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10,
0x20, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x44, 0x82, 0x82, 0x04, 0x08, 0x10, 0x10,
0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x99, 0xA5, 0xA5, 0xA5,
0x9E, 0x80, 0x41, 0x3E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x24, 0x42, 0x81, 0x81, 0xFF,
0x81, 0x81, 0x81, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFC, 0x42, 0x41, 0x41, 0x42,
0x7C, 0x42, 0x41, 0x41, 0x42, 0xFC, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x81,
0x80, 0x80, 0x80, 0x80, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFC, 0x42, 0x41,
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0xFC, 0x00, 0x00, 0x00,
0x00,
0x00, 0xFF, 0x80,
0x80, 0x80, 0x80, 0xFC, 0x80, 0x80, 0x80, 0x80, 0xFF, 0x00, 0x00,
0x00, 0x00,
0x00, 0xFF,
0x80, 0x80, 0x80, 0x80, 0xFC, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00,
0x00, 0x00, 0x00,
0x00,
0x3C, 0x42, 0x81, 0x81, 0x80, 0x9F, 0x81, 0x81, 0x81, 0x42, 0x3C,
0x00, 0x00, 0x00, 0x00,
0x00, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, 0x81, 0x81, 0x81, 0x81,
0x81, 0x00, 0x00, 0x00,
0x00,
0x00, 0x38, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x38, 0x00, 0x00,
0x00, 0x00,
0x00, 0x07, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x82, 0x82, 0x44,
0x38, 0x00,
0x00, 0x00, 0x00,
0x00, 0x81, 0x82, 0x84, 0x88, 0x90, 0xE0, 0x90, 0x88, 0x84, 0x82,
0x81,
0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x81, 0xC3, 0xA5, 0x99, 0x99, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0x00, 0x00, 0x00, 0x00,
0x00, 0x81, 0xC1, 0xA1, 0x91, 0x89, 0x85, 0x83, 0x81,
0x81, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFC, 0x82, 0x81, 0x81, 0x82, 0xFC,
0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81, 0x81, 0x81,
0x81, 0x81, 0x89, 0x85, 0x42, 0x3D, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFC, 0x82, 0x81, 0x81,
0x82, 0xFC, 0x90, 0x88, 0x84, 0x82, 0x81, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x42, 0x81,
0x80, 0x40, 0x3C, 0x02, 0x01, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00,
0x00,
0x00, 0xFE, 0x92,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00,
0x00, 0x00,
0x00, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x42, 0x3C, 0x00,
0x00, 0x00, 0x00,
0x00,
0x81, 0x81, 0x81, 0x81, 0x81, 0x42, 0x42, 0x24, 0x24, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00,
0x00, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x99, 0x99, 0xA5, 0xA5,
0x42, 0x00, 0x00, 0x00,
0x00,
0x00, 0x81, 0x81, 0x81, 0x42, 0x24, 0x18, 0x24, 0x42, 0x81, 0x81,
0x81, 0x00, 0x00,
0x00, 0x00,
0x00, 0x82, 0x82, 0x82, 0x82, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10,
0x10, 0x00,
0x00, 0x00, 0x00,
0x00, 0xFF, 0x01, 0x01, 0x02, 0x04, 0x18, 0x20, 0x40, 0x80, 0x80,
0xFF,
0x00, 0x00, 0x00, 0x00,
0x00, 0x7E, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
0x7E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02,
0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
0x02, 0x02, 0x7E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x24, 0x42, 0x81, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x08, 0x04, 0x02, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x7C, 0x02, 0x02, 0x7E, 0x82, 0x82, 0x7D, 0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0x80, 0x80,
0x80, 0xBC, 0xC2, 0x81, 0x81, 0x81, 0xC2, 0xBC, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x3C, 0x42, 0x80, 0x80, 0x80, 0x42, 0x3C, 0x00, 0x00,
0x00, 0x00,
0x00, 0x01,
0x01, 0x01, 0x01, 0x3D, 0x43, 0x81, 0x81, 0x81, 0x43, 0x3D, 0x00,
0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x81, 0xFF, 0x80, 0x40, 0x3E,
0x00, 0x00, 0x00, 0x00,
0x00, 0x0E, 0x11, 0x10, 0x10, 0xFE, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3D, 0x43, 0x81, 0x81, 0x43, 0x3D,
0x01, 0x02, 0x7C,
0x00, 0x00,
0x00, 0x80, 0x80, 0x80, 0x80, 0xBC, 0xC2, 0x81, 0x81, 0x81, 0x81,
0x81, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x08, 0x08, 0x00, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08,
0x3E,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x02, 0x02, 0x00, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02,
0x82, 0x44, 0x38, 0x00, 0x00,
0x00, 0x80, 0x80, 0x80, 0x80, 0x82, 0x84, 0x88, 0x90, 0xA8,
0xC4, 0x82, 0x00, 0x00, 0x00, 0x00,
0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x08, 0x08, 0x3E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xEC, 0x92, 0x92,
0x92, 0x92, 0x92, 0x92, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xB8, 0xC4,
0x82, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3C,
0x42, 0x81, 0x81, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0xBC, 0xC2, 0x81, 0x81, 0x81, 0xC2, 0xBC, 0x80, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x3D, 0x43, 0x81, 0x81, 0x81, 0x43, 0x3D, 0x01, 0x01, 0x00,
0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0xBE, 0xC1, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00, 0x7E, 0x81, 0x80, 0x7E, 0x01, 0x81, 0x7E, 0x00,
0x00, 0x00, 0x00,
0x10,
0x10, 0x10, 0x10, 0x10, 0xFE, 0x10, 0x10, 0x10, 0x10, 0x11, 0x0E,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x81, 0x81, 0x81, 0x81, 0x43,
0x3D, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x81, 0x81, 0x81, 0x42, 0x24,
0x18, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x82, 0x92, 0x92, 0x92, 0xAA,
0x44, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x42, 0x24, 0x18, 0x24, 0x42,
0x81,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x81, 0x81, 0x81, 0x43, 0x3D,
0x01, 0x02, 0x7C, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x04, 0x18, 0x20,
0x40, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x04, 0x08, 0x10, 0x10, 0x10, 0x20, 0x10, 0x10,
0x10, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x10,
0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x20, 0x10, 0x10, 0x10, 0x08,
0x10, 0x10, 0x10, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x70, 0x99, 0x0E, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x08,
0x1C, 0x36, 0x63, 0x63, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1E, 0x33,
0x61, 0x60, 0x60, 0x61, 0x33, 0x1E, 0x06, 0x03, 0x3E, 0x00, 0x00,
0x00,
0x00, 0x00, 0x66,
0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3B, 0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x06,
0x0C, 0x18, 0x00, 0x3E, 0x63, 0x7F, 0x60, 0x63, 0x3E, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00,
0x08, 0x1C, 0x36, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x66, 0x66, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, 0x3B,
0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x30, 0x18, 0x0C, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, 0x3B,
0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x1C, 0x36, 0x1C, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, 0x3B,
0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x60, 0x66, 0x3C, 0x0C, 0x06,
0x3C,
0x00, 0x00, 0x00, 0x00,
0x00, 0x08, 0x1C, 0x36, 0x00, 0x3E, 0x63, 0x7F, 0x60, 0x63, 0x3E,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x66, 0x66, 0x00, 0x3E, 0x63, 0x7F, 0x60, 0x63,
0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0x18, 0x0C, 0x00, 0x3E, 0x63, 0x7F, 0x60,
0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x66, 0x66, 0x00, 0x38, 0x18, 0x18,
0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x3C, 0x66, 0x00, 0x38, 0x18,
0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x30, 0x18, 0x00, 0x38,
0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x63, 0x63, 0x08, 0x1C,
0x36, 0x63, 0x63, 0x7F, 0x63, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1C, 0x36, 0x1C, 0x00,
0x1C, 0x36, 0x63, 0x63, 0x7F, 0x63, 0x63, 0x00, 0x00, 0x00, 0x00,
0x00,
0x0C, 0x18, 0x30,
0x00, 0x7F, 0x33, 0x30, 0x3E, 0x30, 0x33, 0x7F, 0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x6E, 0x3B, 0x1B, 0x7E, 0xD8, 0xDC, 0x77, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00,
0x00, 0x1F, 0x36, 0x66, 0x66, 0x7F, 0x66, 0x66, 0x66, 0x67, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x08, 0x1C, 0x36, 0x00, 0x3E, 0x63, 0x63, 0x63, 0x63, 0x3E,
0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x63, 0x63, 0x00, 0x3E, 0x63, 0x63, 0x63, 0x63, 0x3E,
0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x30, 0x18, 0x0C, 0x00, 0x3E, 0x63, 0x63, 0x63, 0x63, 0x3E,
0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x18, 0x3C, 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3B,
0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0x18, 0x0C, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3B,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x63, 0x63, 0x00, 0x63, 0x63, 0x63, 0x63, 0x3F,
0x03, 0x06, 0x3C, 0x00, 0x00, 0x00,
0x00, 0x63, 0x63, 0x1C, 0x36, 0x63, 0x63, 0x63, 0x63,
0x36, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x63, 0x63, 0x00, 0x63, 0x63, 0x63, 0x63,
0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x18, 0x7E, 0xC3, 0xC0, 0xC0,
0xC3, 0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1C, 0x36, 0x32, 0x30, 0x78,
0x30, 0x30, 0x30, 0x73, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xC3, 0x66, 0x3C,
0x18, 0xFF, 0x18, 0xFF, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFC, 0x66, 0x66,
0x7C, 0x62, 0x66, 0x6F, 0x66, 0x66, 0xF3, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x0E, 0x1B,
0x18, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x18, 0x18, 0xD8, 0x70, 0x00,
0x00, 0x00,
0x00, 0x0C,
0x18, 0x30, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00,
0x0C, 0x18, 0x30, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x0C, 0x18, 0x30, 0x00, 0x3E, 0x63, 0x63, 0x63, 0x63, 0x3E,
0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x0C, 0x18, 0x30, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3B,
0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x3B, 0x6E, 0x00, 0x6E, 0x33, 0x33, 0x33, 0x33, 0x33,
0x00, 0x00,
0x00, 0x00, 0x00,
0x3B, 0x6E, 0x00, 0x63, 0x73, 0x7B, 0x7F, 0x6F, 0x67, 0x63, 0x63,
0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x3C, 0x6C, 0x6C, 0x3E, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x7C, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x30, 0x63,
0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x60,
0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F,
0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0xE0, 0x63, 0x66, 0x6C,
0x18, 0x30, 0x6E, 0xC3, 0x06, 0x0C, 0x1F, 0x00, 0x00, 0x00,
0x00, 0x60, 0xE0, 0x63, 0x66,
0x6C, 0x18, 0x33, 0x67, 0xCF, 0x1F, 0x03, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18,
0x00, 0x18, 0x18, 0x3C, 0x3C, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00,
0x00, 0x1B, 0x36, 0x6C, 0x36, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x6C, 0x36, 0x1B, 0x36, 0x6C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x11,
0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44,
0x11, 0x44, 0x00, 0x00,
0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55,
0xAA, 0x55, 0xAA, 0x00,
0x00,
0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD,
0x77, 0xDD, 0x77,
0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18,
0x18, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18,
0x18,
0x18, 0x18, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0xF8, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xF6, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x18, 0xF8,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0xF6, 0x06,
0xF6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0xFE, 0x06, 0xF6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36,
0x36, 0xF6, 0x06, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
0x18, 0x18,
0x18, 0x18, 0x18, 0xF8, 0x18, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x18, 0x18, 0x18,
0x18, 0x18,
0x18, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x18, 0x18,
0x18,
0x18, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x1F, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30,
0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3F,
0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36,
0xF7, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0xFF, 0x00, 0xF7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00,
0x00,
0x36, 0x36, 0x36,
0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x36,
0x36, 0x36, 0x36, 0x36, 0xF7, 0x00, 0xF7, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x18, 0x18, 0x18,
0x18, 0x18,
0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x36, 0x36, 0x36,
0x36,
0x36, 0x36, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3F, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x1F, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x1F, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0xFF, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0xFF,
0x18, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1F, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00,
0x00,
0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0x00, 0x00,
0xF0,
0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
0xF0, 0xF0, 0x00, 0x00,
0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
0x0F, 0x0F, 0x0F, 0x00,
0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3B, 0x6E, 0x6C, 0x6C, 0x6E, 0x3B,
0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3E, 0x63, 0x7E, 0x63, 0x63, 0x7E, 0x60,
0x60,
0x20, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7F, 0x63, 0x63, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7F, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7F, 0x63, 0x30, 0x18, 0x0C, 0x18, 0x30,
0x63, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x6C, 0x6C,
0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33,
0x33, 0x3E, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3B, 0x6E,
0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7E, 0x18, 0x3C,
0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1C, 0x36,
0x63, 0x63, 0x7F, 0x63, 0x63, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x1C,
0x36, 0x63, 0x63, 0x63, 0x36, 0x36, 0x36, 0x77, 0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x1E, 0x30, 0x18, 0x0C, 0x3E, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x7E, 0xDB, 0xDB, 0x7E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0x06, 0x7E, 0xDB, 0xDB, 0xF3, 0x7E, 0x60, 0xC0,
0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x1C, 0x30, 0x60, 0x60, 0x7C, 0x60, 0x60, 0x30, 0x1C,
0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00, 0x3E, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x7F, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0x18, 0xFF, 0x18, 0x18, 0x18, 0x00, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x30, 0x18, 0x0C, 0x06, 0x0C, 0x18, 0x30, 0x00,
0x7E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0C, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0C,
0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0E, 0x1B, 0x1B, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0xD8, 0xD8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0x00, 0x00,
0xFF, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3B,
0x6E, 0x00, 0x3B, 0x6E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x6C, 0x6C,
0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00,
0x0F, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0xEC, 0x6C, 0x3C, 0x1C, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0xD8, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x70, 0xD8, 0x30, 0x60, 0xC8, 0xF8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00
};

336
lib/VGA/8x8fnt.c Normal file
View File

@ -0,0 +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
};

33
lib/VGA/ansi.c Normal file
View File

@ -0,0 +1,33 @@
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\
\xB3\033[0m \033[1;36m\xDB\xDB\xDB\xDB\xDB\xDF\033[0;36m\xDF\033[1m\xDF\xDB\033[0;36m\xDF\033[1m\xDF\033[0;36m\xDF\xDF\xDF\xDF\xDF\033[1;37m\xDC\xDC\xDC\033[47m\xDF\033[0m\xDB\xDB\033[1;47;30m\xDF\033[40m\xDC\xDC\xDC\033[0;36m\xDF\xDF\xDF\033[1;37m\xDC\xDC\033[47m\xDF\033[0m\xDB\xDB\xDB\xDB\033[1;47;30m\xDF\033[40m\xDC\xDC\033[0;36m\xDF\xDF\033[37m \033[36m\xDF\xDF\033[1;37m\xDC\xDC\033[47m\xDF\033[0m\xDB\xDB\xDB\xDB\033[1;47;30m\xDF\033[40m\xDC\xDC\033[0m \033[36m\xDF\xDF\xDF\xDF\xDF\033[1m\xDF\033[0;36m\xDF\033[1m\xDB\xDF\033[0;36m\xDF\033[1m\xDF\xDB\xDB\xDB\xDB\033[0m \033[1;30m\xB3\r\n\
\xB3\033[0m \033[1;36m\xDB\xDB\xDF\033[0m\033[5C\033[1;36m\xFA \033[37m\xDC\033[47m\xDF\xDF\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDF\xDF\033[40m\xDC\033[37m\xDF\033[47m\xDC\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDF\033[40m\xDC\033[0m \033[1;36m \033[37m\xDC\033[47m\xDF\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDF\033[40m\xDC\033[0m\033[6C\033[1;36m\xDE \xDF\xDB\xDB\033[0m \033[1;30m\xB3\r\n\
\xB3\033[0m \033[1;36m\xDB\033[0m\033[7C\033[1;36m\xFE \033[37m\xDB\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\033[1;30m\xDB \033[47;37m\xDB\033[0m\xDB\xDB\033[1;47m\xDC\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\033[1;30m\xDB \033[36m \033[37m\xDB\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDE\033[40m\xDD \033[0m \033[1;30m \033[36m\xFE\033[0m\033[6C\033[1;36m\xDB\033[0m \033[1;30m\xB3\r\n\
\xB3\033[0m \033[1;36m\xDE\033[0m\033[10C\033[1m\xDB\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDC\033[40m\xDF \033[37m\xDF\033[47m\xDC\033[0m\xDB\xDB\xDB\033[1;47;30m\xDC\033[40m\xDF\033[37m\xDC\033[47m\xDF\033[0m\xDB\033[1;47;30m\xDC\033[40m\xDF\033[37m\xDE\033[47m\xDD\033[0m\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDF\033[40m\xDC\033[0m \033[1m\xDB\033[0m\xDB\xDB\xDB\xDB\xDB\033[1;30m\xDC\033[37m\xDF\033[47m\xDC\033[0m\xDB\xDB\xDB\xDB\033[1;47;30m\xDE\033[40m\xDD\033[0m\033[12C\033[1;36m\xDE\033[0m \033[1;30m\xB3\r\n\
\xB3\033[0m \033[1;36m\xFE\033[0m\033[9C\033[1m\xDE\033[47m\xDD\033[0m\xDB\xDB\xDB\xDB\xDB\033[1;30m\xDB\033[0m\033[6C\033[1m\xDF\033[0m\xDF\033[1;30m\xDF\033[37m\xDC\033[47m\xDF\033[0m\xDB\xDB\xDB\033[1;30m\xDB \033[37m\xDB\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\033[1;30m\xDB\033[0m \033[1m\xDB\033[0m\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDF\033[40m\xDC\033[37m\xDF\033[47m\xDC\033[30m\xDC\033[40m\xDF\xDF\033[0m\033[13C\033[1;36m\xFA\033[0m \033[1;30m\xB3\r\n\
\xB3\033[0m\033[13C\033[1m\xDB\033[0m\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDE\033[40m\xDD\033[0m\033[9C\033[1m\xDB\033[0m\xDB\xDB\xDB\xDB\033[1;30m\xDB \033[37m\xDB\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\033[1;30m\xDB\033[0m \033[1;30m \033[37m\xDC\xDF\033[47m\xDC\033[0m\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDF\033[40m\xDC\033[0m\033[16C\033[1;36m\xFE\033[0m \033[1;30m\xB3\r\n\
\xB3\033[0m\033[13C\033[1m\xDE\033[47m\xDD\033[0m\xDB\xDB\xDB\xDB\xDB\033[1;30m\xDB\033[0m\033[6C\033[1m\xDC\033[0m\xDC\033[1;30m\xDC\033[37m\xDF\033[47m\xDC\033[0m\xDB\xDB\xDB\033[1;47;30m\xDE\033[40m\xDD \033[37m\xDB\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\033[1;30m\xDB\033[37m\xDC\033[47m\xDF\033[0m\xDB\033[1;47;30m\xDF\033[40m\xDC\033[37m\xDF\033[47m\xDC\033[0m\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDF\033[40m\xDC\033[0m\033[17C\033[1;30m\xB3\r\n\
\xB3\033[0m\033[14C\033[1m\xDB\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDF\033[40m\xDC \033[37m\xDC\033[47m\xDF\033[0m\xDB\xDB\xDB\033[1;47;30m\xDF\033[40m\xDC\033[37m\xDF\033[47m\xDC\033[0m\xDB\033[1;47;30m\xDE\033[40m\xDD\033[37m\xDB\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDC\033[40m\xDF\033[0m\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDF\033[40m\xDC\033[37m\xDF\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\033[1;30m\xDB\033[0m\033[16C\033[1;30m\xB3\r\n\
\xB3\033[0m\033[15C\033[1m\xDB\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\033[1;30m\xDB \033[37m\xDB\033[0m\xDB\033[1;47;30m\xDF\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\xDB\033[1;30m\xDB \033[0m\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDE\033[40m\xDD\033[0m\033[15C\033[1;30m\xB3\r\n\
\xB3\033[0m\033[16C\033[1m\xDF\033[47m\xDC\xDC\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDC\xDC\033[40m\xDF\033[37m\xDC\033[47m\xDF\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDC\033[40m\xDF\033[0m \033[1;47m\xDC\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDC\033[40m\xDF\033[0m\033[16C\033[1;30m\xB3\r\n\
\xB3\033[0m\033[19C\033[1m\xDF\xDF\xDF\033[47m\xDC\033[0m\xDB\xDB\033[1;47;30m\xDC\033[40m\xDF\xDF\xDF\033[0m \033[1m\xDF\xDF\033[47m\xDC\033[0m\xDB\xDB\xDB\xDB\033[1;47;30m\xDC\033[40m\xDF\xDF\033[0m\033[5C\033[1m\xDF\xDF\033[47m\xDC\033[0m\xDB\xDB\xDB\xDB\xDB\xDB\033[1;47;30m\xDC\033[40m\xDF\xDF\033[0m\033[18C\033[1;30m\xB3\r\n\
\xB3\033[0m\033[77C\033[1;30m\xB3\r\n\
\xB3\033[0m\033[77C\033[1;30m\xB3\r\n\
\xB3\033[0m\033[13C\033[1;30m\xDC\xDC\033[0m\xDC\033[1;30m\xDC\033[0m\xDC\xDC\xDC\033[1m\xDC\033[0m\xDC\033[1m\xDC\033[0m \033[1m\xDC\033[0m\xDC\033[1m\xDC\033[0m\xDC\xDC\xDC\033[1m\xDC\033[0m\xDC\033[1m\xDC \033[0m \033[1m\xDC\033[0m\xDC\033[1m\xDC\033[0m\xDC\xDC\xDC\033[1m\xDC\033[0m\xDC\033[1m\xDC \033[0m \033[1m\xDC\033[0m\xDC\033[1m\xDC\033[0m\xDC\xDC\xDC\033[1m\xDC\033[0m\xDC\033[1m\xDC \033[0m\033[14C\033[1;30m\xB3\r\n\
\xB3\033[0m\033[19C\033[1;30m\xB1\xDB\033[37m\xDB\xDB\xDB\033[0m \033[1m\xDB\xDB\xDB\033[30m\xDB\xB1 \033[37m\xDB\xDB\xDB\033[0m \033[1m\xDB\xDB\xDB\033[30m\xDB\xB1 \033[37m\xDB\xDB\xDB\033[0m \033[1m\xDB\xDB\xDB\033[30m\xDB\xB1 \033[37m\xDB\xDB\xDB\033[0m\033[14C\033[1;30m\xB3\r\n\
\xB3\033[0m\033[13C\033[1;30m\xB0\xB0\xB0\xB0\xB0 \xB0\xB2\033[47;37m\xB2\033[40m\xDB\xDB\033[0m \033[1m\xDB\xDB\xDB\033[30m\xB2\xB0 \xB0\xB0\033[37m\xDB\xDB\xDB\033[0m \033[1m\xDB\xDB\xDB\033[30m\xB2\xB0 \xB0\xB0\033[37m\xDB\xDB\xDB\033[0m \033[1m\xDB\xDB\xDB\033[30m\xB2\xB0 \xB0\xB0\033[37m\xDB\xDB\xDB\033[0m\033[14C\033[1;30m\xB3\r\n\
\xB3\033[0m\033[13C\033[1;30m\xB0\xB0\xB0\xB0\xB0\xB0 \xB1\033[47;37m\xB1\xB2\033[40m\xDB\033[0m \033[1;30m \033[47;37m\xB2\033[40m\xDB\xDB\033[30m\xB1 \xB0\xB0\033[47;37m\xB2\033[40m\xDB\xDB\033[30m \033[47;37m\xB2\033[40m\xDB\xDB\033[30m\xB1 \xB0\xB0\033[47;37m\xB2\033[40m\xDB\xDB\033[30m \033[0m \033[1;47m\xB2\033[40m\xDB\xDB\033[30m\xB1 \xB0\xB0\033[47;37m\xB2\033[40m\xDB\xDB\033[30m \033[0m\033[13C\033[1;30m\xB3\r\n\
\xB3\033[0m\033[20C\xDC\033[1;47m\xB0\xB1\xB2\033[0m \033[1;30m \033[47;37m\xB1\xB2\033[40m\xDB\033[30m\xB0 \xB0\xB0\xB0\033[47;37m\xB1\xB2\033[40m\xDB\033[30m \033[47;37m\xB1\xB2\033[40m\xDB\033[30m\xB0 \xB0\xB0\xB0\033[47;37m\xB1\xB2\033[40m\xDB\033[30m \033[0m \033[1;47m\xB1\xB2\033[40m\xDB\033[30m\xB0 \xB0\xB0\xB0\033[47;37m\xB1\xB2\033[40m\xDB\033[30m \033[0m\033[13C\033[1;30m\xB3\r\n\
\xB3\033[0m\033[13C\xDC\033[1;47m\xB1\xB2\xB1\xB2\xDB\xB2\xB1\xB0\033[0m\xDF \033[1;30m\xB0\033[47;37m\xB0\xB1\xB2\033[0m \033[1;30m\xB0\xB0\xB0\033[47;37m\xB0\xB1\xB2\033[40;30m\xB0\xB0\033[47;37m\xB0\xB1\xB2\033[0m \033[1;30m\xB0\xB0\xB0\033[47;37m\xB0\xB1\xB2\033[40;30m\xB0\033[0m \033[1;47m\xB0\xB1\xB2\033[0m \033[1;30m\xB0\xB0\xB0\033[47;37m\xB0\xB1\xB2\033[40;30m\xB0\033[0m\033[13C\033[1;30m\xB3\r\n\
\xB3\033[0m\033[13C\033[1;47m\xB1\xB2\033[40m\xDB\033[30m\xB1\033[0m\033[6C\033[1;30m\xB0\xB0\xB0\033[0m\xDB\033[1;47m\xB0\xB1\033[0m \033[1;30m\xB0\xB0\xB0\xB0\033[0m\xDB\033[1;47m\xB0\xB1\033[40;30m\xB0\xB0\033[0m\xDB\033[1;47m\xB0\xB1\033[0m \033[1;30m\xB0\xB0\xB0\xB0\033[0m\xDB\033[1;47m\xB0\xB1\033[40;30m\xB0\033[0m \xDB\033[1;47m\xB0\xB1\033[0m \033[1;30m\xB0\xB0\xB0\xB0\033[0m\xDB\033[1;47m\xB0\xB1\033[40;30m\xB0\033[0m\033[13C\033[1;30m\xB3\r\n\
\xB3\033[0m \033[1;36m\xDD\033[0m\033[9C\033[1;47m\xB2\033[40m\xDB\xDB\033[30m\xB2\xB0 \xB0\xB0\xB0\xB0\xB0\xB0\xB0\033[47m\xB0\033[0m\xDB\033[1;47m\xB0\033[0m \033[1;30m\xB0\xB0\xB0\xB0\033[47m\xB0\033[0m\xDB\033[1;47m\xB0\033[40;30m\xB0\xB0\033[47m\xB0\033[0m\xDB\033[1;47m\xB0\033[0m \033[1;30m\xB0\xB0\xB0\xB0\033[47m\xB0\033[0m\xDB\033[1;47m\xB0\033[40;30m\xB0\033[0m \033[1;47;30m\xB0\033[0m\xDB\033[1;47m\xB0\033[0m \033[1;30m\xB0\xB0\xB0\xB0\033[47m\xB0\033[0m\xDB\033[1;47m\xB0\033[40;30m\xB0\033[0m\033[13C\033[1;30m\xB3\r\n\
\xB3\033[0m \033[1;36m\xDB\033[0m\033[9C\033[1m\xDB\xDB\xDB\033[30m\xDB\xB1\033[0m\033[8C\033[1;47;30m\xB1\xB0\033[0m\xDB\033[5C\033[1;47;30m\xB1\xB0\033[0m\xDB \033[1;47;30m\xB1\xB0\033[0m\xDB\033[5C\033[1;47;30m\xB1\xB0\033[0m\xDB \033[1;47;30m\xB1\xB0\033[0m\xDB\033[5C\033[1;47;30m\xB1\xB0\033[0m\xDB\033[10C\033[1;36m\xDB\033[0m \033[1;30m\xB3\r\n\
\xB3\033[0m \033[1;36m\xDB\xDC\033[0m\033[9C\033[1m\xDF\033[0m\xDF\033[1m\xDF\033[0m\xDF\xDF\033[1;30m\xDF\033[0m\xDF\033[1;30m\xDF\xDF\xDF\033[0m \033[1m\xDF\033[0m\xDF\033[1m\xDF\033[0m\xDF\xDF\033[1m\xDF\033[0m\xDF\033[1m\xDF\xDF \033[0m \033[1m\xDF\033[0m\xDF\033[1m\xDF\033[0m\xDF\xDF\033[1m\xDF\033[0m\xDF\033[1m\xDF\xDF \033[0m \033[1m\xDF\033[0m\xDF\033[1m\xDF\033[0m\xDF\xDF\033[1m\xDF\033[0m\xDF\033[1m\xDF\xDF \033[0m\033[9C\033[1;36m\xDC\xDB\xDB\033[0m \033[1;30m\xB3\r\n\
\xB3\033[0m \033[1;36m\xDB\xDB\xDB\xDC\033[0;36m\xDC\033[1m\xDC\xDC\033[0;36m\xDC\033[1m\xDC\033[0;36m\xDC\xDC\xDC\xDC\xDC\xDC\xDC\033[37m \033[36m\xDC\xDC\xDC\033[37m\033[17C\033[36m\xDC\xDC\xDC\xDC\033[37m\033[13C\033[36m\xDC\xDC\xDC\033[1m\xDC\033[0;36m\xDC\033[1m\xDC\xDC\033[0;36m\xDC\033[1m\xDC\xDC\xDB\xDB\xDB\xDB\xDB\033[0m \033[1;30m\xB3\r\n\
\xB3\033[0m\033[77C\033[1;30m\xB3\r\n\
\xB3\033[0m\033[6C\033[1mF1-F8\033[30m Consoles virtuelles \033[37mF9\033[30m Debug \033[37mF10\033[30m Mode graphique \033[37mF11\033[30m Aide\033[0m\033[9C\033[1;30m\xB3\r\n\
\xB3\033[0m\033[77C\033[1;30m\xB3\r\n\
\xB3\033[0m Developpe par \033[5;1;47mMrNop\033[0m\033[55C\xB3\r\n\
\xC0\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\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\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\033[0m\xC4\033[1;30m\xC4\033[0m\xC4\xC4\033[1m\xD9\033[0m\r\n\r\n";

130
lib/VGA/modes.c Normal file
View File

@ -0,0 +1,130 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
/* 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},
};
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},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A,
0x3B,
0x3C, 0x3D, 0x3E, 0x3F,
0x0C, 0x00, 0x0F, 0x08, 0x00}},
/*80*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},
{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}},
/*640*480 n&b mode 0x80 */
{{0xE3},
{0x03, 0x01, 0x0F, 0x00, 0x06},
{0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xEA, 0x0C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A,
0x3B,
0x3C, 0x3D, 0x3E, 0x3F,
0x01, 0x00, 0x0F, 0x00, 0x00}},
/*320*200 4 couleurs mode 0x81 */
{{0x63},
{0x03, 0x09, 0x03, 0x00, 0x02},
{0x2D, 0x27, 0x28, 0x90, 0x2B, 0x80, 0xBF, 0x1F, 0x00,
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x0E, 0x8F, 0x14, 0x00, 0x96, 0xB9, 0xA3, 0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x02, 0x00, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A,
0x3B,
0x3C, 0x3D, 0x3E, 0x3F,
0x01, 0x00, 0x03, 0x00, 0x00}},
/*640*480 16 couleurs mode 0x82 */
{{0xE3},
{0x03, 0x01, 0x0F, 0x00, 0x06},
{0x5F, 0x4F, 0x50, 0x82, 0x53, 0x9F, 0x0B, 0x3E, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xE9, 0x8B, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A,
0x3B,
0x3C, 0x3D, 0x3E, 0x3F,
0x01, 0x00, 0x0F, 0x00, 0x00}},
/*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},
{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}},
/*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},
{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}},
/*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},
{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}},
/*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},
{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}},
};

502
lib/cpu.c Executable file → Normal file
View File

@ -1,217 +1,337 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "types.h" #include "types.h"
#include "cpu.h" #include "cpu.h"
#include "cpuid.h"
#include "memory.h" #include "memory.h"
#include "string.h" #include "string.h"
#include "asm.h"
#include "gdt.h"
#include "process.h"
/* Technologies supportées */
static u8 *msg[] = {
static u8 *msg[] = "mmx",
{ "mmx2",
"mmx", "sse",
"mmx2", "sse2",
"sse", "sse3",
"sse2", "fpu",
"sse3", "3dNow!",
"fpu", "3dNow Extended!",
"3dNow!", "HyperThreading",
"3dNow Extended!", "apic",
"HyperThreading", "64bits",
"apic", "syscall",
"msr",
"sse4a",
"vmx",
"sse41",
"sse42",
"apic2"
}; };
static u8 space[]=" "; static u8 space[] = " ";
bool cansetflag (u32 flag) /******************************************************************************/
/* Affiche une erreur CPU et fige l'ordinateur */
void cpuerror(const u8 * src, const regs * dump, bool returnto)
{ {
u32 r1, r2; process *aprocess=findcurrentprocess();
asm("pushfl\n" if (!aprocess->iskernel && !returnto)
"popl %0\n" {
"movl %0, %1\n" printf("\033[31m*** ERREUR CPU, KILLING PROCESS %u : %s *** \r\n", aprocess->pid, src);
"xorl %2, %0\n" deleteprocess(aprocess->pid);
"pushl %0\n" }
"popfl\n" else
"pushfl\n" printf("\033[31m*** ERREUR CPU : %s *** \r\n", src);
"popl %0\n" if (dump != NULL)
"pushl %1\n" show_cpu(dump);
"popfl\n" print("<Appuyer une touche pour continuer>\033[0m\r\n");
: "=&r" (r1), "=&r" (r2) sti();
: "ir" (flag) waitascii();
); if (!returnto)
return ((r1 ^ r2) & flag) != 0; {
print("Retour en force au SHELL\r\n");
initselectors(getinitretry());
}
} }
void cpuid(u32 op, u32 *eax, u32 *ebx,u32 *ecx, u32 *edx) /******************************************************************************/
/* Annule les FLAGs CPU */
bool cansetflag(u32 flag)
{ {
asm("cpuid" : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) : "a" (op) : "cc"); 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;
} }
u8 getcpuinfos(cpuinfo *proc) /******************************************************************************/
/* Lance l'instruction CPUID */
void cpuid(u32 op, u32 * eax, u32 * ebx, u32 * ecx, u32 * edx)
{ {
u32 i,maxfunction,maxextended,unused,regeax,regebx,regecx,regedx; asm("cpuid": "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx): "a"(op):"cc");
bool *boolean;
if (!cansetflag (0x00040000)) return 1; /*386 processor - no cpuid*/
if (!cansetflag (0x00200000)) return 2; /*486 processor with no cpuid*/
cpuid(0, &maxfunction, &unused, &unused, &unused);
maxfunction &= 0xffff;
cpuid(0x80000000, &maxextended, &unused, &unused, &unused);
maxextended &= 0xffff;
if (maxfunction >= 1)
{
cpuid(1, &regeax, &regebx, &regecx, &regedx);
proc->stepping = (regeax & 0x0000000F);
proc->models = ((regeax>>4) & 0x0000000F);
proc->family = ((regeax>>8) & 0x0000000F);
proc->types = ((regeax>>12) & 0x00000003);
proc->emodels = ((regeax>>16) & 0x0000000F);
proc->efamily = ((regeax>>20) & 0x000000FF);
proc->brandid = (regeax & 0xF);
proc->linesize = ((regeax>>8) & 0xF);
proc->count = ((regeax>>16) & 0xF);
proc->apicid = ((regeax>>24) & 0xF);
proc->mmx=((regedx>>23) & 0x00000001);
proc->sse=((regedx>>25) & 0x00000001);
proc->sse2=((regedx>>26) & 0x00000001);
proc->sse3=(regecx & 0x00000001);
proc->fpu=(regedx & 0x00000001);
proc->htt=((regedx>>28) & 0x00000001);
}
if (maxextended >= 1)
{
cpuid(0x80000001, &regeax, &regebx, &regecx, &regedx);
proc->mmx2=((regedx>>22) & 0x00000001);
proc->apic=((regedx>>9) & 0x00000001);
proc->now3d=((regedx>>30) & 0x00000001);
proc->now3d2=((regedx>>31) & 0x00000001);
}
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);
}
}
boolean=&proc->mmx;
i=0;
for(i=0;i<10;i++)
if (*(boolean++)==1)
{
strcat(msg[i],&proc->techs);
strcat(space,&proc->techs);
}
return 0;
} }
u32 viewstack(u32 number) /******************************************************************************/
/* Retourne les informations sur le CPU dans une structure cpuinfo */
u8 getcpuinfos(cpuinfo * proc)
{ {
u32 stack = 0; u32 i, maxfunction, maxextended, unused, regeax, regebx,
asm ( regecx, regedx;
"movl %[a1],%%esi;" bool *boolean;
"addl %%esp,%%esi;"
"movl (%%esi), %[a1] ;" if (!cansetflag(0x00040000))
:[result] "=r" (stack) return 1; /*386 processor - no cpuid */
:[a1] "r" (number) if (!cansetflag(0x00200000))
:"%esi" return 2; /*486 processor with no cpuid */
);
return stack; cpuid(0, &maxfunction, &unused, &unused, &unused);
maxfunction &= 0xffff;
cpuid(0x80000000, &maxextended, &unused, &unused, &unused);
maxextended &= 0xffff;
if (maxfunction >= 1)
{
cpuid(1, &regeax, &regebx, &regecx, &regedx);
proc->stepping = (regeax & 0x0000000F);
proc->models = ((regeax >> 4) & 0x0000000F);
proc->family = ((regeax >> 8) & 0x0000000F);
proc->types = ((regeax >> 12) & 0x00000003);
proc->emodels = ((regeax >> 16) & 0x0000000F);
proc->efamily = ((regeax >> 20) & 0x000000FF);
proc->brandid = (regeax & 0xF);
proc->linesize = ((regeax >> 8) & 0xF);
proc->count = ((regeax >> 16) & 0xF);
proc->apicid = ((regeax >> 24) & 0xF);
proc->mmx = ((regedx >> 23) & 0x00000001);
proc->sse = ((regedx >> 25) & 0x00000001);
proc->sse2 = ((regedx >> 26) & 0x00000001);
proc->sse3 = (regecx & 0x00000001);
proc->fpu = (regedx & 0x00000001);
proc->htt = ((regedx >> 28) & 0x00000001);
proc->vmx = ((regecx >> 5) & 0x00000001);
proc->sse41 = ((regecx >> 19) & 0x00000001);
proc->sse42 = ((regecx >> 20) & 0x00000001);
proc->apic2 = ((regecx >> 21) & 0x00000001);
}
if (maxextended >= 1)
{
cpuid(0x80000001, &regeax, &regebx, &regecx, &regedx);
proc->mmx2 = ((regedx >> 22) & 0x00000001);
proc->apic = ((regedx >> 9) & 0x00000001);
proc->now3d = ((regedx >> 30) & 0x00000001);
proc->now3d2 = ((regedx >> 31) & 0x00000001);
proc->bits64 = ((regedx >> 29) & 0x00000001);
proc->syscall = ((regedx >> 11) & 0x00000001);
proc->msr = ((regedx >> 5) & 0x00000001);
proc->sse4a = ((regecx >> 6) & 0x00000001);
}
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);
}
}
boolean = &proc->mmx;
i = 0;
proc->techs[0] = '\000';
for (i = 0; i < sizeof(msg); i++)
if (*(boolean++) == 1)
{
strcat(msg[i], &proc->techs);
strcat(space, &proc->techs);
}
return 0;
} }
void dump_regs() /******************************************************************************/
/* Affiche les registres CPU */
void show_lightcpu(regs * stack)
{ {
u32 eax = 0; u32 i;
u32 ebx = 0; printf("\33[0mEAX=%Y EBX=%Y ECX=%Y EDX=%Y\r\n", stack->eax,
u32 ecx = 0; stack->ebx, stack->ecx, stack->edx);
u32 edx = 0; printf("ESI=%Y EDI=%Y ESP=%Y EBP=%Y\r\n", stack->esi, stack->edi,
u32 esi = 0; stack->esp, stack->ebp);
u32 edi = 0; printf("EIP=%Y EFL=%Y [%c%c%c%c%c%c%c%c%c]\r\n", stack->eip,
u32 ebp = 0; stack->eflags, (stack->eflags & (1 << 11)) ? 'O' : '-',
u32 esp = 0; (stack->eflags & (1 << 10)) ? 'D' : '-',
u16 cs = 0; (stack->eflags & (1 << 9)) ? 'I' : '-',
u16 ds = 0; (stack->eflags & (1 << 8)) ? 'T' : '-',
u16 es = 0; (stack->eflags & (1 << 7)) ? 'S' : '-',
u16 fs = 0; (stack->eflags & (1 << 6)) ? 'Z' : '-',
u16 gs = 0; (stack->eflags & (1 << 4)) ? 'A' : '-',
u16 ss = 0; (stack->eflags & (1 << 2)) ? 'P' : '-',
u32 flags = 0; (stack->eflags & (1 << 0)) ? 'C' : '-');
asm ( printf("CS =%hY DS =%hY SS =%hY ES =%hY FS =%hY GS =%hY\r\n",
"movl %%eax, %[a1] ;" stack->cs, stack->ds, stack->ss, stack->es, stack->fs,
"movl %%ebx, %[b1] ;" stack->gs);
"movl %%ecx, %[c1] ;" printf("CR0=%Y CR2=%Y CR3=%Y CR4=%Y\r\n\r\n\r\n", stack->cr0,
"movl %%edx, %[d1] ;" stack->cr2, stack->cr3, stack->cr4);
"movl %%esi, %[e1] ;"
"movl %%edi, %[f1] ;"
"movl %%esp, %[g1] ;"
"movl %%ebp, %[h1] ;"
"movw %%cs, %[i1] ;"
"movw %%ds, %[j1] ;"
"movw %%es, %[k1] ;"
"movw %%fs, %[l1] ;"
"movw %%gs, %[m1] ;"
"movw %%ss, %[n1] ;"
:
[a1] "=m" (eax), [b1] "=m" (ebx), [c1] "=m" (ecx), [d1] "=m" (edx), [e1] "=m" (esi), [f1] "=m" (edi),
[g1] "=m" (ebp), [h1] "=m" (esp), [i1] "=m" (cs), [j1] "=m" (ds), [k1] "=m" (es), [l1] "=m" (fs), [m1] "=m" (gs), [n1] "=m" (ss)
);
printf("eax=%x ebx=%x ecx=%x eax=%x\r\n", eax,ebx,ecx,edx);
printf("esi=%x edi=%x\r\n", esi,edi);
printf("cs=%x ds=%x es=%x fs=%x gs=%x\r\n", cs,ds,es,fs,gs);
printf("ss=%x esp=%x ebp=%x\r\n",ss,esp,ebp);
asm (
"pushf ;"
"pop %[f1] ;"
:
[f1] "=m" (flags)
);
printf("FLAGS");
if(flags & (1 << 0)) // Carry
printf(" (C1");
else
printf(" (C0");
if(flags & (1 << 2)) // Parity
printf(" P1");
else
printf(" P0");
if(flags & (1 << 4)) // Adjust
printf(" A1");
else
printf(" A0");
if(flags & (1 << 6)) // Zero
printf(" Z1");
else
printf(" Z0");
if(flags & (1 << 7)) // Sign
printf(" S1");
else
printf(" S0");
if(flags & (1 << 11)) // Overflow
printf(" O1)\n");
else
printf(" O0)\n");
printf("STACK\r\n");
for(u8 i=0;i<25;i++)
printf("+%d\t\t%x\r\n",i,viewstack(i*4));
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");
}
} }
/******************************************************************************/
/* Affiche les registres CPU */
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));
struct gdtr gdtreg;
sgdt(gdtreg);
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("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");
}
}
/*******************************************************************************/

3470
lib/debug.c Normal file

File diff suppressed because it is too large Load Diff

240
lib/gdt.c Normal file
View File

@ -0,0 +1,240 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "gdt.h"
#include "asm.h"
#include "types.h"
#include "memory.h"
/* registre gdt */
static struct gdtr gdtreg;
/* table de GDT */
static gdtdes gdt[GDT_SIZE];
/* TSS */
static struct tss tss0;
/*******************************************************************************/
/* Créé un descripteur GDT */
void makegdtdes(u32 base, u32 limite, u8 acces, u8 flags, gdtdes * desc)
{
desc->lim0_15 = (limite & 0xffff);
desc->base0_15 = (base & 0xffff);
desc->base16_23 = (base & 0xff0000) >> 16;
desc->acces = acces;
desc->lim16_19 = (limite & 0xf0000) >> 16;
desc->flags = (flags & 0xf);
desc->base24_31 = (base & 0xff000000) >> 24;
return;
}
/*******************************************************************************/
/* Initialise la GDT */
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, 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, 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 */
tss0.trapflag = 0x00;
tss0.iomap = 0x00;
tss0.esp0 = 0x6000;
tss0.ss0 = SEL_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);
gdtreg.base = GDT_ADDR;
/* recopie de la GDT a son adresse */
memcpy(&gdt, (u8 *) gdtreg.base, gdtreg.limite, 1);
/* chargement du registre GDT */
lgdt(gdtreg);
/* initialisation des segments */
initselectors(offset);
}
/*******************************************************************************/
/* Initialise les selecteurs avec la GDT */
void initselectors(u32 executingoffset)
{
asm(" movw %[data], %%ax \n \
movw %%ax, %%ds \n \
movw %%ax, %%es \n \
movw %%ax, %%fs \n \
movw %%ax, %%gs \n \
movw %[stack], %%ax \n \
movl %[offset], %%ebx \n \
movw %%ax, %%ss \n \
movl %[stackoff], %%esp \n \
pushl %%ebx \n \
ljmp %[code],$raz \n \
raz:\n \
xor %%eax,%%eax\n\
xor %%ebx,%%ebx\n\
xor %%ecx,%%ecx\n\
xor %%edx,%%edx\n\
xor %%esi,%%esi\n\
xor %%edi,%%edi\n\
xor %%ebp,%%ebp\n\
ret"::[data] "i"(SEL_KERNEL_DATA),[code] "i"(SEL_KERNEL_CODE),[stack] "i"(SEL_KERNEL_STACK),[stackoff] "i"(KERNEL_STACK_ADDR),[offset] "m"(executingoffset));
}
/*******************************************************************************/
/* Change le TSS courant */
void setTSS(u32 ss, u32 sp)
{
tss0.trapflag = 0x00;
tss0.iomap = 0x00;
tss0.ss0 = SEL_TSS;
tss0.esp0 = sp;
tss0.ss0 = ss;
}
/*******************************************************************************/
/* Initialise le registre de tâche (TSR) */
void inittr(void)
{
ltr(SEL_TSS);
}
/*******************************************************************************/
/* récupère la base d'un descripteur GDT */
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));
}
/*******************************************************************************/
/* récupère la limite d'un descripteur GDT */
u32 getdeslimit(u16 sel)
{
gdtdes *entry = GDT_ADDR;
u8 index = sel / sizeof(gdtdes);
return (entry[index].lim0_15 + (entry[index].lim16_19 << 16));
}
/*******************************************************************************/
/* récupère la limite d'un descripteur GDT */
u32 getdesdpl(u16 sel)
{
gdtdes *entry = GDT_ADDR;
u8 index = sel / sizeof(gdtdes);
return (entry[index].acces >> 5 & 0x03);
}
/*******************************************************************************/
/* récupère le type d'un descripteur GDT */
u8 getdestype(u16 sel)
{
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');
}
/*******************************************************************************/
/* récupère l'info 1 d'un descripteur GDT */
u8 getdesbit1(u16 sel)
{
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' : '-');
}
/*******************************************************************************/
/* récupère l'info 2 d'un descripteur GDT */
u8 getdesbit2(u16 sel)
{
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');
}
/*******************************************************************************/
/* récupère l'info 3 d'un descripteur GDT */
u8 getdesbit3(u16 sel)
{
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');
}
/*******************************************************************************/
/* récupère l'alignement d'un descripteur GDT */
u16 getdesalign(u16 sel)
{
gdtdes *entry = GDT_ADDR;
u8 index = sel / sizeof(gdtdes);
return (((entry[index].flags & 0x08) > 0) ? 4096 : 1);
}
/*******************************************************************************/
/* récupère si descripteur GDT est valide */
bool isdesvalid(u16 sel)
{
gdtdes *entry = GDT_ADDR;
u8 index = sel / sizeof(gdtdes);
return ((entry[index].acces & 0x80) > 0);
}
/*******************************************************************************/
/* récupère la dimension d'un descripteur GDT */
u32 getdessize(u16 sel)
{
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);
}

View File

@ -1,58 +0,0 @@
#include "types.h"
#include "vga.h"
#include "video.h"
#include "graph.h"
#include "math.h"
/******************************************************************************/
/* Affiche une ligne entre les points spécifiés */
void line(u32 x1, u32 y1, u32 x2, u32 y2, u8 color)
{
s32 dx,dy,sdx,sdy;
u32 i,dxabs,dyabs,x,y,px,py;
dx=x2-x1; /* distance horizontale de la line */
dy=y2-y1; /* distance verticale de la line **/
dxabs=abs(dx);
dyabs=abs(dy);
sdx=sgn(dx);
sdy=sgn(dy);
x=dyabs>>1;
y=dxabs>>1;
px=x1;
py=y1;
writepxl(px,py,color);
if (dxabs>=dyabs) /* la ligne est plus horizontale que verticale */
{
for(i=0;i<dxabs;i++)
{
y+=dyabs;
if (y>=dxabs)
{
y-=dxabs;
py+=sdy;
}
px+=sdx;
writepxl(px,py,color);
}
}
else /* la ligne est plus verticale que horizontale */
{
for(i=0;i<dyabs;i++)
{
x+=dxabs;
if (x>=dyabs)
{
x-=dyabs;
px+=sdx;
}
py+=sdy;
writepxl(px,py,color);
}
}
}

341
lib/handlers.c Normal file
View File

@ -0,0 +1,341 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "interrupts.h"
#include "types.h"
#include "asm.h"
#include "memory.h"
#include "video.h"
#include "gdt.h"
#include "system.h"
#include "debug.h"
#include "process.h"
/******************************************************************************/
/* Déclenché lors de l'appel d'une interruption */
__attribute__ ((noreturn)) void interruption_handler(regs *dump)
{
u32 interruption=dump->eip;
exception_stack_noerror *caller = (exception_stack_noerror*) ((u32*)dump->esp+1);
bool noerror,user;
if ((caller->cs & 0xFFF8)==SEL_KERNEL_CODE || (caller->cs & 0xFFF8)==SEL_USER_CODE)
{
noerror=true;
dump->eip = caller->eip;
dump->cs = caller->cs;
dump->eflags = caller->eflags;
if ((dump->cs & 0xFFF8)==SEL_KERNEL_CODE)
{
dump->esp = (u32) caller + sizeof(exception_stack_noerror);
user=false;
}
else
{
dump->esp = (u32) ((exception_stack_noerror_user*) caller)->esp;
dump->ss = (u32) ((exception_stack_noerror_user*) caller)->ss;
user=true;
}
}
else
{
noerror=false;
dump->eip = ((exception_stack*)caller)->eip;
dump->cs = ((exception_stack*)caller)->cs;
if ((dump->cs & 0xFFF8)==SEL_KERNEL_CODE)
{
dump->esp = (u32) caller + sizeof(exception_stack);
user=false;
}
else
{
dump->esp = (u32) ((exception_stack_user*) caller)->esp;
dump->ss = (u32) ((exception_stack_user*) caller)->ss;
user=true;
}
}
switch (interruption)
{
case 20:
show_lightcpu(dump);
break;
default:
print("Appel d'une interruption\r\n");
}
if ((dump->cs & 0xFFF8)==SEL_KERNEL_CODE)
{
setESP(dump);
restcpu_kernel();
}
else
{
setESP(dump);
restcpu_user();
iret();
}
}
/******************************************************************************/
/* Les expections */
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
};
__attribute__ ((noreturn)) void exception_handler(regs *dump)
{
u32 exception=dump->eip;
exception_stack_noerror *caller = (exception_stack_noerror*) ((u32*)dump->esp+1);
bool noerror,user;
if ((caller->cs & 0xFFF8)==SEL_KERNEL_CODE || (caller->cs & 0xFFF8)==SEL_USER_CODE)
{
noerror=true;
dump->eip = caller->eip;
dump->cs = caller->cs;
dump->eflags = caller->eflags;
if ((dump->cs & 0xFFF8)==SEL_KERNEL_CODE)
{
dump->esp = (u32) caller + sizeof(exception_stack_noerror);
user=false;
}
else
{
dump->esp = (u32) ((exception_stack_noerror_user*) caller)->esp;
dump->ss = (u32) ((exception_stack_noerror_user*) caller)->ss;
user=true;
}
}
else
{
noerror=false;
dump->eip = ((exception_stack*)caller)->eip;
dump->cs = ((exception_stack*)caller)->cs;
if ((dump->cs & 0xFFF8)==SEL_KERNEL_CODE)
{
dump->esp = (u32) caller + sizeof(exception_stack);
user=false;
}
else
{
dump->esp = (u32) ((exception_stack_user*) caller)->esp;
dump->ss = (u32) ((exception_stack_user*) caller)->ss;
user=true;
}
}
switch (exception)
{
case 0:
cpuerror("#DE Divide error", dump, false);
case 1:
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,
caller->eip + disasm(caller->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(getinitretry());
}
changevc(0);
goto endofexception;
case 2:
cpuerror("NMI Non-maskable hardware interrupt", dump, false);
case 3:
cpuerror("#BP INT3 instruction", dump, true);
iret();
case 4:
cpuerror("#OF INTO instruction detected overflow", dump, false);
case 5:
cpuerror("#BR BOUND instruction detected overrange", dump, false);
case 6:
cpuerror("#UD Invalid instruction opcode", dump, false);
case 7:
cpuerror("#NM No coprocessor", dump, false);
case 8:
cpuerror("#DF Double fault", dump, false);
case 9:
cpuerror("Coprocessor segment overrun", dump, false);
case 10:
cpuerror("#TS Invalid task state segment (TSS)", dump, false);
case 11:
cpuerror("#NP Segment not present", dump, false);
case 12:
cpuerror("#SS Stack fault", dump, false);
case 13:
cpuerror("#GP General protection fault (GPF)", dump, false);
case 14:
if (dump->cr2 >= USER_CODE && dump->cr2 < USER_STACK)
{
virtual_range_new(findcurrentprocess()->pdd,
(u8 *) (dump->cr2 & 0xFFFFF000),
PAGESIZE, PAGE_ALL);
}
else
{
printf("Page fault - %s at adress %Y cs:eip - %Y:%Y\r\n",
ex14_errors[((exception_stack*) caller)->error_code & 0xF], dump->cr2,
dump->cs, dump->eip);
cpuerror("#PGF Page fault", dump, false);
}
goto endofexception;
case 15:
cpuerror("(reserved)", dump, false);
case 16:
cpuerror("#MF Coprocessor error", dump, false);
case 17:
cpuerror("#AC Alignment check", dump, false);
case 18:
cpuerror("#MC Machine check", dump, false);
}
endofexception:
if ((dump->cs & 0xFFF8)==SEL_KERNEL_CODE)
{
setESP(dump);
restcpu_kernel();
}
else
{
setESP(dump);
restcpu_user();
iret();
}
}
/******************************************************************************/
/* Les IRQ par défaut */
__attribute__((interrupt)) void irq0(exception_stack_noerror *caller)
{
print("irq 0");
irqendmaster();
}
__attribute__((interrupt)) void irq1(exception_stack_noerror *caller)
{
print("irq 1");
while ((inb(0x64) & 1) == 0);
inb(0x60);
irqendmaster();
}
__attribute__((interrupt)) void irq2(exception_stack_noerror *caller)
{ print("irq 2");
irqendmaster();
}
__attribute__((interrupt)) void irq3(exception_stack_noerror *caller)
{
print("irq 3");
irqendmaster();
}
__attribute__((interrupt)) void irq4(exception_stack_noerror *caller)
{
print("irq 4");
irqendmaster();
}
__attribute__((interrupt)) void irq5(exception_stack_noerror *caller)
{
print("irq 5");
irqendmaster();
}
__attribute__((interrupt)) void irq6(exception_stack_noerror *caller)
{
print("irq 6");
irqendmaster();
}
__attribute__((interrupt)) void irq7(exception_stack_noerror *caller)
{
print("irq 7");
irqendmaster();
}
__attribute__((interrupt)) void irq8(exception_stack_noerror *caller)
{
print("irq 8");
irqendslave();
irqendmaster();
}
__attribute__((interrupt)) void irq9(exception_stack_noerror *caller)
{
print("irq 9");
irqendslave();
irqendmaster();
}
__attribute__((interrupt)) void irq10(exception_stack_noerror *caller)
{
print("irq 10");
irqendslave();
irqendmaster();
}
__attribute__((interrupt)) void irq11(exception_stack_noerror *caller)
{
print("irq 11");
irqendslave();
irqendmaster();
}
__attribute__((interrupt)) void irq12(exception_stack_noerror *caller)
{
print("irq 12");
while ((inb(0x64) & 1) == 0);
inb(0x60);
irqendslave();
irqendmaster();
}
__attribute__((interrupt)) void irq13(exception_stack_noerror *caller)
{
print("irq 13");
irqendslave();
irqendmaster();
}
__attribute__((interrupt)) void irq14(exception_stack_noerror *caller)
{
print("irq 14");
irqendslave();
irqendmaster();
}
__attribute__((interrupt)) void irq15(exception_stack_noerror *caller)
{
print("irq 15");
irqendslave();
irqendmaster();
}

120
lib/handlers_asm.S Normal file
View File

@ -0,0 +1,120 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
.section .text
.macro exception num
.global wrapper_exception\num
wrapper_exception\num:
pushl %ss
pushl %esp
pushf
pushl %cs
pushl $\num
jmp exception_suite
.endm
.macro semidumpcpu
cli
pushl %ds
pushl %es
pushl %fs
pushl %gs
pushl %eax
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi
pushl %edi
pushl %ebp
mov %cr0, %eax
pushl %eax
mov %cr2, %eax
pushl %eax
mov %cr3, %eax
pushl %eax
mov %cr4, %eax
pushl %eax
mov %dr0, %eax
pushl %eax
mov %dr1, %eax
pushl %eax
mov %dr2, %eax
pushl %eax
mov %dr3, %eax
pushl %eax
mov %dr6, %eax
pushl %eax
mov %dr7, %eax
pushl %eax
mov $0xC0000080, %ecx
rdmsr
pushl %edx
pushl %eax
pushl %esp
.endm
exception 0
exception 1
exception 2
exception 3
exception 4
exception 5
exception 6
exception 7
exception 8
exception 9
exception 10
exception 11
exception 12
exception 13
exception 14
exception 15
exception 16
exception 17
exception 18
exception_suite:
semidumpcpu
call exception_handler
.global wrapper_sysenter
wrapper_sysenter:
pushl %ss
pushl %esp
pushf
pushl %cs
pushl $0x00
semidumpcpu
call sysenter_handler
.global wrapper_interruption20
wrapper_interruption20:
pushl %ss
pushl %esp
pushf
pushl %cs
pushl $0x14
semidumpcpu
call interruption_handler
.global wrapper_interruption
wrapper_interruption:
pushl %ss
pushl %esp
pushf
pushl %cs
pushl $0x00
semidumpcpu
call interruption_handler
.global wrapper_timer
wrapper_timer:
pushl %ss
pushl %esp
pushf
pushl %cs
pushl $0x00
semidumpcpu
call timer_handler

511
lib/idt.c
View File

@ -1,511 +0,0 @@
#include "idt.h"
#include "types.h"
#include "asm.h"
#include "memory.h"
#include "video.h"
/* registre idt */
static struct dtr idtreg;
/* table de IDT */
static idtdes idt[256];
void initpic(void)
{
/* MASTER */
/* Initialisation de ICW1 */
outb(0x20,0x11);
nop();
/* Initialisation de ICW2 - vecteur de depart = 32 */
outb(0x21,0x20);
nop();
/* Initialisation de ICW3 */
outb(0x21,0x04);
nop();
/* Initialisation de ICW4 */
outb(0x21,0x01);
nop();
/* masquage des interruptions */
outb(0x21,0xFF);
nop();
/* SLAVE */
/* Initialisation de ICW1 */
outb(0xA0,0x11);
nop();
/* Initialisation de ICW2 - vecteur de depart = 96 */
outb(0xA1,0x60);
nop();
/* Initialisation de ICW3 */
outb(0xA1,0x02);
nop();
/* Initialisation de ICW4 */
outb(0xA1,0x01);
nop();
/* masquage des interruptions */
outb(0xA1,0xFF);
nop();
/* Demasquage des irqs sauf clavier
outb(0x21,0xFD);
nop();
*/
}
void enableirq(u8 irq)
{
u16 port;
cli();
port = (((irq & 0x08) << 4) + 0x21);
outb(port,inb(port) & ~(1 << (irq & 7)));
sti();
}
void disableirq(u8 irq)
{
u16 port;
cli();
port = (((irq & 0x08) << 4) + 0x21);
outb(port,inb(port) | (1 << (irq & 7)));
sti();
}
void makeidtdes(u32 offset, u16 select, u16 type, idtdes* desc)
{
desc->offset0_15 = (offset & 0xffff);
desc->select = select;
desc->type = type;
desc->offset16_31 = (offset & 0xffff0000) >> 16;
return;
}
void setidt(u32 offset, u16 select, u16 type,u16 index)
{
cli();
idtdes *desc;
desc=idtreg.base;
desc[index].offset0_15 = (offset & 0xffff);
desc[index].select = select;
desc[index].type = type;
desc[index].offset16_31 = (offset & 0xffff0000) >> 16;
sti();
}
void putidt(u32 offset, u16 select, u16 type,u16 index)
{
idtdes temp;
makeidtdes(offset,select,type,&temp);
idt[index]=temp;
}
void cpuerror(const u8 *src)
{
print("\033[31m***** ERREUR CPU ****\r\n -");
print(src);
dump_regs();
while(1)
{
nop();
}
}
void interruption()
{
cli();
pushf();
pushad();
print("Appel d'une interruption\r\n");
popad();
popf();
sti();
iret();
}
void exception0()
{
print("divide error\r\n");
}
void exception1()
{
cpuerror("debug exception\r\n");
}
void exception2()
{
cpuerror("non-maskable hardware interrupt\r\n");
}
void exception3()
{
cpuerror("INT3 instruction\r\n");
}
void exception4()
{
cpuerror("INTO instruction detected overflow\r\n");
}
void exception5()
{
print("BOUND instruction detected overrange\r\n");
}
void exception6()
{
cpuerror("invalid instruction opcode\r\n");
}
void exception7()
{
cpuerror("no coprocessor\r\n");
}
void exception8()
{
cpuerror("double fault\r\n");
}
void exception9()
{
cpuerror("coprocessor segment overrun\r\n");
}
void exception10()
{
cpuerror("invalid task state segment (TSS)\r\n");
}
void exception11()
{
cpuerror("segment not present\r\n");
}
void exception12()
{
cpuerror("stack fault");
}
void exception13()
{
cpuerror("general protection fault (GPF)\r\n");
}
void exception14()
{
cpuerror("page fault\r\n");
}
void exception15()
{
cpuerror("(reserved)\r\n");
}
void exception16()
{
cpuerror("coprocessor error\r\n");
}
void exception17()
{
cpuerror("alignment check\r\n");
}
void exception18()
{
cpuerror("machine check");
}
void irq0()
{
cli();
pushf();
pushad();
print("irq 0");
irqendmaster();
popad();
popf();
sti();
asm("addl $0x01C, %esp;");
iret();
}
void irq1()
{
cli();
pushf();
pushad();
print("irq 1");
while ((inb(0x64)&1)==0);
inb(0x60);
irqendmaster();
popad();
popf();
sti();
asm("addl $0x01C, %esp;");
iret();
}
void irq2()
{
cli();
pushf();
pushad();
print("irq 2");
irqendmaster();
popad();
popf();
sti();
asm("addl $0x01C, %esp;");
iret();
}
void irq3()
{
cli();
pushf();
pushad();
print("irq 3");
irqendmaster();
popad();
popf();
sti();
asm("addl $0x01C, %esp;");
iret();
}
void irq4()
{
cli();
pushf();
pushad();
print("irq 4");
irqendmaster();
popad();
popf();
sti();
asm("addl $0x01C, %esp;");
iret();
}
void irq5()
{
cli();
pushf();
pushad();
print("irq 5");
irqendmaster();
popad();
popf();
sti();
asm("addl $0x01C, %esp;");
iret();
}
void irq6()
{
cli();
pushf();
pushad();
print("irq 6");
irqendmaster();
popad();
popf();
sti();
asm("addl $0x01C, %esp;");
iret();
}
void irq7()
{
cli();
pushf();
pushad();
print("irq 7");
irqendmaster();
popad();
popf();
sti();
asm("addl $0x01C, %esp;");
iret();
}
void irq8()
{
cli();
pushf();
pushad();
print("irq 8");
irqendslave();
irqendmaster();
popad();
popf();
sti();
asm("addl $0x01C, %esp;");
iret();
}
void irq9()
{
cli();
pushf();
pushad();
print("irq 9");
irqendslave();
irqendmaster();
popad();
popf();
sti();
asm("addl $0x01C, %esp;");
iret();
}
void irq10()
{
cli();
pushf();
pushad();
print("irq 10");
irqendslave();
irqendmaster();
popad();
popf();
sti();
asm("addl $0x01C, %esp;");
iret();
}
void irq11()
{
cli();
pushf();
pushad();
print("irq 11");
irqendslave();
irqendmaster();
popad();
popf();
sti();
asm("addl $0x01C, %esp;");
iret();
}
void irq12()
{
cli();
pushf();
pushad();
print("irq 12");
while ((inb(0x64)&1)==0);
inb(0x60);
irqendslave();
irqendmaster();
popad();
popf();
sti();
asm("addl $0x01C, %esp;");
iret();
}
void irq13()
{
cli();
pushf();
pushad();
print("irq 13");
irqendslave();
irqendmaster();
popad();
popf();
sti();
asm("addl $0x01C, %esp;");
iret();
}
void irq14()
{
cli();
pushf();
pushad();
print("irq 14");
irqendslave();
irqendmaster();
popad();
popf();
sti();
asm("addl $0x01C, %esp;");
iret();
}
void irq15()
{
cli();
print("irq 15");
irqendslave();
irqendmaster();
popad();
popf();
sti();
asm("addl $0x01C, %esp;");
iret();
}
void initidt(void)
{
u16 i;
putidt((u32)exception0, 0x20, INTGATE, 0);
putidt((u32)exception1, 0x20, INTGATE, 1);
putidt((u32)exception2, 0x20, INTGATE, 2);
putidt((u32)exception3, 0x20, INTGATE, 3);
putidt((u32)exception4, 0x20, INTGATE, 4);
putidt((u32)exception5, 0x20, INTGATE, 5);
putidt((u32)exception6, 0x20, INTGATE, 6);
putidt((u32)exception7, 0x20, INTGATE, 7);
putidt((u32)exception8, 0x20, INTGATE, 8);
putidt((u32)exception9, 0x20, INTGATE, 9);
putidt((u32)exception10, 0x20, INTGATE, 10);
putidt((u32)exception11, 0x20, INTGATE, 11);
putidt((u32)exception12, 0x20, INTGATE, 12);
putidt((u32)exception13, 0x20, INTGATE, 13);
putidt((u32)exception14, 0x20, INTGATE, 14);
putidt((u32)exception15, 0x20, INTGATE, 15);
putidt((u32)exception16, 0x20, INTGATE, 16);
putidt((u32)exception17, 0x20, INTGATE, 17);
putidt((u32)exception18, 0x20, INTGATE, 18);
for(i=19;i<32;i++)
{
putidt((u32)interruption, 0x20, INTGATE, i);
}
putidt((u32)irq0, 0x20, INTGATE, 32);
putidt((u32)irq1, 0x20, INTGATE, 33);
putidt((u32)irq2, 0x20, INTGATE, 34);
putidt((u32)irq3, 0x20, INTGATE, 35);
putidt((u32)irq4, 0x20, INTGATE, 36);
putidt((u32)irq5, 0x20, INTGATE, 37);
putidt((u32)irq6, 0x20, INTGATE, 38);
putidt((u32)irq7, 0x20, INTGATE, 39);
for(i=40;i<96;i++)
{
putidt((u32)interruption, 0x20, INTGATE, i);
}
putidt((u32)irq8, 0x20, INTGATE, 96);
putidt((u32)irq9, 0x20, INTGATE, 97);
putidt((u32)irq10, 0x20, INTGATE, 98);
putidt((u32)irq11, 0x20, INTGATE, 99);
putidt((u32)irq12, 0x20, INTGATE, 100);
putidt((u32)irq13, 0x20, INTGATE, 101);
putidt((u32)irq14, 0x20, INTGATE, 102);
putidt((u32)irq15, 0x20, INTGATE, 103);
for(i=104;i<255;i++)
{
putidt((u32)interruption, 0x20, INTGATE, i);
}
/* initialise le registre idt */
idtreg.limite = 256*8;
idtreg.base = 0x0000000;
/* recopie de la IDT a son adresse */
memcpy(&idt, (u8*)idtreg.base, idtreg.limite,1);
/* chargement du registre IDTR */
lidt(&idtreg);
}

276
lib/interrupts.c Normal file
View File

@ -0,0 +1,276 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "interrupts.h"
#include "types.h"
#include "asm.h"
#include "memory.h"
#include "video.h"
#include "gdt.h"
#include "system.h"
#include "debug.h"
#include "process.h"
#include "handlers.h"
#define IDT_SIZE 256 /* nombre de descripteurs */
/* registre idt */
static struct idtr idtreg;
/* table de IDT */
static idtdes idt[IDT_SIZE];
static u32 retry_address;
extern wrapper_exception0;
extern wrapper_exception1;
extern wrapper_exception2;
extern wrapper_exception3;
extern wrapper_exception4;
extern wrapper_exception5;
extern wrapper_exception6;
extern wrapper_exception7;
extern wrapper_exception8;
extern wrapper_exception9;
extern wrapper_exception10;
extern wrapper_exception11;
extern wrapper_exception12;
extern wrapper_exception13;
extern wrapper_exception14;
extern wrapper_exception15;
extern wrapper_exception16;
extern wrapper_exception17;
extern wrapper_exception18;
extern wrapper_interruption;
/******************************************************************************/
/* Initialise la reprise après erreur */
void initretry(u32 address)
{
retry_address = address;
}
/******************************************************************************/
/* Récupère l'adresse de reprise après erreur */
u32 getinitretry(void)
{
return retry_address;
}
/******************************************************************************/
/* Initialise le controleur d'interruption 8259A */
void initpic(void)
{
/* MASTER */
/* Initialisation de ICW1 */
outb(PIC1_CMD, ICW1_INIT + ICW1_ICW4);
nop();
/* Initialisation de ICW2 - vecteur de depart = 32 */
outb(PIC1_DATA, 0x20);
nop();
/* Initialisation de ICW3 */
outb(PIC1_DATA, 0x04);
nop();
/* Initialisation de ICW4 */
outb(PIC1_DATA, ICW4_8086);
nop();
/* masquage des interruptions */
outb(PIC1_DATA, 0xFF);
nop();
/* SLAVE */
/* Initialisation de ICW1 */
outb(PIC2_CMD, ICW1_INIT + ICW1_ICW4);
nop();
/* Initialisation de ICW2 - vecteur de depart = 96 */
outb(PIC2_DATA, 0x60);
nop();
/* Initialisation de ICW3 */
outb(PIC2_DATA, 0x02);
nop();
/* Initialisation de ICW4 */
outb(PIC2_DATA, ICW4_8086);
nop();
/* masquage des interruptions */
outb(PIC2_DATA, 0xFF);
nop();
/* Demasquage des irqs sauf clavier
outb(PIC1_DATA,0xFD);
nop();
*/
}
/******************************************************************************/
/* Active une IRQ */
void enableirq(u8 irq)
{
u16 port;
cli();
port = (((irq & 0x08) << 4) + PIC1_DATA);
outb(port, inb(port) & ~(1 << (irq & 7)));
sti();
}
/******************************************************************************/
/* Désactive une IRQ */
void disableirq(u8 irq)
{
u16 port;
cli();
port = (((irq & 0x08) << 4) + PIC1_DATA);
outb(port, inb(port) | (1 << (irq & 7)));
sti();
}
/******************************************************************************/
/* Créé un descripteur pour l'IDT */
void makeidtdes(u32 offset, u16 select, u16 type, idtdes * desc)
{
desc->offset0_15 = (offset & 0xffff);
desc->select = select;
desc->type = type;
desc->offset16_31 = (offset & 0xffff0000) >> 16;
return;
}
/******************************************************************************/
/* Change une entrée dans l'IDT */
void setidt(u32 offset, u16 select, u16 type, u16 index)
{
cli();
idtdes *desc;
desc = idtreg.base;
desc[index].offset0_15 = (offset & 0xffff);
desc[index].select = select;
desc[index].type = type;
desc[index].offset16_31 = (offset & 0xffff0000) >> 16;
sti();
}
/******************************************************************************/
/* Met une entrée dans l'IDT */
void putidt(u32 offset, u16 select, u16 type, u16 index)
{
idtdes temp;
makeidtdes(offset, select, type, &temp);
idt[index] = temp;
}
/******************************************************************************/
/* Initialise une IDT */
void initidt(void)
{
u16 i;
putidt((u32) &wrapper_exception0, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 0);
putidt((u32) &wrapper_exception1, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 1);
putidt((u32) &wrapper_exception2, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 2);
putidt((u32) &wrapper_exception3, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 3);
putidt((u32) &wrapper_exception4, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 4);
putidt((u32) &wrapper_exception5, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 5);
putidt((u32) &wrapper_exception6, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 6);
putidt((u32) &wrapper_exception7, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 7);
putidt((u32) &wrapper_exception8, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 8);
putidt((u32) &wrapper_exception9, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 9);
putidt((u32) &wrapper_exception10, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 10);
putidt((u32) &wrapper_exception11, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 11);
putidt((u32) &wrapper_exception12, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 12);
putidt((u32) &wrapper_exception13, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 13);
putidt((u32) &wrapper_exception14, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 14);
putidt((u32) &wrapper_exception15, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 15);
putidt((u32) &wrapper_exception16, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 16);
putidt((u32) &wrapper_exception17, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 17);
putidt((u32) &wrapper_exception18, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 18);
for (i = 19; i < 32; i++)
{
putidt((u32) &wrapper_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) &wrapper_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) &wrapper_interruption, SEL_KERNEL_CODE,
ENTRY_PRESENT | ENTRY_RING0 | TRAPGATE, i);
}
/* initialise le registre idt */
idtreg.limite = IDT_SIZE * sizeof(idtdes);
idtreg.base = IDT_ADDR;
/* recopie de la IDT a son adresse */
memcpy(&idt, (u8 *) idtreg.base, idtreg.limite, 1);
/* chargement du registre IDTR */
lidt(idtreg);
}
/******************************************************************************/
/* 8253/8254 PIT (Programmable Interval Timer) Timer ajustable */
void inittimer(void)
{
u32 divisor = TIMER_FREQ / HZ;
outb(TIMER_MODE, RATE_GENERATOR);
outb(TIMER0, (u8) divisor);
outb(TIMER0, (u8) (divisor >> 8));
}
/*******************************************************************************/

481
lib/keyboard.c Executable file → Normal file
View File

@ -1,310 +1,381 @@
#include "idt.h" /*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "interrupts.h"
#include "types.h" #include "types.h"
#include "asm.h" #include "asm.h"
#include "memory.h" #include "memory.h"
#include "keyboard.h" #include "keyboard.h"
#include "vga.h"
#include "video.h" #include "video.h"
static u8 bufferscan[256]={0}; static u8 bufferscan[256] = { 0 };
static u8 bufferascii[256]={0}; static u8 bufferascii[256] = { 0 };
static u8 ptrscan=0;
static u8 ptrascii=0; static u8 ptrscan = 0;
static u16 kbdstatus,breakcode ; static u8 ptrascii = 0;
static u16 kbdstatus, breakcode;
static const u8 set1_normal[] =
{ /******************************************************************************/
0, 0x1B, '&', 'é', '\"', '\'', '(', '-', /* Tables clavier */
'è', '_', 'ç', 'à', ')', '=', '\b', '\t',
'a', 'z', 'e', 'r', 't', 'y', 'u', 'i', static const u8 set1_normal[] = {
'o', 'p', '^', '$', '\r', 0, 'q', 's', 0, 0x1B, '&', 'é', '\"', '\'', '(', '-',
'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'è', '_', 'ç', 'à', ')', '=', '\b', '\t',
'ù', '²', 0, '*', 'w', 'x', 'c', 'v', 'a', 'z', 'e', 'r', 't', 'y', 'u', 'i',
'b', 'n', ',', ';', ':', '!', 0, '*', 'o', 'p', '^', '$', '\r', 0, 'q', 's',
0, ' ', 0, 0, 0, 0, 0, 0, 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm',
0, 0, 0, 0, 0, 0, 0, '7', 'ù', '²', 0, '*', 'w', 'x', 'c', 'v',
'8', '9','-', '4','5','6', '+', '1', 'b', 'n', ',', ';', ':', '!', 0, '*',
'2', '3','0','.',0, 0, '<', 0, 0, ' ', 0, 0, 0, 0, 0, 0,
0 0, 0, 0, 0, 0, 0, 0, '7',
'8', '9', '-', '4', '5', '6', '+', '1',
'2', '3', '0', '.', 0, 0, '<', 0,
0
}; };
static const u8 set1_shift[] = static const u8 set1_shift[] = {
{ 0, 0x1B, '1', '2', '3', '4', '5', '6',
0, 0x1B, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '°', '+', '\b', '\t',
'7', '8', '9', '0', '°', '+', '\b', '\t', 'A', 'Z', 'E', 'R', 'T', 'Y', 'U', 'I',
'A', 'Z', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '¨', '£', '\r', 0, 'Q', 'S',
'O', 'P', '¨', '£', '\r', 0, 'Q', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M',
'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', '%', 0, 0, 'µ', 'W', 'X', 'C', 'V',
'%', 0, 0, 'µ', 'W', 'X', 'C', 'V', 'B', 'N', '?', '.', '/', '§', 0, '*',
'B', 'N', '?', '.', '/', '§', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0,
0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7',
0, 0, 0, 0, 0,0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1',
'8', '9','-', '4','5','6', '+', '1', '2', '3', '0', '.', 0, 0, '>', 0,
'2', '3','0','.',0, 0, '>', 0, 0
0
}; };
static const u8 set1_alt[] = static const u8 set1_alt[] = {
{ 0, 0x1B, 0, 0, 0, 0, 0, 0,
0, 0x1B, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\r', 0, 0, 0,
0, 0, 0, 0, '\r', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '*',
0, 0, 0, 0, 0, 0, 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0,
0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7',
0, 0, 0, 0, 0,0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1',
'8', '9','-', '4','5','6', '+', '1', '2', '3', '0', '.', 0, 0, 0, 0,
'2', '3','0','.',0, 0, 0, 0, 0
0
}; };
static const u8 set1_altgr[] = {
static const u8 set1_altgr[] = 0, 0x1B, 0, '~', '#', '{', '[', '|',
{ '`', '\\', '^', '@', ']', '}', '\b', '\t',
0, 0x1B, 0, '~', '#', '{', '[', '|', 0, 0, 0, 0, 0, 0, 0, 0,
'`', '\\', '^', '@', ']', '}', '\b', '\t', 0, 0, 0, '¤', '\r', 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, '¤', '\r', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '*',
0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, '*', 0, 0, 0, 0, 0, 0, 0, '7',
0, ' ', 0, 0, 0, 0, 0, 0, '8', '9', '-', '4', '5', '6', '+', '1',
0, 0, 0, 0, 0,0, 0, '7', '2', '3', '0', '.', 0, 0, 0, 0,
'8', '9','-', '4','5','6', '+', '1', 0
'2', '3','0','.',0, 0, 0, 0,
0
}; };
static const u8 set1_ctrl[] = static const u8 set1_ctrl[] = {
{ 0, 0x1B, 0, 0, 0, 0, 0x1B, 0,
0, 0x1B, 0, 0,0, 0, 0x1B, 0, 0, 0x1C, 0, 0, 0x1D, 0, 0, 0x1F,
0, 0x1C, 0, 0, 0x1D, 0, 0, 0x1F, 0x01, 0x1A, 0x05, 0x012, 0x14, 0x19, 0x15, 0x09,
0x01, 0x1A, 0x05, 0x012, 0x14, 0x19, 0x15, 0x09, 0x0F, 0x10, 0x1E, 0, 0, 0, 0x11, 0x13,
0x0F, 0x10, 0x1E, 0, 0, 0, 0x11, 0x13, 0x04, 0x06, 0x07, 0x08, 0x0A, 0x0B, 0x0C, 0x0D,
0x04, 0x06, 0x07,0x08, 0x0A, 0x0B, 0x0C, 0x0D, 0, 0, 0, 0, 0x17, 0x18, 0x03, 0x16,
0, 0, 0, 0, 0x17, 0x18, 0x03, 0x16, 0x02, 0x0E, 0, 0, 0, 0, 0, '*',
0x02, 0x0E, 0, 0, 0, 0, 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0,
0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7',
0, 0, 0, 0, 0,0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1',
'8', '9','-', '4','5','6', '+', '1', '2', '3', '0', '.', 0, 0, 0, 0,
'2', '3','0','.',0, 0, 0, 0, 0
0
}; };
/******************************************************************************/
u8 waitascii() /******************************************************************************/
{
u8 oldptrscan=ptrscan; /* Attend une chaine de caractère de taille max */
u8 oldptrascii=ptrascii;
while((oldptrascii==ptrascii));/*(oldptrscan==ptrscan)&&*/ u8 *getstring(u8 * temp)
return bufferascii[ptrascii]; {
u8 maxwidth = strlen(temp);
u8 *pointer = temp;
u8 ascii = 0;
while (ascii != '\r')
{
ascii = waitascii();
if (ascii == '\b' && pointer > temp)
{
pointer--;
putchar(ascii);
}
else if (ascii > 31 && pointer <= temp + 80)
{
*pointer++ = ascii;
putchar(ascii);
}
}
*pointer = '\000';
return temp;
} }
/******************************************************************************/ /******************************************************************************/
/* Fonction qui attend l'appuie d'une touche générant un code ASCII puis le retourne */
/* SYSCALL
{
"ID":1,
"LIBRARY":"libsys",
"NAME":"waitkey",
"INTERNALNAME":"waitascii",
"DESCRIPTION":"Wait for user to press a key and return the ascii code pressed",
"ARGS": [],
"RETURN":"u8"
}
END-SYSCALL */
u8 waitascii(void)
{
u8 oldptrascii = ptrascii;
while ((oldptrascii == ptrascii));
return bufferascii[ptrascii];
}
/******************************************************************************/
/* Envoi d'une commande vers le contrôleur de clavier */
void outkbd(u8 port, u8 data) void outkbd(u8 port, u8 data)
{ {
u32 timeout; u32 timeout;
u8 state; u8 state;
/* timeout */ /* timeout */
for(timeout = 500000L; timeout != 0; timeout--) for (timeout = 500000L; timeout != 0; timeout--)
{ {
state = inb(0x64); state = inb(0x64);
/* vide le buffer du 8042 */ /* vide le buffer du 8042 */
if((state & 0x02) == 0) break; if ((state & 0x02) == 0)
break;
} }
if(timeout != 0) if (timeout != 0)
outb(port, data); outb(port, data);
} }
/******************************************************************************/ /******************************************************************************/
static void reboot(void) /* Redemarre l'ordinateur */
void reboot(void)
{ {
u8 temp; u8 temp;
cli(); cli();
/* vide le 8042 */ /* vide le 8042 */
do do
{ {
temp = inb(0x64); temp = inb(0x64);
if((temp & 0x01) != 0) if ((temp & 0x01) != 0)
{ {
(void)inb(0x60); (void) inb(0x60);
continue; continue;
} }
} while((temp & 0x02) != 0); }
while ((temp & 0x02) != 0);
/* active le reset CPU */ /* active le reset CPU */
outb(0x64, 0xFE); outb(0x64, 0xFE);
while(1) while (1)
/* boucle infinie */; /* boucle infinie */ ;
} }
/******************************************************************************/ /******************************************************************************/
/* Converti un scancode vers une code ASCII */
unsigned convert(u32 keypressed) unsigned convert(u32 keypressed)
{ {
u8 temp,key,lastscan; u8 temp, key, lastscan;
/* garde le dernier pointeur du buffer scan */ /* garde le dernier pointeur du buffer scan */
lastscan=ptrscan; lastscan = ptrscan;
/* incrémente le pointeur est assigne au buffer le dernier scancode */ /* incrémente le pointeur est assigne au buffer le dernier scancode */
ptrscan++; ptrscan++;
if (ptrscan==255) ptrscan==0; if (ptrscan == 255)
bufferscan[ptrscan]=keypressed; ptrscan == 0;
bufferscan[ptrscan] = keypressed;
/* break key (touche relaché) ? */ /* break key (touche relaché) ? */
if(keypressed >= 0x80) breakcode = 1; if (keypressed >= 0x80)
key = (keypressed&0x7F); breakcode = 1;
key = (keypressed & 0x7F);
/* Mise a jour des flags lors du relachement de touches de controle */ /* Mise a jour des flags lors du relachement de touches de controle */
if(breakcode) if (breakcode)
{ {
if(key == SCAN_ALT) if (key == SCAN_ALT)
{ {
kbdstatus &= ~STATUS_ALT; kbdstatus &= ~STATUS_ALT;
/* si ALT GR (E01D) alors activer aussi control */ /* si ALT GR (E01D) alors activer aussi control */
if (bufferscan[lastscan]==0xE0) kbdstatus &= ~STATUS_CTRL; if (bufferscan[lastscan] == 0xE0)
} kbdstatus &= ~STATUS_CTRL;
else if(key == SCAN_CTRL) }
else if (key == SCAN_CTRL)
kbdstatus &= ~STATUS_CTRL; kbdstatus &= ~STATUS_CTRL;
else if(key == SCAN_LEFTSHIFT || key == SCAN_RIGHTSHIFT) else if (key == SCAN_LEFTSHIFT || key == SCAN_RIGHTSHIFT)
kbdstatus &= ~STATUS_SHIFT; kbdstatus &= ~STATUS_SHIFT;
breakcode = 0; breakcode = 0;
return 0; return 0;
} }
/* Mise a jour des flags lors de l'appuie de touches de controle */ /* Mise a jour des flags lors de l'appuie de touches de controle */
if(key == SCAN_ALT) if (key == SCAN_ALT)
{ {
kbdstatus |= STATUS_ALT; kbdstatus |= STATUS_ALT;
/* si ALT GR (E01D) alors desactiver aussi control */ /* si ALT GR (E01D) alors desactiver aussi control */
if (bufferscan[lastscan]==0xE0) kbdstatus |= STATUS_CTRL; if (bufferscan[lastscan] == 0xE0)
return 0; kbdstatus |= STATUS_CTRL;
return 0;
} }
if(key == SCAN_CTRL) else if (key == SCAN_CTRL)
{ {
kbdstatus |= STATUS_CTRL; kbdstatus |= STATUS_CTRL;
return 0; return 0;
} }
if(key == SCAN_LEFTSHIFT || key == SCAN_RIGHTSHIFT) else if (key == SCAN_LEFTSHIFT || key == SCAN_RIGHTSHIFT)
{ {
kbdstatus |= STATUS_SHIFT; kbdstatus |= STATUS_SHIFT;
return 0; return 0;
} }
if ((key >= SCAN_F1) && (key <= SCAN_F8)) else if ((key >= SCAN_F1) && (key <= SCAN_F8))
{ {
changevc(key-SCAN_F1); changevc(key - SCAN_F1);
} }
else if (key == SCAN_F9)
{
int20;
}
else if (key == SCAN_F10)
{
apply_nextvideomode();
}
/* Scroll Lock, Num Lock, and Caps Lock mise a jour des leds */ /* Scroll Lock, Num Lock, and Caps Lock mise a jour des leds */
if(key == SCAN_SCROLLLOCK) else if (key == SCAN_SCROLLLOCK)
{ {
kbdstatus ^= STATUS_SCRL; kbdstatus ^= STATUS_SCRL;
goto LEDS; goto LEDS;
} }
if(key == SCAN_NUMLOCK) else if (key == SCAN_NUMLOCK)
{ {
kbdstatus ^= STATUS_NUM; kbdstatus ^= STATUS_NUM;
goto LEDS; goto LEDS;
} }
if(key == SCAN_CAPSLOCK) else if (key == SCAN_CAPSLOCK)
{ {
kbdstatus ^= STATUS_CAPS; kbdstatus ^= STATUS_CAPS;
LEDS: LEDS:
outkbd(0x60, 0xED); /* "mise a jour des LEDS */ outkbd(0x60, 0xED); /* "mise a jour des LEDS */
temp = 0; temp = 0;
if(kbdstatus & STATUS_SCRL) if (kbdstatus & STATUS_SCRL)
temp |= 1; temp |= 1;
if(kbdstatus & STATUS_NUM) if (kbdstatus & STATUS_NUM)
temp |= 2; temp |= 2;
if(kbdstatus & STATUS_CAPS) if (kbdstatus & STATUS_CAPS)
temp |= 4; temp |= 4;
outkbd(0x60, temp); /* 3 bits de poids faible pour les LEDs */ outkbd(0x60, temp); /* 3 bits de poids faible pour les LEDs */
return 0; return 0;
} }
/* est ce un code etendu */
if ((bufferscan[lastscan]==0xE0)||((kbdstatus & STATUS_NUM)&&(key>=0x47)&&(key<=0x53)&&(key!=0x4A)&&(key!=0x4e)))
/* exceptions */
{
/* '/' (E035) */
if (key==0x35) return '/';
/* '\r' (E01C) 2ème enter numérique*/
if (key==0x1C) return '\r';
/* 0x11 (E048) device control 1)*/
if (key==0x48) return 0x11;
/* 0x12 (E050) device control 2)*/
if (key==0x50) return 0x12;
/* 0x13 (E04b) device control 3)*/
if (key==0x4b) return 0x13;
/* 0x14 (E04d) device control 4)*/
if (key==0x4d) return 0x14;
/* 0x02 (E049) start of text)*/
if (key==0x49) return 0x2;
/* 0x03 (E051) end of text)*/
if (key==0x51) return 0x3;
/* 0x10 (E047) Line feed)*/
if (key==0x47) return '\n';
/* 0x1A (E052) Substitution)*/
if (key==0x52) return 0x1A;
/* 0x18 (E053) Cancel)*/
if (key==0x53) return 0x18;
/* 0x19 (E04f) End of medium)*/
if (key==0x4f) return 0x19;
return 0x00;
}
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))
temp = set1_altgr[key];
else if (kbdstatus & STATUS_CTRL)
temp = set1_ctrl[key];
else if (kbdstatus & STATUS_ALT)
temp = set1_alt[key];
else
temp = set1_normal[key];
}
/* si scancode non reconnu fin de fonction */
if(temp == 0) return temp;
/* Appuie de CRTL + ALT + SUPR ? */ /* Appuie de CRTL + ALT + SUPR ? */
if((kbdstatus & STATUS_CTRL) && (kbdstatus & STATUS_ALT) && if ((kbdstatus & STATUS_CTRL) && (kbdstatus & STATUS_ALT)
(key == 76)) && (key == 73))
{ {
print("redemarrage du systeme"); print("redemarrage du systeme");
reboot(); reboot();
} }
/* est ce un code etendu */
if ((bufferscan[lastscan] == 0xE0)
|| ((kbdstatus & STATUS_NUM) && (key >= 0x47) && (key <= 0x53)
&& (key != 0x4A) && (key != 0x4e)))
/* exceptions */
{
/* '/' (E035) */
if (key == 0x35)
return '/';
/* '\r' (E01C) 2ème enter numérique */
if (key == 0x1C)
return '\r';
/* 0x11 (E048) device control 1) */
if (key == 0x48)
return 0x11;
/* 0x12 (E050) device control 2) */
if (key == 0x50)
return 0x12;
/* 0x13 (E04b) device control 3) */
if (key == 0x4b)
return 0x13;
/* 0x14 (E04d) device control 4) */
if (key == 0x4d)
return 0x14;
/* 0x02 (E049) start of text) */
if (key == 0x49)
return 0x2;
/* 0x03 (E051) end of text) */
if (key == 0x51)
return 0x3;
/* 0x10 (E047) Line feed) */
if (key == 0x47)
return '\n';
/* 0x1A (E052) Substitution) */
if (key == 0x52)
return 0x1A;
/* 0x18 (E053) Cancel) */
if (key == 0x53)
return 0x18;
/* 0x19 (E04f) End of medium) */
if (key == 0x4f)
return 0x19;
return 0x00;
}
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))
temp = set1_altgr[key];
else if (kbdstatus & STATUS_CTRL)
temp = set1_ctrl[key];
else if (kbdstatus & STATUS_ALT)
temp = set1_alt[key];
else
temp = set1_normal[key];
}
/* si scancode non reconnu fin de fonction */
if (temp == 0)
return temp;
/* Renvoie le Code ascii */ /* Renvoie le Code ascii */
return temp; return temp;
} }
/******************************************************************************/ /******************************************************************************/
/* Handler d'interruption IRQ 1 pour le clavier */
void keyboard() __attribute__((interrupt)) void keyboard_handler(exception_stack_noerror *caller)
{
cli();
pushf();
pushad();
u8 scancode,ascii;
cli();
while ((inb(0x64)&1)==0);
scancode=inb(0x60);
ascii = convert(scancode);
if(ascii != 0)
{ {
ptrascii++; cli();
if (ptrascii==255) ptrascii==0; u8 scancode, ascii;
bufferascii[ptrascii]=ascii; while ((inb(0x64) & 1) == 0);
} scancode = inb(0x60);
irqendmaster(); ascii = convert(scancode);
popad(); if (ascii != 0)
popf(); {
ptrascii++;
if (ptrascii == 255)
ptrascii == 0;
bufferascii[ptrascii] = ascii;
}
irqendmaster();
sti(); sti();
asm("addl $0x01C, %esp;");
iret();
} }
/******************************************************************************/ /******************************************************************************/

View File

@ -1,16 +1,61 @@
CC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -fomit-frame-pointer -Wall -w -m32 -F pe-i386 -I ../include CC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -Wall -w -m32 -F elf_i386 -fno-pie -no-pie -I ../include -c
LINK=ld -m elf_i386 -r -o ASM=gcc -nostdinc -ffreestanding -fno-builtin -m32 -c -fno-pie -no-pie
OBJS=memory.o vga.o port.o video.o mouse.o idt.o timer.o keyboard.o types.o string.o graph.o 3d.o math.o cpu.o LINK=ld -m elf_i386 -r -o
SRCS= $(wildcard *.c)
all: makeall OBJS= $(SRCS:.c=.o)
SRCASM= $(wildcard *.S)
makeall: libs.o OBJASM= $(SRCASM:.S=.o)
CONVERT=dos2unix
libs.o:$(OBJS) INDENT=indent -nhnl -l75 -ppi3 -ts8 -bls -nbc -di8 -nbad -nbap -nsob -i8 -bl -bli0 -ncdw -nce -cli8 -cbi0 -npcs -cs -saf -sai -saw -nprs -lp -npsl
$(LINK) libs.o $(OBJS) REMOVE=rm -f
CHANGEPERM=chmod 644
.o: .c SYNC=sync
$(CC) $^
clean: all: libs.o
rm -f *.o $(SYNC)
togit: clean indent
libs.o:$(OBJS) $(OBJASM)
$(LINK) libs.o $(OBJS) $(OBJASM)
.o: .S
$(ASM) $^
handlers.o:handlers.c
$(CC) -mgeneral-regs-only $^
keyboard.o:keyboard.c
$(CC) -mgeneral-regs-only $^
mouse.o:mouse.c
$(CC) -mgeneral-regs-only $^
syscall.o:syscall.c
$(CC) -fomit-frame-pointer $^
.o: .c
$(CC) $^
clean:
$(REMOVE) *.o
$(REMOVE) *.c~
$(REMOVE) */*.c~
$(REMOVE) ../include/*.h~
$(REMOVE) ./TEST/*.c
$(SYNC)
indent:
$(CHANGEPERM) *.c
$(CONVERT) *.c
$(INDENT) *.c
$(REMOVE) *.c~
$(CHANGEPERM) ./*/*.c
$(CONVERT) ./*/*.c
$(INDENT) ./*/*.c
$(REMOVE) */*.c~
$(CHANGEPERM) ../include/*.h
$(CONVERT) ../include/*.h
$(INDENT) ../include/*.h
$(REMOVE) ../include/*.h~
$(SYNC)

265
lib/math.c Executable file → Normal file
View File

@ -1,7 +1,258 @@
#include "types.h" /*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
u32 abs(int x) /* */
{ #include "types.h"
if (x<0) x=-x; #include "timer.h"
return (u32)x; #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;
}
/*******************************************************************************/

653
lib/matrix.c Normal file
View File

@ -0,0 +1,653 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "matrix.h"
#include "types.h"
#include "math.h"
/*******************************************************************************/
/* Affiche un vecteur de 4 composantes */
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);
}
/*******************************************************************************/
/* Créé un vecteur de 4 composantes */
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;
}
/*******************************************************************************/
/* Copie un vecteur de 4 composantes */
void vector4_copy(vector4 src, vector4 * 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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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;
}
/*******************************************************************************/
/* Donne la longueur d'un vecteur à 4 composantes */
float vector4_len(vector4 src)
{
return sqrtf((src.x * src.x) + (src.y * src.y) + (src.z * src.z));
}
/*******************************************************************************/
/* Retourne le produit scalaire de deux vecteurs à 4 composantes */
float vector4_dotproduct(vector4 v1, vector4 v2)
{
return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z);
}
/*******************************************************************************/
/* Retourne la norme d'un vecteur à 4 composantes */
float vector4_norm(vector4 src)
{
return sqrtf((src.x * src.x) + (src.y * src.y) + (src.z * src.z));
}
/*******************************************************************************/
/* Retourne la distance de deux vecteurs à 4 composantes */
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));
}
/*******************************************************************************/
/* Compare deux vecteurs à 4 composantes */
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);
}
/*******************************************************************************/
/* Définie le plan normal à 3 vecteurs à 4 composantes */
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);
}
/*******************************************************************************/
/* Créé une matrice d'identité */
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]);
}
/*******************************************************************************/
/* Créé une matrice vide */
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]);
}
/*******************************************************************************/
/* Créé une matrice de redimensionnement (par un vecteur) */
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;
}
/*******************************************************************************/
/* Créé une matrice de déplacement */
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;
}
/*******************************************************************************/
/* Créé une matrice de redimensionnement (par un facteur) */
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);
}
/*******************************************************************************/
/* Créé une matrice de redimensionnement et de déplacement */
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;
}
/*******************************************************************************/
/* Créé une matrice de rotation autour de X */
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;
}
/*******************************************************************************/
/* Créé une matrice de rotation autour de Y */
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;
}
/*******************************************************************************/
/* Créé une matrice de rotation autour de Z */
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;
}
/*******************************************************************************/
/* Créé une matrice de rotation multiple */
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;
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[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;
}
/*******************************************************************************/
/* Multiplie deux matrices */
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);
}
/*******************************************************************************/
/* Transforme une matrice avec un vecteur à 4 composantes */
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;
}
/*******************************************************************************/
/* Calcule le déterminant d'une matrice */
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 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)));
}
/*******************************************************************************/
/* Crée une matrice adjointe */
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;
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;
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].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].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)
{
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)
{
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)
{
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].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].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;
}
/*******************************************************************************/
/* Crée une matrice de camera */
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_crossproduct(zaxis, up, &xaxis);
vector4_normalize(&xaxis);
vector4_crossproduct(xaxis, zaxis, &yaxis);
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;
vector4_create(0, 0, 0, 1, &matrix->V[3]);
matrix44_transpose(matrix);
vector4_create(-eye.x, -eye.y, -eye.z, 1, &negeye);
matrix44_transform(matrix, &negeye);
vector4_copy(negeye, &matrix->V[3]);
}
/*******************************************************************************/
/* Vérifie que deux matrices sont égales */
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]);
}
/*******************************************************************************/
/* Transforme une matrice en tableau */
float *toarray(matrix44 * m)
{
return &m->v;
}

764
lib/memory.c Executable file → Normal file
View File

@ -1,46 +1,718 @@
#include "types.h" /*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/*******************************************************************************/ /* */
#include "types.h"
/* Copie un octet une ou plusieurs fois en mémoire */ #include "memory.h"
void memset(void *dst, u8 val, u32 count,u32 size) #include "queue.h"
{ #include "asm.h"
u8 *temp; #include "boot.h"
for(temp = (u8 *)dst; count != 0; count--)
{ static u8 *kernelcurrentheap = NULL; /* pointeur vers le heap noyau */
temp+=size; static u8 bitmap[MAXMEMPAGE / 8]; /* bitmap */
*temp = val; static vrange_t vrange_head;
} static u64 memorysize=0;
}
extern bootparams* allparams;
/*******************************************************************************/
/*******************************************************************************/
/* Copie une portion de mémoire vers une autre */ /* Erreur fatale */
void memcpy(void *src, void *dst, u32 count, u32 size) void panic(u8 * string)
{ {
char *s, *d; printf("KERNEL PANIC: %s\r\nSysteme arrete...\n");
u32 i; halt();
s = (u8*) src; }
d = (u8*) dst;
for(i=0;i<count;i++){ /*******************************************************************************/
*(d+i*size) = *(s+i); /* Alloue plusieurs pages virtuelles (size) pour le heap du noyau */
}
} tmalloc *mallocpage(u64 size)
{
/*******************************************************************************/ tmalloc *chunk;
u8 *paddr;
/* Compare 2 portions de mémoire */ u16 nbpages = size / PAGESIZE;
u32 memcmp(void *src, void *dst, u32 count, u32 size) u64 realsize = nbpages * PAGESIZE;
{ if (size % PAGESIZE != 0)
const u8 *mem1 = (const u8 *)src; realsize += PAGESIZE;
const u8 *mem2 = (const u8 *)dst; if ((kernelcurrentheap - KERNEL_HEAP + realsize) > MAXHEAPSIZE)
for(; count != 0; count--) panic("Plus de memoire noyau heap disponible a allouer !\n");
{ chunk = (tmalloc *) kernelcurrentheap;
if(*mem1 != *mem2) virtual_range_new_kernel(kernelcurrentheap, realsize);
return *mem1 - *mem2; kernelcurrentheap += realsize;
mem1+=size; chunk->size = realsize;
mem2+=size; chunk->used = 0;
} return chunk;
} }
/*******************************************************************************/ /*******************************************************************************/
/* Retourne le nombre de blocs dynamiques (heap) */
u32 getmallocnb(void)
{
u32 realsize = 0;
tmalloc *chunk;
chunk = KERNEL_HEAP;
while (chunk < (tmalloc *) kernelcurrentheap)
{
realsize++;
chunk = (tmalloc *) ((u8 *) chunk + chunk->size);
}
return realsize;
}
/*******************************************************************************/
/* Retourne la mémoire virtuelle utilisée de façon dynamique (heap) */
u32 getmallocused(void)
{
u32 realsize = 0;
tmalloc *chunk;
chunk = KERNEL_HEAP;
while (chunk < (tmalloc *) kernelcurrentheap)
{
if (chunk->used)
realsize += chunk->size;
chunk = (tmalloc *) ((u8 *) chunk + chunk->size);
}
return realsize;
}
/*******************************************************************************/
/* Retourne la mémoire virtuelle libre de façon dynamique (heap) */
u32 getmallocfree(void)
{
u32 realsize = 0;
tmalloc *chunk;
chunk = KERNEL_HEAP;
while (chunk < (tmalloc *) kernelcurrentheap)
{
if (!chunk->used)
realsize += chunk->size;
chunk = (tmalloc *) ((u8 *) chunk + chunk->size);
}
return realsize;
}
/*******************************************************************************/
/* Retourne la mémoire virtuelle non allouée de façon dynamique (heap) */
u32 getmallocnonallocated(void)
{
return VESA_FBMEM - ((u32) kernelcurrentheap);
}
/*******************************************************************************/
/* Alloue de la mémoire virtuelle au noyau de façon dynamique (heap) */
void *vmalloc(u32 size)
{
u32 realsize;
tmalloc *chunk, *new;
realsize = sizeof(tmalloc) + size;
if (realsize < MALLOC_MINIMUM)
realsize = MALLOC_MINIMUM;
chunk = KERNEL_HEAP;
while (chunk->used || chunk->size < realsize)
{
if (chunk->size == 0)
panic(sprintf
("Element du heap %x defectueux avec une taille nulle (heap %x) !",
chunk, kernelcurrentheap));
chunk = (tmalloc *) ((u8 *) chunk + chunk->size);
if (chunk == (tmalloc *) kernelcurrentheap)
mallocpage(realsize);
else if (chunk > (tmalloc *) kernelcurrentheap)
panic(sprintf
("Element du heap %x depassant la limite %x !",
chunk, kernelcurrentheap));
}
if (chunk->size - realsize < MALLOC_MINIMUM)
chunk->used = 1;
else
{
new = (tmalloc *) ((u8 *) chunk + realsize);
new->size = chunk->size - realsize;
new->used = 0;
chunk->size = realsize;
chunk->used = 1;
}
return (u8 *) chunk + sizeof(tmalloc);
}
/*******************************************************************************/
/* Libère de la mémoire virtuelle depuis le heap noyau */
void vfree(void *vaddr)
{
tmalloc *chunk, *new;
chunk = (tmalloc *) (vaddr - sizeof(tmalloc));
chunk->used = 0;
while ((new = (tmalloc *) ((u8 *) chunk + chunk->size))
&& new < (tmalloc *) kernelcurrentheap && new->used == 0)
chunk->size += new->size;
}
/*******************************************************************************/
/* Retourne la taille de la mémoire physique (selon grub) */
u64 physical_getmemorysize()
{
return memorysize;
}
/*******************************************************************************/
/* Retourne que la page physique actuelle est occupée */
void physical_page_use(u32 page)
{
bitmap[(page / 8)] |= (1 << (page % 8));
}
/*******************************************************************************/
/* Retourne que la page physique actuelle est libre */
void physical_page_free(u32 page)
{
bitmap[(page / 8)] &= ~(1 << (page % 8));
}
/*******************************************************************************/
/* Reserve un espace mémoire physique dans le bitmap */
void physical_range_use(u64 addr, u64 len)
{
u32 nbpage = TOPAGE(len);
u32 pagesrc = TOPAGE(addr);
if (len & 0x3FF > 0)
nbpage++;
if (addr >= MAXMEMSIZE)
return;
if (addr + len >= MAXMEMSIZE)
len = MAXMEMSIZE - addr - 1;
for (u32 page = pagesrc; page < pagesrc + nbpage; page++)
physical_page_use(page);
}
/*******************************************************************************/
/* Libère un espace mémoire physique dans le bitmap */
void physical_range_free(u64 addr, u64 len)
{
u32 nbpage = TOPAGE(len);
u32 pagesrc = TOPAGE(addr);
if (len & 0x3FF > 0)
nbpage++;
if (addr >= MAXMEMSIZE)
return;
if (addr + len >= MAXMEMSIZE)
len = MAXMEMSIZE - addr - 1;
for (u32 page = pagesrc; page < pagesrc + nbpage; page++)
physical_page_free(page);
}
/*******************************************************************************/
/* Retourne une page physique libre */
u8 *physical_page_getfree(void)
{
u32 byte;
u8 bit;
u32 page = 0;
for (byte = 0; byte < sizeof(bitmap); byte++)
if (bitmap[byte] != 0xFF)
for (bit = 0; bit < 8; bit++)
if (!(bitmap[byte] & (1 << bit)))
{
page = 8 * byte + bit;
physical_page_use(page);
return (u8 *) (page * PAGESIZE);
}
return NULL;
}
/*******************************************************************************/
/* Retourne l'espace libre */
u64 getmemoryfree(void)
{
u32 byte, bit;
u64 free = 0;
for (byte = 0; byte < sizeof(bitmap); byte++)
if (bitmap[byte] != 0xFF)
for (bit = 0; bit < 8; bit++)
if (!(bitmap[byte] & (1 << bit)))
free += PAGESIZE;
return free;
}
/*******************************************************************************/
/* Initialisation du bitmap pour la gestion physique de la mémoire */
void physical_init()
{
for (u64 page = 0; page < sizeof(bitmap); page++)
bitmap[page] = 0xFF;
for (u8 i=0;i<allparams->e820_numbers;i++)
{
if (allparams->e820_table[i].type == E820_TYPE_RAM)
physical_range_free(allparams->e820_table[i].addr, allparams->e820_table[i].size);
else
physical_range_use(allparams->e820_table[i].addr, allparams->e820_table[i].size);
if ((allparams->e820_table[i].addr + allparams->e820_table[i].size > memorysize) && allparams->e820_table[i].type == E820_TYPE_RAM)
memorysize = allparams->e820_table[i].addr + allparams->e820_table[i].size;
if (memorysize >= MAXMEMSIZE)
memorysize = MAXMEMSIZE - 1;
}
physical_range_use(0x0, KERNELSIZE);
}
/*******************************************************************************/
/* Retourne une page virtuelle de mémoire */
page *virtual_page_getfree(void)
{
page *pg;
vrange *vpages;
u8 *vaddr, *paddr;
paddr = physical_page_getfree();
if (paddr == NULL)
panic("Plus de memoire physique disponible !\n");
if (TAILQ_EMPTY(&vrange_head))
panic("Plus de place disponible dans la reserve de page !\n");
vpages = TAILQ_FIRST(&vrange_head);
vaddr = vpages->vaddrlow;
vpages->vaddrlow += PAGESIZE;
if (vpages->vaddrlow == vpages->vaddrhigh)
{
TAILQ_REMOVE(&vrange_head, vpages, tailq);
vfree(vpages);
}
virtual_pd_page_add(NULL, vaddr, paddr, 0);
pg = (page *) vmalloc(sizeof(page));
pg->vaddr = vaddr;
pg->paddr = paddr;
return pg;
}
/*******************************************************************************/
/* Création d'un directory pour la gestion virtuelle de la mémoire */
pd *virtual_pd_create()
{
pd *new;
u32 *pdir, *pd0;
u32 i;
new = (pd *) vmalloc(sizeof(pd));
new->addr = virtual_page_getfree();
pdir = (u32 *) new->addr->vaddr;
pd0 = (u32 *) KERNEL_PD_ADDR;
for (i = 0; i < 256; i++)
pdir[i] = pd0[i];
for (i = 256; i < 1023; i++)
pdir[i] = 0;
pdir[1023] =
((u32) new->addr->paddr | (PAGE_PRESENT | PAGE_WRITE));
TAILQ_INIT(&new->page_head);
return new;
}
/*******************************************************************************/
/* Attache une page virtuelle de la mémoire dans le directory spécifié */
void virtual_pd_page_add(pd * dst, u8 * vaddr, u8 * paddr, u32 flags)
{
u32 *pdir;
u32 *ptable;
u32 *pt;
page *pg;
int i;
if (dst == NULL)
if (vaddr > (u8 *) USER_CODE)
{
printf("ERREUR: Adresse %X n'est pas dans l'espace noyau !\n", vaddr);
return;
}
pdir = (u32 *) (0xFFFFF000 | (((u32) vaddr & 0xFFC00000) >> 20));
if ((*pdir & PAGE_PRESENT) == 0)
{
if (dst == NULL)
panic(sprintf
("Page table introuvable pour l'adresse %x !\r\n",
vaddr));
pg = virtual_page_getfree();
pt = (u32 *) pg->vaddr;
for (i = 1; i < 1024; i++)
pt[i] = 0;
*pdir = (u32) pg->paddr | (PAGE_PRESENT | PAGE_WRITE |
flags);
if (dst)
TAILQ_INSERT_TAIL(&dst->page_head, pg, tailq);
}
ptable = (u32 *) (0xFFC00000 | (((u32) vaddr & 0xFFFFF000) >> 10));
*ptable = ((u32) paddr) | (PAGE_PRESENT | PAGE_WRITE | flags);
return;
}
/*******************************************************************************/
/* Retire une page virtuelle de la mémoire dans le directory spécifié */
void virtual_pd_page_remove(u8 * vaddr)
{
u32 *ptable;
if (virtual_to_physical(vaddr))
{
ptable = (u32 *) (0xFFC00000 |
(((u32) vaddr & 0xFFFFF000) >> 10));
*ptable = (*ptable & (~PAGE_PRESENT));
asm("invlpg %0"::"m"(vaddr));
}
return;
}
/*******************************************************************************/
/* Renvoie l'adresse physique de la page virtuel */
u8 *virtual_to_physical(u8 * vaddr)
{
u32 *pdir;
u32 *ptable;
pdir = (u32 *) (0xFFFFF000 | (((u32) vaddr & 0xFFC00000) >> 20));
if ((*pdir & PAGE_PRESENT))
{
ptable = (u32 *) (0xFFC00000 |
(((u32) vaddr & 0xFFFFF000) >> 10));
if ((*ptable & PAGE_PRESENT))
return (u8 *) ((*ptable & 0xFFFFF000) +
(TOPG((u32) vaddr)));
}
return 0;
}
/*******************************************************************************/
/* Détermine une plage virtuelle de mémoire comme étant mappé aux adresses physiques spécifiées GENERIQUE*/
void virtual_range_use(pd * dst, u8 * vaddr, u8 * paddr, u64 len,
u32 flags)
{
u64 i;
u32 realen = len / PAGESIZE;
page *pg;
if (len % PAGESIZE != 0)
realen++;
for (i = 0; i < realen; i++)
{
if (dst == NULL)
{
virtual_pd_page_add(dst, vaddr + i * PAGESIZE,
paddr + i * PAGESIZE, flags);
}
else
{
pg = (page *) vmalloc(sizeof(page));
pg->paddr = paddr + i * PAGESIZE;
pg->vaddr = vaddr + i * PAGESIZE;
TAILQ_INSERT_TAIL(&dst->page_head, pg, tailq);
virtual_pd_page_add(dst, pg->vaddr, pg->paddr,
flags);
}
}
}
/*******************************************************************************/
/* Supprime une plage virtuelle de mémoire GENERIQUE */
void virtual_range_free(pd * dst, u8 * vaddr, u64 len)
{
u64 i;
u32 realen = len / PAGESIZE;
if (len % PAGESIZE != 0)
realen++;
for (i = 0; i < realen; i++)
{
virtual_pd_page_remove(vaddr + i * PAGESIZE);
virtual_page_free(vaddr);
}
}
/*******************************************************************************/
/* Détermine une plage virtuelle de mémoire en attribuant de la mémoire physique GENERIQUE */
void virtual_range_new(pd * dst, u8 * vaddr, u64 len, u32 flags)
{
u64 i;
u32 realen = len / PAGESIZE;
page *pg;
if (len % PAGESIZE != 0)
realen++;
for (i = 0; i < realen; i++)
{
if (dst == NULL)
{
virtual_pd_page_add(dst, vaddr + i * PAGESIZE,
physical_page_getfree(),
flags);
}
else
{
pg = (page *) vmalloc(sizeof(page));
pg->paddr = physical_page_getfree();
pg->vaddr = vaddr + i * PAGESIZE;
TAILQ_INSERT_TAIL(&dst->page_head, pg, tailq);
virtual_pd_page_add(dst, pg->vaddr, pg->paddr,
flags);
}
}
}
/*******************************************************************************/
/* Détermine une plage virtuelle de mémoire comme étant mappé aux adresses physiques spécifiées pour le noyau*/
void virtual_range_use_kernel(u8 * vaddr, u8 * paddr, u64 * len, u32 flags)
{
virtual_range_use(NULL, vaddr, paddr, len, flags);
}
/*******************************************************************************/
/* Supprime une plage virtuelle de mémoire pour le noyau */
void virtual_range_free_kernel(u8 * vaddr, u64 len)
{
virtual_range_free(NULL, vaddr, len);
}
/*******************************************************************************/
/* Détermine une plage virtuelle de mémoire en attribuant de la mémoire physique pour le noyau */
void virtual_range_new_kernel(u8 * vaddr, u64 len, u32 flags)
{
virtual_range_new(NULL, vaddr, len, flags);
}
/*******************************************************************************/
/* Renvoie le nombre de pages virtuelles occupées */
u32 virtual_getpagesused()
{
u32 maxpage = ((u32) MAXPAGESSIZE) / ((u16) PAGESIZE);
return maxpage - virtual_getpagesfree();
}
/*******************************************************************************/
/* Renvoie le nombre de pages virtuelles libres */
u32 virtual_getpagesfree()
{
vrange *next;
u32 realsize = 0;
TAILQ_FOREACH(next, &vrange_head, tailq) realsize +=
(next->vaddrhigh - next->vaddrlow) / PAGESIZE;
return realsize;
}
/*******************************************************************************/
/* Libère une page virtuelle de la mémoire */
void virtual_page_free(u8 * vaddr)
{
vrange *next, *prev, *new;
u8 *paddr;
paddr = virtual_to_physical(vaddr);
if (paddr)
physical_page_free(TOPAGE((u32) paddr));
else
{
printf("Aucune page associee a l'adresse virtuelle %x\n",
vaddr);
return;
}
virtual_pd_page_remove(vaddr);
TAILQ_FOREACH(next, &vrange_head, tailq)
{
if (next->vaddrlow > vaddr)
break;
}
prev = TAILQ_PREV(next, vrange_s, tailq);
if (prev->vaddrhigh == vaddr)
{
prev->vaddrhigh += PAGESIZE;
if (prev->vaddrhigh == next->vaddrlow)
{
prev->vaddrhigh = next->vaddrhigh;
TAILQ_REMOVE(&vrange_head, next, tailq);
vfree(next);
}
}
else if (next->vaddrlow == vaddr + PAGESIZE)
{
next->vaddrlow = vaddr;
}
else if (next->vaddrlow > vaddr + PAGESIZE)
{
new = (vrange *) vmalloc(sizeof(vrange));
new->vaddrlow = vaddr;
new->vaddrhigh = vaddr + PAGESIZE;
TAILQ_INSERT_BEFORE(prev, new, tailq);
}
else
panic("Liste chainee corrompue !\n");
return 0;
}
/*******************************************************************************/
/* Destruction d'un directory pour la gestion virtuelle de la mémoire */
void virtual_pd_destroy(pd * dst)
{
page *pg;
TAILQ_FOREACH(pg, &dst->page_head, tailq)
{
virtual_page_free(pg->vaddr);
TAILQ_REMOVE(&dst->page_head, pg, tailq);
vfree(pg);
}
virtual_page_free(dst->addr->vaddr);
vfree(dst);
return 0;
}
/*******************************************************************************/
/* Affiche toutes les page du directory */
void virtual_pd_show(pd *dst)
{
page *pg;
bool first=true;
TAILQ_FOREACH(pg, &dst->page_head, tailq)
{
if (!first)
print(",");
else
first=false;
printf("%Y",(u32)pg->vaddr);
}
}
/*******************************************************************************/
/* Initialise une pages virtuelles (size) pour le heap du noyau */
void malloc_init(void)
{
tmalloc *chunk;
chunk = (tmalloc *) KERNEL_HEAP;
virtual_pd_page_add(NULL, KERNEL_HEAP, physical_page_getfree(),
PAGE_NOFLAG);
kernelcurrentheap = KERNEL_HEAP + PAGESIZE;
chunk->size = PAGESIZE;
chunk->used = 0;
}
/*******************************************************************************/
/* Initialisation d'une STAILQ pour la gestion virtuelle de la mémoire */
void virtual_init(void)
{
vrange *vpages = (vrange *) vmalloc(sizeof(vrange));
vpages->vaddrlow = (u8 *) KERNEL_PAGES + PAGESIZE;
vpages->vaddrhigh = (u8 *) KERNEL_PAGES + MAXPAGESSIZE;
TAILQ_INIT(&vrange_head);
TAILQ_INSERT_TAIL(&vrange_head, vpages, tailq);
}
/*******************************************************************************/
/* Initialisation des 8 premiers MB de la mémoire en identity mapping */
void identity_init(void)
{
u32 i;
u32 *pd0 = KERNEL_PD_ADDR;
u8 *pg0 = (u8 *) 0;
u8 *pg1 = (u8 *) (PAGESIZE * PAGENUMBER);
pd0[0] = ((u32) pg0 | (PAGE_PRESENT | PAGE_WRITE | PAGE_4MB));
pd0[1] = ((u32) pg1 | (PAGE_PRESENT | PAGE_WRITE | PAGE_4MB));
for (i = 2; i < 1023; i++)
pd0[i] = ((u32) pg1 +
PAGESIZE * i) | (PAGE_PRESENT | PAGE_WRITE);
pd0[1023] = ((u32) pd0 | (PAGE_PRESENT | PAGE_WRITE));
}
/*******************************************************************************/
/* Initialisation des registres CR0, CR3, CR4 */
void registry_init(void)
{
asm("mov %[directory_addr], %%eax \n \
mov %%eax, %%cr3 \n \
mov %%cr4, %%eax \n \
or $0x00000010, %%eax \n \
mov %%eax, %%cr4 \n \
mov %%cr0, %%eax \n \
or $0x80000001, %%eax \n \
mov %%eax, %%cr0"::[directory_addr] "i"(KERNEL_PD_ADDR));
}
/*******************************************************************************/
/* Initialisation de la mémoire paginée */
void initpaging()
{
identity_init();
registry_init();
physical_init();
malloc_init();
virtual_init();
}
/*******************************************************************************/
/* Copie un octet une ou plusieurs fois en mémoire */
void memset(void *dst, u8 val, u32 count, u32 size)
{
u8 *d = (u8 *) dst;
if (size > 0)
size--;
for (; count != 0; count--)
{
*(d++) = val;
d += size;
}
}
/*******************************************************************************/
/* Copie une portion de mémoire vers une autre */
void memcpy(void *src, void *dst, u32 count, u32 size)
{
u8 *s = (u8 *) src;
u8 *d = (u8 *) dst;
if (size > 0)
size--;
for (; count != 0; count--)
{
*(d++) = *(s++);
d += size;
}
}
/*******************************************************************************/
/* Compare 2 portions de mémoire */
u32 memcmp(void *src, void *dst, u32 count, u32 size)
{
u8 *s = (u8 *) src;
u8 *d = (u8 *) dst;
if (size > 0)
size--;
for (; count != 0; count--)
{
if (*(s++) != *(d++))
return *d - *s;
s += size;
d += size;
}
}
/*******************************************************************************/

View File

@ -1,225 +0,0 @@
/* definition des registres de la carte VGA pour differents modes */
#define maxgraphmode 11
#define maxtextmode 5
static mode_def textmodes[maxtextmode] = {
/*40*25 16 couleurs mode 0x00*/
{
0x67,
0x03, 0x08, 0x03, 0x00, 0x02,
0x2D, 0x27, 0x28, 0x90, 0x2B, 0xA0, 0xBF, 0x1F, 0x00,
0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x8E, 0x8F, 0x14, 0x1F, 0x96, 0xB9, 0xA3, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x0C, 0x00, 0x0F, 0x08, 0x00,
45, 25, 4
},
/*80*25 16 couleurs mode 0x01*/
{
0x67,
0x03, 0x00, 0x03, 0x00, 0x02,
0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00,
0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x0E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x0C, 0x00, 0x0F, 0x08, 0x00,
80, 25, 4
},
/*80*50 16 couleurs mode 0x02*/
{
0x63,
0x03, 0x01, 0x03, 0x05, 0x02,
0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00,
0x47, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x8E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x0C, 0x00, 0x0F, 0x00, 0x00,
80, 50, 4
},
/*100*50 16 couleurs mode 0x03*/
{
0x67,
0x03, 0x01, 0x03, 0x05, 0x02,
0x70, 0x63, 0x64, 0x85, 0x68, 0x84, 0xBF, 0x1F, 0x00,
0x47, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x8E, 0x8F, 0x32, 0x1F, 0x96, 0xB9, 0xA3, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x0C, 0x00, 0x0F, 0x00, 0x00,
100, 50, 4
},
/*100*60 16 couleurs mode 0x04*/
{
0xA7,
0x03, 0x01, 0x03, 0x05, 0x02,
0x70, 0x63, 0x64, 0x85, 0x68, 0x84, 0xFF, 0x1F, 0x00,
0x47, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
0xE7, 0x8E, 0xDF, 0x32, 0x1F, 0xDF, 0xE5, 0xA3, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x0C, 0x00, 0x0F, 0x00, 0x00,
100, 60, 4
}
};
static mode_def graphmodes[maxgraphmode] = {
/*640*480 n&b mode 0x80*/
{
0xE3,
0x03, 0x01, 0x0F, 0x00, 0x06,
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xEA, 0x0C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x01, 0x00, 0x0F, 0x00, 0x00,
80, 60, 1
},
/*320*200 4 couleurs mode 0x81*/
{
0x63,
0x03, 0x09, 0x03, 0x00, 0x02,
0x2D, 0x27, 0x28, 0x90, 0x2B, 0x80, 0xBF, 0x1F, 0x00,
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x0E, 0x8F, 0x14, 0x00, 0x96, 0xB9, 0xA3, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x02, 0x00, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x01, 0x00, 0x03, 0x00, 0x00,
40, 25,
},
/*640*480 16 couleurs mode 0x82*/
{
0xE3,
0x03, 0x01, 0x0F, 0x00, 0x06,
0x5F, 0x4F, 0x50, 0x82, 0x53, 0x9F, 0x0B, 0x3E, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xE9, 0x8B, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x01, 0x00, 0x0F, 0x00, 0x00,
80, 60, 4
},
/*720*480 16 couleurs mode 0x83*/
{
0xE7,
0x03, 0x01, 0x08, 0x00, 0x06,
0x6B, 0x59, 0x5A, 0x82, 0x60, 0x8D, 0x0B, 0x3E, 0x00,
0x40, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
0xEA, 0x0C, 0xDF, 0x2D, 0x08, 0xE8, 0x05, 0xE3, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x05, 0x0F, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x01, 0x00, 0x0F, 0x00, 0x00,
90, 60, 4
},
/*800*600 16 couleurs mode 0x84*/
{
0xE7,
0x03, 0x01, 0x0F, 0x00, 0x06,
0x70, 0x63, 0x64, 0x92, 0x65, 0x82, 0x70, 0xF0, 0x00,
0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x5B, 0x8C, 0x57, 0x32, 0x00, 0x58, 0x70, 0xE3, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x01, 0x00, 0x0F, 0x00, 0x00,
100, 75, 4
},
/*320*200 256 couleurs RAPIDE mode 0x85*/
{
0x63,
0x03, 0x01, 0x0F, 0x00, 0x0E,
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00,
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x0E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00,
40, 25, 8
},
/*320*200 256 couleurs mode 0x86*/
{
0x63,
0x03, 0x01, 0x0F, 0x00, 0x06,
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00,
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x0E, 0x8F, 0x28, 0x00, 0x96, 0xB9, 0xE3, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00,
40, 25, 8
},
/*320*400 256 couleurs mode 0x87*/
{
0x63,
0x03, 0x01, 0x0F, 0x00, 0x06,
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x8E, 0x8F, 0x28, 0x00, 0x96, 0xB9, 0xE3, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00,
40, 50, 8
},
/*320*480 256 couleurs mode 0x88*/
{
0xE3,
0x03, 0x01, 0x0F, 0x00, 0x06,
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xEA, 0xAC, 0xDF, 0x28, 0x00, 0xE7, 0x06, 0xE3, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00,
40, 60, 8
},
/*360*480 256 couleurs mode 0x89*/
{
0xE7,
0x03, 0x01, 0x0F, 0x00, 0x06,
0x6B, 0x59, 0x5A, 0x8E, 0x5E, 0x8A, 0x0D, 0x3E, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xEA, 0xAC, 0xDF, 0x2D, 0x00, 0xE7, 0x06, 0xE3, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00,
45, 60, 8
},
/*400*600 256 couleurs mode 0x8A*/
{
0xE7,
0x03, 0x01, 0x0F, 0x00, 0x06,
0x74, 0x63, 0x64, 0x97, 0x68, 0x95, 0x86, 0xF0, 0x00,
0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x5B, 0x8D, 0x57, 0x32, 0x00, 0x60, 0x80, 0xE3, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00,
50, 75, 8
}
};

215
lib/mouse.c Executable file → Normal file
View File

@ -1,3 +1,6 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "types.h" #include "types.h"
#include "asm.h" #include "asm.h"
#include "mouse.h" #include "mouse.h"
@ -5,134 +8,142 @@
#include "vga.h" #include "vga.h"
#include "video.h" #include "video.h"
bool initmouse() /******************************************************************************/
/* initialise la souris */
bool initmouse(void)
{ {
u16 i=1024; u16 i = 1024;
outkbd(0x64,0xA8); /* autorisé Aux */ outkbd(0x64, 0xA8); /* autorisé Aux */
outmseack(0xf3); /*sample*/ outmseack(0xf3); /*sample */
outmseack(100); /*sample donnée*/ outmseack(100); /*sample donnée */
outmseack(0xe8); /*resolution*/ outmseack(0xe8); /*resolution */
outmseack(3); /*resolution donnée*/ outmseack(3); /*resolution donnée */
outmseack(0xe7); /* echelle 2:1*/ outmseack(0xe7); /* echelle 2:1 */
outmseack(0xf4); /* Autorise peripherique */ outmseack(0xf4); /* Autorise peripherique */
outmsecmd(0x47); /* Autorise interruption */ outmsecmd(0x47); /* Autorise interruption */
while(i-->0) if (inb(0x60)==250) return 1; while (i-- > 0)
return 0; if (inb(0x60) == 250)
return 1;
return 0;
} }
static u8 bytepos=0,mousereplies=0; static u8 bytepos = 0, mousereplies = 0;
static u8 mpacket[3]; static u8 mpacket[3];
static s32 mousex=40, mousey=12; static s32 mousex = 40, mousey = 12;
static u16 oldx=0, oldy=0; static u16 oldx = 0, oldy = 0;
static u8 oldchar=0x00,oldattr=0x07; static u8 oldchar = 0x00, oldattr = 0x07;
static bool mousebut1=0,mousebut2=0,mousebut3=0; static bool mousebut1 = 0, mousebut2 = 0, mousebut3 = 0;
static u8 speed=6; static u8 speed = 6;
/******************************************************************************/
/* ecriture vers souris */
void outmseack(u8 value) void outmseack(u8 value)
{ {
outkbd(0x64,0xD4); /* ecriture vers souris */ outkbd(0x64, 0xD4);
outb(0x60,value); outb(0x60, value);
mousereplies++; mousereplies++;
} }
/* ecriture vers mode */
void outmsecmd(u8 command) void outmsecmd(u8 command)
{ {
outkbd(0x64,0x60); /* ecriture vers mode */ outkbd(0x64, 0x60);
outb(0x60,command); outb(0x60, command);
} }
void mouse() /******************************************************************************/
/* Handler d'interruption de la souris IRQ 12 */
__attribute__((interrupt)) void mouse_handler(exception_stack_noerror *caller)
{ {
u8 mbyte=inb(0x60); cli();
s8 changex,changey; u8 mbyte = inb(0x60);
cli(); s8 changex, changey;
if (mousereplies > 0) if (mousereplies > 0)
{ {
if (mbyte == 0xFA) if (mbyte == 0xFA)
{ {
mousereplies--; mousereplies--;
goto endofint; goto endofint;
} }
mousereplies = 0; mousereplies = 0;
} }
mpacket[bytepos]=mbyte; mpacket[bytepos] = mbyte;
bytepos++; bytepos++;
if(bytepos==3) {
bytepos=0;
if ( mpacket[1] == 0)
{
changex = 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]);
}
mousex+= (changex<<speed); if (bytepos == 3)
mousey+= (changey<<speed); {
bytepos = 0;
if(mousex<0) { mousex=0; } if (mpacket[1] == 0)
if(mousex>=65535) { mousex=65535; } {
if(mousey<0) { mousey=0; } changex = 0;
if(mousey>=65535) { mousey=65535; } }
else
u16 newx=(u32)mousex*getxres()/65536; {
u16 newy=(u32)mousey*getyres()/65536; 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]);
}
mousex += (changex << speed);
mousey += (changey << speed);
if (mousex < 0)
{
mousex = 0;
}
if (mousex >= 65535)
{
mousex = 65535;
}
if (mousey < 0)
{
mousey = 0;
}
if (mousey >= 65535)
{
mousey = 65535;
}
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;
mousebut2 = mpacket[0] & 2;
mousebut3 = mpacket[0] & 4;
// Retrieve mouse button status from packet
mousebut1=mpacket[0] & 1;
mousebut2=mpacket[0] & 2;
mousebut3=mpacket[0] & 4;
// printf("RX:%d\tRY:%d\tX:%d\tY:%d\tB1:%d\tB2:%d\tB3:%d\t\r\n",changex,changey,mousex,mousey,mousebut1,mousebut2,mousebut3); // printf("RX:%d\tRY:%d\tX:%d\tY:%d\tB1:%d\tB2:%d\tB3:%d\t\r\n",changex,changey,mousex,mousey,mousebut1,mousebut2,mousebut3);
if ((newx!=oldx)||(newy!=oldy)) if (!info->isgraphic)
{ showchar(newx, newy, 0xDB, 0x0F);
showchar(oldx,oldy,oldchar,oldattr); }
oldx=newx; endofint:
oldy=newy; irqendmaster();
oldchar=getchar(oldx,oldy); irqendslave();
oldattr=getattrib(oldx,oldy); sti();
showchar(newx,newy,0xDB,0x0F);
}
}
endofint:
irqendmaster();
irqendslave();
sti();
//asm("movl 0x2C(%esp), %ebx;movl 0x30(%esp), %esi;movl 0x34(%esp), %edi;movl 0x38(%esp), %ebp;addl $0x3C, %esp;iret;");
asm(
"addl $0x18,%esp;\
popl %bx;\
iret;");
} }
/*******************************************************************************/

147
lib/pci.c Normal file
View File

@ -0,0 +1,147 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "asm.h"
#include "types.h"
#include "pci.h"
#include "PCI/class.c"
#define MAX_BUS_SCAN 256
#define MAX_DEVICE_SCAN 32
#define MAX_FUNCTION_SCAN 8
/*******************************************************************************/
/* Retourne une chaine correspondant à l'ID class/subclass PCI */
u8 *pcigetclassname(const pcidev * device)
{
pciclass *class = NULL;
if (device == NULL)
{
return NULL;
}
if (device->base_class == 0xff)
{
return "Unassigned class";
}
class = classcodes[device->base_class];
if (!class)
{
return "Unknowned class";
}
while (class->name != NULL)
{
if (class->number == device->sub_class)
{
return class->name;
}
class++;
}
return "Unknowned class";
}
/*******************************************************************************/
/* Récupère les identifiants vendeur / periphérique du periphérique PCI donnée */
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;
}
/*******************************************************************************/
/* 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)
{
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 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;
}
/*******************************************************************************/
/* Scan le bus PCI et affiche les périphériques */
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;
}
/*******************************************************************************/
/* Scan le bus PCI et affiche les périphériques */
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;
}
/*******************************************************************************/

View File

@ -1,68 +0,0 @@
#include "types.h"
#include "asm.h"
/*******************************************************************************/
/* Envoie une série d'octet a destination d'une portion de mémoire
vers le registre video spécifié */
void outreg(u16 port,u8 *src,u16 num)
{
int i;
for(i=0;i<num;i++)
{
outb(port,i);
outb(port+1,*src++);
}
}
/*******************************************************************************/
/* Envoie une série d'octet a destination d'une portion de mémoire
vers le registre video spécifié (accés data et index confondu) */
void outregsame(u16 port,u8 *src,u16 num)
{
int i;
for(i=0;i<num;i++)
{
inb(port);
outb(port,i);
outb(port,*src++);
}
}
/*******************************************************************************/
/* Récupère une série d'octet en provenance d'un registre video spécifié
vers portion de mémoire */
void inreg(u16 port,u8 *src,u16 num)
{
int i;
for(i=0;i<num;i++)
{
outb(port,i);
*src++=inb(port+1);
}
}
/*******************************************************************************/
/* Récupère une série d'octet en provenance d'un registre video spécifié
vers portion de mémoire (accés data et index confondu) */
void inregsame(u16 port,u8 *src,u16 num)
{
int i;
for(i=0;i<num;i++)
{
inb(port);
outb(port,i);
*src++=inb(port);
}
}
/*******************************************************************************/

568
lib/process.c Normal file
View File

@ -0,0 +1,568 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "types.h"
#include "process.h"
#include "memory.h"
#include "gdt.h"
process *processes;
tid_t current;
pid_t 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
};
/*******************************************************************************/
/* Vérifie la signature ELF
0 - RAS
1 - Pas la signature ELF
2 - pas ELF32
3 - pas bon organisation LSB/MSB
4 - pas bonne version ELF
5 - pas bon OS
6 - pas bon type machine */
u32 iself(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;
}
else
return 1;
}
/*******************************************************************************/
/* Met fin à une tâche */
/* SYSCALL
{
"ID":5,
"LIBRARY":"libsys",
"NAME":"exit",
"INTERNALNAME":"processexit",
"DESCRIPTION":"End a task for user or kernel domain",
"ARGS": [
{"TYPE":"u32","NAME":"resultcode","DESCRIPTION":"Code result of the execution"}
],
"RETURN":"u32"
}
END-SYSCALL */
void processexit(void)
{
cli();
deleteprocess(getcurrentpid());
switchtask(maketid(1,1));
sti();
}
/*******************************************************************************/
/* Charge le fichier ELF en mémoire et mets à jour les informations sur le processus */
u32 loadelf(u8 * src, pid_t pid)
{
u8 *ptr;
u8 code;
u32 v_begin, v_end;
elf32 *header;
elf32p *program;
u32 i;
header = (elf32 *) src;
program = (elf32p *) (src + header->e_phoff);
code = iself(src);
process *aprocess=findprocess(pid);
if (aprocess==NULL) return NULL;
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)
{
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);
return 0;
}
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)
{
aprocess->exec_low = (u8 *) v_begin;
aprocess->exec_high = (u8 *) v_end;
}
if (program->p_flags == PF_W + PF_R)
{
aprocess->bss_low = (u8 *) v_begin;
aprocess->bss_high = (u8 *) v_end;
}
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++)
ptr[i] = 0;
}
}
return header->e_entry;
}
/*******************************************************************************/
/* Initialise la liste des processus */
void initprocesses(void)
{
u32 i = 0;
processes = (process *) vmalloc(sizeof(process) * MAXNUMPROCESS);
while (i < MAXNUMPROCESS)
{
processes[i].pid = i+1;
processes[i++].status = PROCESS_STATUS_FREE;
}
pid_t pid=(pid_t)1;
process *aprocess=findprocess(pid);
if (aprocess==NULL) return NULL;
aprocess->pid = pid;
aprocess->result = 0;
aprocess->pdd = NULL;
aprocess->status = PROCESS_STATUS_RUN;
aprocess->iskernel = true;
TAILQ_INIT(&aprocess->task_head);
current=createtask(pid,getinitretry(),true);
task *atask = findtask(current);
atask->status = TASK_STATUS_RUN;
}
/*******************************************************************************/
/* Récupère un emplacement dans la liste des processus */
pid_t getfreepid(void)
{
if ((u32)lastpid==0 || lastpid>MAXNUMPROCESS)
lastpid=(pid_t)1;
process* aprocess=findprocess(lastpid);
aprocess=getnextprocess(aprocess, PROCESS_STATUS_FREE);
if (aprocess == NULL)
{
printf("PANIC: plus d'emplacement disponible pour un novueau processus\n");
return NULL;
}
lastpid=aprocess->pid;
return lastpid;
}
/*******************************************************************************/
/* Récupère un emplacement dans la liste des tâche du processus donné */
tid_t getfreeptid(pid_t pid)
{
process *aprocess=findprocess(pid);
if (aprocess==NULL) return maketid(0,0);
u32 number=0;
task *next;
TAILQ_FOREACH(next, &aprocess->task_head, tailq)
if (next->tid.number>number)
number=next->tid.number;
number++;
return maketid(pid,number);
}
/*******************************************************************************/
/* Récupère le PID du processus courant */
pid_t getcurrentpid(void)
{
return current.pid;
}
/*******************************************************************************/
/* Récupère le TID de la tâche courante */
tid_t getcurrenttid(void)
{
return current;
}
/*******************************************************************************/
/* Change la tâche désigné dans le TID */
tid_t maketid(pid_t pid, u32 number)
{
tid_t newtid;
newtid.pid=pid;
newtid.number=number;
return newtid;
}
/*******************************************************************************/
/* Récupère l'adresse d'un processus */
process* findprocess(pid_t pid)
{
if ((u32)pid>0)
return &processes[(u32)pid-1];
else
return NULL;
}
/*******************************************************************************/
/* Récupère l'adresse du processus courant */
process* findcurrentprocess(void)
{
return &processes[(u32)getcurrentpid()-1];
}
/*******************************************************************************/
/* Bascule vers une tâche */
void switchtask(tid_t tid)
{
cli();
tid_t previous = current;
task *atask = findtask(tid);
if (atask==NULL) return;
process *aprocess=findprocess(tid.pid);
if (aprocess==NULL) return;
current = tid;
if (!aprocess->iskernel)
{
setTSS(atask->kernel_stack.ss0, atask->kernel_stack.esp0);
wrmsr(0x175, atask->syscall_stack.esp0, 0x0);
}
else
{
setTSS(0x0, 0x0);
wrmsr(0x175, 0x0, 0x0);
}
if (((atask->dump.cs & 0xFFF8) !=SEL_KERNEL_CODE) && ((atask->dump.cs & 0xFFF8) !=SEL_USER_CODE))
cpuerror("SWITCH ERROR", &atask->dump, false);
//printf("%Y\r\n",atask->tid.pid);
atask->dump.eflags = (atask->dump.eflags | 0x200) & 0xFFFFBFFF;
createdump(atask->dump);
if ((atask->dump.cs & 0xFFF8)==SEL_KERNEL_CODE)
restcpu_kernel();
else
restcpu_user();
iret();
}
/*******************************************************************************/
/* Cherche le prochain processus */
process* getnextprocess(process* aprocess, u32 status)
{
u32 i = (u32) aprocess->pid;
u32 parsed = 0;
while (parsed++ < MAXNUMPROCESS && ((status != PROCESS_STATUS_ALL && processes[i++].status != status) ||
(status == PROCESS_STATUS_ALL && processes[i++].status == PROCESS_STATUS_FREE)))
{
if (i >= MAXNUMPROCESS)
i = 0;
}
if (parsed > MAXNUMPROCESS)
return NULL;
else
return &processes[i-1];
}
/*******************************************************************************/
/* Cherche la prochaine tâche du processus */
task* getnexttask(task *atask, u32 status)
{
task *next=atask;
while (next!=NULL)
{
next=TAILQ_NEXT(next, tailq);
if (next!=NULL && (status == TASK_STATUS_ALL || next->status == status))
return next;
}
return NULL;
}
/*******************************************************************************/
/* Cherche la prochaine tâche */
task* getschedule(void)
{
process *aprocess=findcurrentprocess();
task *next=findcurrenttask();
u32 flag=0;
while(flag<2) {
if (aprocess==NULL) return NULL;
if (next==NULL)
next=findfirsttask(aprocess);
while(true)
{
if (next!=NULL)
if (current.pid==next->tid.pid && current.number==next->tid.number)
flag++;
else
return next;
else
break;
next=getnexttask(next,TASK_STATUS_RUN);
}
aprocess=getnextprocess(aprocess,PROCESS_STATUS_RUN);
}
}
/*******************************************************************************/
/* Cherche la première tâche du processeur */
task* findfirsttask(process* aprocess)
{
task *first;
return TAILQ_FIRST(&aprocess->task_head);
}
/*******************************************************************************/
/* Cherche l'adresse d'une tâche */
task* findtask(tid_t tid)
{
process *aprocess=findprocess(tid.pid);
if (aprocess==NULL) return NULL;
task *next;
TAILQ_FOREACH(next, &aprocess->task_head, tailq)
if (next->tid.number==tid.number)
return next;
}
/*******************************************************************************/
/* Cherche l'adresse de la tâche courante */
task* findcurrenttask(void)
{
return findtask(getcurrenttid());
}
/*******************************************************************************/
/* Détruit une tâche */
void deletetask(tid_t tid)
{
cli();
stoptask(tid);
process* aprocess=findprocess(tid.pid);
if (aprocess==NULL) return;
if (current.pid=tid.pid && current.number==tid.number)
current=maketid(1,1);
task *atask=findtask(tid);
if (atask==NULL) return;
TAILQ_REMOVE(&aprocess->task_head, atask, tailq);
vfree(atask);
}
/*******************************************************************************/
/* Execute une tâche */
void runtask(tid_t tid)
{
task *atask=findtask(tid);
if (atask==NULL) return;
if (atask->status == TASK_STATUS_READY)
atask->status = TASK_STATUS_RUN;
}
/*******************************************************************************/
/* Initialise une tâche */
tid_t createtask(pid_t pid,u8 *entry, bool kerneltask)
{
cli();
tid_t tid;
tid.pid=pid;
process* aprocess=findprocess(pid);
if (aprocess==NULL) return maketid(0,0);
task *new = (task *) vmalloc(sizeof(task));
TAILQ_INSERT_TAIL(&aprocess->task_head, new, tailq);
page *apage = virtual_page_getfree();
if (kerneltask)
{
new->dump.ss = SEL_KERNEL_STACK;
if (pid!=1)
new->dump.esp =
(u32) apage->vaddr + PAGESIZE - 16;
new->dump.esp = KERNEL_STACK_ADDR;
new->dump.eflags = 0x0;
new->dump.cs = SEL_KERNEL_CODE;
new->dump.ds = SEL_KERNEL_DATA;
new->dump.es = SEL_KERNEL_DATA;
new->dump.fs = SEL_KERNEL_DATA;
new->dump.gs = SEL_KERNEL_DATA;
new->dump.cr3 = KERNEL_PD_ADDR;
}
else
{
TAILQ_INSERT_TAIL(&aprocess->pdd->page_head, apage, tailq);
new->kernel_stack.ss0 = SEL_KERNEL_STACK;
new->kernel_stack.esp0 =
(u32) apage->vaddr + PAGESIZE - 16;
page *apage = virtual_page_getfree();
TAILQ_INSERT_TAIL(&aprocess->pdd->page_head, apage, tailq);
new->syscall_stack.ss0 = SEL_KERNEL_STACK;
new->syscall_stack.esp0 =
(u32) apage->vaddr + PAGESIZE - 16;
new->dump.ss = SEL_USER_STACK | RPL_RING3;
new->dump.esp = USER_STACK - 16;
new->dump.eflags = 0x0;
new->dump.cs = SEL_USER_CODE | RPL_RING3;
new->dump.ds = SEL_USER_DATA | RPL_RING3;
new->dump.es = SEL_USER_DATA | RPL_RING3;
new->dump.fs = SEL_USER_DATA | RPL_RING3;
new->dump.gs = SEL_USER_DATA | RPL_RING3;
new->dump.cr3 = aprocess->pdd->addr->paddr;
}
new->tid=getfreeptid(pid);
if (entry==NULL)
new->dump.eip = aprocess->entry;
else
new->dump.eip = entry;
new->dump.eax = 0;
new->dump.ecx = 0;
new->dump.edx = 0;
new->dump.ebx = 0;
new->dump.ebp = 0;
new->dump.esi = 0;
new->dump.edi = 0;
new->status = TASK_STATUS_READY;
return new->tid;
}
/*******************************************************************************/
/* Arrête une tâche */
void stoptask(tid_t tid)
{
task *atask=findtask(tid);
if (atask==NULL) return;
atask->status=TASK_STATUS_STOP;
}
/*******************************************************************************/
/* Initialise un processus */
pid_t createprocess(u8 *src, bool kerneltask)
{
cli();
tid_t previous = current;
process* oldprocess=findcurrentprocess();
current.pid = getfreepid();
current.number = 0;
process* new=findcurrentprocess();
if (new==NULL) return NULL;
new->parent=oldprocess->pid;
new->pdd = virtual_pd_create();
new->iskernel=kerneltask;
TAILQ_INIT(&new->page_head);
TAILQ_INIT(&new->task_head);
setCR3(new->pdd->addr->paddr);
new->entry = loadelf(src, new->pid);
createtask(new->pid,new->entry, new->iskernel);
current = previous;
process* old=findcurrentprocess();
if (old==NULL) return NULL;
u32 cr3=KERNEL_PD_ADDR;
if (old->pdd!=NULL)
cr3=old->pdd->addr->paddr;
setCR3(cr3);
new->status=PROCESS_STATUS_READY;
return new->pid;
sti();
}
/*******************************************************************************/
/* Détruit un processus */
void deleteprocess(pid_t pid)
{
cli();
stopprocess(pid);
process* aprocess=findprocess(pid);
if (aprocess==NULL) return;
task *next;
TAILQ_FOREACH(next, &aprocess->task_head, tailq)
deletetask(next->tid);
virtual_pd_destroy(aprocess->pdd);
if (current.pid==pid)
current=maketid(1,1);
aprocess->status = PROCESS_STATUS_FREE;
sti();
}
/*******************************************************************************/
/* Execute un processus */
void runprocess(pid_t pid)
{
cli();
process* aprocess=findprocess(pid);
if (aprocess==NULL) return;
if (aprocess->status == PROCESS_STATUS_READY)
{
aprocess->status = PROCESS_STATUS_RUN;
tid_t tid=maketid(pid,1);
task *atask=findtask(tid);
if (atask==NULL) return;
atask->status=TASK_STATUS_RUN;
}
sti();
}
/*******************************************************************************/
/* Arrête un processus */
void stopprocess(pid_t pid)
{
process* aprocess=findprocess(pid);
if (aprocess==NULL) return;
if (aprocess->status == PROCESS_STATUS_RUN)
{
aprocess->status = PROCESS_STATUS_READY;
task *next;
TAILQ_FOREACH(next, &aprocess->task_head, tailq)
next->status=TASK_STATUS_READY;
}
}
/*******************************************************************************/

105
lib/scheduler.c Normal file
View File

@ -0,0 +1,105 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "interrupts.h"
#include "types.h"
#include "asm.h"
#include "memory.h"
#include "timer.h"
#include "vga.h"
#include "gdt.h"
#include "process.h"
static u8 curs[4] = { "-\\|/" };
static u8 curspos = 0;
static u32 time = 0;
/******************************************************************************/
/* Récupère la valeur du timer */
/* SYSCALL
{
"ID":4,
"NAME":"getticks",
"LIBRARY":"libsys",
"INTERNALNAME":"gettimer",
"DESCRIPTION":"Return the internal value of the timer",
"ARGS": [],
"RETURN":"u32"
}
END-SYSCALL */
u32 gettimer(void)
{
return time;
}
/******************************************************************************/
/* Handler d'interruption du timer IRQ 0 */
__attribute__ ((noreturn)) void timer_handler(regs *dump)
{
exception_stack_noerror *caller = (exception_stack_noerror*) ((u32*)dump->esp+1);
bool noerror,user;
if ((caller->cs & 0xFFF8)==SEL_KERNEL_CODE || (caller->cs & 0xFFF8)==SEL_USER_CODE)
{
noerror=true;
dump->eip = caller->eip;
dump->cs = caller->cs;
dump->eflags = caller->eflags;
if ((dump->cs & 0xFFF8)==SEL_KERNEL_CODE)
{
dump->esp = (u32) caller + sizeof(exception_stack_noerror);
user=false;
}
else
{
dump->esp = (u32) ((exception_stack_noerror_user*) caller)->esp;
dump->ss = (u32) ((exception_stack_noerror_user*) caller)->ss;
user=true;
}
}
else
{
noerror=false;
dump->eip = ((exception_stack*)caller)->eip;
dump->cs = ((exception_stack*)caller)->cs;
if ((dump->cs & 0xFFF8)==SEL_KERNEL_CODE)
{
dump->esp = (u32) caller + sizeof(exception_stack);
user=false;
}
else
{
dump->esp = (u32) ((exception_stack_user*) caller)->esp;
dump->ss = (u32) ((exception_stack_user*) caller)->ss;
user=true;
}
}
irqendmaster();
showchar(0, 0, curs[curspos], 7);
curspos = (curspos + 1) & 0x3;
time++;
task *new=getschedule();
if (new!=NULL)
{
task *old=findcurrenttask();
memcpy(dump, &old->dump, sizeof(regs), 0);
switchtask(new->tid);
}
if ((dump->cs & 0xFFF8)==SEL_KERNEL_CODE)
{
setESP(dump);
restcpu_kernel();
}
else
{
setESP(dump);
restcpu_user();
iret();
}
}
/*******************************************************************************/

749
lib/shell.c Normal file
View File

@ -0,0 +1,749 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include "vga.h"
#include "3d.h"
#include "matrix.h"
#include "video.h"
#include "interrupts.h"
#include "asm.h"
#include "cpu.h"
#include "string.h"
#include "gdt.h"
#include "shell.h"
#include "math.h"
#include "debug.h"
#include "VGA/ansi.c"
#include "3D/sphere.c"
#include "3D/man.c"
#include "memory.h"
#include "syscall.h"
#include "process.h"
static command commands[] = {
{"reboot", "", &rebootnow},
{"clear", "", &clear},
{"mode", "", &mode},
{"detectcpu", "", &detectcpu},
{"test2d", "", &test2d},
{"regs", "", &showregs},
{"gdt", "", &showgdt},
{"idt", "", &showidt},
{"info", "", &showinfo},
{"err", "", &err},
{"test", "", &test},
{"view", "", &view},
{"disasm", "", &disas},
{"bpset", "", &bpset},
{"bpclr", "", &bpclr},
{"help", "", &help},
{"logo", "", &logo},
{"font", "", &sfont},
{"test3d", "", &test3d},
{"detectpci", "", &detectpci},
{"mem", "", &showmem},
{"testmem", "", &testmem},
{"testtask", "", &testtask},
{"ps", "", &ps},
};
/*******************************************************************************/
/* Shell, traite les commandes */
void shell()
{
static u8 field[] =
" \000";
static u8 item[] = " \000";
int i;
bool found;
while (true)
{
print("\r\n# ");
getstring(&field);
print("\r\n");
if (strgetnbitems(&field, ' ') < 1)
continue;
strgetitem(&field, &item, ' ', 0);
strtolower(&item);
found = false;
for (i = 0; i < sizeof(commands) / sizeof(commands[0]);
i++)
{
if (strcmp(&item, &commands[i].name) == 0)
{
(*commands[i].function) (&field);
found = true;
break;
}
}
if (!found)
printf("Commande inconnue !\r\n\000");
}
}
int test(void)
{
print("Fonction de test !\r\n");
return;
}
/*******************************************************************************/
/* Afiche les processus */
static u8* processstatus[] = {"LIBRE","PRET ","EXEC.","PAUSE"};
static u8* taskstatus[] = {"PRET ","EXEC.","PAUSE"};
/*******************************************************************************/
/* Affiche les tâches et processus */
int ps()
{
print("*** Processus en memoire\r\n| PID | Parent|Status|K|P.|Directo.|Pages...\r\n");
process* aprocess=findprocess((pid_t)1);
while(true)
{
printf("|%Y|%Y| %s|%c|%hh u|%Y|",(u32)aprocess->pid,(u32)aprocess->parent,processstatus[aprocess->status],(aprocess->iskernel?'X':' '),aprocess->priority,(u32)aprocess->pdd);
if (aprocess->pdd!=NULL) virtual_pd_show(aprocess->pdd);
print("\r\n");
aprocess=getnextprocess(aprocess,PROCESS_STATUS_ALL);
if (aprocess==NULL || aprocess->pid==(pid_t)1) break;
}
print("\r\n\r\n*** Taches en memoire\r\n| TID | PID |Status| CS | EIP | SS | ESP |\r\n");
aprocess=findprocess((pid_t)1);
task* atask;
while(true)
{
atask=findfirsttask(aprocess);
while(true)
{
printf("|%Y|%Y| %s|%hY|%Y|%hY|%Y|\r\n",(u32)atask->tid.number,(u32)atask->tid.pid,taskstatus[atask->status],atask->dump.cs,atask->dump.eip,atask->dump.ss,atask->dump.esp);
atask=getnexttask(atask,TASK_STATUS_ALL);
if (atask==NULL || (atask->tid.number==1 && atask->tid.pid==1)) break;
}
aprocess=getnextprocess(aprocess,PROCESS_STATUS_ALL);
if (aprocess==NULL || aprocess->pid==(pid_t)1) break;
}
}
/*******************************************************************************/
/* Test l'usage de création de tâche */
#include "TEST/test.c"
#include "TEST/test2.c"
int testtask()
{
print("*** Creation d'une tache\r\n");
pid_t pid;
pid = createprocess(&programs_test2, false);
runprocess(pid);
pid = createprocess(&programs_test, false);
runprocess(pid);
}
/*******************************************************************************/
/* Test la memoire */
int testmem()
{
u8 *test;
print("**** AVANT ALLOCATION\r\n");
showmem();
test = vmalloc(150 * 1024 * 1024); /* 10 pages */
print("**** APRES ALLOCATION\r\n");
showmem();
vfree(test);
print("**** APRES LIBERATION\r\n");
showmem();
}
/*******************************************************************************/
/* Affiche des informations sur la mémoire */
int showmem()
{
u32 libre = getmemoryfree();
u32 total = physical_getmemorysize();
printf("Memoire physique (TOTAL)\r\n -libre \33[40D\33[15C%H (%.2f%%)\r\n -occupee \33[40D\33[15C%H\r\n -total \33[40D\33[15C%H\r\n\r\n", libre, ((float) libre / total * 100.0f), total - libre, total);
printf("Memoire HEAP (NOYAU) - % u blocs\r\n -libre \33[40D\33[15C%H\r\n -occupee \33[40D\33[15C%H\r\n -allouables \33[40D\33[15C%H\r\n\r\n", getmallocnb(), getmallocfree(), getmallocused(), getmallocnonallocated());
printf("Plan de memoire (NOYAU)\r\n -IDT \33[40D\33[15C%X\r\n -GDT \33[40D\33[15C%X\r\n -PGD \33[40D\33[15C%X\r\n -STACK \33[40D\33[15C%X\r\n -CODE \33[40D\33[15C%X\r\n -PAGES \33[40D\33[15C%X\r\n -HEAP \33[40D\33[15C%X\r\n -VESAFB \33[40D\33[15C%X\r\n\r\n", IDT_ADDR, GDT_ADDR, KERNEL_PD_ADDR, KERNEL_STACK_ADDR, KERNEL_CODE_ADDR, KERNEL_PAGES, KERNEL_HEAP, VESA_FBMEM);
printf("Memoire Virtuelle (NOYAU)\r\n -pages libres \33[40D\33[16C% u\r\n -pages occupees \33[40D\33[16C% u\r\n", virtual_getpagesfree(), virtual_getpagesused());
return;
}
/*******************************************************************************/
/* Affiche les périphériques PCI */
int detectpci()
{
scanPCI();
}
/*******************************************************************************/
/* Change la police courante */
int sfont(u8 * commandline)
{
if (strgetnbitems(commandline, ' ') < 2)
{
print("Syntaxe de la commande FONT\r\nfont \33[32mpolice\r\n\r\n \33[32mpolice\33[0m\33[0m\33[25D\33[10C - \33[Nom de la police de caractere\r\n");
return;
}
setfont(strgetpointeritem(commandline, ' ', 1));
}
/*******************************************************************************/
/* Affiche le logo */
int logo()
{
print(ansilogo);
return;
}
/*******************************************************************************/
/* Renvoie les commandes disponibles */
int help()
{
print("Commandes disponibles :\r\n\r\n");
for (u32 i = 0; i < sizeof(commands) / sizeof(commands[0]); i++)
{
printf("%s \r\n", &commands[i].name);
}
return 0;
}
/*******************************************************************************/
/* Met un breakpoint */
int bpset(u8 * commandline)
{
u8 arg[] = " \000";
u8 *numero;
u8 *pointer;
u8 type = DBG_EXEC;
if (strgetnbitems(commandline, ' ') < 3)
{
print("Syntaxe de la commande BPSET\r\nbpset \33[32mnumero address [type]\r\n\r\n \33[32mnumero\33[0m\33[0m\33[25D\33[10C - numero du breakpoint (0-3)\r\n \33[32madresse\33[0m\33[25D\33[10C - adresse du breakpoint\r\n \33[32mtype\33[0m\33[25D\33[10C - type de breakpoint (0-3)\r\n");
return;
}
strgetitem(commandline, &arg, ' ', 1);
numero = strtoint(&arg);
if (numero > 3)
{
print("numero incorrect");
return;
}
strgetitem(commandline, &arg, ' ', 2);
pointer = strtoint(&arg);
if (strgetnbitems(commandline, ' ') == 4)
{
strgetitem(commandline, &arg, ' ', 3);
type = strtoint(&arg);
}
if (type > DBG_READWRITE)
{
print("type incorrect");
return;
}
setdebugreg(numero, pointer, type);
}
/*******************************************************************************/
/* Retire un breakpoint */
int bpclr(u8 * commandline)
{
u8 arg[] = " \000";
u8 *numero;
if (strgetnbitems(commandline, ' ') < 2)
{
print("Syntaxe de la commande BPCLR\r\nbpclr \33[32mnumero\r\n\r\n \33[32mnumero\33[0m\33[0m\33[25D\33[10C - numero du breakpoint (0-3)\r\n");
return;
}
strgetitem(commandline, &arg, ' ', 1);
numero = strtoint(&arg);
if (numero > 3)
{
print("numero incorrect");
return;
}
setdebugreg(numero, 0x0, DBG_CLEAR);
}
/*******************************************************************************/
/* Desassemble une zone de mémoire donnée */
int disas(u8 * commandline)
{
u8 arg[] = " \000";
u8 *size;
u8 *pointer;
if (strgetnbitems(commandline, ' ') < 3)
{
print("Syntaxe de la commande DISASM\r\ndisasm \33[32madresse taille\r\n\r\n \33[32madresse\33[0m\33[0m\33[25D\33[10C - Adresse a visualiser\r\n \33[32mtaille\33[0m\33[25D\33[10C - nombre d'octets a desassembler <256\r\n");
return;
}
strgetitem(commandline, &arg, ' ', 1);
pointer = strtoint(&arg);
size = pointer;
strgetitem(commandline, &arg, ' ', 2);
size += strtoint(&arg);
while (pointer < size)
{
pointer += disasm(pointer, NULL, true);
}
}
/*******************************************************************************/
/* Génère des exceptions */
int view(u8 * commandline)
{
u8 arg[] = " \000";
u32 address;
u8 size;
u8 *pointerb;
u16 *pointerw;
u32 *pointerd;
u8 format;
u8 nbligne;
if (strgetnbitems(commandline, ' ') < 3)
{
print("Syntaxe de la commande VIEW\r\nview \33[32madresse taille [size] [nbligne]\r\n\r\n \33[32madresse\33[0m\33[0m\33[25D\33[10C - Adresse a visualiser\r\n \33[32mtaille\33[0m\33[25D\33[10C - nombre d'octets a visualiser <256\r\n \33[32mformat\33[0m\33[25D\33[10C - c (ascii) b (octet) w (mot) d (double mot)\r\n \33[32mnbligne\33[0m\33[25D\33[10C - nombre d'octets a visualiser par ligne\r\n");
return;
}
strgetitem(commandline, &arg, ' ', 1);
address = strtoint(&arg);
strgetitem(commandline, &arg, ' ', 2);
size = strtoint(&arg);
if (strgetnbitems(commandline, ' ') < 4)
format = 'b';
else
{
strgetitem(commandline, &arg, ' ', 3);
format = arg[0];
}
switch (format)
{
case 'c':
pointerb = address;
nbligne = 12;
break;
case 'b':
pointerb = address;
nbligne = 22;
break;
case 'w':
pointerw = address;
nbligne = 13;
break;
case 'd':
pointerd = address;
nbligne = 7;
break;
}
if (strgetnbitems(commandline, ' ') == 5)
{
strgetitem(commandline, &arg, ' ', 4);
nbligne = strtoint(&arg);
}
printf("Adresse %Y - % hhu", address, size);
for (u32 i = 0; i < size; i++)
switch (format)
{
case 'c':
if (i % nbligne == 0)
printf("\r\n:%Y - ", pointerb);
printf("%hhY \33[40C%c\33[41D",
*(pointerb), *(pointerb++));
break;
case 'b':
if (i % nbligne == 0)
printf("\r\n:%Y - ", pointerb);
printf("%hhY ", *(pointerb++));
break;
case 'w':
if (i % nbligne == 0)
printf("\r\n:%Y - ", pointerw);
printf("%hY ", *(pointerw++));
break;
case 'd':
if (i % nbligne == 0)
printf("\r\n:%Y - ", pointerd);
printf("%Y ", *(pointerd++));
break;
}
}
/*******************************************************************************/
/* Génère des exceptions */
int err(u8 * commandline)
{
u8 arg[] = " \000";
u32 argint;
if (strgetnbitems(commandline, ' ') < 2)
{
print("Syntaxe de la commande ERR\r\nerr \33[32mexception\r\n\r\n exception\33[0m\33[25D\33[10C - code de l'exception\r\n");
return;
}
strgetitem(commandline, &arg, ' ', 1);
argint = strtoint(&arg);
switch (argint)
{
case 0:
print("Creation d'une erreur de division par 0 !\r\n");
asm("movl $0x0,%ecx; divl %ecx");
break;
case 1:
print("Creation d'un breakpoint !\r\n");
setdebugreg(0, &test, DBG_EXEC);
test();
break;
case 2:
print("NON GERE!\r\n");
break;
case 3:
print("Creation d'une erreur interruption 3 !\r\n");
asm("int $0x3");
break;
case 4:
print("NON GERE!\r\n");
break;
case 5:
print("NON GERE!\r\n");
break;
case 6:
print("Creation d'une erreur d'opcode invalide !\r\n");
asm("mov %cr7, %eax");
break;
case 7:
print("NON GERE!\r\n");
break;
case 8:
print("NON GERE!\r\n");
break;
case 9:
print("NON GERE!\r\n");
break;
case 10:
print("NON GERE!\r\n");
break;
case 11:
print("Creation d'une erreur segment non present !\r\n");
setidt(&err, SEL_KERNEL_CODE, INTGATE, 104);
asm("int $0x68");
break;
case 12:
print("NON GERE!\r\n");
break;
case 13:
print("Creation d'une erreur general fault !\r\n");
asm("mov $0x666, %ax; ltr %ax");
break;
case 14:
if (random(0, 100) > 50)
{
print("Creation d'une erreur de page en ecriture !\r\n");
asm("movl $0x66666666,(0xE0000000)");
}
else
{
print("Creation d'une erreur de page en lecture !\r\n");
asm("movl (0xD0000000),%eax");
}
break;
case 15:
print("NON GERE!\r\n");
break;
case 16:
print("NON GERE!\r\n");
break;
case 17:
print("NON GERE!\r\n");
break;
case 18:
print("NON GERE!\r\n");
break;
default:
print("Exception qui n'existe pas !!!\r\n");
break;
}
return 0;
}
/*******************************************************************************/
/* Information sur le démarrage */
int showinfo()
{
return 0;
}
/*******************************************************************************/
/* Affiche les registres */
int showregs()
{
int20;
return 0;
}
/*******************************************************************************/
/* Change le mode */
int mode(u8 * commandline)
{
u8 arg[] = " \000";
u32 argint;
if (strgetnbitems(commandline, ' ') < 2)
{
print("Syntaxe de la commande MODE\r\nmode \33[32mmodevideo\r\n\r\n modevideo\33[0m\33[25D\33[10C - mode video a initialiser (>0x80 = graphique)\r\n");
return;
}
strgetitem(commandline, &arg, ' ', 1);
argint = strtoint(&arg);
changemode(argint);
return 0;
}
/*******************************************************************************/
/* Efface l'écran */
int clear()
{
clearscreen();
return 0;
}
/*******************************************************************************/
/* Redemarre */
int rebootnow()
{
print("<Appuyer sur une touche pour redemarrer>");
waitascii();
reboot();
return 0;
}
/*******************************************************************************/
/* Teste les fonctionnalités 3D */
int test3d()
{
videoinfos *vinfo = getvideo_info();
if (!vinfo->isgraphic)
{
print("Mode graphique necessaire afin de lancer ce programme\r\n");
return 1;
}
model3d model;
float factor = 100.0f;
type3D type = TYPE3D_POINTS;
matrix44 rotatex, rotatey, rotatez, mrotatex, mrotatey, mrotatez,
identity;
matrix44_homogen(&identity);
matrix44_rotation_x(0.1f, &rotatex);
matrix44_rotation_y(0.1f, &rotatey);
matrix44_rotation_z(0.1f, &rotatez);
matrix44_rotation_x(-0.1f, &mrotatex);
matrix44_rotation_y(-0.1f, &mrotatey);
matrix44_rotation_z(-0.1f, &mrotatez);
matrix44 *transformation = &identity;
vector4 origin = { 0.0f, 0.0f, 0.0f, 0.0f };
vector4 cubeorigin = { 0.0f, 0.0f, 0.0f, 0.0f };
origin.x = vinfo->currentwidth / 2.0f;
origin.y = vinfo->currentheight / 2.0f;
origin.z = 70.0f;
cube(&model, &cubeorigin, 35.0f);
u8 achar = ' ';
u8 i;
while (achar != 'q' && achar != 'Q')
{
clearscreen();
show3dmodel(&model, transformation, &origin, factor, type);
achar = waitascii();
switch (achar)
{
case '1':
load3ds(&man, sizeof(man), &model);
break;
case '2':
load3ds(&sphere, sizeof(sphere), &model);
break;
case 17:
transformation = &rotatex;
break;
case 18:
transformation = &mrotatex;
break;
case 19:
transformation = &rotatey;
break;
case 20:
transformation = &mrotatey;
break;
case 2:
transformation = &rotatez;
break;
case 3:
transformation = &mrotatez;
break;
case '-':
factor -= 10.0;
break;
case '+':
factor += 10.0;
break;
case '*':
switch (type)
{
case TYPE3D_POINTS:
type = TYPE3D_LINES;
break;
case TYPE3D_LINES:
type = TYPE3D_POINTS;
break;
}
break;
}
}
return 0;
}
/*******************************************************************************/
/* Teste les fonctionnalités 2D graphiques */
int test2d()
{
videoinfos *vinfo = getvideo_info();
if (!vinfo->isgraphic)
{
print("Mode graphique necessaire afin de lancer ce programme\r\n");
return 1;
}
struct vertex2d a, b, c;
randomize();
u32 color;
for (int i = 0; i < 2000; i++)
{
a.x = random(0, vinfo->currentwidth);
a.y = random(0, vinfo->currentheight);
b.x = random(0, vinfo->currentwidth);
b.y = random(0, vinfo->currentheight);
if (vinfo->currentdepth > 24)
color = egatorgb(random(0, 16));
else if (vinfo->currentdepth == 8)
color = random(0, 63);
else
color = random(0, 16);
v_line(&a, &b, color);
}
waitascii();
for (int i = 0; i < 2000; i++)
{
a.x = random(0, vinfo->currentwidth);
a.y = random(0, vinfo->currentheight);
b.x = random(0, vinfo->currentwidth);
b.y = random(0, vinfo->currentheight);
c.x = random(0, vinfo->currentwidth);
c.y = random(0, vinfo->currentheight);
if (vinfo->currentdepth > 24)
color = egatorgb(random(0, 16));
else if (vinfo->currentdepth == 8)
color = random(0, 63);
else
color = random(0, 16);
trianglefilled(&a, &b, &c, color);
triangle(&a, &b, &c, egatorgb(4));
}
return 0;
}
/*******************************************************************************/
/* Lit l'IDT et l'affiche */
int showidt()
{
u32 index, i = 0;
idtdes *desc;
struct idtr idtreg;
sidt(idtreg);
printf("Information sur l'IDT\r\nAdresse:%X Limite:%hX\r\n",
idtreg.base, (u32) idtreg.limite);
desc = idtreg.base;
for (index = 0; index < idtreg.limite / sizeof(idtdes); index++)
{
u32 select = desc[index].select;
u32 offset =
desc[index].offset0_15 +
(desc[index].offset16_31 << 16);
u32 type = desc[index].type & 0x0F00;
u8 *typestr1, *typestr2;
if (i >= 32 & i <= 39)
typestr1 = "IRQ master";
else if (i >= 96 & i <= 103)
typestr1 = "IRQ slave ";
else if (i < 19)
typestr1 = "EXCEPTION ";
else
typestr1 = "INTERRUPT ";
if (type == INTGATE)
typestr2 = "INTGATE";
else if (type == TRAPGATE)
typestr2 = "TRAPGATE";
else if (type == TASKGATE)
typestr2 = "TASKGATE";
else if (type == CALLGATE)
typestr2 = "CALLGATE";
else if (type == LDTDES)
typestr2 = "LDTDES";
else
print("inconnu");
printf("%s % hu %hY:%Y - %s\r\n", typestr1, i++, select,
offset, typestr2);
if (i % 32 == 0)
{
print("\r\n<Appuyez sur une touche>\r\n");
waitascii();
}
}
return 0;
}
/*******************************************************************************/
/* Lit les descripteurs GDT et les affiche */
int showgdt()
{
u32 index;
struct gdtr gdtreg;
sgdt(gdtreg);
printf("Information sur la GDT\r\nAdresse:%X Limite:%hX\r\n",
gdtreg.base, gdtreg.limite);
for (index = 0; index < gdtreg.limite; index += sizeof(gdtdes))
{
if (!isdesvalid(index))
printf("\033[31m");
printf("SEL =%hY %Y %Y DPL=%d %cS%d [%c%c%c] %h ub\033[0m\r\n", index, getdesbase(index), getdeslimit(index), getdesdpl(index), getdestype(index), getdessize(index), getdesbit3(index), getdesbit2(index), getdesbit1(index), getdesalign(index));
}
return 0;
}
/*******************************************************************************/
/* Detecte et affiche les information sur le CPU */
int detectcpu()
{
cpuinfo cpu;
u8 noproc[] = "\033[31mInconnu\033[0m\000";
strcpy(&noproc, &cpu.detectedname);
getcpuinfos(&cpu);
printf("\r\nDetection du processeur\r\033[1m Revision \t:%d\r Modele \t:%d\r Famille \t:%d\r Nom cpuid\t:%s\rJeux d'instruction\t:%s\033[0m\r\n\000", cpu.stepping, cpu.models, cpu.family, &cpu.detectedname, &cpu.techs);
return 0;
}
/*******************************************************************************/

405
lib/string.c Executable file → Normal file
View File

@ -1,65 +1,412 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include <string.h> #include <string.h>
/******************************************************************************/
/* Compare 2 chaines de caractère et renvoie la premiere distance (diff) */ /* Compare 2 chaines de caractère et renvoie la premiere distance (diff) */
s8 strcmp(const u8 *src,const u8 *des)
s8 strcmp(const u8 * src, const u8 * dest)
{ {
register s8 result; register s8 result;
do do
{ {
if ((result = *src - *des++) != 0) break; if ((result = *src - *dest++) != 0)
break;
} }
while (*src++!=0); while (*src++ != 0);
return result; return result;
} }
/******************************************************************************/
/* Trouve la premiere occurence d'un caractère dans une chaine et renvoie un pointeur */
/* Trouve la premiere occurence d'un caractère dans une chaine */ u8 *strchr(const u8 * src, u8 achar)
u8 * strchr(const u8 *src, u8 achar)
{ {
for(; *src!= achar; ++src) for (; *src != achar; ++src)
if (*src == 0) return 0; if (*src == 0)
return (u8*)src; return 0;
return (u8 *) src;
} }
/******************************************************************************/
/* Trouve la premiere occurence d'un caractère dans une chaine */
u32 strchrpos(const u8 * src, u8 achar)
{
u32 i;
for (i = 0; *(src + i) != achar; ++i)
if (*(src + i) == 0)
return 0;
return i;
}
/******************************************************************************/
/* Renvoie la taille de la chaine */ /* Renvoie la taille de la chaine */
u32 strlen(const u8 *src)
{
u32 size;
for (size = 0; *(src+size) != 0; size++); u32 strlen(const u8 * src)
{
u32 size;
for (size = 0; *(src + size) != 0; size++);
return size; return size;
} }
/******************************************************************************/
/* copie une chaine dans une autre */ /* copie une chaine dans une autre */
u8* strcpy(const u8 *src, u8 *des) u8 *strcpy(const u8 * src, u8 * dest)
{ {
u8 *temp = des; u8 *temp = dest;
while ((*des++ = *src++) != 0); while ((*dest++ = *src++) != 0);
return temp; return temp;
} }
/******************************************************************************/
/* copie une portion limité d'une chaine asciiZ*/ /* copie une portion limité d'une chaine asciiZ*/
u8 *strncpy(const u8 *src,u8 *des,u32 count) u8 *strncpy(const u8 * src, u8 * dest, u32 count)
{ {
u8 *temp = des; u8 *temp = dest;
while (count) { while (count)
if ((*temp = *src) != 0) src++; {
if ((*temp = *src) != 0)
src++;
temp++; temp++;
count--; count--;
} }
return des; return dest;
} }
/******************************************************************************/
/* concatene 2 chaines de caractère */ /* concatene 2 chaines de caractère */
u8 *strcat( const u8 *src,u8 *des)
u8 *strcat(const u8 * src, u8 * dest)
{ {
u8 *temp = des; u8 *temp = dest;
while (*des!=0) des++; while (*dest != 0)
while ((*des++ = *src++) != 0); dest++;
while ((*dest++ = *src++) != 0);
return temp; return temp;
} }
/******************************************************************************/
/* Met en minuscule */
void strtolower(u8 * src)
{
while (*src != 0)
{
if ((*src >= 'A') && (*src <= 'Z'))
*src = *src + 'a' - 'A';
src++;
}
}
/******************************************************************************/
/* Met en majuscule */
void strtoupper(u8 * src)
{
while (*src != 0)
{
if ((*src >= 'a') && (*src <= 'z'))
*src = *src - ('a' - 'A');
src++;
}
}
/******************************************************************************/
/* inverse la casse */
void strinvertcase(u8 * src)
{
while (*src != 0)
{
if ((*src >= 'A') && (*src <= 'Z'))
*src = *src + 'a' - 'A';
else if ((*src >= 'a') && (*src <= 'z'))
*src = *src - ('a' - 'A');
src++;
}
}
/******************************************************************************/
/* Met une majuscule et met le reste en minuscule */
void stronecase(u8 * src)
{
if ((*src >= 'a') && (*src <= 'z'))
*src = *src - ('a' - 'A');
while (*src != 0)
{
src++;
if ((*src >= 'A') && (*src <= 'Z'))
*src = *src + 'a' - 'A';
}
}
/******************************************************************************/
/* Fixe la taille de la chaine */
void strsetlen(u8 * src, u32 size)
{
*(src + size) = '\000';
}
/******************************************************************************/
/* Inverse la chaine */
void strinvert(u8 * src)
{
u8 *dst = src + strlen(src) - 1;
while (src < dst)
{
u8 char1 = *dst;
u8 char2 = *src;
*dst = char2;
*src = char1;
src++;
dst--;
}
}
/******************************************************************************/
/* Remplace tout les caractères rechercher par un autre */
void strreplace(u8 * src, u8 search, u8 replaced)
{
u8 *pos = strchr(src, search);
while (pos != 0)
{
*pos = replaced;
pos = strchr(src, search);
}
}
/******************************************************************************/
/* Rempli de caractère */
u8 *strfill(u8 * dst, u8 pattern, u32 size)
{
u32 i;
for (i = 0; i <= size; i++)
*(dst + i) = pattern;
*(dst + i + 1) = '\000';
return dst;
}
/******************************************************************************/
/* Renvoie la partie gauche d'une chaine */
void strleft(u8 * src, u8 * dest, u32 size)
{
u32 i;
for (i = 0; (*(src + i) != 0) && (i < size); i++)
*dest++ = *(src + i);
*dest++ = '\000';
}
/******************************************************************************/
/* Renvoie la partie droite d'une chaine */
void strright(u8 * src, u8 * dest, u32 size)
{
u32 i;
u32 begin = strlen(src) - size;
for (i = 0; (*(src + i + begin) != 0) && (i < size); i++)
*dest++ = *(src + i + begin);
*dest++ = '\000';
}
/******************************************************************************/
/* Supprime une portion de chaine */
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++)
*(src + index + i) = *(src + index + size + i);
*(src + index + i) = '\000';
}
/******************************************************************************/
/* Insert une portion dans la chaine */
void strinsert(u8 * src, u8 * dest, u32 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);
for (i = 0; (*(src + i) != 0); i++)
*(dest + index + i) = *(src + i);
}
/******************************************************************************/
/* Supprime les délimiteurs consécutifs */
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++);
if (i > 1)
strdelete(pos, 1, i - 1);
pos = strchr(pos + 1, 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)
{
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';
return dest;
}
/******************************************************************************/
/* 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)
{
u32 i;
u8 *pos = src;
for (i = 0; i < index; i++)
pos = strchr(pos + 1, delim);
if (*pos == delim)
pos++;
return pos;
}
/******************************************************************************/
/* Récupérère le nombre d'éléments d'une liste utilisant un délimiteur */
u32 strgetnbitems(u8 * src, u8 delim)
{
u32 number = 0;
if (*src == 0)
return 0;
number++;
u8 *pos = strchr(src, delim);
while (pos != 0)
{
pos = strchr(pos + 1, delim);
number++;
}
return number;
}
/******************************************************************************/
/* Renvoie la base minimum du nombre */
u8 base[] = " 0123456789ABCDEF\000";
u8 strgetminbase(u8 * src)
{
u8 temp[] = " \000";
u8 *dst = &temp;
strtoupper(strcpy(src, &temp));
u8 max = 0;
while (*dst != 0)
{
u32 result = strchrpos(&base, *dst++);
if (result == 0)
return 0;
if (result > max)
max = result;
}
if (max > 10)
return 16;
else if (max > 8)
return 10;
else if (max > 2)
return 8;
else
return 2;
}
/******************************************************************************/
/* Renvoie la base du nombre */
u8 hexa[] = "0x\000";
u8 bases[] = " bodh\000";
u8 basesnum[] = { 0, 2, 8, 10, 16 };
u8 declaredbase = 10;
u8 minbase = 0;
u8 strgetbase(u8 * src)
{
u8 temp[] = " \000";
strleft(src, &temp, 2);
if (strcmp(&temp, &hexa) == 0)
{
declaredbase = 16;
u8 size = strlen(src);
strright(src, &temp, size - 2);
minbase = strgetminbase(&temp);
}
else
{
strright(src, &temp, 1);
declaredbase = basesnum[strchrpos(&bases, temp[0])];
if (declaredbase > 0)
{
u8 size = strlen(src);
strleft(src, &temp, size - 1);
minbase = strgetminbase(&temp);
}
else
{
minbase = strgetminbase(src);
declaredbase = minbase;
}
}
if (declaredbase >= minbase && minbase != 0)
return declaredbase;
else
return 0;
}
/******************************************************************************/
/* Transforme une chaine en nombre */
u32 strtoint(u8 * src)
{
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 || *temp == 'b' || *temp == 'o' || *temp == 'd'
|| *temp == 'h')
temp--;
while (src + shorter <= temp)
{
u8 achar = *temp--;
if ((achar >= 'a') && (achar <= 'z'))
achar = achar - ('a' - 'A');
result = result + multi * (strchrpos(&base, achar) - 1);
multi = multi * thebase;
}
return result;
}
/*******************************************************************************/

93
lib/syscall.c Normal file
View File

@ -0,0 +1,93 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Horde Nicolas */
/* */
#include <types.h>
#include <gdt.h>
#include <asm.h>
#include <memory.h>
#include <interrupts.h>
#include <syscall.h>
#include <process.h>
/* 32bit SYSENTER instruction entry.
*
* Arguments:
* %eax System call number.
* %ebx Arg1
* %esi Arg2
* %edi Arg3*/
extern wrapper_sysenter;
/*******************************************************************************/
/* Initialise les appels système par SYSENTER/SYSEXIT */
void initsyscall(void)
{
wrmsr(0x174, SEL_KERNEL_CODE, 0x0);
wrmsr(0x175, NULL, 0x0);
wrmsr(0x176, &wrapper_sysenter, 0x0);
return;
}
/*******************************************************************************/
/* Fonction permettant de tester le fonctionnement de SYSENTER */
/* SYSCALL
{
"ID":0,
"LIBRARY":"libsys",
"NAME":"testapi",
"INTERNALNAME":"testapi",
"DESCRIPTION":"Simple function to test if SYSCALL API is correctly running",
"ARGS": [
{"TYPE":"u32","NAME":"arg1","DESCRIPTION":"first argument of your choice"},
{"TYPE":"u32","NAME":"arg2","DESCRIPTION":"second argument of your choice"},
{"TYPE":"u32","NAME":"arg3","DESCRIPTION":"third argument of your choice"}
],
"RETURN":"u32",
"DUMP":"yes"
}
END-SYSCALL */
u32 testapi(u32 arg1, u32 arg2, u32 arg3, regs* dump)
{
printf("Appel syscall %u depuis %Y:%Y avec arguments => ARG1:%Y ARG2:%Y ARG3:%Y\r\n", dump->eax, (u32) dump->cs, dump->eip, arg1, arg2, arg3);
return;
}
/*******************************************************************************/
/* Entrée pour les appels système SYSENTER */
__attribute__ ((noreturn)) void sysenter_handler(regs *dump)
{
sti();
switch (dump->eax)
{
case 5:
dump->eax=(u32) processexit(dump->ebx);
break;
case 4:
dump->eax=(u32) gettimer();
break;
case 2:
dump->eax=(u32) print(dump->ebx);
break;
case 1:
dump->eax=(u32) waitascii();
break;
case 0:
dump->eax=(u32) testapi(dump->ebx, dump->esi, dump->edi, dump);
break;
default:
printf("Appel syscall vers fonction inexistante en %Y:%Y", dump->cs, dump->eip);
break;
}
//dump->eflags &= ~(1 << 6);
dump->eflags |= (1 << 6);
setESP(dump);
restcpu_user();
sysexit();
}
/*******************************************************************************/

View File

@ -1,27 +0,0 @@
#include "idt.h"
#include "types.h"
#include "asm.h"
#include "memory.h"
#include "timer.h"
#include "vga.h"
static u8 curs[4]={"-\\|/"};
static u8 curspos=0;
void timer()
{
cli();
pushf();
pushad();
showchar(0,0,curs[curspos],7);
curspos=(curspos+1)&0x3;
irqendmaster();
popad();
popf();
sti();
asm("addl $0x0C, %esp;");
iret();
}

56
lib/types.c Executable file → Normal file
View File

@ -1,46 +1,50 @@
/*******************************************************************************/
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#include <types.h> #include <types.h>
char ctype[] = char ctype[] = {
{
0x00, 0x00,
/* 0 */ CT_CTL, CT_CTL, CT_CTL, CT_CTL, /* 0 */ CT_CTL, CT_CTL, CT_CTL, CT_CTL,
CT_CTL, CT_CTL, CT_CTL, CT_CTL, CT_CTL, CT_CTL, CT_CTL, CT_CTL,
/* 8 */ CT_CTL, CT_CTL | CT_WHT, CT_CTL | CT_WHT, CT_CTL | CT_WHT, /* 8 */ CT_CTL, CT_CTL | CT_WHT, CT_CTL | CT_WHT, CT_CTL | CT_WHT,
CT_CTL | CT_WHT, CT_CTL | CT_WHT, CT_CTL, CT_CTL, CT_CTL | CT_WHT, CT_CTL | CT_WHT, CT_CTL, CT_CTL,
/* 16 */CT_CTL, CT_CTL, CT_CTL, CT_CTL, /* 16 */ CT_CTL, CT_CTL, CT_CTL, CT_CTL,
CT_CTL, CT_CTL, CT_CTL, CT_CTL, CT_CTL, CT_CTL, CT_CTL, CT_CTL,
/* 24 */CT_CTL, CT_CTL, CT_CTL, CT_CTL, /* 24 */ CT_CTL, CT_CTL, CT_CTL, CT_CTL,
CT_CTL, CT_CTL, CT_CTL, CT_CTL, CT_CTL, CT_CTL, CT_CTL, CT_CTL,
/* ' ' */CT_WHT | CT_SP, CT_PUN, CT_PUN, CT_PUN, /* ' ' */ CT_WHT | CT_SP, CT_PUN, CT_PUN, CT_PUN,
CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN,
/* '(' */CT_PUN, CT_PUN, CT_PUN, CT_PUN, /* '(' */ CT_PUN, CT_PUN, CT_PUN, CT_PUN,
CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN,
/* '0' */CT_DIG, CT_DIG, CT_DIG, CT_DIG, /* '0' */ CT_DIG, CT_DIG, CT_DIG, CT_DIG,
CT_DIG, CT_DIG, CT_DIG, CT_DIG, CT_DIG, CT_DIG, CT_DIG, CT_DIG,
/* '8' */CT_DIG, CT_DIG, CT_PUN, CT_PUN, /* '8' */ CT_DIG, CT_DIG, CT_PUN, CT_PUN,
CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN,
/* '@' */CT_PUN, CT_UP | CT_HEX, CT_UP | CT_HEX, CT_UP | CT_HEX, /* '@' */ CT_PUN, CT_UP | CT_HEX, CT_UP | CT_HEX, CT_UP | CT_HEX,
CT_UP | CT_HEX, CT_UP | CT_HEX, CT_UP | CT_HEX, CT_UP, CT_UP | CT_HEX, CT_UP | CT_HEX, CT_UP | CT_HEX, CT_UP,
/* 'H' */CT_UP, CT_UP, CT_UP, CT_UP, /* 'H' */ CT_UP, CT_UP, CT_UP, CT_UP,
CT_UP, CT_UP, CT_UP, CT_UP, CT_UP, CT_UP, CT_UP, CT_UP,
/* 'P' */CT_UP, CT_UP, CT_UP, CT_UP, /* 'P' */ CT_UP, CT_UP, CT_UP, CT_UP,
CT_UP, CT_UP, CT_UP, CT_UP, CT_UP, CT_UP, CT_UP, CT_UP,
/* 'X' */CT_UP, CT_UP, CT_UP, CT_PUN, /* 'X' */ CT_UP, CT_UP, CT_UP, CT_PUN,
CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN, CT_PUN,
/* '`' */CT_PUN, CT_LOW | CT_HEX, CT_LOW | CT_HEX, CT_LOW | CT_HEX, /* '`' */ CT_PUN, CT_LOW | CT_HEX, CT_LOW | CT_HEX,
CT_LOW | CT_HEX,
CT_LOW | CT_HEX, CT_LOW | CT_HEX, CT_LOW | CT_HEX, CT_LOW, CT_LOW | CT_HEX, CT_LOW | CT_HEX, CT_LOW | CT_HEX, CT_LOW,
/* h' */CT_LOW, CT_LOW, CT_LOW, CT_LOW, /* h' */ CT_LOW, CT_LOW, CT_LOW, CT_LOW,
CT_LOW, CT_LOW, CT_LOW, CT_LOW, CT_LOW, CT_LOW, CT_LOW, CT_LOW,
/* 'p' */CT_LOW, CT_LOW, CT_LOW, CT_LOW, /* 'p' */ CT_LOW, CT_LOW, CT_LOW, CT_LOW,
CT_LOW, CT_LOW, CT_LOW, CT_LOW, CT_LOW, CT_LOW, CT_LOW, CT_LOW,
/* 'x' */CT_LOW, CT_LOW, CT_LOW, CT_PUN, /* 'x' */ CT_LOW, CT_LOW, CT_LOW, CT_PUN,
CT_PUN, CT_PUN, CT_PUN, CT_CTL, CT_PUN, CT_PUN, CT_PUN, CT_CTL,
/* 128 */0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 128 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 144 */0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 144 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 160 */0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 160 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 176 */0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 176 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 192 */0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 192 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 208 */0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 208 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 224 */0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 224 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 240 */0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 240 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}; };
/*******************************************************************************/

Some files were not shown because too many files have changed in this diff Show More