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