Leaked source code of windows server 2003
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.

273 lines
7.5 KiB

  1. /**************************************************************************************************************************
  2. * DEBUG.H SigmaTel STIR4200 debug header file
  3. **************************************************************************************************************************
  4. * (C) Unpublished Copyright of Sigmatel, Inc. All Rights Reserved.
  5. *
  6. *
  7. * Created: 04/06/2000
  8. * Version 0.9
  9. * Edited: 04/27/2000
  10. * Version 0.92
  11. *
  12. *
  13. **************************************************************************************************************************/
  14. #ifndef _DEBUG_H_
  15. #define _DEBUG_H_
  16. #if DBG
  17. #define DEBUG
  18. #define DEBUG_IRUSB
  19. //Begin, Debug code from BulkUsb
  20. #ifndef DBGSTR_PREFIX
  21. #define DBGSTR_PREFIX "StIrUsb: "
  22. #endif
  23. #define DPRINT DbgPrint
  24. #define TRAP() DbgBreakPoint();
  25. #define IRUSB_DBGOUTSIZE 512
  26. typedef struct _IRUSB_DBGDATA
  27. {
  28. // mirrors device extension pending io count
  29. ULONG PendingIoCount;
  30. // count of pipe errors detected during the life of this device instance
  31. ULONG PipeErrorCount;
  32. // count of pipe resets performed during the life of this device instance
  33. ULONG ResetPipeCount;
  34. } IRUSB_DBGDATA, *PIRUSB_DBGDATA;
  35. //these declared in debug 'c' file
  36. extern PIRUSB_DBGDATA gpDbg;
  37. static const PCHAR szIrpMajFuncDesc[] =
  38. { // note this depends on corresponding values to the indexes in wdm.h
  39. "IRP_MJ_CREATE",
  40. "IRP_MJ_CREATE_NAMED_PIPE",
  41. "IRP_MJ_CLOSE",
  42. "IRP_MJ_READ",
  43. "IRP_MJ_WRITE",
  44. "IRP_MJ_QUERY_INFORMATION",
  45. "IRP_MJ_SET_INFORMATION",
  46. "IRP_MJ_QUERY_EA",
  47. "IRP_MJ_SET_EA",
  48. "IRP_MJ_FLUSH_BUFFERS",
  49. "IRP_MJ_QUERY_VOLUME_INFORMATION",
  50. "IRP_MJ_SET_VOLUME_INFORMATION",
  51. "IRP_MJ_DIRECTORY_CONTROL",
  52. "IRP_MJ_FILE_SYSTEM_CONTROL",
  53. "IRP_MJ_DEVICE_CONTROL",
  54. "IRP_MJ_INTERNAL_DEVICE_CONTROL",
  55. "IRP_MJ_SHUTDOWN",
  56. "IRP_MJ_LOCK_CONTROL",
  57. "IRP_MJ_CLEANUP",
  58. "IRP_MJ_CREATE_MAILSLOT",
  59. "IRP_MJ_QUERY_SECURITY",
  60. "IRP_MJ_SET_SECURITY",
  61. "IRP_MJ_POWER",
  62. "IRP_MJ_SYSTEM_CONTROL",
  63. "IRP_MJ_DEVICE_CHANGE",
  64. "IRP_MJ_QUERY_QUOTA",
  65. "IRP_MJ_SET_QUOTA",
  66. "IRP_MJ_PNP"
  67. };
  68. //IRP_MJ_MAXIMUM_FUNCTION defined in wdm.h
  69. static const PCHAR szPnpMnFuncDesc[] =
  70. { // note this depends on corresponding values to the indexes in wdm.h
  71. "IRP_MN_START_DEVICE",
  72. "IRP_MN_QUERY_REMOVE_DEVICE",
  73. "IRP_MN_REMOVE_DEVICE",
  74. "IRP_MN_CANCEL_REMOVE_DEVICE",
  75. "IRP_MN_STOP_DEVICE",
  76. "IRP_MN_QUERY_STOP_DEVICE",
  77. "IRP_MN_CANCEL_STOP_DEVICE",
  78. "IRP_MN_QUERY_DEVICE_RELATIONS",
  79. "IRP_MN_QUERY_INTERFACE",
  80. "IRP_MN_QUERY_CAPABILITIES",
  81. "IRP_MN_QUERY_RESOURCES",
  82. "IRP_MN_QUERY_RESOURCE_REQUIREMENTS",
  83. "IRP_MN_QUERY_DEVICE_TEXT",
  84. "IRP_MN_FILTER_RESOURCE_REQUIREMENTS",
  85. "IRP_MN_READ_CONFIG",
  86. "IRP_MN_WRITE_CONFIG",
  87. "IRP_MN_EJECT",
  88. "IRP_MN_SET_LOCK",
  89. "IRP_MN_QUERY_ID",
  90. "IRP_MN_QUERY_PNP_DEVICE_STATE",
  91. "IRP_MN_QUERY_BUS_INFORMATION",
  92. "IRP_MN_DEVICE_USAGE_NOTIFICATION",
  93. "IRP_MN_SURPRISE_REMOVAL"
  94. };
  95. #define IRP_PNP_MN_FUNCMAX IRP_MN_SURPRISE_REMOVAL
  96. static const PCHAR szSystemPowerState[] =
  97. {
  98. "PowerSystemUnspecified",
  99. "PowerSystemWorking",
  100. "PowerSystemSleeping1",
  101. "PowerSystemSleeping2",
  102. "PowerSystemSleeping3",
  103. "PowerSystemHibernate",
  104. "PowerSystemShutdown",
  105. "PowerSystemMaximum"
  106. };
  107. static const PCHAR szDevicePowerState[] =
  108. {
  109. "PowerDeviceUnspecified",
  110. "PowerDeviceD0",
  111. "PowerDeviceD1",
  112. "PowerDeviceD2",
  113. "PowerDeviceD3",
  114. "PowerDeviceMaximum"
  115. };
  116. VOID
  117. DBG_PrintBuf(
  118. IN PUCHAR bufptr,
  119. int buflen
  120. );
  121. #define IRUSB_ASSERT( cond ) ASSERT( cond )
  122. #define IRUSB_StringForDevState( devState ) szDevicePowerState[ devState ]
  123. #define IRUSB_StringForSysState( sysState ) szSystemPowerState[ sysState ]
  124. #define IRUSB_StringForPnpMnFunc( mnfunc ) szPnpMnFuncDesc[ mnfunc ]
  125. #define IRUSB_StringForIrpMjFunc( mjfunc ) szIrpMajFuncDesc[ mjfunc ]
  126. #else // if not DBG
  127. //
  128. // dummy definitions that go away in the retail build
  129. //
  130. #define IRUSB_ASSERT( cond )
  131. #define IRUSB_StringForDevState( devState )
  132. #define IRUSB_StringForSysState( sysState )
  133. #define IRUSB_StringForPnpMnFunc( mnfunc )
  134. #define IRUSB_StringForIrpMjFunc( mjfunc )
  135. #endif
  136. // End, debug code from Bul kUsb
  137. #ifdef DEBUG
  138. #define DEBUGCOND( ilev, cond, _x_) \
  139. if( (ilev & DbgSettings) && ( cond )) { \
  140. DbgPrint( DBGSTR_PREFIX ); \
  141. DbgPrint _x_ ; \
  142. }
  143. #define DEBUGONCE( ilev, _x_ ) \
  144. { \
  145. static BOOLEAN didOnce = FALSE; \
  146. if ( !didOnce ) { \
  147. didOnce = TRUE; \
  148. DEBUGMSG( ilev, _x_ ); \
  149. } \
  150. }
  151. #define DEBUGONCECOND( ilev, cond, _x_ ) \
  152. { \
  153. static BOOLEAN didOnce = FALSE; \
  154. if (( !didOnce ) && (cond)) { \
  155. didOnce = TRUE; \
  156. DEBUGMSG( ilev, _x_ ); \
  157. } \
  158. }
  159. extern int DbgSettings;
  160. #define DEBUGMSG( dbgs, format ) ( ((dbgs) & DbgSettings)? DbgPrint format:0 )
  161. #define IRUSB_DUMP( flag, parms ) ( (( flag) & DbgSettings )? DBG_PrintBuf parms: 0 )
  162. #define DBG_STAT (1 << 23)
  163. #define DBG_PNP (1 << 24)
  164. #define DBG_TIME (1 << 25)
  165. #define DBG_DBG (1 << 26)
  166. #define DBG_OUT (1 << 27)
  167. #define DBG_BUF (1 << 28)
  168. #define DBG_BUFS (1 << 28)
  169. #define DBG_FUNCTION (1 << 29)
  170. #define DBG_FUNC (1 << 29)
  171. #define DBG_WARN (1 << 30)
  172. #define DBG_WARNING (1 << 30)
  173. #define DBG_ERROR (1 << 31)
  174. #define DBG_ERR (1 << 31)
  175. #if defined(ERROR_MESSAGES)
  176. #define DBG_INT_ERR (1 << 31)
  177. #else
  178. #define DBG_INT_ERR (1 << 29)
  179. #endif
  180. #define DBGDBG(_dbgPrint) \
  181. DbgPrint(_dbgPrint)
  182. #ifdef DEBUG_IRUSB
  183. #define DBG_D(dbgs, i) (((dbgs) & DbgSettings)? DbgPrint("irusb:"#i"==%d\n", (i)):0)
  184. #define DBG_X(dbgs, x) (((dbgs) & DbgSettings)? DbgPrint("irusb:"#x"==0x%0*X\n", sizeof(x)*2, ((ULONG_PTR)(x))&((1<<(sizeof(x)*8))-1) ):0)
  185. #define DBG_UNISTR(dbgs, s) (((dbgs) & DbgSettings)? DbgPrint("irusb:"#s"==%wZ\n", (s) ):0))
  186. #define DBGTIME(_str) \
  187. { \
  188. LARGE_INTEGER Time; \
  189. \
  190. KeQuerySystemTime(&Time); \
  191. DEBUGMSG(DBG_TIME, (_str " %d:%d\n", \
  192. Time.HighPart, \
  193. Time.LowPart/10000)); \
  194. }
  195. #else // DEBUG_IRUSB
  196. #define DBGTIME(_str)
  197. #define DBGFUNC(_dbgPrint)
  198. #define DBGOUT(_dbgPrint)
  199. #define DBGERR(_dbgPrint)
  200. #define DBGWARN(_dbgPrint)
  201. #define DBGSTAT(_dbgPrint)
  202. #define DBGTIME(_dbgPrint)
  203. #define DEBUGMSG(dbgs,format)
  204. #define DEBUGONCE( ilev, _x_ )
  205. #define DEBUGCOND( a, b, c )
  206. #define DEBUGONCECOND( a, b, c )
  207. #define IRUSB_DUMP(dbgs,format)
  208. #endif // DEBUG_IRUSB
  209. #else // DEBUG
  210. #define DBGTIME(_str)
  211. #define DBGFUNC(_dbgPrint)
  212. #define DBGDBG(_dbgPrint)
  213. #define DBGOUT(_dbgPrint)
  214. #define DBGERR(_dbgPrint)
  215. #define DBGWARN(_dbgPrint)
  216. #define DBGSTAT(_dbgPrint)
  217. #define DEBUGMSG(dbgs,format)
  218. #define DBG_D(dbgs, ivar)
  219. #define DBG_X(dbgs, xvar)
  220. #define DBG_UNISTR(dbgs, svar)
  221. #define DEBUGONCE( ilev, _x_ )
  222. #define DEBUGONCECOND( a, b, c )
  223. #define DEBUGCOND( a, b, c )
  224. #define IRUSB_DUMP(dbgs,format)
  225. #endif // DEBUG
  226. #endif // _DEBUG_H_