kernel/src/interrupts/exception.c

51 lines
1.4 KiB
C
Raw Normal View History

#include "main.h"
#include "../panic.h"
2017-11-01 06:07:03 +00:00
2022-06-23 10:51:42 +00:00
#include <kernaux/drivers/console.h>
2020-12-06 03:04:34 +00:00
2017-11-01 10:59:18 +00:00
static const char *const messages[] = {
2017-11-05 16:19:46 +00: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 10:59:18 +00:00
};
2017-11-03 02:27:21 +00:00
void exception_handler(struct IsrRegisters regs)
2017-11-01 06:07:03 +00:00
{
2021-12-21 06:00:49 +00:00
if (regs.int_no > INT_EXCEPTION_LAST) {
2017-11-03 03:14:46 +00:00
return;
}
2022-06-23 10:51:42 +00:00
kernaux_drivers_console_printf("[FAIL] exception: Unhandled protected-mode exception: %s\n", messages[regs.int_no]);
2017-11-05 16:19:46 +00:00
2020-11-27 14:22:20 +00:00
panic("Can not continue.");
2017-11-01 06:07:03 +00:00
}