65 lines
1.2 KiB
C
65 lines
1.2 KiB
C
#include "interrupts.h"
|
|
#include "kpanic.h"
|
|
#include "kprintf.h"
|
|
#include "utils.h"
|
|
|
|
#include <stdint.h>
|
|
#define NTMFDP 0
|
|
|
|
const char *faults[] = {
|
|
"division by zero",
|
|
"debugger",
|
|
"NMI",
|
|
"breakpoint",
|
|
"overflow",
|
|
"bounds",
|
|
"invalid opcode",
|
|
"coprocessor not available",
|
|
"double fault",
|
|
"coprocessor segement overrun",
|
|
"invalid task state segment",
|
|
"segment not present",
|
|
"stack fault",
|
|
"general protection fault",
|
|
"page fault",
|
|
"reserved",
|
|
"math fault",
|
|
"alignment check",
|
|
"machine check",
|
|
"SIMD floating point exception",
|
|
};
|
|
|
|
void exception_handler(void)
|
|
{
|
|
int8_t index = -1;
|
|
__asm__ volatile("movb %%bl, %0" ::"m"(index));
|
|
|
|
if (index == -1) {
|
|
kprintf(KERN_ERR "interrupt triggered without a code\n");
|
|
return;
|
|
}
|
|
|
|
uint8_t i = 0;
|
|
while (i < ARRAY_SIZE(faults)) {
|
|
if (i == index)
|
|
kpanic("interrupt: %s\n", faults[i]);
|
|
i++;
|
|
}
|
|
kprintf(KERN_ERR "interrupt triggered with no matching code\n");
|
|
}
|
|
|
|
void irq_handler(void)
|
|
{
|
|
int8_t index = -1;
|
|
__asm__ volatile("movb %%bl, %0" ::"m"(index));
|
|
|
|
pic_send_eoi(index);
|
|
if (index == -1) {
|
|
kprintf(KERN_ERR "interrupt triggered without a code\n");
|
|
return;
|
|
}
|
|
if (index == 0)
|
|
return;
|
|
kpanic("%d\n", index);
|
|
}
|