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.

369 lines
7.4 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. D:\nt\private\ntos\tdi\rawwan\core\debug.h
  5. Abstract:
  6. Debug macros for the Null Transport module.
  7. Revision History:
  8. Who When What
  9. -------- -------- ----------------------------------------------
  10. arvindm 05-29-97 created based on ATM ARP.
  11. Notes:
  12. --*/
  13. #ifndef _RWANDEBUG__H
  14. #define _RWANDEBUG__H
  15. //
  16. // Message verbosity: lower values indicate higher urgency
  17. //
  18. #define DL_EXTRA_LOUD 20
  19. #define DL_VERY_LOUD 10
  20. #define DL_LOUD 8
  21. #define DL_INFO 6
  22. #define DL_WARN 4
  23. #define DL_ERROR 2
  24. #define DL_FATAL 0
  25. //
  26. // Component being debugged.
  27. //
  28. #define DC_DISPATCH 0x00000001
  29. #define DC_BIND 0x00000002
  30. #define DC_ADDRESS 0x00000004
  31. #define DC_CONNECT 0x00000008
  32. #define DC_DISCON 0x00000010
  33. #define DC_DATA_TX 0x00000020
  34. #define DC_DATA_RX 0x00000040
  35. #define DC_UTIL 0x00000080
  36. #define DC_WILDCARD 0xffffffff
  37. //
  38. // Data traffic debug message flags
  39. //
  40. #define RWAND_DATA_IN 0x01
  41. #define RWAND_DATA_OUT 0x02
  42. #define RWAND_TRACK_BIG_SENDS 0x04
  43. //
  44. // Logging for sends and receives
  45. //
  46. typedef struct _RWAND_DATA_LOG_ENTRY
  47. {
  48. ULONG Operation;
  49. #define RWAND_DLOG_TX_START ' xt'
  50. #define RWAND_DLOG_TX_END ' xT'
  51. #define RWAND_DLOG_RX_START ' xr'
  52. #define RWAND_DLOG_RX_END ' xR'
  53. PNDIS_PACKET pNdisPacket;
  54. PVOID Context;
  55. ULONG PendingCount;
  56. } RWAND_DATA_LOG_ENTRY, *PRWAND_DATA_LOG_ENTRY;
  57. #define MAX_RWAND_PKT_LOG 32
  58. #ifdef PERF
  59. typedef struct _RWAND_SEND_LOG_ENTRY
  60. {
  61. ULONG Flags;
  62. PNDIS_PACKET pNdisPacket;
  63. ULONG Destination;
  64. ULONG Length;
  65. LARGE_INTEGER SendTime;
  66. LARGE_INTEGER SendCompleteTime;
  67. } RWAND_SEND_LOG_ENTRY, *PRWAND_SEND_LOG_ENTRY;
  68. #define RWAND_SEND_FLAG_UNUSED 0x00000000
  69. #define RWAND_SEND_FLAG_WAITING_COMPLETION 0x00000001
  70. #define RWAND_SEND_FLAG_COMPLETED 0x00000002
  71. #define RWAND_SEND_FLAG_RCE_GIVEN 0x00000100
  72. extern VOID
  73. RWandLogSendStart(
  74. IN PNDIS_PACKET pNdisPacket,
  75. IN ULONG Destination,
  76. IN PVOID pRCE
  77. );
  78. extern VOID
  79. RWandLogSendUpdate(
  80. IN PNDIS_PACKET pNdisPacket
  81. );
  82. extern VOID
  83. RWandLogSendComplete(
  84. IN PNDIS_PACKET pNdisPacket
  85. );
  86. extern VOID
  87. RWandLogSendAbort(
  88. IN PNDIS_PACKET pNdisPacket
  89. );
  90. extern LARGE_INTEGER TimeFrequency;
  91. #endif // PERF
  92. #if DBG_SPIN_LOCK
  93. typedef struct _RWAN_LOCK
  94. {
  95. ULONG Signature;
  96. ULONG IsAcquired;
  97. PKTHREAD OwnerThread;
  98. ULONG TouchedByFileNumber;
  99. ULONG TouchedInLineNumber;
  100. NDIS_SPIN_LOCK NdisLock;
  101. } RWAN_LOCK, *PRWAN_LOCK;
  102. #define RWANL_SIG 'KCOL'
  103. extern
  104. VOID
  105. RWanAllocateSpinLock(
  106. IN PRWAN_LOCK pLock,
  107. IN ULONG FileNumber,
  108. IN ULONG LineNumber
  109. );
  110. extern
  111. VOID
  112. RWanAcquireSpinLock(
  113. IN PRWAN_LOCK pLock,
  114. IN ULONG FileNumber,
  115. IN ULONG LineNumber
  116. );
  117. extern
  118. VOID
  119. RWanReleaseSpinLock(
  120. IN PRWAN_LOCK pLock,
  121. IN ULONG FileNumber,
  122. IN ULONG LineNumber
  123. );
  124. #define CHECK_LOCK_COUNT(Count) \
  125. { \
  126. if ((INT)(Count) < 0) \
  127. { \
  128. DbgPrint("Lock Count %d is < 0! File %s, Line %d\n", \
  129. Count, __FILE__, __LINE__); \
  130. DbgBreakPoint(); \
  131. } \
  132. }
  133. #else
  134. #define CHECK_LOCK_COUNT(Count)
  135. #define RWAN_LOCK NDIS_SPIN_LOCK
  136. #define PRWAN_LOCK PNDIS_SPIN_LOCK
  137. #endif // DBG_SPIN_LOCK
  138. #if DBG
  139. extern NDIS_SPIN_LOCK RWanDbgLogLock;
  140. extern INT RWanDebugLevel; // The value here defines what the user wants to see
  141. // all messages with this urgency and higher are enabled
  142. extern ULONG RWanDebugComp; // The bits set here define what components are being
  143. // debugged
  144. extern INT RWanDataDebugLevel;
  145. extern INT RWandBigDataLength;
  146. #define RWANDEBUGP(lev, comp, stmt) \
  147. { \
  148. if (((lev) <= RWanDebugLevel) && ((comp) & RWanDebugComp)) \
  149. { \
  150. DbgPrint("RWan: "); DbgPrint stmt; \
  151. } \
  152. }
  153. #define RWANDEBUGPDUMP(lev, comp, pBuf, Len) \
  154. { \
  155. if (((lev) <= RWanDebugLevel) && ((comp) & RWanDebugComp)) \
  156. { \
  157. DbgPrintHexDump((PUCHAR)(pBuf), (ULONG)(Len)); \
  158. } \
  159. }
  160. #define RWANDEBUGPATMADDR(lev, comp, pString, pAddr) \
  161. { \
  162. if (((lev) <= RWanDebugLevel) && ((comp) & RWanDebugComp)) \
  163. { \
  164. DbgPrintAtmAddr(pString, pAddr); \
  165. } \
  166. }
  167. #define RWAN_ASSERT(exp) \
  168. { \
  169. if (!(exp)) \
  170. { \
  171. DbgPrint("RWan: assert " #exp " failed in file %s, line %d\n", __FILE__, __LINE__); \
  172. DbgBreakPoint(); \
  173. } \
  174. }
  175. #define RWAN_SET_SIGNATURE(s, t)\
  176. (s)->t##_sig = t##_signature;
  177. #define RWAN_STRUCT_ASSERT(s, t)\
  178. if ((s)->t##_sig != t##_signature) {\
  179. DbgPrint("RWan: assertion failure for type " #t " at 0x%x in file %s, line %d\n", (PUCHAR)s, __FILE__, __LINE__); \
  180. DbgBreakPoint(); \
  181. }
  182. #if DBG_CO_SEND
  183. #define NDIS_CO_SEND_PACKETS(_VcHandle, _PktArray, _Count) \
  184. RWanCoSendPackets(_VcHandle, _PktArray, _Count)
  185. #else
  186. #define NDIS_CO_SEND_PACKETS(_VcHandle, _PktArray, _Count) \
  187. NdisCoSendPackets(_VcHandle, _PktArray, _Count)
  188. #endif // DBG_CO_SEND
  189. extern INT RWanSkipAll; // Used as an emergency exit mechanism!
  190. //
  191. // Memory Allocation/Freeing Audit:
  192. //
  193. //
  194. // The RWAND_ALLOCATION structure stores all info about one allocation
  195. //
  196. typedef struct _RWAND_ALLOCATION {
  197. ULONG Signature;
  198. struct _RWAND_ALLOCATION *Next;
  199. struct _RWAND_ALLOCATION *Prev;
  200. ULONG FileNumber;
  201. ULONG LineNumber;
  202. ULONG Size;
  203. ULONG_PTR Location; // where the returned pointer was put
  204. union
  205. {
  206. ULONGLONG Alignment;
  207. UCHAR UserData;
  208. };
  209. } RWAND_ALLOCATION, *PRWAND_ALLOCATION;
  210. #define RWAND_MEMORY_SIGNATURE (ULONG)'CSII'
  211. extern
  212. PVOID
  213. RWanAuditAllocMem (
  214. PVOID pPointer,
  215. ULONG Size,
  216. ULONG FileNumber,
  217. ULONG LineNumber
  218. );
  219. extern
  220. VOID
  221. RWanAuditFreeMem(
  222. PVOID Pointer
  223. );
  224. extern
  225. VOID
  226. RWanAuditShutdown(
  227. VOID
  228. );
  229. extern
  230. VOID
  231. DbgPrintHexDump(
  232. PUCHAR pBuffer,
  233. ULONG Length
  234. );
  235. extern
  236. VOID
  237. DbgPrintAtmAddr(
  238. PCHAR pString,
  239. ATM_ADDRESS UNALIGNED * pAddr
  240. );
  241. extern
  242. VOID
  243. DbgPrintMapping(
  244. PCHAR pString,
  245. UCHAR UNALIGNED * pIpAddr,
  246. ATM_ADDRESS UNALIGNED * pAddr
  247. );
  248. extern
  249. VOID
  250. RWanCoSendPackets(
  251. IN NDIS_HANDLE NdisVcHandle,
  252. IN PNDIS_PACKET * PacketArray,
  253. IN UINT PacketCount
  254. );
  255. extern NDIS_SPIN_LOCK RWanDPacketLogLock;
  256. #if DBG_LOG_PACKETS
  257. #define RWAND_LOG_PACKET(_pVc, _Op, _pPkt, _Ctxt) \
  258. { \
  259. struct _RWAND_DATA_LOG_ENTRY * pEnt; \
  260. NdisAcquireSpinLock(&RWanDPacketLogLock); \
  261. pEnt = &(_pVc)->DataLog[(_pVc)->Index]; \
  262. (_pVc)->Index++; \
  263. if ((_pVc)->Index == MAX_RWAND_PKT_LOG) \
  264. (_pVc)->Index = 0; \
  265. pEnt->Operation = _Op; \
  266. pEnt->pNdisPacket = _pPkt; \
  267. pEnt->Context = _Ctxt; \
  268. pEnt->PendingCount = (_pVc)->PendingPacketCount;\
  269. NdisReleaseSpinLock(&RWanDPacketLogLock); \
  270. }
  271. #else
  272. #define RWAND_LOG_PACKET(_pVc, _Op, _pPkt, _Ctxt)
  273. #endif
  274. #else
  275. //
  276. // No debug
  277. //
  278. #define RWANDEBUGP(lev, comp, stmt)
  279. #define RWANDEBUGPDUMP(lev, comp, pBuf, Len)
  280. #define RWANDEBUGPATMADDR(lev, comp, pString, pAddr)
  281. #define RWAN_ASSERT(exp)
  282. #define RWAN_SET_SIGNATURE(s, t)
  283. #define RWAN_STRUCT_ASSERT(s, t)
  284. #define NDIS_CO_SEND_PACKETS(_VcHandle, _PktArray, _Count) \
  285. NdisCoSendPackets(_VcHandle, _PktArray, _Count)
  286. #define RWAND_LOG_PACKET(_pVc, _Op, _pPkt, _Ctxt)
  287. #endif // DBG
  288. extern ULONG gHackSendSize;
  289. #endif // _RWANDEBUG__H