]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOTimeStamp.h
xnu-7195.101.1.tar.gz
[apple/xnu.git] / iokit / IOKit / IOTimeStamp.h
1 /*
2 * Copyright (c) 1998-2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 #ifndef IOKIT_IOTIMESTAMP_H
29 #define IOKIT_IOTIMESTAMP_H
30
31 #include <sys/kdebug.h>
32
33 static inline void
34 IOTimeStampStartConstant(unsigned int csc,
35 uintptr_t a = 0, uintptr_t b = 0,
36 uintptr_t c = 0, uintptr_t d = 0)
37 {
38 (void)csc;
39 (void)a;
40 (void)b;
41 (void)c;
42 (void)d;
43 KERNEL_DEBUG_CONSTANT(((uint32_t)csc) | DBG_FUNC_START, a, b, c, d, 0);
44 }
45
46 static inline void
47 IOTimeStampEndConstant(uintptr_t csc,
48 uintptr_t a = 0, uintptr_t b = 0,
49 uintptr_t c = 0, uintptr_t d = 0)
50 {
51 (void)csc;
52 (void)a;
53 (void)b;
54 (void)c;
55 (void)d;
56 KERNEL_DEBUG_CONSTANT(((uint32_t)csc) | DBG_FUNC_END, a, b, c, d, 0);
57 }
58
59 static inline void
60 IOTimeStampConstant(uintptr_t csc,
61 uintptr_t a = 0, uintptr_t b = 0,
62 uintptr_t c = 0, uintptr_t d = 0)
63 {
64 (void)csc;
65 (void)a;
66 (void)b;
67 (void)c;
68 (void)d;
69 KERNEL_DEBUG_CONSTANT(((uint32_t)csc) | DBG_FUNC_NONE, a, b, c, d, 0);
70 }
71
72 static inline void
73 IOTimeStampConstantFiltered(uintptr_t csc,
74 uintptr_t a = 0, uintptr_t b = 0,
75 uintptr_t c = 0, uintptr_t d = 0)
76 {
77 (void)csc;
78 (void)a;
79 (void)b;
80 (void)c;
81 (void)d;
82 KERNEL_DEBUG_CONSTANT_FILTERED(((uint32_t)csc) | DBG_FUNC_NONE, a, b, c, d, 0);
83 }
84
85 /*
86 * Objects of this class will trace a filtered interval for their lifetime.
87 * The constructor takes in the start tracepoint's arguments.
88 * By default, the end tracepoint emits no additional arguments,
89 * but you can set them with setEndCodes.
90 * Alternatively, you can set them individually with setA...setD
91 */
92 class IOTimeStampIntervalConstantFiltered
93 {
94 public:
95 IOTimeStampIntervalConstantFiltered(unsigned int csc,
96 uintptr_t arg1 = 0, uintptr_t arg2 = 0,
97 uintptr_t arg3 = 0, uintptr_t arg4 = 0)
98 : _csc(csc), _endArg1(0), _endArg2(0), _endArg3(0), _endArg4(0)
99 {
100 (void)csc;
101 (void)arg1;
102 (void)arg2;
103 (void)arg3;
104 (void)arg4;
105 KDBG_FILTERED(((uint32_t)csc) | DBG_FUNC_START, arg1, arg2, arg3, arg4);
106 }
107 // Setters for the end debug codes
108 void
109 setEndCodes(uintptr_t arg1 = 0, uintptr_t arg2 = 0,
110 uintptr_t arg3 = 0, uintptr_t arg4 = 0)
111 {
112 _endArg1 = arg1;
113 _endArg2 = arg2;
114 _endArg3 = arg3;
115 _endArg4 = arg4;
116 }
117 void
118 setEndArg1(uintptr_t arg)
119 {
120 _endArg1 = arg;
121 }
122 void
123 setEndArg2(uintptr_t arg)
124 {
125 _endArg2 = arg;
126 }
127 void
128 setEndArg3(uintptr_t arg)
129 {
130 _endArg3 = arg;
131 }
132 void
133 setEndArg4(uintptr_t arg)
134 {
135 _endArg4 = arg;
136 }
137 ~IOTimeStampIntervalConstantFiltered()
138 {
139 KDBG_FILTERED(((uint32_t)_csc) | DBG_FUNC_END, _endArg1, _endArg2, _endArg3, _endArg4);
140 }
141 private:
142 #if (KDEBUG_LEVEL < KDEBUG_LEVEL_STANDARD)
143 __unused
144 #endif /* KDEBUG_LEVEL < KDEBUG_LEVEL_STANDARD */
145 unsigned int _csc;
146 // End debug codes
147 #if (KDEBUG_LEVEL < KDEBUG_LEVEL_STANDARD)
148 __unused
149 #endif /* KDEBUG_LEVEL < KDEBUG_LEVEL_STANDARD */
150 uintptr_t _endArg1, _endArg2, _endArg3, _endArg4;
151 };
152
153 #if KDEBUG
154
155 static inline void
156 IOTimeStampStart(uintptr_t csc,
157 uintptr_t a = 0, uintptr_t b = 0,
158 uintptr_t c = 0, uintptr_t d = 0)
159 {
160 (void)csc;
161 (void)a;
162 (void)b;
163 (void)c;
164 (void)d;
165 KERNEL_DEBUG(((uint32_t)csc) | DBG_FUNC_START, a, b, c, d, 0);
166 }
167
168 static inline void
169 IOTimeStampEnd(uintptr_t csc,
170 uintptr_t a = 0, uintptr_t b = 0,
171 uintptr_t c = 0, uintptr_t d = 0)
172 {
173 (void)csc;
174 (void)a;
175 (void)b;
176 (void)c;
177 (void)d;
178 KERNEL_DEBUG(((uint32_t)csc) | DBG_FUNC_END, a, b, c, d, 0);
179 }
180
181 static inline void
182 IOTimeStamp(uintptr_t csc,
183 uintptr_t a = 0, uintptr_t b = 0,
184 uintptr_t c = 0, uintptr_t d = 0)
185 {
186 (void)csc;
187 (void)a;
188 (void)b;
189 (void)c;
190 (void)d;
191 KERNEL_DEBUG(((uint32_t)csc) | DBG_FUNC_NONE, a, b, c, d, 0);
192 }
193
194 #endif /* KDEBUG */
195
196 #define IODBG_STORAGE(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSTORAGE, code))
197 #define IODBG_NETWORK(code) (KDBG_CODE(DBG_IOKIT, DBG_IONETWORK, code))
198 #define IODBG_KEYBOARD(code) (KDBG_CODE(DBG_IOKIT, DBG_IOKEYBOARD, code))
199 #define IODBG_HID(code) (KDBG_CODE(DBG_IOKIT, DBG_IOHID, code))
200 #define IODBG_AUDIO(code) (KDBG_CODE(DBG_IOKIT, DBG_IOAUDIO, code))
201 #define IODBG_SERIAL(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSERIAL, code))
202 #define IODBG_TTY(code) (KDBG_CODE(DBG_IOKIT, DBG_IOTTY, code))
203 #define IODBG_SAM(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSAM, code))
204 #define IODBG_PARALLELATA(code) (KDBG_CODE(DBG_IOKIT, DBG_IOPARALLELATA, code))
205 #define IODBG_PARALLELSCSI(code) (KDBG_CODE(DBG_IOKIT, DBG_IOPARALLELSCSI, code))
206 #define IODBG_SATA(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSATA, code))
207 #define IODBG_SAS(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSAS, code))
208 #define IODBG_FIBRECHANNEL(code) (KDBG_CODE(DBG_IOKIT, DBG_IOFIBRECHANNEL, code))
209 #define IODBG_USB(code) (KDBG_CODE(DBG_IOKIT, DBG_IOUSB, code))
210 #define IODBG_BLUETOOTH(code) (KDBG_CODE(DBG_IOKIT, DBG_IOBLUETOOTH, code))
211 #define IODBG_FIREWIRE(code) (KDBG_CODE(DBG_IOKIT, DBG_IOFIREWIRE, code))
212 #define IODBG_INFINIBAND(code) (KDBG_CODE(DBG_IOKIT, DBG_IOINFINIBAND, code))
213
214
215 /* Backwards compatibility */
216 #define IODBG_DISK(code) IODBG_STORAGE(code)
217 #define IODBG_POINTING(code) IODBG_HID(code)
218
219
220 /* IOKit infrastructure subclasses */
221 #define IODBG_INTC(code) (KDBG_CODE(DBG_IOKIT, DBG_IOINTC, code))
222 #define IODBG_WORKLOOP(code) (KDBG_CODE(DBG_IOKIT, DBG_IOWORKLOOP, code))
223 #define IODBG_INTES(code) (KDBG_CODE(DBG_IOKIT, DBG_IOINTES, code))
224 #define IODBG_TIMES(code) (KDBG_CODE(DBG_IOKIT, DBG_IOCLKES, code))
225 #define IODBG_CMDQ(code) (KDBG_CODE(DBG_IOKIT, DBG_IOCMDQ, code))
226 #define IODBG_MCURS(code) (KDBG_CODE(DBG_IOKIT, DBG_IOMCURS, code))
227 #define IODBG_MDESC(code) (KDBG_CODE(DBG_IOKIT, DBG_IOMDESC, code))
228 #define IODBG_POWER(code) (KDBG_CODE(DBG_IOKIT, DBG_IOPOWER, code))
229 #define IODBG_IOSERVICE(code) (KDBG_CODE(DBG_IOKIT, DBG_IOSERVICE, code))
230 #define IODBG_IOREGISTRY(code) (KDBG_CODE(DBG_IOKIT, DBG_IOREGISTRY, code))
231 #define IODBG_IOMDPA(code) (KDBG_CODE(DBG_IOKIT, DBG_IOMDPA, code))
232
233 /* IOKit specific codes - within each subclass */
234
235 /* DBG_IOKIT/DBG_IODISK codes */
236
237 /* DBG_IOKIT/DBG_IONETWORK codes */
238
239 /* DBG_IOKIT/DBG_IOKEYBOARD codes */
240
241 /* DBG_IOKIT/DBG_IOHID codes */
242
243 /* DBG_IOKIT/DBG_IOAUDIO codes */
244
245 /* DBG_IOKIT/DBG_IOSERIAL codes */
246
247 /* DBG_IOKIT/DBG_IOTTY codes */
248
249 /* DBG_IOKIT/DBG_IOINTC codes */
250 #define IOINTC_HANDLER 1 /* 0x05000004 */
251 #define IOINTC_SPURIOUS 2 /* 0x05000008 */
252
253 /* DBG_IOKIT/DBG_IOWORKLOOP codes */
254 #define IOWL_CLIENT 1 /* 0x05010004 */
255 #define IOWL_WORK 2 /* 0x05010008 */
256
257 /* DBG_IOKIT/DBG_IOINTES codes */
258 #define IOINTES_CLIENT 1 /* 0x05020004 */
259 #define IOINTES_LAT 2 /* 0x05020008 */
260 #define IOINTES_SEMA 3 /* 0x0502000c */
261 #define IOINTES_INTCTXT 4 /* 0x05020010 */
262 #define IOINTES_INTFLTR 5 /* 0x05020014 */
263 #define IOINTES_ACTION 6 /* 0x05020018 */
264 #define IOINTES_FILTER 7 /* 0x0502001c */
265
266 /* DBG_IOKIT/DBG_IOTIMES codes */
267 #define IOTIMES_CLIENT 1 /* 0x05030004 */
268 #define IOTIMES_LAT 2 /* 0x05030008 */
269 #define IOTIMES_SEMA 3 /* 0x0503000c */
270 #define IOTIMES_ACTION 4 /* 0x05030010 */
271
272 /* DBG_IOKIT/DBG_IOCMDQ codes */
273 #define IOCMDQ_CLIENT 1 /* 0x05040004 */
274 #define IOCMDQ_LAT 2 /* 0x05040008 */
275 #define IOCMDQ_SEMA 3 /* 0x0504000c */
276 #define IOCMDQ_PSEMA 4 /* 0x05040010 */
277 #define IOCMDQ_PLOCK 5 /* 0x05040014 */
278 #define IOCMDQ_ACTION 6 /* 0x05040018 */
279
280 /* DBG_IOKIT/DBG_IOMCURS codes */
281
282 /* DBG_IOKIT/DBG_IOMDESC codes */
283 #define IOMDESC_WIRE 1 /* 0x05060004 */
284 #define IOMDESC_PREPARE 2 /* 0x05060008 */
285 #define IOMDESC_MAP 3 /* 0x0506000C */
286 #define IOMDESC_UNMAP 4 /* 0x05060010 */
287 #define IOMDESC_DMA_MAP 5 /* 0x05060014 */
288 #define IOMDESC_DMA_UNMAP 6 /* 0x05060018 */
289 #define IOMDESC_COMPLETE 7 /* 0x0506001C */
290
291 /* DBG_IOKIT/DBG_IOMDPA */
292 #define IOMDPA_MAPPED 1 /* 0x05410004 */
293 #define IOMDPA_UNMAPPED 2 /* 0x05410008 */
294 #define IOMDPA_SEGMENTS_PAGE 3 /* 0x0541000C */
295 #define IOMDPA_SEGMENTS_LONG 4 /* 0x05410010 */
296
297 /* DBG_IOKIT/DBG_IOPOWER codes */
298 // See IOKit/pwr_mgt/IOPMlog.h for the power management codes
299
300 /* DBG_IOKIT/DBG_IOSERVICE codes */
301 #define IOSERVICE_BUSY 1 /* 0x05080004 */
302 #define IOSERVICE_NONBUSY 2 /* 0x05080008 */
303 #define IOSERVICE_MODULESTALL 3 /* 0x0508000C */
304 #define IOSERVICE_MODULEUNSTALL 4 /* 0x05080010 */
305
306 #define IOSERVICE_TERMINATE_PHASE1 5 /* 0x05080014 */
307 #define IOSERVICE_TERMINATE_REQUEST_OK 6 /* 0x05080018 */
308 #define IOSERVICE_TERMINATE_REQUEST_FAIL 7 /* 0x0508001C */
309 #define IOSERVICE_TERMINATE_SCHEDULE_STOP 8 /* 0x05080020 */
310 #define IOSERVICE_TERMINATE_SCHEDULE_FINALIZE 9 /* 0x05080024 */
311 #define IOSERVICE_TERMINATE_WILL 10 /* 0x05080028 */
312 #define IOSERVICE_TERMINATE_DID 11 /* 0x0508002C */
313 #define IOSERVICE_TERMINATE_DID_DEFER 12 /* 0x05080030 */
314 #define IOSERVICE_TERMINATE_FINALIZE 13 /* 0x05080034 */
315 #define IOSERVICE_TERMINATE_STOP 14 /* 0x05080038 */
316 #define IOSERVICE_TERMINATE_STOP_NOP 15 /* 0x0508003C */
317 #define IOSERVICE_TERMINATE_STOP_DEFER 16 /* 0x05080040 */
318 #define IOSERVICE_TERMINATE_DONE 17 /* 0x05080044 */
319
320 #define IOSERVICE_KEXTD_ALIVE 18 /* 0x05080048 */
321 #define IOSERVICE_KEXTD_READY 19 /* 0x0508004C */
322 #define IOSERVICE_REGISTRY_QUIET 20 /* 0x05080050 */
323
324 #define IOSERVICE_TERM_SET_INACTIVE 21 /* 0x05080054 */
325 #define IOSERVICE_TERM_SCHED_PHASE2 22 /* 0x05080058 */
326 #define IOSERVICE_TERM_START_PHASE2 23 /* 0x0508005C */
327 #define IOSERVICE_TERM_TRY_PHASE2 24 /* 0x05080060 */
328 #define IOSERVICE_TERM_UC_DEFER 25 /* 0x05080064 */
329 #define IOSERVICE_DETACH 26 /* 0x05080068 */
330
331 /* DBG_IOKIT/DBG_IOREGISTRY codes */
332 #define IOREGISTRYENTRY_NAME_STRING 1 /* 0x05090004 */
333 #define IOREGISTRYENTRY_NAME 2 /* 0x05090008 */
334
335 #endif /* ! IOKIT_IOTIMESTAMP_H */