1 /* $NetBSD: profileio.h,v 1.2 2015/09/07 03:49:45 dholland 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 #include <sys/ioccom.h> 49 50 /* I have no idea what the 'P' group id means, 51 * I presume it isn't used for much.?? 52 */ 53 #define PROFIOSTART _IOWR('P', 0, struct profStartInfo) /* start profiling */ 54 #define PROFIOSTOP _IO('P', 1) /* stop profiling */ 55 56 /* hash table stuff. 57 */ 58 #define TABLE_ENTRY_SIZE (sizeof(struct hashEntry)) 59 #define REDUNDANT_BITS 0x02 60 #define COUNT_BITS 0x02 61 #define COUNT_BIT_MASK 0x03 62 63 /* sample mode flags. 64 */ 65 #define SAMPLE_MODE_MASK 0x03 66 #define SAMPLE_PROC 0x01 67 #define SAMPLE_KERN 0x02 68 69 /* an actual entry 70 */ 71 struct profHashEntry 72 { 73 unsigned int pc; /* the pc, minus any redundant bits. */ 74 unsigned int next; /* the next pointer as an entry index */ 75 unsigned short counts[4]; /* the counts */ 76 }; 77 78 /* table header. 79 */ 80 struct profHashHeader 81 { 82 unsigned int tableSize; /* total table size in entries */ 83 unsigned int entries; /* first level table size, in entries */ 84 unsigned int samples; /* the number of samples in the table. */ 85 unsigned int missed; /* the number of samples missed. */ 86 unsigned int fiqs; /* the number of fiqs. */ 87 unsigned int last; /* last entry in the overflow area */ 88 pid_t pid; /* The pid being sampled */ 89 int mode; /* kernel or user mode */ 90 } 91 __attribute__ ((packed)); 92 93 /* actual table 94 */ 95 struct profHashTable 96 { 97 struct profHashHeader hdr; 98 struct profHashEntry *entries; 99 }; 100 101 /* information passed to the start/stop ioctl. 102 */ 103 struct profStartInfo 104 { 105 pid_t pid; /* if this is -1 sample no processes */ 106 unsigned int tableSize; /* the total table size in entries */ 107 unsigned int entries; /* number of entries to hash */ 108 unsigned int mode; /* if set profile the kernel */ 109 int status; /* status of command returned by driver. */ 110 }; 111 112 113 /* Communications Protocol stuff 114 * defines the messages that the host and 115 * target will use to communicate. 116 */ 117 118 struct packetHeader 119 { 120 int code; /* this will either be a command or a 121 * data specifier. 122 */ 123 unsigned int size; /* size of data to follow, 124 * quantity depends on code. 125 */ 126 } 127 __attribute__ ((packed)); 128 129 struct startSamplingCommand 130 { 131 pid_t pid; /* the pid to sample */ 132 unsigned int tableSize; /* the total table size in entries */ 133 unsigned int entries; /* number of entries to hash */ 134 unsigned int mode; /* if set profile kernel also. */ 135 } 136 __attribute__ ((packed)); 137 138 struct startSamplingResponse 139 { 140 int status; /* identifies the status of the command. */ 141 int count; /* number of shared lib entries following. */ 142 } 143 __attribute__ ((packed)); 144 145 struct stopSamplingCommand 146 { 147 int alert; /* if set then the daemon sends a SIGINT to 148 * the process. 149 */ 150 } 151 __attribute__ ((packed)); 152 153 struct disassemble 154 { 155 unsigned int offset; /* offset into file to begin disassembling */ 156 unsigned int length; /* length in arm words ie 32bits. */ 157 } 158 __attribute__ ((packed)); 159 160 struct profStatus 161 { 162 unsigned int status; /* identifies the status. */ 163 } 164 __attribute__ ((packed)); 165 166 167 /* Command/Data Types 168 * Only one bit may be set for any one command. 169 * so these are not masks but distinct values. 170 */ 171 #define START_SAMPLING 0x01 172 #define STOP_SAMPLING 0x02 173 #define READ_TABLE 0x03 174 #define DISASSEMBLY 0x04 175 #define SYMBOL_INFO 0x05 176 #define PROCESS_INFO 0x06 177 178 /* Data Types */ 179 #define TABLE_DATA 0x07 180 #define SYMBOL_DATA 0x08 181 #define DISAS_DATA 0x09 182 #define PROC_DATA 0x0a 183 #define STATUS_DATA 0x0b 184 #define START_DATA 0x0c 185 186 /* Status Codes */ 187 #define CMD_OK 0x00 188 #define ALREADY_SAMPLING 0x01 189 #define NOT_SAMPLING 0x02 190 #define NO_MEMORY 0x03 191 #define BAD_TABLE_SIZE 0x04 192 #define ILLEGAL_PACKET 0x05 193 #define ILLEGAL_COMMAND 0x06 194 #define BAD_OPTION 0x07 195 196 #endif 197