ia64/xen-unstable

changeset 2502:691d8544fd52

bitkeeper revision 1.1159.79.6 (414f0c30eDJfFqGyvgWEYxbnA7GHDw)

Merge equilibrium.research:/export/scratch/xeno-xentrace.bk
into equilibrium.research:/export/scratch/xeno-xencheck.bk
author mwilli2@equilibrium.research
date Mon Sep 20 16:58:24 2004 +0000 (2004-09-20)
parents 8c94f94b6b2b 6f4e8aa5e998
children c7b0154dff73 94600c6f4011
files tools/xentrace/xentrace.c xen/common/trace.c xen/include/hypervisor-ifs/dom0_ops.h xen/include/hypervisor-ifs/trace.h
line diff
     1.1 --- a/tools/xentrace/xentrace.c	Mon Sep 20 10:49:48 2004 +0000
     1.2 +++ b/tools/xentrace/xentrace.c	Mon Sep 20 16:58:24 2004 +0000
     1.3 @@ -85,13 +85,13 @@ void write_rec(unsigned int cpu, struct 
     1.4  
     1.5  /**
     1.6   * get_tbufs - get pointer to and size of the trace buffers
     1.7 - * @phys_addr: location to store physical address if the trace buffers to
     1.8 + * @mach_addr: location to store machine address if the trace buffers to
     1.9   * @size:      location to store the size of a trace buffer to
    1.10   *
    1.11 - * Gets the physical address of the trace pointer area and the size of the
    1.12 + * Gets the machine address of the trace pointer area and the size of the
    1.13   * per CPU buffers.
    1.14   */
    1.15 -void get_tbufs(unsigned long *phys_addr, unsigned long *size)
    1.16 +void get_tbufs(unsigned long *mach_addr, unsigned long *size)
    1.17  {
    1.18      int ret;
    1.19      dom0_op_t op;                        /* dom0 op we'll build             */
    1.20 @@ -110,40 +110,40 @@ void get_tbufs(unsigned long *phys_addr,
    1.21          exit(EXIT_FAILURE);
    1.22      }
    1.23  
    1.24 -    *phys_addr = op.u.gettbufs.phys_addr;
    1.25 +    *mach_addr = op.u.gettbufs.mach_addr;
    1.26      *size      = op.u.gettbufs.size;
    1.27  }
    1.28  
    1.29  /**
    1.30   * map_tbufs - memory map Xen trace buffers into user space
    1.31 - * @tbufs:     physical address of the trace buffers
    1.32 + * @tbufs:     machine address of the trace buffers
    1.33   * @num:       number of trace buffers to map
    1.34   * @size:      size of each trace buffer
    1.35   *
    1.36   * Maps the Xen trace buffers them into process address space by memory mapping
    1.37   * /dev/mem.  Returns the location the buffers have been mapped to.
    1.38   */
    1.39 -struct t_buf *map_tbufs(unsigned long tbufs_phys, unsigned int num,
    1.40 +struct t_buf *map_tbufs(unsigned long tbufs_mach, unsigned int num,
    1.41                          unsigned long size)
    1.42  {
    1.43 -    int dm_fd;                               /* file descriptor for /dev/mem */
    1.44 +    int xc_handle;                  /* file descriptor for /proc/xen/privcmd */
    1.45      struct t_buf *tbufs_mapped;
    1.46  
    1.47 -    dm_fd = open("/dev/mem", O_RDONLY);
    1.48 +    xc_handle = xc_interface_open();
    1.49  
    1.50 -    if ( dm_fd < 0 ) 
    1.51 +    if ( xc_handle < 0 ) 
    1.52      {
    1.53 -        PERROR("Open /dev/mem when mapping trace buffers\n");
    1.54 +        PERROR("Open /proc/xen/privcmd when mapping trace buffers\n");
    1.55          exit(EXIT_FAILURE);
    1.56      }
    1.57  
    1.58 -    tbufs_mapped = (struct t_buf *)mmap(NULL, size * num,
    1.59 -                                        PROT_READ, MAP_SHARED,
    1.60 -                                        dm_fd, (off_t)tbufs_phys);
    1.61 +    tbufs_mapped = xc_map_foreign_range(xc_handle, 0 /* Dom 0 ID */,
    1.62 +					size * num, PROT_READ,
    1.63 +					tbufs_mach >> PAGE_SHIFT);
    1.64  
    1.65 -    close(dm_fd);
    1.66 +    xc_interface_close(xc_handle);
    1.67  
    1.68 -    if ( tbufs_mapped == MAP_FAILED ) 
    1.69 +    if ( tbufs_mapped == 0 ) 
    1.70      {
    1.71          PERROR("Failed to mmap trace buffers");
    1.72          exit(EXIT_FAILURE);
    1.73 @@ -187,16 +187,16 @@ struct t_buf **init_bufs_ptrs(void *bufs
    1.74  
    1.75  /**
    1.76   * init_rec_ptrs - initialises data area pointers to locations in user space
    1.77 - * @tbufs_phys:    physical base address of the trace buffer area
    1.78 + * @tbufs_mach:    machine base address of the trace buffer area
    1.79   * @tbufs_mapped:  user virtual address of base of trace buffer area
    1.80   * @meta:          array of user-space pointers to struct t_buf's of metadata
    1.81   * @num:           number of trace buffers
    1.82   *
    1.83   * Initialises data area pointers to the locations that data areas have been
    1.84 - * mapped in user space.  Note that the trace buffer metadata contains physical
    1.85 + * mapped in user space.  Note that the trace buffer metadata contains machine
    1.86   * pointers - the array returned allows more convenient access to them.
    1.87   */
    1.88 -struct t_rec **init_rec_ptrs(unsigned long tbufs_phys,
    1.89 +struct t_rec **init_rec_ptrs(unsigned long tbufs_mach,
    1.90                               struct t_buf *tbufs_mapped,
    1.91                               struct t_buf **meta,
    1.92                               unsigned int num)
    1.93 @@ -212,8 +212,8 @@ struct t_rec **init_rec_ptrs(unsigned lo
    1.94      }
    1.95  
    1.96      for ( i = 0; i<num; i++ )
    1.97 -        data[i] = (struct t_rec *)((unsigned long)meta[i]->data -
    1.98 -                                   tbufs_phys + (unsigned long)tbufs_mapped);
    1.99 +        data[i] = (struct t_rec *)(meta[i]->data - tbufs_mach
   1.100 +				   + (unsigned long)tbufs_mapped);
   1.101  
   1.102      return data;
   1.103  }
   1.104 @@ -283,7 +283,7 @@ int monitor_tbufs(FILE *logfile)
   1.105      struct t_rec **data;         /* pointers to the trace buffer data areas
   1.106                                    * where they are mapped into user space.   */
   1.107      unsigned long *cons;         /* store tail indexes for the trace buffers */
   1.108 -    unsigned long tbufs_phys;    /* physical address of the tbufs            */
   1.109 +    unsigned long tbufs_mach;    /* machine address of the tbufs             */
   1.110      unsigned int  num;           /* number of trace buffers / logical CPUS   */
   1.111      unsigned long size;          /* size of a single trace buffer            */
   1.112  
   1.113 @@ -293,36 +293,26 @@ int monitor_tbufs(FILE *logfile)
   1.114      num = get_num_cpus();
   1.115  
   1.116      /* setup access to trace buffers */
   1.117 -    get_tbufs(&tbufs_phys, &size);
   1.118 -    tbufs_mapped = map_tbufs(tbufs_phys, num, size);
   1.119 +    get_tbufs(&tbufs_mach, &size);
   1.120 +    tbufs_mapped = map_tbufs(tbufs_mach, num, size);
   1.121  
   1.122      size_in_recs = (size / sizeof(struct t_rec) )-1;
   1.123  
   1.124      /* build arrays of convenience ptrs */
   1.125      meta  = init_bufs_ptrs (tbufs_mapped, num, size);
   1.126 -    data  = init_rec_ptrs  (tbufs_phys, tbufs_mapped, meta, num);
   1.127 +    data  = init_rec_ptrs  (tbufs_mach, tbufs_mapped, meta, num);
   1.128      cons  = init_tail_idxs (meta, num);
   1.129  
   1.130      /* now, scan buffers for events */
   1.131      while ( !interrupted )
   1.132      {
   1.133          for ( i = 0; ( i < num ) && !interrupted; i++ )
   1.134 -        {	    
   1.135 -/*	    printf("XX%d: cons=%ld head=%ld  %p\n", i,
   1.136 -		   cons[i], meta[i]->head, data[i] + (cons[i] % size_in_recs) );
   1.137 -		   */
   1.138  	    while( cons[i] != meta[i]->head )
   1.139  	    {
   1.140 -/*
   1.141 -		if( (cons[i] % 6  ) == 0 )
   1.142 -		    printf("%d: cons=%ld head=%ld  %p\n", i,
   1.143 -		       cons[i], meta[i]->head, data[i] + (cons[i] % size_in_recs) );
   1.144 -		       */
   1.145  		write_rec(i, data[i] + (cons[i] % size_in_recs), logfile);
   1.146  		cons[i]++;
   1.147  	    }
   1.148  
   1.149 -        }
   1.150          nanosleep(&opts.poll_sleep, NULL);
   1.151      }
   1.152  
     2.1 --- a/xen/common/trace.c	Mon Sep 20 10:49:48 2004 +0000
     2.2 +++ b/xen/common/trace.c	Mon Sep 20 16:58:24 2004 +0000
     2.3 @@ -83,7 +83,7 @@ void init_trace_bufs(void)
     2.4          buf->head_ptr = buf->vdata;
     2.5          
     2.6          /* For use in user space. */
     2.7 -        buf->data = (struct t_rec *)__pa(buf->vdata);
     2.8 +        buf->data = __pa(buf->vdata);
     2.9          buf->head = 0;
    2.10  
    2.11          /* For use in both. */
    2.12 @@ -92,7 +92,7 @@ void init_trace_bufs(void)
    2.13      }
    2.14  
    2.15      printk("Xen trace buffers: initialised\n");
    2.16 - 
    2.17 +    
    2.18      wmb(); /* above must be visible before tb_init_done flag set */
    2.19  
    2.20      tb_init_done = 1;
    2.21 @@ -102,7 +102,7 @@ void init_trace_bufs(void)
    2.22   * get_tb_info - get trace buffer details
    2.23   * @st: a pointer to a dom0_gettbufs_t to be filled out
    2.24   *
    2.25 - * Called by the %DOM0_GETTBUFS dom0 op to fetch the physical address of the
    2.26 + * Called by the %DOM0_GETTBUFS dom0 op to fetch the machine address of the
    2.27   * trace buffers.
    2.28   */
    2.29  int get_tb_info(dom0_gettbufs_t *st)
    2.30 @@ -111,14 +111,14 @@ int get_tb_info(dom0_gettbufs_t *st)
    2.31      {
    2.32          extern unsigned int opt_tbuf_size;
    2.33          
    2.34 -        st->phys_addr = __pa(t_bufs[0]);
    2.35 +        st->mach_addr = __pa(t_bufs[0]);
    2.36          st->size      = opt_tbuf_size * PAGE_SIZE;
    2.37          
    2.38          return 0;
    2.39      }
    2.40      else
    2.41      {
    2.42 -        st->phys_addr = 0;
    2.43 +        st->mach_addr = 0;
    2.44          st->size      = 0;
    2.45          return -ENODATA;
    2.46      }
     3.1 --- a/xen/include/hypervisor-ifs/dom0_ops.h	Mon Sep 20 10:49:48 2004 +0000
     3.2 +++ b/xen/include/hypervisor-ifs/dom0_ops.h	Mon Sep 20 16:58:24 2004 +0000
     3.3 @@ -19,7 +19,7 @@
     3.4   * This makes sure that old versions of dom0 tools will stop working in a
     3.5   * well-defined way (rather than crashing the machine, for instance).
     3.6   */
     3.7 -#define DOM0_INTERFACE_VERSION   0xAAAA0014
     3.8 +#define DOM0_INTERFACE_VERSION   0xAAAA0015
     3.9  
    3.10  #define MAX_DOMAIN_NAME    16
    3.11  
    3.12 @@ -216,11 +216,11 @@ typedef struct {
    3.13      s32          cpu;                 /*  4: -1 implies unpin */
    3.14  } PACKED dom0_pincpudomain_t; /* 8 bytes */
    3.15  
    3.16 -/* Get trace buffers physical base pointer */
    3.17 +/* Get trace buffers machine base address */
    3.18  #define DOM0_GETTBUFS         21
    3.19  typedef struct {
    3.20      /* OUT variables */
    3.21 -    memory_t phys_addr;   /*  0: location of the trace buffers       */
    3.22 +    memory_t mach_addr;   /*  0: location of the trace buffers       */
    3.23      MEMORY_PADDING;
    3.24      u32      size;        /*  8: size of each trace buffer, in bytes */
    3.25  } PACKED dom0_gettbufs_t; /* 12 bytes */
     4.1 --- a/xen/include/hypervisor-ifs/trace.h	Mon Sep 20 10:49:48 2004 +0000
     4.2 +++ b/xen/include/hypervisor-ifs/trace.h	Mon Sep 20 16:58:24 2004 +0000
     4.3 @@ -17,13 +17,13 @@ struct t_rec {
     4.4   * field, indexes into an array of struct t_rec's.
     4.5   */
     4.6  struct t_buf {
     4.7 -    struct t_rec *data;     /* pointer to data area.  physical address
     4.8 -                             * for convenience in user space code            */
     4.9 +    unsigned long data;      /* pointer to data area.  machine address
    4.10 +                              * for convenience in user space code           */
    4.11  
    4.12      unsigned long size;      /* size of the data area, in t_recs             */
    4.13      unsigned long head;      /* array index of the most recent record        */
    4.14  
    4.15 -    /* Kernel-private elements follow... */
    4.16 +    /* Xen-private elements follow... */
    4.17      struct t_rec *head_ptr; /* pointer to the head record                    */
    4.18      struct t_rec *vdata;    /* virtual address pointer to data               */
    4.19  };