45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#define MODULE "isr"
|
|
|
|
#include "interrupts/IRQ.h"
|
|
#include "interrupts/SavedContext.h"
|
|
#include "log/Log.h"
|
|
#include "panic/hang.h"
|
|
#include "std/stdio.h"
|
|
#include "trace/StackTracer.h"
|
|
|
|
extern "C" void common_handler(SavedContext* context)
|
|
{
|
|
if (context->number >= 0x20 && context->number < 0x30)
|
|
{
|
|
IRQ::interrupt_handler(context);
|
|
return;
|
|
}
|
|
if (context->number == 13)
|
|
{
|
|
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);
|
|
kinfoln("Stack trace:");
|
|
|
|
StackTracer tracer(context->rbp);
|
|
tracer.trace();
|
|
while (1) halt();
|
|
}
|
|
if (context->number == 14)
|
|
{
|
|
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);
|
|
kinfoln("Stack trace:");
|
|
|
|
StackTracer tracer(context->rbp);
|
|
tracer.trace();
|
|
|
|
hang();
|
|
}
|
|
if (context->number == 8)
|
|
{
|
|
kerrorln("Double fault, halting");
|
|
hang();
|
|
}
|
|
if (context->number == 256) { kwarnln("Unused interrupt"); }
|
|
return;
|
|
} |