kern

annotate 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
rev   line source
nuclear@11 1 #include <stdio.h>
nuclear@13 2 #include <string.h>
nuclear@11 3 #include <stdarg.h>
nuclear@11 4 #include "asmops.h"
nuclear@11 5
nuclear@13 6 struct registers {
nuclear@13 7 uint32_t eax, ebx, ecx, edx;
nuclear@13 8 uint32_t esp, ebp, esi, edi;
nuclear@13 9 uint32_t eflags;
nuclear@13 10 uint32_t cs, ss, ds, es, fs, gs;
nuclear@13 11 uint32_t cr0, cr1, cr2, cr3;
nuclear@13 12 };
nuclear@13 13
nuclear@13 14 /* defined in regs.S */
nuclear@13 15 void get_regs(struct registers *regs);
nuclear@13 16
nuclear@11 17 void panic(const char *fmt, ...)
nuclear@11 18 {
nuclear@11 19 va_list ap;
nuclear@13 20 struct registers regs;
nuclear@13 21
nuclear@13 22 disable_intr();
nuclear@13 23
nuclear@13 24 memset(&regs, 0, sizeof regs);
nuclear@13 25 get_regs(&regs);
nuclear@11 26
nuclear@11 27 printf("~~~~~ kernel panic ~~~~~\n");
nuclear@11 28 va_start(ap, fmt);
nuclear@11 29 vprintf(fmt, ap);
nuclear@11 30 va_end(ap);
nuclear@11 31
nuclear@13 32 printf("\nRegisters:\n");
nuclear@13 33 printf("eax: %x, ebx: %x, ecx: %x, edx: %x\n", regs.eax, regs.ebx, regs.ecx, regs.edx);
nuclear@13 34 printf("esp: %x, ebp: %x, esi: %x, edi: %x\n", regs.esp, regs.ebp, regs.esi, regs.edi);
nuclear@13 35 printf("eflags: %x\n", regs.eflags);
nuclear@13 36 printf("cr0: %x, cr1: %x, cr2: %x, cr3: %x\n", regs.cr0, regs.cr1, regs.cr2, regs.cr3);
nuclear@13 37 printf("cs: %x (%d|%d)\n", regs.cs, regs.cs >> 3, regs.cs & 3);
nuclear@13 38 printf("ss: %x (%d|%d)\n", regs.ss, regs.ss >> 3, regs.ss & 3);
nuclear@13 39 printf("ds: %x (%d|%d)\n", regs.ds, regs.ds >> 3, regs.ds & 3);
nuclear@13 40 printf("es: %x (%d|%d)\n", regs.es, regs.es >> 3, regs.es & 3);
nuclear@13 41 printf("fs: %x (%d|%d)\n", regs.fs, regs.fs >> 3, regs.fs & 3);
nuclear@13 42 printf("gs: %x (%d|%d)\n", regs.gs, regs.gs >> 3, regs.gs & 3);
nuclear@13 43
nuclear@11 44 halt_cpu();
nuclear@11 45 }