ia64/xen-unstable

changeset 790:a3daaeea74de

bitkeeper revision 1.481 (3f819edcp-Umo-ETIWz6UGXiFY1R7A)

synced two different minimal os version
author rneugeba@wyvis.research
date Mon Oct 06 16:57:00 2003 +0000 (2003-10-06)
parents 3e6f62b7d409
children 22057fc2142f e035a9453032
files mini-os/kernel.c mini-os/traps.c
line diff
     1.1 --- a/mini-os/kernel.c	Mon Oct 06 11:28:12 2003 +0000
     1.2 +++ b/mini-os/kernel.c	Mon Oct 06 16:57:00 2003 +0000
     1.3 @@ -39,6 +39,8 @@ void failsafe_callback(void);
     1.4  /* default exit event handler */
     1.5  static void exit_handler(int ev, struct pt_regs *regs);
     1.6  
     1.7 +extern void trap_init(void);
     1.8 +
     1.9  /*
    1.10   * INITIAL C ENTRY POINT.
    1.11   */
    1.12 @@ -58,6 +60,9 @@ void start_kernel(start_info_t *si)
    1.13          __KERNEL_CS, (unsigned long)failsafe_callback);
    1.14  
    1.15  
    1.16 +    trap_init();
    1.17 +
    1.18 +
    1.19      /* ENABLE EVENT DELIVERY. This is disabled at start of day. */
    1.20      __sti();
    1.21      
    1.22 @@ -78,6 +83,12 @@ void start_kernel(start_info_t *si)
    1.23      printk("  flags:      0x%lx\n", si->flags);
    1.24      printk("  cmd_line:   %s\n",  si->cmd_line ? (const char *)si->cmd_line : "NULL");
    1.25  
    1.26 +
    1.27 +    /*
    1.28 +     * If used for porting another OS, start here to figure out your
    1.29 +     * guest os entry point. Otherwise continue below...
    1.30 +     */
    1.31 +
    1.32      /* init memory management */
    1.33      init_mm();
    1.34  
     2.1 --- a/mini-os/traps.c	Mon Oct 06 11:28:12 2003 +0000
     2.2 +++ b/mini-os/traps.c	Mon Oct 06 16:57:00 2003 +0000
     2.3 @@ -27,6 +27,66 @@ void alignment_check(void);
     2.4  void spurious_interrupt_bug(void);
     2.5  void machine_check(void);
     2.6  
     2.7 +
     2.8 +extern void do_exit(void);
     2.9 +
    2.10 +int kstack_depth_to_print = 24;
    2.11 +
    2.12 +static inline int kernel_text_address(unsigned long addr)
    2.13 +{
    2.14 +    return ( (addr >> 20) > 0x800 && (addr >> 20) < 0x804 );
    2.15 +}
    2.16 +
    2.17 +void show_trace(unsigned long * stack)
    2.18 +{
    2.19 +    int i;
    2.20 +    unsigned long addr;
    2.21 +
    2.22 +    if (!stack)
    2.23 +        stack = (unsigned long*)&stack;
    2.24 +
    2.25 +    printk("Call Trace: ");
    2.26 +    i = 1;
    2.27 +    while (((long) stack & (4095)) != 0) {
    2.28 +        addr = *stack++;
    2.29 +        if (kernel_text_address(addr)) {
    2.30 +            printf("0x%lx", addr);
    2.31 +            i++;
    2.32 +        }
    2.33 +    }
    2.34 +    printk("\n");
    2.35 +}
    2.36 +
    2.37 +void dump_regs(struct pt_regs *regs) {
    2.38 +  printk("Register dump:");
    2.39 +  printk("ebx: \t 0x%lx",      regs->ebx);
    2.40 +  printk("ecx: \t 0x%lx",      regs->ecx);
    2.41 +  printk("edx: \t 0x%lx",      regs->edx);
    2.42 +  printk("esi: \t 0x%lx",      regs->esi);
    2.43 +  printk("edi: \t 0x%lx",      regs->edi);
    2.44 +  printk("ebp: \t 0x%lx",      regs->ebp);
    2.45 +  printk("eax: \t 0x%lx",      regs->eax);
    2.46 +  printk("xds: \t 0x%x",      regs->xds);
    2.47 +  printk("xes: \t 0x%x",      regs->xes);
    2.48 +  printk("orig_eax: \t 0x%lx", regs->orig_eax);
    2.49 +  printk("eip: \t 0x%lx",      regs->eip);
    2.50 +  printk("xcs: \t 0x%x",      regs->xcs);
    2.51 +  printk("eflags: \t 0x%lx",   regs->eflags);
    2.52 +  printk("esp: \t 0x%lx",      regs->esp);
    2.53 +  printk("xss: \t 0x%x",      regs->xss);
    2.54 +};
    2.55 +
    2.56 +static inline void dump_code(unsigned eip)
    2.57 +{
    2.58 +  unsigned *ptr = (unsigned *)eip;
    2.59 +  int x;
    2.60 +
    2.61 +  printk("Bytes at eip:\n");
    2.62 +  for (x = -4; x < 5; x++)
    2.63 +      printf("%x", ptr[x]);
    2.64 +}
    2.65 +
    2.66 +
    2.67  /*
    2.68   * C handlers here have their parameter-list constructed by the
    2.69   * assembler stubs above. Each one gets a pointer to a list
    2.70 @@ -42,7 +102,13 @@ void machine_check(void);
    2.71  static void inline do_trap(int trapnr, char *str,
    2.72  			   struct pt_regs * regs, long error_code)
    2.73  {
    2.74 -    printk("Trap\n");
    2.75 +  printk("FATAL:  Unhandled Trap (see mini-os:traps.c)");
    2.76 +  printf("%d %s", trapnr, str);
    2.77 +  dump_regs(regs);
    2.78 +  show_trace((void *)regs->esp);
    2.79 +  dump_code(regs->eip);
    2.80 +
    2.81 +  do_exit();
    2.82  }
    2.83  
    2.84  #define DO_ERROR(trapnr, str, name) \
    2.85 @@ -75,11 +141,21 @@ void do_page_fault(struct pt_regs * regs
    2.86                     unsigned long address)
    2.87  {
    2.88      printk("Page fault\n");
    2.89 +    printk("Address: 0x%lx", address);
    2.90 +    printk("Error Code: 0x%lx", error_code);
    2.91 +    printk("eip: \t 0x%lx", regs->eip);
    2.92 +    do_exit();
    2.93  }
    2.94  
    2.95  void do_general_protection(struct pt_regs * regs, long error_code)
    2.96  {
    2.97 -    printk("GPF\n");
    2.98 +
    2.99 +  HYPERVISOR_shared_info->events_mask = 0;
   2.100 +  printk("GPF\n");
   2.101 +  printk("Error Code: 0x%lx", error_code);
   2.102 +  dump_regs(regs);
   2.103 +  dump_code(regs->eip);
   2.104 +  do_exit();
   2.105  }
   2.106  
   2.107  
   2.108 @@ -88,6 +164,8 @@ void do_debug(struct pt_regs * regs, lon
   2.109      printk("Debug exception\n");
   2.110  #define TF_MASK 0x100
   2.111      regs->eflags &= ~TF_MASK;
   2.112 +    dump_regs(regs);
   2.113 +    do_exit();
   2.114  }
   2.115  
   2.116  
   2.117 @@ -95,6 +173,9 @@ void do_debug(struct pt_regs * regs, lon
   2.118  void do_coprocessor_error(struct pt_regs * regs, long error_code)
   2.119  {
   2.120      printk("Copro error\n");
   2.121 +    dump_regs(regs);
   2.122 +    dump_code(regs->eip);
   2.123 +    do_exit();
   2.124  }
   2.125  
   2.126  void simd_math_error(void *eip)