kern
view src/panic.c @ 30:a2c6110bd24b
refactored the code a bit, and merged with the malloc implementation branch
author | John Tsiombikas <nuclear@siggraph.org> |
---|---|
date | Fri, 27 May 2011 22:09:10 +0300 |
parents | cccaa40f5432 |
children | 5f6c5751ae05 |
line source
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdarg.h>
4 #include "asmops.h"
6 struct registers {
7 uint32_t eax, ebx, ecx, edx;
8 uint32_t esp, ebp, esi, edi;
9 uint32_t eflags;
10 uint32_t cs, ss, ds, es, fs, gs;
11 uint32_t cr0, cr1, cr2, cr3;
12 };
14 /* defined in regs.S */
15 void get_regs(struct registers *regs);
17 void panic(const char *fmt, ...)
18 {
19 va_list ap;
20 struct registers regs;
22 disable_intr();
24 memset(®s, 0, sizeof regs);
25 get_regs(®s);
27 printf("~~~~~ kernel panic ~~~~~\n");
28 va_start(ap, fmt);
29 vprintf(fmt, ap);
30 va_end(ap);
32 printf("\nRegisters:\n");
33 printf("eax: %x, ebx: %x, ecx: %x, edx: %x\n", regs.eax, regs.ebx, regs.ecx, regs.edx);
34 printf("esp: %x, ebp: %x, esi: %x, edi: %x\n", regs.esp, regs.ebp, regs.esi, regs.edi);
35 printf("eflags: %x\n", regs.eflags);
36 printf("cr0: %x, cr1: %x, cr2: %x, cr3: %x\n", regs.cr0, regs.cr1, regs.cr2, regs.cr3);
37 printf("cs: %x (%d|%d)\n", regs.cs, regs.cs >> 3, regs.cs & 3);
38 printf("ss: %x (%d|%d)\n", regs.ss, regs.ss >> 3, regs.ss & 3);
39 printf("ds: %x (%d|%d)\n", regs.ds, regs.ds >> 3, regs.ds & 3);
40 printf("es: %x (%d|%d)\n", regs.es, regs.es >> 3, regs.es & 3);
41 printf("fs: %x (%d|%d)\n", regs.fs, regs.fs >> 3, regs.fs & 3);
42 printf("gs: %x (%d|%d)\n", regs.gs, regs.gs >> 3, regs.gs & 3);
44 halt_cpu();
45 }