Home | History | Annotate | Line # | Download | only in include
profileio.h revision 1.1
      1 /*	$NetBSD: profileio.h,v 1.1 2002/02/10 01:57:37 thorpej Exp $	*/
      2 
      3 /*
      4  * Copyright 1997
      5  * Digital Equipment Corporation. All rights reserved.
      6  *
      7  * This software is furnished under license and may be used and
      8  * copied only in accordance with the following terms and conditions.
      9  * Subject to these conditions, you may download, copy, install,
     10  * use, modify and distribute this software in source and/or binary
     11  * form. No title or ownership is transferred hereby.
     12  *
     13  * 1) Any source code used, modified or distributed must reproduce
     14  *    and retain this copyright notice and list of conditions as
     15  *    they appear in the source file.
     16  *
     17  * 2) No right is granted to use any trade name, trademark, or logo of
     18  *    Digital Equipment Corporation. Neither the "Digital Equipment
     19  *    Corporation" name nor any trademark or logo of Digital Equipment
     20  *    Corporation may be used to endorse or promote products derived
     21  *    from this software without the prior written permission of
     22  *    Digital Equipment Corporation.
     23  *
     24  * 3) This software is provided "AS-IS" and any express or implied
     25  *    warranties, including but not limited to, any implied warranties
     26  *    of merchantability, fitness for a particular purpose, or
     27  *    non-infringement are disclaimed. In no event shall DIGITAL be
     28  *    liable for any damages whatsoever, and in particular, DIGITAL
     29  *    shall not be liable for special, indirect, consequential, or
     30  *    incidental damages or damages for lost profits, loss of
     31  *    revenue or loss of use, whether such damages arise in contract,
     32  *    negligence, tort, under statute, in equity, at law or otherwise,
     33  *    even if advised of the possibility of such damage.
     34  */
     35 
     36 /*
     37  * Remote profiler structures used to communicate between the
     38  * target (SHARK) and the host (GUI'd) machine.
     39  * Also has stuff used to talk between the profiling driver and
     40  * profiling server function.
     41  *
     42  */
     43 
     44 #ifndef __PROFILE_IO_H__
     45 #define __PROFILE_IO_H__
     46 
     47 #include <sys/types.h>
     48 
     49 /* I have no idea what the 'P' group id means,
     50  * I presume it isn't used for much.??
     51  */
     52 #define PROFIOSTART	_IOWR('P', 0, struct profStartInfo) /* start profiling */
     53 #define PROFIOSTOP	_IO('P', 1)	/* stop profiling  */
     54 
     55 /* hash table stuff.
     56  */
     57 #define TABLE_ENTRY_SIZE (sizeof(struct hashEntry))
     58 #define REDUNDANT_BITS   0x02
     59 #define COUNT_BITS       0x02
     60 #define COUNT_BIT_MASK   0x03
     61 
     62 /* sample mode flags.
     63  */
     64 #define SAMPLE_MODE_MASK 0x03
     65 #define SAMPLE_PROC      0x01
     66 #define SAMPLE_KERN      0x02
     67 
     68 /* an actual entry
     69  */
     70 struct profHashEntry
     71 {
     72     unsigned int pc;          /* the pc, minus any redundant bits. */
     73     unsigned int next;        /* the next pointer as an entry index */
     74     unsigned short counts[4]; /* the counts */
     75 };
     76 
     77 /* table header.
     78  */
     79 struct profHashHeader
     80 {
     81     unsigned int tableSize;     /* total table size in entries */
     82     unsigned int entries;       /* first level table size, in entries */
     83     unsigned int samples;       /* the number of samples in the table. */
     84     unsigned int missed;        /* the number of samples missed. */
     85     unsigned int fiqs;          /* the number of fiqs. */
     86     unsigned int last;          /* last entry in the overflow area */
     87     pid_t pid;                  /* The pid being sampled */
     88     int mode;                   /* kernel or user mode */
     89 }
     90 __attribute__ ((packed));
     91 
     92 /* actual table
     93  */
     94 struct profHashTable
     95 {
     96     struct profHashHeader hdr;
     97     struct profHashEntry *entries;
     98 };
     99 
    100 /* information passed to the start/stop ioctl.
    101  */
    102 struct profStartInfo
    103 {
    104     pid_t pid;                  /* if this is -1 sample no processes */
    105     unsigned int tableSize;     /* the total table size in entries */
    106     unsigned int entries;       /* number of entries to hash */
    107     unsigned int mode;          /* if set profile the kernel */
    108     int status;                 /* status of command returned by driver. */
    109 };
    110 
    111 
    112 /* Communications Protocol stuff
    113  * defines the messages that the host and
    114  * target will use to communicate.
    115  */
    116 
    117 struct packetHeader
    118 {
    119     int code;        /* this will either be a command or a
    120 				* data specifier.
    121 				*/
    122     unsigned int size;         /* size of data to follow,
    123 				* quantity depends on code.
    124 				*/
    125 }
    126 __attribute__ ((packed));
    127 
    128 struct startSamplingCommand
    129 {
    130     pid_t pid;              /* the pid to sample */
    131     unsigned int tableSize; /* the total table size in entries */
    132     unsigned int entries;   /* number of entries to hash */
    133     unsigned int mode;     /* if set profile kernel also. */
    134 }
    135 __attribute__ ((packed));
    136 
    137 struct startSamplingResponse
    138 {
    139     int status;          /* identifies the status of the command. */
    140     int count;           /* number of shared lib entries following. */
    141 }
    142 __attribute__ ((packed));
    143 
    144 struct stopSamplingCommand
    145 {
    146     int alert;          /* if set then the daemon sends a SIGINT to
    147 			 * the process.
    148 			 */
    149 }
    150 __attribute__ ((packed));
    151 
    152 struct disassemble
    153 {
    154     unsigned int offset; /* offset into file to begin disassembling */
    155     unsigned int length; /* length in arm words ie 32bits. */
    156 }
    157 __attribute__ ((packed));
    158 
    159 struct profStatus
    160 {
    161     unsigned int status;    /* identifies the status. */
    162 }
    163 __attribute__ ((packed));
    164 
    165 
    166 /* Command/Data Types
    167  * Only one bit may be set for any one command.
    168  * so these are not masks but distinct values.
    169  */
    170 #define START_SAMPLING 0x01
    171 #define STOP_SAMPLING  0x02
    172 #define READ_TABLE     0x03
    173 #define DISASSEMBLY    0x04
    174 #define SYMBOL_INFO    0x05
    175 #define PROCESS_INFO   0x06
    176 
    177 /* Data Types */
    178 #define TABLE_DATA     0x07
    179 #define SYMBOL_DATA    0x08
    180 #define DISAS_DATA     0x09
    181 #define PROC_DATA      0x0a
    182 #define STATUS_DATA    0x0b
    183 #define START_DATA     0x0c
    184 
    185 /* Status Codes */
    186 #define CMD_OK           0x00
    187 #define ALREADY_SAMPLING 0x01
    188 #define NOT_SAMPLING     0x02
    189 #define NO_MEMORY        0x03
    190 #define BAD_TABLE_SIZE   0x04
    191 #define ILLEGAL_PACKET   0x05
    192 #define ILLEGAL_COMMAND  0x06
    193 #define BAD_OPTION       0x07
    194 
    195 #endif
    196