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