kern

view src/panic.c @ 71:c7bd6ec7b946

changed test_proc to modify memory after the fork in order to try out copy-on-write, by pushing the result of getpid on the stack.
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 13 Oct 2011 05:22:35 +0300
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(&regs, 0, sizeof regs);
26 get_regs(&regs);
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 }