Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

261 lines
9.4 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1993 - 1999
  3. Module Name:
  4. debug.h
  5. Abstract:
  6. This module contains debug macros and goodies.
  7. Author:
  8. Robbie Harris (Hewlett-Packard) 1-July-1998
  9. Environment:
  10. Kernel mode
  11. Revision History :
  12. --*/
  13. #define DDPnP1(_x_)
  14. #define DD(_x_)
  15. // #define DDPnP1(_x_) DbgPrint _x_
  16. #ifndef _DEBUG_
  17. #define _DEBUG_
  18. #if (1 == DVRH_DELAY_THEORY)
  19. extern int DVRH_wt;
  20. extern int DVRH_wb;
  21. extern int DVRH_rt;
  22. extern int DVRH_rb;
  23. #endif
  24. typedef struct tagSTRUCTUREOFFSETSTABLE {
  25. char * pszField;
  26. unsigned long dwOffset;
  27. } STRUCTUREOFFSETSTABLE, *PSTRUCTUREOFFSETSTABLE;
  28. #if DBG
  29. // PAR_TEST_HARNESS is used to enable a special mode to bucket
  30. // writes and siphon reads to a test harness. This functionality
  31. // is for debugging purposes only.
  32. // 0 - off
  33. // 1 - on
  34. #define PAR_TEST_HARNESS 0
  35. // use with ParDebugLevel and ParDump(...)
  36. #define PARALWAYS ((ULONG)0xffffffff) // Set all the bits. So this will always show
  37. #define PARERRORS ((ULONG)0x00000001)
  38. #define PARUNLOAD ((ULONG)0x00000002)
  39. #define PARINITDEV ((ULONG)0x00000004)
  40. #define PARIRPPATH ((ULONG)0x00000008)
  41. #define PARSTARTER ((ULONG)0x00000010)
  42. #define PAROPENCLOSE ((ULONG)0x00000020)
  43. #define PARREMLOCK ((ULONG)0x00000040)
  44. #define PARTHREAD ((ULONG)0x00000080)
  45. #define PARIEEE ((ULONG)0x00000100)
  46. #define PAREXIT ((ULONG)0x00000200)
  47. #define PARENTRY ((ULONG)0x00000400)
  48. #define PARENTRY_EXIT (PARENTRY | PAREXIT)
  49. #define PARINFO ((ULONG)0x00000800)
  50. #define PARECPTRACE ((ULONG)0x00001000)
  51. #define PARALLOCFREEPORT ((ULONG)0x00002000)
  52. #define PARSELECTDESELECT ((ULONG)0x00004000)
  53. #define PARDOT3DL ((ULONG)0x00008000)
  54. #define PARPNP1 ((ULONG)0x00010000) // device object create/kill - major events
  55. #define PARPNP2 ((ULONG)0x00020000) // device object create/kill - verbose
  56. #define PARPNP4 ((ULONG)0x00040000)
  57. #define PARPNP8 ((ULONG)0x00080000)
  58. #define PARLGZIP ((ULONG)0x00100000) // Legacy Zip drive
  59. #define PARRESCAN ((ULONG)0x00200000) // bus rescan - QUERY_DEVICE_RELATIONS/BusRelations
  60. #define PARIOCTL1 ((ULONG)0x00400000) // IOCTL related info
  61. #define PARIOCTL2 ((ULONG)0x00800000) // IOCTL related info
  62. #define PARDUMP_PNP_PARPORT ((ULONG)0x01000000) // ParPort PnP interface and device notification callback activity
  63. #define PARDUMP_PNP_DL ((ULONG)0x02000000) // 1284.3 DL PnP
  64. #define PARREG ((ULONG)0x04000000) // registry operations
  65. #define PARPOWER ((ULONG)0x08000000)
  66. #define PARDUMP_SILENT ((ULONG)0x00000000)
  67. #define PARDUMP_VERBOSE ((ULONG)0x20000000)
  68. #define PARDUMP_VERBOSE_VERY ((ULONG)0x40000000)
  69. #define PARDUMP_VERBOSE_MAX ((ULONG)0xFFFFFFFF)
  70. // use with ParBreakOn
  71. #define PAR_BREAK_ON_NOTHING ((ULONG)0x00000000)
  72. #define PAR_BREAK_ON_DRIVER_ENTRY ((ULONG)0x00000001)
  73. #define PAR_BREAK_ON_UNLOAD ((ULONG)0x00000002)
  74. #define PAR_BREAK_ON_ADD_DEVICE ((ULONG)0x00000004)
  75. #define PAR_BREAK_ON_DEV_1 ((ULONG)0x00000100)
  76. extern ULONG ParDebugLevel; // How verbose do we want parallel.sys to be with DbgPrint messages?
  77. extern ULONG ParBreakOn; // What conditions do we want to break on?
  78. extern ULONG ParUseAsserts; // 0 == disable ASSERTs
  79. #endif // DBG
  80. #if DBG
  81. // DVRH_SHOW_DEBUG_SPEW 0 - Debug Spew is off
  82. // 1 - Debug Spew is on
  83. // - Note: The timer spew is not controlled by this
  84. // Look at DVRH_SHOW_SHALLOW_TIMER and
  85. // DVRH_SHOW_DEEP_TIMER.
  86. #define DVRH_SHOW_DEBUG_SPEW 1
  87. // DVRH_SHOW_SHALLOW_TIMER 0 - Entry Timers off
  88. // 1 - Entry Timers on
  89. #define DVRH_SHOW_SHALLOW_TIMER 0
  90. // DVRH_SHOW_DEEP_TIMER 0 - Full Timer off
  91. // 1 - Full Timer on
  92. #define DVRH_SHOW_DEEP_TIMER 0
  93. // DVRH_SHOW_BYTE_LOG 0 - Byte Log off
  94. // 1 - Byte Log on
  95. #define DVRH_SHOW_BYTE_LOG 0
  96. // DVRH_PAR_LOGFILE is used to allow for debug logging to a file
  97. // This functionality is for debugging purposes only.
  98. // 0 - off
  99. // 1 - on
  100. #define DVRH_PAR_LOGFILE 0
  101. // DVRH_BUS_RESET_ON_ERROR
  102. // This functionality is for debugging purposes only.
  103. // Holds a bus reset for 100us when a handshaking error
  104. // is discovered.
  105. // 0 - off
  106. // 1 - on
  107. #define DVRH_BUS_RESET_ON_ERROR 0
  108. #else
  109. #define DVRH_SHOW_DEBUG_SPEW 0
  110. #define DVRH_SHOW_SHALLOW_TIMER 0
  111. #define DVRH_SHOW_DEEP_TIMER 0
  112. #define DVRH_SHOW_BYTE_LOG 0
  113. #define DVRH_PAR_LOGFILE 0
  114. #define DVRH_BUS_RESET_ON_ERROR 0
  115. #endif
  116. #if (1 == DVRH_PAR_LOGFILE)
  117. #define DEFAULT_LOG_FILE_NAME L"\\??\\C:\\tmp\\parallel.log"
  118. BOOLEAN DVRH_LogMessage(PCHAR szFormat, ...);
  119. // BOOLEAN DVRH_LogByteData(BOOLEAN READ,PCHAR szBuff,ULONG dwTransferred);
  120. #if 1
  121. #define DVRH_DbgPrint DVRH_LogMessage
  122. #define DDF DVRH_LogMessage
  123. #else
  124. // This is put in so I can pinpoint a single debug message
  125. #define DVRH_DbgPrint
  126. // #define DVRH_ShallowDbgMsg DVRH_LogMessage
  127. #define DVRH_ShallowDbgMsg
  128. #endif
  129. #else
  130. #define DVRH_DbgPrint DbgPrint
  131. #define DVRH_ShallowDbgMsg
  132. #define DDF DbgPrint
  133. #endif
  134. #if (DBG && 1 == DVRH_SHOW_DEBUG_SPEW)
  135. #define ParAssert( ASSERTION ) if(ParUseAsserts) ASSERT( ASSERTION )
  136. #define ParDump(LEVEL,STRING) \
  137. if (ParDebugLevel & (LEVEL)) DVRH_DbgPrint STRING
  138. #define ParDump2(LEVEL,STRING) \
  139. if (ParDebugLevel & (LEVEL)) { \
  140. DVRH_DbgPrint("PARALLEL: "); \
  141. DVRH_DbgPrint STRING; \
  142. }
  143. // display if we want PnP info
  144. #define ParDumpP(STRING) \
  145. if (ParDebugLevel & PARPNP1) { \
  146. DVRH_DbgPrint("PARALLEL: "); \
  147. DVRH_DbgPrint STRING; \
  148. }
  149. // display if we want Register info
  150. #define ParDumpReg(LEVEL,STRING,ECRADDR,DCRADDR,DSRADDR) \
  151. if (ParDebugLevel & (LEVEL) ) { \
  152. DVRH_DbgPrint("PARALLEL: "); \
  153. DVRH_DbgPrint STRING; \
  154. DVRH_DbgPrint(" dsr[%02x] dcr[%02x] ecr[%02x]\r\n", \
  155. (int)READ_PORT_UCHAR(DSRADDR), \
  156. (int)READ_PORT_UCHAR(DCRADDR), \
  157. (int)READ_PORT_UCHAR(ECRADDR)); \
  158. }
  159. // verbose - display if ANY debug flag is set
  160. #define ParDumpV(STRING) \
  161. if (ParDebugLevel & PARDUMP_VERBOSE_MAX) { \
  162. DVRH_DbgPrint("PARALLEL: "); \
  163. DVRH_DbgPrint STRING; \
  164. }
  165. #define ParBreak(BREAK_CONDITION,STRING) \
  166. if (ParBreakOn & (BREAK_CONDITION)) { \
  167. DVRH_DbgPrint("PARALLEL: Break: "); \
  168. DVRH_DbgPrint STRING; \
  169. DbgBreakPoint(); \
  170. }
  171. #endif // (DBG && 1 == DVRH_SHOW_DEBUG_SPEW)
  172. #if (DBG && 1 == DVRH_SHOW_SHALLOW_TIMER)
  173. #define ParTimerMainCheck(x) { \
  174. LARGE_INTEGER myTickCount; \
  175. KeQueryTickCount(&myTickCount); \
  176. DVRH_DbgPrint("Parallel:Timer: %d,%d,%I64d, ", \
  177. PsGetCurrentProcessId(), \
  178. PsGetCurrentThreadId(), \
  179. myTickCount); \
  180. DVRH_DbgPrint x; \
  181. }
  182. #endif
  183. #if (DBG && 1 == DVRH_SHOW_DEEP_TIMER)
  184. #define ParTimerCheck(x) { \
  185. LARGE_INTEGER myTickCount; \
  186. KeQueryTickCount(&myTickCount); \
  187. DVRH_DbgPrint("Parallel:Timer: %d,%d,%I64d, ", \
  188. PsGetCurrentProcessId(), \
  189. PsGetCurrentThreadId(), \
  190. myTickCount); \
  191. DVRH_DbgPrint x; \
  192. }
  193. #endif
  194. #if (0 == DVRH_SHOW_DEBUG_SPEW)
  195. #define ParAssert( X ) //lint !e760
  196. #define ParDump(LEVEL,STRING) //lint !e760
  197. #define ParDump2(LEVEL,STRING) //lint !e760
  198. #define ParDumpP(STRING) //lint !e760
  199. #define ParDumpReg(LEVEL,STRING,ECRADDR,DCRADDR,DSRADDR) //lint !e760
  200. #define ParDumpV(STRING) //lint !e760
  201. #define ParBreak(LEVEL,STRING) //lint !e760
  202. #endif // DBG
  203. #if (0 == DVRH_SHOW_SHALLOW_TIMER)
  204. #define ParTimerMainCheck(x) //lint !e760
  205. #endif // DBG
  206. #if (0 == DVRH_SHOW_DEEP_TIMER)
  207. #define ParTimerCheck(x) //lint !e760
  208. #endif // DBG
  209. #endif