Leaked source code of windows server 2003
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.

344 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 DbgIsNull(_Ptr) ( ((PVOID)(_Ptr)) == NULL )
  120. #else
  121. #define DBGPRINT(Component, Level, Fmt)
  122. #define DBGPRINT_RAW(Component, Level, Fmt)
  123. #define DBGPRINT_UNICODE(Component, Level, UString)
  124. #define DBGBREAK(Component, Level)
  125. #define DbgIsNonPaged(_Address) TRUE
  126. #define DbgIsNull(_Ptr) FALSE
  127. #define IF_DBG(Component, Level) if (FALSE)
  128. #define ndisDbgPrintUnicodeString(UnicodeString)
  129. #endif // DBG
  130. #ifdef TRACK_MOPEN_REFCOUNTS
  131. //
  132. // Declarations for ndis' logfile.
  133. // The purpose of the logfile is to log events
  134. // relating to the increments and decrements of an mopen's
  135. // refcounts.
  136. //
  137. //
  138. // The Ndis Logfile's size is fixed at 0x10000 and the index
  139. // is of type ushort. This ensures that the logfile always stays
  140. // within its prescribed limits
  141. //
  142. #define NDIS_LOGFILE_SIZE 0x10000
  143. //
  144. // NdisLogfile Events
  145. //
  146. #define NDIS_INCREMENT_M_OPEN_REFCOUNT 0x0101
  147. #define NDIS_DECREMENT_M_OPEN_REFCOUNT 0x0102
  148. #define NDIS_INCREMENT_OPEN_AF_NOTIFICATION 0xAF01
  149. #define NDIS_DECREMENT_OPEN_AF_NOTIFICATION 0xAF02
  150. /*
  151. VOID
  152. NDIS_APPEND_MOPEN_LOGFILE(
  153. IN USHORT EventCode,
  154. IN USHORT LineNumber,
  155. IN UINT ModuleNumber,
  156. IN UINT Arg1,
  157. IN UINT Arg2
  158. );
  159. */
  160. #define NDIS_APPEND_MOPEN_LOGFILE( _Ev, _L, _M, _A1, _A2) \
  161. ndisLogfile[ndisLogfileIndex++] = (ULONG_PTR)(_Ev); \
  162. ndisLogfile[ndisLogfileIndex++] = (ULONG_PTR)((_M) | (_L)); \
  163. ndisLogfile[ndisLogfileIndex++] = (ULONG_PTR)_A1; \
  164. ndisLogfile[ndisLogfileIndex++] = (ULONG_PTR)_A2;
  165. #else // TRACK_MOPEN_REFCOUNTS
  166. #define NDIS_APPEND_MOPEN_LOGFILE( _Ev, _L, _M, _A1, _A2)
  167. #endif // TRACK_MOPEN_REFCOUNTS
  168. #ifdef TRACK_MINIPORT_REFCOUNTS
  169. //
  170. // Declarations for ndis' logfile.
  171. // The purpose of the logfile is to log events
  172. // relating to the increments and decrements of a miniport's
  173. // refcounts.
  174. //
  175. //
  176. // The Ndis Logfile's size is fixed at 0x10000 and the index
  177. // is of type ushort. This ensures that the logfile always stays
  178. // within its prescribed limits
  179. //
  180. #define NDIS_MINIPORT_LOGFILE_SIZE 0x10000
  181. //
  182. // NdisLogfile Events
  183. //
  184. #define NDIS_INCREMENT_MINIPORT_REFCOUNT 0x0101
  185. #define NDIS_DECREMENT_MINIPORT_REFCOUNT 0x0102
  186. #define NDIS_SET_MINIPORT_REFCOUNT 0x0103
  187. /*
  188. VOID
  189. NDIS_APPEND_MINIPORT_LOGFILE( USHORT EventCode,
  190. USHORT LineNumber,
  191. UINT ModuleNumber,
  192. UINT Arg1,
  193. UINT Arg2 );
  194. */
  195. #define NDIS_APPEND_MINIPORT_LOGFILE( _Ev, _L, _Mo, _Mi, _R) \
  196. ndisMiniportLogfile[ndisMiniportLogfileIndex++] = (ULONG_PTR)(_Ev); \
  197. ndisMiniportLogfile[ndisMiniportLogfileIndex++] = (ULONG_PTR)((_Mo) | (_L)); \
  198. ndisMiniportLogfile[ndisMiniportLogfileIndex++] = (ULONG_PTR)(_Mi); \
  199. ndisMiniportLogfile[ndisMiniportLogfileIndex++] = (ULONG_PTR)(_R);
  200. #define M_LOG_MINIPORT_INCREMENT_REF(_Mi, _L, _Mo) \
  201. NDIS_APPEND_MINIPORT_LOGFILE(NDIS_INCREMENT_MINIPORT_REFCOUNT, \
  202. _L, \
  203. _Mo, \
  204. (_Mi), \
  205. (_Mi)->Ref.ReferenceCount);
  206. #define M_LOG_MINIPORT_INCREMENT_REF_CREATE(_Mi, _L, _Mo) \
  207. NDIS_APPEND_MINIPORT_LOGFILE(IoGetCurrentProcess(), \
  208. _L, \
  209. _Mo, \
  210. (_Mi), \
  211. (_Mi)->Ref.ReferenceCount);
  212. #define M_LOG_MINIPORT_DECREMENT_REF(_Mi, _R) \
  213. NDIS_APPEND_MINIPORT_LOGFILE(NDIS_DECREMENT_MINIPORT_REFCOUNT, \
  214. __LINE__, \
  215. MODULE_NUMBER, \
  216. (_Mi), \
  217. (_R));
  218. #define M_LOG_MINIPORT_DECREMENT_REF_CLOSE(_Mi, _R) \
  219. NDIS_APPEND_MINIPORT_LOGFILE(IoGetCurrentProcess(), \
  220. __LINE__, \
  221. MODULE_NUMBER, \
  222. (_Mi), \
  223. (_R));
  224. #define M_LOG_MINIPORT_SET_REF(_Mi, _R) \
  225. NDIS_APPEND_MINIPORT_LOGFILE(NDIS_SET_MINIPORT_REFCOUNT, \
  226. __LINE__, \
  227. MODULE_NUMBER, \
  228. (_Mi), \
  229. (_R));
  230. #else // TRACK_MINIPORT_REFCOUNTS
  231. #define M_LOG_MINIPORT_INCREMENT_REF(_Mi, _L, _Mo)
  232. #define M_LOG_MINIPORT_INCREMENT_REF_CREATE(_Mi, _L, _Mo)
  233. #define M_LOG_MINIPORT_DECREMENT_REF(_M, _R)
  234. #define M_LOG_MINIPORT_DECREMENT_REF_CLOSE(_Mi, _R)
  235. #define M_LOG_MINIPORT_SET_REF(_M, _R)
  236. #endif // TRACK_MINIPORT_REFCOUNTS
  237. #ifdef TRACK_RECEIVED_PACKETS
  238. //
  239. // The Ndis Received Logfile's size is fixed at 0x10000 and the index
  240. // is of type ushort. This ensures that the logfile always stays
  241. // within its prescribed limits
  242. //
  243. #define NDIS_RCV_LOGFILE_SIZE 0x10000
  244. /*
  245. VOID
  246. NDIS_APPEND_RCV_LOGFILE(PVOID Packet,
  247. PVOID Miniport,
  248. PVOID CurrentThread,
  249. ULONG Code,
  250. ULONG StackLocation,
  251. ULONG Ref,
  252. ULONG XRef,
  253. ULONG Status
  254. );
  255. */
  256. #define NDIS_APPEND_RCV_LOGFILE(_PACKET, _MINIPORT, _THREAD, _CODE, _SP, _REF, _XREF, _STATUS) \
  257. ndisRcvLogfile[ndisRcvLogfileIndex++] = (UINT)(_PACKET); \
  258. ndisRcvLogfile[ndisRcvLogfileIndex++] = (UINT)(_MINIPORT); \
  259. ndisRcvLogfile[ndisRcvLogfileIndex++] = (UINT)(_THREAD); \
  260. ndisRcvLogfile[ndisRcvLogfileIndex++] = (UINT)((_CODE<<24)|((_SP&0xff)<<16)|((_REF&0xf)<<12)|(_XREF<<8)|(_STATUS&0xff));
  261. // ndisRcvLogfile[ndisRcvLogfileIndex++] = (UINT)((_Mo) | (_L)); \
  262. // ndisRcvLogfile[ndisRcvLogfileIndex++] = (UINT)((_SP<<24)|((_REF&0xff)<<16)|(_XREF<<8)|(_Status&0xff));
  263. #else // TRACK_MINIPORT_REFCOUNTS
  264. #define NDIS_APPEND_RCV_LOGFILE( _P, _L, _Mo, _SP, _REF, _XREF, _Status, _Arg1)
  265. #endif // TRACK_RECEIVED_PACKETS
  266. #define DBG_LEVEL_INFO 0x00000000
  267. #define DBG_LEVEL_LOG 0x00000800
  268. #define DBG_LEVEL_WARN 0x00001000
  269. #define DBG_LEVEL_ERR 0x00002000
  270. #define DBG_LEVEL_FATAL 0x00003000
  271. #endif // __DEBUG_H