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.

246 lines
6.7 KiB

  1. /*++
  2. Copyright (c) 1990-1998 Microsoft Corporation, All Rights Reserved.
  3. Module Name:
  4. ATMSMDbg.h
  5. Abstract:
  6. Debug macros for ATMSMDRV
  7. Author:
  8. Anil Francis Thomas (10/98)
  9. Environment:
  10. Kernel
  11. Revision History:
  12. --*/
  13. #ifndef _ATMSMDbg__H
  14. #define _ATMSMDbg__H
  15. #define MEMORY_TAG 'MSDN'
  16. //
  17. // The ID of each source section (Used as the first 28 bits of AtmSmDebugFlag)
  18. //
  19. #define MODULE_INIT 0x00000010
  20. #define MODULE_ADAPTER 0x00000100
  21. #define MODULE_CALLMGR 0x00000200
  22. #define MODULE_WMI 0x00001000
  23. #define MODULE_PACKET 0x00002000
  24. #define MODULE_SEND 0x00010000
  25. #define MODULE_RECV 0x00020000
  26. #define MODULE_MISC 0x00100000
  27. #define MODULE_REQUEST 0x00200000
  28. #define MODULE_IOCTL 0x00400000
  29. #define MODULE_DEBUG 0x10000000
  30. #if DBG
  31. // The value here defines what debug output you wants to see. The value is a
  32. // combination of DebugLevel and the module IDs
  33. // All messages in the specified modules with urgency lower than
  34. // specified will be enabled.
  35. extern UINT AtmSmDebugFlag;
  36. //
  37. // Message verbosity: lower values indicate higher urgency.
  38. // (specified in the last 4 bits of AtmSmDebugFlag)
  39. //
  40. #define ATMSMD_VERY_LOUD 6
  41. #define ATMSMD_IN_OUT 5
  42. #define ATMSMD_LOUD 4
  43. #define ATMSMD_INFO 3
  44. #define ATMSMD_WARN 2
  45. #define ATMSMD_ERR 1
  46. #define ATMSMD_FATAL 0
  47. #define DBG_LVL(DbgFlag) (DbgFlag & 0x0000000F)
  48. #define CheckLockCount(Count) { \
  49. \
  50. if ((INT)(Count) < 0) { \
  51. \
  52. DbgPrint("Lock Count %d is < 0! File %s, Line %d\n", \
  53. Count, __FILE__, __LINE__); \
  54. DbgBreakPoint(); \
  55. } \
  56. }
  57. #define ATMSMDebugP(Level, Fmt) { \
  58. \
  59. if((MODULE_ID & AtmSmDebugFlag) \
  60. && (Level <= DBG_LVL(AtmSmDebugFlag))) { \
  61. \
  62. DbgPrint("** AtmSmDrv (0x%X): ", MODULE_ID ); \
  63. DbgPrint Fmt; \
  64. } \
  65. }
  66. #define DbgVeryLoud(Fmt) ATMSMDebugP(ATMSMD_VERY_LOUD, Fmt)
  67. #define DbgInOut(Fmt) ATMSMDebugP(ATMSMD_IN_OUT, Fmt)
  68. #define DbgLoud(Fmt) ATMSMDebugP(ATMSMD_LOUD, Fmt)
  69. #define DbgInfo(Fmt) ATMSMDebugP(ATMSMD_INFO, Fmt)
  70. #define DbgWarn(Fmt) ATMSMDebugP(ATMSMD_WARN, Fmt)
  71. #define DbgErr(Fmt) ATMSMDebugP(ATMSMD_ERR, Fmt)
  72. #define DbgFatal(Fmt) ATMSMDebugP(ATMSMD_FATAL, Fmt)
  73. #define TraceIn(x) DbgInOut(("--> "#x"\n"))
  74. #define TraceOut(x) DbgInOut(("<-- "#x"\n"))
  75. //
  76. // Memory Allocation/Freeing Auditing:
  77. //
  78. #define INIT_DONE_PATTERN 0x01020102
  79. #define TRAILER_PATTERN 0x0A0B0C0D
  80. //
  81. // The ATMSMD_ALLOCATION structure stores all info about one AtmSmMemAlloc.
  82. //
  83. typedef struct _ATMSMD_ALLOCATION {
  84. ULONG ulSignature;
  85. struct _ATMSMD_ALLOCATION *Next;
  86. struct _ATMSMD_ALLOCATION *Prev;
  87. ULONG ulModuleNumber;
  88. ULONG ulLineNumber;
  89. ULONG ulSize;
  90. union
  91. {
  92. ULONGLONG Alignment;
  93. UINT_PTR Location; // where the returned pointer was put
  94. };
  95. } ATMSMD_ALLOCATION, *PATMSMD_ALLOCATION;
  96. typedef struct _ATMSMD_ALLOC_GLOBAL {
  97. PATMSMD_ALLOCATION pAtmSmHead;
  98. PATMSMD_ALLOCATION pAtmSmTail;
  99. ULONG ulAtmSmAllocCount;
  100. NDIS_SPIN_LOCK AtmSmMemoryLock;
  101. ULONG ulAtmSmInitDonePattern;
  102. } ATMSMD_ALLOC_GLOBAL, *PATMSMD_ALLOC_GLOBAL;
  103. extern
  104. VOID
  105. AtmSmInitializeAuditMem(
  106. );
  107. extern
  108. VOID
  109. AtmSmShutdownAuditMem(
  110. );
  111. extern
  112. PVOID
  113. AtmSmAuditAllocMem (
  114. PVOID *ppPointer,
  115. ULONG ulSize,
  116. ULONG ulModuleNumber,
  117. ULONG ulLineNumber
  118. );
  119. extern
  120. VOID
  121. AtmSmAuditFreeMem(
  122. PVOID Pointer
  123. );
  124. #define ATMSM_INITIALIZE_AUDIT_MEM() AtmSmInitializeAuditMem()
  125. #define ATMSM_SHUTDOWN_AUDIT_MEM() AtmSmShutdownAuditMem()
  126. #define AtmSmAllocMem(ppPointer, TYPE, Size) \
  127. *ppPointer = (TYPE)AtmSmAuditAllocMem((PVOID *)ppPointer, Size, \
  128. MODULE_ID, __LINE__)
  129. #define AtmSmFreeMem(pPointer) AtmSmAuditFreeMem((PVOID)pPointer)
  130. VOID
  131. PrintATMAddr(
  132. IN char *pStr,
  133. IN PATM_ADDRESS pAtmAddr
  134. );
  135. #define DumpATMAddress(Level, Str, Addr) { \
  136. \
  137. if((MODULE_ID & AtmSmDebugFlag) \
  138. && (Level <= DBG_LVL(AtmSmDebugFlag))) { \
  139. \
  140. PrintATMAddr(Str,Addr); \
  141. } \
  142. }
  143. #define ATMSM_GET_ENTRY_IRQL(_Irql) \
  144. _Irql = KeGetCurrentIrql()
  145. #define ATMSM_CHECK_EXIT_IRQL(_EntryIrql, _ExitIrql) \
  146. { \
  147. _ExitIrql = KeGetCurrentIrql(); \
  148. if (_ExitIrql != _EntryIrql) \
  149. { \
  150. DbgPrint("File %s, Line %d, Exit IRQ %d != Entry IRQ %d\n", \
  151. __FILE__, __LINE__, _ExitIrql, _EntryIrql); \
  152. DbgBreakPoint(); \
  153. } \
  154. }
  155. #else // DBG
  156. //
  157. // No debug
  158. //
  159. #define ATMSM_INITIALIZE_AUDIT_MEM()
  160. #define ATMSM_SHUTDOWN_AUDIT_MEM()
  161. #define AtmSmAllocMem(ppPointer, TYPE, Size) \
  162. NdisAllocateMemoryWithTag((PVOID *)ppPointer, (ULONG)Size, \
  163. (ULONG)MEMORY_TAG)
  164. #define AtmSmFreeMem(pPointer) NdisFreeMemory((PVOID)(pPointer), 0, 0)
  165. #define CheckLockCount(Count)
  166. #define DbgVeryLoud(Fmt)
  167. #define DbgInOut(Fmt)
  168. #define DbgLoud(Fmt)
  169. #define DbgInfo(Fmt)
  170. #define DbgWarn(Fmt)
  171. #define DbgErr(Fmt)
  172. #define DbgFatal(Fmt)
  173. #define TraceIn(x)
  174. #define TraceOut(x)
  175. #define DumpATMAddress(Level, Str, Addr)
  176. #define ATMSM_GET_ENTRY_IRQL(Irql)
  177. #define ATMSM_CHECK_EXIT_IRQL(EntryIrql, ExitIrql)
  178. #endif // DBG
  179. #endif // _AtmSmDbg__H