2018-09-28 20:35:51 +02:00
|
|
|
/*******************************************************************************/
|
|
|
|
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
|
|
|
|
/* */
|
2007-04-02 14:52:01 +02:00
|
|
|
#include "vga.h"
|
2007-04-02 15:26:03 +02:00
|
|
|
#include "video.h"
|
2018-08-17 16:46:56 +02:00
|
|
|
#include "interrupts.h"
|
2007-04-02 15:47:30 +02:00
|
|
|
#include "timer.h"
|
|
|
|
#include "keyboard.h"
|
2007-04-02 16:19:44 +02:00
|
|
|
#include "mouse.h"
|
2007-04-02 15:47:30 +02:00
|
|
|
#include "asm.h"
|
2007-04-02 16:19:44 +02:00
|
|
|
#include "cpu.h"
|
|
|
|
#include "string.h"
|
2018-08-22 17:36:30 +02:00
|
|
|
#include "2d.h"
|
2007-04-02 16:19:44 +02:00
|
|
|
#include "ansi.c"
|
2018-08-31 02:48:03 +02:00
|
|
|
#include "gdt.h"
|
2018-09-17 18:17:11 +02:00
|
|
|
#include "shell.h"
|
2018-09-18 14:29:35 +02:00
|
|
|
#include "syscall.h"
|
2018-09-27 17:12:12 +02:00
|
|
|
#include "multiboot2.h"
|
2018-09-27 07:55:24 +02:00
|
|
|
|
2018-08-17 16:46:56 +02:00
|
|
|
static u8 warnmsg[] =
|
2018-09-27 21:01:02 +02:00
|
|
|
"\033[99C\033[8D\033[37m\033[1m[ \033[36mNON\033[37m ]\033[0m";
|
2018-08-17 16:46:56 +02:00
|
|
|
static u8 okmsg[] =
|
2018-09-27 21:01:02 +02:00
|
|
|
"\033[99C\033[8D\033[37m\033[1m[ \033[32mOK\033[37m ]\033[0m";
|
2018-08-17 16:46:56 +02:00
|
|
|
static u8 errormsg[] =
|
2018-09-27 21:01:02 +02:00
|
|
|
"\033[99C\033[8D\033[37m\033[1m[\033[31mERREUR\033[37m]\033[0m";
|
2018-08-17 16:46:56 +02:00
|
|
|
static u8 key = 0;
|
2007-04-02 16:19:44 +02:00
|
|
|
|
|
|
|
void ok()
|
|
|
|
{
|
2018-08-17 16:46:56 +02:00
|
|
|
print(okmsg);
|
|
|
|
return;
|
2007-04-02 16:19:44 +02:00
|
|
|
}
|
2007-04-02 14:52:01 +02:00
|
|
|
|
2018-08-17 16:46:56 +02:00
|
|
|
void warning()
|
|
|
|
{
|
|
|
|
print(warnmsg);
|
|
|
|
return;
|
|
|
|
}
|
2007-04-02 16:19:44 +02:00
|
|
|
|
2018-08-17 16:46:56 +02:00
|
|
|
void error()
|
|
|
|
{
|
|
|
|
print(errormsg);
|
|
|
|
return;
|
2007-04-02 15:26:03 +02:00
|
|
|
}
|
2007-04-02 15:47:30 +02:00
|
|
|
|
2018-09-27 21:01:02 +02:00
|
|
|
int main(u32 magic, u32 addr)
|
2018-08-17 16:46:56 +02:00
|
|
|
{
|
|
|
|
cli();
|
|
|
|
setvmode(0x02);
|
|
|
|
/* Efface l'ecran */
|
2018-09-27 17:32:25 +02:00
|
|
|
|
2018-08-17 16:46:56 +02:00
|
|
|
print("\033[2J\000");
|
2018-10-07 12:57:38 +02:00
|
|
|
print(ansilogo);
|
2018-08-17 16:46:56 +02:00
|
|
|
|
2018-09-27 21:01:02 +02:00
|
|
|
print("\033[37m\033[0m -Chargement noyaux");
|
2018-09-27 17:47:27 +02:00
|
|
|
ok();
|
2018-09-27 17:32:25 +02:00
|
|
|
|
2018-09-27 21:01:02 +02:00
|
|
|
printf("\033[37m\033[0m -Nombre magique multiboot2 : %X",
|
2018-09-27 17:47:27 +02:00
|
|
|
(u32) magic);
|
|
|
|
if (magic == MULTIBOOT2_BOOTLOADER_MAGIC)
|
2018-09-27 21:01:02 +02:00
|
|
|
{
|
|
|
|
initmultiboot(addr);
|
2018-09-27 17:47:27 +02:00
|
|
|
ok();
|
2018-09-27 21:01:02 +02:00
|
|
|
}
|
2018-09-27 17:47:27 +02:00
|
|
|
else
|
|
|
|
error();
|
2018-09-27 17:32:25 +02:00
|
|
|
|
2018-09-27 21:01:02 +02:00
|
|
|
print("\033[37m\033[0m -Initilisation de la memoire (GDT)");
|
2018-09-27 17:47:27 +02:00
|
|
|
initgdt(&&next);
|
|
|
|
next:
|
2018-09-01 22:58:05 +02:00
|
|
|
ok();
|
|
|
|
|
2018-09-27 21:01:02 +02:00
|
|
|
print("\033[37m\033[0m -Initilisation des taches (TSR)");
|
2018-09-27 17:47:27 +02:00
|
|
|
inittr();
|
2018-09-18 15:11:50 +02:00
|
|
|
ok();
|
|
|
|
|
2018-10-02 02:16:14 +02:00
|
|
|
print("\033[37m\033[0m -Initilisation de la pagination (PAGING)");
|
|
|
|
initpaging();
|
|
|
|
ok();
|
|
|
|
|
2018-09-27 21:01:02 +02:00
|
|
|
print("\033[37m\033[0m -Initilisation des interruptions (IDT/PIC)");
|
2018-08-17 16:46:56 +02:00
|
|
|
initidt();
|
|
|
|
initpic();
|
2018-10-02 13:49:10 +02:00
|
|
|
initretry(&&retry);
|
2018-08-17 16:46:56 +02:00
|
|
|
sti();
|
|
|
|
ok();
|
|
|
|
|
2018-09-27 21:01:02 +02:00
|
|
|
print(" -Installation du handler timer (IRQ 0)");
|
2018-10-04 14:55:41 +02:00
|
|
|
setidt((u32) timer, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 32);
|
2018-08-17 16:46:56 +02:00
|
|
|
enableirq(0);
|
|
|
|
ok();
|
|
|
|
|
2018-09-27 21:01:02 +02:00
|
|
|
print(" -Installation du handler clavier (IRQ 1)");
|
2018-10-04 14:55:41 +02:00
|
|
|
setidt((u32) keyboard, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 33);
|
2018-08-17 16:46:56 +02:00
|
|
|
enableirq(1);
|
|
|
|
ok();
|
|
|
|
|
2018-09-27 21:01:02 +02:00
|
|
|
print(" -Installation du handler souris (IRQ12+Cascade IRQ2)");
|
2018-10-04 14:55:41 +02:00
|
|
|
setidt((u32) mouse, SEL_KERNEL_CODE, ENTRY_PRESENT | ENTRY_RING0 | INTGATE, 100);
|
2018-08-17 16:46:56 +02:00
|
|
|
enableirq(2);
|
|
|
|
enableirq(12);
|
|
|
|
if (initmouse() != 1)
|
|
|
|
warning();
|
|
|
|
else
|
|
|
|
ok();
|
2018-10-04 21:49:06 +02:00
|
|
|
printf(" -Installation des appels systemes utilisateur");
|
2018-09-18 14:29:35 +02:00
|
|
|
initsyscall();
|
|
|
|
ok();
|
2018-10-07 12:57:38 +02:00
|
|
|
static u8 tester[]="ceci est un test";
|
|
|
|
static u8 strings[255];
|
|
|
|
sprintf(&strings," pour voir : %u %d %f %s",123456789,-2522,3.14f,tester);
|
|
|
|
print(&strings);
|
2018-09-18 14:29:35 +02:00
|
|
|
|
2018-10-02 13:49:10 +02:00
|
|
|
retry:
|
2018-09-27 17:47:27 +02:00
|
|
|
shell();
|
2018-08-17 16:46:56 +02:00
|
|
|
}
|