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 dump_regs();
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 "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("<Appuyer une touche pour continuer>\r\n");
waitascii();
initselectors(retry_address);
/*while (true) {
nop();
}*/

View File

@ -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

View File

@ -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();
}