Implements BSOD.

This commit is contained in:
Felix Queißner 2016-05-05 19:51:04 +02:00
parent 5829e701df
commit 9a8f9e956f
5 changed files with 54 additions and 46 deletions

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "errors.hpp" #include "errors.hpp"
#include "cpustate.hpp"
/** /**
* This class provides the blue screen of death. * This class provides the blue screen of death.
@ -17,4 +18,9 @@ public:
*/ */
static void die(Error code, const char *msg); static void die(Error code, const char *msg);
/**
* Dies with a simple message and error code display.
*/
static void die(Error code, const char *msg, CpuState *cpu);
}; };

View file

@ -4,7 +4,6 @@ enum class Error
{ {
Success = 0, Success = 0,
OutOfMemory = 1, OutOfMemory = 1,
UnhandledException = 2,
UnhandledInterrupt = 3,
}; };

View file

@ -98,6 +98,8 @@ extern "C" void init(Structure const & data)
} }
*/ */
asm volatile("int $0x1");
while(true); while(true);
} }

View file

@ -1,6 +1,45 @@
#include "bsod.hpp" #include "bsod.hpp"
#include "console.hpp"
void BSOD::die(Error code, const char *msg) void BSOD::die(Error code, const char *msg)
{ {
__asm__ volatile ("cli"); BSOD::die(code, msg, nullptr);
}
/**
* Dies with a simple message and error code display.
*/
void BSOD::die(Error code, const char *msg, CpuState *cpu)
{
using namespace console_tools;
asm volatile ("cli");
Console::main << FColor(Color::White) << BColor(Color::Red);
Console::main.clear();
Console::main
<< "OH MY GOD. DasOS crashed! But i can tell you: \n"
<< msg << "\n"
<< "Also here is some CPU information:\n";
Console::main
<< "eax = " << hex(cpu->eax) << "\n"
<< "ebx = " << hex(cpu->ebx) << "\n"
<< "ecx = " << hex(cpu->ecx) << "\n"
<< "edx = " << hex(cpu->edx) << "\n"
<< "esi = " << hex(cpu->esi) << "\n"
<< "edi = " << hex(cpu->edi) << "\n"
<< "ebp = " << hex(cpu->ebp) << "\n"
<< "intr = " << cpu->interrupt << "\n"
<< "error = " << cpu->error << "\n"
<< "eip = " << hex(cpu->eip) << "\n"
<< "cs = " << hex(cpu->cs) << "\n"
<< "eflags = " << bin(cpu->eflags) << "\n"
<< "esp = " << hex(cpu->esp) << "\n"
<< "ss = " << hex(cpu->ss) << "\n";
asm volatile ("hlt");
while(true);
} }

View file

@ -1,6 +1,6 @@
#include "idt.hpp" #include "idt.hpp"
#include "io.hpp" #include "io.hpp"
#include "console.hpp" #include "bsod.hpp"
#include "pic.hpp" #include "pic.hpp"
#define ISR(num) extern "C" void isr_##num(); #define ISR(num) extern "C" void isr_##num();
@ -54,57 +54,19 @@ void IDT::setupPIC()
void IDT::dispatch(CpuState *cpu) void IDT::dispatch(CpuState *cpu)
{ {
using namespace console_tools;
if(cpu->interrupt <= 0x1F) { if(cpu->interrupt <= 0x1F) {
// Exception Handling // Exception Handling
BSOD::die(Error::UnhandledException, "Ermahgerd, Exceptions!", cpu);
Console::main << FColor(Color::Red) << "Ermahgerd, Exceptions!\n";
Console::main
<< "eax = " << hex(cpu->eax) << "\n"
<< "ebx = " << hex(cpu->ebx) << "\n"
<< "ecx = " << hex(cpu->ecx) << "\n"
<< "edx = " << hex(cpu->edx) << "\n"
<< "esi = " << hex(cpu->esi) << "\n"
<< "edi = " << hex(cpu->edi) << "\n"
<< "ebp = " << hex(cpu->ebp) << "\n"
<< "intr = " << cpu->interrupt << "\n"
<< "error = " << cpu->error << "\n"
<< "eip = " << hex(cpu->eip) << "\n"
<< "cs = " << hex(cpu->cs) << "\n"
<< "eflags = " << bin(cpu->eflags) << "\n"
<< "esp = " << hex(cpu->esp) << "\n"
<< "ss = " << hex(cpu->ss) << "\n";
while(true);
} else if (cpu->interrupt >= 0x20 && cpu->interrupt <= 0x2F) { } else if (cpu->interrupt >= 0x20 && cpu->interrupt <= 0x2F) {
// IRQ // IRQ
Console::main << "[IRQ " << (cpu->interrupt - 0x20) << "]"; // Console::main << "[IRQ " << (cpu->interrupt - 0x20) << "]";
if(cpu->interrupt >= 0x28) { if(cpu->interrupt >= 0x28) {
slavePIC.sendEndOfInterrupt(); slavePIC.sendEndOfInterrupt();
} }
masterPIC.sendEndOfInterrupt(); masterPIC.sendEndOfInterrupt();
} else { } else {
// Other Interrupt BSOD::die(Error::UnhandledInterrupt, "Ermahgerd, Interrupts!", cpu);
Console::main << "Ermahgerd, Interrupts!\n";
Console::main
<< "eax = " << hex(cpu->eax) << "\n"
<< "ebx = " << hex(cpu->ebx) << "\n"
<< "ecx = " << hex(cpu->ecx) << "\n"
<< "edx = " << hex(cpu->edx) << "\n"
<< "esi = " << hex(cpu->esi) << "\n"
<< "edi = " << hex(cpu->edi) << "\n"
<< "ebp = " << hex(cpu->ebp) << "\n"
<< "intr = " << cpu->interrupt << "\n"
<< "error = " << cpu->error << "\n"
<< "eip = " << hex(cpu->eip) << "\n"
<< "cs = " << hex(cpu->cs) << "\n"
<< "eflags = " << bin(cpu->eflags) << "\n"
<< "esp = " << hex(cpu->esp) << "\n"
<< "ss = " << hex(cpu->ss) << "\n";
while(true);
} }
} }