From 14758ff4ea674e4b8f8eb23df69c4134e45b6478 Mon Sep 17 00:00:00 2001 From: 0x35c Date: Thu, 3 Oct 2024 17:00:47 +0200 Subject: [PATCH] feature: kpanic on interrupts (merdella cmd to test it) --- src/interrupt/handler.c | 45 +++++++++++++++---------------- src/shell/commands/merdella_cmd.c | 1 + 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/interrupt/handler.c b/src/interrupt/handler.c index 038cdf6..1aea8cd 100644 --- a/src/interrupt/handler.c +++ b/src/interrupt/handler.c @@ -1,5 +1,5 @@ #include "interrupts.h" -#include "kprintf.h" +#include "kpanic.h" #include @@ -8,70 +8,69 @@ void exception_handler(void) int8_t index = -1; __asm__ volatile("movb %%bl, %0" ::"m"(index)); - kprintf(KERN_CRIT "interrupt: "); switch (index) { case 0: - kprintf(KERN_CRIT "division by zero"); + kpanic("interrupt: division by zero\n"); break; case 1: - kprintf(KERN_CRIT "debugger"); + kpanic("interrupt: debugger\n"); break; case 2: - kprintf(KERN_CRIT "NMI"); + kpanic("interrupt: NMI\n"); break; case 3: - kprintf(KERN_CRIT "breakpoint"); + kpanic("interrupt: breakpoint\n"); break; case 4: - kprintf(KERN_CRIT "overflow"); + kpanic("interrupt: overflow\n"); break; case 5: - kprintf(KERN_CRIT "bounds"); + kpanic("interrupt: bounds\n"); break; case 6: - kprintf(KERN_CRIT "invalid opcode"); + kpanic("interrupt: invalid opcode\n"); break; case 7: - kprintf(KERN_CRIT "coprocessor not available"); + kpanic("interrupt: coprocessor not available\n"); break; case 8: - kprintf(KERN_CRIT "double fault"); + kpanic("interrupt: double fault\n"); break; case 9: - kprintf(KERN_CRIT "coprocessor segement overrun"); + kpanic("interrupt: coprocessor segement overrun\n"); break; case 10: - kprintf(KERN_CRIT "invalid task state segment"); + kpanic("interrupt: invalid task state segment\n"); break; case 11: - kprintf(KERN_CRIT "segment not present"); + kpanic("interrupt: segment not present\n"); break; case 12: - kprintf(KERN_CRIT "stack fault"); + kpanic("interrupt: stack fault\n"); break; case 13: - kprintf(KERN_CRIT "general protection fault"); + kpanic("interrupt: general protection fault\n"); break; case 14: - kprintf(KERN_CRIT "page fault"); + kpanic("interrupt: page fault\n"); break; case 15: - kprintf(KERN_CRIT "reserved"); + kpanic("interrupt: reserved\n"); break; case 16: - kprintf(KERN_CRIT "math fault"); + kpanic("interrupt: math fault\n"); break; case 17: - kprintf(KERN_CRIT "alignment check"); + kpanic("interrupt: alignment check\n"); break; case 18: - kprintf(KERN_CRIT "machine check"); + kpanic("interrupt: machine check\n"); break; case 19: - kprintf(KERN_CRIT "SIMD floating point exception"); + kpanic("interrupt: SIMD floating point exception\n"); break; default: + return; break; } - kprintf(KERN_CRIT "\n"); } diff --git a/src/shell/commands/merdella_cmd.c b/src/shell/commands/merdella_cmd.c index e9660bc..29f4d3e 100644 --- a/src/shell/commands/merdella_cmd.c +++ b/src/shell/commands/merdella_cmd.c @@ -46,4 +46,5 @@ void merdella_cmd(char *arg) { (void)arg; kprintf(POOP); + int i = 1 / 0; }