From 28c831870ec17124469f2fa6cbaefd51f43bca3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Tue, 2 Oct 2018 13:49:10 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20reprise=20du=20shell=20apr=C3=A8s=20erre?= =?UTF-8?q?ur=20fatale,=20test=20avec=20commande=20pagefault?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/shell.h | 1 + include/system.h | 3 +++ lib/interrupts.c | 14 ++++++++++++++ lib/shell.c | 36 ++++++++++++++++++++++-------------- system/system.c | 7 ++----- 5 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 include/system.h diff --git a/include/shell.h b/include/shell.h index 2e1db08..009ebff 100644 --- a/include/shell.h +++ b/include/shell.h @@ -17,3 +17,4 @@ int mode(); int clear(); int dump_regs(); int info(); +int pagefault(); diff --git a/include/system.h b/include/system.h new file mode 100644 index 0000000..325329e --- /dev/null +++ b/include/system.h @@ -0,0 +1,3 @@ +/*******************************************************************************/ +/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */ +/* */extern restart; diff --git a/lib/interrupts.c b/lib/interrupts.c index f3daebe..e1f9938 100755 --- a/lib/interrupts.c +++ b/lib/interrupts.c @@ -7,6 +7,7 @@ #include "memory.h" #include "video.h" #include "gdt.h" +#include "system.h" #define IDT_SIZE 256 /* nombre de descripteurs */ @@ -16,6 +17,16 @@ static struct idtr idtreg; /* table de IDT */ static idtdes idt[IDT_SIZE]; +static u32 retry_address; + +/******************************************************************************/ +/* Initialise la reprise après erreur */ + +void initretry(u32 address) +{ + retry_address=address; +} + /******************************************************************************/ /* Initialise le controleur d'interruption 8259A */ @@ -130,6 +141,9 @@ void cpuerror(const u8 * src) print("\033[31m***** ERREUR CPU ****\r\n -"); print(src); dump_regs(); + print("\r\n"); + waitascii(); + initselectors(retry_address); /*while (true) { nop(); }*/ diff --git a/lib/shell.c b/lib/shell.c index 18c2d63..e13cf35 100644 --- a/lib/shell.c +++ b/lib/shell.c @@ -13,15 +13,16 @@ #include "multiboot2.h" static command commands[] = { - {"REBOOT", "", &rebootnow}, - {"CLEAR", "", &clear}, - {"MODE", "", &mode}, - {"DETECTCPU", "", &detectcpu}, - {"TEST2D", "", &test2d}, - {"REGS", "", &dump_regs}, - {"GDT", "", &readgdt}, - {"IDT", "", &readidt}, - {"INFO", "", &info} + {"REBOOT" , "", &rebootnow}, + {"CLEAR" , "", &clear}, + {"MODE" , "", &mode}, + {"DETECTCPU" , "", &detectcpu}, + {"TEST2D" , "", &test2d}, + {"REGS" , "", &dump_regs}, + {"GDT" , "", &readgdt}, + {"IDT" , "", &readidt}, + {"INFO" , "", &info}, + {"PAGEFAULT" , "", &pagefault} }; /*******************************************************************************/ @@ -56,7 +57,15 @@ void shell() } /*******************************************************************************/ +/* Génère une erreur de page à l'adresse 0xE0000000 */ +int pagefault() +{ + print("*** Creation d'une erreur de page ***\r\n"); + asm("mov $0x66666666, %eax \n \ + mov %eax,0xE0000000"); +} +/*******************************************************************************/ /* Information sur le démarrage */ int info() { @@ -74,7 +83,6 @@ int regs() } /*******************************************************************************/ - /* Change le mode */ int mode() { @@ -190,10 +198,10 @@ int readgdt() ("\r\nSelecteur %hX: base:%X limit:%X access:%hX flags:%hX\r\n -> ", index * sizeof(gdtdes), base, limit, acces, flags); if ((acces >> 4) & 1 == 1) - print("Systeme "); + print("System "); else { if (acces & 1 == 1) - print("Acces "); + print("Access "); } if ((acces >> 3) & 1 == 1) { print("Code."); @@ -215,9 +223,9 @@ int readgdt() if (flags & 1 == 1) print("Dispo "); if ((flags >> 2) & 1 == 1) - print("32 bits "); + print("32bits "); else - print("16 bits "); + print("16bits "); if ((flags >> 3) & 1 == 1) print("4k "); else diff --git a/system/system.c b/system/system.c index 379f5cc..4513c8f 100755 --- a/system/system.c +++ b/system/system.c @@ -81,6 +81,7 @@ int main(u32 magic, u32 addr) print("\033[37m\033[0m -Initilisation des interruptions (IDT/PIC)"); initidt(); initpic(); + initretry(&&retry); sti(); ok(); @@ -107,10 +108,6 @@ int main(u32 magic, u32 addr) initsyscall(); ok(); - print(" -Create a double fault error"); - asm("mov $0x66666666, %eax \n \ - mov %eax,0xE0000000"); - error(); - +retry: shell(); }