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.

380 lines
8.0 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. debug.h
  5. Abstract:
  6. Debug macros for the ATM/ARP module
  7. Revision History:
  8. Who When What
  9. -------- -------- ----------------------------------------------
  10. arvindm 06-13-96 created based on Call Manager debug.h
  11. Notes:
  12. --*/
  13. #ifndef _AADEBUG__H
  14. #define _AADEBUG__H
  15. //
  16. // Message verbosity: lower values indicate higher urgency
  17. //
  18. #define AAD_EXTRA_LOUD 20
  19. #define AAD_VERY_LOUD 10
  20. #define AAD_LOUD 8
  21. #define AAD_INFO 6
  22. #define AAD_WARNING 4
  23. #define AAD_ERROR 2
  24. #define AAD_FATAL 0
  25. //
  26. // Data traffic debug message flags
  27. //
  28. #define AAD_DATA_IN 0x01
  29. #define AAD_DATA_OUT 0x02
  30. #define AAD_TRACK_BIG_SENDS 0x04
  31. #ifdef PERF
  32. typedef struct _AAD_SEND_LOG_ENTRY
  33. {
  34. ULONG Flags;
  35. PNDIS_PACKET pNdisPacket;
  36. ULONG Destination;
  37. ULONG Length;
  38. LARGE_INTEGER SendTime;
  39. LARGE_INTEGER SendCompleteTime;
  40. } AAD_SEND_LOG_ENTRY, *PAAD_SEND_LOG_ENTRY;
  41. #define AAD_SEND_FLAG_UNUSED 0x00000000
  42. #define AAD_SEND_FLAG_WAITING_COMPLETION 0x00000001
  43. #define AAD_SEND_FLAG_COMPLETED 0x00000002
  44. #define AAD_SEND_FLAG_RCE_GIVEN 0x00000100
  45. extern VOID
  46. AadLogSendStart(
  47. IN PNDIS_PACKET pNdisPacket,
  48. IN ULONG Destination,
  49. IN PVOID pRCE
  50. );
  51. extern VOID
  52. AadLogSendUpdate(
  53. IN PNDIS_PACKET pNdisPacket
  54. );
  55. extern VOID
  56. AadLogSendComplete(
  57. IN PNDIS_PACKET pNdisPacket
  58. );
  59. extern VOID
  60. AadLogSendAbort(
  61. IN PNDIS_PACKET pNdisPacket
  62. );
  63. extern LARGE_INTEGER TimeFrequency;
  64. #endif // PERF
  65. #if DBG_SPIN_LOCK
  66. typedef struct _ATMARP_LOCK
  67. {
  68. ULONG Signature;
  69. ULONG IsAcquired;
  70. PKTHREAD OwnerThread;
  71. ULONG TouchedByFileNumber;
  72. ULONG TouchedInLineNumber;
  73. NDIS_SPIN_LOCK NdisLock;
  74. } ATMARP_LOCK, *PATMARP_LOCK;
  75. #define AAL_SIG 'KCOL'
  76. extern
  77. VOID
  78. AtmArpAllocateSpinLock(
  79. IN PATMARP_LOCK pLock,
  80. IN ULONG FileNumber,
  81. IN ULONG LineNumber
  82. );
  83. extern
  84. VOID
  85. AtmArpAcquireSpinLock(
  86. IN PATMARP_LOCK pLock,
  87. IN ULONG FileNumber,
  88. IN ULONG LineNumber
  89. );
  90. extern
  91. VOID
  92. AtmArpReleaseSpinLock(
  93. IN PATMARP_LOCK pLock,
  94. IN ULONG FileNumber,
  95. IN ULONG LineNumber
  96. );
  97. #define CHECK_LOCK_COUNT(Count) \
  98. { \
  99. if ((INT)(Count) < 0) \
  100. { \
  101. DbgPrint("Lock Count %d is < 0! File %s, Line %d\n", \
  102. Count, __FILE__, __LINE__); \
  103. DbgBreakPoint(); \
  104. } \
  105. }
  106. #else
  107. #define CHECK_LOCK_COUNT(Count)
  108. #define ATMARP_LOCK NDIS_SPIN_LOCK
  109. #define PATMARP_LOCK PNDIS_SPIN_LOCK
  110. #endif // DBG_SPIN_LOCK
  111. #if DBG
  112. extern INT AaDebugLevel; // the value here defines what the user wants to see
  113. // all messages with this urgency and higher are enabled
  114. extern INT AaMcDebugLevel;
  115. extern INT AaDataDebugLevel;
  116. extern INT AadBigDataLength;
  117. #define AADEBUGP(lev, stmt) \
  118. { if ((lev) <= AaDebugLevel) { DbgPrint("AtmArpC: "); DbgPrint stmt; }}
  119. #define AADEBUGPDUMP(lev, pBuf, Len) \
  120. { if ((lev) <= AaDebugLevel) { DbgPrintHexDump((PUCHAR)(pBuf), (ULONG)(Len)); }}
  121. #define AADEBUGPATMADDR(lev, pString, pAddr) \
  122. { if ((lev) <= AaDebugLevel) { DbgPrintAtmAddr(pString, pAddr); } }
  123. #define AADEBUGPMAP(lev, pString, pIpAddr, pAtmAddr) \
  124. { if ((lev) <= AaDebugLevel) { DbgPrintMapping(pString, (PUCHAR)pIpAddr, pAtmAddr); } }
  125. #define AAMCDEBUGP(lev, stmt) \
  126. { if ((lev) <= AaMcDebugLevel) { DbgPrint("AtmArpC: "); DbgPrint stmt; }}
  127. #define AAMCDEBUGPDUMP(lev, pBuf, Len) \
  128. { if ((lev) <= AaMcDebugLevel) { DbgPrintHexDump((PUCHAR)(pBuf), (ULONG)(Len)); }}
  129. #define AAMCDEBUGPATMADDR(lev, pString, pAddr) \
  130. { if ((lev) <= AaMcDebugLevel) { DbgPrintAtmAddr(pString, pAddr); } }
  131. #define AAMCDEBUGPMAP(lev, pString, pIpAddr, pAtmAddr) \
  132. { if ((lev) <= AaMcDebugLevel) { DbgPrintMapping(pString, (PUCHAR)pIpAddr, pAtmAddr); } }
  133. #define AA_ASSERT(exp) \
  134. { if (!(exp)) { DbgPrint("ATMARPC: assert " #exp " failed in file %s, line %d\n", __FILE__, __LINE__); DbgBreakPoint(); } }
  135. #define AA_STRUCT_ASSERT(s, t)\
  136. if ((s)->t##_sig != t##_signature) {\
  137. DbgPrint("Structure assertion failure for type " #t " in file %s, line %d\n", __FILE__, __LINE__); \
  138. DbgBreakPoint(); \
  139. }
  140. #if DBG_CO_SEND
  141. #define NDIS_CO_SEND_PACKETS(_VcHandle, _PktArray, _Count) \
  142. AaCoSendPackets(_VcHandle, _PktArray, _Count)
  143. #else
  144. #define NDIS_CO_SEND_PACKETS(_VcHandle, _PktArray, _Count) \
  145. NdisCoSendPackets(_VcHandle, _PktArray, _Count)
  146. #endif // DBG_CO_SEND
  147. extern INT AaSkipAll; // Used as an emergency exit mechanism!
  148. //
  149. // Memory Allocation/Freeing Audit:
  150. //
  151. //
  152. // The AAD_ALLOCATION structure stores all info about one allocation
  153. //
  154. typedef struct _AAD_ALLOCATION {
  155. ULONG Signature;
  156. struct _AAD_ALLOCATION *Next;
  157. struct _AAD_ALLOCATION *Prev;
  158. ULONG FileNumber;
  159. ULONG LineNumber;
  160. ULONG Size;
  161. PVOID Location; // where the returned pointer was put
  162. union
  163. {
  164. ULONGLONG Alignment;
  165. UCHAR UserData;
  166. };
  167. } AAD_ALLOCATION, *PAAD_ALLOCATION;
  168. #define AAD_MEMORY_SIGNATURE (ULONG)'CSII'
  169. extern
  170. PVOID
  171. AaAuditAllocMem (
  172. PVOID pPointer,
  173. ULONG Size,
  174. ULONG FileNumber,
  175. ULONG LineNumber
  176. );
  177. extern
  178. VOID
  179. AaAuditFreeMem(
  180. PVOID Pointer
  181. );
  182. extern
  183. VOID
  184. AaAuditShutdown(
  185. VOID
  186. );
  187. extern
  188. VOID
  189. DbgPrintHexDump(
  190. PUCHAR pBuffer,
  191. ULONG Length
  192. );
  193. extern
  194. VOID
  195. DbgPrintAtmAddr(
  196. PCHAR pString,
  197. ATM_ADDRESS UNALIGNED * pAddr
  198. );
  199. extern
  200. VOID
  201. DbgPrintMapping(
  202. PCHAR pString,
  203. UCHAR UNALIGNED * pIpAddr,
  204. ATM_ADDRESS UNALIGNED * pAddr
  205. );
  206. extern
  207. VOID
  208. AaCoSendPackets(
  209. IN NDIS_HANDLE NdisVcHandle,
  210. IN PNDIS_PACKET * PacketArray,
  211. IN UINT PacketCount
  212. );
  213. #else
  214. //
  215. // No debug
  216. //
  217. #define AADEBUGP(lev, stmt)
  218. #define AADEBUGPDUMP(lev, pBuf, Len)
  219. #define AADEBUGPATMADDR(lev, pString, pAddr)
  220. #define AADEBUGPMAP(lev, pString, pIpAddr, pAtmAddr)
  221. #define AAMCDEBUGP(lev, stmt)
  222. #define AAMCDEBUGPDUMP(lev, pBuf, Len)
  223. #define AAMCDEBUGPATMADDR(lev, pString, pAddr)
  224. #define AAMCDEBUGPMAP(lev, pString, pIpAddr, pAtmAddr)
  225. #define AA_ASSERT(exp)
  226. #define AA_STRUCT_ASSERT(s, t)
  227. #define NDIS_CO_SEND_PACKETS(_VcHandle, _PktArray, _Count) \
  228. NdisCoSendPackets(_VcHandle, _PktArray, _Count)
  229. #endif // DBG
  230. #if DBG
  231. #define AA_REF_AE(_pAE, _RefType) \
  232. AtmArpReferenceAtmEntryEx(_pAE, _RefType)
  233. #define AA_DEREF_AE(_pAE, _RefType) \
  234. AtmArpDereferenceAtmEntryEx(_pAE, _RefType, TRUE)
  235. #define AA_DEREF_AE_NO_DELETE(_pAE, _RefType) \
  236. AtmArpDereferenceAtmEntryEx(_pAE, _RefType, FALSE)
  237. #define AA_REF_IE(_pIE, _RefType) \
  238. AtmArpReferenceIPEntryEx(_pIE, _RefType)
  239. #define AA_DEREF_IE(_pIE, _RefType) \
  240. AtmArpDereferenceIPEntryEx(_pIE, _RefType, TRUE)
  241. #define AA_DEREF_IE_NO_DELETE(_pIE, _RefType) \
  242. AtmArpDereferenceIPEntryEx(_pIE, _RefType, FALSE)
  243. #define AA_SWITCH_IE_REFTYPE(_pIE, _FromRefType, _ToRefType) \
  244. ( AtmArpReferenceIPEntryEx(_pIE, _ToRefType) \
  245. ,AtmArpDereferenceIPEntryEx(_pIE, _FromRefType, FALSE))
  246. #define AA_REF_JE(_pJE) \
  247. AtmArpReferenceJoinEntryEx(_pJE, (_FILENUMBER << 16) | __LINE__)
  248. #define AA_DEREF_JE(_pJE) \
  249. AtmArpDereferenceJoinEntryEx(_pJE, (_FILENUMBER << 16) | __LINE__)
  250. #else // !DBG
  251. #define AA_REF_AE(_pAE, _RefType) \
  252. AtmArpReferenceAtmEntry(_pAE)
  253. #define AA_DEREF_AE(_pAE, _RefType) \
  254. AtmArpDereferenceAtmEntry(_pAE)
  255. #define AA_DEREF_AE_NO_DELETE(_pAE, _RefType) \
  256. ((_pAE)->RefCount--)
  257. #define AA_REF_IE(_pIE, _RefType) \
  258. AtmArpReferenceIPEntry(_pIE)
  259. #define AA_DEREF_IE(_pIE, _RefType) \
  260. AtmArpDereferenceIPEntry(_pIE)
  261. #define AA_DEREF_IE_NO_DELETE(_pIE, _RefType) \
  262. ((_pIE)->RefCount--)
  263. #define AA_SWITCH_IE_REFTYPE(_pIE, _FromRefType, _ToRefType) \
  264. ((void)(0))
  265. #define AA_REF_JE(_pJE) \
  266. AtmArpReferenceJoinEntry(_pJE)
  267. #define AA_DEREF_JE(_pJE) \
  268. AtmArpDereferenceJoinEntry(_pJE)
  269. #endif // !DBG
  270. #if DBG
  271. #define AA_CHECK_TIMER_IN_ACTIVE_LIST(_pTimer, _pIf, _pStruct, _pName) \
  272. AtmArpCheckIfTimerIsInActiveList( \
  273. _pTimer, \
  274. _pIf, \
  275. _pStruct, \
  276. _pName \
  277. )
  278. #else
  279. #define AA_CHECK_TIMER_IN_ACTIVE_LIST(_pTimer, _pIf, _pStruct, _pName)
  280. #endif // DBG
  281. #endif // _AADEBUG__H