kern
view src/panic.c @ 77:a6513dc35f04
- started writing disk/ata code
- made the debug script rip the commandline arguments out of the run script so I won't have to keep them in sync
- added 64bit sized types in klibc/intypes.h
- temporarily commented out the processes init from main
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 06 Dec 2011 11:56:08 +0200 |
parents | 5f6c5751ae05 |
children | 2dda077c1d38 |
line source
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdarg.h>
4 #include "asmops.h"
6 struct all_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 all_registers *regs);
17 void panic(const char *fmt, ...)
18 {
19 va_list ap;
20 struct all_registers regs;
21 uint32_t eip;
23 disable_intr();
25 memset(®s, 0, sizeof regs);
26 get_regs(®s);
28 eip = get_caller_instr_ptr();
30 printf("~~~~~ kernel panic ~~~~~\n");
31 va_start(ap, fmt);
32 vprintf(fmt, ap);
33 va_end(ap);
35 printf("\nRegisters:\n");
36 printf("eax: %x, ebx: %x, ecx: %x, edx: %x\n", regs.eax, regs.ebx, regs.ecx, regs.edx);
37 printf("esp: %x, ebp: %x, esi: %x, edi: %x\n", regs.esp, regs.ebp, regs.esi, regs.edi);
38 printf("eip: %x, eflags: %x\n", eip, regs.eflags);
39 printf("cr0: %x, cr1: %x, cr2: %x, cr3: %x\n", regs.cr0, regs.cr1, regs.cr2, regs.cr3);
40 printf("cs: %x (%d|%d)\n", regs.cs, regs.cs >> 3, regs.cs & 3);
41 printf("ss: %x (%d|%d)\n", regs.ss, regs.ss >> 3, regs.ss & 3);
42 printf("ds: %x (%d|%d)\n", regs.ds, regs.ds >> 3, regs.ds & 3);
43 printf("es: %x (%d|%d)\n", regs.es, regs.es >> 3, regs.es & 3);
44 printf("fs: %x (%d|%d)\n", regs.fs, regs.fs >> 3, regs.fs & 3);
45 printf("gs: %x (%d|%d)\n", regs.gs, regs.gs >> 3, regs.gs & 3);
47 halt_cpu();
48 }