-
Notifications
You must be signed in to change notification settings - Fork 158
/
Copy pathndisx.h
4720 lines (4113 loc) · 147 KB
/
ndisx.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef __NDIS_X_H_
#define __NDIS_X_H_
#define NUMBER_OF_WORK_ITEM_TYPES NdisMaxWorkItems
#define NUMBER_OF_SINGLE_WORK_ITEMS 6
#define NDIS_M_MAX_MULTI_LIST 32
typedef struct _NDIS_BIND_PATHS
{
UINT Number;
NDIS_STRING Paths[1];
} NDIS_BIND_PATHS, *PNDIS_BIND_PATHS;
//
// Defines the type of work item.
//
typedef enum _NDIS_WORK_ITEM_TYPE
{
NdisWorkItemRequest,
NdisWorkItemSend,
NdisWorkItemReturnPackets,
NdisWorkItemResetRequested,
NdisWorkItemResetInProgress,
NdisWorkItemHalt,
#if !(NDIS_NT)
NdisWorkItemSendLoopback,
#endif
NdisWorkItemMiniportCallback,
NdisMaxWorkItems
} NDIS_WORK_ITEM_TYPE, *PNDIS_WORK_ITEM_TYPE;
typedef enum _NDIS_PNP_DEVICE_STATE
{
NdisPnPDeviceAdded,
NdisPnPDeviceStarted,
NdisPnPDeviceQueryStopped,
NdisPnPDeviceStopped,
NdisPnPDeviceQueryRemoved,
NdisPnPDeviceRemoved,
NdisPnPDeviceSurpriseRemoved
} NDIS_PNP_DEVICE_STATE;
typedef struct _FDDI_FILTER *PFDDI_FILTER;
typedef struct _NDIS_MAC_BLOCK NDIS_MAC_BLOCK, *PNDIS_MAC_BLOCK;
typedef struct _OID_LIST OID_LIST, *POID_LIST;
typedef struct _NDIS_M_OPEN_BLOCK NDIS_M_OPEN_BLOCK,*PNDIS_M_OPEN_BLOCK;
typedef struct _ARC_FILTER ARC_FILTER,*PARC_FILTER;
//
// Arcnet specific stuff
//
#define ARC_SEND_BUFFERS 8
#define ARC_HEADER_SIZE 4
typedef struct _ARC_BUFFER_LIST
{
PVOID Buffer;
UINT Size;
UINT BytesLeft;
struct _ARC_BUFFER_LIST *Next;
} ARC_BUFFER_LIST, *PARC_BUFFER_LIST;
typedef struct _NDIS_ARC_BUF
{
NDIS_HANDLE ArcnetBufferPool;
PUCHAR ArcnetLookaheadBuffer;
UINT NumFree;
ARC_BUFFER_LIST ArcnetBuffers[ARC_SEND_BUFFERS];
} NDIS_ARC_BUF, *PNDIS_ARC_BUF;
typedef struct _NDIS_LOG
{
PNDIS_MINIPORT_BLOCK Miniport; // The owning miniport block
KSPIN_LOCK LogLock; // For serialization
PIRP Irp; // Pending Irp to consume this log
UINT TotalSize; // Size of the log buffer
UINT CurrentSize;// Size of the log buffer
UINT InPtr; // IN part of the circular buffer
UINT OutPtr; // OUT part of the circular buffer
UCHAR LogBuf[1]; // The circular buffer
} NDIS_LOG, *PNDIS_LOG;
typedef struct _NDIS_MINIPORT_WORK_ITEM
{
//
// Link for the list of work items of this type.
//
SINGLE_LIST_ENTRY Link;
//
// type of work item and context information.
//
NDIS_WORK_ITEM_TYPE WorkItemType;
PVOID WorkItemContext;
} NDIS_MINIPORT_WORK_ITEM, *PNDIS_MINIPORT_WORK_ITEM;
//
// block used for references using a ULONG
//
typedef struct _ULONG_REFERENCE
{
KSPIN_LOCK SpinLock;
ULONG ReferenceCount;
BOOLEAN Closing;
} ULONG_REFERENCE, *PULONG_REFERENCE;
typedef struct _NDIS_SG_DMA_BLOCK
{
NDIS_OBJECT_HEADER Header;
PNDIS_MINIPORT_BLOCK Miniport;
PVOID MiniportAdapterContext;
PDMA_ADAPTER DmaAdapterObject;
PVOID ProcessSGListHandler;
PVOID SharedMemAllocateCompleteHandler;
ULONG Flags;
ULONG MaximumPhysicalMapping;
ULONG ScatterGatherListSize;
PNPAGED_LOOKASIDE_LIST SGListLookasideList;
LONG DmaAdapterRefCount;
PKEVENT DmaResourcesReleasedEvent;
PVOID SharedMemoryPage[2];
ULONG SharedMemoryLeft[2];
LARGE_INTEGER SharedMemoryAddress[2];
PDMA_ADAPTER SavedDmaAdapterObject;
PMAP_REGISTER_ENTRY MapRegisters;
PKEVENT AllocationEvent;
USHORT CurrentMapRegister;
USHORT BaseMapRegistersNeeded;
USHORT SGMapRegistersNeeded;
} NDIS_SG_DMA_BLOCK, *PNDIS_SG_DMA_BLOCK;
typedef struct _NDIS_STATS
{
LARGE_INTEGER StartTicks;
ULONGLONG DirectedPacketsOut;
ULONGLONG DirectedPacketsIn;
}NDIS_STATS,*PNDIS_STATS;
typedef
VOID
(*FDDI_RCV_INDICATE_HANDLER)(
IN PFDDI_FILTER Filter,
IN NDIS_HANDLE MacReceiveContext,
IN PCHAR Address,
IN UINT AddressLength,
IN PVOID HeaderBuffer,
IN UINT HeaderBufferSize,
IN PVOID LookaheadBuffer,
IN UINT LookaheadBufferSize,
IN UINT PacketSize
);
typedef
VOID
(*FDDI_RCV_COMPLETE_HANDLER)(
IN PFDDI_FILTER Filter
);
typedef
VOID
(FASTCALL *NDIS_M_PROCESS_DEFERRED)(
IN PNDIS_MINIPORT_BLOCK Miniport
);
typedef
NDIS_STATUS
(FASTCALL *NDIS_M_QUEUE_WORK_ITEM)(
IN PNDIS_MINIPORT_BLOCK Miniport,
IN NDIS_WORK_ITEM_TYPE WorkItemType,
IN PVOID WorkItemContext1,
IN PVOID WorkItemContext2
);
typedef
NDIS_STATUS
(FASTCALL *NDIS_M_QUEUE_NEW_WORK_ITEM)(
IN PNDIS_MINIPORT_BLOCK Miniport,
IN NDIS_WORK_ITEM_TYPE WorkItemType,
IN PVOID WorkItemContext1,
IN PVOID WorkItemContext2
);
typedef
VOID
(FASTCALL *NDIS_M_DEQUEUE_WORK_ITEM)(
IN PNDIS_MINIPORT_BLOCK Miniport,
IN NDIS_WORK_ITEM_TYPE WorkItemType,
OUT PVOID * WorkItemContext1,
OUT PVOID * WorkItemContext2
);
//
// Miniport extensions for NDIS 5.1
//
typedef VOID
(*W_CANCEL_SEND_PACKETS_HANDLER)(
__in NDIS_HANDLE MiniportAdapterContext,
__in PVOID CancelId
);
typedef VOID
(*W_PNP_EVENT_NOTIFY_HANDLER)(
__in NDIS_HANDLE MiniportAdapterContext,
__in NDIS_DEVICE_PNP_EVENT DevicePnPEvent,
__in PVOID InformationBuffer,
__in ULONG InformationBufferLength
);
typedef VOID
(*W_MINIPORT_SHUTDOWN_HANDLER) (
__in NDIS_HANDLE MiniportAdapterContext
);
typedef struct _X_BINDING_INFO X_BINDING_INFO,*PX_BINDING_INFO;
typedef struct _X_FILTER
{
PX_BINDING_INFO OpenList;
NDIS_RW_LOCK BindListLock;
PNDIS_MINIPORT_BLOCK Miniport;
ULONG CombinedPacketFilter;
ULONG OldCombinedPacketFilter;
ULONG NumOpens;
PX_BINDING_INFO MCastSet;
PX_BINDING_INFO SingleActiveOpen;
UCHAR AdapterAddress[6];
union{
struct{
UCHAR (*MCastAddressBuf)[6];
UCHAR (*OldMCastAddressBuf)[6];
ULONG MaxMulticastAddresses;
ULONG NumAddresses;
ULONG OldNumAddresses;
};
struct{
UCHAR AdapterShortAddress[2];
UCHAR (*MCastLongAddressBuf)[6];
UCHAR (*MCastShortAddressBuf)[2];
UCHAR (*OldMCastLongAddressBuf)[6];
UCHAR (*OldMCastShortAddressBuf)[2];
ULONG MaxMulticastLongAddresses;
ULONG MaxMulticastShortAddresses;
ULONG NumLongAddresses;
ULONG NumShortAddresses;
ULONG OldNumLongAddresses;
ULONG OldNumShortAddresses;
UCHAR SupportsShortAddresses;
};
struct{
ULONG CombinedFunctionalAddress;
ULONG GroupAddress;
ULONG GroupReferences;
ULONG OldCombinedFunctionalAddress;
ULONG OldGroupAddress;
ULONG OldGroupReferences;
};
};
}X_FILTER,*PX_FILTER;
typedef struct _DMA_OPERATIONS_V1 {
ULONG Size;
PPUT_DMA_ADAPTER PutDmaAdapter;
PALLOCATE_COMMON_BUFFER AllocateCommonBuffer;
PFREE_COMMON_BUFFER FreeCommonBuffer;
PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
PFREE_MAP_REGISTERS FreeMapRegisters;
PMAP_TRANSFER MapTransfer;
PGET_DMA_ALIGNMENT GetDmaAlignment;
PREAD_DMA_COUNTER ReadDmaCounter;
PGET_SCATTER_GATHER_LIST GetScatterGatherList;
PPUT_SCATTER_GATHER_LIST PutScatterGatherList;
} DMA_OPERATIONS_V1,*PDMA_OPERATIONS_V1;
typedef struct _DMA_OPERATIONS_V2 {
DMA_OPERATIONS_V1;
PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList;
PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList;
PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList;
} DMA_OPERATIONS_V2,*PDMA_OPERATIONS_V2;
typedef struct _DMA_OPERATIONS_V3 {
DMA_OPERATIONS_V2;
PVOID GetDmaAdapterInfo;
PVOID GetDmaTransferInfo;
PVOID InitializeDmaTransferContext;
PVOID AllocateCommonBufferEx;
PVOID AllocateAdapterChannelEx;
PVOID ConfigureAdapterChannel;
PVOID CancelAdapterChannel;
PVOID MapTransferEx;
PVOID GetScatterGatherListEx;
PVOID BuildScatterGatherListEx;
PVOID FlushAdapterBuffersEx;
PVOID FreeAdapterObject;
PVOID CancelMappedTransfer;
} DMA_OPERATIONS_V3,*PDMA_OPERATIONS_V3;
//
// one of these per mini-port registered on a Driver
//
struct _NDIS_MINIPORT_BLOCK_NT
{
ULONG NullValue; // used to distinquish between MACs and mini-ports
PDEVICE_OBJECT DeviceObject; // created by the wrapper
PNDIS_M_DRIVER_BLOCK DriverHandle; // pointer to our Driver block
NDIS_HANDLE MiniportAdapterContext; // context when calling mini-port functions
NDIS_STRING MiniportName; // how mini-port refers to us
PNDIS_M_OPEN_BLOCK OpenQueue; // queue of opens for this mini-port
PNDIS_MINIPORT_BLOCK NextMiniport; // used by driver's MiniportQueue
REFERENCE Ref; // contains spinlock for OpenQueue
BOOLEAN padding1; // normal ints: DO NOT REMOVE OR NDIS WILL BREAK!!!
BOOLEAN padding2; // processing def: DO NOT REMOVE OR NDIS WILL BREAK!!!
//
// Synchronization stuff.
//
// The boolean is used to lock out several DPCs from running at the
// same time. The difficultly is if DPC A releases the spin lock
// and DPC B tries to run, we want to defer B until after A has
// exited.
//
BOOLEAN LockAcquired; // EXPOSED via macros. Do not move
UCHAR PmodeOpens; // Count of opens which turned on pmode/all_local
NDIS_SPIN_LOCK Lock;
PNDIS_MINIPORT_INTERRUPT Interrupt;
ULONG Flags; // Flags to keep track of the
// miniport's state.
//
//Work that the miniport needs to do.
//
KSPIN_LOCK WorkLock;
SINGLE_LIST_ENTRY WorkQueue[NUMBER_OF_WORK_ITEM_TYPES];
SINGLE_LIST_ENTRY WorkItemFreeQueue;
//
// Stuff that got deferred.
//
KDPC Dpc;
NDIS_TIMER WakeUpDpcTimer;
//
// Holds media specific information.
//
PETH_FILTER EthDB; // EXPOSED via macros. Do not move
PTR_FILTER TrDB; // EXPOSED via macros. Do not move
PFDDI_FILTER FddiDB; // EXPOSED via macros. Do not move
PARC_FILTER ArcDB; // EXPOSED via macros. Do not move
FILTER_PACKET_INDICATION_HANDLER PacketIndicateHandler;
NDIS_M_SEND_COMPLETE_HANDLER SendCompleteHandler;
NDIS_M_SEND_RESOURCES_HANDLER SendResourcesHandler;
NDIS_M_RESET_COMPLETE_HANDLER ResetCompleteHandler;
PVOID WrapperContext;
NDIS_MEDIUM MediaType;
//
// contains mini-port information
//
ULONG BusNumber;
NDIS_INTERFACE_TYPE BusType;
NDIS_INTERFACE_TYPE AdapterType;
//
// Holds the map registers for this mini-port.
//
ULONG PhysicalMapRegistersNeeded;
ULONG MaximumPhysicalMapping;
PMAP_REGISTER_ENTRY MapRegisters; // EXPOSED via macros. Do not move
//
// WorkItem routines that can change depending on whether we
// are fullduplex or not.
//
NDIS_M_PROCESS_DEFERRED ProcessDeferredHandler;
NDIS_M_QUEUE_WORK_ITEM QueueWorkItemHandler;
NDIS_M_QUEUE_NEW_WORK_ITEM QueueNewWorkItemHandler;
NDIS_M_DEQUEUE_WORK_ITEM DeQueueWorkItemHandler;
PNDIS_TIMER DeferredTimer;
//
// Resource information
//
PCM_RESOURCE_LIST Resources;
//
// This pointer is reserved. Used for debugging
//
PVOID Reserved;
PADAPTER_OBJECT SystemAdapterObject;
SINGLE_LIST_ENTRY SingleWorkItems[NUMBER_OF_SINGLE_WORK_ITEMS];
//
// For efficiency
//
W_HANDLE_INTERRUPT_HANDLER HandleInterruptHandler;
W_DISABLE_INTERRUPT_HANDLER DisableInterruptHandler;
W_ENABLE_INTERRUPT_HANDLER EnableInterruptHandler;
W_SEND_PACKETS_HANDLER SendPacketsHandler;
NDIS_M_START_SENDS DeferredSendHandler;
//
// The following cannot be unionized.
//
ETH_RCV_INDICATE_HANDLER EthRxIndicateHandler; // EXPOSED via macros. Do not move
TR_RCV_INDICATE_HANDLER TrRxIndicateHandler; // EXPOSED via macros. Do not move
FDDI_RCV_INDICATE_HANDLER FddiRxIndicateHandler; // EXPOSED via macros. Do not move
ETH_RCV_COMPLETE_HANDLER EthRxCompleteHandler; // EXPOSED via macros. Do not move
TR_RCV_COMPLETE_HANDLER TrRxCompleteHandler; // EXPOSED via macros. Do not move
FDDI_RCV_COMPLETE_HANDLER FddiRxCompleteHandler; // EXPOSED via macros. Do not move
NDIS_M_STATUS_HANDLER StatusHandler; // EXPOSED via macros. Do not move
NDIS_M_STS_COMPLETE_HANDLER StatusCompleteHandler; // EXPOSED via macros. Do not move
NDIS_M_TD_COMPLETE_HANDLER TDCompleteHandler; // EXPOSED via macros. Do not move
NDIS_M_REQ_COMPLETE_HANDLER QueryCompleteHandler; // EXPOSED via macros. Do not move
NDIS_M_REQ_COMPLETE_HANDLER SetCompleteHandler; // EXPOSED via macros. Do not move
/********************************************************************************************/
/**************** **********/
/**************** STUFF ABOVE IS POTENTIALLY ACCESSED BY MACROS. ADD STUFF BELOW **********/
/**************** SEVERE POSSIBILITY OF BREAKING SOMETHING IF STUFF ABOVE IS MOVED **********/
/**************** **********/
/********************************************************************************************/
PNDIS_MAC_BLOCK FakeMac;
ULONG InterruptLevel;
ULONG InterruptVector;
NDIS_INTERRUPT_MODE InterruptMode;
UCHAR TrResetRing;
UCHAR ArcnetAddress;
//
// This is the processor number that the miniport's
// interrupt DPC and timers are running on.
//
UCHAR AssignedProcessor;
NDIS_HANDLE ArcnetBufferPool;
PARC_BUFFER_LIST ArcnetFreeBufferList;
PARC_BUFFER_LIST ArcnetUsedBufferList;
PUCHAR ArcnetLookaheadBuffer;
UINT CheckForHangTimeout;
//
// These two are used temporarily while allocating the map registers.
//
KEVENT AllocationEvent;
UINT CurrentMapRegister;
//
// Send information
//
NDIS_SPIN_LOCK SendLock;
ULONG SendFlags; // Flags for send path.
PNDIS_PACKET FirstPacket; // This pointer serves two purposes;
// it is the head of the queue of ALL
// packets that have been sent to
// the miniport, it is also the head
// of the packets that have been sent
// down to the miniport by the wrapper.
PNDIS_PACKET LastPacket; // This is tail pointer for the global
// packet queue and this is the tail
// pointer to the queue of packets
// waiting to be sent to the miniport.
PNDIS_PACKET FirstPendingPacket; // This is head of the queue of packets
// waiting to be sent to miniport.
PNDIS_PACKET LastMiniportPacket; // This is the tail pointer of the
// queue of packets that have been
// sent to the miniport by the wrapper.
PNDIS_PACKET LoopbackHead; // Head of loopback queue.
PNDIS_PACKET LoopbackTail; // Tail of loopback queue.
ULONG SendResourcesAvailable;
PPNDIS_PACKET PacketArray;
UINT MaximumSendPackets;
//
// Transfer data information
//
PNDIS_PACKET FirstTDPacket;
PNDIS_PACKET LastTDPacket;
PNDIS_PACKET LoopbackPacket;
//
// Reset information
//
NDIS_STATUS ResetStatus;
//
// RequestInformation
//
PNDIS_REQUEST PendingRequest;
PNDIS_REQUEST MiniportRequest;
NDIS_STATUS RequestStatus;
UINT MaximumLongAddresses;
UINT MaximumShortAddresses;
UINT CurrentLookahead;
UINT MaximumLookahead;
UINT MacOptions;
KEVENT RequestEvent;
UCHAR MulticastBuffer[NDIS_M_MAX_MULTI_LIST][6];
//
// Temp stuff for using the old NDIS functions
//
ULONG ChannelNumber;
UINT NumberOfAllocatedWorkItems;
PNDIS_LOG Log;
//
// List of registered address families. Valid for the call-manager, Null for the client
//
PNDIS_AF_LIST CallMgrAfList;
//
// Store information here to track adapters
//
ULONG BusId;
ULONG SlotNumber;
//
// Pointer to the current thread. Used in layered miniport code.
//
LONG MiniportThread;
LONG SendThread;
//
// To handle packets returned during RcvIndication
//
WORK_QUEUE_ITEM WorkItem;
PNDIS_PACKET ReturnPacketsQueue;
//
// Context associated with the intermediate driver
//
NDIS_HANDLE DeviceContext;
//
// Needed for PnP. Upcased version. The buffer is allocated as part of the
// NDIS_MINIPORT_BLOCK itself.
//
UNICODE_STRING BaseName;
}NDIS_MINIPORT_BLOCK_NT,*PNDIS_MINIPORT_BLOCK_NT;
//
// one of these per mini-port registered on a Driver
//
typedef struct _NDIS_MINIPORT_BLOCK_W2K
{
ULONG NullValue; // used to distinquish between MACs and mini-ports
PNDIS_MINIPORT_BLOCK NextMiniport; // used by driver's MiniportQueue
PNDIS_M_DRIVER_BLOCK DriverHandle; // pointer to our Driver block
NDIS_HANDLE MiniportAdapterContext; // context when calling mini-port functions
UNICODE_STRING MiniportName; // how mini-port refers to us
PNDIS_BIND_PATHS BindPaths;
NDIS_HANDLE OpenQueue; // queue of opens for this mini-port
REFERENCE ShortRef; // contains spinlock for OpenQueue
NDIS_HANDLE DeviceContext; // Context associated with the intermediate driver
UCHAR Padding1; // DO NOT REMOVE OR NDIS WILL BREAK!!!
//
// Synchronization stuff.
//
// The boolean is used to lock out several DPCs from running at the same time.
//
UCHAR LockAcquired; // EXPOSED via macros. Do not move
UCHAR PmodeOpens; // Count of opens which turned on pmode/all_local
//
// This is the processor number that the miniport's
// interrupt DPC and timers are running on.
//
UCHAR AssignedProcessor;
KSPIN_LOCK Lock;
PNDIS_REQUEST MediaRequest;
PNDIS_MINIPORT_INTERRUPT Interrupt;
ULONG Flags; // Flags to keep track of the
// miniport's state.
ULONG PnPFlags;
//
// Send information
//
LIST_ENTRY PacketList;
PNDIS_PACKET FirstPendingPacket; // This is head of the queue of packets
// waiting to be sent to miniport.
PNDIS_PACKET ReturnPacketsQueue;
//
// Space used for temp. use during request processing
//
ULONG RequestBuffer;
PVOID SetMCastBuffer;
PNDIS_MINIPORT_BLOCK PrimaryMiniport;
PVOID WrapperContext;
//
// context to pass to bus driver when reading or writing config space
//
PVOID BusDataContext;
//
// flag to specify PnP capabilities of the device. we need this to fail query_stop
// query_remove or suspend request if the device can not handle it
//
ULONG PnPCapabilities;
//
// Resource information
//
PCM_RESOURCE_LIST Resources;
//
// Watch-dog timer
//
NDIS_TIMER WakeUpDpcTimer;
//
// Needed for PnP. Upcased version. The buffer is allocated as part of the
// NDIS_MINIPORT_BLOCK itself.
//
// Note:
// the following two fields should be explicitly UNICODE_STRING because
// under Win9x the NDIS_STRING is an ANSI_STRING
//
UNICODE_STRING BaseName;
UNICODE_STRING SymbolicLinkName;
//
// Check for hang stuff
//
ULONG CheckForHangSeconds;
USHORT CFHangTicks;
USHORT CFHangCurrentTick;
//
// Reset information
//
NDIS_STATUS ResetStatus;
NDIS_HANDLE ResetOpen;
//
// Holds media specific information.
//
#ifdef __cplusplus
FILTERDBS FilterDbs; // EXPOSED via macros. Do not move
#else
FILTERDBS; // EXPOSED via macros. Do not move
#endif
FILTER_PACKET_INDICATION_HANDLER PacketIndicateHandler;
NDIS_M_SEND_COMPLETE_HANDLER SendCompleteHandler;
NDIS_M_SEND_RESOURCES_HANDLER SendResourcesHandler;
NDIS_M_RESET_COMPLETE_HANDLER ResetCompleteHandler;
NDIS_MEDIUM MediaType;
//
// contains mini-port information
//
ULONG BusNumber;
NDIS_INTERFACE_TYPE BusType;
NDIS_INTERFACE_TYPE AdapterType;
PDEVICE_OBJECT DeviceObject;
PDEVICE_OBJECT PhysicalDeviceObject;
PDEVICE_OBJECT NextDeviceObject;
//
// Holds the map registers for this mini-port.
//
PMAP_REGISTER_ENTRY MapRegisters; // EXPOSED via macros. Do not move
//
// List of registered address families. Valid for the call-manager, Null for the client
//
PNDIS_AF_LIST CallMgrAfList;
PVOID MiniportThread;
PVOID SetInfoBuf;
USHORT SetInfoBufLen;
USHORT MaxSendPackets;
//
// Status code that is returned from the fake handlers.
//
NDIS_STATUS FakeStatus;
PVOID LockHandler; // For the filter lock
//
// the following field should be explicitly UNICODE_STRING because
// under Win9x the NDIS_STRING is an ANSI_STRING
//
PUNICODE_STRING pAdapterInstanceName; // Instance specific name for the adapter.
PADAPTER_OBJECT SystemAdapterObject;
UINT MacOptions;
//
// RequestInformation
//
PNDIS_REQUEST PendingRequest;
UINT MaximumLongAddresses;
UINT MaximumShortAddresses;
UINT CurrentLookahead;
UINT MaximumLookahead;
//
// For efficiency
//
W_HANDLE_INTERRUPT_HANDLER HandleInterruptHandler;
W_DISABLE_INTERRUPT_HANDLER DisableInterruptHandler;
W_ENABLE_INTERRUPT_HANDLER EnableInterruptHandler;
W_SEND_PACKETS_HANDLER SendPacketsHandler;
NDIS_M_START_SENDS DeferredSendHandler;
//
// The following cannot be unionized.
//
ETH_RCV_INDICATE_HANDLER EthRxIndicateHandler; // EXPOSED via macros. Do not move
TR_RCV_INDICATE_HANDLER TrRxIndicateHandler; // EXPOSED via macros. Do not move
FDDI_RCV_INDICATE_HANDLER FddiRxIndicateHandler; // EXPOSED via macros. Do not move
ETH_RCV_COMPLETE_HANDLER EthRxCompleteHandler; // EXPOSED via macros. Do not move
TR_RCV_COMPLETE_HANDLER TrRxCompleteHandler; // EXPOSED via macros. Do not move
FDDI_RCV_COMPLETE_HANDLER FddiRxCompleteHandler; // EXPOSED via macros. Do not move
NDIS_M_STATUS_HANDLER StatusHandler; // EXPOSED via macros. Do not move
NDIS_M_STS_COMPLETE_HANDLER StatusCompleteHandler; // EXPOSED via macros. Do not move
NDIS_M_TD_COMPLETE_HANDLER TDCompleteHandler; // EXPOSED via macros. Do not move
NDIS_M_REQ_COMPLETE_HANDLER QueryCompleteHandler; // EXPOSED via macros. Do not move
NDIS_M_REQ_COMPLETE_HANDLER SetCompleteHandler; // EXPOSED via macros. Do not move
NDIS_WM_SEND_COMPLETE_HANDLER WanSendCompleteHandler;// EXPOSED via macros. Do not move
WAN_RCV_HANDLER WanRcvHandler; // EXPOSED via macros. Do not move
WAN_RCV_COMPLETE_HANDLER WanRcvCompleteHandler; // EXPOSED via macros. Do not move
/********************************************************************************************/
/**************** **********/
/**************** STUFF ABOVE IS POTENTIALLY ACCESSED BY MACROS. ADD STUFF BELOW **********/
/**************** SEVERE POSSIBILITY OF BREAKING SOMETHING IF STUFF ABOVE IS MOVED **********/
/**************** **********/
/********************************************************************************************/
//
// Work that the miniport needs to do.
//
SINGLE_LIST_ENTRY WorkQueue[NUMBER_OF_WORK_ITEM_TYPES];
SINGLE_LIST_ENTRY SingleWorkItems[NUMBER_OF_SINGLE_WORK_ITEMS];
PNDIS_MAC_BLOCK FakeMac;
UCHAR SendFlags;
UCHAR TrResetRing;
UCHAR ArcnetAddress;
union
{
PNDIS_ARC_BUF ArcBuf;
//
// the following fiels has a different use under NT and Memphis
//
#if NDIS_NT
PVOID BusInterface;
#else
PVOID PhysicalAddressArray;
#endif
};
//
// Temp stuff for using the old NDIS functions
//
ULONG ChannelNumber;
PNDIS_LOG Log;
//
// Store information here to track adapters
//
ULONG BusId;
ULONG SlotNumber;
PCM_RESOURCE_LIST AllocatedResources;
PCM_RESOURCE_LIST AllocatedResourcesTranslated;
//
// Contains a list of the packet patterns that have been added to the
// adapter.
//
SINGLE_LIST_ENTRY PatternList;
//
// The driver's power management capabilities.
//
NDIS_PNP_CAPABILITIES PMCapabilities;
//
// DeviceCapabilites as received from bus driver
//
DEVICE_CAPABILITIES DeviceCaps;
//
// Contains the wake-up events that are enabled for the miniport.
//
ULONG WakeUpEnable;
//
// The current device state that the adapter is in.
//
DEVICE_POWER_STATE CurrentDeviceState;
//
// The following IRP is created in response to a cable disconnect
// from the device. We keep a pointer around in case we need to cancel
// it.
//
PIRP pIrpWaitWake;
SYSTEM_POWER_STATE WaitWakeSystemState;
//
// The following is a pointer to a dynamically allocated array
// of GUID structs. This is used to map GUIDs to OIDs
// for custom GUIDs provided by the miniport.
//
LARGE_INTEGER VcIndex; // Index used to identify a VC.
KSPIN_LOCK VcCountLock; // Lock used to protect VC instance count.
LIST_ENTRY WmiEnabledVcs; // List of WMI enabled VCs
PNDIS_GUID pNdisGuidMap; // This is a list of all the GUIDs
// and OIDs supported including any
// customg GUIDs.
PNDIS_GUID pCustomGuidMap; // This is a pointer into
// the pGuidToOidMap to the
// first custom GUID.
USHORT VcCount; // Number of VC's that have instance names.
USHORT cNdisGuidMap; // This is the number of std. GUIDs
USHORT cCustomGuidMap; // This is the number of custom GUIDs
//
// These two are used temporarily while allocating the map registers.
//
USHORT CurrentMapRegister;
PKEVENT AllocationEvent;
USHORT PhysicalMapRegistersNeeded;
USHORT SGMapRegistersNeeded;
ULONG MaximumPhysicalMapping;
//
// This timer is used for media disconnect timouts.
//
NDIS_TIMER MediaDisconnectTimer;
//
// The timeout value for media disconnect timer to fire
// default is 20 seconds
//
USHORT MediaDisconnectTimeOut;
//
// Used for WMI support
//
USHORT InstanceNumber;
//
// this event will be set at the end of adapter initialization
//
NDIS_EVENT OpenReadyEvent;
//
// current PnP state of the device, ex. started, stopped, query_removed, etc.
//
NDIS_PNP_DEVICE_STATE PnPDeviceState;
//
// previous device state. to be used when we get a cancel_remove or a cancel_stop
//
NDIS_PNP_DEVICE_STATE OldPnPDeviceState;
//
// Handlers to Write/Read Bus data
//
PGET_SET_DEVICE_DATA SetBusData;
PGET_SET_DEVICE_DATA GetBusData;
POID_LIST OidList;
KDPC DeferredDpc;
//
// Some NDIS gathered stats
//
NDIS_STATS NdisStats;
//
// Valid during Packet Indication
//
PNDIS_PACKET IndicatedPacket[MAXIMUM_PROCESSORS];
//
// this event is for protecting against returning from REMOVE IRP
// too early and while we still have pending workitems
//
PKEVENT RemoveReadyEvent;
//
// this event gets signaled when all opens on the miniport are closed
//
PKEVENT AllOpensClosedEvent;
//
// this event gets signaled when all requests on the miniport are gone
//
PKEVENT AllRequestsCompletedEvent;
//
// Init time for the miniport in milliseconds
//
ULONG InitTimeMs;
NDIS_MINIPORT_WORK_ITEM WorkItemBuffer[NUMBER_OF_SINGLE_WORK_ITEMS];
PNDIS_MINIPORT_TIMER TimerQueue;
//
// flags to fail certain NDIS APIs to make sure the driver does the right things
//
ULONG DriverVerifyFlags;
//
// used to queue miniport on global miniport queue
//
PNDIS_MINIPORT_BLOCK NextGlobalMiniport;
//
// InternalResetCount: The # of times NDIS decided a miniport was hung
// MiniportResetCount The # of times miniport decided it was hung
//
USHORT InternalResetCount;
USHORT MiniportResetCount;
USHORT MediaSenseConnectCount;
USHORT MediaSenseDisconnectCount;
PNDIS_PACKET * xPackets;
//
// track the user mode requests
//
ULONG UserModeOpenReferences;
#if LOCK_DBG
ULONG LockDbg;
ULONG LockDbgX;
PVOID LockThread;
#endif
PSECURITY_DESCRIPTOR SecurityDescriptor;
//
// both these variables are protected by Ref->SpinLock
//
ULONG NumUserOpens; // number of non-admin open handles
ULONG NumAdminOpens; // number of admin open handles
ULONG_REFERENCE Ref;
#if !(NDIS_NT)
PNDIS_PACKET LoopbackHead;