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.

343 lines
13 KiB

  1. /*++
  2. Copyright (c) 1990-1995 Microsoft Corporation
  3. Module Name:
  4. ndisdbg.h
  5. Abstract:
  6. NDIS wrapper definitions
  7. Author:
  8. Environment:
  9. Kernel mode, FSD
  10. Revision History:
  11. Jul-14 Kyle Brandon Added debug supported for conditional breaks.
  12. --*/
  13. #ifndef __DEBUG_H
  14. #define __DEBUG_H
  15. //
  16. // Define module numbers.
  17. //
  18. #define MODULE_NDIS 0x00010000
  19. #define MODULE_DATA 0x00020000
  20. #define MODULE_INIT 0x00030000
  21. #define MODULE_INITPNP 0x00040000
  22. #define MODULE_COMMON 0x00050000
  23. #define MODULE_CONFIG 0x00060000
  24. #define MODULE_CONFIGM 0x00070000
  25. #define MODULE_BUS 0x00080000
  26. #define MODULE_TIMER 0x00090000
  27. #define MODULE_TIMERM 0x000A0000
  28. #define MODULE_MINIPORT 0x000B0000
  29. #define MODULE_REQUESTM 0x000C0000
  30. #define MODULE_MINISUB 0x000D0000
  31. #define MODULE_MAC 0x000E0000
  32. #define MODULE_PROTOCOL 0x000F0000
  33. #define MODULE_EFILTER 0x00100000
  34. #define MODULE_TFILTER 0x00110000
  35. #define MODULE_FFILTER 0x00120000
  36. #define MODULE_AFILTER 0x00130000
  37. #define MODULE_NFILTER 0x00140000
  38. #define MODULE_DEBUG 0x00150000
  39. #define MODULE_MININT 0x00160000
  40. #define MODULE_SENDM 0x00170000
  41. #define MODULE_NDIS_CO 0x00180000
  42. #define MODULE_NDIS_PNP 0x00190000
  43. #define MODULE_POWER 0x001A0000
  44. #define MODULE_WMI 0x001B0000
  45. #define MODULE_DMA 0x001C0000
  46. #define MODULE_CDATA 0x001D0000
  47. #define MODULE_VERIFY 0x001E0000
  48. #define DBG_LEVEL_INFO 0x00000000
  49. #define DBG_LEVEL_LOG 0x00000800
  50. #define DBG_LEVEL_WARN 0x00001000
  51. #define DBG_LEVEL_ERR 0x00002000
  52. #define DBG_LEVEL_FATAL 0x00003000
  53. #define DBG_COMP_INIT 0x00000001
  54. #define DBG_COMP_CONFIG 0x00000002
  55. #define DBG_COMP_SEND 0x00000004
  56. #define DBG_COMP_RECV 0x00000008
  57. #define DBG_COMP_PROTOCOL 0x00000010
  58. #define DBG_COMP_BIND 0x00000020
  59. #define DBG_COMP_BUSINFO 0x00000040
  60. #define DBG_COMP_REG 0x00000080
  61. #define DBG_COMP_MEMORY 0x00000100
  62. #define DBG_COMP_FILTER 0x00000200
  63. #define DBG_COMP_REQUEST 0x00000400
  64. #define DBG_COMP_WORK_ITEM 0x00000800
  65. #define DBG_COMP_PNP 0x00001000
  66. #define DBG_COMP_PM 0x00002000
  67. #define DBG_COMP_OPENREF 0x00004000
  68. #define DBG_COMP_LOCKS 0x00008000
  69. #define DBG_COMP_RESET 0x00010000
  70. #define DBG_COMP_WMI 0x00020000
  71. #define DBG_COMP_CO 0x00040000
  72. #define DBG_COMP_REF 0x00080000
  73. #define DBG_COMP_ALL 0xFFFFFFFF
  74. #if DBG
  75. #if defined(MEMPRINT)
  76. #include "memprint.h" // DavidTr's memprint program at ntos\srv
  77. #endif // MEMPRINT
  78. VOID
  79. ndisDbgPrintUnicodeString(
  80. IN PUNICODE_STRING UnicodeString
  81. );
  82. #define DBGPRINT(Component, Level, Fmt) \
  83. { \
  84. if ((Level >= ndisDebugLevel) && \
  85. ((ndisDebugSystems & Component) == Component)) \
  86. { \
  87. DbgPrint("***NDIS*** (%x, %d) ", \
  88. MODULE_NUMBER >> 16, __LINE__); \
  89. DbgPrint Fmt; \
  90. } \
  91. }
  92. #define DBGPRINT_RAW(Component, Level, Fmt) \
  93. { \
  94. if ((Level >= ndisDebugLevel) && \
  95. ((ndisDebugSystems & Component) == Component)) \
  96. { \
  97. DbgPrint Fmt; \
  98. } \
  99. }
  100. #define DBGPRINT_UNICODE(Component, Level, UString) \
  101. { \
  102. if ((Level >= ndisDebugLevel) && \
  103. ((ndisDebugSystems & Component) == Component)) \
  104. { \
  105. ndisDbgPrintUnicodeString(UString); \
  106. } \
  107. }
  108. #define DBGBREAK(Component, Level) \
  109. { \
  110. if ((Level >= ndisDebugLevel) && ((ndisDebugSystems & Component) == Component)) \
  111. { \
  112. DbgPrint("***NDIS*** DbgBreak @ %x, %d\n", \
  113. MODULE_NUMBER, __LINE__); \
  114. DbgBreakPoint(); \
  115. } \
  116. }
  117. #define IF_DBG(Component, Level) if ((Level >= ndisDebugLevel) && ((ndisDebugSystems & Component) == Component))
  118. #define DbgIsNonPaged(_Address) (MmIsNonPagedSystemAddressValid((PVOID)(_Address)))
  119. #define DbgIsPacket(_Packet) \
  120. ((((PNDIS_PKT_POOL)((_Packet)->Private.Pool))->PacketLength) > sizeof(_Packet))
  121. #define DbgIsNull(_Ptr) ( ((PVOID)(_Ptr)) == NULL )
  122. #else
  123. #define DBGPRINT(Component, Level, Fmt)
  124. #define DBGPRINT_RAW(Component, Level, Fmt)
  125. #define DBGPRINT_UNICODE(Component, Level, UString)
  126. #define DBGBREAK(Component, Level)
  127. #define DbgIsNonPaged(_Address) TRUE
  128. #define DbgIsPacket(_Packet) TRUE
  129. #define DbgIsNull(_Ptr) FALSE
  130. #define IF_DBG(Component, Level) if (FALSE)
  131. #define ndisDbgPrintUnicodeString(UnicodeString)
  132. #endif // DBG
  133. #ifdef TRACK_MOPEN_REFCOUNTS
  134. //
  135. // Declarations for ndis' logfile.
  136. // The purpose of the logfile is to log events
  137. // relating to the increments and decrements of an mopen's
  138. // refcounts.
  139. //
  140. //
  141. // The Ndis Logfile's size is fixed at 0x10000 and the index
  142. // is of type ushort. This ensures that the logfile always stays
  143. // within its prescribed limits
  144. //
  145. #define NDIS_LOGFILE_SIZE 0x10000
  146. //
  147. // NdisLogfile Events
  148. //
  149. #define NDIS_INCREMENT_M_OPEN_REFCOUNT 0x0101
  150. #define NDIS_DECREMENT_M_OPEN_REFCOUNT 0x0102
  151. #define NDIS_INCREMENT_OPEN_AF_NOTIFICATION 0xAF01
  152. #define NDIS_DECREMENT_OPEN_AF_NOTIFICATION 0xAF02
  153. /*
  154. VOID
  155. NDIS_APPEND_MOPEN_LOGFILE(
  156. IN USHORT EventCode,
  157. IN USHORT LineNumber,
  158. IN UINT ModuleNumber,
  159. IN UINT Arg1,
  160. IN UINT Arg2
  161. );
  162. */
  163. #define NDIS_APPEND_MOPEN_LOGFILE( _Ev, _L, _M, _A1, _A2) \
  164. ndisLogfile[ndisLogfileIndex++] = (ULONG_PTR)(_Ev); \
  165. ndisLogfile[ndisLogfileIndex++] = (ULONG_PTR)((_M) | (_L)); \
  166. ndisLogfile[ndisLogfileIndex++] = (ULONG_PTR)_A1; \
  167. ndisLogfile[ndisLogfileIndex++] = (ULONG_PTR)_A2;
  168. #else // TRACK_MOPEN_REFCOUNTS
  169. #define NDIS_APPEND_MOPEN_LOGFILE( _Ev, _L, _M, _A1, _A2)
  170. #endif // TRACK_MOPEN_REFCOUNTS
  171. #ifdef TRACK_MINIPORT_REFCOUNTS
  172. //
  173. // Declarations for ndis' logfile.
  174. // The purpose of the logfile is to log events
  175. // relating to the increments and decrements of a miniport's
  176. // refcounts.
  177. //
  178. //
  179. // The Ndis Logfile's size is fixed at 0x10000 and the index
  180. // is of type ushort. This ensures that the logfile always stays
  181. // within its prescribed limits
  182. //
  183. #define NDIS_MINIPORT_LOGFILE_SIZE 0x10000
  184. //
  185. // NdisLogfile Events
  186. //
  187. #define NDIS_INCREMENT_MINIPORT_REFCOUNT 0x0101
  188. #define NDIS_DECREMENT_MINIPORT_REFCOUNT 0x0102
  189. #define NDIS_SET_MINIPORT_REFCOUNT 0x0103
  190. /*
  191. VOID
  192. NDIS_APPEND_MINIPORT_LOGFILE( USHORT EventCode,
  193. USHORT LineNumber,
  194. UINT ModuleNumber,
  195. UINT Arg1,
  196. UINT Arg2 );
  197. */
  198. #define NDIS_APPEND_MINIPORT_LOGFILE( _Ev, _L, _Mo, _Mi, _R) \
  199. ndisMiniportLogfile[ndisMiniportLogfileIndex++] = (UINT)(_Ev); \
  200. ndisMiniportLogfile[ndisMiniportLogfileIndex++] = (UINT)((_Mo) | (_L)); \
  201. ndisMiniportLogfile[ndisMiniportLogfileIndex++] = (UINT)(_Mi); \
  202. ndisMiniportLogfile[ndisMiniportLogfileIndex++] = (UINT)(_R);
  203. #define M_LOG_MINIPORT_INCREMENT_REF(_Mi, _L, _Mo) \
  204. NDIS_APPEND_MINIPORT_LOGFILE(NDIS_INCREMENT_MINIPORT_REFCOUNT, \
  205. _L, \
  206. _Mo, \
  207. (_Mi), \
  208. (_Mi)->Ref.ReferenceCount);
  209. #define M_LOG_MINIPORT_INCREMENT_REF_CREATE(_Mi, _L, _Mo) \
  210. NDIS_APPEND_MINIPORT_LOGFILE(IoGetCurrentProcess(), \
  211. _L, \
  212. _Mo, \
  213. (_Mi), \
  214. (_Mi)->Ref.ReferenceCount);
  215. #define M_LOG_MINIPORT_DECREMENT_REF(_Mi, _R) \
  216. NDIS_APPEND_MINIPORT_LOGFILE(NDIS_DECREMENT_MINIPORT_REFCOUNT, \
  217. __LINE__, \
  218. MODULE_NUMBER, \
  219. (_Mi), \
  220. (_R));
  221. #define M_LOG_MINIPORT_DECREMENT_REF_CLOSE(_Mi, _R) \
  222. NDIS_APPEND_MINIPORT_LOGFILE(IoGetCurrentProcess(), \
  223. __LINE__, \
  224. MODULE_NUMBER, \
  225. (_Mi), \
  226. (_R));
  227. #define M_LOG_MINIPORT_SET_REF(_Mi, _R) \
  228. NDIS_APPEND_MINIPORT_LOGFILE(NDIS_SET_MINIPORT_REFCOUNT, \
  229. __LINE__, \
  230. MODULE_NUMBER, \
  231. (_Mi), \
  232. (_R));
  233. #else // TRACK_MINIPORT_REFCOUNTS
  234. #define M_LOG_MINIPORT_INCREMENT_REF(_Mi, _L, _Mo)
  235. #define M_LOG_MINIPORT_INCREMENT_REF_CREATE(_Mi, _L, _Mo)
  236. #define M_LOG_MINIPORT_DECREMENT_REF(_M, _R)
  237. #define M_LOG_MINIPORT_DECREMENT_REF_CLOSE(_Mi, _R)
  238. #define M_LOG_MINIPORT_SET_REF(_M, _R)
  239. #endif // TRACK_MINIPORT_REFCOUNTS
  240. #ifdef TRACK_RECEIVED_PACKETS
  241. //
  242. // The Ndis Received Logfile's size is fixed at 0x10000 and the index
  243. // is of type ushort. This ensures that the logfile always stays
  244. // within its prescribed limits
  245. //
  246. #define NDIS_RCV_LOGFILE_SIZE 0x10000
  247. /*
  248. VOID
  249. NDIS_APPEND_RCV_LOGFILE(PVOID Packet,
  250. PVOID Miniport,
  251. PVOID CurrentThread,
  252. ULONG Code,
  253. ULONG StackLocation,
  254. ULONG Ref,
  255. ULONG XRef,
  256. ULONG Status
  257. );
  258. */
  259. #define NDIS_APPEND_RCV_LOGFILE(_PACKET, _MINIPORT, _THREAD, _CODE, _SP, _REF, _XREF, _STATUS) \
  260. ndisRcvLogfile[ndisRcvLogfileIndex++] = (UINT)(_PACKET); \
  261. ndisRcvLogfile[ndisRcvLogfileIndex++] = (UINT)(_MINIPORT); \
  262. ndisRcvLogfile[ndisRcvLogfileIndex++] = (UINT)(_THREAD); \
  263. ndisRcvLogfile[ndisRcvLogfileIndex++] = (UINT)((_CODE<<24)|((_SP&0xff)<<16)|((_REF&0xf)<<12)|(_XREF<<8)|(_STATUS&0xff));
  264. // ndisRcvLogfile[ndisRcvLogfileIndex++] = (UINT)((_Mo) | (_L)); \
  265. // ndisRcvLogfile[ndisRcvLogfileIndex++] = (UINT)((_SP<<24)|((_REF&0xff)<<16)|(_XREF<<8)|(_Status&0xff));
  266. #else // TRACK_MINIPORT_REFCOUNTS
  267. #define NDIS_APPEND_RCV_LOGFILE( _P, _L, _Mo, _SP, _REF, _XREF, _Status, _Arg1)
  268. #endif // TRACK_RECEIVED_PACKETS
  269. #endif // __DEBUG_H