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.

183 lines
4.4 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. DBG.H
  5. Abstract:
  6. This module contains the PRIVATE (driver-only) definitions for the
  7. code that implements the usbd driver.
  8. Environment:
  9. Kernel & user mode
  10. Revision History:
  11. 09-29-95 : created
  12. --*/
  13. #define NAME_MAX 64
  14. #define USBD_TAG 0x44425355 /* "USBD" */
  15. #define USBD_FREE_TAG 0x65657266 /* "free" */
  16. #if DBG
  17. #define DEBUG_LOG
  18. #define DEBUG_HEAP
  19. #endif
  20. #define SIG_CONFIG 0x464E4F43 //"CONF" signature for config handle
  21. #define SIG_PIPE 0x45504950 //"PIPE" signature for pipe handle
  22. #define SIG_INTERFACE 0x43414658 //"XFAC" signature for interface handle
  23. #define SIG_DEVICE 0x56454455 //"UDEV" signature for device handle
  24. #if DBG
  25. #define ASSERT_CONFIG(ch) USBD_ASSERT((ch)->Sig == SIG_CONFIG)
  26. #define ASSERT_PIPE(ph) USBD_ASSERT((ph)->Sig == SIG_PIPE)
  27. #define ASSERT_INTERFACE(ih) USBD_ASSERT((ih)->Sig == SIG_INTERFACE)
  28. #define ASSERT_DEVICE(d) USBD_ASSERT((d)->Sig == SIG_DEVICE)
  29. ULONG
  30. _cdecl
  31. USBD_KdPrintX(
  32. PCH Format,
  33. ...
  34. );
  35. extern ULONG USBD_Debug_Trace_Level;
  36. // the convention here is to print to the ntkern log if
  37. // l (level) is > 1 otherwise print to the terminal
  38. // in usbd you have to manully specify the ' in the output
  39. // string
  40. #define USBD_KdPrint(l, _x_) if (((l) == 0) || (((l)-1) < USBD_Debug_Trace_Level)) \
  41. {\
  42. if ((l) == 1) {\
  43. DbgPrint("USBD: ");\
  44. } else {\
  45. DbgPrint("'USBD: ");\
  46. }\
  47. USBD_KdPrintX _x_;\
  48. }
  49. VOID
  50. USBD_Assert(
  51. PVOID FailedAssertion,
  52. PVOID FileName,
  53. ULONG LineNumber,
  54. PCHAR Message
  55. );
  56. #define USBD_ASSERT( exp ) \
  57. if (!(exp)) \
  58. USBD_Assert( #exp, __FILE__, __LINE__, NULL )
  59. #define USBD_ASSERTMSG( msg, exp ) \
  60. if (!(exp)) \
  61. USBD_Assert( #exp, __FILE__, __LINE__, msg )
  62. // TEST_TRAP() is a code coverage trap these should be removed
  63. // if you are able to 'g' past the OK
  64. //
  65. // TRAP() breaks in the debugger on the debugger build
  66. // these indicate bugs in client drivers or fatal error
  67. // conditions that should be debugged. also used to mark
  68. // code for features not implemented yet.
  69. //
  70. // KdBreak() breaks in the debugger when in MAX_DEBUG mode
  71. // ie debug trace info is turned on, these are intended to help
  72. // debug drivers devices and special conditions on the
  73. // bus.
  74. #ifdef NTKERN
  75. // Ntkern currently implements DebugBreak with a global int 3,
  76. // we really would like the int 3 in our own code.
  77. #define DBGBREAK() _asm { int 3 }
  78. #else
  79. #define DBGBREAK() DbgBreakPoint()
  80. #endif /* NTKERN */
  81. #define TEST_TRAP() { DbgPrint( " Code Coverage Trap %s %d\n", __FILE__, __LINE__); \
  82. DBGBREAK(); }
  83. #ifdef MAX_DEBUG
  84. #define USBD_KdBreak(_x_) { DbgPrint("USBD:"); \
  85. DbgPrint _x_ ; \
  86. DBGBREAK(); }
  87. #else
  88. #define USBD_KdBreak(_x_)
  89. #endif
  90. #define USBD_KdTrap(_x_) { DbgPrint( "USBD: "); \
  91. DbgPrint _x_; \
  92. DBGBREAK(); }
  93. VOID
  94. USBD_Debug_LogEntry(
  95. IN CHAR *Name,
  96. IN ULONG_PTR Info1,
  97. IN ULONG_PTR Info2,
  98. IN ULONG_PTR Info3
  99. );
  100. #define LOGENTRY(sig, info1, info2, info3) \
  101. USBD_Debug_LogEntry(sig, (ULONG_PTR)info1, (ULONG_PTR)info2, (ULONG_PTR)info3)
  102. extern LONG USBDTotalHeapAllocated;
  103. PVOID
  104. USBD_Debug_GetHeap(
  105. IN POOL_TYPE PoolType,
  106. IN ULONG NumberOfBytes,
  107. IN ULONG Signature,
  108. IN PLONG TotalAllocatedHeapSpace
  109. );
  110. #define GETHEAP(pooltype, numbytes) USBD_Debug_GetHeap(pooltype, numbytes,\
  111. USBD_TAG, &USBDTotalHeapAllocated)
  112. VOID
  113. USBD_Debug_RetHeap(
  114. IN PVOID P,
  115. IN ULONG Signature,
  116. IN PLONG TotalAllocatedHeapSpace
  117. );
  118. #define RETHEAP(p) USBD_Debug_RetHeap(p, USBD_TAG, &USBDTotalHeapAllocated)
  119. #else /* DBG not defined */
  120. #define USBD_KdBreak(_x_)
  121. #define USBD_KdPrint(l, _x_)
  122. #define USBD_KdTrap(_x_)
  123. #define TEST_TRAP()
  124. #define ASSERT_CONFIG(ch)
  125. #define ASSERT_PIPE(ph)
  126. #define ASSERT_INTERFACE(ih)
  127. #define ASSERT_DEVICE(d)
  128. #define USBD_ASSERT( exp )
  129. #define USBD_ASSERTMSG( msg, exp )
  130. #define GETHEAP(pooltype, numbytes) ExAllocatePoolWithTag(pooltype, numbytes, USBD_TAG)
  131. #define RETHEAP(p) ExFreePool(p)
  132. #endif /* DBG */