1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-12-11 11:35:39 -05:00
kernel/kernelmq/exception.c

54 lines
1.5 KiB
C
Raw Normal View History

2017-11-05 07:44:57 -05:00
#include "interrupt.h"
2017-11-02 23:14:46 -04:00
#include "config.h"
2017-11-01 02:07:03 -04:00
#include "logger.h"
2017-11-01 06:59:18 -04:00
static const char *const messages[] = {
2017-11-05 11:19:46 -05:00
"0 #DE - Divide Error Exception",
"1 #DB - Debug Exception",
"2 NMI - Non-maskable interrupt",
"3 #BP - Breakpoint Exception",
"4 #OF - Overflow Exception",
"5 #BR - BOUND Range Exceeded Exception",
"6 #UD - Invalid Opcode Exception",
"7 #NM - Device Not Available Exception",
"8 #DF - Double Fault Exception",
"9 Reserved - Coprocessor Segment Overrun",
"10 #TS - Invalid TSS Exception",
"11 #NP - Segment Not Present",
"12 #SS - Stack Fault Exception",
"13 #GP - General Protection Exception",
"14 #PF - Page-Fault Exception",
"15 Reserved",
"16 #MF - x87 FPU Floating-Point Error",
"17 #AC - Alignment Check Exception",
"18 #MC - Machine-Check Exception",
"19 #XF - SIMD Floating-Point Exception",
"20 Reserved",
"21 Reserved",
"22 Reserved",
"23 Reserved",
"24 Reserved",
"25 Reserved",
"26 Reserved",
"27 Reserved",
"28 Reserved",
"29 Reserved",
"30 Reserved",
"31 Reserved"
2017-11-01 06:59:18 -04:00
};
2017-11-02 22:27:21 -04:00
void exception_handler(struct IsrRegisters regs)
2017-11-01 02:07:03 -04:00
{
2017-11-02 23:14:46 -04:00
if (
2017-11-03 00:12:44 -04:00
!(/* regs.int_no >= INT_EXCEPTION_FIRST && */ // unsigned is always >= 0
2017-11-02 23:14:46 -04:00
regs.int_no <= INT_EXCEPTION_LAST)
) {
return;
}
2017-11-05 23:21:18 -05:00
logger_fail_from("exception", "Unhandled protected-mode exception:\n%s", messages[regs.int_no]);
2017-11-05 11:19:46 -05:00
asm volatile("cli");
while (1) {}
2017-11-01 02:07:03 -04:00
}