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