kern

annotate src/panic.c @ 57:437360696883

I think we're done for now. two processes seem to be scheduled and switched just fine, fork seems to work (NO CoW YET!)
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 16 Aug 2011 03:26:53 +0300
parents 5f6c5751ae05
children 2dda077c1d38
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@43 6 struct all_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@43 15 void get_regs(struct all_registers *regs);
nuclear@13 16
nuclear@11 17 void panic(const char *fmt, ...)
nuclear@11 18 {
nuclear@11 19 va_list ap;
nuclear@43 20 struct all_registers regs;
nuclear@57 21 uint32_t eip;
nuclear@13 22
nuclear@13 23 disable_intr();
nuclear@13 24
nuclear@13 25 memset(&regs, 0, sizeof regs);
nuclear@13 26 get_regs(&regs);
nuclear@11 27
nuclear@57 28 eip = get_caller_instr_ptr();
nuclear@57 29
nuclear@11 30 printf("~~~~~ kernel panic ~~~~~\n");
nuclear@11 31 va_start(ap, fmt);
nuclear@11 32 vprintf(fmt, ap);
nuclear@11 33 va_end(ap);
nuclear@11 34
nuclear@13 35 printf("\nRegisters:\n");
nuclear@13 36 printf("eax: %x, ebx: %x, ecx: %x, edx: %x\n", regs.eax, regs.ebx, regs.ecx, regs.edx);
nuclear@13 37 printf("esp: %x, ebp: %x, esi: %x, edi: %x\n", regs.esp, regs.ebp, regs.esi, regs.edi);
nuclear@57 38 printf("eip: %x, eflags: %x\n", eip, regs.eflags);
nuclear@13 39 printf("cr0: %x, cr1: %x, cr2: %x, cr3: %x\n", regs.cr0, regs.cr1, regs.cr2, regs.cr3);
nuclear@13 40 printf("cs: %x (%d|%d)\n", regs.cs, regs.cs >> 3, regs.cs & 3);
nuclear@13 41 printf("ss: %x (%d|%d)\n", regs.ss, regs.ss >> 3, regs.ss & 3);
nuclear@13 42 printf("ds: %x (%d|%d)\n", regs.ds, regs.ds >> 3, regs.ds & 3);
nuclear@13 43 printf("es: %x (%d|%d)\n", regs.es, regs.es >> 3, regs.es & 3);
nuclear@13 44 printf("fs: %x (%d|%d)\n", regs.fs, regs.fs >> 3, regs.fs & 3);
nuclear@13 45 printf("gs: %x (%d|%d)\n", regs.gs, regs.gs >> 3, regs.gs & 3);
nuclear@13 46
nuclear@11 47 halt_cpu();
nuclear@11 48 }