home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / darwin / darwinx86.iso / usr / include / sys / kdebug.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-30  |  8.7 KB  |  258 lines

  1. /*
  2.  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  3.  *
  4.  * @APPLE_LICENSE_HEADER_START@
  5.  * 
  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.
  11.  * 
  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
  18.  * under the License.
  19.  * 
  20.  * @APPLE_LICENSE_HEADER_END@
  21.  */
  22.  
  23. /*     Copyright (c) 1997 Apple Computer, Inc.  All rights reserved. 
  24.  *
  25.  * kdebug.h -   kernel_debug definitions
  26.  *
  27.  */
  28.  
  29. #ifndef BSD_SYS_KDEBUG_H
  30. #define BSD_SYS_KDEBUG_H
  31.  
  32. #include <sys/cdefs.h>
  33. __BEGIN_DECLS
  34.  
  35. #include <mach/clock_types.h>
  36. #if    defined(KERNEL_BUILD)
  37. #include <kdebug.h>
  38. #endif /* KERNEL_BUILD */
  39.  
  40. /*
  41.  * types of faults that vm_fault handles
  42.  * and creates trace entries for
  43.  */
  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
  48.  
  49.  
  50. /* The debug code consists of the following 
  51. *
  52. * ----------------------------------------------------------------------
  53. *|              |               |                               |Func   |
  54. *| Class (8)    | SubClass (8)  |          Code (14)            |Qual(2)|
  55. * ----------------------------------------------------------------------
  56. * The class specifies the higher level 
  57. */
  58.  
  59. /* The Function qualifiers  */
  60. #define DBG_FUNC_START        1
  61. #define DBG_FUNC_END        2
  62. #define DBG_FUNC_NONE        0
  63.  
  64.  
  65. /* The Kernel Debug Classes  */
  66. #define DBG_MACH        1
  67. #define DBG_NETWORK        2    
  68. #define DBG_FSYSTEM        3
  69. #define DBG_BSD            4
  70. #define DBG_IOKIT        5
  71. #define DBG_DRIVERS        6
  72. #define DBG_TRACE               7
  73. #define DBG_DLIL            8
  74. #define DBG_MISC        20
  75. #define DBG_MIG            255
  76.  
  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 */
  92.  
  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 */
  101.  
  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 */
  114.  
  115. /* For Apple talk */
  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 */
  126.  
  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 */
  143.  
  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
  154.  
  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 */
  161.  
  162. /* The Kernel Debug Sub Classes for File System */
  163. #define DBG_FSRW      1       /* reads and writes to the filesystem */
  164.  
  165. /* The Kernel Debug Sub Classes for BSD */
  166. #define    DBG_BSD_EXCP_SC    0x0C    /* System Calls */
  167.  
  168. /* The Kernel Debug Sub Classes for DBG_TRACE */
  169. #define DBG_TRACE_DATA      0
  170. #define DBG_TRACE_STRING    1
  171.  
  172. /**********************************************************************/
  173.  
  174. #define KDBG_CODE(Class, SubClass, code) (((Class & 0xff) << 24) | ((SubClass & 0xff) << 16) | ((code & 0x3fff)  << 2))
  175.  
  176. #define KDBG_MIGCODE(msgid) ((DBG_MIG << 24) | (((msgid) & 0x3fffff)  << 2))
  177.  
  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)
  187.  
  188. /*   Usage:
  189. * kernel_debug((KDBG_CODE(DBG_NETWORK, DNET_PROTOCOL, 51) | DBG_FUNC_START), 
  190. *    offset, 0, 0, 0,0) 
  191. * For ex, 
  192. * #include <sys/kdebug.h>
  193. * #define DBG_NETIPINIT NETDBG_CODE(DBG_NETIP,1)
  194. * void
  195. * ip_init()
  196. * {
  197. *    register struct protosw *pr;
  198. *    register int i;
  199. *     
  200. *    KERNEL_DEBUG(DBG_NETIPINIT | DBG_FUNC_START, 0,0,0,0,0)
  201. *     --------
  202. *    KERNEL_DEBUG(DBG_NETIPINIT, 0,0,0,0,0)
  203. *     --------
  204. *    KERNEL_DEBUG(DBG_NETIPINIT | DBG_FUNC_END, 0,0,0,0,0)
  205. * }
  206. *
  207.  
  208. */
  209.  
  210. extern unsigned int kdebug_enable;
  211. #define KERNEL_DEBUG_CONSTANT(x,a,b,c,d,e)    \
  212. do {                    \
  213.     if (kdebug_enable)            \
  214.         kernel_debug(x,a,b,c,d,e);    \
  215. } while(0)
  216.  
  217. #define KERNEL_DEBUG_CONSTANT1(x,a,b,c,d,e)    \
  218. do {                    \
  219.     if (kdebug_enable)            \
  220.         kernel_debug1(x,a,b,c,d,e);    \
  221. } while(0)
  222.  
  223. extern void kernel_debug(unsigned int debugid, unsigned int arg1, unsigned int arg2, unsigned int arg3,  unsigned int arg4, unsigned int arg5);
  224.  
  225. extern void kernel_debug1(unsigned int debugid, unsigned int arg1, unsigned int arg2, unsigned int arg3,  unsigned int arg4, unsigned int arg5);
  226.  
  227. #if    KDEBUG
  228.  
  229. #define KERNEL_DEBUG(x,a,b,c,d,e)    \
  230. do {                    \
  231.     if (kdebug_enable)            \
  232.         kernel_debug(x,a,b,c,d,e);    \
  233. } while(0)
  234.  
  235. #define KERNEL_DEBUG1(x,a,b,c,d,e)    \
  236. do {                    \
  237.     if (kdebug_enable)            \
  238.         kernel_debug1(x,a,b,c,d,e);    \
  239. } while(0)
  240.  
  241. #else
  242.  
  243. #define KERNEL_DEBUG(x,a,b,c,d,e)
  244. #define KERNEL_DEBUG1(x,a,b,c,d,e)
  245.  
  246. #endif
  247.  
  248. __END_DECLS
  249.  
  250.  
  251.  
  252. #endif /* !BSD_SYS_KDEBUG_H */
  253.