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
5.2 KiB

  1. /*++
  2. Copyright (c) 1996-1998 Microsoft Corporation
  3. Module Name:
  4. DBG.H
  5. Abstract:
  6. Copied from Header file for USBSTOR driver debug utility functions
  7. Environment:
  8. kernel mode
  9. Revision History:
  10. September 2001: Created by KenRay
  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 (GenUSB_DriverGlobals.DebugFlags & flag) { \
  47. DbgBreakPoint(); \
  48. } \
  49. } while (0)
  50. #define DBGPRINT(level, _x_) do { \
  51. if (level <= GenUSB_DriverGlobals.DebugLevel) { \
  52. KdPrint(("GenUSB: ")); \
  53. KdPrint( _x_ ); \
  54. } \
  55. } while (0)
  56. #endif
  57. #if !DEBUG_LOG
  58. #define LOGINIT(ext)
  59. #define LOGUNINIT(ext)
  60. #define LOGENTRY(ext, tag, info1, info2, info3)
  61. #else
  62. #define LOGSIZE 10 // the power of two that gives the size of the log.
  63. #define LOGINIT(ext) GenUSB_LogInit(ext)
  64. #define LOGUNINIT(ext) GenUSB_LogUnInit(ext)
  65. #define LOGENTRY(ext, tag, info1, info2, info3) \
  66. GenUSB_LogEntry(ext, \
  67. ((((tag) >> 24) & 0x000000FF) | \
  68. (((tag) >> 8) & 0x0000FF00) | \
  69. (((tag) << 8) & 0x00FF0000) | \
  70. (((tag) << 24) & 0xFF000000)), \
  71. ((ULONG_PTR)info1), \
  72. ((ULONG_PTR)info2), \
  73. ((ULONG_PTR)info3))
  74. #endif
  75. //*****************************************************************************
  76. // T Y P E D E F S
  77. //*****************************************************************************
  78. #ifdef _WIN64
  79. #define GENUSB_LOG_ENTRY GENUSB_LOG_ENTRY64
  80. #define PGENUSB_LOG_ENTRY PGENUSB_LOG_ENTRY64
  81. #else
  82. #define GENUSB_LOG_ENTRY GENUSB_LOG_ENTRY32
  83. #define PGENUSB_LOG_ENTRY PGENUSB_LOG_ENTRY32
  84. #endif
  85. typedef struct _GENUSB_LOG_ENTRY64 {
  86. ULONG le_tag;
  87. ULONG pad;
  88. ULONG64 le_info1;
  89. ULONG64 le_info2;
  90. ULONG64 le_info3;
  91. } GENUSB_LOG_ENTRY64, *PGENUSB_LOG_ENTRY64;
  92. typedef struct _GENUSB_LOG_ENTRY32 {
  93. ULONG le_tag;
  94. ULONG le_info1;
  95. ULONG le_info2;
  96. ULONG le_info3;
  97. } GENUSB_LOG_ENTRY32, *PGENUSB_LOG_ENTRY32;
  98. typedef struct _DRIVERGLOBALS
  99. {
  100. ULONG DebugFlags; // DBGF_* Flags
  101. LONG DebugLevel; // Level of debug output
  102. // PGENUSB_LOG_ENTRY LogStart; // Start of log buffer (older entries)
  103. // ULONG LogIndex;
  104. // ULONG LogMask;
  105. } DRIVERGLOBALS;
  106. //*****************************************************************************
  107. //
  108. // G L O B A L S
  109. //
  110. //*****************************************************************************
  111. //
  112. // DBG.C
  113. //
  114. extern DRIVERGLOBALS GenUSB_DriverGlobals;
  115. //*****************************************************************************
  116. //
  117. // F U N C T I O N P R O T O T Y P E S
  118. //
  119. //*****************************************************************************
  120. //
  121. // DBG.C
  122. //
  123. VOID
  124. GenUSB_QueryGlobalParams (
  125. );
  126. #if DEBUG_LOG
  127. VOID
  128. GenUSB_LogInit (
  129. struct _DEVICE_EXTENSION * DeviceExtension
  130. );
  131. VOID
  132. GenUSB_LogUnInit (
  133. struct _DEVICE_EXTENSION * DeviceExtension
  134. );
  135. VOID
  136. GenUSB_LogEntry (
  137. IN struct _DEVICE_EXTENSION * DeviceExtension,
  138. IN ULONG Tag,
  139. IN ULONG_PTR Info1,
  140. IN ULONG_PTR Info2,
  141. IN ULONG_PTR Info3
  142. );
  143. #endif
  144. #if DBG
  145. PCHAR
  146. PnPMinorFunctionString (
  147. UCHAR MinorFunction
  148. );
  149. PCHAR
  150. PowerMinorFunctionString (
  151. UCHAR MinorFunction
  152. );
  153. PCHAR
  154. PowerDeviceStateString (
  155. DEVICE_POWER_STATE State
  156. );
  157. PCHAR
  158. PowerSystemStateString (
  159. SYSTEM_POWER_STATE State
  160. );
  161. VOID
  162. DumpDeviceDesc (
  163. PUSB_DEVICE_DESCRIPTOR DeviceDesc
  164. );
  165. VOID
  166. DumpConfigDesc (
  167. PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc
  168. );
  169. VOID
  170. DumpConfigurationDescriptor (
  171. PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc
  172. );
  173. VOID
  174. DumpInterfaceDescriptor (
  175. PUSB_INTERFACE_DESCRIPTOR InterfaceDesc
  176. );
  177. VOID
  178. DumpEndpointDescriptor (
  179. PUSB_ENDPOINT_DESCRIPTOR EndpointDesc
  180. );
  181. #endif