]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
2d21ac55 | 2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 A |
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. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | ||
29 | /* Copyright (c) 1997 Apple Computer, Inc. All rights reserved. | |
30 | * | |
31 | * kdebug.h - kernel_debug definitions | |
32 | * | |
33 | */ | |
34 | ||
35 | #ifndef BSD_SYS_KDEBUG_H | |
36 | #define BSD_SYS_KDEBUG_H | |
37 | ||
9bccf70c | 38 | #include <sys/appleapiopts.h> |
1c79356b A |
39 | #include <sys/cdefs.h> |
40 | __BEGIN_DECLS | |
41 | ||
9bccf70c A |
42 | #ifdef __APPLE_API_UNSTABLE |
43 | ||
1c79356b | 44 | #include <mach/clock_types.h> |
55e303ae | 45 | #include <stdint.h> |
1c79356b A |
46 | #if defined(KERNEL_BUILD) |
47 | #include <kdebug.h> | |
48 | #endif /* KERNEL_BUILD */ | |
49 | ||
50 | /* | |
51 | * types of faults that vm_fault handles | |
52 | * and creates trace entries for | |
53 | */ | |
54 | #define DBG_ZERO_FILL_FAULT 1 | |
55 | #define DBG_PAGEIN_FAULT 2 | |
56 | #define DBG_COW_FAULT 3 | |
57 | #define DBG_CACHE_HIT_FAULT 4 | |
2d21ac55 A |
58 | #define DBG_NZF_PAGE_FAULT 5 |
59 | #define DBG_GUARD_FAULT 6 | |
b0d623f7 A |
60 | #define DBG_PAGEINV_FAULT 7 |
61 | #define DBG_PAGEIND_FAULT 8 | |
1c79356b A |
62 | |
63 | ||
64 | /* The debug code consists of the following | |
65 | * | |
66 | * ---------------------------------------------------------------------- | |
67 | *| | | |Func | | |
68 | *| Class (8) | SubClass (8) | Code (14) |Qual(2)| | |
69 | * ---------------------------------------------------------------------- | |
70 | * The class specifies the higher level | |
71 | */ | |
72 | ||
73 | /* The Function qualifiers */ | |
74 | #define DBG_FUNC_START 1 | |
75 | #define DBG_FUNC_END 2 | |
76 | #define DBG_FUNC_NONE 0 | |
77 | ||
78 | ||
79 | /* The Kernel Debug Classes */ | |
0c530ab8 A |
80 | #define DBG_MACH 1 |
81 | #define DBG_NETWORK 2 | |
82 | #define DBG_FSYSTEM 3 | |
83 | #define DBG_BSD 4 | |
84 | #define DBG_IOKIT 5 | |
85 | #define DBG_DRIVERS 6 | |
86 | #define DBG_TRACE 7 | |
1c79356b | 87 | #define DBG_DLIL 8 |
91447636 | 88 | #define DBG_SECURITY 9 |
0c530ab8 A |
89 | #define DBG_MISC 20 |
90 | #define DBG_DYLD 31 | |
91 | #define DBG_QT 32 | |
92 | #define DBG_APPS 33 | |
b0d623f7 | 93 | #define DBG_LAUNCHD 34 |
0c530ab8 | 94 | #define DBG_MIG 255 |
1c79356b A |
95 | |
96 | /* **** The Kernel Debug Sub Classes for Mach (DBG_MACH) **** */ | |
0c530ab8 | 97 | #define DBG_MACH_EXCP_KTRAP_x86 0x02 /* Kernel Traps on x86 */ |
1c79356b A |
98 | #define DBG_MACH_EXCP_DFLT 0x03 /* Data Translation Fault */ |
99 | #define DBG_MACH_EXCP_IFLT 0x04 /* Inst Translation Fault */ | |
100 | #define DBG_MACH_EXCP_INTR 0x05 /* Interrupts */ | |
101 | #define DBG_MACH_EXCP_ALNG 0x06 /* Alignment Exception */ | |
0c530ab8 | 102 | #define DBG_MACH_EXCP_UTRAP_x86 0x07 /* User Traps on x86 */ |
1c79356b A |
103 | #define DBG_MACH_EXCP_FP 0x08 /* FP Unavail */ |
104 | #define DBG_MACH_EXCP_DECI 0x09 /* Decrementer Interrupt */ | |
0c530ab8 | 105 | #define DBG_MACH_CHUD 0x0A /* CHUD */ |
1c79356b A |
106 | #define DBG_MACH_EXCP_SC 0x0C /* System Calls */ |
107 | #define DBG_MACH_EXCP_TRACE 0x0D /* Trace exception */ | |
55e303ae | 108 | #define DBG_MACH_EXCP_EMUL 0x0E /* Instruction emulated */ |
1c79356b A |
109 | #define DBG_MACH_IHDLR 0x10 /* Interrupt Handlers */ |
110 | #define DBG_MACH_IPC 0x20 /* Inter Process Comm */ | |
111 | #define DBG_MACH_VM 0x30 /* Virtual Memory */ | |
2d21ac55 | 112 | #define DBG_MACH_LEAKS 0x31 /* alloc/free */ |
1c79356b A |
113 | #define DBG_MACH_SCHED 0x40 /* Scheduler */ |
114 | #define DBG_MACH_MSGID_INVALID 0x50 /* Messages - invalid */ | |
91447636 | 115 | #define DBG_MACH_LOCKS 0x60 /* new lock APIs */ |
2d21ac55 | 116 | #define DBG_MACH_PMAP 0x70 /* pmap */ |
1c79356b A |
117 | |
118 | /* Codes for Scheduler (DBG_MACH_SCHED) */ | |
119 | #define MACH_SCHED 0x0 /* Scheduler */ | |
120 | #define MACH_STACK_ATTACH 0x1 /* stack_attach() */ | |
121 | #define MACH_STACK_HANDOFF 0x2 /* stack_handoff() */ | |
122 | #define MACH_CALL_CONT 0x3 /* call_continuation() */ | |
123 | #define MACH_CALLOUT 0x4 /* callouts */ | |
124 | #define MACH_STACK_DETACH 0x5 | |
0b4e3aa0 | 125 | #define MACH_MAKE_RUNNABLE 0x6 /* make thread runnable */ |
b0d623f7 A |
126 | #define MACH_PROMOTE 0x7 /* promoted due to resource */ |
127 | #define MACH_DEMOTE 0x8 /* promotion undone */ | |
128 | #define MACH_IDLE 0x9 /* processor idling */ | |
129 | #define MACH_STACK_DEPTH 0xa /* stack depth at switch */ | |
2d21ac55 A |
130 | |
131 | /* Codes for pmap (DBG_MACH_PMAP) */ | |
132 | #define PMAP__CREATE 0x0 | |
133 | #define PMAP__DESTROY 0x1 | |
134 | #define PMAP__PROTECT 0x2 | |
135 | #define PMAP__PAGE_PROTECT 0x3 | |
136 | #define PMAP__ENTER 0x4 | |
137 | #define PMAP__REMOVE 0x5 | |
138 | #define PMAP__NEST 0x6 | |
139 | #define PMAP__UNNEST 0x7 | |
140 | #define PMAP__FLUSH_TLBS 0x8 | |
141 | #define PMAP__UPDATE_INTERRUPT 0x9 | |
142 | #define PMAP__ATTRIBUTE_CLEAR 0xa | |
1c79356b A |
143 | |
144 | /* **** The Kernel Debug Sub Classes for Network (DBG_NETWORK) **** */ | |
145 | #define DBG_NETIP 1 /* Internet Protocol */ | |
146 | #define DBG_NETARP 2 /* Address Resolution Protocol */ | |
147 | #define DBG_NETUDP 3 /* User Datagram Protocol */ | |
148 | #define DBG_NETTCP 4 /* Transmission Control Protocol */ | |
149 | #define DBG_NETICMP 5 /* Internet Control Message Protocol */ | |
150 | #define DBG_NETIGMP 6 /* Internet Group Management Protocol */ | |
151 | #define DBG_NETRIP 7 /* Routing Information Protocol */ | |
152 | #define DBG_NETOSPF 8 /* Open Shortest Path First */ | |
153 | #define DBG_NETISIS 9 /* Intermediate System to Intermediate System */ | |
154 | #define DBG_NETSNMP 10 /* Simple Network Management Protocol */ | |
155 | #define DBG_NETSOCK 11 /* Socket Layer */ | |
156 | ||
157 | /* For Apple talk */ | |
158 | #define DBG_NETAARP 100 /* Apple ARP */ | |
159 | #define DBG_NETDDP 101 /* Datagram Delivery Protocol */ | |
160 | #define DBG_NETNBP 102 /* Name Binding Protocol */ | |
161 | #define DBG_NETZIP 103 /* Zone Information Protocol */ | |
162 | #define DBG_NETADSP 104 /* Name Binding Protocol */ | |
163 | #define DBG_NETATP 105 /* Apple Transaction Protocol */ | |
164 | #define DBG_NETASP 106 /* Apple Session Protocol */ | |
165 | #define DBG_NETAFP 107 /* Apple Filing Protocol */ | |
166 | #define DBG_NETRTMP 108 /* Routing Table Maintenance Protocol */ | |
167 | #define DBG_NETAURP 109 /* Apple Update Routing Protocol */ | |
55e303ae | 168 | #define DBG_NETIPSEC 128 /* IPsec Protocol */ |
1c79356b A |
169 | |
170 | /* **** The Kernel Debug Sub Classes for IOKIT (DBG_IOKIT) **** */ | |
0c530ab8 A |
171 | #define DBG_IOWORKLOOP 1 /* Work from work loop */ |
172 | #define DBG_IOINTES 2 /* Interrupt event source */ | |
173 | #define DBG_IOCLKES 3 /* Clock event source */ | |
174 | #define DBG_IOCMDQ 4 /* Command queue latencies */ | |
175 | #define DBG_IOMCURS 5 /* Memory Cursor */ | |
176 | #define DBG_IOMDESC 6 /* Memory Descriptors */ | |
177 | #define DBG_IOPOWER 7 /* Power Managerment */ | |
b0d623f7 | 178 | #define DBG_IOSERVICE 8 /* Matching etc. */ |
0c530ab8 | 179 | |
b0d623f7 | 180 | /* **** 9-32 reserved for internal IOKit usage **** */ |
0c530ab8 A |
181 | |
182 | #define DBG_IOSTORAGE 32 /* Storage layers */ | |
183 | #define DBG_IONETWORK 33 /* Network layers */ | |
184 | #define DBG_IOKEYBOARD 34 /* Keyboard */ | |
185 | #define DBG_IOHID 35 /* HID Devices */ | |
186 | #define DBG_IOAUDIO 36 /* Audio */ | |
187 | #define DBG_IOSERIAL 37 /* Serial */ | |
188 | #define DBG_IOTTY 38 /* TTY layers */ | |
189 | #define DBG_IOSAM 39 /* SCSI Architecture Model layers */ | |
190 | #define DBG_IOPARALLELATA 40 /* Parallel ATA */ | |
191 | #define DBG_IOPARALLELSCSI 41 /* Parallel SCSI */ | |
192 | #define DBG_IOSATA 42 /* Serial-ATA */ | |
193 | #define DBG_IOSAS 43 /* SAS */ | |
194 | #define DBG_IOFIBRECHANNEL 44 /* FiberChannel */ | |
195 | #define DBG_IOUSB 45 /* USB */ | |
196 | #define DBG_IOBLUETOOTH 46 /* Bluetooth */ | |
197 | #define DBG_IOFIREWIRE 47 /* FireWire */ | |
198 | #define DBG_IOINFINIBAND 48 /* Infiniband */ | |
593a1d5f A |
199 | #define DBG_IOCPUPM 49 /* CPU Power Management */ |
200 | #define DBG_IOGRAPHICS 50 /* Graphics */ | |
0c530ab8 A |
201 | |
202 | /* Backwards compatibility */ | |
203 | #define DBG_IOPOINTING DBG_IOHID /* OBSOLETE: Use DBG_IOHID instead */ | |
204 | #define DBG_IODISK DBG_IOSTORAGE /* OBSOLETE: Use DBG_IOSTORAGE instead */ | |
1c79356b A |
205 | |
206 | /* **** The Kernel Debug Sub Classes for Device Drivers (DBG_DRIVERS) **** */ | |
0c530ab8 A |
207 | #define DBG_DRVSTORAGE 1 /* Storage layers */ |
208 | #define DBG_DRVNETWORK 2 /* Network layers */ | |
209 | #define DBG_DRVKEYBOARD 3 /* Keyboard */ | |
210 | #define DBG_DRVHID 4 /* HID Devices */ | |
211 | #define DBG_DRVAUDIO 5 /* Audio */ | |
212 | #define DBG_DRVSERIAL 7 /* Serial */ | |
213 | #define DBG_DRVSAM 8 /* SCSI Architecture Model layers */ | |
214 | #define DBG_DRVPARALLELATA 9 /* Parallel ATA */ | |
215 | #define DBG_DRVPARALLELSCSI 10 /* Parallel SCSI */ | |
216 | #define DBG_DRVSATA 11 /* Serial ATA */ | |
217 | #define DBG_DRVSAS 12 /* SAS */ | |
218 | #define DBG_DRVFIBRECHANNEL 13 /* FiberChannel */ | |
219 | #define DBG_DRVUSB 14 /* USB */ | |
220 | #define DBG_DRVBLUETOOTH 15 /* Bluetooth */ | |
221 | #define DBG_DRVFIREWIRE 16 /* FireWire */ | |
222 | #define DBG_DRVINFINIBAND 17 /* Infiniband */ | |
593a1d5f | 223 | #define DBG_DRVGRAPHICS 18 /* Graphics */ |
0c530ab8 A |
224 | |
225 | /* Backwards compatibility */ | |
226 | #define DBG_DRVPOINTING DBG_DRVHID /* OBSOLETE: Use DBG_DRVHID instead */ | |
227 | #define DBG_DRVDISK DBG_DRVSTORAGE /* OBSOLETE: Use DBG_DRVSTORAGE instead */ | |
1c79356b A |
228 | |
229 | /* **** The Kernel Debug Sub Classes for the DLIL Layer (DBG_DLIL) **** */ | |
230 | #define DBG_DLIL_STATIC 1 /* Static DLIL code */ | |
231 | #define DBG_DLIL_PR_MOD 2 /* DLIL Protocol Module */ | |
232 | #define DBG_DLIL_IF_MOD 3 /* DLIL Interface Module */ | |
233 | #define DBG_DLIL_PR_FLT 4 /* DLIL Protocol Filter */ | |
234 | #define DBG_DLIL_IF_FLT 5 /* DLIL Interface FIlter */ | |
235 | ||
236 | /* The Kernel Debug Sub Classes for File System */ | |
237 | #define DBG_FSRW 1 /* reads and writes to the filesystem */ | |
9bccf70c | 238 | #define DBG_DKRW 2 /* reads and writes to the disk */ |
55e303ae A |
239 | #define DBG_FSVN 3 /* vnode operations (inc. locking/unlocking) */ |
240 | #define DBG_FSLOOOKUP 4 /* namei and other lookup-related operations */ | |
2d21ac55 | 241 | #define DBG_JOURNAL 5 /* journaling operations */ |
b0d623f7 A |
242 | #define DBG_IOCTL 6 /* ioctl to the disk */ |
243 | #define DBG_BOOTCACHE 7 /* bootcache operations */ | |
1c79356b A |
244 | |
245 | /* The Kernel Debug Sub Classes for BSD */ | |
b0d623f7 | 246 | #define DBG_BSD_PROC 0x01 /* process/signals related */ |
2d21ac55 | 247 | #define DBG_BSD_EXCP_SC 0x0C /* System Calls */ |
55e303ae | 248 | #define DBG_BSD_AIO 0x0D /* aio (POSIX async IO) */ |
2d21ac55 A |
249 | #define DBG_BSD_SC_EXTENDED_INFO 0x0E /* System Calls, extended info */ |
250 | #define DBG_BSD_SC_EXTENDED_INFO2 0x0F /* System Calls, extended info */ | |
1c79356b | 251 | |
b0d623f7 A |
252 | |
253 | /* The Codes for BSD subcode class DBG_BSD_PROC */ | |
254 | #define BSD_PROC_EXIT 1 /* process exit */ | |
255 | #define BSD_PROC_FRCEXIT 2 /* Kernel force termination */ | |
1c79356b A |
256 | /* The Kernel Debug Sub Classes for DBG_TRACE */ |
257 | #define DBG_TRACE_DATA 0 | |
258 | #define DBG_TRACE_STRING 1 | |
b0d623f7 | 259 | #define DBG_TRACE_INFO 2 |
1c79356b | 260 | |
0c530ab8 A |
261 | /* The Kernel Debug Sub Classes for DBG_MISC */ |
262 | #define DBG_EVENT 0x10 | |
263 | #define DBG_BUFFER 0x20 | |
264 | ||
9bccf70c A |
265 | /* The Kernel Debug Sub Classes for DBG_DYLD */ |
266 | #define DBG_DYLD_STRING 5 | |
267 | ||
268 | /* The Kernel Debug modifiers for the DBG_DKRW sub class */ | |
269 | #define DKIO_DONE 0x01 | |
270 | #define DKIO_READ 0x02 | |
271 | #define DKIO_ASYNC 0x04 | |
272 | #define DKIO_META 0x08 | |
273 | #define DKIO_PAGING 0x10 | |
274 | ||
2d21ac55 A |
275 | /* Codes for Application Sub Classes */ |
276 | #define DBG_APP_SAMBA 128 | |
0c530ab8 | 277 | |
1c79356b A |
278 | /**********************************************************************/ |
279 | ||
280 | #define KDBG_CODE(Class, SubClass, code) (((Class & 0xff) << 24) | ((SubClass & 0xff) << 16) | ((code & 0x3fff) << 2)) | |
281 | ||
282 | #define KDBG_MIGCODE(msgid) ((DBG_MIG << 24) | (((msgid) & 0x3fffff) << 2)) | |
283 | ||
284 | #define MACHDBG_CODE(SubClass, code) KDBG_CODE(DBG_MACH, SubClass, code) | |
285 | #define NETDBG_CODE(SubClass, code) KDBG_CODE(DBG_NETWORK, SubClass, code) | |
286 | #define FSDBG_CODE(SubClass, code) KDBG_CODE(DBG_FSYSTEM, SubClass, code) | |
287 | #define BSDDBG_CODE(SubClass, code) KDBG_CODE(DBG_BSD, SubClass, code) | |
288 | #define IOKDBG_CODE(SubClass, code) KDBG_CODE(DBG_IOKIT, SubClass, code) | |
289 | #define DRVDBG_CODE(SubClass, code) KDBG_CODE(DBG_DRIVERS, SubClass, code) | |
290 | #define TRACEDBG_CODE(SubClass,code) KDBG_CODE(DBG_TRACE, SubClass, code) | |
291 | #define MISCDBG_CODE(SubClass,code) KDBG_CODE(DBG_MISC, SubClass, code) | |
292 | #define DLILDBG_CODE(SubClass,code) KDBG_CODE(DBG_DLIL, SubClass, code) | |
91447636 | 293 | #define SECURITYDBG_CODE(SubClass,code) KDBG_CODE(DBG_SECURITY, SubClass, code) |
9bccf70c | 294 | #define DYLDDBG_CODE(SubClass,code) KDBG_CODE(DBG_DYLD, SubClass, code) |
55e303ae | 295 | #define QTDBG_CODE(SubClass,code) KDBG_CODE(DBG_QT, SubClass, code) |
91447636 | 296 | #define APPSDBG_CODE(SubClass,code) KDBG_CODE(DBG_APPS, SubClass, code) |
0c530ab8 | 297 | #define CPUPM_CODE(code) IOKDBG_CODE(DBG_IOCPUPM, code) |
1c79356b | 298 | |
2d21ac55 A |
299 | #define KMEM_ALLOC_CODE MACHDBG_CODE(DBG_MACH_LEAKS, 0) |
300 | #define KMEM_ALLOC_CODE_2 MACHDBG_CODE(DBG_MACH_LEAKS, 1) | |
301 | #define KMEM_FREE_CODE MACHDBG_CODE(DBG_MACH_LEAKS, 2) | |
302 | #define KMEM_FREE_CODE_2 MACHDBG_CODE(DBG_MACH_LEAKS, 3) | |
303 | #define ZALLOC_CODE MACHDBG_CODE(DBG_MACH_LEAKS, 4) | |
304 | #define ZALLOC_CODE_2 MACHDBG_CODE(DBG_MACH_LEAKS, 5) | |
305 | #define ZFREE_CODE MACHDBG_CODE(DBG_MACH_LEAKS, 6) | |
306 | #define ZFREE_CODE_2 MACHDBG_CODE(DBG_MACH_LEAKS, 7) | |
307 | ||
308 | #define PMAP_CODE(code) MACHDBG_CODE(DBG_MACH_PMAP, code) | |
309 | ||
1c79356b A |
310 | /* Usage: |
311 | * kernel_debug((KDBG_CODE(DBG_NETWORK, DNET_PROTOCOL, 51) | DBG_FUNC_START), | |
312 | * offset, 0, 0, 0,0) | |
313 | * | |
314 | * For ex, | |
315 | * | |
316 | * #include <sys/kdebug.h> | |
317 | * | |
318 | * #define DBG_NETIPINIT NETDBG_CODE(DBG_NETIP,1) | |
319 | * | |
320 | * | |
321 | * void | |
322 | * ip_init() | |
323 | * { | |
324 | * register struct protosw *pr; | |
325 | * register int i; | |
326 | * | |
327 | * KERNEL_DEBUG(DBG_NETIPINIT | DBG_FUNC_START, 0,0,0,0,0) | |
328 | * -------- | |
329 | * KERNEL_DEBUG(DBG_NETIPINIT, 0,0,0,0,0) | |
330 | * -------- | |
331 | * KERNEL_DEBUG(DBG_NETIPINIT | DBG_FUNC_END, 0,0,0,0,0) | |
332 | * } | |
333 | * | |
334 | ||
335 | */ | |
336 | ||
337 | extern unsigned int kdebug_enable; | |
9bccf70c A |
338 | #define KDEBUG_ENABLE_TRACE 0x1 |
339 | #define KDEBUG_ENABLE_ENTROPY 0x2 | |
340 | #define KDEBUG_ENABLE_CHUD 0x4 | |
341 | ||
2d21ac55 A |
342 | #if (!defined(NO_KDEBUG)) |
343 | ||
b0d623f7 A |
344 | #define KERNEL_DEBUG_CONSTANT(x,a,b,c,d,e) \ |
345 | do { \ | |
346 | if (kdebug_enable) \ | |
347 | kernel_debug(x,(uintptr_t)a,(uintptr_t)b,(uintptr_t)c, \ | |
348 | (uintptr_t)d,(uintptr_t)e); \ | |
1c79356b A |
349 | } while(0) |
350 | ||
b0d623f7 A |
351 | #define KERNEL_DEBUG_CONSTANT1(x,a,b,c,d,e) \ |
352 | do { \ | |
353 | if (kdebug_enable) \ | |
354 | kernel_debug1(x,(uintptr_t)a,(uintptr_t)b,(uintptr_t)c, \ | |
355 | (uintptr_t)d,(uintptr_t)e); \ | |
0b4e3aa0 A |
356 | } while(0) |
357 | ||
2d21ac55 A |
358 | #else |
359 | ||
360 | #define KERNEL_DEBUG_CONSTANT(x,a,b,c,d,e) | |
361 | #define KERNEL_DEBUG_CONSTANT1(x,a,b,c,d,e) | |
362 | ||
363 | #define __kdebug_constant_only __unused | |
364 | #endif | |
365 | ||
b0d623f7 A |
366 | extern void kernel_debug( |
367 | uint32_t debugid, | |
368 | uintptr_t arg1, | |
369 | uintptr_t arg2, | |
370 | uintptr_t arg3, | |
371 | uintptr_t arg4, | |
372 | uintptr_t arg5); | |
1c79356b | 373 | |
b0d623f7 A |
374 | extern void kernel_debug1( |
375 | uint32_t debugid, | |
376 | uintptr_t arg1, | |
377 | uintptr_t arg2, | |
378 | uintptr_t arg3, | |
379 | uintptr_t arg4, | |
380 | uintptr_t arg5); | |
91447636 | 381 | |
91447636 | 382 | |
2d21ac55 | 383 | #if (KDEBUG && (!defined(NO_KDEBUG))) |
1c79356b | 384 | |
b0d623f7 A |
385 | #define KERNEL_DEBUG(x,a,b,c,d,e) \ |
386 | do { \ | |
387 | if (kdebug_enable) \ | |
388 | kernel_debug((uint32_t)x, (uintptr_t)a, (uintptr_t)b, \ | |
389 | (uintptr_t)c, (uintptr_t)d, (uintptr_t)e); \ | |
1c79356b A |
390 | } while(0) |
391 | ||
b0d623f7 A |
392 | #define KERNEL_DEBUG1(x,a,b,c,d,e) \ |
393 | do { \ | |
394 | if (kdebug_enable) \ | |
395 | kernel_debug1((uint32_t)x, (uintptr_t)a, (uintptr_t)b, \ | |
396 | (uintptr_t)c, (uintptr_t)d, (uintptr_t)e); \ | |
1c79356b A |
397 | } while(0) |
398 | ||
91447636 A |
399 | #define __kdebug_only |
400 | ||
1c79356b A |
401 | #else |
402 | ||
2d21ac55 A |
403 | #define KERNEL_DEBUG(x,a,b,c,d,e) do {} while (0) |
404 | #define KERNEL_DEBUG1(x,a,b,c,d,e) do {} while (0) | |
1c79356b | 405 | |
91447636 | 406 | #define __kdebug_only __unused |
1c79356b A |
407 | #endif |
408 | ||
b0d623f7 A |
409 | #ifdef KERNEL_PRIVATE |
410 | struct proc; | |
411 | extern void kdbg_trace_data(struct proc *proc, long *arg_pid); | |
412 | ||
413 | extern void kdbg_trace_string(struct proc *proc, long *arg1, long *arg2, long *arg3, long *arg4); | |
414 | ||
415 | extern void kdbg_dump_trace_to_file(const char *); | |
2d21ac55 | 416 | void start_kern_tracing(unsigned int); |
b0d623f7 A |
417 | #endif /* KERNEL_PRIVATE */ |
418 | ||
2d21ac55 | 419 | |
9bccf70c | 420 | #endif /* __APPLE_API_UNSTABLE */ |
1c79356b A |
421 | __END_DECLS |
422 | ||
423 | ||
91447636 | 424 | #ifdef PRIVATE |
9bccf70c | 425 | #ifdef __APPLE_API_PRIVATE |
1c79356b A |
426 | /* |
427 | * private kernel_debug definitions | |
428 | */ | |
429 | ||
430 | typedef struct { | |
2d21ac55 | 431 | uint64_t timestamp; |
b0d623f7 A |
432 | uintptr_t arg1; |
433 | uintptr_t arg2; | |
434 | uintptr_t arg3; | |
435 | uintptr_t arg4; | |
436 | uintptr_t arg5; /* will hold current thread */ | |
437 | uint32_t debugid; | |
438 | #if defined(__LP64__) | |
439 | uint32_t cpuid; | |
440 | uintptr_t unused; | |
441 | #endif | |
1c79356b A |
442 | } kd_buf; |
443 | ||
b0d623f7 A |
444 | #if !defined(__LP64__) |
445 | #define KDBG_TIMESTAMP_MASK 0x00ffffffffffffffULL | |
446 | #define KDBG_CPU_MASK 0x0f00000000000000ULL | |
447 | #define KDBG_CPU_SHIFT 56 | |
448 | static inline void | |
449 | kdbg_set_cpu(kd_buf *kp, int cpu) | |
450 | { | |
451 | kp->timestamp = (kp->timestamp & KDBG_TIMESTAMP_MASK) | | |
452 | (((uint64_t) cpu) << KDBG_CPU_SHIFT); | |
453 | } | |
454 | static inline int | |
455 | kdbg_get_cpu(kd_buf *kp) | |
456 | { | |
457 | return (int) (((kp)->timestamp & KDBG_CPU_MASK) >> KDBG_CPU_SHIFT); | |
458 | } | |
459 | static inline void | |
460 | kdbg_set_timestamp(kd_buf *kp, uint64_t time) | |
461 | { | |
462 | kp->timestamp = time & KDBG_TIMESTAMP_MASK; | |
463 | } | |
464 | static inline uint64_t | |
465 | kdbg_get_timestamp(kd_buf *kp) | |
466 | { | |
467 | return kp->timestamp & KDBG_TIMESTAMP_MASK; | |
468 | } | |
469 | static inline void | |
470 | kdbg_set_timestamp_and_cpu(kd_buf *kp, uint64_t time, int cpu) | |
471 | { | |
472 | kp->timestamp = (time & KDBG_TIMESTAMP_MASK) | | |
473 | (((uint64_t) cpu) << KDBG_CPU_SHIFT); | |
474 | } | |
475 | #else | |
476 | #define KDBG_TIMESTAMP_MASK 0xffffffffffffffffULL | |
477 | static inline void | |
478 | kdbg_set_cpu(kd_buf *kp, int cpu) | |
479 | { | |
480 | kp->cpuid = cpu; | |
481 | } | |
482 | static inline int | |
483 | kdbg_get_cpu(kd_buf *kp) | |
484 | { | |
485 | return kp->cpuid; | |
486 | } | |
487 | static inline void | |
488 | kdbg_set_timestamp(kd_buf *kp, uint64_t time) | |
489 | { | |
490 | kp->timestamp = time; | |
491 | } | |
492 | static inline uint64_t | |
493 | kdbg_get_timestamp(kd_buf *kp) | |
494 | { | |
495 | return kp->timestamp; | |
496 | } | |
497 | static inline void | |
498 | kdbg_set_timestamp_and_cpu(kd_buf *kp, uint64_t time, int cpu) | |
499 | { | |
500 | kdbg_set_timestamp(kp, time); | |
501 | kdbg_set_cpu(kp, cpu); | |
502 | } | |
503 | #endif | |
1c79356b A |
504 | |
505 | /* Debug Flags */ | |
b0d623f7 A |
506 | #define KDBG_INIT 0x001 |
507 | #define KDBG_NOWRAP 0x002 | |
508 | #define KDBG_FREERUN 0x004 | |
509 | #define KDBG_WRAPPED 0x008 | |
1c79356b | 510 | #define KDBG_USERFLAGS (KDBG_FREERUN|KDBG_NOWRAP|KDBG_INIT) |
b0d623f7 A |
511 | #define KDBG_PIDCHECK 0x010 |
512 | #define KDBG_MAPINIT 0x020 | |
513 | #define KDBG_PIDEXCLUDE 0x040 | |
514 | #define KDBG_LOCKINIT 0x080 | |
515 | #define KDBG_LP64 0x100 | |
1c79356b A |
516 | |
517 | typedef struct { | |
518 | unsigned int type; | |
519 | unsigned int value1; | |
520 | unsigned int value2; | |
521 | unsigned int value3; | |
522 | unsigned int value4; | |
523 | ||
524 | } kd_regtype; | |
525 | ||
526 | typedef struct | |
527 | { | |
b0d623f7 A |
528 | int nkdbufs; |
529 | int nolog; | |
530 | int flags; | |
531 | int nkdthreads; | |
532 | int bufid; | |
1c79356b A |
533 | } kbufinfo_t; |
534 | ||
b0d623f7 A |
535 | typedef struct { |
536 | uintptr_t thread; | |
537 | int valid; | |
538 | char command[20]; | |
1c79356b A |
539 | } kd_threadmap; |
540 | ||
541 | #define KDBG_CLASSTYPE 0x10000 | |
542 | #define KDBG_SUBCLSTYPE 0x20000 | |
543 | #define KDBG_RANGETYPE 0x40000 | |
544 | #define KDBG_TYPENONE 0x80000 | |
545 | #define KDBG_CKTYPES 0xF0000 | |
546 | ||
547 | #define KDBG_RANGECHECK 0x100000 | |
548 | #define KDBG_VALCHECK 0x200000 /* Check up to 4 individual values */ | |
549 | ||
550 | #define KDBG_BUFINIT 0x80000000 | |
551 | ||
552 | /* Control operations */ | |
553 | #define KDBG_EFLAGS 1 | |
554 | #define KDBG_DFLAGS 2 | |
555 | #define KDBG_ENABLE 3 | |
556 | #define KDBG_SETNUMBUF 4 | |
557 | #define KDBG_GETNUMBUF 5 | |
558 | #define KDBG_SETUP 6 | |
559 | #define KDBG_REMOVE 7 | |
560 | #define KDBG_SETREGCODE 8 | |
561 | #define KDBG_GETREGCODE 9 | |
562 | #define KDBG_READTRACE 10 | |
563 | #define KDBG_PIDTR 11 | |
564 | #define KDBG_THRMAP 12 | |
565 | #define KDBG_PIDEX 14 | |
566 | #define KDBG_SETRTCDEC 15 | |
9bccf70c | 567 | #define KDBG_KDGETENTROPY 16 |
1c79356b A |
568 | |
569 | /* Minimum value allowed when setting decrementer ticks */ | |
570 | #define KDBG_MINRTCDEC 2500 | |
571 | ||
9bccf70c | 572 | #endif /* __APPLE_API_PRIVATE */ |
91447636 | 573 | #endif /* PRIVATE */ |
1c79356b A |
574 | |
575 | #endif /* !BSD_SYS_KDEBUG_H */ |