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.

3273 lines
103 KiB

  1. //
  2. // Indicate that we're building for NT. NDIS_NT is always used for
  3. // miniport builds.
  4. //
  5. #define NDIS_NT 1
  6. #if defined(NDIS_DOS)
  7. #undef NDIS_DOS
  8. #endif
  9. //
  10. // Define status codes and event log codes.
  11. //
  12. #include <ntstatus.h>
  13. #include <netevent.h>
  14. //
  15. // Define a couple of extra types.
  16. //
  17. #if !defined(_WINDEF_) // these are defined in windows.h too
  18. typedef signed int INT, *PINT;
  19. typedef unsigned int UINT, *PUINT;
  20. #endif
  21. typedef UNICODE_STRING NDIS_STRING, *PNDIS_STRING;
  22. //
  23. // Portability extentions
  24. //
  25. #define NDIS_INIT_FUNCTION(_F) alloc_text(INIT,_F)
  26. #define NDIS_PAGABLE_FUNCTION(_F) alloc_text(PAGE,_F)
  27. #define NDIS_PAGEABLE_FUNCTION(_F) alloc_text(PAGE,_F)
  28. //
  29. // This file contains the definition of an NDIS_OID as
  30. // well as #defines for all the current OID values.
  31. //
  32. //
  33. // Define NDIS_STATUS and NDIS_HANDLE here
  34. //
  35. typedef PVOID NDIS_HANDLE, *PNDIS_HANDLE;
  36. typedef int NDIS_STATUS, *PNDIS_STATUS; // note default size
  37. //
  38. // for Miniports versions 5.0 and up, provide a consistent way to match
  39. // Ndis version in their characteristics with their makefile defines
  40. //
  41. #if (!defined(NDIS_MINIPORT_MAJOR_VERSION) && !defined(NDIS_MINIPORT_MINOR_VERSION))
  42. #if (defined(NDIS51_MINIPORT))
  43. #define NDIS_MINIPORT_MAJOR_VERSION 5
  44. #define NDIS_MINIPORT_MINOR_VERSION 1
  45. #elif (defined(NDIS50_MINIPORT))
  46. #define NDIS_MINIPORT_MAJOR_VERSION 5
  47. #define NDIS_MINIPORT_MINOR_VERSION 0
  48. #endif
  49. #endif
  50. //
  51. // for protocol versions 5.0 and up, provide a consistent way to match
  52. // Ndis version in their characteristics with their makefile defines
  53. //
  54. #if (!defined(NDIS_PROTOCOL_MAJOR_VERSION) && !defined(NDIS_PROTOCOL_MINOR_VERSION))
  55. #if (defined(NDIS51))
  56. #define NDIS_PROTOCOL_MAJOR_VERSION 5
  57. #define NDIS_PROTOCOL_MINOR_VERSION 1
  58. #elif (defined(NDIS50))
  59. #define NDIS_PROTOCOL_MAJOR_VERSION 5
  60. #define NDIS_PROTOCOL_MINOR_VERSION 0
  61. #endif
  62. #endif
  63. #include <ntddndis.h>
  64. //
  65. // Ndis defines for configuration manager data structures
  66. //
  67. typedef CM_MCA_POS_DATA NDIS_MCA_POS_DATA, *PNDIS_MCA_POS_DATA;
  68. typedef CM_EISA_SLOT_INFORMATION NDIS_EISA_SLOT_INFORMATION, *PNDIS_EISA_SLOT_INFORMATION;
  69. typedef CM_EISA_FUNCTION_INFORMATION NDIS_EISA_FUNCTION_INFORMATION, *PNDIS_EISA_FUNCTION_INFORMATION;
  70. //
  71. // Define an exported function.
  72. //
  73. #if defined(NDIS_WRAPPER)
  74. #define EXPORT
  75. #else
  76. #define EXPORT DECLSPEC_IMPORT
  77. #endif
  78. //
  79. // Memory manipulation functions.
  80. //
  81. #define NdisMoveMemory(Destination, Source, Length) RtlCopyMemory(Destination, Source, Length)
  82. #define NdisZeroMemory(Destination, Length) RtlZeroMemory(Destination, Length)
  83. #define NdisEqualMemory(Source1, Source2, Length) RtlEqualMemory(Source1, Source2, Length)
  84. #define NdisFillMemory(Destination, Length, Fill) RtlFillMemory(Destination, Length, Fill)
  85. #define NdisRetrieveUlong(Destination, Source) RtlRetrieveUlong(Destination, Source)
  86. #define NdisStoreUlong(Destination, Value) RtlStoreUlong(Destination, Value)
  87. #define NDIS_STRING_CONST(x) {sizeof(L##x)-2, sizeof(L##x), L##x}
  88. //
  89. // On a RISC machine, I/O mapped memory can't be accessed with
  90. // the Rtl routines.
  91. //
  92. #if defined(_M_IX86) || defined(_M_AMD64)
  93. #define NdisMoveMappedMemory(Destination,Source,Length) RtlCopyMemory(Destination,Source,Length)
  94. #define NdisZeroMappedMemory(Destination,Length) RtlZeroMemory(Destination,Length)
  95. #elif defined(_M_IA64)
  96. #define NdisMoveMappedMemory(Destination,Source,Length) \
  97. { \
  98. PUCHAR _Src = (Source); \
  99. PUCHAR _Dest = (Destination); \
  100. PUCHAR _End = _Dest + (Length); \
  101. while (_Dest < _End) \
  102. { \
  103. *_Dest++ = *_Src++; \
  104. } \
  105. }
  106. #define NdisZeroMappedMemory(Destination,Length) \
  107. { \
  108. PUCHAR _Dest = (Destination); \
  109. PUCHAR _End = _Dest + (Length); \
  110. while (_Dest < _End) \
  111. { \
  112. *_Dest++ = 0; \
  113. } \
  114. }
  115. #endif
  116. #define NdisMoveToMappedMemory(Destination,Source,Length) \
  117. NdisMoveMappedMemory(Destination,Source,Length)
  118. #define NdisMoveFromMappedMemory(Destination,Source,Length) \
  119. NdisMoveMappedMemory(Destination,Source,Length)
  120. //
  121. // definition of the basic spin lock structure
  122. //
  123. typedef struct _NDIS_SPIN_LOCK
  124. {
  125. KSPIN_LOCK SpinLock;
  126. KIRQL OldIrql;
  127. } NDIS_SPIN_LOCK, * PNDIS_SPIN_LOCK;
  128. //
  129. // definition of the ndis event structure
  130. //
  131. typedef struct _NDIS_EVENT
  132. {
  133. KEVENT Event;
  134. } NDIS_EVENT, *PNDIS_EVENT;
  135. #pragma warning(push)
  136. #pragma warning(disable:4115) // named type definition in parenthesis
  137. typedef VOID (*NDIS_PROC)(struct _NDIS_WORK_ITEM *, PVOID);
  138. #pragma warning(pop)
  139. //
  140. // Definition of an ndis work-item
  141. //
  142. typedef struct _NDIS_WORK_ITEM
  143. {
  144. PVOID Context;
  145. NDIS_PROC Routine;
  146. UCHAR WrapperReserved[8*sizeof(PVOID)];
  147. } NDIS_WORK_ITEM, *PNDIS_WORK_ITEM;
  148. #define NdisInterruptLatched Latched
  149. #define NdisInterruptLevelSensitive LevelSensitive
  150. typedef KINTERRUPT_MODE NDIS_INTERRUPT_MODE, *PNDIS_INTERRUPT_MODE;
  151. //
  152. // Configuration definitions
  153. //
  154. //
  155. // Possible data types
  156. //
  157. typedef enum _NDIS_PARAMETER_TYPE
  158. {
  159. NdisParameterInteger,
  160. NdisParameterHexInteger,
  161. NdisParameterString,
  162. NdisParameterMultiString,
  163. NdisParameterBinary
  164. } NDIS_PARAMETER_TYPE, *PNDIS_PARAMETER_TYPE;
  165. typedef struct
  166. {
  167. USHORT Length;
  168. PVOID Buffer;
  169. } BINARY_DATA;
  170. //
  171. // To store configuration information
  172. //
  173. typedef struct _NDIS_CONFIGURATION_PARAMETER
  174. {
  175. NDIS_PARAMETER_TYPE ParameterType;
  176. union
  177. {
  178. ULONG IntegerData;
  179. NDIS_STRING StringData;
  180. BINARY_DATA BinaryData;
  181. } ParameterData;
  182. } NDIS_CONFIGURATION_PARAMETER, *PNDIS_CONFIGURATION_PARAMETER;
  183. //
  184. // Definitions for the "ProcessorType" keyword
  185. //
  186. typedef enum _NDIS_PROCESSOR_TYPE
  187. {
  188. NdisProcessorX86,
  189. NdisProcessorMips,
  190. NdisProcessorAlpha,
  191. NdisProcessorPpc,
  192. NdisProcessorAmd64
  193. } NDIS_PROCESSOR_TYPE, *PNDIS_PROCESSOR_TYPE;
  194. //
  195. // Definitions for the "Environment" keyword
  196. //
  197. typedef enum _NDIS_ENVIRONMENT_TYPE
  198. {
  199. NdisEnvironmentWindows,
  200. NdisEnvironmentWindowsNt
  201. } NDIS_ENVIRONMENT_TYPE, *PNDIS_ENVIRONMENT_TYPE;
  202. //
  203. // Possible Hardware Architecture. Define these to
  204. // match the HAL INTERFACE_TYPE enum.
  205. //
  206. typedef enum _NDIS_INTERFACE_TYPE
  207. {
  208. NdisInterfaceInternal = Internal,
  209. NdisInterfaceIsa = Isa,
  210. NdisInterfaceEisa = Eisa,
  211. NdisInterfaceMca = MicroChannel,
  212. NdisInterfaceTurboChannel = TurboChannel,
  213. NdisInterfacePci = PCIBus,
  214. NdisInterfacePcMcia = PCMCIABus,
  215. NdisInterfaceCBus = CBus,
  216. NdisInterfaceMPIBus = MPIBus,
  217. NdisInterfaceMPSABus = MPSABus,
  218. NdisInterfaceProcessorInternal = ProcessorInternal,
  219. NdisInterfaceInternalPowerBus = InternalPowerBus,
  220. NdisInterfacePNPISABus = PNPISABus,
  221. NdisInterfacePNPBus = PNPBus,
  222. NdisMaximumInterfaceType
  223. } NDIS_INTERFACE_TYPE, *PNDIS_INTERFACE_TYPE;
  224. //
  225. // Definition for shutdown handler
  226. //
  227. typedef
  228. VOID
  229. (*ADAPTER_SHUTDOWN_HANDLER) (
  230. IN PVOID ShutdownContext
  231. );
  232. //
  233. // Stuff for PCI configuring
  234. //
  235. typedef CM_PARTIAL_RESOURCE_LIST NDIS_RESOURCE_LIST, *PNDIS_RESOURCE_LIST;
  236. //
  237. // The structure passed up on a WAN_LINE_UP indication
  238. //
  239. typedef struct _NDIS_WAN_LINE_UP
  240. {
  241. IN ULONG LinkSpeed; // 100 bps units
  242. IN ULONG MaximumTotalSize; // suggested max for send packets
  243. IN NDIS_WAN_QUALITY Quality;
  244. IN USHORT SendWindow; // suggested by the MAC
  245. IN UCHAR RemoteAddress[6];
  246. IN OUT UCHAR LocalAddress[6];
  247. IN ULONG ProtocolBufferLength; // Length of protocol info buffer
  248. IN PUCHAR ProtocolBuffer; // Information used by protocol
  249. IN USHORT ProtocolType; // Protocol ID
  250. IN OUT NDIS_STRING DeviceName;
  251. } NDIS_WAN_LINE_UP, *PNDIS_WAN_LINE_UP;
  252. //
  253. // The structure passed up on a WAN_LINE_DOWN indication
  254. //
  255. typedef struct _NDIS_WAN_LINE_DOWN
  256. {
  257. IN UCHAR RemoteAddress[6];
  258. IN UCHAR LocalAddress[6];
  259. } NDIS_WAN_LINE_DOWN, *PNDIS_WAN_LINE_DOWN;
  260. //
  261. // The structure passed up on a WAN_FRAGMENT indication
  262. //
  263. typedef struct _NDIS_WAN_FRAGMENT
  264. {
  265. IN UCHAR RemoteAddress[6];
  266. IN UCHAR LocalAddress[6];
  267. } NDIS_WAN_FRAGMENT, *PNDIS_WAN_FRAGMENT;
  268. //
  269. // The structure passed up on a WAN_GET_STATS indication
  270. //
  271. typedef struct _NDIS_WAN_GET_STATS
  272. {
  273. IN UCHAR LocalAddress[6];
  274. OUT ULONG BytesSent;
  275. OUT ULONG BytesRcvd;
  276. OUT ULONG FramesSent;
  277. OUT ULONG FramesRcvd;
  278. OUT ULONG CRCErrors; // Serial-like info only
  279. OUT ULONG TimeoutErrors; // Serial-like info only
  280. OUT ULONG AlignmentErrors; // Serial-like info only
  281. OUT ULONG SerialOverrunErrors; // Serial-like info only
  282. OUT ULONG FramingErrors; // Serial-like info only
  283. OUT ULONG BufferOverrunErrors; // Serial-like info only
  284. OUT ULONG BytesTransmittedUncompressed; // Compression info only
  285. OUT ULONG BytesReceivedUncompressed; // Compression info only
  286. OUT ULONG BytesTransmittedCompressed; // Compression info only
  287. OUT ULONG BytesReceivedCompressed; // Compression info only
  288. } NDIS_WAN_GET_STATS, *PNDIS_WAN_GET_STATS;
  289. //
  290. // DMA Channel information
  291. //
  292. typedef struct _NDIS_DMA_DESCRIPTION
  293. {
  294. BOOLEAN DemandMode;
  295. BOOLEAN AutoInitialize;
  296. BOOLEAN DmaChannelSpecified;
  297. DMA_WIDTH DmaWidth;
  298. DMA_SPEED DmaSpeed;
  299. ULONG DmaPort;
  300. ULONG DmaChannel;
  301. } NDIS_DMA_DESCRIPTION, *PNDIS_DMA_DESCRIPTION;
  302. //
  303. // Internal structure representing an NDIS DMA channel
  304. //
  305. typedef struct _NDIS_DMA_BLOCK
  306. {
  307. PVOID MapRegisterBase;
  308. KEVENT AllocationEvent;
  309. PVOID SystemAdapterObject;
  310. PVOID Miniport;
  311. BOOLEAN InProgress;
  312. } NDIS_DMA_BLOCK, *PNDIS_DMA_BLOCK;
  313. #if defined(NDIS_WRAPPER)
  314. //
  315. // definitions for PnP state
  316. //
  317. typedef enum _NDIS_PNP_DEVICE_STATE
  318. {
  319. NdisPnPDeviceAdded,
  320. NdisPnPDeviceStarted,
  321. NdisPnPDeviceQueryStopped,
  322. NdisPnPDeviceStopped,
  323. NdisPnPDeviceQueryRemoved,
  324. NdisPnPDeviceRemoved,
  325. NdisPnPDeviceSurpriseRemoved
  326. } NDIS_PNP_DEVICE_STATE;
  327. //
  328. // flags to use in PnPCapabilities Flag
  329. //
  330. #define NDIS_DEVICE_NOT_STOPPABLE 0x00000001 // the debvice is not stoppable i.e. ISA
  331. #define NDIS_DEVICE_NOT_REMOVEABLE 0x00000002 // the device can not be safely removed
  332. #define NDIS_DEVICE_NOT_SUSPENDABLE 0x00000004 // the device can not be safely suspended
  333. #define NDIS_DEVICE_DISABLE_PM 0x00000008 // disable all PM features
  334. #define NDIS_DEVICE_DISABLE_WAKE_UP 0x00000010 // disable device waking up the system
  335. #define NDIS_DEVICE_DISABLE_WAKE_ON_RECONNECT 0x00000020 // disable device waking up the -system- due to a cable re-connect
  336. #define NDIS_DEVICE_RESERVED 0x00000040 // should not be used
  337. #define NDIS_DEVICE_DISABLE_WAKE_ON_MAGIC_PACKET 0x00000080 // disable device waking up the -system- due to a magic packet
  338. #define NDIS_DEVICE_DISABLE_WAKE_ON_PATTERN_MATCH 0x00000100 // disable device waking up the -system- due to a pattern match
  339. #endif // NDIS_WRAPPER defined
  340. //
  341. // Ndis Buffer is actually an Mdl
  342. //
  343. typedef MDL NDIS_BUFFER, *PNDIS_BUFFER;
  344. struct _NDIS_PACKET;
  345. typedef NDIS_HANDLE PNDIS_PACKET_POOL;
  346. //
  347. //
  348. // wrapper-specific part of a packet
  349. //
  350. typedef struct _NDIS_PACKET_PRIVATE
  351. {
  352. UINT PhysicalCount; // number of physical pages in packet.
  353. UINT TotalLength; // Total amount of data in the packet.
  354. PNDIS_BUFFER Head; // first buffer in the chain
  355. PNDIS_BUFFER Tail; // last buffer in the chain
  356. // if Head is NULL the chain is empty; Tail doesn't have to be NULL also
  357. PNDIS_PACKET_POOL Pool; // so we know where to free it back to
  358. UINT Count;
  359. ULONG Flags;
  360. BOOLEAN ValidCounts;
  361. UCHAR NdisPacketFlags; // See fPACKET_xxx bits below
  362. USHORT NdisPacketOobOffset;
  363. } NDIS_PACKET_PRIVATE, * PNDIS_PACKET_PRIVATE;
  364. //
  365. // The bits define the bits in the Flags
  366. //
  367. #define NDIS_FLAGS_PROTOCOL_ID_MASK 0x0000000F // The low 4 bits are defined for protocol-id
  368. // The values are defined in ntddndis.h
  369. #define NDIS_FLAGS_MULTICAST_PACKET 0x00000010 // don't use
  370. #define NDIS_FLAGS_RESERVED2 0x00000020 // don't use
  371. #define NDIS_FLAGS_RESERVED3 0x00000040 // don't use
  372. #define NDIS_FLAGS_DONT_LOOPBACK 0x00000080 // Write only
  373. #define NDIS_FLAGS_IS_LOOPBACK_PACKET 0x00000100 // Read only
  374. #define NDIS_FLAGS_LOOPBACK_ONLY 0x00000200 // Write only
  375. #define NDIS_FLAGS_RESERVED4 0x00000400 // don't use
  376. #define NDIS_FLAGS_DOUBLE_BUFFERED 0x00000800 // used by ndis
  377. #define NDIS_FLAGS_SENT_AT_DPC 0x00001000 // the protocol sent this packet at DPC
  378. #define NDIS_FLAGS_USES_SG_BUFFER_LIST 0x00002000 // used by Ndis
  379. #define NDIS_FLAGS_CONTAINS_ARCNET_HEADER 0x00004000 // used by Ndis
  380. //
  381. // Low-bits in the NdisPacketFlags are reserved by NDIS Wrapper for internal use
  382. //
  383. #define fPACKET_WRAPPER_RESERVED 0x3F
  384. #define fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO 0x40
  385. #define fPACKET_ALLOCATED_BY_NDIS 0x80
  386. //
  387. // Definition for layout of the media-specific data. More than one class of media-specific
  388. // information can be tagged onto a packet.
  389. //
  390. typedef enum _NDIS_CLASS_ID
  391. {
  392. NdisClass802_3Priority,
  393. NdisClassWirelessWanMbxMailbox,
  394. NdisClassIrdaPacketInfo,
  395. NdisClassAtmAALInfo
  396. } NDIS_CLASS_ID;
  397. typedef struct _MEDIA_SPECIFIC_INFORMATION
  398. {
  399. UINT NextEntryOffset;
  400. NDIS_CLASS_ID ClassId;
  401. UINT Size;
  402. UCHAR ClassInformation[1];
  403. } MEDIA_SPECIFIC_INFORMATION, *PMEDIA_SPECIFIC_INFORMATION;
  404. typedef struct _NDIS_PACKET_OOB_DATA
  405. {
  406. union
  407. {
  408. ULONGLONG TimeToSend;
  409. ULONGLONG TimeSent;
  410. };
  411. ULONGLONG TimeReceived;
  412. UINT HeaderSize;
  413. UINT SizeMediaSpecificInfo;
  414. PVOID MediaSpecificInformation;
  415. NDIS_STATUS Status;
  416. } NDIS_PACKET_OOB_DATA, *PNDIS_PACKET_OOB_DATA;
  417. #define NDIS_GET_PACKET_PROTOCOL_TYPE(_Packet_) ((_Packet_)->Private.Flags & NDIS_PROTOCOL_ID_MASK)
  418. #define NDIS_OOB_DATA_FROM_PACKET(_p) \
  419. (PNDIS_PACKET_OOB_DATA)((PUCHAR)(_p) + \
  420. (_p)->Private.NdisPacketOobOffset)
  421. #define NDIS_GET_PACKET_HEADER_SIZE(_Packet) \
  422. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  423. (_Packet)->Private.NdisPacketOobOffset))->HeaderSize
  424. #define NDIS_GET_PACKET_STATUS(_Packet) \
  425. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  426. (_Packet)->Private.NdisPacketOobOffset))->Status
  427. #define NDIS_GET_PACKET_TIME_TO_SEND(_Packet) \
  428. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  429. (_Packet)->Private.NdisPacketOobOffset))->TimeToSend
  430. #define NDIS_GET_PACKET_TIME_SENT(_Packet) \
  431. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  432. (_Packet)->Private.NdisPacketOobOffset))->TimeSent
  433. #define NDIS_GET_PACKET_TIME_RECEIVED(_Packet) \
  434. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  435. (_Packet)->Private.NdisPacketOobOffset))->TimeReceived
  436. #define NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO(_Packet, \
  437. _pMediaSpecificInfo, \
  438. _pSizeMediaSpecificInfo) \
  439. { \
  440. if (!((_Packet)->Private.NdisPacketFlags & fPACKET_ALLOCATED_BY_NDIS) ||\
  441. !((_Packet)->Private.NdisPacketFlags & fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO))\
  442. { \
  443. *(_pMediaSpecificInfo) = NULL; \
  444. *(_pSizeMediaSpecificInfo) = 0; \
  445. } \
  446. else \
  447. { \
  448. *(_pMediaSpecificInfo) =((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +\
  449. (_Packet)->Private.NdisPacketOobOffset))->MediaSpecificInformation;\
  450. *(_pSizeMediaSpecificInfo) = ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +\
  451. (_Packet)->Private.NdisPacketOobOffset))->SizeMediaSpecificInfo;\
  452. } \
  453. }
  454. #define NDIS_SET_PACKET_HEADER_SIZE(_Packet, _HdrSize) \
  455. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  456. (_Packet)->Private.NdisPacketOobOffset))->HeaderSize = (_HdrSize)
  457. #define NDIS_SET_PACKET_STATUS(_Packet, _Status) \
  458. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  459. (_Packet)->Private.NdisPacketOobOffset))->Status = (_Status)
  460. #define NDIS_SET_PACKET_TIME_TO_SEND(_Packet, _TimeToSend) \
  461. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  462. (_Packet)->Private.NdisPacketOobOffset))->TimeToSend = (_TimeToSend)
  463. #define NDIS_SET_PACKET_TIME_SENT(_Packet, _TimeSent) \
  464. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  465. (_Packet)->Private.NdisPacketOobOffset))->TimeSent = (_TimeSent)
  466. #define NDIS_SET_PACKET_TIME_RECEIVED(_Packet, _TimeReceived) \
  467. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  468. (_Packet)->Private.NdisPacketOobOffset))->TimeReceived = (_TimeReceived)
  469. #define NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(_Packet, \
  470. _MediaSpecificInfo, \
  471. _SizeMediaSpecificInfo) \
  472. { \
  473. if ((_Packet)->Private.NdisPacketFlags & fPACKET_ALLOCATED_BY_NDIS) \
  474. { \
  475. (_Packet)->Private.NdisPacketFlags |= fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO;\
  476. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  477. (_Packet)->Private.NdisPacketOobOffset))->MediaSpecificInformation = (_MediaSpecificInfo);\
  478. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  479. (_Packet)->Private.NdisPacketOobOffset))->SizeMediaSpecificInfo = (_SizeMediaSpecificInfo);\
  480. } \
  481. }
  482. //
  483. // packet definition
  484. //
  485. typedef struct _NDIS_PACKET
  486. {
  487. NDIS_PACKET_PRIVATE Private;
  488. union
  489. {
  490. struct // For Connection-less miniports
  491. {
  492. UCHAR MiniportReserved[2*sizeof(PVOID)];
  493. UCHAR WrapperReserved[2*sizeof(PVOID)];
  494. };
  495. struct
  496. {
  497. //
  498. // For de-serialized miniports. And by implication conn-oriented miniports.
  499. //
  500. UCHAR MiniportReservedEx[3*sizeof(PVOID)];
  501. UCHAR WrapperReservedEx[sizeof(PVOID)];
  502. };
  503. struct
  504. {
  505. UCHAR MacReserved[4*sizeof(PVOID)];
  506. };
  507. };
  508. ULONG_PTR Reserved[2]; // For compatibility with Win95
  509. UCHAR ProtocolReserved[1];
  510. } NDIS_PACKET, *PNDIS_PACKET, **PPNDIS_PACKET;
  511. //
  512. // NDIS per-packet information.
  513. //
  514. typedef enum _NDIS_PER_PACKET_INFO
  515. {
  516. TcpIpChecksumPacketInfo,
  517. IpSecPacketInfo,
  518. TcpLargeSendPacketInfo,
  519. ClassificationHandlePacketInfo,
  520. NdisReserved,
  521. ScatterGatherListPacketInfo,
  522. Ieee8021QInfo,
  523. OriginalPacketInfo,
  524. PacketCancelId,
  525. MaxPerPacketInfo
  526. } NDIS_PER_PACKET_INFO, *PNDIS_PER_PACKET_INFO;
  527. typedef struct _NDIS_PACKET_EXTENSION
  528. {
  529. PVOID NdisPacketInfo[MaxPerPacketInfo];
  530. } NDIS_PACKET_EXTENSION, *PNDIS_PACKET_EXTENSION;
  531. #define NDIS_PACKET_EXTENSION_FROM_PACKET(_P) ((PNDIS_PACKET_EXTENSION)((PUCHAR)(_P) + (_P)->Private.NdisPacketOobOffset + sizeof(NDIS_PACKET_OOB_DATA)))
  532. #define NDIS_PER_PACKET_INFO_FROM_PACKET(_P, _Id) ((PNDIS_PACKET_EXTENSION)((PUCHAR)(_P) + (_P)->Private.NdisPacketOobOffset + sizeof(NDIS_PACKET_OOB_DATA)))->NdisPacketInfo[(_Id)]
  533. #define NDIS_GET_ORIGINAL_PACKET(_P) NDIS_PER_PACKET_INFO_FROM_PACKET(_P, OriginalPacketInfo)
  534. #define NDIS_SET_ORIGINAL_PACKET(_P, _OP) NDIS_PER_PACKET_INFO_FROM_PACKET(_P, OriginalPacketInfo) = _OP
  535. #define NDIS_GET_PACKET_CANCEL_ID(_P) NDIS_PER_PACKET_INFO_FROM_PACKET(_P, PacketCancelId)
  536. #define NDIS_SET_PACKET_CANCEL_ID(_P, _cId) NDIS_PER_PACKET_INFO_FROM_PACKET(_P, PacketCancelId) = _cId
  537. typedef struct _NDIS_PACKET_STACK
  538. {
  539. ULONG_PTR IMReserved[2];
  540. ULONG_PTR NdisReserved[4];
  541. } NDIS_PACKET_STACK, *PNDIS_PACKET_STACK;
  542. //
  543. // Per-packet information for TcpIpChecksumPacketInfo.
  544. //
  545. typedef struct _NDIS_TCP_IP_CHECKSUM_PACKET_INFO
  546. {
  547. union
  548. {
  549. struct
  550. {
  551. ULONG NdisPacketChecksumV4:1;
  552. ULONG NdisPacketChecksumV6:1;
  553. ULONG NdisPacketTcpChecksum:1;
  554. ULONG NdisPacketUdpChecksum:1;
  555. ULONG NdisPacketIpChecksum:1;
  556. } Transmit;
  557. struct
  558. {
  559. ULONG NdisPacketTcpChecksumFailed:1;
  560. ULONG NdisPacketUdpChecksumFailed:1;
  561. ULONG NdisPacketIpChecksumFailed:1;
  562. ULONG NdisPacketTcpChecksumSucceeded:1;
  563. ULONG NdisPacketUdpChecksumSucceeded:1;
  564. ULONG NdisPacketIpChecksumSucceeded:1;
  565. ULONG NdisPacketLoopback:1;
  566. } Receive;
  567. ULONG Value;
  568. };
  569. } NDIS_TCP_IP_CHECKSUM_PACKET_INFO, *PNDIS_TCP_IP_CHECKSUM_PACKET_INFO;
  570. //
  571. // Per-packet information for Ieee8021QInfo.
  572. //
  573. typedef struct _NDIS_PACKET_8021Q_INFO
  574. {
  575. union
  576. {
  577. struct
  578. {
  579. UINT32 UserPriority:3; // 802.1p priority
  580. UINT32 CanonicalFormatId:1; // always 0
  581. UINT32 VlanId:12; // VLAN Identification
  582. UINT32 Reserved:16; // set to 0
  583. } TagHeader;
  584. PVOID Value;
  585. };
  586. } NDIS_PACKET_8021Q_INFO, *PNDIS_PACKET_8021Q_INFO;
  587. //
  588. // Old definitions, to be obsoleted.
  589. //
  590. #define Ieee8021pPriority Ieee8021QInfo
  591. typedef UINT IEEE8021PPRIORITY;
  592. #define MAX_HASHES 4
  593. #define TRUNCATED_HASH_LEN 12
  594. #define CRYPTO_SUCCESS 0
  595. #define CRYPTO_GENERIC_ERROR 1
  596. #define CRYPTO_TRANSPORT_AH_AUTH_FAILED 2
  597. #define CRYPTO_TRANSPORT_ESP_AUTH_FAILED 3
  598. #define CRYPTO_TUNNEL_AH_AUTH_FAILED 4
  599. #define CRYPTO_TUNNEL_ESP_AUTH_FAILED 5
  600. #define CRYPTO_INVALID_PACKET_SYNTAX 6
  601. #define CRYPTO_INVALID_PROTOCOL 7
  602. typedef struct _NDIS_IPSEC_PACKET_INFO
  603. {
  604. union
  605. {
  606. struct
  607. {
  608. NDIS_HANDLE OffloadHandle;
  609. NDIS_HANDLE NextOffloadHandle;
  610. } Transmit;
  611. struct
  612. {
  613. ULONG SA_DELETE_REQ:1;
  614. ULONG CRYPTO_DONE:1;
  615. ULONG NEXT_CRYPTO_DONE:1;
  616. ULONG CryptoStatus;
  617. } Receive;
  618. };
  619. } NDIS_IPSEC_PACKET_INFO, *PNDIS_IPSEC_PACKET_INFO;
  620. ///
  621. // NDIS Task Off-Load data structures.
  622. ///
  623. #define NDIS_TASK_OFFLOAD_VERSION 1
  624. //
  625. // The following defines are used in the Task field above to define
  626. // the type of task offloading necessary.
  627. //
  628. typedef enum _NDIS_TASK
  629. {
  630. TcpIpChecksumNdisTask,
  631. IpSecNdisTask,
  632. TcpLargeSendNdisTask,
  633. MaxNdisTask
  634. } NDIS_TASK, *PNDIS_TASK;
  635. typedef enum _NDIS_ENCAPSULATION
  636. {
  637. UNSPECIFIED_Encapsulation,
  638. NULL_Encapsulation,
  639. IEEE_802_3_Encapsulation,
  640. IEEE_802_5_Encapsulation,
  641. LLC_SNAP_ROUTED_Encapsulation,
  642. LLC_SNAP_BRIDGED_Encapsulation
  643. } NDIS_ENCAPSULATION;
  644. //
  645. // Encapsulation header format
  646. //
  647. typedef struct _NDIS_ENCAPSULATION_FORMAT
  648. {
  649. NDIS_ENCAPSULATION Encapsulation; // Encapsulation type
  650. struct
  651. {
  652. ULONG FixedHeaderSize:1;
  653. ULONG Reserved:31;
  654. } Flags;
  655. ULONG EncapsulationHeaderSize; // Encapsulation header size
  656. } NDIS_ENCAPSULATION_FORMAT,*PNDIS_ENCAPSULATION_FORMAT;
  657. //
  658. // OFFLOAD header structure for OID_TCP_TASK_OFFLOAD
  659. //
  660. typedef struct _NDIS_TASK_OFFLOAD_HEADER
  661. {
  662. ULONG Version; // set to NDIS_TASK_OFFLOAD_VERSION
  663. ULONG Size; // Size of this structure
  664. ULONG Reserved; // Reserved for future use
  665. ULONG OffsetFirstTask; // Offset to the first
  666. NDIS_ENCAPSULATION_FORMAT EncapsulationFormat; // Encapsulation information.
  667. // NDIS_TASK_OFFLOAD structure(s)
  668. } NDIS_TASK_OFFLOAD_HEADER, *PNDIS_TASK_OFFLOAD_HEADER;
  669. //
  670. // Task offload Structure, which follows the above header in ndis query
  671. //
  672. typedef struct _NDIS_TASK_OFFLOAD
  673. {
  674. ULONG Version; // NDIS_TASK_OFFLOAD_VERSION
  675. ULONG Size; // Size of this structure. Used for version checking.
  676. NDIS_TASK Task; // Task.
  677. ULONG OffsetNextTask; // Offset to the next NDIS_TASK_OFFLOAD
  678. ULONG TaskBufferLength; // Length of the task offload information.
  679. UCHAR TaskBuffer[1]; // The task offload information.
  680. } NDIS_TASK_OFFLOAD, *PNDIS_TASK_OFFLOAD;
  681. //
  682. // Offload structure for NDIS_TASK_TCP_IP_CHECKSUM
  683. //
  684. typedef struct _NDIS_TASK_TCP_IP_CHECKSUM
  685. {
  686. struct
  687. {
  688. ULONG IpOptionsSupported:1;
  689. ULONG TcpOptionsSupported:1;
  690. ULONG TcpChecksum:1;
  691. ULONG UdpChecksum:1;
  692. ULONG IpChecksum:1;
  693. } V4Transmit;
  694. struct
  695. {
  696. ULONG IpOptionsSupported:1;
  697. ULONG TcpOptionsSupported:1;
  698. ULONG TcpChecksum:1;
  699. ULONG UdpChecksum:1;
  700. ULONG IpChecksum:1;
  701. } V4Receive;
  702. struct
  703. {
  704. ULONG IpOptionsSupported:1;
  705. ULONG TcpOptionsSupported:1;
  706. ULONG TcpChecksum:1;
  707. ULONG UdpChecksum:1;
  708. } V6Transmit;
  709. struct
  710. {
  711. ULONG IpOptionsSupported:1;
  712. ULONG TcpOptionsSupported:1;
  713. ULONG TcpChecksum:1;
  714. ULONG UdpChecksum:1;
  715. } V6Receive;
  716. } NDIS_TASK_TCP_IP_CHECKSUM, *PNDIS_TASK_TCP_IP_CHECKSUM;
  717. //
  718. // Off-load structure for NDIS_TASK_TCP_LARGE_SEND
  719. //
  720. typedef struct _NDIS_TASK_TCP_LARGE_SEND
  721. {
  722. ULONG Version;
  723. ULONG MaxOffLoadSize;
  724. ULONG MinSegmentCount;
  725. BOOLEAN TcpOptions;
  726. BOOLEAN IpOptions;
  727. } NDIS_TASK_TCP_LARGE_SEND, *PNDIS_TASK_TCP_LARGE_SEND;
  728. typedef struct _NDIS_TASK_IPSEC
  729. {
  730. struct
  731. {
  732. ULONG AH_ESP_COMBINED;
  733. ULONG TRANSPORT_TUNNEL_COMBINED;
  734. ULONG V4_OPTIONS;
  735. ULONG RESERVED;
  736. } Supported;
  737. struct
  738. {
  739. ULONG MD5:1;
  740. ULONG SHA_1:1;
  741. ULONG Transport:1;
  742. ULONG Tunnel:1;
  743. ULONG Send:1;
  744. ULONG Receive:1;
  745. } V4AH;
  746. struct
  747. {
  748. ULONG DES:1;
  749. ULONG RESERVED:1;
  750. ULONG TRIPLE_DES:1;
  751. ULONG NULL_ESP:1;
  752. ULONG Transport:1;
  753. ULONG Tunnel:1;
  754. ULONG Send:1;
  755. ULONG Receive:1;
  756. } V4ESP;
  757. } NDIS_TASK_IPSEC, *PNDIS_TASK_IPSEC;
  758. #define IPSEC_TPT_UDPESP_ENCAPTYPE_IKE 0x00000001
  759. #define IPSEC_TUN_UDPESP_ENCAPTYPE_IKE 0x00000002
  760. #define IPSEC_TPTOVERTUN_UDPESP_ENCAPTYPE_IKE 0x00000004
  761. #define IPSEC_TPT_UDPESP_OVER_PURE_TUN_ENCAPTYPE_IKE 0x00000008
  762. #define IPSEC_TPT_UDPESP_ENCAPTYPE_OTHER 0x00000010
  763. #define IPSEC_TUN_UDPESP_ENCAPTYPE_OTHER 0x00000020
  764. #define IPSEC_TPTOVERTUN_UDPESP_ENCAPTYPE_OTHER 0x00000040
  765. #define IPSEC_TPT_UDPESP_OVER_PURE_TUN_ENCAPTYPE_OTHER 0x00000080
  766. typedef UINT IEEE8021PPRIORITY;
  767. //
  768. // WAN Packet. This is used by WAN miniports only. This is the legacy model.
  769. // Co-Ndis is the preferred model for WAN miniports
  770. //
  771. typedef struct _NDIS_WAN_PACKET
  772. {
  773. LIST_ENTRY WanPacketQueue;
  774. PUCHAR CurrentBuffer;
  775. ULONG CurrentLength;
  776. PUCHAR StartBuffer;
  777. PUCHAR EndBuffer;
  778. PVOID ProtocolReserved1;
  779. PVOID ProtocolReserved2;
  780. PVOID ProtocolReserved3;
  781. PVOID ProtocolReserved4;
  782. PVOID MacReserved1;
  783. PVOID MacReserved2;
  784. PVOID MacReserved3;
  785. PVOID MacReserved4;
  786. } NDIS_WAN_PACKET, *PNDIS_WAN_PACKET;
  787. //
  788. // Routines to get/set packet flags
  789. //
  790. /*++
  791. UINT
  792. NdisGetPacketFlags(
  793. IN PNDIS_PACKET Packet
  794. );
  795. --*/
  796. #define NdisGetPacketFlags(_Packet) (_Packet)->Private.Flags
  797. /*++
  798. VOID
  799. NdisSetPacketFlags(
  800. IN PNDIS_PACKET Packet,
  801. IN UINT Flags
  802. );
  803. --*/
  804. #define NdisSetPacketFlags(_Packet, _Flags) (_Packet)->Private.Flags |= (_Flags)
  805. #define NdisClearPacketFlags(_Packet, _Flags) (_Packet)->Private.Flags &= ~(_Flags)
  806. //
  807. // Request types used by NdisRequest; constants are added for
  808. // all entry points in the MAC, for those that want to create
  809. // their own internal requests.
  810. //
  811. typedef enum _NDIS_REQUEST_TYPE
  812. {
  813. NdisRequestQueryInformation,
  814. NdisRequestSetInformation,
  815. NdisRequestQueryStatistics,
  816. NdisRequestOpen,
  817. NdisRequestClose,
  818. NdisRequestSend,
  819. NdisRequestTransferData,
  820. NdisRequestReset,
  821. NdisRequestGeneric1,
  822. NdisRequestGeneric2,
  823. NdisRequestGeneric3,
  824. NdisRequestGeneric4
  825. } NDIS_REQUEST_TYPE, *PNDIS_REQUEST_TYPE;
  826. //
  827. // Structure of requests sent via NdisRequest
  828. //
  829. typedef struct _NDIS_REQUEST
  830. {
  831. UCHAR MacReserved[4*sizeof(PVOID)];
  832. NDIS_REQUEST_TYPE RequestType;
  833. union _DATA
  834. {
  835. struct _QUERY_INFORMATION
  836. {
  837. NDIS_OID Oid;
  838. PVOID InformationBuffer;
  839. UINT InformationBufferLength;
  840. UINT BytesWritten;
  841. UINT BytesNeeded;
  842. } QUERY_INFORMATION;
  843. struct _SET_INFORMATION
  844. {
  845. NDIS_OID Oid;
  846. PVOID InformationBuffer;
  847. UINT InformationBufferLength;
  848. UINT BytesRead;
  849. UINT BytesNeeded;
  850. } SET_INFORMATION;
  851. } DATA;
  852. #if (defined(NDIS50) || defined(NDIS51) || defined(NDIS50_MINIPORT) || defined(NDIS51_MINIPORT))
  853. UCHAR NdisReserved[9*sizeof(PVOID)];
  854. union
  855. {
  856. UCHAR CallMgrReserved[2*sizeof(PVOID)];
  857. UCHAR ProtocolReserved[2*sizeof(PVOID)];
  858. };
  859. UCHAR MiniportReserved[2*sizeof(PVOID)];
  860. #endif
  861. } NDIS_REQUEST, *PNDIS_REQUEST;
  862. //
  863. // NDIS Address Family definitions.
  864. //
  865. typedef ULONG NDIS_AF, *PNDIS_AF;
  866. #define CO_ADDRESS_FAMILY_Q2931 ((NDIS_AF)0x1) // ATM
  867. #define CO_ADDRESS_FAMILY_PSCHED ((NDIS_AF)0x2) // Packet scheduler
  868. #define CO_ADDRESS_FAMILY_L2TP ((NDIS_AF)0x3)
  869. #define CO_ADDRESS_FAMILY_IRDA ((NDIS_AF)0x4)
  870. #define CO_ADDRESS_FAMILY_1394 ((NDIS_AF)0x5)
  871. #define CO_ADDRESS_FAMILY_PPP ((NDIS_AF)0x6)
  872. #define CO_ADDRESS_FAMILY_INFINIBAND ((NDIS_AF)0x7)
  873. #define CO_ADDRESS_FAMILY_TAPI ((NDIS_AF)0x800)
  874. #define CO_ADDRESS_FAMILY_TAPI_PROXY ((NDIS_AF)0x801)
  875. //
  876. // The following is OR'ed with the base AF to denote proxy support
  877. //
  878. #define CO_ADDRESS_FAMILY_PROXY 0x80000000
  879. //
  880. // Address family structure registered/opened via
  881. // NdisCmRegisterAddressFamily
  882. // NdisClOpenAddressFamily
  883. //
  884. typedef struct
  885. {
  886. NDIS_AF AddressFamily; // one of the CO_ADDRESS_FAMILY_xxx values above
  887. ULONG MajorVersion; // the major version of call manager
  888. ULONG MinorVersion; // the minor version of call manager
  889. } CO_ADDRESS_FAMILY, *PCO_ADDRESS_FAMILY;
  890. //
  891. // Definition for a SAP
  892. //
  893. typedef struct
  894. {
  895. ULONG SapType;
  896. ULONG SapLength;
  897. UCHAR Sap[1];
  898. } CO_SAP, *PCO_SAP;
  899. //
  900. // Definitions for physical address.
  901. //
  902. typedef PHYSICAL_ADDRESS NDIS_PHYSICAL_ADDRESS, *PNDIS_PHYSICAL_ADDRESS;
  903. typedef struct _NDIS_PHYSICAL_ADDRESS_UNIT
  904. {
  905. NDIS_PHYSICAL_ADDRESS PhysicalAddress;
  906. UINT Length;
  907. } NDIS_PHYSICAL_ADDRESS_UNIT, *PNDIS_PHYSICAL_ADDRESS_UNIT;
  908. /*++
  909. ULONG
  910. NdisGetPhysicalAddressHigh(
  911. IN NDIS_PHYSICAL_ADDRESS PhysicalAddress
  912. );
  913. --*/
  914. #define NdisGetPhysicalAddressHigh(_PhysicalAddress) \
  915. ((_PhysicalAddress).HighPart)
  916. /*++
  917. VOID
  918. NdisSetPhysicalAddressHigh(
  919. IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
  920. IN ULONG Value
  921. );
  922. --*/
  923. #define NdisSetPhysicalAddressHigh(_PhysicalAddress, _Value) \
  924. ((_PhysicalAddress).HighPart) = (_Value)
  925. /*++
  926. ULONG
  927. NdisGetPhysicalAddressLow(
  928. IN NDIS_PHYSICAL_ADDRESS PhysicalAddress
  929. );
  930. --*/
  931. #define NdisGetPhysicalAddressLow(_PhysicalAddress) \
  932. ((_PhysicalAddress).LowPart)
  933. /*++
  934. VOID
  935. NdisSetPhysicalAddressLow(
  936. IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
  937. IN ULONG Value
  938. );
  939. --*/
  940. #define NdisSetPhysicalAddressLow(_PhysicalAddress, _Value) \
  941. ((_PhysicalAddress).LowPart) = (_Value)
  942. //
  943. // Macro to initialize an NDIS_PHYSICAL_ADDRESS constant
  944. //
  945. #define NDIS_PHYSICAL_ADDRESS_CONST(_Low, _High) \
  946. { (ULONG)(_Low), (LONG)(_High) }
  947. //
  948. // block used for references...
  949. //
  950. typedef struct _REFERENCE
  951. {
  952. KSPIN_LOCK SpinLock;
  953. USHORT ReferenceCount;
  954. BOOLEAN Closing;
  955. } REFERENCE, * PREFERENCE;
  956. //
  957. // block used for references using a ULONG
  958. //
  959. typedef struct _ULONG_REFERENCE
  960. {
  961. KSPIN_LOCK SpinLock;
  962. ULONG ReferenceCount;
  963. BOOLEAN Closing;
  964. } ULONG_REFERENCE, *PULONG_REFERENCE;
  965. //
  966. // Types of Memory (not mutually exclusive)
  967. //
  968. #define NDIS_MEMORY_CONTIGUOUS 0x00000001
  969. #define NDIS_MEMORY_NONCACHED 0x00000002
  970. //
  971. // Open options
  972. //
  973. #define NDIS_OPEN_RECEIVE_NOT_REENTRANT 0x00000001
  974. //
  975. // NDIS_STATUS values
  976. //
  977. #define NDIS_STATUS_SUCCESS ((NDIS_STATUS)STATUS_SUCCESS)
  978. #define NDIS_STATUS_PENDING ((NDIS_STATUS) STATUS_PENDING)
  979. #define NDIS_STATUS_NOT_RECOGNIZED ((NDIS_STATUS)0x00010001L)
  980. #define NDIS_STATUS_NOT_COPIED ((NDIS_STATUS)0x00010002L)
  981. #define NDIS_STATUS_NOT_ACCEPTED ((NDIS_STATUS)0x00010003L)
  982. #define NDIS_STATUS_CALL_ACTIVE ((NDIS_STATUS)0x00010007L)
  983. #define NDIS_STATUS_ONLINE ((NDIS_STATUS)0x40010003L)
  984. #define NDIS_STATUS_RESET_START ((NDIS_STATUS)0x40010004L)
  985. #define NDIS_STATUS_RESET_END ((NDIS_STATUS)0x40010005L)
  986. #define NDIS_STATUS_RING_STATUS ((NDIS_STATUS)0x40010006L)
  987. #define NDIS_STATUS_CLOSED ((NDIS_STATUS)0x40010007L)
  988. #define NDIS_STATUS_WAN_LINE_UP ((NDIS_STATUS)0x40010008L)
  989. #define NDIS_STATUS_WAN_LINE_DOWN ((NDIS_STATUS)0x40010009L)
  990. #define NDIS_STATUS_WAN_FRAGMENT ((NDIS_STATUS)0x4001000AL)
  991. #define NDIS_STATUS_MEDIA_CONNECT ((NDIS_STATUS)0x4001000BL)
  992. #define NDIS_STATUS_MEDIA_DISCONNECT ((NDIS_STATUS)0x4001000CL)
  993. #define NDIS_STATUS_HARDWARE_LINE_UP ((NDIS_STATUS)0x4001000DL)
  994. #define NDIS_STATUS_HARDWARE_LINE_DOWN ((NDIS_STATUS)0x4001000EL)
  995. #define NDIS_STATUS_INTERFACE_UP ((NDIS_STATUS)0x4001000FL)
  996. #define NDIS_STATUS_INTERFACE_DOWN ((NDIS_STATUS)0x40010010L)
  997. #define NDIS_STATUS_MEDIA_BUSY ((NDIS_STATUS)0x40010011L)
  998. #define NDIS_STATUS_MEDIA_SPECIFIC_INDICATION ((NDIS_STATUS)0x40010012L)
  999. #define NDIS_STATUS_WW_INDICATION NDIS_STATUS_MEDIA_SPECIFIC_INDICATION
  1000. #define NDIS_STATUS_LINK_SPEED_CHANGE ((NDIS_STATUS)0x40010013L)
  1001. #define NDIS_STATUS_WAN_GET_STATS ((NDIS_STATUS)0x40010014L)
  1002. #define NDIS_STATUS_WAN_CO_FRAGMENT ((NDIS_STATUS)0x40010015L)
  1003. #define NDIS_STATUS_WAN_CO_LINKPARAMS ((NDIS_STATUS)0x40010016L)
  1004. #define NDIS_STATUS_NOT_RESETTABLE ((NDIS_STATUS)0x80010001L)
  1005. #define NDIS_STATUS_SOFT_ERRORS ((NDIS_STATUS)0x80010003L)
  1006. #define NDIS_STATUS_HARD_ERRORS ((NDIS_STATUS)0x80010004L)
  1007. #define NDIS_STATUS_BUFFER_OVERFLOW ((NDIS_STATUS)STATUS_BUFFER_OVERFLOW)
  1008. #define NDIS_STATUS_FAILURE ((NDIS_STATUS) STATUS_UNSUCCESSFUL)
  1009. #define NDIS_STATUS_RESOURCES ((NDIS_STATUS)STATUS_INSUFFICIENT_RESOURCES)
  1010. #define NDIS_STATUS_CLOSING ((NDIS_STATUS)0xC0010002L)
  1011. #define NDIS_STATUS_BAD_VERSION ((NDIS_STATUS)0xC0010004L)
  1012. #define NDIS_STATUS_BAD_CHARACTERISTICS ((NDIS_STATUS)0xC0010005L)
  1013. #define NDIS_STATUS_ADAPTER_NOT_FOUND ((NDIS_STATUS)0xC0010006L)
  1014. #define NDIS_STATUS_OPEN_FAILED ((NDIS_STATUS)0xC0010007L)
  1015. #define NDIS_STATUS_DEVICE_FAILED ((NDIS_STATUS)0xC0010008L)
  1016. #define NDIS_STATUS_MULTICAST_FULL ((NDIS_STATUS)0xC0010009L)
  1017. #define NDIS_STATUS_MULTICAST_EXISTS ((NDIS_STATUS)0xC001000AL)
  1018. #define NDIS_STATUS_MULTICAST_NOT_FOUND ((NDIS_STATUS)0xC001000BL)
  1019. #define NDIS_STATUS_REQUEST_ABORTED ((NDIS_STATUS)0xC001000CL)
  1020. #define NDIS_STATUS_RESET_IN_PROGRESS ((NDIS_STATUS)0xC001000DL)
  1021. #define NDIS_STATUS_CLOSING_INDICATING ((NDIS_STATUS)0xC001000EL)
  1022. #define NDIS_STATUS_NOT_SUPPORTED ((NDIS_STATUS)STATUS_NOT_SUPPORTED)
  1023. #define NDIS_STATUS_INVALID_PACKET ((NDIS_STATUS)0xC001000FL)
  1024. #define NDIS_STATUS_OPEN_LIST_FULL ((NDIS_STATUS)0xC0010010L)
  1025. #define NDIS_STATUS_ADAPTER_NOT_READY ((NDIS_STATUS)0xC0010011L)
  1026. #define NDIS_STATUS_ADAPTER_NOT_OPEN ((NDIS_STATUS)0xC0010012L)
  1027. #define NDIS_STATUS_NOT_INDICATING ((NDIS_STATUS)0xC0010013L)
  1028. #define NDIS_STATUS_INVALID_LENGTH ((NDIS_STATUS)0xC0010014L)
  1029. #define NDIS_STATUS_INVALID_DATA ((NDIS_STATUS)0xC0010015L)
  1030. #define NDIS_STATUS_BUFFER_TOO_SHORT ((NDIS_STATUS)0xC0010016L)
  1031. #define NDIS_STATUS_INVALID_OID ((NDIS_STATUS)0xC0010017L)
  1032. #define NDIS_STATUS_ADAPTER_REMOVED ((NDIS_STATUS)0xC0010018L)
  1033. #define NDIS_STATUS_UNSUPPORTED_MEDIA ((NDIS_STATUS)0xC0010019L)
  1034. #define NDIS_STATUS_GROUP_ADDRESS_IN_USE ((NDIS_STATUS)0xC001001AL)
  1035. #define NDIS_STATUS_FILE_NOT_FOUND ((NDIS_STATUS)0xC001001BL)
  1036. #define NDIS_STATUS_ERROR_READING_FILE ((NDIS_STATUS)0xC001001CL)
  1037. #define NDIS_STATUS_ALREADY_MAPPED ((NDIS_STATUS)0xC001001DL)
  1038. #define NDIS_STATUS_RESOURCE_CONFLICT ((NDIS_STATUS)0xC001001EL)
  1039. #define NDIS_STATUS_NO_CABLE ((NDIS_STATUS)0xC001001FL)
  1040. #define NDIS_STATUS_INVALID_SAP ((NDIS_STATUS)0xC0010020L)
  1041. #define NDIS_STATUS_SAP_IN_USE ((NDIS_STATUS)0xC0010021L)
  1042. #define NDIS_STATUS_INVALID_ADDRESS ((NDIS_STATUS)0xC0010022L)
  1043. #define NDIS_STATUS_VC_NOT_ACTIVATED ((NDIS_STATUS)0xC0010023L)
  1044. #define NDIS_STATUS_DEST_OUT_OF_ORDER ((NDIS_STATUS)0xC0010024L) // cause 27
  1045. #define NDIS_STATUS_VC_NOT_AVAILABLE ((NDIS_STATUS)0xC0010025L) // cause 35,45
  1046. #define NDIS_STATUS_CELLRATE_NOT_AVAILABLE ((NDIS_STATUS)0xC0010026L) // cause 37
  1047. #define NDIS_STATUS_INCOMPATABLE_QOS ((NDIS_STATUS)0xC0010027L) // cause 49
  1048. #define NDIS_STATUS_AAL_PARAMS_UNSUPPORTED ((NDIS_STATUS)0xC0010028L) // cause 93
  1049. #define NDIS_STATUS_NO_ROUTE_TO_DESTINATION ((NDIS_STATUS)0xC0010029L) // cause 3
  1050. #define NDIS_STATUS_TOKEN_RING_OPEN_ERROR ((NDIS_STATUS)0xC0011000L)
  1051. #define NDIS_STATUS_INVALID_DEVICE_REQUEST ((NDIS_STATUS)STATUS_INVALID_DEVICE_REQUEST)
  1052. #define NDIS_STATUS_NETWORK_UNREACHABLE ((NDIS_STATUS)STATUS_NETWORK_UNREACHABLE)
  1053. //
  1054. // used in error logging
  1055. //
  1056. #define NDIS_ERROR_CODE ULONG
  1057. #define NDIS_ERROR_CODE_RESOURCE_CONFLICT EVENT_NDIS_RESOURCE_CONFLICT
  1058. #define NDIS_ERROR_CODE_OUT_OF_RESOURCES EVENT_NDIS_OUT_OF_RESOURCE
  1059. #define NDIS_ERROR_CODE_HARDWARE_FAILURE EVENT_NDIS_HARDWARE_FAILURE
  1060. #define NDIS_ERROR_CODE_ADAPTER_NOT_FOUND EVENT_NDIS_ADAPTER_NOT_FOUND
  1061. #define NDIS_ERROR_CODE_INTERRUPT_CONNECT EVENT_NDIS_INTERRUPT_CONNECT
  1062. #define NDIS_ERROR_CODE_DRIVER_FAILURE EVENT_NDIS_DRIVER_FAILURE
  1063. #define NDIS_ERROR_CODE_BAD_VERSION EVENT_NDIS_BAD_VERSION
  1064. #define NDIS_ERROR_CODE_TIMEOUT EVENT_NDIS_TIMEOUT
  1065. #define NDIS_ERROR_CODE_NETWORK_ADDRESS EVENT_NDIS_NETWORK_ADDRESS
  1066. #define NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION EVENT_NDIS_UNSUPPORTED_CONFIGURATION
  1067. #define NDIS_ERROR_CODE_INVALID_VALUE_FROM_ADAPTER EVENT_NDIS_INVALID_VALUE_FROM_ADAPTER
  1068. #define NDIS_ERROR_CODE_MISSING_CONFIGURATION_PARAMETER EVENT_NDIS_MISSING_CONFIGURATION_PARAMETER
  1069. #define NDIS_ERROR_CODE_BAD_IO_BASE_ADDRESS EVENT_NDIS_BAD_IO_BASE_ADDRESS
  1070. #define NDIS_ERROR_CODE_RECEIVE_SPACE_SMALL EVENT_NDIS_RECEIVE_SPACE_SMALL
  1071. #define NDIS_ERROR_CODE_ADAPTER_DISABLED EVENT_NDIS_ADAPTER_DISABLED
  1072. #if BINARY_COMPATIBLE
  1073. #if USE_KLOCKS
  1074. #define DISPATCH_LEVEL 2
  1075. #define NdisAllocateSpinLock(_SpinLock) KeInitializeSpinLock(&(_SpinLock)->SpinLock)
  1076. #define NdisFreeSpinLock(_SpinLock)
  1077. #define NdisAcquireSpinLock(_SpinLock) KeAcquireSpinLock(&(_SpinLock)->SpinLock, &(_SpinLock)->OldIrql)
  1078. #define NdisReleaseSpinLock(_SpinLock) KeReleaseSpinLock(&(_SpinLock)->SpinLock,(_SpinLock)->OldIrql)
  1079. #define NdisDprAcquireSpinLock(_SpinLock) \
  1080. { \
  1081. KeAcquireSpinLockAtDpcLevel(&(_SpinLock)->SpinLock); \
  1082. (_SpinLock)->OldIrql = DISPATCH_LEVEL; \
  1083. }
  1084. #define NdisDprReleaseSpinLock(_SpinLock) KeReleaseSpinLockFromDpcLevel(&(_SpinLock)->SpinLock)
  1085. #else
  1086. //
  1087. // Ndis Spin Locks
  1088. //
  1089. EXPORT
  1090. VOID
  1091. NdisAllocateSpinLock(
  1092. IN PNDIS_SPIN_LOCK SpinLock
  1093. );
  1094. EXPORT
  1095. VOID
  1096. NdisFreeSpinLock(
  1097. IN PNDIS_SPIN_LOCK SpinLock
  1098. );
  1099. EXPORT
  1100. VOID
  1101. NdisAcquireSpinLock(
  1102. IN PNDIS_SPIN_LOCK SpinLock
  1103. );
  1104. EXPORT
  1105. VOID
  1106. NdisReleaseSpinLock(
  1107. IN PNDIS_SPIN_LOCK SpinLock
  1108. );
  1109. EXPORT
  1110. VOID
  1111. NdisDprAcquireSpinLock(
  1112. IN PNDIS_SPIN_LOCK SpinLock
  1113. );
  1114. EXPORT
  1115. VOID
  1116. NdisDprReleaseSpinLock(
  1117. IN PNDIS_SPIN_LOCK SpinLock
  1118. );
  1119. #endif
  1120. EXPORT
  1121. VOID
  1122. NdisGetCurrentSystemTime(
  1123. PLARGE_INTEGER pSystemTime
  1124. );
  1125. //
  1126. // Interlocked support functions
  1127. //
  1128. EXPORT
  1129. LONG
  1130. NdisInterlockedIncrement(
  1131. IN PLONG Addend
  1132. );
  1133. EXPORT
  1134. LONG
  1135. NdisInterlockedDecrement(
  1136. IN PLONG Addend
  1137. );
  1138. EXPORT
  1139. VOID
  1140. NdisInterlockedAddUlong(
  1141. IN PULONG Addend,
  1142. IN ULONG Increment,
  1143. IN PNDIS_SPIN_LOCK SpinLock
  1144. );
  1145. EXPORT
  1146. PLIST_ENTRY
  1147. NdisInterlockedInsertHeadList(
  1148. IN PLIST_ENTRY ListHead,
  1149. IN PLIST_ENTRY ListEntry,
  1150. IN PNDIS_SPIN_LOCK SpinLock
  1151. );
  1152. EXPORT
  1153. PLIST_ENTRY
  1154. NdisInterlockedInsertTailList(
  1155. IN PLIST_ENTRY ListHead,
  1156. IN PLIST_ENTRY ListEntry,
  1157. IN PNDIS_SPIN_LOCK SpinLock
  1158. );
  1159. EXPORT
  1160. PLIST_ENTRY
  1161. NdisInterlockedRemoveHeadList(
  1162. IN PLIST_ENTRY ListHead,
  1163. IN PNDIS_SPIN_LOCK SpinLock
  1164. );
  1165. EXPORT
  1166. LARGE_INTEGER
  1167. NdisInterlockedAddLargeInteger(
  1168. IN PLARGE_INTEGER Addend,
  1169. IN ULONG Increment,
  1170. IN PKSPIN_LOCK Lock
  1171. );
  1172. #else // BINARY_COMPATIBLE
  1173. #define NdisAllocateSpinLock(_SpinLock) KeInitializeSpinLock(&(_SpinLock)->SpinLock)
  1174. #define NdisFreeSpinLock(_SpinLock)
  1175. #define NdisAcquireSpinLock(_SpinLock) KeAcquireSpinLock(&(_SpinLock)->SpinLock, &(_SpinLock)->OldIrql)
  1176. #define NdisReleaseSpinLock(_SpinLock) KeReleaseSpinLock(&(_SpinLock)->SpinLock,(_SpinLock)->OldIrql)
  1177. #define NdisDprAcquireSpinLock(_SpinLock) \
  1178. { \
  1179. KeAcquireSpinLockAtDpcLevel(&(_SpinLock)->SpinLock); \
  1180. (_SpinLock)->OldIrql = DISPATCH_LEVEL; \
  1181. }
  1182. #define NdisDprReleaseSpinLock(_SpinLock) KeReleaseSpinLockFromDpcLevel(&(_SpinLock)->SpinLock)
  1183. #define NdisGetCurrentSystemTime(_pSystemTime) \
  1184. { \
  1185. KeQuerySystemTime(_pSystemTime); \
  1186. }
  1187. //
  1188. // Interlocked support functions
  1189. //
  1190. #define NdisInterlockedIncrement(Addend) InterlockedIncrement(Addend)
  1191. #define NdisInterlockedDecrement(Addend) InterlockedDecrement(Addend)
  1192. #define NdisInterlockedAddUlong(_Addend, _Increment, _SpinLock) \
  1193. ExInterlockedAddUlong(_Addend, _Increment, &(_SpinLock)->SpinLock)
  1194. #define NdisInterlockedInsertHeadList(_ListHead, _ListEntry, _SpinLock) \
  1195. ExInterlockedInsertHeadList(_ListHead, _ListEntry, &(_SpinLock)->SpinLock)
  1196. #define NdisInterlockedInsertTailList(_ListHead, _ListEntry, _SpinLock) \
  1197. ExInterlockedInsertTailList(_ListHead, _ListEntry, &(_SpinLock)->SpinLock)
  1198. #define NdisInterlockedRemoveHeadList(_ListHead, _SpinLock) \
  1199. ExInterlockedRemoveHeadList(_ListHead, &(_SpinLock)->SpinLock)
  1200. #define NdisInterlockedPushEntryList(ListHead, ListEntry, Lock) \
  1201. ExInterlockedPushEntryList(ListHead, ListEntry, &(Lock)->SpinLock)
  1202. #define NdisInterlockedPopEntryList(ListHead, Lock) \
  1203. ExInterlockedPopEntryList(ListHead, &(Lock)->SpinLock)
  1204. #endif // BINARY_COMPATIBLE
  1205. #ifndef MAXIMUM_PROCESSORS
  1206. #ifdef _WIN64
  1207. #define MAXIMUM_PROCESSORS 64
  1208. #else
  1209. #define MAXIMUM_PROCESSORS 32
  1210. #endif
  1211. #endif
  1212. typedef union _NDIS_RW_LOCK_REFCOUNT
  1213. {
  1214. UINT RefCount;
  1215. UCHAR cacheLine[16]; // One refCount per cache line
  1216. } NDIS_RW_LOCK_REFCOUNT;
  1217. typedef struct _NDIS_RW_LOCK
  1218. {
  1219. union
  1220. {
  1221. struct
  1222. {
  1223. KSPIN_LOCK SpinLock;
  1224. PVOID Context;
  1225. };
  1226. UCHAR Reserved[16];
  1227. };
  1228. NDIS_RW_LOCK_REFCOUNT RefCount[MAXIMUM_PROCESSORS];
  1229. } NDIS_RW_LOCK, *PNDIS_RW_LOCK;
  1230. typedef struct _LOCK_STATE
  1231. {
  1232. USHORT LockState;
  1233. KIRQL OldIrql;
  1234. } LOCK_STATE, *PLOCK_STATE;
  1235. EXPORT
  1236. VOID
  1237. NdisInitializeReadWriteLock(
  1238. IN PNDIS_RW_LOCK Lock
  1239. );
  1240. EXPORT
  1241. VOID
  1242. NdisAcquireReadWriteLock(
  1243. IN PNDIS_RW_LOCK Lock,
  1244. IN BOOLEAN fWrite, // TRUE -> Write, FALSE -> Read
  1245. IN PLOCK_STATE LockState
  1246. );
  1247. EXPORT
  1248. VOID
  1249. NdisReleaseReadWriteLock(
  1250. IN PNDIS_RW_LOCK Lock,
  1251. IN PLOCK_STATE LockState
  1252. );
  1253. #define NdisInterlockedAddLargeStatistic(_Addend, _Increment) \
  1254. ExInterlockedAddLargeStatistic((PLARGE_INTEGER)_Addend, _Increment)
  1255. //
  1256. // S-List support
  1257. //
  1258. #define NdisInterlockedPushEntrySList(SListHead, SListEntry, Lock) \
  1259. ExInterlockedPushEntrySList(SListHead, SListEntry, &(Lock)->SpinLock)
  1260. #define NdisInterlockedPopEntrySList(SListHead, Lock) \
  1261. ExInterlockedPopEntrySList(SListHead, &(Lock)->SpinLock)
  1262. #define NdisInterlockedFlushSList(SListHead) ExInterlockedFlushSList(SListHead)
  1263. #define NdisInitializeSListHead(SListHead) ExInitializeSListHead(SListHead)
  1264. #define NdisQueryDepthSList(SListHead) ExQueryDepthSList(SListHead)
  1265. EXPORT
  1266. VOID
  1267. NdisGetCurrentProcessorCpuUsage(
  1268. OUT PULONG pCpuUsage
  1269. );
  1270. EXPORT
  1271. VOID
  1272. NdisGetCurrentProcessorCounts(
  1273. OUT PULONG pIdleCount,
  1274. OUT PULONG pKernelAndUser,
  1275. OUT PULONG pIndex
  1276. );
  1277. EXPORT
  1278. VOID
  1279. NdisGetSystemUpTime(
  1280. OUT PULONG pSystemUpTime
  1281. );
  1282. //
  1283. // List manipulation
  1284. //
  1285. /*++
  1286. VOID
  1287. NdisInitializeListHead(
  1288. IN PLIST_ENTRY ListHead
  1289. );
  1290. --*/
  1291. #define NdisInitializeListHead(_ListHead) InitializeListHead(_ListHead)
  1292. //
  1293. // Configuration Requests
  1294. //
  1295. EXPORT
  1296. VOID
  1297. NdisOpenConfiguration(
  1298. OUT PNDIS_STATUS Status,
  1299. OUT PNDIS_HANDLE ConfigurationHandle,
  1300. IN NDIS_HANDLE WrapperConfigurationContext
  1301. );
  1302. EXPORT
  1303. VOID
  1304. NdisOpenConfigurationKeyByName(
  1305. OUT PNDIS_STATUS Status,
  1306. IN NDIS_HANDLE ConfigurationHandle,
  1307. IN PNDIS_STRING SubKeyName,
  1308. OUT PNDIS_HANDLE SubKeyHandle
  1309. );
  1310. EXPORT
  1311. VOID
  1312. NdisOpenConfigurationKeyByIndex(
  1313. OUT PNDIS_STATUS Status,
  1314. IN NDIS_HANDLE ConfigurationHandle,
  1315. IN ULONG Index,
  1316. OUT PNDIS_STRING KeyName,
  1317. OUT PNDIS_HANDLE KeyHandle
  1318. );
  1319. EXPORT
  1320. VOID
  1321. NdisReadConfiguration(
  1322. OUT PNDIS_STATUS Status,
  1323. OUT PNDIS_CONFIGURATION_PARAMETER *ParameterValue,
  1324. IN NDIS_HANDLE ConfigurationHandle,
  1325. IN PNDIS_STRING Keyword,
  1326. IN NDIS_PARAMETER_TYPE ParameterType
  1327. );
  1328. EXPORT
  1329. VOID
  1330. NdisWriteConfiguration(
  1331. OUT PNDIS_STATUS Status,
  1332. IN NDIS_HANDLE ConfigurationHandle,
  1333. IN PNDIS_STRING Keyword,
  1334. IN PNDIS_CONFIGURATION_PARAMETER ParameterValue
  1335. );
  1336. EXPORT
  1337. VOID
  1338. NdisCloseConfiguration(
  1339. IN NDIS_HANDLE ConfigurationHandle
  1340. );
  1341. EXPORT
  1342. VOID
  1343. NdisReadNetworkAddress(
  1344. OUT PNDIS_STATUS Status,
  1345. OUT PVOID * NetworkAddress,
  1346. OUT PUINT NetworkAddressLength,
  1347. IN NDIS_HANDLE ConfigurationHandle
  1348. );
  1349. EXPORT
  1350. VOID
  1351. NdisReadEisaSlotInformation(
  1352. OUT PNDIS_STATUS Status,
  1353. IN NDIS_HANDLE WrapperConfigurationContext,
  1354. OUT PUINT SlotNumber,
  1355. OUT PNDIS_EISA_FUNCTION_INFORMATION EisaData
  1356. );
  1357. EXPORT
  1358. VOID
  1359. NdisReadEisaSlotInformationEx(
  1360. OUT PNDIS_STATUS Status,
  1361. IN NDIS_HANDLE WrapperConfigurationContext,
  1362. OUT PUINT SlotNumber,
  1363. OUT PNDIS_EISA_FUNCTION_INFORMATION *EisaData,
  1364. OUT PUINT NumberOfFunctions
  1365. );
  1366. EXPORT
  1367. ULONG
  1368. NdisReadPciSlotInformation(
  1369. IN NDIS_HANDLE NdisAdapterHandle,
  1370. IN ULONG SlotNumber,
  1371. IN ULONG Offset,
  1372. IN PVOID Buffer,
  1373. IN ULONG Length
  1374. );
  1375. EXPORT
  1376. ULONG
  1377. NdisWritePciSlotInformation(
  1378. IN NDIS_HANDLE NdisAdapterHandle,
  1379. IN ULONG SlotNumber,
  1380. IN ULONG Offset,
  1381. IN PVOID Buffer,
  1382. IN ULONG Length
  1383. );
  1384. EXPORT
  1385. ULONG
  1386. NdisReadPcmciaAttributeMemory(
  1387. IN NDIS_HANDLE NdisAdapterHandle,
  1388. IN ULONG Offset,
  1389. IN PVOID Buffer,
  1390. IN ULONG Length
  1391. );
  1392. EXPORT
  1393. ULONG
  1394. NdisWritePcmciaAttributeMemory(
  1395. IN NDIS_HANDLE NdisAdapterHandle,
  1396. IN ULONG Offset,
  1397. IN PVOID Buffer,
  1398. IN ULONG Length
  1399. );
  1400. //
  1401. // Buffer Pool
  1402. //
  1403. EXPORT
  1404. VOID
  1405. NdisAllocateBufferPool(
  1406. OUT PNDIS_STATUS Status,
  1407. OUT PNDIS_HANDLE PoolHandle,
  1408. IN UINT NumberOfDescriptors
  1409. );
  1410. EXPORT
  1411. VOID
  1412. NdisFreeBufferPool(
  1413. IN NDIS_HANDLE PoolHandle
  1414. );
  1415. EXPORT
  1416. VOID
  1417. NdisAllocateBuffer(
  1418. OUT PNDIS_STATUS Status,
  1419. OUT PNDIS_BUFFER * Buffer,
  1420. IN NDIS_HANDLE PoolHandle,
  1421. IN PVOID VirtualAddress,
  1422. IN UINT Length
  1423. );
  1424. EXPORT
  1425. VOID
  1426. NdisCopyBuffer(
  1427. OUT PNDIS_STATUS Status,
  1428. OUT PNDIS_BUFFER * Buffer,
  1429. IN NDIS_HANDLE PoolHandle,
  1430. IN PVOID MemoryDescriptor,
  1431. IN UINT Offset,
  1432. IN UINT Length
  1433. );
  1434. //
  1435. // VOID
  1436. // NdisCopyLookaheadData(
  1437. // IN PVOID Destination,
  1438. // IN PVOID Source,
  1439. // IN ULONG Length,
  1440. // IN ULONG ReceiveFlags
  1441. // );
  1442. //
  1443. #if defined(_M_IX86) || defined(_M_AMD64)
  1444. #define NdisCopyLookaheadData(_Destination, _Source, _Length, _MacOptions) \
  1445. RtlCopyMemory(_Destination, _Source, _Length)
  1446. #else
  1447. #define NdisCopyLookaheadData(_Destination, _Source, _Length, _MacOptions) \
  1448. { \
  1449. if ((_MacOptions) & NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA) \
  1450. { \
  1451. RtlCopyMemory(_Destination, _Source, _Length); \
  1452. } \
  1453. else \
  1454. { \
  1455. PUCHAR _Src = (PUCHAR)(_Source); \
  1456. PUCHAR _Dest = (PUCHAR)(_Destination); \
  1457. PUCHAR _End = _Dest + (_Length); \
  1458. while (_Dest < _End) \
  1459. { \
  1460. *_Dest++ = *_Src++; \
  1461. } \
  1462. } \
  1463. }
  1464. #endif
  1465. //
  1466. // Packet Pool
  1467. //
  1468. EXPORT
  1469. VOID
  1470. NdisAllocatePacketPool(
  1471. OUT PNDIS_STATUS Status,
  1472. OUT PNDIS_HANDLE PoolHandle,
  1473. IN UINT NumberOfDescriptors,
  1474. IN UINT ProtocolReservedLength
  1475. );
  1476. EXPORT
  1477. VOID
  1478. NdisAllocatePacketPoolEx(
  1479. OUT PNDIS_STATUS Status,
  1480. OUT PNDIS_HANDLE PoolHandle,
  1481. IN UINT NumberOfDescriptors,
  1482. IN UINT NumberOfOverflowDescriptors,
  1483. IN UINT ProtocolReservedLength
  1484. );
  1485. EXPORT
  1486. VOID
  1487. NdisSetPacketPoolProtocolId(
  1488. IN NDIS_HANDLE PacketPoolHandle,
  1489. IN UINT ProtocolId
  1490. );
  1491. EXPORT
  1492. UINT
  1493. NdisPacketPoolUsage(
  1494. IN NDIS_HANDLE PoolHandle
  1495. );
  1496. EXPORT
  1497. UINT
  1498. NdisPacketSize(
  1499. IN UINT ProtocolReservedSize
  1500. );
  1501. EXPORT
  1502. NDIS_HANDLE
  1503. NdisGetPoolFromPacket(
  1504. IN PNDIS_PACKET Packet
  1505. );
  1506. EXPORT
  1507. PNDIS_PACKET_STACK
  1508. NdisIMGetCurrentPacketStack(
  1509. IN PNDIS_PACKET Packet,
  1510. OUT BOOLEAN * StacksRemaining
  1511. );
  1512. EXPORT
  1513. VOID
  1514. NdisFreePacketPool(
  1515. IN NDIS_HANDLE PoolHandle
  1516. );
  1517. EXPORT
  1518. VOID
  1519. NdisFreePacket(
  1520. IN PNDIS_PACKET Packet
  1521. );
  1522. EXPORT
  1523. VOID
  1524. NdisDprFreePacket(
  1525. IN PNDIS_PACKET Packet
  1526. );
  1527. EXPORT
  1528. VOID
  1529. NdisDprFreePacketNonInterlocked(
  1530. IN PNDIS_PACKET Packet
  1531. );
  1532. EXPORT
  1533. VOID
  1534. NdisAllocatePacket(
  1535. OUT PNDIS_STATUS Status,
  1536. OUT PNDIS_PACKET * Packet,
  1537. IN NDIS_HANDLE PoolHandle
  1538. );
  1539. EXPORT
  1540. VOID
  1541. NdisDprAllocatePacket(
  1542. OUT PNDIS_STATUS Status,
  1543. OUT PNDIS_PACKET * Packet,
  1544. IN NDIS_HANDLE PoolHandle
  1545. );
  1546. EXPORT
  1547. VOID
  1548. NdisDprAllocatePacketNonInterlocked(
  1549. OUT PNDIS_STATUS Status,
  1550. OUT PNDIS_PACKET * Packet,
  1551. IN NDIS_HANDLE PoolHandle
  1552. );
  1553. // VOID
  1554. // NdisReinitializePacket(
  1555. // IN OUT PNDIS_PACKET Packet
  1556. // );
  1557. #define NdisReinitializePacket(Packet) \
  1558. { \
  1559. (Packet)->Private.Head = (PNDIS_BUFFER)NULL; \
  1560. (Packet)->Private.ValidCounts = FALSE; \
  1561. }
  1562. //
  1563. // Block Pool APIs
  1564. //
  1565. typedef
  1566. VOID
  1567. (__stdcall *NDIS_BLOCK_INITIALIZER) (
  1568. IN PUCHAR Block,
  1569. IN SIZE_T NumberOfBytes
  1570. );
  1571. NDIS_HANDLE
  1572. NdisCreateBlockPool(
  1573. IN USHORT BlockSize,
  1574. IN USHORT FreeBlockLinkOffset,
  1575. IN ULONG Tag,
  1576. IN NDIS_BLOCK_INITIALIZER InitFunction OPTIONAL
  1577. );
  1578. VOID
  1579. NdisDestroyBlockPool(
  1580. IN NDIS_HANDLE BlockPoolHandle
  1581. );
  1582. PUCHAR
  1583. NdisAllocateFromBlockPool(
  1584. IN NDIS_HANDLE BlockPoolHandle
  1585. );
  1586. VOID
  1587. NdisFreeToBlockPool(
  1588. IN PUCHAR Block
  1589. );
  1590. #if BINARY_COMPATIBLE
  1591. EXPORT
  1592. VOID
  1593. NdisFreeBuffer(
  1594. IN PNDIS_BUFFER Buffer
  1595. );
  1596. EXPORT
  1597. VOID
  1598. NdisQueryBuffer(
  1599. IN PNDIS_BUFFER Buffer,
  1600. OUT PVOID * VirtualAddress OPTIONAL,
  1601. OUT PUINT Length
  1602. );
  1603. EXPORT
  1604. VOID
  1605. NdisQueryBufferSafe(
  1606. IN PNDIS_BUFFER Buffer,
  1607. OUT PVOID * VirtualAddress OPTIONAL,
  1608. OUT PUINT Length,
  1609. IN MM_PAGE_PRIORITY Priority
  1610. );
  1611. EXPORT
  1612. VOID
  1613. NdisQueryBufferOffset(
  1614. IN PNDIS_BUFFER Buffer,
  1615. OUT PUINT Offset,
  1616. OUT PUINT Length
  1617. );
  1618. //
  1619. // This is a combination of NdisQueryPacket and NdisQueryBuffer and
  1620. // optimized for protocols to get the first Buffer, its VA and its size.
  1621. //
  1622. VOID
  1623. NdisGetFirstBufferFromPacket(
  1624. IN PNDIS_PACKET Packet,
  1625. OUT PNDIS_BUFFER * FirstBuffer,
  1626. OUT PVOID * FirstBufferVA,
  1627. OUT PUINT FirstBufferLength,
  1628. OUT PUINT TotalBufferLength
  1629. );
  1630. VOID
  1631. NdisGetFirstBufferFromPacketSafe(
  1632. IN PNDIS_PACKET Packet,
  1633. OUT PNDIS_BUFFER * FirstBuffer,
  1634. OUT PVOID * FirstBufferVA,
  1635. OUT PUINT FirstBufferLength,
  1636. OUT PUINT TotalBufferLength,
  1637. IN MM_PAGE_PRIORITY Priority
  1638. );
  1639. //
  1640. // This is used to determine how many physical pieces
  1641. // an NDIS_BUFFER will take up when mapped.
  1642. //
  1643. EXPORT
  1644. ULONG
  1645. NDIS_BUFFER_TO_SPAN_PAGES(
  1646. IN PNDIS_BUFFER Buffer
  1647. );
  1648. EXPORT
  1649. VOID
  1650. NdisGetBufferPhysicalArraySize(
  1651. IN PNDIS_BUFFER Buffer,
  1652. OUT PUINT ArraySize
  1653. );
  1654. #else // BINARY_COMPATIBLE
  1655. #define NdisFreeBuffer(Buffer) IoFreeMdl(Buffer)
  1656. #define NdisQueryBuffer(_Buffer, _VirtualAddress, _Length) \
  1657. { \
  1658. if (ARGUMENT_PRESENT(_VirtualAddress)) \
  1659. { \
  1660. *(PVOID *)(_VirtualAddress) = MmGetSystemAddressForMdl(_Buffer); \
  1661. } \
  1662. *(_Length) = MmGetMdlByteCount(_Buffer); \
  1663. }
  1664. #define NdisQueryBufferSafe(_Buffer, _VirtualAddress, _Length, _Priority) \
  1665. { \
  1666. if (ARGUMENT_PRESENT(_VirtualAddress)) \
  1667. { \
  1668. *(PVOID *)(_VirtualAddress) = MmGetSystemAddressForMdlSafe(_Buffer, _Priority); \
  1669. } \
  1670. *(_Length) = MmGetMdlByteCount(_Buffer); \
  1671. }
  1672. #define NdisQueryBufferOffset(_Buffer, _Offset, _Length) \
  1673. { \
  1674. *(_Offset) = MmGetMdlByteOffset(_Buffer); \
  1675. *(_Length) = MmGetMdlByteCount(_Buffer); \
  1676. }
  1677. #define NdisGetFirstBufferFromPacket(_Packet, \
  1678. _FirstBuffer, \
  1679. _FirstBufferVA, \
  1680. _FirstBufferLength, \
  1681. _TotalBufferLength) \
  1682. { \
  1683. PNDIS_BUFFER _pBuf; \
  1684. \
  1685. _pBuf = (_Packet)->Private.Head; \
  1686. *(_FirstBuffer) = _pBuf; \
  1687. if (_pBuf) \
  1688. { \
  1689. *(_FirstBufferVA) = MmGetSystemAddressForMdl(_pBuf); \
  1690. *(_FirstBufferLength) = \
  1691. *(_TotalBufferLength) = MmGetMdlByteCount(_pBuf); \
  1692. for (_pBuf = _pBuf->Next; \
  1693. _pBuf != NULL; \
  1694. _pBuf = _pBuf->Next) \
  1695. { \
  1696. *(_TotalBufferLength) += MmGetMdlByteCount(_pBuf); \
  1697. } \
  1698. } \
  1699. else \
  1700. { \
  1701. *(_FirstBufferVA) = 0; \
  1702. *(_FirstBufferLength) = 0; \
  1703. *(_TotalBufferLength) = 0; \
  1704. } \
  1705. }
  1706. #define NdisGetFirstBufferFromPacketSafe(_Packet, \
  1707. _FirstBuffer, \
  1708. _FirstBufferVA, \
  1709. _FirstBufferLength, \
  1710. _TotalBufferLength, \
  1711. _Priority) \
  1712. { \
  1713. PNDIS_BUFFER _pBuf; \
  1714. \
  1715. _pBuf = (_Packet)->Private.Head; \
  1716. *(_FirstBuffer) = _pBuf; \
  1717. if (_pBuf) \
  1718. { \
  1719. *(_FirstBufferVA) = MmGetSystemAddressForMdlSafe(_pBuf, _Priority); \
  1720. *(_FirstBufferLength) = *(_TotalBufferLength) = MmGetMdlByteCount(_pBuf); \
  1721. for (_pBuf = _pBuf->Next; \
  1722. _pBuf != NULL; \
  1723. _pBuf = _pBuf->Next) \
  1724. { \
  1725. *(_TotalBufferLength) += MmGetMdlByteCount(_pBuf); \
  1726. } \
  1727. } \
  1728. else \
  1729. { \
  1730. *(_FirstBufferVA) = 0; \
  1731. *(_FirstBufferLength) = 0; \
  1732. *(_TotalBufferLength) = 0; \
  1733. } \
  1734. }
  1735. #define NDIS_BUFFER_TO_SPAN_PAGES(_Buffer) \
  1736. (MmGetMdlByteCount(_Buffer)==0 ? \
  1737. 1 : \
  1738. (ADDRESS_AND_SIZE_TO_SPAN_PAGES( \
  1739. MmGetMdlVirtualAddress(_Buffer), \
  1740. MmGetMdlByteCount(_Buffer))))
  1741. #define NdisGetBufferPhysicalArraySize(Buffer, ArraySize) \
  1742. (*(ArraySize) = NDIS_BUFFER_TO_SPAN_PAGES(Buffer))
  1743. #endif // BINARY_COMPATIBLE
  1744. /*++
  1745. NDIS_BUFFER_LINKAGE(
  1746. IN PNDIS_BUFFER Buffer
  1747. );
  1748. --*/
  1749. #define NDIS_BUFFER_LINKAGE(Buffer) ((Buffer)->Next)
  1750. /*++
  1751. VOID
  1752. NdisRecalculatePacketCounts(
  1753. IN OUT PNDIS_PACKET Packet
  1754. );
  1755. --*/
  1756. #define NdisRecalculatePacketCounts(Packet) \
  1757. { \
  1758. { \
  1759. PNDIS_BUFFER TmpBuffer = (Packet)->Private.Head; \
  1760. if (TmpBuffer) \
  1761. { \
  1762. while (TmpBuffer->Next) \
  1763. { \
  1764. TmpBuffer = TmpBuffer->Next; \
  1765. } \
  1766. (Packet)->Private.Tail = TmpBuffer; \
  1767. } \
  1768. (Packet)->Private.ValidCounts = FALSE; \
  1769. } \
  1770. }
  1771. /*++
  1772. VOID
  1773. NdisChainBufferAtFront(
  1774. IN OUT PNDIS_PACKET Packet,
  1775. IN OUT PNDIS_BUFFER Buffer
  1776. );
  1777. --*/
  1778. #define NdisChainBufferAtFront(Packet, Buffer) \
  1779. { \
  1780. PNDIS_BUFFER TmpBuffer = (Buffer); \
  1781. \
  1782. for (;;) \
  1783. { \
  1784. if (TmpBuffer->Next == (PNDIS_BUFFER)NULL) \
  1785. break; \
  1786. TmpBuffer = TmpBuffer->Next; \
  1787. } \
  1788. if ((Packet)->Private.Head == NULL) \
  1789. { \
  1790. (Packet)->Private.Tail = TmpBuffer; \
  1791. } \
  1792. TmpBuffer->Next = (Packet)->Private.Head; \
  1793. (Packet)->Private.Head = (Buffer); \
  1794. (Packet)->Private.ValidCounts = FALSE; \
  1795. }
  1796. /*++
  1797. VOID
  1798. NdisChainBufferAtBack(
  1799. IN OUT PNDIS_PACKET Packet,
  1800. IN OUT PNDIS_BUFFER Buffer
  1801. );
  1802. --*/
  1803. #define NdisChainBufferAtBack(Packet, Buffer) \
  1804. { \
  1805. PNDIS_BUFFER TmpBuffer = (Buffer); \
  1806. \
  1807. for (;;) \
  1808. { \
  1809. if (TmpBuffer->Next == NULL) \
  1810. break; \
  1811. TmpBuffer = TmpBuffer->Next; \
  1812. } \
  1813. if ((Packet)->Private.Head != NULL) \
  1814. { \
  1815. (Packet)->Private.Tail->Next = (Buffer); \
  1816. } \
  1817. else \
  1818. { \
  1819. (Packet)->Private.Head = (Buffer); \
  1820. } \
  1821. (Packet)->Private.Tail = TmpBuffer; \
  1822. (Packet)->Private.ValidCounts = FALSE; \
  1823. }
  1824. EXPORT
  1825. VOID
  1826. NdisUnchainBufferAtFront(
  1827. IN OUT PNDIS_PACKET Packet,
  1828. OUT PNDIS_BUFFER * Buffer
  1829. );
  1830. EXPORT
  1831. VOID
  1832. NdisUnchainBufferAtBack(
  1833. IN OUT PNDIS_PACKET Packet,
  1834. OUT PNDIS_BUFFER * Buffer
  1835. );
  1836. /*++
  1837. VOID
  1838. NdisQueryPacket(
  1839. IN PNDIS_PACKET _Packet,
  1840. OUT PUINT _PhysicalBufferCount OPTIONAL,
  1841. OUT PUINT _BufferCount OPTIONAL,
  1842. OUT PNDIS_BUFFER * _FirstBuffer OPTIONAL,
  1843. OUT PUINT _TotalPacketLength OPTIONAL
  1844. );
  1845. --*/
  1846. #pragma warning(push)
  1847. #pragma warning(disable:4127)
  1848. __inline
  1849. VOID
  1850. NdisQueryPacket(
  1851. IN PNDIS_PACKET _Packet,
  1852. OUT PUINT _PhysicalBufferCount OPTIONAL,
  1853. OUT PUINT _BufferCount OPTIONAL,
  1854. OUT PNDIS_BUFFER * _FirstBuffer OPTIONAL,
  1855. OUT PUINT _TotalPacketLength OPTIONAL
  1856. )
  1857. {
  1858. if ((_FirstBuffer) != NULL)
  1859. {
  1860. PNDIS_BUFFER * __FirstBuffer = (_FirstBuffer);
  1861. *(__FirstBuffer) = (_Packet)->Private.Head;
  1862. }
  1863. if ((_TotalPacketLength) || (_BufferCount) || (_PhysicalBufferCount))
  1864. {
  1865. if (!(_Packet)->Private.ValidCounts)
  1866. {
  1867. PNDIS_BUFFER TmpBuffer = (_Packet)->Private.Head;
  1868. UINT PTotalLength = 0, PPhysicalCount = 0, PAddedCount = 0;
  1869. UINT PacketLength, Offset;
  1870. while (TmpBuffer != (PNDIS_BUFFER)NULL)
  1871. {
  1872. NdisQueryBufferOffset(TmpBuffer, &Offset, &PacketLength);
  1873. PTotalLength += PacketLength;
  1874. PPhysicalCount += (UINT)NDIS_BUFFER_TO_SPAN_PAGES(TmpBuffer);
  1875. ++PAddedCount;
  1876. TmpBuffer = TmpBuffer->Next;
  1877. }
  1878. (_Packet)->Private.Count = PAddedCount;
  1879. (_Packet)->Private.TotalLength = PTotalLength;
  1880. (_Packet)->Private.PhysicalCount = PPhysicalCount;
  1881. (_Packet)->Private.ValidCounts = TRUE;
  1882. }
  1883. if (_PhysicalBufferCount)
  1884. {
  1885. PUINT __PhysicalBufferCount = (_PhysicalBufferCount);
  1886. *(__PhysicalBufferCount) = (_Packet)->Private.PhysicalCount;
  1887. }
  1888. if (_BufferCount)
  1889. {
  1890. PUINT __BufferCount = (_BufferCount);
  1891. *(__BufferCount) = (_Packet)->Private.Count;
  1892. }
  1893. if (_TotalPacketLength)
  1894. {
  1895. PUINT __TotalPacketLength = (_TotalPacketLength);
  1896. *(__TotalPacketLength) = (_Packet)->Private.TotalLength;
  1897. }
  1898. }
  1899. }
  1900. #pragma warning(pop)
  1901. /*++
  1902. VOID
  1903. NdisQueryPacketLength(
  1904. IN PNDIS_PACKET _Packet,
  1905. OUT PUINT _TotalPacketLength OPTIONAL
  1906. );
  1907. --*/
  1908. #define NdisQueryPacketLength(_Packet, \
  1909. _TotalPacketLength) \
  1910. { \
  1911. if (!(_Packet)->Private.ValidCounts) \
  1912. { \
  1913. NdisQueryPacket(_Packet, NULL, NULL, NULL, _TotalPacketLength); \
  1914. } \
  1915. else *(_TotalPacketLength) = (_Packet)->Private.TotalLength; \
  1916. }
  1917. /*++
  1918. VOID
  1919. NdisGetNextBuffer(
  1920. IN PNDIS_BUFFER CurrentBuffer,
  1921. OUT PNDIS_BUFFER * NextBuffer
  1922. );
  1923. --*/
  1924. #define NdisGetNextBuffer(CurrentBuffer, NextBuffer) \
  1925. { \
  1926. *(NextBuffer) = (CurrentBuffer)->Next; \
  1927. }
  1928. #if BINARY_COMPATIBLE
  1929. VOID
  1930. NdisAdjustBufferLength(
  1931. IN PNDIS_BUFFER Buffer,
  1932. IN UINT Length
  1933. );
  1934. #else // BINARY_COMPATIBLE
  1935. #define NdisAdjustBufferLength(Buffer, Length) (((Buffer)->ByteCount) = (Length))
  1936. #endif // BINARY_COMPATIBLE
  1937. EXPORT
  1938. VOID
  1939. NdisCopyFromPacketToPacket(
  1940. IN PNDIS_PACKET Destination,
  1941. IN UINT DestinationOffset,
  1942. IN UINT BytesToCopy,
  1943. IN PNDIS_PACKET Source,
  1944. IN UINT SourceOffset,
  1945. OUT PUINT BytesCopied
  1946. );
  1947. EXPORT
  1948. VOID
  1949. NdisCopyFromPacketToPacketSafe(
  1950. IN PNDIS_PACKET Destination,
  1951. IN UINT DestinationOffset,
  1952. IN UINT BytesToCopy,
  1953. IN PNDIS_PACKET Source,
  1954. IN UINT SourceOffset,
  1955. OUT PUINT BytesCopied,
  1956. IN MM_PAGE_PRIORITY Priority
  1957. );
  1958. EXPORT
  1959. NDIS_STATUS
  1960. NdisAllocateMemory(
  1961. OUT PVOID * VirtualAddress,
  1962. IN UINT Length,
  1963. IN UINT MemoryFlags,
  1964. IN NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress
  1965. );
  1966. EXPORT
  1967. NDIS_STATUS
  1968. NdisAllocateMemoryWithTag(
  1969. OUT PVOID * VirtualAddress,
  1970. IN UINT Length,
  1971. IN ULONG Tag
  1972. );
  1973. EXPORT
  1974. VOID
  1975. NdisFreeMemory(
  1976. IN PVOID VirtualAddress,
  1977. IN UINT Length,
  1978. IN UINT MemoryFlags
  1979. );
  1980. /*++
  1981. VOID
  1982. NdisStallExecution(
  1983. IN UINT MicrosecondsToStall
  1984. )
  1985. --*/
  1986. #define NdisStallExecution(MicroSecondsToStall) KeStallExecutionProcessor(MicroSecondsToStall)
  1987. EXPORT
  1988. VOID
  1989. NdisInitializeEvent(
  1990. IN PNDIS_EVENT Event
  1991. );
  1992. EXPORT
  1993. VOID
  1994. NdisSetEvent(
  1995. IN PNDIS_EVENT Event
  1996. );
  1997. EXPORT
  1998. VOID
  1999. NdisResetEvent(
  2000. IN PNDIS_EVENT Event
  2001. );
  2002. EXPORT
  2003. BOOLEAN
  2004. NdisWaitEvent(
  2005. IN PNDIS_EVENT Event,
  2006. IN UINT msToWait
  2007. );
  2008. /*++
  2009. VOID
  2010. NdisInitializeWorkItem(
  2011. IN PNDIS_WORK_ITEM WorkItem,
  2012. IN NDIS_PROC Routine,
  2013. IN PVOID Context
  2014. );
  2015. --*/
  2016. #define NdisInitializeWorkItem(_WI_, _R_, _C_) \
  2017. { \
  2018. (_WI_)->Context = _C_; \
  2019. (_WI_)->Routine = _R_; \
  2020. }
  2021. EXPORT
  2022. NDIS_STATUS
  2023. NdisScheduleWorkItem(
  2024. IN PNDIS_WORK_ITEM WorkItem
  2025. );
  2026. //
  2027. // Simple I/O support
  2028. //
  2029. EXPORT
  2030. VOID
  2031. NdisOpenFile(
  2032. OUT PNDIS_STATUS Status,
  2033. OUT PNDIS_HANDLE FileHandle,
  2034. OUT PUINT FileLength,
  2035. IN PNDIS_STRING FileName,
  2036. IN NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress
  2037. );
  2038. EXPORT
  2039. VOID
  2040. NdisCloseFile(
  2041. IN NDIS_HANDLE FileHandle
  2042. );
  2043. EXPORT
  2044. VOID
  2045. NdisMapFile(
  2046. OUT PNDIS_STATUS Status,
  2047. OUT PVOID * MappedBuffer,
  2048. IN NDIS_HANDLE FileHandle
  2049. );
  2050. EXPORT
  2051. VOID
  2052. NdisUnmapFile(
  2053. IN NDIS_HANDLE FileHandle
  2054. );
  2055. //
  2056. // Portability extensions
  2057. //
  2058. /*++
  2059. VOID
  2060. NdisFlushBuffer(
  2061. IN PNDIS_BUFFER Buffer,
  2062. IN BOOLEAN WriteToDevice
  2063. )
  2064. --*/
  2065. #define NdisFlushBuffer(Buffer,WriteToDevice) \
  2066. KeFlushIoBuffers((Buffer),!(WriteToDevice), TRUE)
  2067. EXPORT
  2068. ULONG
  2069. NdisGetSharedDataAlignment(
  2070. VOID
  2071. );
  2072. //
  2073. // Write Port
  2074. //
  2075. /*++
  2076. VOID
  2077. NdisWritePortUchar(
  2078. IN NDIS_HANDLE NdisAdapterHandle,
  2079. IN ULONG Port,
  2080. IN UCHAR Data
  2081. )
  2082. --*/
  2083. #define NdisWritePortUchar(Handle,Port,Data) \
  2084. WRITE_PORT_UCHAR((PUCHAR)(NDIS_PORT_TO_PORT(Handle,Port)),(UCHAR)(Data))
  2085. /*++
  2086. VOID
  2087. NdisWritePortUshort(
  2088. IN NDIS_HANDLE NdisAdapterHandle,
  2089. IN ULONG Port,
  2090. IN USHORT Data
  2091. )
  2092. --*/
  2093. #define NdisWritePortUshort(Handle,Port,Data) \
  2094. WRITE_PORT_USHORT((PUSHORT)(NDIS_PORT_TO_PORT(Handle,Port)),(USHORT)(Data))
  2095. /*++
  2096. VOID
  2097. NdisWritePortUlong(
  2098. IN NDIS_HANDLE NdisAdapterHandle,
  2099. IN ULONG Port,
  2100. IN ULONG Data
  2101. )
  2102. --*/
  2103. #define NdisWritePortUlong(Handle,Port,Data) \
  2104. WRITE_PORT_ULONG((PULONG)(NDIS_PORT_TO_PORT(Handle,Port)),(ULONG)(Data))
  2105. //
  2106. // Write Port Buffers
  2107. //
  2108. /*++
  2109. VOID
  2110. NdisWritePortBufferUchar(
  2111. IN NDIS_HANDLE NdisAdapterHandle,
  2112. IN ULONG Port,
  2113. IN PUCHAR Buffer,
  2114. IN ULONG Length
  2115. )
  2116. --*/
  2117. #define NdisWritePortBufferUchar(Handle,Port,Buffer,Length) \
  2118. NdisRawWritePortBufferUchar(NDIS_PORT_TO_PORT((Handle),(Port)),(Buffer),(Length))
  2119. /*++
  2120. VOID
  2121. NdisWritePortBufferUshort(
  2122. IN NDIS_HANDLE NdisAdapterHandle,
  2123. IN ULONG Port,
  2124. IN PUSHORT Buffer,
  2125. IN ULONG Length
  2126. )
  2127. --*/
  2128. #define NdisWritePortBufferUshort(Handle,Port,Buffer,Length) \
  2129. NdisRawWritePortBufferUshort(NDIS_PORT_TO_PORT((Handle),(Port)),(Buffer),(Length))
  2130. /*++
  2131. VOID
  2132. NdisWritePortBufferUlong(
  2133. IN NDIS_HANDLE NdisAdapterHandle,
  2134. IN ULONG Port,
  2135. IN PULONG Buffer,
  2136. IN ULONG Length
  2137. )
  2138. --*/
  2139. #define NdisWritePortBufferUlong(Handle,Port,Buffer,Length) \
  2140. NdisRawWritePortBufferUlong(NDIS_PORT_TO_PORT((Handle),(Port)),(Buffer),(Length))
  2141. //
  2142. // Read Ports
  2143. //
  2144. /*++
  2145. VOID
  2146. NdisReadPortUchar(
  2147. IN NDIS_HANDLE NdisAdapterHandle,
  2148. IN ULONG Port,
  2149. OUT PUCHAR Data
  2150. )
  2151. --*/
  2152. #define NdisReadPortUchar(Handle,Port, Data) \
  2153. NdisRawReadPortUchar(NDIS_PORT_TO_PORT((Handle),(Port)),(Data))
  2154. /*++
  2155. VOID
  2156. NdisReadPortUshort(
  2157. IN NDIS_HANDLE NdisAdapterHandle,
  2158. IN ULONG Port,
  2159. OUT PUSHORT Data
  2160. )
  2161. --*/
  2162. #define NdisReadPortUshort(Handle,Port,Data) \
  2163. NdisRawReadPortUshort(NDIS_PORT_TO_PORT((Handle),(Port)),(Data))
  2164. /*++
  2165. VOID
  2166. NdisReadPortUlong(
  2167. IN NDIS_HANDLE NdisAdapterHandle,
  2168. IN ULONG Port,
  2169. OUT PULONG Data
  2170. )
  2171. --*/
  2172. #define NdisReadPortUlong(Handle,Port,Data) \
  2173. NdisRawReadPortUlong(NDIS_PORT_TO_PORT((Handle),(Port)),(Data))
  2174. //
  2175. // Read Buffer Ports
  2176. //
  2177. /*++
  2178. VOID
  2179. NdisReadPortBufferUchar(
  2180. IN NDIS_HANDLE NdisAdapterHandle,
  2181. IN ULONG Port,
  2182. OUT PUCHAR Buffer,
  2183. IN ULONG Length
  2184. )
  2185. --*/
  2186. #define NdisReadPortBufferUchar(Handle,Port,Buffer,Length) \
  2187. NdisRawReadPortBufferUchar(NDIS_PORT_TO_PORT((Handle),(Port)),(Buffer),(Length))
  2188. /*++
  2189. VOID
  2190. NdisReadPortBufferUshort(
  2191. IN NDIS_HANDLE NdisAdapterHandle,
  2192. IN ULONG Port,
  2193. OUT PUSHORT Buffer,
  2194. IN ULONG Length
  2195. )
  2196. --*/
  2197. #define NdisReadPortBufferUshort(Handle,Port,Buffer,Length) \
  2198. NdisRawReadPortBufferUshort(NDIS_PORT_TO_PORT((Handle),(Port)),(Buffer),(Length))
  2199. /*++
  2200. VOID
  2201. NdisReadPortBufferUlong(
  2202. IN NDIS_HANDLE NdisAdapterHandle,
  2203. IN ULONG Port,
  2204. OUT PULONG Buffer,
  2205. IN ULONG Length
  2206. )
  2207. --*/
  2208. #define NdisReadPortBufferUlong(Handle,Port,Buffer) \
  2209. NdisRawReadPortBufferUlong(NDIS_PORT_TO_PORT((Handle),(Port)),(Buffer),(Length))
  2210. //
  2211. // Raw Routines
  2212. //
  2213. //
  2214. // Write Port Raw
  2215. //
  2216. /*++
  2217. VOID
  2218. NdisRawWritePortUchar(
  2219. IN ULONG_PTR Port,
  2220. IN UCHAR Data
  2221. )
  2222. --*/
  2223. #define NdisRawWritePortUchar(Port,Data) \
  2224. WRITE_PORT_UCHAR((PUCHAR)(Port),(UCHAR)(Data))
  2225. /*++
  2226. VOID
  2227. NdisRawWritePortUshort(
  2228. IN ULONG_PTR Port,
  2229. IN USHORT Data
  2230. )
  2231. --*/
  2232. #define NdisRawWritePortUshort(Port,Data) \
  2233. WRITE_PORT_USHORT((PUSHORT)(Port),(USHORT)(Data))
  2234. /*++
  2235. VOID
  2236. NdisRawWritePortUlong(
  2237. IN ULONG_PTR Port,
  2238. IN ULONG Data
  2239. )
  2240. --*/
  2241. #define NdisRawWritePortUlong(Port,Data) \
  2242. WRITE_PORT_ULONG((PULONG)(Port),(ULONG)(Data))
  2243. //
  2244. // Raw Write Port Buffers
  2245. //
  2246. /*++
  2247. VOID
  2248. NdisRawWritePortBufferUchar(
  2249. IN ULONG_PTR Port,
  2250. IN PUCHAR Buffer,
  2251. IN ULONG Length
  2252. )
  2253. --*/
  2254. #define NdisRawWritePortBufferUchar(Port,Buffer,Length) \
  2255. WRITE_PORT_BUFFER_UCHAR((PUCHAR)(Port),(PUCHAR)(Buffer),(Length))
  2256. /*++
  2257. VOID
  2258. NdisRawWritePortBufferUshort(
  2259. IN ULONG_PTR Port,
  2260. IN PUSHORT Buffer,
  2261. IN ULONG Length
  2262. )
  2263. --*/
  2264. #if defined(_M_IX86) || defined(_M_AMD64)
  2265. #define NdisRawWritePortBufferUshort(Port,Buffer,Length) \
  2266. WRITE_PORT_BUFFER_USHORT((PUSHORT)(Port),(PUSHORT)(Buffer),(Length))
  2267. #else
  2268. #define NdisRawWritePortBufferUshort(Port,Buffer,Length) \
  2269. { \
  2270. ULONG_PTR _Port = (ULONG_PTR)(Port); \
  2271. PUSHORT _Current = (Buffer); \
  2272. PUSHORT _End = _Current + (Length); \
  2273. for ( ; _Current < _End; ++_Current) \
  2274. { \
  2275. WRITE_PORT_USHORT((PUSHORT)_Port,*(UNALIGNED USHORT *)_Current);\
  2276. } \
  2277. }
  2278. #endif
  2279. /*++
  2280. VOID
  2281. NdisRawWritePortBufferUlong(
  2282. IN ULONG_PTR Port,
  2283. IN PULONG Buffer,
  2284. IN ULONG Length
  2285. )
  2286. --*/
  2287. #if defined(_M_IX86) || defined(_M_AMD64)
  2288. #define NdisRawWritePortBufferUlong(Port,Buffer,Length) \
  2289. WRITE_PORT_BUFFER_ULONG((PULONG)(Port),(PULONG)(Buffer),(Length))
  2290. #else
  2291. #define NdisRawWritePortBufferUlong(Port,Buffer,Length) \
  2292. { \
  2293. ULONG_PTR _Port = (ULONG_PTR)(Port); \
  2294. PULONG _Current = (Buffer); \
  2295. PULONG _End = _Current + (Length); \
  2296. for ( ; _Current < _End; ++_Current) \
  2297. { \
  2298. WRITE_PORT_ULONG((PULONG)_Port,*(UNALIGNED ULONG *)_Current); \
  2299. } \
  2300. }
  2301. #endif
  2302. //
  2303. // Raw Read Ports
  2304. //
  2305. /*++
  2306. VOID
  2307. NdisRawReadPortUchar(
  2308. IN ULONG_PTR Port,
  2309. OUT PUCHAR Data
  2310. )
  2311. --*/
  2312. #define NdisRawReadPortUchar(Port, Data) \
  2313. *(Data) = READ_PORT_UCHAR((PUCHAR)(Port))
  2314. /*++
  2315. VOID
  2316. NdisRawReadPortUshort(
  2317. IN ULONG_PTR Port,
  2318. OUT PUSHORT Data
  2319. )
  2320. --*/
  2321. #define NdisRawReadPortUshort(Port,Data) \
  2322. *(Data) = READ_PORT_USHORT((PUSHORT)(Port))
  2323. /*++
  2324. VOID
  2325. NdisRawReadPortUlong(
  2326. IN ULONG_PTR Port,
  2327. OUT PULONG Data
  2328. )
  2329. --*/
  2330. #define NdisRawReadPortUlong(Port,Data) \
  2331. *(Data) = READ_PORT_ULONG((PULONG)(Port))
  2332. //
  2333. // Raw Read Buffer Ports
  2334. //
  2335. /*++
  2336. VOID
  2337. NdisRawReadPortBufferUchar(
  2338. IN ULONG_PTR Port,
  2339. OUT PUCHAR Buffer,
  2340. IN ULONG Length
  2341. )
  2342. --*/
  2343. #define NdisRawReadPortBufferUchar(Port,Buffer,Length) \
  2344. READ_PORT_BUFFER_UCHAR((PUCHAR)(Port),(PUCHAR)(Buffer),(Length))
  2345. /*++
  2346. VOID
  2347. NdisRawReadPortBufferUshort(
  2348. IN ULONG_PTR Port,
  2349. OUT PUSHORT Buffer,
  2350. IN ULONG Length
  2351. )
  2352. --*/
  2353. #if defined(_M_IX86) || defined(_M_AMD64)
  2354. #define NdisRawReadPortBufferUshort(Port,Buffer,Length) \
  2355. READ_PORT_BUFFER_USHORT((PUSHORT)(Port),(PUSHORT)(Buffer),(Length))
  2356. #else
  2357. #define NdisRawReadPortBufferUshort(Port,Buffer,Length) \
  2358. { \
  2359. ULONG_PTR _Port = (ULONG_PTR)(Port); \
  2360. PUSHORT _Current = (Buffer); \
  2361. PUSHORT _End = _Current + (Length); \
  2362. for ( ; _Current < _End; ++_Current) \
  2363. { \
  2364. *(UNALIGNED USHORT *)_Current = READ_PORT_USHORT((PUSHORT)_Port); \
  2365. } \
  2366. }
  2367. #endif
  2368. /*++
  2369. VOID
  2370. NdisRawReadPortBufferUlong(
  2371. IN ULONG_PTR Port,
  2372. OUT PULONG Buffer,
  2373. IN ULONG Length
  2374. )
  2375. --*/
  2376. #if defined(_M_IX86) || defined(_M_AMD64)
  2377. #define NdisRawReadPortBufferUlong(Port,Buffer,Length) \
  2378. READ_PORT_BUFFER_ULONG((PULONG)(Port),(PULONG)(Buffer),(Length))
  2379. #else
  2380. #define NdisRawReadPortBufferUlong(Port,Buffer,Length) \
  2381. { \
  2382. ULONG_PTR _Port = (ULONG_PTR)(Port); \
  2383. PULONG _Current = (Buffer); \
  2384. PULONG _End = _Current + (Length); \
  2385. for ( ; _Current < _End; ++_Current) \
  2386. { \
  2387. *(UNALIGNED ULONG *)_Current = READ_PORT_ULONG((PULONG)_Port); \
  2388. } \
  2389. }
  2390. #endif
  2391. //
  2392. // Write Registers
  2393. //
  2394. /*++
  2395. VOID
  2396. NdisWriteRegisterUchar(
  2397. IN PUCHAR Register,
  2398. IN UCHAR Data
  2399. )
  2400. --*/
  2401. #if defined(_M_IX86) || defined(_M_AMD64)
  2402. #define NdisWriteRegisterUchar(Register,Data) \
  2403. WRITE_REGISTER_UCHAR((Register),(Data))
  2404. #else
  2405. #define NdisWriteRegisterUchar(Register,Data) \
  2406. { \
  2407. WRITE_REGISTER_UCHAR((Register),(Data)); \
  2408. READ_REGISTER_UCHAR(Register); \
  2409. }
  2410. #endif
  2411. /*++
  2412. VOID
  2413. NdisWriteRegisterUshort(
  2414. IN PUCHAR Register,
  2415. IN USHORT Data
  2416. )
  2417. --*/
  2418. #if defined(_M_IX86) || defined(_M_AMD64)
  2419. #define NdisWriteRegisterUshort(Register,Data) \
  2420. WRITE_REGISTER_USHORT((Register),(Data))
  2421. #else
  2422. #define NdisWriteRegisterUshort(Register,Data) \
  2423. { \
  2424. WRITE_REGISTER_USHORT((Register),(Data)); \
  2425. READ_REGISTER_USHORT(Register); \
  2426. }
  2427. #endif
  2428. /*++
  2429. VOID
  2430. NdisWriteRegisterUlong(
  2431. IN PUCHAR Register,
  2432. IN ULONG Data
  2433. )
  2434. --*/
  2435. #if defined(_M_IX86) || defined(_M_AMD64)
  2436. #define NdisWriteRegisterUlong(Register,Data) WRITE_REGISTER_ULONG((Register),(Data))
  2437. #else
  2438. #define NdisWriteRegisterUlong(Register,Data) \
  2439. { \
  2440. WRITE_REGISTER_ULONG((Register),(Data)); \
  2441. READ_REGISTER_ULONG(Register); \
  2442. }
  2443. #endif
  2444. /*++
  2445. VOID
  2446. NdisReadRegisterUchar(
  2447. IN PUCHAR Register,
  2448. OUT PUCHAR Data
  2449. )
  2450. --*/
  2451. #if defined(_M_IX86) || defined(_M_AMD64)
  2452. #define NdisReadRegisterUchar(Register,Data) *(Data) = *((volatile UCHAR * const)(Register))
  2453. #else
  2454. #define NdisReadRegisterUchar(Register,Data) *(Data) = READ_REGISTER_UCHAR((PUCHAR)(Register))
  2455. #endif
  2456. /*++
  2457. VOID
  2458. NdisReadRegisterUshort(
  2459. IN PUSHORT Register,
  2460. OUT PUSHORT Data
  2461. )
  2462. --*/
  2463. #if defined(_M_IX86) || defined(_M_AMD64)
  2464. #define NdisReadRegisterUshort(Register,Data) *(Data) = *((volatile USHORT * const)(Register))
  2465. #else
  2466. #define NdisReadRegisterUshort(Register,Data) *(Data) = READ_REGISTER_USHORT((PUSHORT)(Register))
  2467. #endif
  2468. /*++
  2469. VOID
  2470. NdisReadRegisterUlong(
  2471. IN PULONG Register,
  2472. OUT PULONG Data
  2473. )
  2474. --*/
  2475. #if defined(_M_IX86) || defined(_M_AMD64)
  2476. #define NdisReadRegisterUlong(Register,Data) *(Data) = *((volatile ULONG * const)(Register))
  2477. #else
  2478. #define NdisReadRegisterUlong(Register,Data) *(Data) = READ_REGISTER_ULONG((PULONG)(Register))
  2479. #endif
  2480. #define NdisEqualAnsiString(_String1,_String2, _CaseInsensitive) \
  2481. RtlEqualAnsiString(_String1, _String2, _CaseInsensitive)
  2482. #define NdisEqualString(_String1, _String2, _CaseInsensitive) \
  2483. RtlEqualUnicodeString(_String1, _String2, _CaseInsensitive)
  2484. #define NdisEqualUnicodeString(_String1, _String2, _CaseInsensitive) \
  2485. RtlEqualUnicodeString(_String1, _String2, _CaseInsensitive)
  2486. EXPORT
  2487. VOID __cdecl
  2488. NdisWriteErrorLogEntry(
  2489. IN NDIS_HANDLE NdisAdapterHandle,
  2490. IN NDIS_ERROR_CODE ErrorCode,
  2491. IN ULONG NumberOfErrorValues,
  2492. ...
  2493. );
  2494. EXPORT
  2495. VOID
  2496. NdisInitializeString(
  2497. OUT PNDIS_STRING Destination,
  2498. IN PUCHAR Source
  2499. );
  2500. #define NdisFreeString(String) NdisFreeMemory((String).Buffer, (String).MaximumLength, 0)
  2501. #define NdisPrintString(String) DbgPrint("%ls",(String).Buffer)
  2502. /*++
  2503. VOID
  2504. NdisCreateLookaheadBufferFromSharedMemory(
  2505. IN PVOID pSharedMemory,
  2506. IN UINT LookaheadLength,
  2507. OUT PVOID * pLookaheadBuffer
  2508. );
  2509. --*/
  2510. #define NdisCreateLookaheadBufferFromSharedMemory(_S, _L, _B) ((*(_B)) = (_S))
  2511. /*++
  2512. VOID
  2513. NdisDestroyLookaheadBufferFromSharedMemory(
  2514. IN PVOID pLookaheadBuffer
  2515. );
  2516. --*/
  2517. #define NdisDestroyLookaheadBufferFromSharedMemory(_B)
  2518. //
  2519. // The following declarations are shared between ndismac.h and ndismini.h. They
  2520. // are meant to be for internal use only. They should not be used directly by
  2521. // miniport drivers.
  2522. //
  2523. //
  2524. // declare these first since they point to each other
  2525. //
  2526. typedef struct _NDIS_WRAPPER_HANDLE NDIS_WRAPPER_HANDLE, *PNDIS_WRAPPER_HANDLE;
  2527. typedef struct _NDIS_PROTOCOL_BLOCK NDIS_PROTOCOL_BLOCK, *PNDIS_PROTOCOL_BLOCK;
  2528. typedef struct _NDIS_OPEN_BLOCK NDIS_OPEN_BLOCK, *PNDIS_OPEN_BLOCK;
  2529. typedef struct _NDIS_M_DRIVER_BLOCK NDIS_M_DRIVER_BLOCK, *PNDIS_M_DRIVER_BLOCK;
  2530. typedef struct _NDIS_MINIPORT_BLOCK NDIS_MINIPORT_BLOCK,*PNDIS_MINIPORT_BLOCK;
  2531. typedef struct _CO_CALL_PARAMETERS CO_CALL_PARAMETERS, *PCO_CALL_PARAMETERS;
  2532. typedef struct _CO_MEDIA_PARAMETERS CO_MEDIA_PARAMETERS, *PCO_MEDIA_PARAMETERS;
  2533. typedef struct _NDIS_CALL_MANAGER_CHARACTERISTICS *PNDIS_CALL_MANAGER_CHARACTERISTICS;
  2534. typedef struct _NDIS_AF_LIST NDIS_AF_LIST, *PNDIS_AF_LIST;
  2535. typedef struct _X_FILTER ETH_FILTER, *PETH_FILTER;
  2536. typedef struct _X_FILTER FDDI_FILTER, *PFDDI_FILTER;
  2537. typedef struct _X_FILTER TR_FILTER, *PTR_FILTER;
  2538. typedef struct _X_FILTER NULL_FILTER, *PNULL_FILTER;
  2539. //
  2540. // Timers.
  2541. //
  2542. typedef
  2543. VOID
  2544. (*PNDIS_TIMER_FUNCTION) (
  2545. IN PVOID SystemSpecific1,
  2546. IN PVOID FunctionContext,
  2547. IN PVOID SystemSpecific2,
  2548. IN PVOID SystemSpecific3
  2549. );
  2550. typedef struct _NDIS_TIMER
  2551. {
  2552. KTIMER Timer;
  2553. KDPC Dpc;
  2554. } NDIS_TIMER, *PNDIS_TIMER;
  2555. EXPORT
  2556. VOID
  2557. NdisInitializeTimer(
  2558. IN OUT PNDIS_TIMER Timer,
  2559. IN PNDIS_TIMER_FUNCTION TimerFunction,
  2560. IN PVOID FunctionContext
  2561. );
  2562. VOID
  2563. NdisCancelTimer(
  2564. IN PNDIS_TIMER Timer,
  2565. OUT PBOOLEAN TimerCancelled
  2566. );
  2567. EXPORT
  2568. VOID
  2569. NdisSetTimer(
  2570. IN PNDIS_TIMER Timer,
  2571. IN UINT MillisecondsToDelay
  2572. );
  2573. EXPORT
  2574. VOID
  2575. NdisSetTimerEx(
  2576. IN PNDIS_TIMER Timer,
  2577. IN UINT MillisecondsToDelay,
  2578. IN PVOID FunctionContext
  2579. );
  2580. //
  2581. // DMA operations.
  2582. //
  2583. EXPORT
  2584. VOID
  2585. NdisAllocateDmaChannel(
  2586. OUT PNDIS_STATUS Status,
  2587. OUT PNDIS_HANDLE NdisDmaHandle,
  2588. IN NDIS_HANDLE NdisAdapterHandle,
  2589. IN PNDIS_DMA_DESCRIPTION DmaDescription,
  2590. IN ULONG MaximumLength
  2591. );
  2592. EXPORT
  2593. VOID
  2594. NdisSetupDmaTransfer(
  2595. OUT PNDIS_STATUS Status,
  2596. IN NDIS_HANDLE NdisDmaHandle,
  2597. IN PNDIS_BUFFER Buffer,
  2598. IN ULONG Offset,
  2599. IN ULONG Length,
  2600. IN BOOLEAN WriteToDevice
  2601. );
  2602. EXPORT
  2603. VOID
  2604. NdisCompleteDmaTransfer(
  2605. OUT PNDIS_STATUS Status,
  2606. IN NDIS_HANDLE NdisDmaHandle,
  2607. IN PNDIS_BUFFER Buffer,
  2608. IN ULONG Offset,
  2609. IN ULONG Length,
  2610. IN BOOLEAN WriteToDevice
  2611. );
  2612. //
  2613. // Wrapper initialization and termination.
  2614. //
  2615. EXPORT
  2616. VOID
  2617. NdisInitializeWrapper(
  2618. OUT PNDIS_HANDLE NdisWrapperHandle,
  2619. IN PVOID SystemSpecific1,
  2620. IN PVOID SystemSpecific2,
  2621. IN PVOID SystemSpecific3
  2622. );
  2623. EXPORT
  2624. VOID
  2625. NdisTerminateWrapper(
  2626. IN NDIS_HANDLE NdisWrapperHandle,
  2627. IN PVOID SystemSpecific
  2628. );
  2629. //
  2630. // Shared memory
  2631. //
  2632. #define NdisUpdateSharedMemory(_H, _L, _V, _P)
  2633. //
  2634. // System processor count
  2635. //
  2636. EXPORT
  2637. CCHAR
  2638. NdisSystemProcessorCount(
  2639. VOID
  2640. );
  2641. EXPORT
  2642. PVOID
  2643. NdisGetRoutineAddress(
  2644. IN PNDIS_STRING NdisRoutineName
  2645. );
  2646. EXPORT
  2647. UINT
  2648. NdisGetVersion(
  2649. VOID
  2650. );
  2651. //
  2652. // Ansi/Unicode support routines
  2653. //
  2654. #if BINARY_COMPATIBLE
  2655. EXPORT
  2656. VOID
  2657. NdisInitAnsiString(
  2658. IN OUT PANSI_STRING DestinationString,
  2659. IN PCSTR SourceString
  2660. );
  2661. EXPORT
  2662. VOID
  2663. NdisInitUnicodeString(
  2664. IN OUT PUNICODE_STRING DestinationString,
  2665. IN PCWSTR SourceString
  2666. );
  2667. EXPORT
  2668. NDIS_STATUS
  2669. NdisAnsiStringToUnicodeString(
  2670. IN OUT PUNICODE_STRING DestinationString,
  2671. IN PANSI_STRING SourceString
  2672. );
  2673. EXPORT
  2674. NDIS_STATUS
  2675. NdisUnicodeStringToAnsiString(
  2676. IN OUT PANSI_STRING DestinationString,
  2677. IN PUNICODE_STRING SourceString
  2678. );
  2679. EXPORT
  2680. NDIS_STATUS
  2681. NdisUpcaseUnicodeString(
  2682. OUT PUNICODE_STRING DestinationString,
  2683. IN PUNICODE_STRING SourceString
  2684. );
  2685. #else // BINARY_COMPATIBLE
  2686. #define NdisInitAnsiString(_as, s) RtlInitString(_as, s)
  2687. #define NdisInitUnicodeString(_us, s) RtlInitUnicodeString(_us, s)
  2688. #define NdisAnsiStringToUnicodeString(_us, _as) RtlAnsiStringToUnicodeString(_us, _as, FALSE)
  2689. #define NdisUnicodeStringToAnsiString(_as, _us) RtlUnicodeStringToAnsiString(_as, _us, FALSE)
  2690. #define NdisUpcaseUnicodeString(_d, _s) RtlUpcaseUnicodeString(_d, _s, FALSE)
  2691. #endif // BINARY_COMPATIBLE
  2692. //
  2693. // Non-paged lookaside list support routines
  2694. //
  2695. #define NdisInitializeNPagedLookasideList(_L, _AR, _FR, _Fl, _S, _T, _D) \
  2696. ExInitializeNPagedLookasideList(_L, _AR, _FR, _Fl, _S, _T, _D)
  2697. #define NdisDeleteNPagedLookasideList(_L) ExDeleteNPagedLookasideList(_L)
  2698. #define NdisAllocateFromNPagedLookasideList(_L) ExAllocateFromNPagedLookasideList(_L)
  2699. #define NdisFreeToNPagedLookasideList(_L, _E) ExFreeToNPagedLookasideList(_L, _E)
  2700. EXPORT
  2701. VOID
  2702. NdisSetPacketStatus(
  2703. IN PNDIS_PACKET Packet,
  2704. IN NDIS_STATUS Status,
  2705. IN NDIS_HANDLE Handle,
  2706. IN ULONG Code
  2707. );
  2708. #define NDIS_MAX_EVENT_LOG_DATA_SIZE ((ERROR_LOG_MAXIMUM_SIZE - sizeof(IO_ERROR_LOG_PACKET) + sizeof(ULONG)) & ~3)
  2709. #if NDIS_RECV_SCALE
  2710. #define NDIS_MAX_PROCESSOR_COUNT 32
  2711. typedef struct _NDIS_RECEIVE_SCALE_HASH_MAP
  2712. {
  2713. CCHAR TargetCpu[NDIS_MAX_PROCESSOR_COUNT];
  2714. } NDIS_RECEIVE_SCALE_HASH_MAP, *PNDIS_RECEIVE_SCALE_HASH_MAP;
  2715. //
  2716. // used in OID_GEN_RECEIVE_SCALE_PARAMETERS
  2717. //
  2718. typedef struct _NDIS_RECEIVE_SCALE_PARAMETERS
  2719. {
  2720. USHORT EthType;
  2721. USHORT CurrentHashFunction;
  2722. NDIS_RECEIVE_SCALE_HASH_MAP HashMap;
  2723. } NDIS_RECEIVE_SCALE_PARAMETERS, *PNDIS_RECEIVE_SCALE_PARAMETERS;
  2724. #endif
  2725. #define NDIS_CURRENT_PROCESSOR KeGetCurrentProcessorNumber()
  2726. #if defined(NDIS_WRAPPER)
  2727. typedef struct _OID_LIST OID_LIST, *POID_LIST;
  2728. #endif // NDIS_WRAPPER defined