]>
git.saurik.com Git - apple/xnu.git/blob - bsd/sys/kdebug.h
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 /* Copyright (c) 1997 Apple Computer, Inc. All rights reserved.
31 * kdebug.h - kernel_debug definitions
35 #ifndef BSD_SYS_KDEBUG_H
36 #define BSD_SYS_KDEBUG_H
38 #include <sys/appleapiopts.h>
39 #include <sys/cdefs.h>
42 #ifdef __APPLE_API_UNSTABLE
44 #include <mach/clock_types.h>
46 #if defined(KERNEL_BUILD)
48 #endif /* KERNEL_BUILD */
51 * types of faults that vm_fault handles
52 * and creates trace entries for
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
60 /* The debug code consists of the following
62 * ----------------------------------------------------------------------
64 *| Class (8) | SubClass (8) | Code (14) |Qual(2)|
65 * ----------------------------------------------------------------------
66 * The class specifies the higher level
69 /* The Function qualifiers */
70 #define DBG_FUNC_START 1
71 #define DBG_FUNC_END 2
72 #define DBG_FUNC_NONE 0
75 /* The Kernel Debug Classes */
84 #define DBG_SECURITY 9
91 /* **** The Kernel Debug Sub Classes for Mach (DBG_MACH) **** */
92 #define DBG_MACH_EXCP_DFLT 0x03 /* Data Translation Fault */
93 #define DBG_MACH_EXCP_IFLT 0x04 /* Inst Translation Fault */
94 #define DBG_MACH_EXCP_INTR 0x05 /* Interrupts */
95 #define DBG_MACH_EXCP_ALNG 0x06 /* Alignment Exception */
96 #define DBG_MACH_EXCP_TRAP 0x07 /* Traps */
97 #define DBG_MACH_EXCP_FP 0x08 /* FP Unavail */
98 #define DBG_MACH_EXCP_DECI 0x09 /* Decrementer Interrupt */
99 #define DBG_MACH_EXCP_SC 0x0C /* System Calls */
100 #define DBG_MACH_EXCP_TRACE 0x0D /* Trace exception */
101 #define DBG_MACH_EXCP_EMUL 0x0E /* Instruction emulated */
102 #define DBG_MACH_IHDLR 0x10 /* Interrupt Handlers */
103 #define DBG_MACH_IPC 0x20 /* Inter Process Comm */
104 #define DBG_MACH_VM 0x30 /* Virtual Memory */
105 #define DBG_MACH_SCHED 0x40 /* Scheduler */
106 #define DBG_MACH_MSGID_INVALID 0x50 /* Messages - invalid */
107 #define DBG_MACH_LOCKS 0x60 /* new lock APIs */
109 /* Codes for Scheduler (DBG_MACH_SCHED) */
110 #define MACH_SCHED 0x0 /* Scheduler */
111 #define MACH_STACK_ATTACH 0x1 /* stack_attach() */
112 #define MACH_STACK_HANDOFF 0x2 /* stack_handoff() */
113 #define MACH_CALL_CONT 0x3 /* call_continuation() */
114 #define MACH_CALLOUT 0x4 /* callouts */
115 #define MACH_STACK_DETACH 0x5
116 #define MACH_MAKE_RUNNABLE 0x6 /* make thread runnable */
117 #define MACH_PROMOTE 0x7 /* promoted due to resource */
118 #define MACH_DEMOTE 0x8 /* promotion undone */
119 #define MACH_PREBLOCK_MUTEX 0x9 /* preblocking on mutex */
121 /* **** The Kernel Debug Sub Classes for Network (DBG_NETWORK) **** */
122 #define DBG_NETIP 1 /* Internet Protocol */
123 #define DBG_NETARP 2 /* Address Resolution Protocol */
124 #define DBG_NETUDP 3 /* User Datagram Protocol */
125 #define DBG_NETTCP 4 /* Transmission Control Protocol */
126 #define DBG_NETICMP 5 /* Internet Control Message Protocol */
127 #define DBG_NETIGMP 6 /* Internet Group Management Protocol */
128 #define DBG_NETRIP 7 /* Routing Information Protocol */
129 #define DBG_NETOSPF 8 /* Open Shortest Path First */
130 #define DBG_NETISIS 9 /* Intermediate System to Intermediate System */
131 #define DBG_NETSNMP 10 /* Simple Network Management Protocol */
132 #define DBG_NETSOCK 11 /* Socket Layer */
135 #define DBG_NETAARP 100 /* Apple ARP */
136 #define DBG_NETDDP 101 /* Datagram Delivery Protocol */
137 #define DBG_NETNBP 102 /* Name Binding Protocol */
138 #define DBG_NETZIP 103 /* Zone Information Protocol */
139 #define DBG_NETADSP 104 /* Name Binding Protocol */
140 #define DBG_NETATP 105 /* Apple Transaction Protocol */
141 #define DBG_NETASP 106 /* Apple Session Protocol */
142 #define DBG_NETAFP 107 /* Apple Filing Protocol */
143 #define DBG_NETRTMP 108 /* Routing Table Maintenance Protocol */
144 #define DBG_NETAURP 109 /* Apple Update Routing Protocol */
145 #define DBG_NETIPSEC 128 /* IPsec Protocol */
147 /* **** The Kernel Debug Sub Classes for IOKIT (DBG_IOKIT) **** */
148 #define DBG_IOSCSI 1 /* SCSI */
149 #define DBG_IODISK 2 /* Disk layers */
150 #define DBG_IONETWORK 3 /* Network layers */
151 #define DBG_IOKEYBOARD 4 /* Keyboard */
152 #define DBG_IOPOINTING 5 /* Pointing Devices */
153 #define DBG_IOAUDIO 6 /* Audio */
154 #define DBG_IOFLOPPY 7 /* Floppy */
155 #define DBG_IOSERIAL 8 /* Serial */
156 #define DBG_IOTTY 9 /* TTY layers */
157 #define DBG_IOWORKLOOP 10 /* Work from work loop */
158 #define DBG_IOINTES 11 /* Interrupt event source */
159 #define DBG_IOCLKES 12 /* Clock event source */
160 #define DBG_IOCMDQ 13 /* Command queue latencies */
161 #define DBG_IOMCURS 14 /* Memory Cursor */
162 #define DBG_IOMDESC 15 /* Memory Descriptors */
163 #define DBG_IOPOWER 16 /* Power Managerment */
165 /* **** The Kernel Debug Sub Classes for Device Drivers (DBG_DRIVERS) **** */
166 #define DBG_DRVSCSI 1 /* SCSI */
167 #define DBG_DRVDISK 2 /* Disk layers */
168 #define DBG_DRVNETWORK 3 /* Network layers */
169 #define DBG_DRVKEYBOARD 4 /* Keyboard */
170 #define DBG_DRVPOINTING 5 /* Pointing Devices */
171 #define DBG_DRVAUDIO 6 /* Audio */
172 #define DBG_DRVFLOPPY 7 /* Floppy */
173 #define DBG_DRVSERIAL 8 /* Serial */
174 #define DBG_DRVSPLT 9
176 /* **** The Kernel Debug Sub Classes for the DLIL Layer (DBG_DLIL) **** */
177 #define DBG_DLIL_STATIC 1 /* Static DLIL code */
178 #define DBG_DLIL_PR_MOD 2 /* DLIL Protocol Module */
179 #define DBG_DLIL_IF_MOD 3 /* DLIL Interface Module */
180 #define DBG_DLIL_PR_FLT 4 /* DLIL Protocol Filter */
181 #define DBG_DLIL_IF_FLT 5 /* DLIL Interface FIlter */
183 /* The Kernel Debug Sub Classes for File System */
184 #define DBG_FSRW 1 /* reads and writes to the filesystem */
185 #define DBG_DKRW 2 /* reads and writes to the disk */
186 #define DBG_FSVN 3 /* vnode operations (inc. locking/unlocking) */
187 #define DBG_FSLOOOKUP 4 /* namei and other lookup-related operations */
189 /* The Kernel Debug Sub Classes for BSD */
190 #define DBG_BSD_EXCP_SC 0x0C /* System Calls */
191 #define DBG_BSD_AIO 0x0D /* aio (POSIX async IO) */
192 #define DBG_BSD_SC_EXTENDED_INFO 0x0E /* System Calls, extended info */
194 /* The Kernel Debug Sub Classes for DBG_TRACE */
195 #define DBG_TRACE_DATA 0
196 #define DBG_TRACE_STRING 1
198 /* The Kernel Debug Sub Classes for DBG_DYLD */
199 #define DBG_DYLD_STRING 5
201 /* The Kernel Debug modifiers for the DBG_DKRW sub class */
202 #define DKIO_DONE 0x01
203 #define DKIO_READ 0x02
204 #define DKIO_ASYNC 0x04
205 #define DKIO_META 0x08
206 #define DKIO_PAGING 0x10
208 /**********************************************************************/
210 #define KDBG_CODE(Class, SubClass, code) (((Class & 0xff) << 24) | ((SubClass & 0xff) << 16) | ((code & 0x3fff) << 2))
212 #define KDBG_MIGCODE(msgid) ((DBG_MIG << 24) | (((msgid) & 0x3fffff) << 2))
214 #define MACHDBG_CODE(SubClass, code) KDBG_CODE(DBG_MACH, SubClass, code)
215 #define NETDBG_CODE(SubClass, code) KDBG_CODE(DBG_NETWORK, SubClass, code)
216 #define FSDBG_CODE(SubClass, code) KDBG_CODE(DBG_FSYSTEM, SubClass, code)
217 #define BSDDBG_CODE(SubClass, code) KDBG_CODE(DBG_BSD, SubClass, code)
218 #define IOKDBG_CODE(SubClass, code) KDBG_CODE(DBG_IOKIT, SubClass, code)
219 #define DRVDBG_CODE(SubClass, code) KDBG_CODE(DBG_DRIVERS, SubClass, code)
220 #define TRACEDBG_CODE(SubClass,code) KDBG_CODE(DBG_TRACE, SubClass, code)
221 #define MISCDBG_CODE(SubClass,code) KDBG_CODE(DBG_MISC, SubClass, code)
222 #define DLILDBG_CODE(SubClass,code) KDBG_CODE(DBG_DLIL, SubClass, code)
223 #define SECURITYDBG_CODE(SubClass,code) KDBG_CODE(DBG_SECURITY, SubClass, code)
224 #define DYLDDBG_CODE(SubClass,code) KDBG_CODE(DBG_DYLD, SubClass, code)
225 #define QTDBG_CODE(SubClass,code) KDBG_CODE(DBG_QT, SubClass, code)
226 #define APPSDBG_CODE(SubClass,code) KDBG_CODE(DBG_APPS, SubClass, code)
229 * kernel_debug((KDBG_CODE(DBG_NETWORK, DNET_PROTOCOL, 51) | DBG_FUNC_START),
234 * #include <sys/kdebug.h>
236 * #define DBG_NETIPINIT NETDBG_CODE(DBG_NETIP,1)
242 * register struct protosw *pr;
245 * KERNEL_DEBUG(DBG_NETIPINIT | DBG_FUNC_START, 0,0,0,0,0)
247 * KERNEL_DEBUG(DBG_NETIPINIT, 0,0,0,0,0)
249 * KERNEL_DEBUG(DBG_NETIPINIT | DBG_FUNC_END, 0,0,0,0,0)
255 extern unsigned int kdebug_enable
;
256 #define KDEBUG_ENABLE_TRACE 0x1
257 #define KDEBUG_ENABLE_ENTROPY 0x2
258 #define KDEBUG_ENABLE_CHUD 0x4
260 #define KERNEL_DEBUG_CONSTANT(x,a,b,c,d,e) \
263 kernel_debug(x,a,b,c,d,e); \
266 #define KERNEL_DEBUG_CONSTANT1(x,a,b,c,d,e) \
269 kernel_debug1(x,a,b,c,d,e); \
272 extern void kernel_debug(unsigned int debugid
, unsigned int arg1
, unsigned int arg2
, unsigned int arg3
, unsigned int arg4
, unsigned int arg5
);
274 extern void kernel_debug1(unsigned int debugid
, unsigned int arg1
, unsigned int arg2
, unsigned int arg3
, unsigned int arg4
, unsigned int arg5
);
277 * LP64todo - for some reason these are problematic
279 extern void kdbg_trace_data(struct proc
*proc
, long *arg_pid
);
281 extern void kdbg_trace_string(struct proc
*proc
, long *arg1
, long *arg2
, long *arg3
, long *arg4
);
285 #define KERNEL_DEBUG(x,a,b,c,d,e) \
288 kernel_debug(x,a,b,c,d,e); \
291 #define KERNEL_DEBUG1(x,a,b,c,d,e) \
294 kernel_debug1(x,a,b,c,d,e); \
297 #define __kdebug_only
301 #define KERNEL_DEBUG(x,a,b,c,d,e)
302 #define KERNEL_DEBUG1(x,a,b,c,d,e)
304 #define __kdebug_only __unused
307 #endif /* __APPLE_API_UNSTABLE */
312 #ifdef __APPLE_API_PRIVATE
314 * private kernel_debug definitions
323 unsigned int arg5
; /* will hold current thread */
324 unsigned int debugid
;
327 #define KDBG_TIMESTAMP_MASK 0x00ffffffffffffffULL
328 #define KDBG_CPU_MASK 0x0f00000000000000ULL
329 #define KDBG_CPU_SHIFT 56
332 #define KDBG_INIT 0x1
333 #define KDBG_NOWRAP 0x2
334 #define KDBG_FREERUN 0x4
335 #define KDBG_WRAPPED 0x8
336 #define KDBG_USERFLAGS (KDBG_FREERUN|KDBG_NOWRAP|KDBG_INIT)
337 #define KDBG_PIDCHECK 0x10
338 #define KDBG_MAPINIT 0x20
339 #define KDBG_PIDEXCLUDE 0x40
340 #define KDBG_LOCKINIT 0x80
367 #define KDBG_CLASSTYPE 0x10000
368 #define KDBG_SUBCLSTYPE 0x20000
369 #define KDBG_RANGETYPE 0x40000
370 #define KDBG_TYPENONE 0x80000
371 #define KDBG_CKTYPES 0xF0000
373 #define KDBG_RANGECHECK 0x100000
374 #define KDBG_VALCHECK 0x200000 /* Check up to 4 individual values */
376 #define KDBG_BUFINIT 0x80000000
378 /* Control operations */
379 #define KDBG_EFLAGS 1
380 #define KDBG_DFLAGS 2
381 #define KDBG_ENABLE 3
382 #define KDBG_SETNUMBUF 4
383 #define KDBG_GETNUMBUF 5
385 #define KDBG_REMOVE 7
386 #define KDBG_SETREGCODE 8
387 #define KDBG_GETREGCODE 9
388 #define KDBG_READTRACE 10
389 #define KDBG_PIDTR 11
390 #define KDBG_THRMAP 12
391 #define KDBG_PIDEX 14
392 #define KDBG_SETRTCDEC 15
393 #define KDBG_KDGETENTROPY 16
395 /* Minimum value allowed when setting decrementer ticks */
396 #define KDBG_MINRTCDEC 2500
399 /* PCSAMPLES control operations */
400 #define PCSAMPLE_DISABLE 1
401 #define PCSAMPLE_SETNUMBUF 2
402 #define PCSAMPLE_GETNUMBUF 3
403 #define PCSAMPLE_SETUP 4
404 #define PCSAMPLE_REMOVE 5
405 #define PCSAMPLE_READBUF 6
406 #define PCSAMPLE_SETREG 7
407 #define PCSAMPLE_COMM 8
409 #define MAX_PCSAMPLES 1000000 /* Maximum number of pc's in a single buffer */
412 extern unsigned int pcsample_enable
;
419 unsigned int pcsample_beg
;
420 unsigned int pcsample_end
;
423 #endif /* __APPLE_API_PRIVATE */
426 #endif /* !BSD_SYS_KDEBUG_H */