52 lines
1.4 KiB
C++
Raw Normal View History

#define MODULE "isr"
#include "assert.h"
2022-09-05 16:13:51 +02:00
#include "interrupts/IRQ.h"
#include "interrupts/Interrupts.h"
2022-09-05 16:13:51 +02:00
#include "interrupts/SavedContext.h"
#include "log/Log.h"
2022-09-05 16:13:51 +02:00
#include "panic/hang.h"
#include "std/stdio.h"
2022-09-19 21:11:43 +02:00
#include "trace/StackTracer.h"
2022-09-05 16:13:51 +02:00
extern "C" void common_handler(SavedContext* context)
{
ASSERT(Interrupts::is_in_handler());
if (context->number >= 0x20 && context->number < 0x30)
{
IRQ::interrupt_handler(context);
return;
}
2022-09-05 16:13:51 +02:00
if (context->number == 13)
{
2022-09-19 21:11:43 +02:00
kerrorln("General protection fault at RIP %lx, cs %ld, ss %ld, RSP %lx, error code %ld", context->rip,
context->cs, context->ss, context->rsp, context->error_code);
2022-09-19 21:11:43 +02:00
kinfoln("Stack trace:");
StackTracer tracer(context->rbp);
tracer.trace();
2022-09-05 16:13:51 +02:00
while (1) halt();
}
if (context->number == 14)
{
2022-09-19 21:11:43 +02:00
kerrorln("Page fault in %s (RIP %lx), while trying to access %lx, error code %ld",
context->cs == 8 ? "ring 0" : "ring 3", context->rip, context->cr2, context->error_code);
2022-09-19 21:11:43 +02:00
kinfoln("Stack trace:");
StackTracer tracer(context->rbp);
tracer.trace();
2022-09-11 08:23:32 +02:00
hang();
}
if (context->number == 8)
{
kerrorln("Double fault, halting");
kinfoln("Stack trace:");
StackTracer tracer(context->rbp);
tracer.trace();
hang();
}
if (context->number == 256) { kwarnln("Unused interrupt"); }
2022-09-05 16:13:51 +02:00
return;
}