kern
diff src/panic.c @ 13:6c9138a87e02
added register dump in panic()
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 23 Feb 2011 00:12:36 +0200 |
parents | cccaa40f5432 |
children | 5f6c5751ae05 |
line diff
1.1 --- a/src/panic.c Tue Feb 22 18:51:44 2011 +0200 1.2 +++ b/src/panic.c Wed Feb 23 00:12:36 2011 +0200 1.3 @@ -1,16 +1,45 @@ 1.4 #include <stdio.h> 1.5 +#include <string.h> 1.6 #include <stdarg.h> 1.7 #include "asmops.h" 1.8 1.9 +struct registers { 1.10 + uint32_t eax, ebx, ecx, edx; 1.11 + uint32_t esp, ebp, esi, edi; 1.12 + uint32_t eflags; 1.13 + uint32_t cs, ss, ds, es, fs, gs; 1.14 + uint32_t cr0, cr1, cr2, cr3; 1.15 +}; 1.16 + 1.17 +/* defined in regs.S */ 1.18 +void get_regs(struct registers *regs); 1.19 + 1.20 void panic(const char *fmt, ...) 1.21 { 1.22 va_list ap; 1.23 + struct registers regs; 1.24 + 1.25 + disable_intr(); 1.26 + 1.27 + memset(®s, 0, sizeof regs); 1.28 + get_regs(®s); 1.29 1.30 printf("~~~~~ kernel panic ~~~~~\n"); 1.31 va_start(ap, fmt); 1.32 vprintf(fmt, ap); 1.33 va_end(ap); 1.34 1.35 - disable_intr(); 1.36 + printf("\nRegisters:\n"); 1.37 + printf("eax: %x, ebx: %x, ecx: %x, edx: %x\n", regs.eax, regs.ebx, regs.ecx, regs.edx); 1.38 + printf("esp: %x, ebp: %x, esi: %x, edi: %x\n", regs.esp, regs.ebp, regs.esi, regs.edi); 1.39 + printf("eflags: %x\n", regs.eflags); 1.40 + printf("cr0: %x, cr1: %x, cr2: %x, cr3: %x\n", regs.cr0, regs.cr1, regs.cr2, regs.cr3); 1.41 + printf("cs: %x (%d|%d)\n", regs.cs, regs.cs >> 3, regs.cs & 3); 1.42 + printf("ss: %x (%d|%d)\n", regs.ss, regs.ss >> 3, regs.ss & 3); 1.43 + printf("ds: %x (%d|%d)\n", regs.ds, regs.ds >> 3, regs.ds & 3); 1.44 + printf("es: %x (%d|%d)\n", regs.es, regs.es >> 3, regs.es & 3); 1.45 + printf("fs: %x (%d|%d)\n", regs.fs, regs.fs >> 3, regs.fs & 3); 1.46 + printf("gs: %x (%d|%d)\n", regs.gs, regs.gs >> 3, regs.gs & 3); 1.47 + 1.48 halt_cpu(); 1.49 }