- Get NDIS to compile on msvc/ddk (thanks to filip for his help)
[reactos.git] / reactos / drivers / net / ndis / include / ndissys.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS NDIS library
4 * FILE: ndissys.h
5 * PURPOSE: NDIS library definitions
6 * NOTES: Spin lock acquire order:
7 * - Miniport list lock
8 * - Adapter list lock
9 */
10 #ifndef __NDISSYS_H
11 #define __NDISSYS_H
12
13 typedef unsigned long NDIS_STATS;
14
15 #include <ntifs.h>
16 #include <ndis.h>
17 #include <xfilter.h>
18 #include <afilter.h>
19 #include <atm.h>
20
21 struct _ADAPTER_BINDING;
22
23 typedef struct _NDISI_PACKET_POOL {
24 NDIS_SPIN_LOCK SpinLock;
25 struct _NDIS_PACKET *FreeList;
26 UINT PacketLength;
27 UCHAR Buffer[1];
28 } NDISI_PACKET_POOL, * PNDISI_PACKET_POOL;
29
30 /* WDK Compatibility. Taken from w32api DDK */
31 #ifndef __NDIS_H
32 typedef struct _X_FILTER FDDI_FILTER, *PFDDI_FILTER;
33
34 typedef VOID
35 (NTAPI *FDDI_RCV_COMPLETE_HANDLER)(
36 IN PFDDI_FILTER Filter);
37
38 typedef VOID
39 (NTAPI *FDDI_RCV_INDICATE_HANDLER)(
40 IN PFDDI_FILTER Filter,
41 IN NDIS_HANDLE MacReceiveContext,
42 IN PCHAR Address,
43 IN UINT AddressLength,
44 IN PVOID HeaderBuffer,
45 IN UINT HeaderBufferSize,
46 IN PVOID LookaheadBuffer,
47 IN UINT LookaheadBufferSize,
48 IN UINT PacketSize);
49
50 typedef enum _NDIS_WORK_ITEM_TYPE {
51 NdisWorkItemRequest,
52 NdisWorkItemSend,
53 NdisWorkItemReturnPackets,
54 NdisWorkItemResetRequested,
55 NdisWorkItemResetInProgress,
56 NdisWorkItemHalt,
57 NdisWorkItemSendLoopback,
58 NdisWorkItemMiniportCallback,
59 NdisMaxWorkItems
60 } NDIS_WORK_ITEM_TYPE, *PNDIS_WORK_ITEM_TYPE;
61
62 #define NUMBER_OF_WORK_ITEM_TYPES NdisMaxWorkItems
63 #define NUMBER_OF_SINGLE_WORK_ITEMS 6
64
65 typedef struct _NDIS_MINIPORT_WORK_ITEM {
66 SINGLE_LIST_ENTRY Link;
67 NDIS_WORK_ITEM_TYPE WorkItemType;
68 PVOID WorkItemContext;
69 } NDIS_MINIPORT_WORK_ITEM, *PNDIS_MINIPORT_WORK_ITEM;
70
71 typedef VOID (NTAPI *W_MINIPORT_CALLBACK)(
72 IN NDIS_HANDLE MiniportAdapterContext,
73 IN PVOID CallbackContext);
74
75 typedef struct _NDIS_BIND_PATHS {
76 UINT Number;
77 NDIS_STRING Paths[1];
78 } NDIS_BIND_PATHS, *PNDIS_BIND_PATHS;
79
80 #if ARCNET
81 #define FILTERDBS_ARCNET_S \
82 PARC_FILTER ArcDB;
83 #else /* !ARCNET */
84 #define FILTERDBS_ARCNET_S \
85 PVOID XXXDB;
86 #endif /* !ARCNET */
87
88 #define FILTERDBS_S \
89 union { \
90 PETH_FILTER EthDB; \
91 PNULL_FILTER NullDB; \
92 }; \
93 PTR_FILTER TrDB; \
94 PFDDI_FILTER FddiDB; \
95 FILTERDBS_ARCNET_S
96
97 typedef struct _NDIS_LOG {
98 PNDIS_MINIPORT_BLOCK Miniport;
99 KSPIN_LOCK LogLock;
100 PIRP Irp;
101 UINT TotalSize;
102 UINT CurrentSize;
103 UINT InPtr;
104 UINT OutPtr;
105 UCHAR LogBuf[1];
106 } NDIS_LOG, *PNDIS_LOG;
107
108 typedef enum _NDIS_PNP_DEVICE_STATE {
109 NdisPnPDeviceAdded,
110 NdisPnPDeviceStarted,
111 NdisPnPDeviceQueryStopped,
112 NdisPnPDeviceStopped,
113 NdisPnPDeviceQueryRemoved,
114 NdisPnPDeviceRemoved,
115 NdisPnPDeviceSurpriseRemoved
116 } NDIS_PNP_DEVICE_STATE;
117
118 typedef struct _OID_LIST OID_LIST, *POID_LIST;
119
120 struct _NDIS_MINIPORT_BLOCK {
121 PVOID Signature;
122 PNDIS_MINIPORT_BLOCK NextMiniport;
123 PNDIS_M_DRIVER_BLOCK DriverHandle;
124 NDIS_HANDLE MiniportAdapterContext;
125 UNICODE_STRING MiniportName;
126 PNDIS_BIND_PATHS BindPaths;
127 NDIS_HANDLE OpenQueue;
128 REFERENCE ShortRef;
129 NDIS_HANDLE DeviceContext;
130 UCHAR Padding1;
131 UCHAR LockAcquired;
132 UCHAR PmodeOpens;
133 UCHAR AssignedProcessor;
134 KSPIN_LOCK Lock;
135 PNDIS_REQUEST MediaRequest;
136 PNDIS_MINIPORT_INTERRUPT Interrupt;
137 ULONG Flags;
138 ULONG PnPFlags;
139 LIST_ENTRY PacketList;
140 PNDIS_PACKET FirstPendingPacket;
141 PNDIS_PACKET ReturnPacketsQueue;
142 ULONG RequestBuffer;
143 PVOID SetMCastBuffer;
144 PNDIS_MINIPORT_BLOCK PrimaryMiniport;
145 PVOID WrapperContext;
146 PVOID BusDataContext;
147 ULONG PnPCapabilities;
148 PCM_RESOURCE_LIST Resources;
149 NDIS_TIMER WakeUpDpcTimer;
150 UNICODE_STRING BaseName;
151 UNICODE_STRING SymbolicLinkName;
152 ULONG CheckForHangSeconds;
153 USHORT CFHangTicks;
154 USHORT CFHangCurrentTick;
155 NDIS_STATUS ResetStatus;
156 NDIS_HANDLE ResetOpen;
157 FILTERDBS_S
158 FILTER_PACKET_INDICATION_HANDLER PacketIndicateHandler;
159 NDIS_M_SEND_COMPLETE_HANDLER SendCompleteHandler;
160 NDIS_M_SEND_RESOURCES_HANDLER SendResourcesHandler;
161 NDIS_M_RESET_COMPLETE_HANDLER ResetCompleteHandler;
162 NDIS_MEDIUM MediaType;
163 ULONG BusNumber;
164 NDIS_INTERFACE_TYPE BusType;
165 NDIS_INTERFACE_TYPE AdapterType;
166 PDEVICE_OBJECT DeviceObject;
167 PDEVICE_OBJECT PhysicalDeviceObject;
168 PDEVICE_OBJECT NextDeviceObject;
169 PMAP_REGISTER_ENTRY MapRegisters;
170 PNDIS_AF_LIST CallMgrAfList;
171 PVOID MiniportThread;
172 PVOID SetInfoBuf;
173 USHORT SetInfoBufLen;
174 USHORT MaxSendPackets;
175 NDIS_STATUS FakeStatus;
176 PVOID LockHandler;
177 PUNICODE_STRING pAdapterInstanceName;
178 PNDIS_MINIPORT_TIMER TimerQueue;
179 UINT MacOptions;
180 PNDIS_REQUEST PendingRequest;
181 UINT MaximumLongAddresses;
182 UINT MaximumShortAddresses;
183 UINT CurrentLookahead;
184 UINT MaximumLookahead;
185 W_HANDLE_INTERRUPT_HANDLER HandleInterruptHandler;
186 W_DISABLE_INTERRUPT_HANDLER DisableInterruptHandler;
187 W_ENABLE_INTERRUPT_HANDLER EnableInterruptHandler;
188 W_SEND_PACKETS_HANDLER SendPacketsHandler;
189 NDIS_M_START_SENDS DeferredSendHandler;
190 ETH_RCV_INDICATE_HANDLER EthRxIndicateHandler;
191 TR_RCV_INDICATE_HANDLER TrRxIndicateHandler;
192 FDDI_RCV_INDICATE_HANDLER FddiRxIndicateHandler;
193 ETH_RCV_COMPLETE_HANDLER EthRxCompleteHandler;
194 TR_RCV_COMPLETE_HANDLER TrRxCompleteHandler;
195 FDDI_RCV_COMPLETE_HANDLER FddiRxCompleteHandler;
196 NDIS_M_STATUS_HANDLER StatusHandler;
197 NDIS_M_STS_COMPLETE_HANDLER StatusCompleteHandler;
198 NDIS_M_TD_COMPLETE_HANDLER TDCompleteHandler;
199 NDIS_M_REQ_COMPLETE_HANDLER QueryCompleteHandler;
200 NDIS_M_REQ_COMPLETE_HANDLER SetCompleteHandler;
201 NDIS_WM_SEND_COMPLETE_HANDLER WanSendCompleteHandler;
202 WAN_RCV_HANDLER WanRcvHandler;
203 WAN_RCV_COMPLETE_HANDLER WanRcvCompleteHandler;
204 #if defined(NDIS_WRAPPER)
205 PNDIS_MINIPORT_BLOCK NextGlobalMiniport;
206 SINGLE_LIST_ENTRY WorkQueue[NUMBER_OF_WORK_ITEM_TYPES];
207 SINGLE_LIST_ENTRY SingleWorkItems[NUMBER_OF_SINGLE_WORK_ITEMS];
208 UCHAR SendFlags;
209 UCHAR TrResetRing;
210 UCHAR ArcnetAddress;
211 UCHAR XState;
212 union {
213 #if ARCNET
214 PNDIS_ARC_BUF ArcBuf;
215 #endif
216 PVOID BusInterface;
217 };
218 PNDIS_LOG Log;
219 ULONG SlotNumber;
220 PCM_RESOURCE_LIST AllocatedResources;
221 PCM_RESOURCE_LIST AllocatedResourcesTranslated;
222 SINGLE_LIST_ENTRY PatternList;
223 NDIS_PNP_CAPABILITIES PMCapabilities;
224 DEVICE_CAPABILITIES DeviceCaps;
225 ULONG WakeUpEnable;
226 DEVICE_POWER_STATE CurrentDevicePowerState;
227 PIRP pIrpWaitWake;
228 SYSTEM_POWER_STATE WaitWakeSystemState;
229 LARGE_INTEGER VcIndex;
230 KSPIN_LOCK VcCountLock;
231 LIST_ENTRY WmiEnabledVcs;
232 PNDIS_GUID pNdisGuidMap;
233 PNDIS_GUID pCustomGuidMap;
234 USHORT VcCount;
235 USHORT cNdisGuidMap;
236 USHORT cCustomGuidMap;
237 USHORT CurrentMapRegister;
238 PKEVENT AllocationEvent;
239 USHORT BaseMapRegistersNeeded;
240 USHORT SGMapRegistersNeeded;
241 ULONG MaximumPhysicalMapping;
242 NDIS_TIMER MediaDisconnectTimer;
243 USHORT MediaDisconnectTimeOut;
244 USHORT InstanceNumber;
245 NDIS_EVENT OpenReadyEvent;
246 NDIS_PNP_DEVICE_STATE PnPDeviceState;
247 NDIS_PNP_DEVICE_STATE OldPnPDeviceState;
248 PGET_SET_DEVICE_DATA SetBusData;
249 PGET_SET_DEVICE_DATA GetBusData;
250 KDPC DeferredDpc;
251 #if 0
252 /* FIXME: */
253 NDIS_STATS NdisStats;
254 #else
255 ULONG NdisStats;
256 #endif
257 PNDIS_PACKET IndicatedPacket[MAXIMUM_PROCESSORS];
258 PKEVENT RemoveReadyEvent;
259 PKEVENT AllOpensClosedEvent;
260 PKEVENT AllRequestsCompletedEvent;
261 ULONG InitTimeMs;
262 NDIS_MINIPORT_WORK_ITEM WorkItemBuffer[NUMBER_OF_SINGLE_WORK_ITEMS];
263 PDMA_ADAPTER SystemAdapterObject;
264 ULONG DriverVerifyFlags;
265 POID_LIST OidList;
266 USHORT InternalResetCount;
267 USHORT MiniportResetCount;
268 USHORT MediaSenseConnectCount;
269 USHORT MediaSenseDisconnectCount;
270 PNDIS_PACKET *xPackets;
271 ULONG UserModeOpenReferences;
272 union {
273 PVOID SavedSendHandler;
274 PVOID SavedWanSendHandler;
275 };
276 PVOID SavedSendPacketsHandler;
277 PVOID SavedCancelSendPacketsHandler;
278 W_SEND_PACKETS_HANDLER WSendPacketsHandler;
279 ULONG MiniportAttributes;
280 PDMA_ADAPTER SavedSystemAdapterObject;
281 USHORT NumOpens;
282 USHORT CFHangXTicks;
283 ULONG RequestCount;
284 ULONG IndicatedPacketsCount;
285 ULONG PhysicalMediumType;
286 PNDIS_REQUEST LastRequest;
287 LONG DmaAdapterRefCount;
288 PVOID FakeMac;
289 ULONG LockDbg;
290 ULONG LockDbgX;
291 PVOID LockThread;
292 ULONG InfoFlags;
293 KSPIN_LOCK TimerQueueLock;
294 PKEVENT ResetCompletedEvent;
295 PKEVENT QueuedBindingCompletedEvent;
296 PKEVENT DmaResourcesReleasedEvent;
297 FILTER_PACKET_INDICATION_HANDLER SavedPacketIndicateHandler;
298 ULONG RegisteredInterrupts;
299 PNPAGED_LOOKASIDE_LIST SGListLookasideList;
300 ULONG ScatterGatherListSize;
301 #endif /* _NDIS_ */
302 };
303
304 #if 1
305 /* FIXME: */
306 typedef PVOID QUEUED_CLOSE;
307 #endif
308
309 #if defined(NDIS_WRAPPER)
310 #define NDIS_COMMON_OPEN_BLOCK_WRAPPER_S \
311 ULONG Flags; \
312 ULONG References; \
313 KSPIN_LOCK SpinLock; \
314 NDIS_HANDLE FilterHandle; \
315 ULONG ProtocolOptions; \
316 USHORT CurrentLookahead; \
317 USHORT ConnectDampTicks; \
318 USHORT DisconnectDampTicks; \
319 W_SEND_HANDLER WSendHandler; \
320 W_TRANSFER_DATA_HANDLER WTransferDataHandler; \
321 W_SEND_PACKETS_HANDLER WSendPacketsHandler; \
322 W_CANCEL_SEND_PACKETS_HANDLER CancelSendPacketsHandler; \
323 ULONG WakeUpEnable; \
324 PKEVENT CloseCompleteEvent; \
325 QUEUED_CLOSE QC; \
326 ULONG AfReferences; \
327 PNDIS_OPEN_BLOCK NextGlobalOpen;
328 #else
329 #define NDIS_COMMON_OPEN_BLOCK_WRAPPER_S
330 #endif
331
332 #define NDIS_COMMON_OPEN_BLOCK_S \
333 PVOID MacHandle; \
334 NDIS_HANDLE BindingHandle; \
335 PNDIS_MINIPORT_BLOCK MiniportHandle; \
336 PNDIS_PROTOCOL_BLOCK ProtocolHandle; \
337 NDIS_HANDLE ProtocolBindingContext; \
338 PNDIS_OPEN_BLOCK MiniportNextOpen; \
339 PNDIS_OPEN_BLOCK ProtocolNextOpen; \
340 NDIS_HANDLE MiniportAdapterContext; \
341 BOOLEAN Reserved1; \
342 BOOLEAN Reserved2; \
343 BOOLEAN Reserved3; \
344 BOOLEAN Reserved4; \
345 PNDIS_STRING BindDeviceName; \
346 KSPIN_LOCK Reserved5; \
347 PNDIS_STRING RootDeviceName; \
348 union { \
349 SEND_HANDLER SendHandler; \
350 WAN_SEND_HANDLER WanSendHandler; \
351 }; \
352 TRANSFER_DATA_HANDLER TransferDataHandler; \
353 SEND_COMPLETE_HANDLER SendCompleteHandler; \
354 TRANSFER_DATA_COMPLETE_HANDLER TransferDataCompleteHandler; \
355 RECEIVE_HANDLER ReceiveHandler; \
356 RECEIVE_COMPLETE_HANDLER ReceiveCompleteHandler; \
357 WAN_RECEIVE_HANDLER WanReceiveHandler; \
358 REQUEST_COMPLETE_HANDLER RequestCompleteHandler; \
359 RECEIVE_PACKET_HANDLER ReceivePacketHandler; \
360 SEND_PACKETS_HANDLER SendPacketsHandler; \
361 RESET_HANDLER ResetHandler; \
362 REQUEST_HANDLER RequestHandler; \
363 RESET_COMPLETE_HANDLER ResetCompleteHandler; \
364 STATUS_HANDLER StatusHandler; \
365 STATUS_COMPLETE_HANDLER StatusCompleteHandler; \
366 NDIS_COMMON_OPEN_BLOCK_WRAPPER_S
367
368 typedef struct _NDIS_COMMON_OPEN_BLOCK {
369 NDIS_COMMON_OPEN_BLOCK_S
370 } NDIS_COMMON_OPEN_BLOCK;
371
372 struct _NDIS_OPEN_BLOCK
373 {
374 #ifdef __cplusplus
375 NDIS_COMMON_OPEN_BLOCK NdisCommonOpenBlock;
376 #else
377 NDIS_COMMON_OPEN_BLOCK_S
378 #endif
379 #if defined(NDIS_WRAPPER)
380 struct _NDIS_OPEN_CO
381 {
382 struct _NDIS_CO_AF_BLOCK * NextAf;
383 W_CO_CREATE_VC_HANDLER MiniportCoCreateVcHandler;
384 W_CO_REQUEST_HANDLER MiniportCoRequestHandler;
385 CO_CREATE_VC_HANDLER CoCreateVcHandler;
386 CO_DELETE_VC_HANDLER CoDeleteVcHandler;
387 PVOID CmActivateVcCompleteHandler;
388 PVOID CmDeactivateVcCompleteHandler;
389 PVOID CoRequestCompleteHandler;
390 LIST_ENTRY ActiveVcHead;
391 LIST_ENTRY InactiveVcHead;
392 LONG PendingAfNotifications;
393 PKEVENT AfNotifyCompleteEvent;
394 };
395 #endif /* _NDIS_ */
396 };
397
398 #define NDIS30_PROTOCOL_CHARACTERISTICS_S \
399 UCHAR MajorNdisVersion; \
400 UCHAR MinorNdisVersion; \
401 USHORT Filler; \
402 union { \
403 UINT Reserved; \
404 UINT Flags; \
405 }; \
406 OPEN_ADAPTER_COMPLETE_HANDLER OpenAdapterCompleteHandler; \
407 CLOSE_ADAPTER_COMPLETE_HANDLER CloseAdapterCompleteHandler; \
408 union { \
409 SEND_COMPLETE_HANDLER SendCompleteHandler; \
410 WAN_SEND_COMPLETE_HANDLER WanSendCompleteHandler; \
411 }; \
412 union { \
413 TRANSFER_DATA_COMPLETE_HANDLER TransferDataCompleteHandler; \
414 WAN_TRANSFER_DATA_COMPLETE_HANDLER WanTransferDataCompleteHandler; \
415 }; \
416 RESET_COMPLETE_HANDLER ResetCompleteHandler; \
417 REQUEST_COMPLETE_HANDLER RequestCompleteHandler; \
418 union { \
419 RECEIVE_HANDLER ReceiveHandler; \
420 WAN_RECEIVE_HANDLER WanReceiveHandler; \
421 }; \
422 RECEIVE_COMPLETE_HANDLER ReceiveCompleteHandler; \
423 STATUS_HANDLER StatusHandler; \
424 STATUS_COMPLETE_HANDLER StatusCompleteHandler; \
425 NDIS_STRING Name;
426
427 typedef struct _NDIS30_PROTOCOL_CHARACTERISTICS {
428 NDIS30_PROTOCOL_CHARACTERISTICS_S
429 } NDIS30_PROTOCOL_CHARACTERISTICS, *PNDIS30_PROTOCOL_CHARACTERISTICS;
430
431 #define NDIS30_MINIPORT_CHARACTERISTICS_S \
432 UCHAR MajorNdisVersion; \
433 UCHAR MinorNdisVersion; \
434 USHORT Filler; \
435 UINT Reserved; \
436 W_CHECK_FOR_HANG_HANDLER CheckForHangHandler; \
437 W_DISABLE_INTERRUPT_HANDLER DisableInterruptHandler; \
438 W_ENABLE_INTERRUPT_HANDLER EnableInterruptHandler; \
439 W_HALT_HANDLER HaltHandler; \
440 W_HANDLE_INTERRUPT_HANDLER HandleInterruptHandler; \
441 W_INITIALIZE_HANDLER InitializeHandler; \
442 W_ISR_HANDLER ISRHandler; \
443 W_QUERY_INFORMATION_HANDLER QueryInformationHandler; \
444 W_RECONFIGURE_HANDLER ReconfigureHandler; \
445 W_RESET_HANDLER ResetHandler; \
446 union { \
447 W_SEND_HANDLER SendHandler; \
448 WM_SEND_HANDLER WanSendHandler; \
449 }u1; \
450 W_SET_INFORMATION_HANDLER SetInformationHandler; \
451 union { \
452 W_TRANSFER_DATA_HANDLER TransferDataHandler; \
453 WM_TRANSFER_DATA_HANDLER WanTransferDataHandler; \
454 }u2;
455
456 typedef struct _NDIS30_MINIPORT_CHARACTERISTICS {
457 NDIS30_MINIPORT_CHARACTERISTICS_S
458 } NDIS30_MINIPORT_CHARACTERISTICS, *PSNDIS30_MINIPORT_CHARACTERISTICS;
459
460 #ifdef __cplusplus
461
462 #define NDIS40_MINIPORT_CHARACTERISTICS_S \
463 NDIS30_MINIPORT_CHARACTERISTICS Ndis30Chars; \
464 W_RETURN_PACKET_HANDLER ReturnPacketHandler; \
465 W_SEND_PACKETS_HANDLER SendPacketsHandler; \
466 W_ALLOCATE_COMPLETE_HANDLER AllocateCompleteHandler;
467
468 #else /* !__cplusplus */
469
470 #define NDIS40_MINIPORT_CHARACTERISTICS_S \
471 NDIS30_MINIPORT_CHARACTERISTICS_S \
472 W_RETURN_PACKET_HANDLER ReturnPacketHandler; \
473 W_SEND_PACKETS_HANDLER SendPacketsHandler; \
474 W_ALLOCATE_COMPLETE_HANDLER AllocateCompleteHandler;
475
476 #endif /* !__cplusplus */
477
478 typedef struct _NDIS40_MINIPORT_CHARACTERISTICS {
479 NDIS40_MINIPORT_CHARACTERISTICS_S
480 } NDIS40_MINIPORT_CHARACTERISTICS, *PNDIS40_MINIPORT_CHARACTERISTICS;
481
482 #endif
483
484 #include "miniport.h"
485 #include "protocol.h"
486
487 #include <debug.h>
488
489 /* Exported functions */
490 #ifndef EXPORT
491 #define EXPORT NTAPI
492 #endif
493
494 #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
495 #define NDIS_TAG 0x4e4d4953
496
497 #define MIN(value1, value2) \
498 ((value1 < value2)? value1 : value2)
499
500 #define MAX(value1, value2) \
501 ((value1 > value2)? value1 : value2)
502
503 #endif /* __NDISSYS_H */
504
505 /* EOF */