kern

view src/panic.c @ 80:4db99a52863e

fixed the "endianess" of the text messages in the ATA identify info block. this is the first time I've seen wrong byteorder in ascii text, the ATA committee should be commended.
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 06 Dec 2011 13:35:39 +0200
parents 437360696883
children
line source
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdarg.h>
4 #include "asmops.h"
5 #include "proc.h"
7 struct all_registers {
8 uint32_t eax, ebx, ecx, edx;
9 uint32_t esp, ebp, esi, edi;
10 uint32_t eflags;
11 uint32_t cs, ss, ds, es, fs, gs;
12 uint32_t cr0, cr1, cr2, cr3;
13 };
15 /* defined in regs.S */
16 void get_regs(struct all_registers *regs);
18 void panic(const char *fmt, ...)
19 {
20 va_list ap;
21 struct all_registers regs;
22 uint32_t eip;
24 disable_intr();
26 memset(&regs, 0, sizeof regs);
27 get_regs(&regs);
29 eip = get_caller_instr_ptr();
31 printf("~~~~~ kernel panic ~~~~~\n");
32 va_start(ap, fmt);
33 vprintf(fmt, ap);
34 va_end(ap);
36 printf("\nRegisters:\n");
37 printf("eax: %x, ebx: %x, ecx: %x, edx: %x\n", regs.eax, regs.ebx, regs.ecx, regs.edx);
38 printf("esp: %x, ebp: %x, esi: %x, edi: %x\n", regs.esp, regs.ebp, regs.esi, regs.edi);
39 printf("eip: %x, eflags: %x\n", eip, regs.eflags);
40 printf("cr0: %x, cr1: %x, cr2: %x, cr3: %x\n", regs.cr0, regs.cr1, regs.cr2, regs.cr3);
41 printf("cs: %x (%d|%d)\n", regs.cs, regs.cs >> 3, regs.cs & 3);
42 printf("ss: %x (%d|%d)\n", regs.ss, regs.ss >> 3, regs.ss & 3);
43 printf("ds: %x (%d|%d)\n", regs.ds, regs.ds >> 3, regs.ds & 3);
44 printf("es: %x (%d|%d)\n", regs.es, regs.es >> 3, regs.es & 3);
45 printf("fs: %x (%d|%d)\n", regs.fs, regs.fs >> 3, regs.fs & 3);
46 printf("gs: %x (%d|%d)\n", regs.gs, regs.gs >> 3, regs.gs & 3);
48 halt_cpu();
49 }