feat(IDT): IDT and exception handling support

This commit is contained in:
Daniel Hammer
2025-03-08 10:40:12 +01:00
parent 3656df42bc
commit 942adef65f
9 changed files with 245 additions and 9 deletions
+34 -3
View File
@@ -1,9 +1,40 @@
#include "Panic.hpp"
void Panic(const char *meditationString, System::Registers) {
kerr << "=========== Kernel panic ===========" << Kt::newline;
kerr << meditationString << Kt::newline;
void Panic(const char *meditationString, System::PanicFrame* frame) {
kerr << "\nGuru Meditation" << "\n" << "\n";
kerr << "\t" << "MeditationString: " << meditationString << Kt::newline;
#if defined (__x86_64__)
if (frame != nullptr) {
if (frame->InterruptVector == 0xE) { // In case of #PF the CPU pushes some other data to the frame
auto pf_frame = (System::PageFaultPanicFrame*)frame;
frame = (System::PanicFrame*)&pf_frame->IP;
kerr << "\t" << "InterruptVector: " << "0x" << base::hex << 0xE << "\n";
/* Page fault error details */
kerr << "\t" << "PageFaultPresent: " << base::dec << pf_frame->PageFaultError.Present << "\n";
kerr << "\t" << "PageFaultWrite: " << base::dec << pf_frame->PageFaultError.Write << "\n";
kerr << "\t" << "PageFaultUser: " << base::dec << pf_frame->PageFaultError.User << "\n";
kerr << "\t" << "PageFaultReservedWrite: " << base::dec << pf_frame->PageFaultError.ReservedWrite << "\n";
kerr << "\t" << "PageFaultInstructionFetch: " << base::dec << pf_frame->PageFaultError.InstructionFetch << "\n";
kerr << "\t" << "PageFaultProtectionKey: " << base::dec << pf_frame->PageFaultError.ProtectionKey << "\n";
kerr << "\t" << "PageFaultShadowStack: " << base::dec << pf_frame->PageFaultError.ShadowStack << "\n";
kerr << "\t" << "PageFaultSGX: " << base::dec << pf_frame->PageFaultError.ShadowStack << "\n";
}
else
{
kerr << "\t" << "InterruptVector: " << "0x" << base::hex << frame->InterruptVector << "\n";
}
kerr << "\t" << "InstructionPointer: " << "0x" << base::hex << frame->IP << "\n";
kerr << "\t" << "CodeSegment: " << "0x" << base::hex << frame->CS << "\n";
kerr << "\t" << "Flags: " << "0x" << base::hex << frame->Flags << "\n";
kerr << "\t" << "StackPointer: " << "0x" << base::hex << frame->SP << "\n";
kerr << "\t" << "StackSegment: " << "0x" << base::hex << frame->SS << "\n";
}
#endif
while (true) {
#if defined (__x86_64__)
asm ("cli");
+1 -1
View File
@@ -2,4 +2,4 @@
#include <Platform/Registers.hpp>
#include <Terminal/terminal.hpp>
void Panic(const char *meditationString, System::Registers registers);
void Panic(const char *meditationString, System::PanicFrame* frame);