fix: reprise du shell après erreur fatale, test avec commande pagefault

This commit is contained in:
Nicolas Hordé 2018-10-02 13:49:10 +02:00
parent 62bd72dfe0
commit 28c831870e
5 changed files with 42 additions and 19 deletions

View File

@ -17,3 +17,4 @@ int mode();
int clear(); int clear();
int dump_regs(); int dump_regs();
int info(); int info();
int pagefault();

3
include/system.h Normal file
View File

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

View File

@ -7,6 +7,7 @@
#include "memory.h" #include "memory.h"
#include "video.h" #include "video.h"
#include "gdt.h" #include "gdt.h"
#include "system.h"
#define IDT_SIZE 256 /* nombre de descripteurs */ #define IDT_SIZE 256 /* nombre de descripteurs */
@ -16,6 +17,16 @@ static struct idtr idtreg;
/* table de IDT */ /* table de IDT */
static idtdes idt[IDT_SIZE]; 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 */ /* Initialise le controleur d'interruption 8259A */
@ -130,6 +141,9 @@ void cpuerror(const u8 * src)
print("\033[31m***** ERREUR CPU ****\r\n -"); print("\033[31m***** ERREUR CPU ****\r\n -");
print(src); print(src);
dump_regs(); dump_regs();
print("<Appuyer une touche pour continuer>\r\n");
waitascii();
initselectors(retry_address);
/*while (true) { /*while (true) {
nop(); nop();
}*/ }*/

View File

@ -13,15 +13,16 @@
#include "multiboot2.h" #include "multiboot2.h"
static command commands[] = { static command commands[] = {
{"REBOOT", "", &rebootnow}, {"REBOOT" , "", &rebootnow},
{"CLEAR", "", &clear}, {"CLEAR" , "", &clear},
{"MODE", "", &mode}, {"MODE" , "", &mode},
{"DETECTCPU", "", &detectcpu}, {"DETECTCPU" , "", &detectcpu},
{"TEST2D", "", &test2d}, {"TEST2D" , "", &test2d},
{"REGS", "", &dump_regs}, {"REGS" , "", &dump_regs},
{"GDT", "", &readgdt}, {"GDT" , "", &readgdt},
{"IDT", "", &readidt}, {"IDT" , "", &readidt},
{"INFO", "", &info} {"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 */ /* Information sur le démarrage */
int info() int info()
{ {
@ -74,7 +83,6 @@ int regs()
} }
/*******************************************************************************/ /*******************************************************************************/
/* Change le mode */ /* Change le mode */
int mode() int mode()
{ {
@ -190,10 +198,10 @@ int readgdt()
("\r\nSelecteur %hX: base:%X limit:%X access:%hX flags:%hX\r\n -> ", ("\r\nSelecteur %hX: base:%X limit:%X access:%hX flags:%hX\r\n -> ",
index * sizeof(gdtdes), base, limit, acces, flags); index * sizeof(gdtdes), base, limit, acces, flags);
if ((acces >> 4) & 1 == 1) if ((acces >> 4) & 1 == 1)
print("Systeme "); print("System ");
else { else {
if (acces & 1 == 1) if (acces & 1 == 1)
print("Acces "); print("Access ");
} }
if ((acces >> 3) & 1 == 1) { if ((acces >> 3) & 1 == 1) {
print("Code."); print("Code.");
@ -215,9 +223,9 @@ int readgdt()
if (flags & 1 == 1) if (flags & 1 == 1)
print("Dispo "); print("Dispo ");
if ((flags >> 2) & 1 == 1) if ((flags >> 2) & 1 == 1)
print("32 bits "); print("32bits ");
else else
print("16 bits "); print("16bits ");
if ((flags >> 3) & 1 == 1) if ((flags >> 3) & 1 == 1)
print("4k "); print("4k ");
else else

View File

@ -81,6 +81,7 @@ int main(u32 magic, u32 addr)
print("\033[37m\033[0m -Initilisation des interruptions (IDT/PIC)"); print("\033[37m\033[0m -Initilisation des interruptions (IDT/PIC)");
initidt(); initidt();
initpic(); initpic();
initretry(&&retry);
sti(); sti();
ok(); ok();
@ -107,10 +108,6 @@ int main(u32 magic, u32 addr)
initsyscall(); initsyscall();
ok(); ok();
print(" -Create a double fault error"); retry:
asm("mov $0x66666666, %eax \n \
mov %eax,0xE0000000");
error();
shell(); shell();
} }