summaryrefslogtreecommitdiff
path: root/kernel/panic.c
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-01-10 03:31:15 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-01-10 03:31:15 +0100
commit1f061145327d255a97ca0fff6960744a12b42863 (patch)
tree9bd6b834aee93ce4d74c762c682c18b3e9e41d61 /kernel/panic.c
parente44ad9e6463db78c3f1df8f4dbff0cbf343ca49f (diff)
Expanded kernel panic function.
Diffstat (limited to 'kernel/panic.c')
-rw-r--r--kernel/panic.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/kernel/panic.c b/kernel/panic.c
new file mode 100644
index 0000000..bdd4e93
--- /dev/null
+++ b/kernel/panic.c
@@ -0,0 +1,41 @@
+#include "panic.h"
+#include "printf.h"
+
+char* panic_msg[] = {
+ "#DE - Divide error.",
+ "#DB",
+ "#2",
+ "#BP",
+ "#OF",
+ "#BR",
+ "#UD - Invalid opcode.",
+ "#NM",
+ "#DF - Double fault.",
+ "#9",
+ "#TS",
+ "#NP",
+ "#SS",
+ "#GP - General protection fault.",
+ "#PF - Page fault.",
+ "#15",
+ "#MF",
+ "#AC",
+ "#MC",
+ "#XM",
+ [20 ... 31] = "Undefined exception."
+};
+
+void panic(panic_stack_t stack) {
+ printf("Kernel panic: %s\n", panic_msg[stack.num]);
+ printf("INT: %8u EC: %08x\n", stack.num, stack.error_code);
+ printf(" CS: %04x DS: %04x SS: %04x\n", stack.cs, stack.ds, stack.ss);
+ printf("EIP: %08x EFLAGS: %08x\n", stack.eip, stack.eflags);
+ printf("EAX: %08x EBX: %08x ECX: %08x EDX: %08x\n", stack.eax, stack.ebx, stack.ecx, stack.edx);
+ printf("ESP: %08x EBP: %08x ESI: %08x EDI: %08x\n", stack.esp, stack.ebp, stack.esi, stack.edi);
+
+ asm volatile(
+ "cli\n"
+ "hlt\n"
+ );
+ while(1);
+}