From 8d3ef773f8daea3a0c2b110ab48f235f5d2bf22d Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 5 Oct 2021 20:57:01 +0200 Subject: kill the process that caused an exception instead of panicking --- src/kernel/arch/i386/interrupts/isr.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/kernel/arch/i386') diff --git a/src/kernel/arch/i386/interrupts/isr.c b/src/kernel/arch/i386/interrupts/isr.c index dacecba..6701d58 100644 --- a/src/kernel/arch/i386/interrupts/isr.c +++ b/src/kernel/arch/i386/interrupts/isr.c @@ -1,29 +1,40 @@ #include #include #include +#include #include #include -#define log_n_panic(x) {tty_const(x); panic_unimplemented();} // TODO kill the current process instead of panicking - bool isr_test_interrupt_called = false; +/** Kills the process that caused the exception */ +_Noreturn static void exception_finish(void) { + // TODO check if the exception was in the kernel + process_kill(process_current, 0); // TODO make the return code mean something + process_switch_any(); +} + void isr_stage3(int interrupt) { switch (interrupt) { - case 0x08: log_n_panic("#DF"); // double fault - case 0x0D: log_n_panic("#GP"); // general protection fault + case 0x08: // double fault + tty_const("#DF"); + panic_invalid_state(); + case 0x0D: // general protection fault + exception_finish(); case 0x0E: { // page fault - int cr2; + /*int cr2; tty_const("#PF at "); asm ("mov %%cr2, %0;" : "=r"(cr2) ::); - _tty_var(cr2); - panic_unimplemented(); + _tty_var(cr2);*/ + exception_finish(); } case 0x34: isr_test_interrupt_called = true; return; - default: log_n_panic("unknown interrupt"); + default: + tty_const("unknown interrupt"); + panic_unimplemented(); } } -- cgit v1.2.3