nuclear@11: #include nuclear@13: #include nuclear@11: #include nuclear@11: #include "asmops.h" nuclear@79: #include "proc.h" nuclear@11: nuclear@43: struct all_registers { nuclear@13: uint32_t eax, ebx, ecx, edx; nuclear@13: uint32_t esp, ebp, esi, edi; nuclear@13: uint32_t eflags; nuclear@13: uint32_t cs, ss, ds, es, fs, gs; nuclear@13: uint32_t cr0, cr1, cr2, cr3; nuclear@13: }; nuclear@13: nuclear@13: /* defined in regs.S */ nuclear@43: void get_regs(struct all_registers *regs); nuclear@13: nuclear@11: void panic(const char *fmt, ...) nuclear@11: { nuclear@11: va_list ap; nuclear@43: struct all_registers regs; nuclear@57: uint32_t eip; nuclear@13: nuclear@13: disable_intr(); nuclear@13: nuclear@13: memset(®s, 0, sizeof regs); nuclear@13: get_regs(®s); nuclear@11: nuclear@57: eip = get_caller_instr_ptr(); nuclear@57: nuclear@11: printf("~~~~~ kernel panic ~~~~~\n"); nuclear@11: va_start(ap, fmt); nuclear@11: vprintf(fmt, ap); nuclear@11: va_end(ap); nuclear@11: nuclear@13: printf("\nRegisters:\n"); nuclear@13: printf("eax: %x, ebx: %x, ecx: %x, edx: %x\n", regs.eax, regs.ebx, regs.ecx, regs.edx); nuclear@13: printf("esp: %x, ebp: %x, esi: %x, edi: %x\n", regs.esp, regs.ebp, regs.esi, regs.edi); nuclear@57: printf("eip: %x, eflags: %x\n", eip, regs.eflags); nuclear@13: printf("cr0: %x, cr1: %x, cr2: %x, cr3: %x\n", regs.cr0, regs.cr1, regs.cr2, regs.cr3); nuclear@13: printf("cs: %x (%d|%d)\n", regs.cs, regs.cs >> 3, regs.cs & 3); nuclear@13: printf("ss: %x (%d|%d)\n", regs.ss, regs.ss >> 3, regs.ss & 3); nuclear@13: printf("ds: %x (%d|%d)\n", regs.ds, regs.ds >> 3, regs.ds & 3); nuclear@13: printf("es: %x (%d|%d)\n", regs.es, regs.es >> 3, regs.es & 3); nuclear@13: printf("fs: %x (%d|%d)\n", regs.fs, regs.fs >> 3, regs.fs & 3); nuclear@13: printf("gs: %x (%d|%d)\n", regs.gs, regs.gs >> 3, regs.gs & 3); nuclear@13: nuclear@11: halt_cpu(); nuclear@11: }