Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3254 lines
100 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. typedef VOID (*NDIS_PROC)(struct _NDIS_WORK_ITEM *, PVOID);
  136. //
  137. // Definition of an ndis work-item
  138. //
  139. typedef struct _NDIS_WORK_ITEM
  140. {
  141. PVOID Context;
  142. NDIS_PROC Routine;
  143. UCHAR WrapperReserved[8*sizeof(PVOID)];
  144. } NDIS_WORK_ITEM, *PNDIS_WORK_ITEM;
  145. #define NdisInterruptLatched Latched
  146. #define NdisInterruptLevelSensitive LevelSensitive
  147. typedef KINTERRUPT_MODE NDIS_INTERRUPT_MODE, *PNDIS_INTERRUPT_MODE;
  148. //
  149. // Configuration definitions
  150. //
  151. //
  152. // Possible data types
  153. //
  154. typedef enum _NDIS_PARAMETER_TYPE
  155. {
  156. NdisParameterInteger,
  157. NdisParameterHexInteger,
  158. NdisParameterString,
  159. NdisParameterMultiString,
  160. NdisParameterBinary
  161. } NDIS_PARAMETER_TYPE, *PNDIS_PARAMETER_TYPE;
  162. typedef struct
  163. {
  164. USHORT Length;
  165. PVOID Buffer;
  166. } BINARY_DATA;
  167. //
  168. // To store configuration information
  169. //
  170. typedef struct _NDIS_CONFIGURATION_PARAMETER
  171. {
  172. NDIS_PARAMETER_TYPE ParameterType;
  173. union
  174. {
  175. ULONG IntegerData;
  176. NDIS_STRING StringData;
  177. BINARY_DATA BinaryData;
  178. } ParameterData;
  179. } NDIS_CONFIGURATION_PARAMETER, *PNDIS_CONFIGURATION_PARAMETER;
  180. //
  181. // Definitions for the "ProcessorType" keyword
  182. //
  183. typedef enum _NDIS_PROCESSOR_TYPE
  184. {
  185. NdisProcessorX86,
  186. NdisProcessorMips,
  187. NdisProcessorAlpha,
  188. NdisProcessorPpc,
  189. NdisProcessorAmd64
  190. } NDIS_PROCESSOR_TYPE, *PNDIS_PROCESSOR_TYPE;
  191. //
  192. // Definitions for the "Environment" keyword
  193. //
  194. typedef enum _NDIS_ENVIRONMENT_TYPE
  195. {
  196. NdisEnvironmentWindows,
  197. NdisEnvironmentWindowsNt
  198. } NDIS_ENVIRONMENT_TYPE, *PNDIS_ENVIRONMENT_TYPE;
  199. //
  200. // Possible Hardware Architecture. Define these to
  201. // match the HAL INTERFACE_TYPE enum.
  202. //
  203. typedef enum _NDIS_INTERFACE_TYPE
  204. {
  205. NdisInterfaceInternal = Internal,
  206. NdisInterfaceIsa = Isa,
  207. NdisInterfaceEisa = Eisa,
  208. NdisInterfaceMca = MicroChannel,
  209. NdisInterfaceTurboChannel = TurboChannel,
  210. NdisInterfacePci = PCIBus,
  211. NdisInterfacePcMcia = PCMCIABus,
  212. NdisInterfaceCBus = CBus,
  213. NdisInterfaceMPIBus = MPIBus,
  214. NdisInterfaceMPSABus = MPSABus,
  215. NdisInterfaceProcessorInternal = ProcessorInternal,
  216. NdisInterfaceInternalPowerBus = InternalPowerBus,
  217. NdisInterfacePNPISABus = PNPISABus,
  218. NdisInterfacePNPBus = PNPBus,
  219. NdisMaximumInterfaceType
  220. } NDIS_INTERFACE_TYPE, *PNDIS_INTERFACE_TYPE;
  221. //
  222. // Definition for shutdown handler
  223. //
  224. typedef
  225. VOID
  226. (*ADAPTER_SHUTDOWN_HANDLER) (
  227. IN PVOID ShutdownContext
  228. );
  229. //
  230. // Stuff for PCI configuring
  231. //
  232. typedef CM_PARTIAL_RESOURCE_LIST NDIS_RESOURCE_LIST, *PNDIS_RESOURCE_LIST;
  233. //
  234. // The structure passed up on a WAN_LINE_UP indication
  235. //
  236. typedef struct _NDIS_WAN_LINE_UP
  237. {
  238. IN ULONG LinkSpeed; // 100 bps units
  239. IN ULONG MaximumTotalSize; // suggested max for send packets
  240. IN NDIS_WAN_QUALITY Quality;
  241. IN USHORT SendWindow; // suggested by the MAC
  242. IN UCHAR RemoteAddress[6];
  243. IN OUT UCHAR LocalAddress[6];
  244. IN ULONG ProtocolBufferLength; // Length of protocol info buffer
  245. IN PUCHAR ProtocolBuffer; // Information used by protocol
  246. IN USHORT ProtocolType; // Protocol ID
  247. IN OUT NDIS_STRING DeviceName;
  248. } NDIS_WAN_LINE_UP, *PNDIS_WAN_LINE_UP;
  249. //
  250. // The structure passed up on a WAN_LINE_DOWN indication
  251. //
  252. typedef struct _NDIS_WAN_LINE_DOWN
  253. {
  254. IN UCHAR RemoteAddress[6];
  255. IN UCHAR LocalAddress[6];
  256. } NDIS_WAN_LINE_DOWN, *PNDIS_WAN_LINE_DOWN;
  257. //
  258. // The structure passed up on a WAN_FRAGMENT indication
  259. //
  260. typedef struct _NDIS_WAN_FRAGMENT
  261. {
  262. IN UCHAR RemoteAddress[6];
  263. IN UCHAR LocalAddress[6];
  264. } NDIS_WAN_FRAGMENT, *PNDIS_WAN_FRAGMENT;
  265. //
  266. // The structure passed up on a WAN_GET_STATS indication
  267. //
  268. typedef struct _NDIS_WAN_GET_STATS
  269. {
  270. IN UCHAR LocalAddress[6];
  271. OUT ULONG BytesSent;
  272. OUT ULONG BytesRcvd;
  273. OUT ULONG FramesSent;
  274. OUT ULONG FramesRcvd;
  275. OUT ULONG CRCErrors; // Serial-like info only
  276. OUT ULONG TimeoutErrors; // Serial-like info only
  277. OUT ULONG AlignmentErrors; // Serial-like info only
  278. OUT ULONG SerialOverrunErrors; // Serial-like info only
  279. OUT ULONG FramingErrors; // Serial-like info only
  280. OUT ULONG BufferOverrunErrors; // Serial-like info only
  281. OUT ULONG BytesTransmittedUncompressed; // Compression info only
  282. OUT ULONG BytesReceivedUncompressed; // Compression info only
  283. OUT ULONG BytesTransmittedCompressed; // Compression info only
  284. OUT ULONG BytesReceivedCompressed; // Compression info only
  285. } NDIS_WAN_GET_STATS, *PNDIS_WAN_GET_STATS;
  286. //
  287. // DMA Channel information
  288. //
  289. typedef struct _NDIS_DMA_DESCRIPTION
  290. {
  291. BOOLEAN DemandMode;
  292. BOOLEAN AutoInitialize;
  293. BOOLEAN DmaChannelSpecified;
  294. DMA_WIDTH DmaWidth;
  295. DMA_SPEED DmaSpeed;
  296. ULONG DmaPort;
  297. ULONG DmaChannel;
  298. } NDIS_DMA_DESCRIPTION, *PNDIS_DMA_DESCRIPTION;
  299. //
  300. // Internal structure representing an NDIS DMA channel
  301. //
  302. typedef struct _NDIS_DMA_BLOCK
  303. {
  304. PVOID MapRegisterBase;
  305. KEVENT AllocationEvent;
  306. PVOID SystemAdapterObject;
  307. BOOLEAN InProgress;
  308. } NDIS_DMA_BLOCK, *PNDIS_DMA_BLOCK;
  309. #if defined(NDIS_WRAPPER)
  310. //
  311. // definitions for PnP state
  312. //
  313. typedef enum _NDIS_PNP_DEVICE_STATE
  314. {
  315. NdisPnPDeviceAdded,
  316. NdisPnPDeviceStarted,
  317. NdisPnPDeviceQueryStopped,
  318. NdisPnPDeviceStopped,
  319. NdisPnPDeviceQueryRemoved,
  320. NdisPnPDeviceRemoved,
  321. NdisPnPDeviceSurpriseRemoved
  322. } NDIS_PNP_DEVICE_STATE;
  323. //
  324. // flags to use in PnPCapabilities Flag
  325. //
  326. #define NDIS_DEVICE_NOT_STOPPABLE 0x00000001 // the debvice is not stoppable i.e. ISA
  327. #define NDIS_DEVICE_NOT_REMOVEABLE 0x00000002 // the device can not be safely removed
  328. #define NDIS_DEVICE_NOT_SUSPENDABLE 0x00000004 // the device can not be safely suspended
  329. #define NDIS_DEVICE_DISABLE_PM 0x00000008 // disable all PM features
  330. #define NDIS_DEVICE_DISABLE_WAKE_UP 0x00000010 // disable device waking up the system
  331. #define NDIS_DEVICE_DISABLE_WAKE_ON_RECONNECT 0x00000020 // disable device waking up the -system- due to a cable re-connect
  332. #define NDIS_DEVICE_RESERVED 0x00000040 // should not be used
  333. #define NDIS_DEVICE_DISABLE_WAKE_ON_MAGIC_PACKET 0x00000080 // disable device waking up the -system- due to a magic packet
  334. #define NDIS_DEVICE_DISABLE_WAKE_ON_PATTERN_MATCH 0x00000100 // disable device waking up the -system- due to a pattern match
  335. #endif // NDIS_WRAPPER defined
  336. //
  337. // Ndis Buffer is actually an Mdl
  338. //
  339. typedef MDL NDIS_BUFFER, *PNDIS_BUFFER;
  340. struct _NDIS_PACKET;
  341. typedef NDIS_HANDLE PNDIS_PACKET_POOL;
  342. //
  343. //
  344. // wrapper-specific part of a packet
  345. //
  346. typedef struct _NDIS_PACKET_PRIVATE
  347. {
  348. UINT PhysicalCount; // number of physical pages in packet.
  349. UINT TotalLength; // Total amount of data in the packet.
  350. PNDIS_BUFFER Head; // first buffer in the chain
  351. PNDIS_BUFFER Tail; // last buffer in the chain
  352. // if Head is NULL the chain is empty; Tail doesn't have to be NULL also
  353. PNDIS_PACKET_POOL Pool; // so we know where to free it back to
  354. UINT Count;
  355. ULONG Flags;
  356. BOOLEAN ValidCounts;
  357. UCHAR NdisPacketFlags; // See fPACKET_xxx bits below
  358. USHORT NdisPacketOobOffset;
  359. } NDIS_PACKET_PRIVATE, * PNDIS_PACKET_PRIVATE;
  360. //
  361. // The bits define the bits in the Flags
  362. //
  363. #define NDIS_FLAGS_PROTOCOL_ID_MASK 0x0000000F // The low 4 bits are defined for protocol-id
  364. // The values are defined in ntddndis.h
  365. #define NDIS_FLAGS_MULTICAST_PACKET 0x00000010 // don't use
  366. #define NDIS_FLAGS_RESERVED2 0x00000020 // don't use
  367. #define NDIS_FLAGS_RESERVED3 0x00000040 // don't use
  368. #define NDIS_FLAGS_DONT_LOOPBACK 0x00000080 // Write only
  369. #define NDIS_FLAGS_IS_LOOPBACK_PACKET 0x00000100 // Read only
  370. #define NDIS_FLAGS_LOOPBACK_ONLY 0x00000200 // Write only
  371. #define NDIS_FLAGS_RESERVED4 0x00000400 // don't use
  372. #define NDIS_FLAGS_DOUBLE_BUFFERED 0x00000800 // used by ndis
  373. #define NDIS_FLAGS_SENT_AT_DPC 0x00001000 // the protocol sent this packet at DPC
  374. #define NDIS_FLAGS_USES_SG_BUFFER_LIST 0x00002000 // used by Ndis
  375. //
  376. // Low-bits in the NdisPacketFlags are reserved by NDIS Wrapper for internal use
  377. //
  378. #define fPACKET_WRAPPER_RESERVED 0x3F
  379. #define fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO 0x40
  380. #define fPACKET_ALLOCATED_BY_NDIS 0x80
  381. //
  382. // Definition for layout of the media-specific data. More than one class of media-specific
  383. // information can be tagged onto a packet.
  384. //
  385. typedef enum _NDIS_CLASS_ID
  386. {
  387. NdisClass802_3Priority,
  388. NdisClassWirelessWanMbxMailbox,
  389. NdisClassIrdaPacketInfo,
  390. NdisClassAtmAALInfo
  391. } NDIS_CLASS_ID;
  392. typedef struct _MEDIA_SPECIFIC_INFORMATION
  393. {
  394. UINT NextEntryOffset;
  395. NDIS_CLASS_ID ClassId;
  396. UINT Size;
  397. UCHAR ClassInformation[1];
  398. } MEDIA_SPECIFIC_INFORMATION, *PMEDIA_SPECIFIC_INFORMATION;
  399. typedef struct _NDIS_PACKET_OOB_DATA
  400. {
  401. union
  402. {
  403. ULONGLONG TimeToSend;
  404. ULONGLONG TimeSent;
  405. };
  406. ULONGLONG TimeReceived;
  407. UINT HeaderSize;
  408. UINT SizeMediaSpecificInfo;
  409. PVOID MediaSpecificInformation;
  410. NDIS_STATUS Status;
  411. } NDIS_PACKET_OOB_DATA, *PNDIS_PACKET_OOB_DATA;
  412. #define NDIS_GET_PACKET_PROTOCOL_TYPE(_Packet_) ((_Packet_)->Private.Flags & NDIS_PROTOCOL_ID_MASK)
  413. #define NDIS_OOB_DATA_FROM_PACKET(_p) \
  414. (PNDIS_PACKET_OOB_DATA)((PUCHAR)(_p) + \
  415. (_p)->Private.NdisPacketOobOffset)
  416. #define NDIS_GET_PACKET_HEADER_SIZE(_Packet) \
  417. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  418. (_Packet)->Private.NdisPacketOobOffset))->HeaderSize
  419. #define NDIS_GET_PACKET_STATUS(_Packet) \
  420. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  421. (_Packet)->Private.NdisPacketOobOffset))->Status
  422. #define NDIS_GET_PACKET_TIME_TO_SEND(_Packet) \
  423. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  424. (_Packet)->Private.NdisPacketOobOffset))->TimeToSend
  425. #define NDIS_GET_PACKET_TIME_SENT(_Packet) \
  426. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  427. (_Packet)->Private.NdisPacketOobOffset))->TimeSent
  428. #define NDIS_GET_PACKET_TIME_RECEIVED(_Packet) \
  429. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  430. (_Packet)->Private.NdisPacketOobOffset))->TimeReceived
  431. #define NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO(_Packet, \
  432. _pMediaSpecificInfo, \
  433. _pSizeMediaSpecificInfo) \
  434. { \
  435. if (!((_Packet)->Private.NdisPacketFlags & fPACKET_ALLOCATED_BY_NDIS) ||\
  436. !((_Packet)->Private.NdisPacketFlags & fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO))\
  437. { \
  438. *(_pMediaSpecificInfo) = NULL; \
  439. *(_pSizeMediaSpecificInfo) = 0; \
  440. } \
  441. else \
  442. { \
  443. *(_pMediaSpecificInfo) =((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +\
  444. (_Packet)->Private.NdisPacketOobOffset))->MediaSpecificInformation;\
  445. *(_pSizeMediaSpecificInfo) = ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +\
  446. (_Packet)->Private.NdisPacketOobOffset))->SizeMediaSpecificInfo;\
  447. } \
  448. }
  449. #define NDIS_SET_PACKET_HEADER_SIZE(_Packet, _HdrSize) \
  450. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  451. (_Packet)->Private.NdisPacketOobOffset))->HeaderSize = (_HdrSize)
  452. #define NDIS_SET_PACKET_STATUS(_Packet, _Status) \
  453. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  454. (_Packet)->Private.NdisPacketOobOffset))->Status = (_Status)
  455. #define NDIS_SET_PACKET_TIME_TO_SEND(_Packet, _TimeToSend) \
  456. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  457. (_Packet)->Private.NdisPacketOobOffset))->TimeToSend = (_TimeToSend)
  458. #define NDIS_SET_PACKET_TIME_SENT(_Packet, _TimeSent) \
  459. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  460. (_Packet)->Private.NdisPacketOobOffset))->TimeSent = (_TimeSent)
  461. #define NDIS_SET_PACKET_TIME_RECEIVED(_Packet, _TimeReceived) \
  462. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  463. (_Packet)->Private.NdisPacketOobOffset))->TimeReceived = (_TimeReceived)
  464. #define NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(_Packet, \
  465. _MediaSpecificInfo, \
  466. _SizeMediaSpecificInfo) \
  467. { \
  468. if ((_Packet)->Private.NdisPacketFlags & fPACKET_ALLOCATED_BY_NDIS) \
  469. { \
  470. (_Packet)->Private.NdisPacketFlags |= fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO;\
  471. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  472. (_Packet)->Private.NdisPacketOobOffset))->MediaSpecificInformation = (_MediaSpecificInfo);\
  473. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  474. (_Packet)->Private.NdisPacketOobOffset))->SizeMediaSpecificInfo = (_SizeMediaSpecificInfo);\
  475. } \
  476. }
  477. //
  478. // packet definition
  479. //
  480. typedef struct _NDIS_PACKET
  481. {
  482. NDIS_PACKET_PRIVATE Private;
  483. union
  484. {
  485. struct // For Connection-less miniports
  486. {
  487. UCHAR MiniportReserved[2*sizeof(PVOID)];
  488. UCHAR WrapperReserved[2*sizeof(PVOID)];
  489. };
  490. struct
  491. {
  492. //
  493. // For de-serialized miniports. And by implication conn-oriented miniports.
  494. // This is for the send-path only. Packets indicated will use WrapperReserved
  495. // instead of WrapperReservedEx
  496. //
  497. UCHAR MiniportReservedEx[3*sizeof(PVOID)];
  498. UCHAR WrapperReservedEx[sizeof(PVOID)];
  499. };
  500. struct
  501. {
  502. UCHAR MacReserved[4*sizeof(PVOID)];
  503. };
  504. };
  505. ULONG_PTR Reserved[2]; // For compatibility with Win95
  506. UCHAR ProtocolReserved[1];
  507. } NDIS_PACKET, *PNDIS_PACKET, **PPNDIS_PACKET;
  508. //
  509. // NDIS per-packet information.
  510. //
  511. typedef enum _NDIS_PER_PACKET_INFO
  512. {
  513. TcpIpChecksumPacketInfo,
  514. IpSecPacketInfo,
  515. TcpLargeSendPacketInfo,
  516. ClassificationHandlePacketInfo,
  517. NdisReserved,
  518. ScatterGatherListPacketInfo,
  519. Ieee8021QInfo,
  520. OriginalPacketInfo,
  521. PacketCancelId,
  522. MaxPerPacketInfo
  523. } NDIS_PER_PACKET_INFO, *PNDIS_PER_PACKET_INFO;
  524. typedef struct _NDIS_PACKET_EXTENSION
  525. {
  526. PVOID NdisPacketInfo[MaxPerPacketInfo];
  527. } NDIS_PACKET_EXTENSION, *PNDIS_PACKET_EXTENSION;
  528. #define NDIS_PACKET_EXTENSION_FROM_PACKET(_P) ((PNDIS_PACKET_EXTENSION)((PUCHAR)(_P) + (_P)->Private.NdisPacketOobOffset + sizeof(NDIS_PACKET_OOB_DATA)))
  529. #define NDIS_PER_PACKET_INFO_FROM_PACKET(_P, _Id) ((PNDIS_PACKET_EXTENSION)((PUCHAR)(_P) + (_P)->Private.NdisPacketOobOffset + sizeof(NDIS_PACKET_OOB_DATA)))->NdisPacketInfo[(_Id)]
  530. #define NDIS_GET_ORIGINAL_PACKET(_P) NDIS_PER_PACKET_INFO_FROM_PACKET(_P, OriginalPacketInfo)
  531. #define NDIS_SET_ORIGINAL_PACKET(_P, _OP) NDIS_PER_PACKET_INFO_FROM_PACKET(_P, OriginalPacketInfo) = _OP
  532. #define NDIS_GET_PACKET_CANCEL_ID(_P) NDIS_PER_PACKET_INFO_FROM_PACKET(_P, PacketCancelId)
  533. #define NDIS_SET_PACKET_CANCEL_ID(_P, _cId) NDIS_PER_PACKET_INFO_FROM_PACKET(_P, PacketCancelId) = _cId
  534. typedef struct _NDIS_PACKET_STACK
  535. {
  536. ULONG_PTR IMReserved[2];
  537. ULONG_PTR NdisReserved[4];
  538. } NDIS_PACKET_STACK, *PNDIS_PACKET_STACK;
  539. //
  540. // Per-packet information for TcpIpChecksumPacketInfo.
  541. //
  542. typedef struct _NDIS_TCP_IP_CHECKSUM_PACKET_INFO
  543. {
  544. union
  545. {
  546. struct
  547. {
  548. ULONG NdisPacketChecksumV4:1;
  549. ULONG NdisPacketChecksumV6:1;
  550. ULONG NdisPacketTcpChecksum:1;
  551. ULONG NdisPacketUdpChecksum:1;
  552. ULONG NdisPacketIpChecksum:1;
  553. } Transmit;
  554. struct
  555. {
  556. ULONG NdisPacketTcpChecksumFailed:1;
  557. ULONG NdisPacketUdpChecksumFailed:1;
  558. ULONG NdisPacketIpChecksumFailed:1;
  559. ULONG NdisPacketTcpChecksumSucceeded:1;
  560. ULONG NdisPacketUdpChecksumSucceeded:1;
  561. ULONG NdisPacketIpChecksumSucceeded:1;
  562. ULONG NdisPacketLoopback:1;
  563. } Receive;
  564. ULONG Value;
  565. };
  566. } NDIS_TCP_IP_CHECKSUM_PACKET_INFO, *PNDIS_TCP_IP_CHECKSUM_PACKET_INFO;
  567. //
  568. // Per-packet information for Ieee8021QInfo.
  569. //
  570. typedef struct _NDIS_PACKET_8021Q_INFO
  571. {
  572. union
  573. {
  574. struct
  575. {
  576. UINT32 UserPriority:3; // 802.1p priority
  577. UINT32 CanonicalFormatId:1; // always 0
  578. UINT32 VlanId:12; // VLAN Identification
  579. UINT32 Reserved:16; // set to 0
  580. } TagHeader;
  581. PVOID Value;
  582. };
  583. } NDIS_PACKET_8021Q_INFO, *PNDIS_PACKET_8021Q_INFO;
  584. //
  585. // Old definitions, to be obsoleted.
  586. //
  587. #define Ieee8021pPriority Ieee8021QInfo
  588. typedef UINT IEEE8021PPRIORITY;
  589. #define MAX_HASHES 4
  590. #define TRUNCATED_HASH_LEN 12
  591. #define CRYPTO_SUCCESS 0
  592. #define CRYPTO_GENERIC_ERROR 1
  593. #define CRYPTO_TRANSPORT_AH_AUTH_FAILED 2
  594. #define CRYPTO_TRANSPORT_ESP_AUTH_FAILED 3
  595. #define CRYPTO_TUNNEL_AH_AUTH_FAILED 4
  596. #define CRYPTO_TUNNEL_ESP_AUTH_FAILED 5
  597. #define CRYPTO_INVALID_PACKET_SYNTAX 6
  598. #define CRYPTO_INVALID_PROTOCOL 7
  599. typedef struct _NDIS_IPSEC_PACKET_INFO
  600. {
  601. union
  602. {
  603. struct
  604. {
  605. NDIS_HANDLE OffloadHandle;
  606. NDIS_HANDLE NextOffloadHandle;
  607. } Transmit;
  608. struct
  609. {
  610. ULONG SA_DELETE_REQ:1;
  611. ULONG CRYPTO_DONE:1;
  612. ULONG NEXT_CRYPTO_DONE:1;
  613. ULONG CryptoStatus;
  614. } Receive;
  615. };
  616. } NDIS_IPSEC_PACKET_INFO, *PNDIS_IPSEC_PACKET_INFO;
  617. ///
  618. // NDIS Task Off-Load data structures.
  619. ///
  620. #define NDIS_TASK_OFFLOAD_VERSION 1
  621. //
  622. // The following defines are used in the Task field above to define
  623. // the type of task offloading necessary.
  624. //
  625. typedef enum _NDIS_TASK
  626. {
  627. TcpIpChecksumNdisTask,
  628. IpSecNdisTask,
  629. TcpLargeSendNdisTask,
  630. MaxNdisTask
  631. } NDIS_TASK, *PNDIS_TASK;
  632. typedef enum _NDIS_ENCAPSULATION
  633. {
  634. UNSPECIFIED_Encapsulation,
  635. NULL_Encapsulation,
  636. IEEE_802_3_Encapsulation,
  637. IEEE_802_5_Encapsulation,
  638. LLC_SNAP_ROUTED_Encapsulation,
  639. LLC_SNAP_BRIDGED_Encapsulation
  640. } NDIS_ENCAPSULATION;
  641. //
  642. // Encapsulation header format
  643. //
  644. typedef struct _NDIS_ENCAPSULATION_FORMAT
  645. {
  646. NDIS_ENCAPSULATION Encapsulation; // Encapsulation type
  647. struct
  648. {
  649. ULONG FixedHeaderSize:1;
  650. ULONG Reserved:31;
  651. } Flags;
  652. ULONG EncapsulationHeaderSize; // Encapsulation header size
  653. } NDIS_ENCAPSULATION_FORMAT,*PNDIS_ENCAPSULATION_FORMAT;
  654. //
  655. // OFFLOAD header structure for OID_TCP_TASK_OFFLOAD
  656. //
  657. typedef struct _NDIS_TASK_OFFLOAD_HEADER
  658. {
  659. ULONG Version; // set to NDIS_TASK_OFFLOAD_VERSION
  660. ULONG Size; // Size of this structure
  661. ULONG Reserved; // Reserved for future use
  662. ULONG OffsetFirstTask; // Offset to the first
  663. NDIS_ENCAPSULATION_FORMAT EncapsulationFormat; // Encapsulation information.
  664. // NDIS_TASK_OFFLOAD structure(s)
  665. } NDIS_TASK_OFFLOAD_HEADER, *PNDIS_TASK_OFFLOAD_HEADER;
  666. //
  667. // Task offload Structure, which follows the above header in ndis query
  668. //
  669. typedef struct _NDIS_TASK_OFFLOAD
  670. {
  671. ULONG Version; // NDIS_TASK_OFFLOAD_VERSION
  672. ULONG Size; // Size of this structure. Used for version checking.
  673. NDIS_TASK Task; // Task.
  674. ULONG OffsetNextTask; // Offset to the next NDIS_TASK_OFFLOAD
  675. ULONG TaskBufferLength; // Length of the task offload information.
  676. UCHAR TaskBuffer[1]; // The task offload information.
  677. } NDIS_TASK_OFFLOAD, *PNDIS_TASK_OFFLOAD;
  678. //
  679. // Offload structure for NDIS_TASK_TCP_IP_CHECKSUM
  680. //
  681. typedef struct _NDIS_TASK_TCP_IP_CHECKSUM
  682. {
  683. struct
  684. {
  685. ULONG IpOptionsSupported:1;
  686. ULONG TcpOptionsSupported:1;
  687. ULONG TcpChecksum:1;
  688. ULONG UdpChecksum:1;
  689. ULONG IpChecksum:1;
  690. } V4Transmit;
  691. struct
  692. {
  693. ULONG IpOptionsSupported:1;
  694. ULONG TcpOptionsSupported:1;
  695. ULONG TcpChecksum:1;
  696. ULONG UdpChecksum:1;
  697. ULONG IpChecksum:1;
  698. } V4Receive;
  699. struct
  700. {
  701. ULONG IpOptionsSupported:1;
  702. ULONG TcpOptionsSupported:1;
  703. ULONG TcpChecksum:1;
  704. ULONG UdpChecksum:1;
  705. } V6Transmit;
  706. struct
  707. {
  708. ULONG IpOptionsSupported:1;
  709. ULONG TcpOptionsSupported:1;
  710. ULONG TcpChecksum:1;
  711. ULONG UdpChecksum:1;
  712. } V6Receive;
  713. } NDIS_TASK_TCP_IP_CHECKSUM, *PNDIS_TASK_TCP_IP_CHECKSUM;
  714. //
  715. // Off-load structure for NDIS_TASK_TCP_LARGE_SEND
  716. //
  717. typedef struct _NDIS_TASK_TCP_LARGE_SEND
  718. {
  719. ULONG Version;
  720. ULONG MaxOffLoadSize;
  721. ULONG MinSegmentCount;
  722. BOOLEAN TcpOptions;
  723. BOOLEAN IpOptions;
  724. } NDIS_TASK_TCP_LARGE_SEND, *PNDIS_TASK_TCP_LARGE_SEND;
  725. typedef struct _NDIS_TASK_IPSEC
  726. {
  727. struct
  728. {
  729. ULONG AH_ESP_COMBINED;
  730. ULONG TRANSPORT_TUNNEL_COMBINED;
  731. ULONG V4_OPTIONS;
  732. ULONG RESERVED;
  733. } Supported;
  734. struct
  735. {
  736. ULONG MD5:1;
  737. ULONG SHA_1:1;
  738. ULONG Transport:1;
  739. ULONG Tunnel:1;
  740. ULONG Send:1;
  741. ULONG Receive:1;
  742. } V4AH;
  743. struct
  744. {
  745. ULONG DES:1;
  746. ULONG RESERVED:1;
  747. ULONG TRIPLE_DES:1;
  748. ULONG NULL_ESP:1;
  749. ULONG Transport:1;
  750. ULONG Tunnel:1;
  751. ULONG Send:1;
  752. ULONG Receive:1;
  753. } V4ESP;
  754. } NDIS_TASK_IPSEC, *PNDIS_TASK_IPSEC;
  755. typedef UINT IEEE8021PPRIORITY;
  756. //
  757. // WAN Packet. This is used by WAN miniports only. This is the legacy model.
  758. // Co-Ndis is the preferred model for WAN miniports
  759. //
  760. typedef struct _NDIS_WAN_PACKET
  761. {
  762. LIST_ENTRY WanPacketQueue;
  763. PUCHAR CurrentBuffer;
  764. ULONG CurrentLength;
  765. PUCHAR StartBuffer;
  766. PUCHAR EndBuffer;
  767. PVOID ProtocolReserved1;
  768. PVOID ProtocolReserved2;
  769. PVOID ProtocolReserved3;
  770. PVOID ProtocolReserved4;
  771. PVOID MacReserved1;
  772. PVOID MacReserved2;
  773. PVOID MacReserved3;
  774. PVOID MacReserved4;
  775. } NDIS_WAN_PACKET, *PNDIS_WAN_PACKET;
  776. //
  777. // Routines to get/set packet flags
  778. //
  779. /*++
  780. UINT
  781. NdisGetPacketFlags(
  782. IN PNDIS_PACKET Packet
  783. );
  784. --*/
  785. #define NdisGetPacketFlags(_Packet) (_Packet)->Private.Flags
  786. /*++
  787. VOID
  788. NdisSetPacketFlags(
  789. IN PNDIS_PACKET Packet,
  790. IN UINT Flags
  791. );
  792. --*/
  793. #define NdisSetPacketFlags(_Packet, _Flags) (_Packet)->Private.Flags |= (_Flags)
  794. #define NdisClearPacketFlags(_Packet, _Flags) (_Packet)->Private.Flags &= ~(_Flags)
  795. //
  796. // Request types used by NdisRequest; constants are added for
  797. // all entry points in the MAC, for those that want to create
  798. // their own internal requests.
  799. //
  800. typedef enum _NDIS_REQUEST_TYPE
  801. {
  802. NdisRequestQueryInformation,
  803. NdisRequestSetInformation,
  804. NdisRequestQueryStatistics,
  805. NdisRequestOpen,
  806. NdisRequestClose,
  807. NdisRequestSend,
  808. NdisRequestTransferData,
  809. NdisRequestReset,
  810. NdisRequestGeneric1,
  811. NdisRequestGeneric2,
  812. NdisRequestGeneric3,
  813. NdisRequestGeneric4
  814. } NDIS_REQUEST_TYPE, *PNDIS_REQUEST_TYPE;
  815. //
  816. // Structure of requests sent via NdisRequest
  817. //
  818. typedef struct _NDIS_REQUEST
  819. {
  820. UCHAR MacReserved[4*sizeof(PVOID)];
  821. NDIS_REQUEST_TYPE RequestType;
  822. union _DATA
  823. {
  824. struct _QUERY_INFORMATION
  825. {
  826. NDIS_OID Oid;
  827. PVOID InformationBuffer;
  828. UINT InformationBufferLength;
  829. UINT BytesWritten;
  830. UINT BytesNeeded;
  831. } QUERY_INFORMATION;
  832. struct _SET_INFORMATION
  833. {
  834. NDIS_OID Oid;
  835. PVOID InformationBuffer;
  836. UINT InformationBufferLength;
  837. UINT BytesRead;
  838. UINT BytesNeeded;
  839. } SET_INFORMATION;
  840. } DATA;
  841. #if (defined(NDIS50) || defined(NDIS51) || defined(NDIS50_MINIPORT) || defined(NDIS51_MINIPORT))
  842. UCHAR NdisReserved[9*sizeof(PVOID)];
  843. union
  844. {
  845. UCHAR CallMgrReserved[2*sizeof(PVOID)];
  846. UCHAR ProtocolReserved[2*sizeof(PVOID)];
  847. };
  848. UCHAR MiniportReserved[2*sizeof(PVOID)];
  849. #endif
  850. } NDIS_REQUEST, *PNDIS_REQUEST;
  851. //
  852. // NDIS Address Family definitions.
  853. //
  854. typedef ULONG NDIS_AF, *PNDIS_AF;
  855. #define CO_ADDRESS_FAMILY_Q2931 ((NDIS_AF)0x1) // ATM
  856. #define CO_ADDRESS_FAMILY_PSCHED ((NDIS_AF)0x2) // Packet scheduler
  857. #define CO_ADDRESS_FAMILY_L2TP ((NDIS_AF)0x3)
  858. #define CO_ADDRESS_FAMILY_IRDA ((NDIS_AF)0x4)
  859. #define CO_ADDRESS_FAMILY_1394 ((NDIS_AF)0x5)
  860. #define CO_ADDRESS_FAMILY_PPP ((NDIS_AF)0x6)
  861. #define CO_ADDRESS_FAMILY_TAPI ((NDIS_AF)0x800)
  862. #define CO_ADDRESS_FAMILY_TAPI_PROXY ((NDIS_AF)0x801)
  863. //
  864. // The following is OR'ed with the base AF to denote proxy support
  865. //
  866. #define CO_ADDRESS_FAMILY_PROXY 0x80000000
  867. //
  868. // Address family structure registered/opened via
  869. // NdisCmRegisterAddressFamily
  870. // NdisClOpenAddressFamily
  871. //
  872. typedef struct
  873. {
  874. NDIS_AF AddressFamily; // one of the CO_ADDRESS_FAMILY_xxx values above
  875. ULONG MajorVersion; // the major version of call manager
  876. ULONG MinorVersion; // the minor version of call manager
  877. } CO_ADDRESS_FAMILY, *PCO_ADDRESS_FAMILY;
  878. //
  879. // Definition for a SAP
  880. //
  881. typedef struct
  882. {
  883. ULONG SapType;
  884. ULONG SapLength;
  885. UCHAR Sap[1];
  886. } CO_SAP, *PCO_SAP;
  887. //
  888. // Definitions for physical address.
  889. //
  890. typedef PHYSICAL_ADDRESS NDIS_PHYSICAL_ADDRESS, *PNDIS_PHYSICAL_ADDRESS;
  891. typedef struct _NDIS_PHYSICAL_ADDRESS_UNIT
  892. {
  893. NDIS_PHYSICAL_ADDRESS PhysicalAddress;
  894. UINT Length;
  895. } NDIS_PHYSICAL_ADDRESS_UNIT, *PNDIS_PHYSICAL_ADDRESS_UNIT;
  896. /*++
  897. ULONG
  898. NdisGetPhysicalAddressHigh(
  899. IN NDIS_PHYSICAL_ADDRESS PhysicalAddress
  900. );
  901. --*/
  902. #define NdisGetPhysicalAddressHigh(_PhysicalAddress) \
  903. ((_PhysicalAddress).HighPart)
  904. /*++
  905. VOID
  906. NdisSetPhysicalAddressHigh(
  907. IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
  908. IN ULONG Value
  909. );
  910. --*/
  911. #define NdisSetPhysicalAddressHigh(_PhysicalAddress, _Value) \
  912. ((_PhysicalAddress).HighPart) = (_Value)
  913. /*++
  914. ULONG
  915. NdisGetPhysicalAddressLow(
  916. IN NDIS_PHYSICAL_ADDRESS PhysicalAddress
  917. );
  918. --*/
  919. #define NdisGetPhysicalAddressLow(_PhysicalAddress) \
  920. ((_PhysicalAddress).LowPart)
  921. /*++
  922. VOID
  923. NdisSetPhysicalAddressLow(
  924. IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
  925. IN ULONG Value
  926. );
  927. --*/
  928. #define NdisSetPhysicalAddressLow(_PhysicalAddress, _Value) \
  929. ((_PhysicalAddress).LowPart) = (_Value)
  930. //
  931. // Macro to initialize an NDIS_PHYSICAL_ADDRESS constant
  932. //
  933. #define NDIS_PHYSICAL_ADDRESS_CONST(_Low, _High) \
  934. { (ULONG)(_Low), (LONG)(_High) }
  935. //
  936. // block used for references...
  937. //
  938. typedef struct _REFERENCE
  939. {
  940. KSPIN_LOCK SpinLock;
  941. USHORT ReferenceCount;
  942. BOOLEAN Closing;
  943. } REFERENCE, * PREFERENCE;
  944. //
  945. // block used for references using a ULONG
  946. //
  947. typedef struct _ULONG_REFERENCE
  948. {
  949. KSPIN_LOCK SpinLock;
  950. ULONG ReferenceCount;
  951. BOOLEAN Closing;
  952. } ULONG_REFERENCE, *PULONG_REFERENCE;
  953. //
  954. // This holds a map register entry.
  955. //
  956. typedef struct _MAP_REGISTER_ENTRY
  957. {
  958. PVOID MapRegister;
  959. BOOLEAN WriteToDevice;
  960. } MAP_REGISTER_ENTRY, * PMAP_REGISTER_ENTRY;
  961. //
  962. // Types of Memory (not mutually exclusive)
  963. //
  964. #define NDIS_MEMORY_CONTIGUOUS 0x00000001
  965. #define NDIS_MEMORY_NONCACHED 0x00000002
  966. //
  967. // Open options
  968. //
  969. #define NDIS_OPEN_RECEIVE_NOT_REENTRANT 0x00000001
  970. //
  971. // NDIS_STATUS values
  972. //
  973. #define NDIS_STATUS_SUCCESS ((NDIS_STATUS)STATUS_SUCCESS)
  974. #define NDIS_STATUS_PENDING ((NDIS_STATUS) STATUS_PENDING)
  975. #define NDIS_STATUS_NOT_RECOGNIZED ((NDIS_STATUS)0x00010001L)
  976. #define NDIS_STATUS_NOT_COPIED ((NDIS_STATUS)0x00010002L)
  977. #define NDIS_STATUS_NOT_ACCEPTED ((NDIS_STATUS)0x00010003L)
  978. #define NDIS_STATUS_CALL_ACTIVE ((NDIS_STATUS)0x00010007L)
  979. #define NDIS_STATUS_ONLINE ((NDIS_STATUS)0x40010003L)
  980. #define NDIS_STATUS_RESET_START ((NDIS_STATUS)0x40010004L)
  981. #define NDIS_STATUS_RESET_END ((NDIS_STATUS)0x40010005L)
  982. #define NDIS_STATUS_RING_STATUS ((NDIS_STATUS)0x40010006L)
  983. #define NDIS_STATUS_CLOSED ((NDIS_STATUS)0x40010007L)
  984. #define NDIS_STATUS_WAN_LINE_UP ((NDIS_STATUS)0x40010008L)
  985. #define NDIS_STATUS_WAN_LINE_DOWN ((NDIS_STATUS)0x40010009L)
  986. #define NDIS_STATUS_WAN_FRAGMENT ((NDIS_STATUS)0x4001000AL)
  987. #define NDIS_STATUS_MEDIA_CONNECT ((NDIS_STATUS)0x4001000BL)
  988. #define NDIS_STATUS_MEDIA_DISCONNECT ((NDIS_STATUS)0x4001000CL)
  989. #define NDIS_STATUS_HARDWARE_LINE_UP ((NDIS_STATUS)0x4001000DL)
  990. #define NDIS_STATUS_HARDWARE_LINE_DOWN ((NDIS_STATUS)0x4001000EL)
  991. #define NDIS_STATUS_INTERFACE_UP ((NDIS_STATUS)0x4001000FL)
  992. #define NDIS_STATUS_INTERFACE_DOWN ((NDIS_STATUS)0x40010010L)
  993. #define NDIS_STATUS_MEDIA_BUSY ((NDIS_STATUS)0x40010011L)
  994. #define NDIS_STATUS_MEDIA_SPECIFIC_INDICATION ((NDIS_STATUS)0x40010012L)
  995. #define NDIS_STATUS_WW_INDICATION NDIS_STATUS_MEDIA_SPECIFIC_INDICATION
  996. #define NDIS_STATUS_LINK_SPEED_CHANGE ((NDIS_STATUS)0x40010013L)
  997. #define NDIS_STATUS_WAN_GET_STATS ((NDIS_STATUS)0x40010014L)
  998. #define NDIS_STATUS_WAN_CO_FRAGMENT ((NDIS_STATUS)0x40010015L)
  999. #define NDIS_STATUS_WAN_CO_LINKPARAMS ((NDIS_STATUS)0x40010016L)
  1000. #define NDIS_STATUS_NOT_RESETTABLE ((NDIS_STATUS)0x80010001L)
  1001. #define NDIS_STATUS_SOFT_ERRORS ((NDIS_STATUS)0x80010003L)
  1002. #define NDIS_STATUS_HARD_ERRORS ((NDIS_STATUS)0x80010004L)
  1003. #define NDIS_STATUS_BUFFER_OVERFLOW ((NDIS_STATUS)STATUS_BUFFER_OVERFLOW)
  1004. #define NDIS_STATUS_FAILURE ((NDIS_STATUS) STATUS_UNSUCCESSFUL)
  1005. #define NDIS_STATUS_RESOURCES ((NDIS_STATUS)STATUS_INSUFFICIENT_RESOURCES)
  1006. #define NDIS_STATUS_CLOSING ((NDIS_STATUS)0xC0010002L)
  1007. #define NDIS_STATUS_BAD_VERSION ((NDIS_STATUS)0xC0010004L)
  1008. #define NDIS_STATUS_BAD_CHARACTERISTICS ((NDIS_STATUS)0xC0010005L)
  1009. #define NDIS_STATUS_ADAPTER_NOT_FOUND ((NDIS_STATUS)0xC0010006L)
  1010. #define NDIS_STATUS_OPEN_FAILED ((NDIS_STATUS)0xC0010007L)
  1011. #define NDIS_STATUS_DEVICE_FAILED ((NDIS_STATUS)0xC0010008L)
  1012. #define NDIS_STATUS_MULTICAST_FULL ((NDIS_STATUS)0xC0010009L)
  1013. #define NDIS_STATUS_MULTICAST_EXISTS ((NDIS_STATUS)0xC001000AL)
  1014. #define NDIS_STATUS_MULTICAST_NOT_FOUND ((NDIS_STATUS)0xC001000BL)
  1015. #define NDIS_STATUS_REQUEST_ABORTED ((NDIS_STATUS)0xC001000CL)
  1016. #define NDIS_STATUS_RESET_IN_PROGRESS ((NDIS_STATUS)0xC001000DL)
  1017. #define NDIS_STATUS_CLOSING_INDICATING ((NDIS_STATUS)0xC001000EL)
  1018. #define NDIS_STATUS_NOT_SUPPORTED ((NDIS_STATUS)STATUS_NOT_SUPPORTED)
  1019. #define NDIS_STATUS_INVALID_PACKET ((NDIS_STATUS)0xC001000FL)
  1020. #define NDIS_STATUS_OPEN_LIST_FULL ((NDIS_STATUS)0xC0010010L)
  1021. #define NDIS_STATUS_ADAPTER_NOT_READY ((NDIS_STATUS)0xC0010011L)
  1022. #define NDIS_STATUS_ADAPTER_NOT_OPEN ((NDIS_STATUS)0xC0010012L)
  1023. #define NDIS_STATUS_NOT_INDICATING ((NDIS_STATUS)0xC0010013L)
  1024. #define NDIS_STATUS_INVALID_LENGTH ((NDIS_STATUS)0xC0010014L)
  1025. #define NDIS_STATUS_INVALID_DATA ((NDIS_STATUS)0xC0010015L)
  1026. #define NDIS_STATUS_BUFFER_TOO_SHORT ((NDIS_STATUS)0xC0010016L)
  1027. #define NDIS_STATUS_INVALID_OID ((NDIS_STATUS)0xC0010017L)
  1028. #define NDIS_STATUS_ADAPTER_REMOVED ((NDIS_STATUS)0xC0010018L)
  1029. #define NDIS_STATUS_UNSUPPORTED_MEDIA ((NDIS_STATUS)0xC0010019L)
  1030. #define NDIS_STATUS_GROUP_ADDRESS_IN_USE ((NDIS_STATUS)0xC001001AL)
  1031. #define NDIS_STATUS_FILE_NOT_FOUND ((NDIS_STATUS)0xC001001BL)
  1032. #define NDIS_STATUS_ERROR_READING_FILE ((NDIS_STATUS)0xC001001CL)
  1033. #define NDIS_STATUS_ALREADY_MAPPED ((NDIS_STATUS)0xC001001DL)
  1034. #define NDIS_STATUS_RESOURCE_CONFLICT ((NDIS_STATUS)0xC001001EL)
  1035. #define NDIS_STATUS_NO_CABLE ((NDIS_STATUS)0xC001001FL)
  1036. #define NDIS_STATUS_INVALID_SAP ((NDIS_STATUS)0xC0010020L)
  1037. #define NDIS_STATUS_SAP_IN_USE ((NDIS_STATUS)0xC0010021L)
  1038. #define NDIS_STATUS_INVALID_ADDRESS ((NDIS_STATUS)0xC0010022L)
  1039. #define NDIS_STATUS_VC_NOT_ACTIVATED ((NDIS_STATUS)0xC0010023L)
  1040. #define NDIS_STATUS_DEST_OUT_OF_ORDER ((NDIS_STATUS)0xC0010024L) // cause 27
  1041. #define NDIS_STATUS_VC_NOT_AVAILABLE ((NDIS_STATUS)0xC0010025L) // cause 35,45
  1042. #define NDIS_STATUS_CELLRATE_NOT_AVAILABLE ((NDIS_STATUS)0xC0010026L) // cause 37
  1043. #define NDIS_STATUS_INCOMPATABLE_QOS ((NDIS_STATUS)0xC0010027L) // cause 49
  1044. #define NDIS_STATUS_AAL_PARAMS_UNSUPPORTED ((NDIS_STATUS)0xC0010028L) // cause 93
  1045. #define NDIS_STATUS_NO_ROUTE_TO_DESTINATION ((NDIS_STATUS)0xC0010029L) // cause 3
  1046. #define NDIS_STATUS_TOKEN_RING_OPEN_ERROR ((NDIS_STATUS)0xC0011000L)
  1047. #define NDIS_STATUS_INVALID_DEVICE_REQUEST ((NDIS_STATUS)STATUS_INVALID_DEVICE_REQUEST)
  1048. #define NDIS_STATUS_NETWORK_UNREACHABLE ((NDIS_STATUS)STATUS_NETWORK_UNREACHABLE)
  1049. //
  1050. // used in error logging
  1051. //
  1052. #define NDIS_ERROR_CODE ULONG
  1053. #define NDIS_ERROR_CODE_RESOURCE_CONFLICT EVENT_NDIS_RESOURCE_CONFLICT
  1054. #define NDIS_ERROR_CODE_OUT_OF_RESOURCES EVENT_NDIS_OUT_OF_RESOURCE
  1055. #define NDIS_ERROR_CODE_HARDWARE_FAILURE EVENT_NDIS_HARDWARE_FAILURE
  1056. #define NDIS_ERROR_CODE_ADAPTER_NOT_FOUND EVENT_NDIS_ADAPTER_NOT_FOUND
  1057. #define NDIS_ERROR_CODE_INTERRUPT_CONNECT EVENT_NDIS_INTERRUPT_CONNECT
  1058. #define NDIS_ERROR_CODE_DRIVER_FAILURE EVENT_NDIS_DRIVER_FAILURE
  1059. #define NDIS_ERROR_CODE_BAD_VERSION EVENT_NDIS_BAD_VERSION
  1060. #define NDIS_ERROR_CODE_TIMEOUT EVENT_NDIS_TIMEOUT
  1061. #define NDIS_ERROR_CODE_NETWORK_ADDRESS EVENT_NDIS_NETWORK_ADDRESS
  1062. #define NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION EVENT_NDIS_UNSUPPORTED_CONFIGURATION
  1063. #define NDIS_ERROR_CODE_INVALID_VALUE_FROM_ADAPTER EVENT_NDIS_INVALID_VALUE_FROM_ADAPTER
  1064. #define NDIS_ERROR_CODE_MISSING_CONFIGURATION_PARAMETER EVENT_NDIS_MISSING_CONFIGURATION_PARAMETER
  1065. #define NDIS_ERROR_CODE_BAD_IO_BASE_ADDRESS EVENT_NDIS_BAD_IO_BASE_ADDRESS
  1066. #define NDIS_ERROR_CODE_RECEIVE_SPACE_SMALL EVENT_NDIS_RECEIVE_SPACE_SMALL
  1067. #define NDIS_ERROR_CODE_ADAPTER_DISABLED EVENT_NDIS_ADAPTER_DISABLED
  1068. #if BINARY_COMPATIBLE
  1069. #if USE_KLOCKS
  1070. #define DISPATCH_LEVEL 2
  1071. #define NdisAllocateSpinLock(_SpinLock) KeInitializeSpinLock(&(_SpinLock)->SpinLock)
  1072. #define NdisFreeSpinLock(_SpinLock)
  1073. #define NdisAcquireSpinLock(_SpinLock) KeAcquireSpinLock(&(_SpinLock)->SpinLock, &(_SpinLock)->OldIrql)
  1074. #define NdisReleaseSpinLock(_SpinLock) KeReleaseSpinLock(&(_SpinLock)->SpinLock,(_SpinLock)->OldIrql)
  1075. #define NdisDprAcquireSpinLock(_SpinLock) \
  1076. { \
  1077. KeAcquireSpinLockAtDpcLevel(&(_SpinLock)->SpinLock); \
  1078. (_SpinLock)->OldIrql = DISPATCH_LEVEL; \
  1079. }
  1080. #define NdisDprReleaseSpinLock(_SpinLock) KeReleaseSpinLockFromDpcLevel(&(_SpinLock)->SpinLock)
  1081. #else
  1082. //
  1083. // Ndis Spin Locks
  1084. //
  1085. EXPORT
  1086. VOID
  1087. NdisAllocateSpinLock(
  1088. IN PNDIS_SPIN_LOCK SpinLock
  1089. );
  1090. EXPORT
  1091. VOID
  1092. NdisFreeSpinLock(
  1093. IN PNDIS_SPIN_LOCK SpinLock
  1094. );
  1095. EXPORT
  1096. VOID
  1097. NdisAcquireSpinLock(
  1098. IN PNDIS_SPIN_LOCK SpinLock
  1099. );
  1100. EXPORT
  1101. VOID
  1102. NdisReleaseSpinLock(
  1103. IN PNDIS_SPIN_LOCK SpinLock
  1104. );
  1105. EXPORT
  1106. VOID
  1107. NdisDprAcquireSpinLock(
  1108. IN PNDIS_SPIN_LOCK SpinLock
  1109. );
  1110. EXPORT
  1111. VOID
  1112. NdisDprReleaseSpinLock(
  1113. IN PNDIS_SPIN_LOCK SpinLock
  1114. );
  1115. #endif
  1116. EXPORT
  1117. VOID
  1118. NdisGetCurrentSystemTime(
  1119. PLARGE_INTEGER pSystemTime
  1120. );
  1121. //
  1122. // Interlocked support functions
  1123. //
  1124. EXPORT
  1125. ULONG
  1126. NdisInterlockedIncrement(
  1127. IN PLONG Addend
  1128. );
  1129. EXPORT
  1130. ULONG
  1131. NdisInterlockedDecrement(
  1132. IN PLONG Addend
  1133. );
  1134. EXPORT
  1135. VOID
  1136. NdisInterlockedAddUlong(
  1137. IN PULONG Addend,
  1138. IN ULONG Increment,
  1139. IN PNDIS_SPIN_LOCK SpinLock
  1140. );
  1141. EXPORT
  1142. PLIST_ENTRY
  1143. NdisInterlockedInsertHeadList(
  1144. IN PLIST_ENTRY ListHead,
  1145. IN PLIST_ENTRY ListEntry,
  1146. IN PNDIS_SPIN_LOCK SpinLock
  1147. );
  1148. EXPORT
  1149. PLIST_ENTRY
  1150. NdisInterlockedInsertTailList(
  1151. IN PLIST_ENTRY ListHead,
  1152. IN PLIST_ENTRY ListEntry,
  1153. IN PNDIS_SPIN_LOCK SpinLock
  1154. );
  1155. EXPORT
  1156. PLIST_ENTRY
  1157. NdisInterlockedRemoveHeadList(
  1158. IN PLIST_ENTRY ListHead,
  1159. IN PNDIS_SPIN_LOCK SpinLock
  1160. );
  1161. EXPORT
  1162. LARGE_INTEGER
  1163. NdisInterlockedAddLargeInteger(
  1164. IN PLARGE_INTEGER Addend,
  1165. IN ULONG Increment,
  1166. IN PKSPIN_LOCK Lock
  1167. );
  1168. #else // BINARY_COMPATIBLE
  1169. #define NdisAllocateSpinLock(_SpinLock) KeInitializeSpinLock(&(_SpinLock)->SpinLock)
  1170. #define NdisFreeSpinLock(_SpinLock)
  1171. #define NdisAcquireSpinLock(_SpinLock) KeAcquireSpinLock(&(_SpinLock)->SpinLock, &(_SpinLock)->OldIrql)
  1172. #define NdisReleaseSpinLock(_SpinLock) KeReleaseSpinLock(&(_SpinLock)->SpinLock,(_SpinLock)->OldIrql)
  1173. #define NdisDprAcquireSpinLock(_SpinLock) \
  1174. { \
  1175. KeAcquireSpinLockAtDpcLevel(&(_SpinLock)->SpinLock); \
  1176. (_SpinLock)->OldIrql = DISPATCH_LEVEL; \
  1177. }
  1178. #define NdisDprReleaseSpinLock(_SpinLock) KeReleaseSpinLockFromDpcLevel(&(_SpinLock)->SpinLock)
  1179. #define NdisGetCurrentSystemTime(_pSystemTime) \
  1180. { \
  1181. KeQuerySystemTime(_pSystemTime); \
  1182. }
  1183. //
  1184. // Interlocked support functions
  1185. //
  1186. #define NdisInterlockedIncrement(Addend) InterlockedIncrement(Addend)
  1187. #define NdisInterlockedDecrement(Addend) InterlockedDecrement(Addend)
  1188. #define NdisInterlockedAddUlong(_Addend, _Increment, _SpinLock) \
  1189. ExInterlockedAddUlong(_Addend, _Increment, &(_SpinLock)->SpinLock)
  1190. #define NdisInterlockedInsertHeadList(_ListHead, _ListEntry, _SpinLock) \
  1191. ExInterlockedInsertHeadList(_ListHead, _ListEntry, &(_SpinLock)->SpinLock)
  1192. #define NdisInterlockedInsertTailList(_ListHead, _ListEntry, _SpinLock) \
  1193. ExInterlockedInsertTailList(_ListHead, _ListEntry, &(_SpinLock)->SpinLock)
  1194. #define NdisInterlockedRemoveHeadList(_ListHead, _SpinLock) \
  1195. ExInterlockedRemoveHeadList(_ListHead, &(_SpinLock)->SpinLock)
  1196. #define NdisInterlockedPushEntryList(ListHead, ListEntry, Lock) \
  1197. ExInterlockedPushEntryList(ListHead, ListEntry, &(Lock)->SpinLock)
  1198. #define NdisInterlockedPopEntryList(ListHead, Lock) \
  1199. ExInterlockedPopEntryList(ListHead, &(Lock)->SpinLock)
  1200. #endif // BINARY_COMPATIBLE
  1201. #ifndef MAXIMUM_PROCESSORS
  1202. #ifdef _WIN64
  1203. #define MAXIMUM_PROCESSORS 64
  1204. #else
  1205. #define MAXIMUM_PROCESSORS 32
  1206. #endif
  1207. #endif
  1208. typedef union _NDIS_RW_LOCK_REFCOUNT
  1209. {
  1210. UINT RefCount;
  1211. UCHAR cacheLine[16]; // One refCount per cache line
  1212. } NDIS_RW_LOCK_REFCOUNT;
  1213. typedef struct _NDIS_RW_LOCK
  1214. {
  1215. union
  1216. {
  1217. struct
  1218. {
  1219. KSPIN_LOCK SpinLock;
  1220. PVOID Context;
  1221. };
  1222. UCHAR Reserved[16];
  1223. };
  1224. NDIS_RW_LOCK_REFCOUNT RefCount[MAXIMUM_PROCESSORS];
  1225. } NDIS_RW_LOCK, *PNDIS_RW_LOCK;
  1226. typedef struct _LOCK_STATE
  1227. {
  1228. USHORT LockState;
  1229. KIRQL OldIrql;
  1230. } LOCK_STATE, *PLOCK_STATE;
  1231. EXPORT
  1232. VOID
  1233. NdisInitializeReadWriteLock(
  1234. IN PNDIS_RW_LOCK Lock
  1235. );
  1236. EXPORT
  1237. VOID
  1238. NdisAcquireReadWriteLock(
  1239. IN PNDIS_RW_LOCK Lock,
  1240. IN BOOLEAN fWrite, // TRUE -> Write, FALSE -> Read
  1241. IN PLOCK_STATE LockState
  1242. );
  1243. EXPORT
  1244. VOID
  1245. NdisReleaseReadWriteLock(
  1246. IN PNDIS_RW_LOCK Lock,
  1247. IN PLOCK_STATE LockState
  1248. );
  1249. #define NdisInterlockedAddLargeStatistic(_Addend, _Increment) \
  1250. ExInterlockedAddLargeStatistic((PLARGE_INTEGER)_Addend, _Increment)
  1251. //
  1252. // S-List support
  1253. //
  1254. #define NdisInterlockedPushEntrySList(SListHead, SListEntry, Lock) \
  1255. ExInterlockedPushEntrySList(SListHead, SListEntry, &(Lock)->SpinLock)
  1256. #define NdisInterlockedPopEntrySList(SListHead, Lock) \
  1257. ExInterlockedPopEntrySList(SListHead, &(Lock)->SpinLock)
  1258. #define NdisInterlockedFlushSList(SListHead) ExInterlockedFlushSList(SListHead)
  1259. #define NdisInitializeSListHead(SListHead) ExInitializeSListHead(SListHead)
  1260. #define NdisQueryDepthSList(SListHead) ExQueryDepthSList(SListHead)
  1261. EXPORT
  1262. VOID
  1263. NdisGetCurrentProcessorCpuUsage(
  1264. OUT PULONG pCpuUsage
  1265. );
  1266. EXPORT
  1267. VOID
  1268. NdisGetCurrentProcessorCounts(
  1269. OUT PULONG pIdleCount,
  1270. OUT PULONG pKernelAndUser,
  1271. OUT PULONG pIndex
  1272. );
  1273. EXPORT
  1274. VOID
  1275. NdisGetSystemUpTime(
  1276. OUT PULONG pSystemUpTime
  1277. );
  1278. //
  1279. // List manipulation
  1280. //
  1281. /*++
  1282. VOID
  1283. NdisInitializeListHead(
  1284. IN PLIST_ENTRY ListHead
  1285. );
  1286. --*/
  1287. #define NdisInitializeListHead(_ListHead) InitializeListHead(_ListHead)
  1288. //
  1289. // Configuration Requests
  1290. //
  1291. EXPORT
  1292. VOID
  1293. NdisOpenConfiguration(
  1294. OUT PNDIS_STATUS Status,
  1295. OUT PNDIS_HANDLE ConfigurationHandle,
  1296. IN NDIS_HANDLE WrapperConfigurationContext
  1297. );
  1298. EXPORT
  1299. VOID
  1300. NdisOpenConfigurationKeyByName(
  1301. OUT PNDIS_STATUS Status,
  1302. IN NDIS_HANDLE ConfigurationHandle,
  1303. IN PNDIS_STRING SubKeyName,
  1304. OUT PNDIS_HANDLE SubKeyHandle
  1305. );
  1306. EXPORT
  1307. VOID
  1308. NdisOpenConfigurationKeyByIndex(
  1309. OUT PNDIS_STATUS Status,
  1310. IN NDIS_HANDLE ConfigurationHandle,
  1311. IN ULONG Index,
  1312. OUT PNDIS_STRING KeyName,
  1313. OUT PNDIS_HANDLE KeyHandle
  1314. );
  1315. EXPORT
  1316. VOID
  1317. NdisReadConfiguration(
  1318. OUT PNDIS_STATUS Status,
  1319. OUT PNDIS_CONFIGURATION_PARAMETER *ParameterValue,
  1320. IN NDIS_HANDLE ConfigurationHandle,
  1321. IN PNDIS_STRING Keyword,
  1322. IN NDIS_PARAMETER_TYPE ParameterType
  1323. );
  1324. EXPORT
  1325. VOID
  1326. NdisWriteConfiguration(
  1327. OUT PNDIS_STATUS Status,
  1328. IN NDIS_HANDLE ConfigurationHandle,
  1329. IN PNDIS_STRING Keyword,
  1330. IN PNDIS_CONFIGURATION_PARAMETER ParameterValue
  1331. );
  1332. EXPORT
  1333. VOID
  1334. NdisCloseConfiguration(
  1335. IN NDIS_HANDLE ConfigurationHandle
  1336. );
  1337. EXPORT
  1338. VOID
  1339. NdisReadNetworkAddress(
  1340. OUT PNDIS_STATUS Status,
  1341. OUT PVOID * NetworkAddress,
  1342. OUT PUINT NetworkAddressLength,
  1343. IN NDIS_HANDLE ConfigurationHandle
  1344. );
  1345. EXPORT
  1346. VOID
  1347. NdisReadEisaSlotInformation(
  1348. OUT PNDIS_STATUS Status,
  1349. IN NDIS_HANDLE WrapperConfigurationContext,
  1350. OUT PUINT SlotNumber,
  1351. OUT PNDIS_EISA_FUNCTION_INFORMATION EisaData
  1352. );
  1353. EXPORT
  1354. VOID
  1355. NdisReadEisaSlotInformationEx(
  1356. OUT PNDIS_STATUS Status,
  1357. IN NDIS_HANDLE WrapperConfigurationContext,
  1358. OUT PUINT SlotNumber,
  1359. OUT PNDIS_EISA_FUNCTION_INFORMATION *EisaData,
  1360. OUT PUINT NumberOfFunctions
  1361. );
  1362. EXPORT
  1363. ULONG
  1364. NdisReadPciSlotInformation(
  1365. IN NDIS_HANDLE NdisAdapterHandle,
  1366. IN ULONG SlotNumber,
  1367. IN ULONG Offset,
  1368. IN PVOID Buffer,
  1369. IN ULONG Length
  1370. );
  1371. EXPORT
  1372. ULONG
  1373. NdisWritePciSlotInformation(
  1374. IN NDIS_HANDLE NdisAdapterHandle,
  1375. IN ULONG SlotNumber,
  1376. IN ULONG Offset,
  1377. IN PVOID Buffer,
  1378. IN ULONG Length
  1379. );
  1380. EXPORT
  1381. NDIS_STATUS
  1382. NdisPciAssignResources(
  1383. IN NDIS_HANDLE NdisMacHandle,
  1384. IN NDIS_HANDLE NdisWrapperHandle,
  1385. IN NDIS_HANDLE WrapperConfigurationContext,
  1386. IN ULONG SlotNumber,
  1387. OUT PNDIS_RESOURCE_LIST * AssignedResources
  1388. );
  1389. EXPORT
  1390. ULONG
  1391. NdisReadPcmciaAttributeMemory(
  1392. IN NDIS_HANDLE NdisAdapterHandle,
  1393. IN ULONG Offset,
  1394. IN PVOID Buffer,
  1395. IN ULONG Length
  1396. );
  1397. EXPORT
  1398. ULONG
  1399. NdisWritePcmciaAttributeMemory(
  1400. IN NDIS_HANDLE NdisAdapterHandle,
  1401. IN ULONG Offset,
  1402. IN PVOID Buffer,
  1403. IN ULONG Length
  1404. );
  1405. //
  1406. // Buffer Pool
  1407. //
  1408. EXPORT
  1409. VOID
  1410. NdisAllocateBufferPool(
  1411. OUT PNDIS_STATUS Status,
  1412. OUT PNDIS_HANDLE PoolHandle,
  1413. IN UINT NumberOfDescriptors
  1414. );
  1415. EXPORT
  1416. VOID
  1417. NdisFreeBufferPool(
  1418. IN NDIS_HANDLE PoolHandle
  1419. );
  1420. EXPORT
  1421. VOID
  1422. NdisAllocateBuffer(
  1423. OUT PNDIS_STATUS Status,
  1424. OUT PNDIS_BUFFER * Buffer,
  1425. IN NDIS_HANDLE PoolHandle,
  1426. IN PVOID VirtualAddress,
  1427. IN UINT Length
  1428. );
  1429. EXPORT
  1430. VOID
  1431. NdisCopyBuffer(
  1432. OUT PNDIS_STATUS Status,
  1433. OUT PNDIS_BUFFER * Buffer,
  1434. IN NDIS_HANDLE PoolHandle,
  1435. IN PVOID MemoryDescriptor,
  1436. IN UINT Offset,
  1437. IN UINT Length
  1438. );
  1439. //
  1440. // VOID
  1441. // NdisCopyLookaheadData(
  1442. // IN PVOID Destination,
  1443. // IN PVOID Source,
  1444. // IN ULONG Length,
  1445. // IN ULONG ReceiveFlags
  1446. // );
  1447. //
  1448. #if defined(_M_IX86) || defined(_M_AMD64)
  1449. #define NdisCopyLookaheadData(_Destination, _Source, _Length, _MacOptions) \
  1450. RtlCopyMemory(_Destination, _Source, _Length)
  1451. #else
  1452. #define NdisCopyLookaheadData(_Destination, _Source, _Length, _MacOptions) \
  1453. { \
  1454. if ((_MacOptions) & NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA) \
  1455. { \
  1456. RtlCopyMemory(_Destination, _Source, _Length); \
  1457. } \
  1458. else \
  1459. { \
  1460. PUCHAR _Src = (PUCHAR)(_Source); \
  1461. PUCHAR _Dest = (PUCHAR)(_Destination); \
  1462. PUCHAR _End = _Dest + (_Length); \
  1463. while (_Dest < _End) \
  1464. { \
  1465. *_Dest++ = *_Src++; \
  1466. } \
  1467. } \
  1468. }
  1469. #endif
  1470. //
  1471. // Packet Pool
  1472. //
  1473. EXPORT
  1474. VOID
  1475. NdisAllocatePacketPool(
  1476. OUT PNDIS_STATUS Status,
  1477. OUT PNDIS_HANDLE PoolHandle,
  1478. IN UINT NumberOfDescriptors,
  1479. IN UINT ProtocolReservedLength
  1480. );
  1481. EXPORT
  1482. VOID
  1483. NdisAllocatePacketPoolEx(
  1484. OUT PNDIS_STATUS Status,
  1485. OUT PNDIS_HANDLE PoolHandle,
  1486. IN UINT NumberOfDescriptors,
  1487. IN UINT NumberOfOverflowDescriptors,
  1488. IN UINT ProtocolReservedLength
  1489. );
  1490. EXPORT
  1491. VOID
  1492. NdisSetPacketPoolProtocolId(
  1493. IN NDIS_HANDLE PacketPoolHandle,
  1494. IN UINT ProtocolId
  1495. );
  1496. EXPORT
  1497. UINT
  1498. NdisPacketPoolUsage(
  1499. IN NDIS_HANDLE PoolHandle
  1500. );
  1501. EXPORT
  1502. UINT
  1503. NdisPacketSize(
  1504. IN UINT ProtocolReservedSize
  1505. );
  1506. EXPORT
  1507. NDIS_HANDLE
  1508. NdisGetPoolFromPacket(
  1509. IN PNDIS_PACKET Packet
  1510. );
  1511. EXPORT
  1512. PNDIS_PACKET_STACK
  1513. NdisIMGetCurrentPacketStack(
  1514. IN PNDIS_PACKET Packet,
  1515. OUT BOOLEAN * StacksRemaining
  1516. );
  1517. EXPORT
  1518. VOID
  1519. NdisFreePacketPool(
  1520. IN NDIS_HANDLE PoolHandle
  1521. );
  1522. EXPORT
  1523. VOID
  1524. NdisFreePacket(
  1525. IN PNDIS_PACKET Packet
  1526. );
  1527. EXPORT
  1528. VOID
  1529. NdisDprFreePacket(
  1530. IN PNDIS_PACKET Packet
  1531. );
  1532. EXPORT
  1533. VOID
  1534. NdisDprFreePacketNonInterlocked(
  1535. IN PNDIS_PACKET Packet
  1536. );
  1537. EXPORT
  1538. VOID
  1539. NdisAllocatePacket(
  1540. OUT PNDIS_STATUS Status,
  1541. OUT PNDIS_PACKET * Packet,
  1542. IN NDIS_HANDLE PoolHandle
  1543. );
  1544. EXPORT
  1545. VOID
  1546. NdisDprAllocatePacket(
  1547. OUT PNDIS_STATUS Status,
  1548. OUT PNDIS_PACKET * Packet,
  1549. IN NDIS_HANDLE PoolHandle
  1550. );
  1551. EXPORT
  1552. VOID
  1553. NdisDprAllocatePacketNonInterlocked(
  1554. OUT PNDIS_STATUS Status,
  1555. OUT PNDIS_PACKET * Packet,
  1556. IN NDIS_HANDLE PoolHandle
  1557. );
  1558. // VOID
  1559. // NdisReinitializePacket(
  1560. // IN OUT PNDIS_PACKET Packet
  1561. // );
  1562. #define NdisReinitializePacket(Packet) \
  1563. { \
  1564. (Packet)->Private.Head = (PNDIS_BUFFER)NULL; \
  1565. (Packet)->Private.ValidCounts = FALSE; \
  1566. }
  1567. //
  1568. // Block Pool APIs
  1569. //
  1570. typedef
  1571. VOID
  1572. (__stdcall *NDIS_BLOCK_INITIALIZER) (
  1573. IN PUCHAR Block,
  1574. IN SIZE_T NumberOfBytes
  1575. );
  1576. NDIS_HANDLE
  1577. NdisCreateBlockPool(
  1578. IN USHORT BlockSize,
  1579. IN USHORT FreeBlockLinkOffset,
  1580. IN ULONG Tag,
  1581. IN NDIS_BLOCK_INITIALIZER InitFunction OPTIONAL
  1582. );
  1583. VOID
  1584. NdisDestroyBlockPool(
  1585. IN NDIS_HANDLE BlockPoolHandle
  1586. );
  1587. PUCHAR
  1588. NdisAllocateFromBlockPool(
  1589. IN NDIS_HANDLE BlockPoolHandle
  1590. );
  1591. VOID
  1592. NdisFreeToBlockPool(
  1593. IN PUCHAR Block
  1594. );
  1595. #if BINARY_COMPATIBLE
  1596. EXPORT
  1597. VOID
  1598. NdisFreeBuffer(
  1599. IN PNDIS_BUFFER Buffer
  1600. );
  1601. EXPORT
  1602. VOID
  1603. NdisQueryBuffer(
  1604. IN PNDIS_BUFFER Buffer,
  1605. OUT PVOID * VirtualAddress OPTIONAL,
  1606. OUT PUINT Length
  1607. );
  1608. EXPORT
  1609. VOID
  1610. NdisQueryBufferSafe(
  1611. IN PNDIS_BUFFER Buffer,
  1612. OUT PVOID * VirtualAddress OPTIONAL,
  1613. OUT PUINT Length,
  1614. IN MM_PAGE_PRIORITY Priority
  1615. );
  1616. EXPORT
  1617. VOID
  1618. NdisQueryBufferOffset(
  1619. IN PNDIS_BUFFER Buffer,
  1620. OUT PUINT Offset,
  1621. OUT PUINT Length
  1622. );
  1623. //
  1624. // This is a combination of NdisQueryPacket and NdisQueryBuffer and
  1625. // optimized for protocols to get the first Buffer, its VA and its size.
  1626. //
  1627. VOID
  1628. NdisGetFirstBufferFromPacket(
  1629. IN PNDIS_PACKET Packet,
  1630. OUT PNDIS_BUFFER * FirstBuffer,
  1631. OUT PVOID * FirstBufferVA,
  1632. OUT PUINT FirstBufferLength,
  1633. OUT PUINT TotalBufferLength
  1634. );
  1635. VOID
  1636. NdisGetFirstBufferFromPacketSafe(
  1637. IN PNDIS_PACKET Packet,
  1638. OUT PNDIS_BUFFER * FirstBuffer,
  1639. OUT PVOID * FirstBufferVA,
  1640. OUT PUINT FirstBufferLength,
  1641. OUT PUINT TotalBufferLength,
  1642. IN MM_PAGE_PRIORITY Priority
  1643. );
  1644. //
  1645. // This is used to determine how many physical pieces
  1646. // an NDIS_BUFFER will take up when mapped.
  1647. //
  1648. EXPORT
  1649. ULONG
  1650. NDIS_BUFFER_TO_SPAN_PAGES(
  1651. IN PNDIS_BUFFER Buffer
  1652. );
  1653. EXPORT
  1654. VOID
  1655. NdisGetBufferPhysicalArraySize(
  1656. IN PNDIS_BUFFER Buffer,
  1657. OUT PUINT ArraySize
  1658. );
  1659. #else // BINARY_COMPATIBLE
  1660. #define NdisFreeBuffer(Buffer) IoFreeMdl(Buffer)
  1661. #define NdisQueryBuffer(_Buffer, _VirtualAddress, _Length) \
  1662. { \
  1663. if (ARGUMENT_PRESENT(_VirtualAddress)) \
  1664. { \
  1665. *(PVOID *)(_VirtualAddress) = MmGetSystemAddressForMdl(_Buffer); \
  1666. } \
  1667. *(_Length) = MmGetMdlByteCount(_Buffer); \
  1668. }
  1669. #define NdisQueryBufferSafe(_Buffer, _VirtualAddress, _Length, _Priority) \
  1670. { \
  1671. if (ARGUMENT_PRESENT(_VirtualAddress)) \
  1672. { \
  1673. *(PVOID *)(_VirtualAddress) = MmGetSystemAddressForMdlSafe(_Buffer, _Priority); \
  1674. } \
  1675. *(_Length) = MmGetMdlByteCount(_Buffer); \
  1676. }
  1677. #define NdisQueryBufferOffset(_Buffer, _Offset, _Length) \
  1678. { \
  1679. *(_Offset) = MmGetMdlByteOffset(_Buffer); \
  1680. *(_Length) = MmGetMdlByteCount(_Buffer); \
  1681. }
  1682. #define NdisGetFirstBufferFromPacket(_Packet, \
  1683. _FirstBuffer, \
  1684. _FirstBufferVA, \
  1685. _FirstBufferLength, \
  1686. _TotalBufferLength) \
  1687. { \
  1688. PNDIS_BUFFER _pBuf; \
  1689. \
  1690. _pBuf = (_Packet)->Private.Head; \
  1691. *(_FirstBuffer) = _pBuf; \
  1692. if (_pBuf) \
  1693. { \
  1694. *(_FirstBufferVA) = MmGetSystemAddressForMdl(_pBuf); \
  1695. *(_FirstBufferLength) = \
  1696. *(_TotalBufferLength) = MmGetMdlByteCount(_pBuf); \
  1697. for (_pBuf = _pBuf->Next; \
  1698. _pBuf != NULL; \
  1699. _pBuf = _pBuf->Next) \
  1700. { \
  1701. *(_TotalBufferLength) += MmGetMdlByteCount(_pBuf); \
  1702. } \
  1703. } \
  1704. else \
  1705. { \
  1706. *(_FirstBufferVA) = 0; \
  1707. *(_FirstBufferLength) = 0; \
  1708. *(_TotalBufferLength) = 0; \
  1709. } \
  1710. }
  1711. #define NdisGetFirstBufferFromPacketSafe(_Packet, \
  1712. _FirstBuffer, \
  1713. _FirstBufferVA, \
  1714. _FirstBufferLength, \
  1715. _TotalBufferLength, \
  1716. _Priority) \
  1717. { \
  1718. PNDIS_BUFFER _pBuf; \
  1719. \
  1720. _pBuf = (_Packet)->Private.Head; \
  1721. *(_FirstBuffer) = _pBuf; \
  1722. if (_pBuf) \
  1723. { \
  1724. *(_FirstBufferVA) = MmGetSystemAddressForMdlSafe(_pBuf, _Priority); \
  1725. *(_FirstBufferLength) = *(_TotalBufferLength) = MmGetMdlByteCount(_pBuf); \
  1726. for (_pBuf = _pBuf->Next; \
  1727. _pBuf != NULL; \
  1728. _pBuf = _pBuf->Next) \
  1729. { \
  1730. *(_TotalBufferLength) += MmGetMdlByteCount(_pBuf); \
  1731. } \
  1732. } \
  1733. else \
  1734. { \
  1735. *(_FirstBufferVA) = 0; \
  1736. *(_FirstBufferLength) = 0; \
  1737. *(_TotalBufferLength) = 0; \
  1738. } \
  1739. }
  1740. #define NDIS_BUFFER_TO_SPAN_PAGES(_Buffer) \
  1741. (MmGetMdlByteCount(_Buffer)==0 ? \
  1742. 1 : \
  1743. (COMPUTE_PAGES_SPANNED( \
  1744. MmGetMdlVirtualAddress(_Buffer), \
  1745. MmGetMdlByteCount(_Buffer))))
  1746. #define NdisGetBufferPhysicalArraySize(Buffer, ArraySize) \
  1747. (*(ArraySize) = NDIS_BUFFER_TO_SPAN_PAGES(Buffer))
  1748. #endif // BINARY_COMPATIBLE
  1749. /*++
  1750. NDIS_BUFFER_LINKAGE(
  1751. IN PNDIS_BUFFER Buffer
  1752. );
  1753. --*/
  1754. #define NDIS_BUFFER_LINKAGE(Buffer) ((Buffer)->Next)
  1755. /*++
  1756. VOID
  1757. NdisRecalculatePacketCounts(
  1758. IN OUT PNDIS_PACKET Packet
  1759. );
  1760. --*/
  1761. #define NdisRecalculatePacketCounts(Packet) \
  1762. { \
  1763. { \
  1764. PNDIS_BUFFER TmpBuffer = (Packet)->Private.Head; \
  1765. if (TmpBuffer) \
  1766. { \
  1767. while (TmpBuffer->Next) \
  1768. { \
  1769. TmpBuffer = TmpBuffer->Next; \
  1770. } \
  1771. (Packet)->Private.Tail = TmpBuffer; \
  1772. } \
  1773. (Packet)->Private.ValidCounts = FALSE; \
  1774. } \
  1775. }
  1776. /*++
  1777. VOID
  1778. NdisChainBufferAtFront(
  1779. IN OUT PNDIS_PACKET Packet,
  1780. IN OUT PNDIS_BUFFER Buffer
  1781. );
  1782. --*/
  1783. #define NdisChainBufferAtFront(Packet, Buffer) \
  1784. { \
  1785. PNDIS_BUFFER TmpBuffer = (Buffer); \
  1786. \
  1787. for (;;) \
  1788. { \
  1789. if (TmpBuffer->Next == (PNDIS_BUFFER)NULL) \
  1790. break; \
  1791. TmpBuffer = TmpBuffer->Next; \
  1792. } \
  1793. if ((Packet)->Private.Head == NULL) \
  1794. { \
  1795. (Packet)->Private.Tail = TmpBuffer; \
  1796. } \
  1797. TmpBuffer->Next = (Packet)->Private.Head; \
  1798. (Packet)->Private.Head = (Buffer); \
  1799. (Packet)->Private.ValidCounts = FALSE; \
  1800. }
  1801. /*++
  1802. VOID
  1803. NdisChainBufferAtBack(
  1804. IN OUT PNDIS_PACKET Packet,
  1805. IN OUT PNDIS_BUFFER Buffer
  1806. );
  1807. --*/
  1808. #define NdisChainBufferAtBack(Packet, Buffer) \
  1809. { \
  1810. PNDIS_BUFFER TmpBuffer = (Buffer); \
  1811. \
  1812. for (;;) \
  1813. { \
  1814. if (TmpBuffer->Next == NULL) \
  1815. break; \
  1816. TmpBuffer = TmpBuffer->Next; \
  1817. } \
  1818. if ((Packet)->Private.Head != NULL) \
  1819. { \
  1820. (Packet)->Private.Tail->Next = (Buffer); \
  1821. } \
  1822. else \
  1823. { \
  1824. (Packet)->Private.Head = (Buffer); \
  1825. } \
  1826. (Packet)->Private.Tail = TmpBuffer; \
  1827. (Packet)->Private.ValidCounts = FALSE; \
  1828. }
  1829. EXPORT
  1830. VOID
  1831. NdisUnchainBufferAtFront(
  1832. IN OUT PNDIS_PACKET Packet,
  1833. OUT PNDIS_BUFFER * Buffer
  1834. );
  1835. EXPORT
  1836. VOID
  1837. NdisUnchainBufferAtBack(
  1838. IN OUT PNDIS_PACKET Packet,
  1839. OUT PNDIS_BUFFER * Buffer
  1840. );
  1841. /*++
  1842. VOID
  1843. NdisQueryPacket(
  1844. IN PNDIS_PACKET _Packet,
  1845. OUT PUINT _PhysicalBufferCount OPTIONAL,
  1846. OUT PUINT _BufferCount OPTIONAL,
  1847. OUT PNDIS_BUFFER * _FirstBuffer OPTIONAL,
  1848. OUT PUINT _TotalPacketLength OPTIONAL
  1849. );
  1850. --*/
  1851. #define NdisQueryPacket(_Packet, \
  1852. _PhysicalBufferCount, \
  1853. _BufferCount, \
  1854. _FirstBuffer, \
  1855. _TotalPacketLength) \
  1856. { \
  1857. if ((_FirstBuffer) != NULL) \
  1858. { \
  1859. PNDIS_BUFFER * __FirstBuffer = (_FirstBuffer); \
  1860. *(__FirstBuffer) = (_Packet)->Private.Head; \
  1861. } \
  1862. if ((_TotalPacketLength) || (_BufferCount) || (_PhysicalBufferCount)) \
  1863. { \
  1864. if (!(_Packet)->Private.ValidCounts) \
  1865. { \
  1866. PNDIS_BUFFER TmpBuffer = (_Packet)->Private.Head; \
  1867. UINT PTotalLength = 0, PPhysicalCount = 0, PAddedCount = 0; \
  1868. UINT PacketLength, Offset; \
  1869. \
  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. \
  1884. if (_PhysicalBufferCount) \
  1885. { \
  1886. PUINT __PhysicalBufferCount = (_PhysicalBufferCount); \
  1887. *(__PhysicalBufferCount) = (_Packet)->Private.PhysicalCount; \
  1888. } \
  1889. if (_BufferCount) \
  1890. { \
  1891. PUINT __BufferCount = (_BufferCount); \
  1892. *(__BufferCount) = (_Packet)->Private.Count; \
  1893. } \
  1894. if (_TotalPacketLength) \
  1895. { \
  1896. PUINT __TotalPacketLength = (_TotalPacketLength); \
  1897. *(__TotalPacketLength) = (_Packet)->Private.TotalLength; \
  1898. } \
  1899. } \
  1900. }
  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. NdisFreeDmaChannel(
  2595. IN NDIS_HANDLE NdisDmaHandle
  2596. );
  2597. EXPORT
  2598. VOID
  2599. NdisSetupDmaTransfer(
  2600. OUT PNDIS_STATUS Status,
  2601. IN NDIS_HANDLE NdisDmaHandle,
  2602. IN PNDIS_BUFFER Buffer,
  2603. IN ULONG Offset,
  2604. IN ULONG Length,
  2605. IN BOOLEAN WriteToDevice
  2606. );
  2607. EXPORT
  2608. VOID
  2609. NdisCompleteDmaTransfer(
  2610. OUT PNDIS_STATUS Status,
  2611. IN NDIS_HANDLE NdisDmaHandle,
  2612. IN PNDIS_BUFFER Buffer,
  2613. IN ULONG Offset,
  2614. IN ULONG Length,
  2615. IN BOOLEAN WriteToDevice
  2616. );
  2617. //
  2618. // Wrapper initialization and termination.
  2619. //
  2620. EXPORT
  2621. VOID
  2622. NdisInitializeWrapper(
  2623. OUT PNDIS_HANDLE NdisWrapperHandle,
  2624. IN PVOID SystemSpecific1,
  2625. IN PVOID SystemSpecific2,
  2626. IN PVOID SystemSpecific3
  2627. );
  2628. EXPORT
  2629. VOID
  2630. NdisTerminateWrapper(
  2631. IN NDIS_HANDLE NdisWrapperHandle,
  2632. IN PVOID SystemSpecific
  2633. );
  2634. //
  2635. // Shared memory
  2636. //
  2637. #define NdisUpdateSharedMemory(_H, _L, _V, _P)
  2638. //
  2639. // System processor count
  2640. //
  2641. EXPORT
  2642. CCHAR
  2643. NdisSystemProcessorCount(
  2644. VOID
  2645. );
  2646. EXPORT
  2647. PVOID
  2648. NdisGetRoutineAddress(
  2649. IN PUNICODE_STRING NdisRoutineName
  2650. );
  2651. EXPORT
  2652. UINT
  2653. NdisGetVersion(
  2654. VOID
  2655. );
  2656. //
  2657. // Ansi/Unicode support routines
  2658. //
  2659. #if BINARY_COMPATIBLE
  2660. EXPORT
  2661. VOID
  2662. NdisInitAnsiString(
  2663. IN OUT PANSI_STRING DestinationString,
  2664. IN PCSTR SourceString
  2665. );
  2666. EXPORT
  2667. VOID
  2668. NdisInitUnicodeString(
  2669. IN OUT PUNICODE_STRING DestinationString,
  2670. IN PCWSTR SourceString
  2671. );
  2672. EXPORT
  2673. NDIS_STATUS
  2674. NdisAnsiStringToUnicodeString(
  2675. IN OUT PUNICODE_STRING DestinationString,
  2676. IN PANSI_STRING SourceString
  2677. );
  2678. EXPORT
  2679. NDIS_STATUS
  2680. NdisUnicodeStringToAnsiString(
  2681. IN OUT PANSI_STRING DestinationString,
  2682. IN PUNICODE_STRING SourceString
  2683. );
  2684. EXPORT
  2685. NDIS_STATUS
  2686. NdisUpcaseUnicodeString(
  2687. OUT PUNICODE_STRING DestinationString,
  2688. IN PUNICODE_STRING SourceString
  2689. );
  2690. #else // BINARY_COMPATIBLE
  2691. #define NdisInitAnsiString(_as, s) RtlInitString(_as, s)
  2692. #define NdisInitUnicodeString(_us, s) RtlInitUnicodeString(_us, s)
  2693. #define NdisAnsiStringToUnicodeString(_us, _as) RtlAnsiStringToUnicodeString(_us, _as, FALSE)
  2694. #define NdisUnicodeStringToAnsiString(_as, _us) RtlUnicodeStringToAnsiString(_as, _us, FALSE)
  2695. #define NdisUpcaseUnicodeString(_d, _s) RtlUpcaseUnicodeString(_d, _s, FALSE)
  2696. #endif // BINARY_COMPATIBLE
  2697. //
  2698. // Non-paged lookaside list support routines
  2699. //
  2700. #define NdisInitializeNPagedLookasideList(_L, _AR, _FR, _Fl, _S, _T, _D) \
  2701. ExInitializeNPagedLookasideList(_L, _AR, _FR, _Fl, _S, _T, _D)
  2702. #define NdisDeleteNPagedLookasideList(_L) ExDeleteNPagedLookasideList(_L)
  2703. #define NdisAllocateFromNPagedLookasideList(_L) ExAllocateFromNPagedLookasideList(_L)
  2704. #define NdisFreeToNPagedLookasideList(_L, _E) ExFreeToNPagedLookasideList(_L, _E)
  2705. EXPORT
  2706. VOID
  2707. NdisSetPacketStatus(
  2708. IN PNDIS_PACKET Packet,
  2709. IN NDIS_STATUS Status,
  2710. IN NDIS_HANDLE Handle,
  2711. IN ULONG Code
  2712. );
  2713. #define NDIS_MAX_EVENT_LOG_DATA_SIZE ((ERROR_LOG_MAXIMUM_SIZE - sizeof(IO_ERROR_LOG_PACKET) + sizeof(ULONG)) & ~3)
  2714. #if defined(NDIS_WRAPPER)
  2715. typedef struct _OID_LIST OID_LIST, *POID_LIST;
  2716. #endif // NDIS_WRAPPER defined