2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 /* Copyright (c) 1997 Apple Computer, Inc. All rights reserved.
25 * kdebug.h - kernel_debug definitions
29 #ifndef BSD_SYS_KDEBUG_H
30 #define BSD_SYS_KDEBUG_H
32 #include <sys/cdefs.h>
35 #include <mach/clock_types.h>
36 #if defined(KERNEL_BUILD)
38 #endif /* KERNEL_BUILD */
41 * types of faults that vm_fault handles
42 * and creates trace entries for
44 #define DBG_ZERO_FILL_FAULT 1
45 #define DBG_PAGEIN_FAULT 2
46 #define DBG_COW_FAULT 3
47 #define DBG_CACHE_HIT_FAULT 4
50 /* The debug code consists of the following
52 * ----------------------------------------------------------------------
54 *| Class (8) | SubClass (8) | Code (14) |Qual(2)|
55 * ----------------------------------------------------------------------
56 * The class specifies the higher level
59 /* The Function qualifiers */
60 #define DBG_FUNC_START 1
61 #define DBG_FUNC_END 2
62 #define DBG_FUNC_NONE 0
65 /* The Kernel Debug Classes */
77 /* **** The Kernel Debug Sub Classes for Mach (DBG_MACH) **** */
78 #define DBG_MACH_EXCP_DFLT 0x03 /* Data Translation Fault */
79 #define DBG_MACH_EXCP_IFLT 0x04 /* Inst Translation Fault */
80 #define DBG_MACH_EXCP_INTR 0x05 /* Interrupts */
81 #define DBG_MACH_EXCP_ALNG 0x06 /* Alignment Exception */
82 #define DBG_MACH_EXCP_TRAP 0x07 /* Traps */
83 #define DBG_MACH_EXCP_FP 0x08 /* FP Unavail */
84 #define DBG_MACH_EXCP_DECI 0x09 /* Decrementer Interrupt */
85 #define DBG_MACH_EXCP_SC 0x0C /* System Calls */
86 #define DBG_MACH_EXCP_TRACE 0x0D /* Trace exception */
87 #define DBG_MACH_IHDLR 0x10 /* Interrupt Handlers */
88 #define DBG_MACH_IPC 0x20 /* Inter Process Comm */
89 #define DBG_MACH_VM 0x30 /* Virtual Memory */
90 #define DBG_MACH_SCHED 0x40 /* Scheduler */
91 #define DBG_MACH_MSGID_INVALID 0x50 /* Messages - invalid */
93 /* Codes for Scheduler (DBG_MACH_SCHED) */
94 #define MACH_SCHED 0x0 /* Scheduler */
95 #define MACH_STACK_ATTACH 0x1 /* stack_attach() */
96 #define MACH_STACK_HANDOFF 0x2 /* stack_handoff() */
97 #define MACH_CALL_CONT 0x3 /* call_continuation() */
98 #define MACH_CALLOUT 0x4 /* callouts */
99 #define MACH_STACK_DETACH 0x5
101 /* **** The Kernel Debug Sub Classes for Network (DBG_NETWORK) **** */
102 #define DBG_NETIP 1 /* Internet Protocol */
103 #define DBG_NETARP 2 /* Address Resolution Protocol */
104 #define DBG_NETUDP 3 /* User Datagram Protocol */
105 #define DBG_NETTCP 4 /* Transmission Control Protocol */
106 #define DBG_NETICMP 5 /* Internet Control Message Protocol */
107 #define DBG_NETIGMP 6 /* Internet Group Management Protocol */
108 #define DBG_NETRIP 7 /* Routing Information Protocol */
109 #define DBG_NETOSPF 8 /* Open Shortest Path First */
110 #define DBG_NETISIS 9 /* Intermediate System to Intermediate System */
111 #define DBG_NETSNMP 10 /* Simple Network Management Protocol */
112 #define DBG_NETSOCK 11 /* Socket Layer */
115 #define DBG_NETAARP 100 /* Apple ARP */
116 #define DBG_NETDDP 101 /* Datagram Delivery Protocol */
117 #define DBG_NETNBP 102 /* Name Binding Protocol */
118 #define DBG_NETZIP 103 /* Zone Information Protocol */
119 #define DBG_NETADSP 104 /* Name Binding Protocol */
120 #define DBG_NETATP 105 /* Apple Transaction Protocol */
121 #define DBG_NETASP 106 /* Apple Session Protocol */
122 #define DBG_NETAFP 107 /* Apple Filing Protocol */
123 #define DBG_NETRTMP 108 /* Routing Table Maintenance Protocol */
124 #define DBG_NETAURP 109 /* Apple Update Routing Protocol */
126 /* **** The Kernel Debug Sub Classes for IOKIT (DBG_IOKIT) **** */
127 #define DBG_IOSCSI 1 /* SCSI */
128 #define DBG_IODISK 2 /* Disk layers */
129 #define DBG_IONETWORK 3 /* Network layers */
130 #define DBG_IOKEYBOARD 4 /* Keyboard */
131 #define DBG_IOPOINTING 5 /* Pointing Devices */
132 #define DBG_IOAUDIO 6 /* Audio */
133 #define DBG_IOFLOPPY 7 /* Floppy */
134 #define DBG_IOSERIAL 8 /* Serial */
135 #define DBG_IOTTY 9 /* TTY layers */
136 #define DBG_IOWORKLOOP 10 /* Work from work loop */
137 #define DBG_IOINTES 11 /* Interrupt event source */
138 #define DBG_IOCLKES 12 /* Clock event source */
139 #define DBG_IOCMDQ 13 /* Command queue latencies */
140 #define DBG_IOMCURS 14 /* Memory Cursor */
141 #define DBG_IOMDESC 15 /* Memory Descriptors */
143 /* **** The Kernel Debug Sub Classes for Device Drivers (DBG_DRIVERS) **** */
144 #define DBG_DRVSCSI 1 /* SCSI */
145 #define DBG_DRVDISK 2 /* Disk layers */
146 #define DBG_DRVNETWORK 3 /* Network layers */
147 #define DBG_DRVKEYBOARD 4 /* Keyboard */
148 #define DBG_DRVPOINTING 5 /* Pointing Devices */
149 #define DBG_DRVAUDIO 6 /* Audio */
150 #define DBG_DRVFLOPPY 7 /* Floppy */
151 #define DBG_DRVSERIAL 8 /* Serial */
152 #define DBG_DRVSPLT 9
154 /* **** The Kernel Debug Sub Classes for the DLIL Layer (DBG_DLIL) **** */
155 #define DBG_DLIL_STATIC 1 /* Static DLIL code */
156 #define DBG_DLIL_PR_MOD 2 /* DLIL Protocol Module */
157 #define DBG_DLIL_IF_MOD 3 /* DLIL Interface Module */
158 #define DBG_DLIL_PR_FLT 4 /* DLIL Protocol Filter */
159 #define DBG_DLIL_IF_FLT 5 /* DLIL Interface FIlter */
161 /* The Kernel Debug Sub Classes for File System */
162 #define DBG_FSRW 1 /* reads and writes to the filesystem */
164 /* The Kernel Debug Sub Classes for BSD */
165 #define DBG_BSD_EXCP_SC 0x0C /* System Calls */
167 /* The Kernel Debug Sub Classes for DBG_TRACE */
168 #define DBG_TRACE_DATA 0
169 #define DBG_TRACE_STRING 1
171 /**********************************************************************/
173 #define KDBG_CODE(Class, SubClass, code) (((Class & 0xff) << 24) | ((SubClass & 0xff) << 16) | ((code & 0x3fff) << 2))
175 #define KDBG_MIGCODE(msgid) ((DBG_MIG << 24) | (((msgid) & 0x3fffff) << 2))
177 #define MACHDBG_CODE(SubClass, code) KDBG_CODE(DBG_MACH, SubClass, code)
178 #define NETDBG_CODE(SubClass, code) KDBG_CODE(DBG_NETWORK, SubClass, code)
179 #define FSDBG_CODE(SubClass, code) KDBG_CODE(DBG_FSYSTEM, SubClass, code)
180 #define BSDDBG_CODE(SubClass, code) KDBG_CODE(DBG_BSD, SubClass, code)
181 #define IOKDBG_CODE(SubClass, code) KDBG_CODE(DBG_IOKIT, SubClass, code)
182 #define DRVDBG_CODE(SubClass, code) KDBG_CODE(DBG_DRIVERS, SubClass, code)
183 #define TRACEDBG_CODE(SubClass,code) KDBG_CODE(DBG_TRACE, SubClass, code)
184 #define MISCDBG_CODE(SubClass,code) KDBG_CODE(DBG_MISC, SubClass, code)
185 #define DLILDBG_CODE(SubClass,code) KDBG_CODE(DBG_DLIL, SubClass, code)
188 * kernel_debug((KDBG_CODE(DBG_NETWORK, DNET_PROTOCOL, 51) | DBG_FUNC_START),
193 * #include <sys/kdebug.h>
195 * #define DBG_NETIPINIT NETDBG_CODE(DBG_NETIP,1)
201 * register struct protosw *pr;
204 * KERNEL_DEBUG(DBG_NETIPINIT | DBG_FUNC_START, 0,0,0,0,0)
206 * KERNEL_DEBUG(DBG_NETIPINIT, 0,0,0,0,0)
208 * KERNEL_DEBUG(DBG_NETIPINIT | DBG_FUNC_END, 0,0,0,0,0)
214 extern unsigned int kdebug_enable
;
215 #define KERNEL_DEBUG_CONSTANT(x,a,b,c,d,e) \
218 kernel_debug(x,a,b,c,d,e); \
221 extern void kernel_debug(unsigned int debugid
, unsigned int arg1
, unsigned int arg2
, unsigned int arg3
, unsigned int arg4
, unsigned int arg5
);
223 extern void kernel_debug1(unsigned int debugid
, unsigned int arg1
, unsigned int arg2
, unsigned int arg3
, unsigned int arg4
, unsigned int arg5
);
227 #define KERNEL_DEBUG(x,a,b,c,d,e) \
230 kernel_debug(x,a,b,c,d,e); \
233 #define KERNEL_DEBUG1(x,a,b,c,d,e) \
236 kernel_debug1(x,a,b,c,d,e); \
241 #define KERNEL_DEBUG(x,a,b,c,d,e)
242 #define KERNEL_DEBUG1(x,a,b,c,d,e)
249 #ifdef KERNEL_PRIVATE
251 * private kernel_debug definitions
255 mach_timespec_t timestamp
;
260 unsigned int arg5
; /* will hold current thread */
261 unsigned int debugid
;
264 #define KDBG_THREAD_MASK 0x7fffffff
265 #define KDBG_CPU_MASK 0x80000000
268 #define KDBG_INIT 0x1
269 #define KDBG_NOWRAP 0x2
270 #define KDBG_FREERUN 0x4
271 #define KDBG_WRAPPED 0x8
272 #define KDBG_USERFLAGS (KDBG_FREERUN|KDBG_NOWRAP|KDBG_INIT)
273 #define KDBG_PIDCHECK 0x10
274 #define KDBG_MAPINIT 0x20
275 #define KDBG_PIDEXCLUDE 0x40
301 #define KDBG_CLASSTYPE 0x10000
302 #define KDBG_SUBCLSTYPE 0x20000
303 #define KDBG_RANGETYPE 0x40000
304 #define KDBG_TYPENONE 0x80000
305 #define KDBG_CKTYPES 0xF0000
307 #define KDBG_RANGECHECK 0x100000
308 #define KDBG_VALCHECK 0x200000 /* Check up to 4 individual values */
310 #define KDBG_BUFINIT 0x80000000
312 /* Control operations */
313 #define KDBG_EFLAGS 1
314 #define KDBG_DFLAGS 2
315 #define KDBG_ENABLE 3
316 #define KDBG_SETNUMBUF 4
317 #define KDBG_GETNUMBUF 5
319 #define KDBG_REMOVE 7
320 #define KDBG_SETREGCODE 8
321 #define KDBG_GETREGCODE 9
322 #define KDBG_READTRACE 10
323 #define KDBG_PIDTR 11
324 #define KDBG_THRMAP 12
325 #define KDBG_PIDEX 14
326 #define KDBG_SETRTCDEC 15
328 /* Minimum value allowed when setting decrementer ticks */
329 #define KDBG_MINRTCDEC 2500
332 /* PCSAMPLES control operations */
333 #define PCSAMPLE_DISABLE 1
334 #define PCSAMPLE_SETNUMBUF 2
335 #define PCSAMPLE_GETNUMBUF 3
336 #define PCSAMPLE_SETUP 4
337 #define PCSAMPLE_REMOVE 5
338 #define PCSAMPLE_READBUF 6
339 #define PCSAMPLE_SETREG 7
340 #define PCSAMPLE_COMM 8
342 #define MAX_PCSAMPLES 1000000 /* Maximum number of pc's in a single buffer */
345 extern unsigned int pcsample_enable
;
352 unsigned long pcsample_beg
;
353 unsigned long pcsample_end
;
356 #endif /* KERNEL_PRIVATE */
358 #endif /* !BSD_SYS_KDEBUG_H */