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
100 #define MACH_MAKE_RUNNABLE 0x6 /* make thread runnable */
102 /* **** The Kernel Debug Sub Classes for Network (DBG_NETWORK) **** */
103 #define DBG_NETIP 1 /* Internet Protocol */
104 #define DBG_NETARP 2 /* Address Resolution Protocol */
105 #define DBG_NETUDP 3 /* User Datagram Protocol */
106 #define DBG_NETTCP 4 /* Transmission Control Protocol */
107 #define DBG_NETICMP 5 /* Internet Control Message Protocol */
108 #define DBG_NETIGMP 6 /* Internet Group Management Protocol */
109 #define DBG_NETRIP 7 /* Routing Information Protocol */
110 #define DBG_NETOSPF 8 /* Open Shortest Path First */
111 #define DBG_NETISIS 9 /* Intermediate System to Intermediate System */
112 #define DBG_NETSNMP 10 /* Simple Network Management Protocol */
113 #define DBG_NETSOCK 11 /* Socket Layer */
116 #define DBG_NETAARP 100 /* Apple ARP */
117 #define DBG_NETDDP 101 /* Datagram Delivery Protocol */
118 #define DBG_NETNBP 102 /* Name Binding Protocol */
119 #define DBG_NETZIP 103 /* Zone Information Protocol */
120 #define DBG_NETADSP 104 /* Name Binding Protocol */
121 #define DBG_NETATP 105 /* Apple Transaction Protocol */
122 #define DBG_NETASP 106 /* Apple Session Protocol */
123 #define DBG_NETAFP 107 /* Apple Filing Protocol */
124 #define DBG_NETRTMP 108 /* Routing Table Maintenance Protocol */
125 #define DBG_NETAURP 109 /* Apple Update Routing Protocol */
127 /* **** The Kernel Debug Sub Classes for IOKIT (DBG_IOKIT) **** */
128 #define DBG_IOSCSI 1 /* SCSI */
129 #define DBG_IODISK 2 /* Disk layers */
130 #define DBG_IONETWORK 3 /* Network layers */
131 #define DBG_IOKEYBOARD 4 /* Keyboard */
132 #define DBG_IOPOINTING 5 /* Pointing Devices */
133 #define DBG_IOAUDIO 6 /* Audio */
134 #define DBG_IOFLOPPY 7 /* Floppy */
135 #define DBG_IOSERIAL 8 /* Serial */
136 #define DBG_IOTTY 9 /* TTY layers */
137 #define DBG_IOWORKLOOP 10 /* Work from work loop */
138 #define DBG_IOINTES 11 /* Interrupt event source */
139 #define DBG_IOCLKES 12 /* Clock event source */
140 #define DBG_IOCMDQ 13 /* Command queue latencies */
141 #define DBG_IOMCURS 14 /* Memory Cursor */
142 #define DBG_IOMDESC 15 /* Memory Descriptors */
144 /* **** The Kernel Debug Sub Classes for Device Drivers (DBG_DRIVERS) **** */
145 #define DBG_DRVSCSI 1 /* SCSI */
146 #define DBG_DRVDISK 2 /* Disk layers */
147 #define DBG_DRVNETWORK 3 /* Network layers */
148 #define DBG_DRVKEYBOARD 4 /* Keyboard */
149 #define DBG_DRVPOINTING 5 /* Pointing Devices */
150 #define DBG_DRVAUDIO 6 /* Audio */
151 #define DBG_DRVFLOPPY 7 /* Floppy */
152 #define DBG_DRVSERIAL 8 /* Serial */
153 #define DBG_DRVSPLT 9
155 /* **** The Kernel Debug Sub Classes for the DLIL Layer (DBG_DLIL) **** */
156 #define DBG_DLIL_STATIC 1 /* Static DLIL code */
157 #define DBG_DLIL_PR_MOD 2 /* DLIL Protocol Module */
158 #define DBG_DLIL_IF_MOD 3 /* DLIL Interface Module */
159 #define DBG_DLIL_PR_FLT 4 /* DLIL Protocol Filter */
160 #define DBG_DLIL_IF_FLT 5 /* DLIL Interface FIlter */
162 /* The Kernel Debug Sub Classes for File System */
163 #define DBG_FSRW 1 /* reads and writes to the filesystem */
165 /* The Kernel Debug Sub Classes for BSD */
166 #define DBG_BSD_EXCP_SC 0x0C /* System Calls */
168 /* The Kernel Debug Sub Classes for DBG_TRACE */
169 #define DBG_TRACE_DATA 0
170 #define DBG_TRACE_STRING 1
172 /**********************************************************************/
174 #define KDBG_CODE(Class, SubClass, code) (((Class & 0xff) << 24) | ((SubClass & 0xff) << 16) | ((code & 0x3fff) << 2))
176 #define KDBG_MIGCODE(msgid) ((DBG_MIG << 24) | (((msgid) & 0x3fffff) << 2))
178 #define MACHDBG_CODE(SubClass, code) KDBG_CODE(DBG_MACH, SubClass, code)
179 #define NETDBG_CODE(SubClass, code) KDBG_CODE(DBG_NETWORK, SubClass, code)
180 #define FSDBG_CODE(SubClass, code) KDBG_CODE(DBG_FSYSTEM, SubClass, code)
181 #define BSDDBG_CODE(SubClass, code) KDBG_CODE(DBG_BSD, SubClass, code)
182 #define IOKDBG_CODE(SubClass, code) KDBG_CODE(DBG_IOKIT, SubClass, code)
183 #define DRVDBG_CODE(SubClass, code) KDBG_CODE(DBG_DRIVERS, SubClass, code)
184 #define TRACEDBG_CODE(SubClass,code) KDBG_CODE(DBG_TRACE, SubClass, code)
185 #define MISCDBG_CODE(SubClass,code) KDBG_CODE(DBG_MISC, SubClass, code)
186 #define DLILDBG_CODE(SubClass,code) KDBG_CODE(DBG_DLIL, SubClass, code)
189 * kernel_debug((KDBG_CODE(DBG_NETWORK, DNET_PROTOCOL, 51) | DBG_FUNC_START),
194 * #include <sys/kdebug.h>
196 * #define DBG_NETIPINIT NETDBG_CODE(DBG_NETIP,1)
202 * register struct protosw *pr;
205 * KERNEL_DEBUG(DBG_NETIPINIT | DBG_FUNC_START, 0,0,0,0,0)
207 * KERNEL_DEBUG(DBG_NETIPINIT, 0,0,0,0,0)
209 * KERNEL_DEBUG(DBG_NETIPINIT | DBG_FUNC_END, 0,0,0,0,0)
215 extern unsigned int kdebug_enable
;
216 #define KERNEL_DEBUG_CONSTANT(x,a,b,c,d,e) \
219 kernel_debug(x,a,b,c,d,e); \
222 #define KERNEL_DEBUG_CONSTANT1(x,a,b,c,d,e) \
225 kernel_debug1(x,a,b,c,d,e); \
228 extern void kernel_debug(unsigned int debugid
, unsigned int arg1
, unsigned int arg2
, unsigned int arg3
, unsigned int arg4
, unsigned int arg5
);
230 extern void kernel_debug1(unsigned int debugid
, unsigned int arg1
, unsigned int arg2
, unsigned int arg3
, unsigned int arg4
, unsigned int arg5
);
234 #define KERNEL_DEBUG(x,a,b,c,d,e) \
237 kernel_debug(x,a,b,c,d,e); \
240 #define KERNEL_DEBUG1(x,a,b,c,d,e) \
243 kernel_debug1(x,a,b,c,d,e); \
248 #define KERNEL_DEBUG(x,a,b,c,d,e)
249 #define KERNEL_DEBUG1(x,a,b,c,d,e)
256 #ifdef KERNEL_PRIVATE
258 * private kernel_debug definitions
262 mach_timespec_t timestamp
;
267 unsigned int arg5
; /* will hold current thread */
268 unsigned int debugid
;
271 #define KDBG_THREAD_MASK 0x7fffffff
272 #define KDBG_CPU_MASK 0x80000000
275 #define KDBG_INIT 0x1
276 #define KDBG_NOWRAP 0x2
277 #define KDBG_FREERUN 0x4
278 #define KDBG_WRAPPED 0x8
279 #define KDBG_USERFLAGS (KDBG_FREERUN|KDBG_NOWRAP|KDBG_INIT)
280 #define KDBG_PIDCHECK 0x10
281 #define KDBG_MAPINIT 0x20
282 #define KDBG_PIDEXCLUDE 0x40
308 #define KDBG_CLASSTYPE 0x10000
309 #define KDBG_SUBCLSTYPE 0x20000
310 #define KDBG_RANGETYPE 0x40000
311 #define KDBG_TYPENONE 0x80000
312 #define KDBG_CKTYPES 0xF0000
314 #define KDBG_RANGECHECK 0x100000
315 #define KDBG_VALCHECK 0x200000 /* Check up to 4 individual values */
317 #define KDBG_BUFINIT 0x80000000
319 /* Control operations */
320 #define KDBG_EFLAGS 1
321 #define KDBG_DFLAGS 2
322 #define KDBG_ENABLE 3
323 #define KDBG_SETNUMBUF 4
324 #define KDBG_GETNUMBUF 5
326 #define KDBG_REMOVE 7
327 #define KDBG_SETREGCODE 8
328 #define KDBG_GETREGCODE 9
329 #define KDBG_READTRACE 10
330 #define KDBG_PIDTR 11
331 #define KDBG_THRMAP 12
332 #define KDBG_PIDEX 14
333 #define KDBG_SETRTCDEC 15
335 /* Minimum value allowed when setting decrementer ticks */
336 #define KDBG_MINRTCDEC 2500
339 /* PCSAMPLES control operations */
340 #define PCSAMPLE_DISABLE 1
341 #define PCSAMPLE_SETNUMBUF 2
342 #define PCSAMPLE_GETNUMBUF 3
343 #define PCSAMPLE_SETUP 4
344 #define PCSAMPLE_REMOVE 5
345 #define PCSAMPLE_READBUF 6
346 #define PCSAMPLE_SETREG 7
347 #define PCSAMPLE_COMM 8
349 #define MAX_PCSAMPLES 1000000 /* Maximum number of pc's in a single buffer */
352 extern unsigned int pcsample_enable
;
359 unsigned long pcsample_beg
;
360 unsigned long pcsample_end
;
363 #endif /* KERNEL_PRIVATE */
365 #endif /* !BSD_SYS_KDEBUG_H */