ia64/xen-unstable

changeset 795:3a4eb84cc402

bitkeeper revision 1.485 (3f81b19fL5Y4lVlRaEpJI9r_IZlDcw)

Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/users/rn212/xeno.mini
into labyrinth.cl.cam.ac.uk:/auto/anfs/scratch/labyrinth/iap10/xeno-clone/xeno.bk
author iap10@labyrinth.cl.cam.ac.uk
date Mon Oct 06 18:17:03 2003 +0000 (2003-10-06)
parents 04ff2912ebc2 e035a9453032
children 8f90e566a816
files extras/mini-os/h/os.h extras/mini-os/kernel.c extras/mini-os/traps.c
line diff
     1.1 --- a/extras/mini-os/h/os.h	Mon Oct 06 17:44:09 2003 +0000
     1.2 +++ b/extras/mini-os/h/os.h	Mon Oct 06 18:17:03 2003 +0000
     1.3 @@ -63,6 +63,10 @@ struct pt_regs {
     1.4  	int  xss;
     1.5  };
     1.6  
     1.7 +/* some function prototypes */
     1.8 +void trap_init(void);
     1.9 +void dump_regs(struct pt_regs *regs);
    1.10 +
    1.11  
    1.12  /*
    1.13   * STI/CLI equivalents. These basically set and clear the virtual
     2.1 --- a/extras/mini-os/kernel.c	Mon Oct 06 17:44:09 2003 +0000
     2.2 +++ b/extras/mini-os/kernel.c	Mon Oct 06 18:17:03 2003 +0000
     2.3 @@ -36,10 +36,10 @@ char stack[8192];
     2.4  void hypervisor_callback(void);
     2.5  void failsafe_callback(void);
     2.6  
     2.7 -/* default exit event handler */
     2.8 +/* default event handlers */
     2.9  static void exit_handler(int ev, struct pt_regs *regs);
    2.10 +static void debug_handler(int ev, struct pt_regs *regs);
    2.11  
    2.12 -extern void trap_init(void);
    2.13  
    2.14  /*
    2.15   * INITIAL C ENTRY POINT.
    2.16 @@ -100,6 +100,10 @@ void start_kernel(start_info_t *si)
    2.17      enable_ev_action(EV_DIE);
    2.18      enable_hypervisor_event(EV_DIE);
    2.19  
    2.20 +    add_ev_action(EV_DEBUG, &debug_handler);
    2.21 +    enable_ev_action(EV_DEBUG);
    2.22 +    enable_hypervisor_event(EV_DEBUG);
    2.23 +
    2.24      /* init time and timers */
    2.25      init_time();
    2.26  
    2.27 @@ -124,3 +128,9 @@ static void exit_handler(int ev, struct 
    2.28      do_exit();
    2.29  }
    2.30  
    2.31 +/*
    2.32 + * a debug handler to print out some state from the guest
    2.33 + */
    2.34 +static void debug_handler(int ev, struct pt_regs *regs) {
    2.35 +    dump_regs(regs);
    2.36 +}
     3.1 --- a/extras/mini-os/traps.c	Mon Oct 06 17:44:09 2003 +0000
     3.2 +++ b/extras/mini-os/traps.c	Mon Oct 06 18:17:03 2003 +0000
     3.3 @@ -1,6 +1,7 @@
     3.4  
     3.5  #include <os.h>
     3.6  #include <hypervisor.h>
     3.7 +#include <mm.h>
     3.8  #include <lib.h>
     3.9  
    3.10  /*
    3.11 @@ -31,6 +32,7 @@ void machine_check(void);
    3.12  extern void do_exit(void);
    3.13  
    3.14  int kstack_depth_to_print = 24;
    3.15 +#define THREAD_SIZE (2*PAGE_SIZE)
    3.16  
    3.17  static inline int kernel_text_address(unsigned long addr)
    3.18  {
    3.19 @@ -57,24 +59,49 @@ void show_trace(unsigned long * stack)
    3.20      printk("\n");
    3.21  }
    3.22  
    3.23 -void dump_regs(struct pt_regs *regs) {
    3.24 -  printk("Register dump:");
    3.25 -  printk("ebx: \t 0x%lx",      regs->ebx);
    3.26 -  printk("ecx: \t 0x%lx",      regs->ecx);
    3.27 -  printk("edx: \t 0x%lx",      regs->edx);
    3.28 -  printk("esi: \t 0x%lx",      regs->esi);
    3.29 -  printk("edi: \t 0x%lx",      regs->edi);
    3.30 -  printk("ebp: \t 0x%lx",      regs->ebp);
    3.31 -  printk("eax: \t 0x%lx",      regs->eax);
    3.32 -  printk("xds: \t 0x%x",      regs->xds);
    3.33 -  printk("xes: \t 0x%x",      regs->xes);
    3.34 -  printk("orig_eax: \t 0x%lx", regs->orig_eax);
    3.35 -  printk("eip: \t 0x%lx",      regs->eip);
    3.36 -  printk("xcs: \t 0x%x",      regs->xcs);
    3.37 -  printk("eflags: \t 0x%lx",   regs->eflags);
    3.38 -  printk("esp: \t 0x%lx",      regs->esp);
    3.39 -  printk("xss: \t 0x%x",      regs->xss);
    3.40 -};
    3.41 +void show_stack(unsigned long * esp)
    3.42 +{
    3.43 +	unsigned long *stack;
    3.44 +	int i;
    3.45 +
    3.46 +	if(esp==NULL)
    3.47 +		esp=(unsigned long*)&esp;
    3.48 +
    3.49 +	stack = esp;
    3.50 +	for(i=0; i < kstack_depth_to_print; i++) {
    3.51 +		if (((long) stack & (THREAD_SIZE-1)) == 0)
    3.52 +			break;
    3.53 +		printk("%08lx ", *stack++);
    3.54 +	}
    3.55 +	printk("\n");
    3.56 +	show_trace(esp);
    3.57 +}
    3.58 +
    3.59 +void dump_regs(struct pt_regs *regs)
    3.60 +{
    3.61 +	int in_kernel = 1;
    3.62 +	unsigned long esp;
    3.63 +	unsigned short ss;
    3.64 +
    3.65 +	esp = (unsigned long) (&regs->esp);
    3.66 +	ss = __KERNEL_DS;
    3.67 +	if (regs->xcs & 2) {
    3.68 +		in_kernel = 0;
    3.69 +		esp = regs->esp;
    3.70 +		ss = regs->xss & 0xffff;
    3.71 +	}
    3.72 +	printf("EIP:    %04x:[<%08lx>]\n",
    3.73 +	       0xffff & regs->xcs, regs->eip);
    3.74 +	printf("EFLAGS: %08lx\n",regs->eflags);
    3.75 +	printf("eax: %08lx   ebx: %08lx   ecx: %08lx   edx: %08lx\n",
    3.76 +		regs->eax, regs->ebx, regs->ecx, regs->edx);
    3.77 +	printf("esi: %08lx   edi: %08lx   ebp: %08lx   esp: %08lx\n",
    3.78 +		regs->esi, regs->edi, regs->ebp, esp);
    3.79 +	printf("ds: %04x   es: %04x   ss: %04x\n",
    3.80 +		regs->xds & 0xffff, regs->xes & 0xffff, ss);
    3.81 +	printf("\n");
    3.82 +}	
    3.83 +
    3.84  
    3.85  static inline void dump_code(unsigned eip)
    3.86  {