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.

237 lines
4.8 KiB

  1. /*++
  2. Copyright (c) 1996-1998 Microsoft Corporation
  3. Module Name:
  4. DBG.H
  5. Abstract:
  6. Header file for USBSTOR driver debug utility functions
  7. Environment:
  8. kernel mode
  9. Revision History:
  10. 06-01-98 : started rewrite
  11. --*/
  12. //*****************************************************************************
  13. // D E F I N E S
  14. //*****************************************************************************
  15. #if DBG
  16. #if defined(DEBUG_LOG)
  17. #undef DEBUG_LOG
  18. #endif
  19. #define DEBUG_LOG 1
  20. #else
  21. #if !defined(DEBUG_LOG)
  22. #define DEBUG_LOG 0
  23. #endif
  24. #endif
  25. #if !DBG
  26. #define DBGFBRK(flag)
  27. #define DBGPRINT(level, _x_)
  28. #else
  29. #define DBGF_BRK_DRIVERENTRY 0x00000001
  30. #define DBGF_BRK_UNLOAD 0x00000002
  31. #define DBGF_BRK_ADDDEVICE 0x00000004
  32. #define DBGF_BRK_REMOVEDEVICE 0x00000008
  33. #define DBGF_BRK_STARTDEVICE 0x00000010
  34. #define DBGF_BRK_STOPDEVICE 0x00000020
  35. #define DBGF_BRK_QUERYSTOPDEVICE 0x00000040
  36. #define DBGF_BRK_CANCELSTOPDEVICE 0x00000080
  37. #define DBGF_BRK_RESET 0x00000100
  38. #define DBGF_BRK_RESETPIPE 0x00000200
  39. #define DBGF_BRK_CREATE 0x00010000
  40. #define DBGF_BRK_CLOSE 0x00020000
  41. #define DBGF_BRK_READWRITE 0x00040000
  42. #define DBGF_BRK_IOCTL 0x00080000
  43. #define DBGF_BRK_SCSI 0x00100000
  44. #define DBGF_BRK_INVALID_REQ 0x00200000
  45. #define DBGFBRK(flag) do { \
  46. if (USBSTOR_DriverGlobals.DebugFlags & flag) { \
  47. DbgBreakPoint(); \
  48. } \
  49. } while (0)
  50. #define DBGPRINT(level, _x_) do { \
  51. if (level <= USBSTOR_DriverGlobals.DebugLevel) { \
  52. KdPrint(("USBSTOR: ")); \
  53. KdPrint( _x_ ); \
  54. } \
  55. } while (0)
  56. #endif
  57. #if !DEBUG_LOG
  58. #define LOGINIT()
  59. #define LOGUNINIT()
  60. #define LOGENTRY(tag, info1, info2, info3)
  61. #else
  62. #define LOGSIZE 4096
  63. #define LOGINIT() USBSTOR_LogInit()
  64. #define LOGUNINIT() USBSTOR_LogUnInit()
  65. #define LOGENTRY(tag, info1, info2, info3) \
  66. USBSTOR_LogEntry(((((tag) >> 24) & 0x000000FF) | \
  67. (((tag) >> 8) & 0x0000FF00) | \
  68. (((tag) << 8) & 0x00FF0000) | \
  69. (((tag) << 24) & 0xFF000000)), \
  70. ((ULONG_PTR)info1), \
  71. ((ULONG_PTR)info2), \
  72. ((ULONG_PTR)info3))
  73. #endif
  74. //*****************************************************************************
  75. // T Y P E D E F S
  76. //*****************************************************************************
  77. #if DEBUG_LOG
  78. typedef struct _USBSTOR_LOG_ENTRY {
  79. ULONG le_tag;
  80. ULONG_PTR le_info1;
  81. ULONG_PTR le_info2;
  82. ULONG_PTR le_info3;
  83. } USBSTOR_LOG_ENTRY, *PUSBSTOR_LOG_ENTRY;
  84. #endif
  85. #if DBG || DEBUG_LOG
  86. typedef struct _DRIVERGLOBALS
  87. {
  88. #if DBG
  89. ULONG DebugFlags; // DBGF_* Flags
  90. LONG DebugLevel; // Level of debug output
  91. #endif
  92. PUSBSTOR_LOG_ENTRY LogStart; // Start of log buffer (older entries)
  93. PUSBSTOR_LOG_ENTRY LogPtr; // Current entry in log buffer
  94. PUSBSTOR_LOG_ENTRY LogEnd; // End of log buffer (newer entries)
  95. KSPIN_LOCK LogSpinLock; // Protects LogPtr
  96. } DRIVERGLOBALS;
  97. #endif
  98. //*****************************************************************************
  99. //
  100. // G L O B A L S
  101. //
  102. //*****************************************************************************
  103. //
  104. // DBG.C
  105. //
  106. #if DBG || DEBUG_LOG
  107. DRIVERGLOBALS USBSTOR_DriverGlobals;
  108. #endif
  109. //*****************************************************************************
  110. //
  111. // F U N C T I O N P R O T O T Y P E S
  112. //
  113. //*****************************************************************************
  114. //
  115. // DBG.C
  116. //
  117. #if DBG
  118. VOID
  119. USBSTOR_QueryGlobalParams (
  120. );
  121. #endif
  122. #if DEBUG_LOG
  123. VOID
  124. USBSTOR_LogInit (
  125. );
  126. VOID
  127. USBSTOR_LogUnInit (
  128. );
  129. VOID
  130. USBSTOR_LogEntry (
  131. IN ULONG Tag,
  132. IN ULONG_PTR Info1,
  133. IN ULONG_PTR Info2,
  134. IN ULONG_PTR Info3
  135. );
  136. #endif
  137. #if DBG
  138. PCHAR
  139. PnPMinorFunctionString (
  140. UCHAR MinorFunction
  141. );
  142. PCHAR
  143. PowerMinorFunctionString (
  144. UCHAR MinorFunction
  145. );
  146. PCHAR
  147. PowerDeviceStateString (
  148. DEVICE_POWER_STATE State
  149. );
  150. PCHAR
  151. PowerSystemStateString (
  152. SYSTEM_POWER_STATE State
  153. );
  154. VOID
  155. DumpDeviceDesc (
  156. PUSB_DEVICE_DESCRIPTOR DeviceDesc
  157. );
  158. VOID
  159. DumpConfigDesc (
  160. PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc
  161. );
  162. VOID
  163. DumpConfigurationDescriptor (
  164. PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc
  165. );
  166. VOID
  167. DumpInterfaceDescriptor (
  168. PUSB_INTERFACE_DESCRIPTOR InterfaceDesc
  169. );
  170. VOID
  171. DumpEndpointDescriptor (
  172. PUSB_ENDPOINT_DESCRIPTOR EndpointDesc
  173. );
  174. #endif