summaryrefslogblamecommitdiffstats
path: root/private/ntos/ndis/ndis30/ndismini.h
blob: 38892897d445dc454e3f5c54c9a14b25a37bb169 (plain) (tree)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                              
#include <afilter.h>
#include <efilter.h>
#include <tfilter.h>
#include <ffilter.h>

#define NDIS_M_MAX_MULTI_LIST 32
#define NDIS_M_MAX_LOOKAHEAD 526

//
// declare these first since they point to each other
//

typedef struct _NDIS_M_DRIVER_BLOCK   NDIS_M_DRIVER_BLOCK,   * PNDIS_M_DRIVER_BLOCK;
typedef struct _NDIS_MINIPORT_BLOCK   NDIS_MINIPORT_BLOCK,   * PNDIS_MINIPORT_BLOCK;
typedef struct _NDIS_M_PROTOCOL_BLOCK NDIS_M_PROTOCOL_BLOCK, * PNDIS_M_PROTOCOL_BLOCK;
typedef struct _NDIS_M_OPEN_BLOCK     NDIS_M_OPEN_BLOCK,     * PNDIS_M_OPEN_BLOCK;


//
// Function types for NDIS_MINIPORT_CHARACTERISTICS
//


typedef
BOOLEAN
(*W_CHECK_FOR_HANG_HANDLER) (
    IN NDIS_HANDLE MiniportAdapterContext
    );

typedef
VOID
(*W_DISABLE_INTERRUPT_HANDLER) (
    IN NDIS_HANDLE MiniportAdapterContext
    );

typedef
VOID
(*W_ENABLE_INTERRUPT_HANDLER) (
    IN NDIS_HANDLE MiniportAdapterContext
    );

typedef
VOID
(*W_HALT_HANDLER) (
    IN NDIS_HANDLE MiniportAdapterContext
    );

typedef
VOID
(*W_HANDLE_INTERRUPT_HANDLER) (
    IN NDIS_HANDLE MiniportAdapterContext
    );

typedef
NDIS_STATUS
(*W_INITIALIZE_HANDLER) (
    OUT PNDIS_STATUS OpenErrorStatus,
    OUT PUINT SelectedMediumIndex,
    IN PNDIS_MEDIUM MediumArray,
    IN UINT MediumArraySize,
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN NDIS_HANDLE WrapperConfigurationContext
    );

typedef
VOID
(*W_ISR_HANDLER) (
    OUT PBOOLEAN InterruptRecognized,
    OUT PBOOLEAN QueueMiniportHandleInterrupt,
    IN NDIS_HANDLE MiniportAdapterContext
    );

typedef
NDIS_STATUS
(*W_QUERY_INFORMATION_HANDLER) (
    IN NDIS_HANDLE MiniportAdapterContext,
    IN NDIS_OID Oid,
    IN PVOID InformationBuffer,
    IN ULONG InformationBufferLength,
    OUT PULONG BytesWritten,
    OUT PULONG BytesNeeded
    );

typedef
NDIS_STATUS
(*W_RECONFIGURE_HANDLER) (
    OUT PNDIS_STATUS OpenErrorStatus,
    IN NDIS_HANDLE MiniportAdapterContext,
    IN NDIS_HANDLE WrapperConfigurationContext
    );

typedef
NDIS_STATUS
(*W_RESET_HANDLER) (
    OUT PBOOLEAN AddressingReset,
    IN NDIS_HANDLE MiniportAdapterContext
    );

typedef
NDIS_STATUS
(*W_SEND_HANDLER) (
    IN NDIS_HANDLE MiniportAdapterContext,
    IN PNDIS_PACKET Packet,
    IN UINT Flags
    );

typedef
NDIS_STATUS
(*W_SET_INFORMATION_HANDLER) (
    IN NDIS_HANDLE MiniportAdapterContext,
    IN NDIS_OID Oid,
    IN PVOID InformationBuffer,
    IN ULONG InformationBufferLength,
    OUT PULONG BytesRead,
    OUT PULONG BytesNeeded
    );

typedef
NDIS_STATUS
(*W_TRANSFER_DATA_HANDLER) (
    OUT PNDIS_PACKET Packet,
    OUT PUINT BytesTransferred,
    IN NDIS_HANDLE MiniportAdapterContext,
    IN NDIS_HANDLE MiniportReceiveContext,
    IN UINT ByteOffset,
    IN UINT BytesToTransfer
    );

typedef struct _NDIS_MINIPORT_CHARACTERISTICS {
    UCHAR MajorNdisVersion;
    UCHAR MinorNdisVersion;
    UINT Reserved;
    W_CHECK_FOR_HANG_HANDLER    CheckForHangHandler;
    W_DISABLE_INTERRUPT_HANDLER DisableInterruptHandler;
    W_ENABLE_INTERRUPT_HANDLER  EnableInterruptHandler;
    W_HALT_HANDLER              HaltHandler;
    W_HANDLE_INTERRUPT_HANDLER  HandleInterruptHandler;
    W_INITIALIZE_HANDLER        InitializeHandler;
    W_ISR_HANDLER               ISRHandler;
    W_QUERY_INFORMATION_HANDLER QueryInformationHandler;
    W_RECONFIGURE_HANDLER       ReconfigureHandler;
    W_RESET_HANDLER             ResetHandler;
    W_SEND_HANDLER              SendHandler;
    W_SET_INFORMATION_HANDLER   SetInformationHandler;
    W_TRANSFER_DATA_HANDLER     TransferDataHandler;
} NDIS_MINIPORT_CHARACTERISTICS, *PNDIS_MINIPORT_CHARACTERISTICS;

//
// one of these per Driver
//

struct _NDIS_M_DRIVER_BLOCK {
    PNDIS_MINIPORT_BLOCK MiniportQueue;     // queue of mini-ports for this driver
    NDIS_HANDLE MiniportIdField;

    REFERENCE Ref;                      // contains spinlock for MiniportQueue
    UINT Length;                        // of this NDIS_DRIVER_BLOCK structure
    NDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics;    // handler addresses
    PNDIS_WRAPPER_HANDLE NdisDriverInfo;  // Driver information.
    PNDIS_M_DRIVER_BLOCK NextDriver;
    PNDIS_MAC_BLOCK FakeMac;
    KEVENT MiniportsRemovedEvent;         // used to find when all mini-ports are gone.
    BOOLEAN Unloading;                  // TRUE if unloading

};

typedef struct _NDIS_MINIPORT_INTERRUPT {
    PKINTERRUPT InterruptObject;
    KSPIN_LOCK DpcCountLock;
    PVOID MiniportIdField;
    W_ISR_HANDLER MiniportIsr;
    W_HANDLE_INTERRUPT_HANDLER MiniportDpc;
    KDPC InterruptDpc;
    PNDIS_MINIPORT_BLOCK Miniport;
    UCHAR DpcCount;
    BOOLEAN Filler1;

    //
    // This is used to tell when all the Dpcs for the adapter are completed.
    //

    KEVENT DpcsCompletedEvent;

    BOOLEAN SharedInterrupt;
    BOOLEAN IsrRequested;

} NDIS_MINIPORT_INTERRUPT, *PNDIS_MINIPORT_INTERRUPT;


typedef struct _NDIS_MINIPORT_TIMER {
    KTIMER Timer;
    KDPC Dpc;
    PNDIS_TIMER_FUNCTION MiniportTimerFunction;
    PVOID MiniportTimerContext;
    PNDIS_MINIPORT_BLOCK Miniport;
    struct _NDIS_MINIPORT_TIMER *NextDeferredTimer;
} NDIS_MINIPORT_TIMER, *PNDIS_MINIPORT_TIMER;

//
// Pending NdisOpenAdapter() structure (for miniports only).
//

typedef struct _MINIPORT_PENDING_OPEN *PMINIPORT_PENDING_OPEN;

typedef struct _MINIPORT_PENDING_OPEN {

    PMINIPORT_PENDING_OPEN  NextPendingOpen;
    PNDIS_HANDLE            NdisBindingHandle;
    PNDIS_MINIPORT_BLOCK    Miniport;
    PVOID                   NewOpenP;
    PVOID                   FileObject;
    NDIS_HANDLE             NdisProtocolHandle;
    NDIS_HANDLE             ProtocolBindingContext;
    PNDIS_STRING            AdapterName;
    UINT                    OpenOptions;
    PSTRING                 AddressingInformation;
    BOOLEAN                 UsingEncapsulation;
} MINIPORT_PENDING_OPEN;


//
// one of these per mini-port registered on a Driver
//

struct _NDIS_MINIPORT_BLOCK {
    ULONG Flags;                        // 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 NormalInterrupts;
    BOOLEAN ProcessingDeferred;         // TRUE if processing deferred operations

    //
    // 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;
    NDIS_SPIN_LOCK Lock;
    PNDIS_MINIPORT_INTERRUPT Interrupt;

    //
    // Stuff that got deferred.
    //
    BOOLEAN RunDpc;
    BOOLEAN Timeout;
    BOOLEAN InAddDriver;
    BOOLEAN InInitialize;
    PNDIS_MINIPORT_TIMER RunTimer;
    NDIS_TIMER DpcTimer;
    NDIS_TIMER WakeUpDpcTimer;

    //
    // Holds media specific information
    //
    PETH_FILTER EthDB;
    PTR_FILTER TrDB;
    PFDDI_FILTER FddiDB;
    PARC_FILTER ArcDB;
    NDIS_MEDIUM MediaType;

    UCHAR TrResetRing;
    UCHAR ArcnetAddress;
    BOOLEAN ArcnetBroadcastSet;
    BOOLEAN SendCompleteCalled;

    PVOID WrapperContext;

    NDIS_HANDLE ArcnetBufferPool;
    PARC_BUFFER_LIST ArcnetFreeBufferList;
    PARC_BUFFER_LIST ArcnetUsedBufferList;

    //
    // Resource information
    //
    PCM_RESOURCE_LIST Resources;

    //
    // contains mini-port information
    //
    ULONG BusNumber;
    NDIS_INTERFACE_TYPE BusType;
    NDIS_INTERFACE_TYPE AdapterType;
    BOOLEAN Master;

    //
    // Holds the map registers for this mini-port.
    //
    BOOLEAN Dma32BitAddresses;
    PMAP_REGISTER_ENTRY MapRegisters;
    ULONG PhysicalMapRegistersNeeded;
    ULONG MaximumPhysicalMapping;

    //
    // These two are used temporarily while allocating
    // the map registers.
    //
    KEVENT AllocationEvent;
    UINT CurrentMapRegister;
    PADAPTER_OBJECT SystemAdapterObject;

    //
    // Send information
    //
    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.
    ULONG SendResourcesAvailable;
    PNDIS_PACKET DeadPacket;            //  This pointer is used by the wake-up
                                        //  dpc to make sure that a packet that
                                        //  was sent to the miniport has been
                                        //  completed with-in a decent amount
                                        //  of time.
    BOOLEAN      AlreadyLoopedBack;     //  This flag is set if a packet that
                                        //  is waiting to be sent to the
                                        //  miniport has already been looped-
                                        //  back;


    //
    // Transfer data information
    //
    PNDIS_PACKET FirstTDPacket;
    PNDIS_PACKET LastTDPacket;
    PNDIS_PACKET LoopbackPacket;
    UINT LoopbackPacketHeaderSize;

    //
    // Reset information
    //
    PNDIS_M_OPEN_BLOCK ResetRequested;
    PNDIS_M_OPEN_BLOCK ResetInProgress;

    //
    // RequestInformation
    //
    KEVENT RequestEvent;
    PNDIS_REQUEST FirstPendingRequest;
    PNDIS_REQUEST LastPendingRequest;
    PNDIS_REQUEST MiniportRequest;
    NDIS_REQUEST InternalRequest;
    NDIS_STATUS RequestStatus;
    UINT MaximumLongAddresses;
    UINT MaximumShortAddresses;
    UINT CurrentLookahead;
    UINT MaximumLookahead;
    UINT MacOptions;
    ULONG SupportedPacketFilters;
    BOOLEAN NeedToUpdateEthAddresses;
    BOOLEAN NeedToUpdatePacketFilter;
    BOOLEAN NeedToUpdateFunctionalAddress;
    BOOLEAN NeedToUpdateGroupAddress;
    BOOLEAN NeedToUpdateFddiLongAddresses;
    BOOLEAN NeedToUpdateFddiShortAddresses;
    BOOLEAN RunDoRequests;
    BOOLEAN ProcessOddDeferredStuff;
    UCHAR MulticastBuffer[NDIS_M_MAX_MULTI_LIST][6];
    UCHAR LookaheadBuffer[NDIS_M_MAX_LOOKAHEAD];

    BOOLEAN BeingRemoved;               // TRUE if mini-port is being removed
    BOOLEAN HaltingMiniport;              // TRUE if mini-port halt handler needs to be called

    //
    // Temp stuff for using the old NDIS functions
    //
    ULONG ChannelNumber;

    PMINIPORT_PENDING_OPEN  FirstPendingOpen;
    PMINIPORT_PENDING_OPEN  LastPendingOpen;
	BOOLEAN			PendingRequestTimeout;
};

#define MINIPORT_LOCK_ACQUIRED(_Miniport) ((_Miniport)->LockAcquired)


//
// one of these per open on an mini-port/protocol
//

struct _NDIS_M_OPEN_BLOCK {
    PNDIS_M_DRIVER_BLOCK DriverHandle;      // pointer to our driver
    PNDIS_MINIPORT_BLOCK MiniportHandle;        // pointer to our mini-port
    PNDIS_PROTOCOL_BLOCK ProtocolHandle;    // pointer to our protocol
    PNDIS_OPEN_BLOCK FakeOpen;              // Pointer to fake open block
    NDIS_HANDLE ProtocolBindingContext;     // context when calling ProtXX funcs
    NDIS_HANDLE MiniportAdapterContext;       // context when calling MiniportXX funcs
    PNDIS_M_OPEN_BLOCK MiniportNextOpen;      // used by mini-port's OpenQueue
    PFILE_OBJECT FileObject;                // created by operating system
    BOOLEAN Closing;                        // TRUE when removing this struct
    BOOLEAN UsingEthEncapsulation;          // TRUE if running 802.3 on 878.2
    NDIS_HANDLE CloseRequestHandle;         // 0 indicates an internal close
    NDIS_HANDLE FilterHandle;
    NDIS_SPIN_LOCK SpinLock;                // guards Closing
    ULONG References;
    UINT CurrentLookahead;
    ULONG ProtocolOptions;

    //
    // These are optimizations for getting to driver routines.  They are not
    // necessary, but are here to save a dereference through the Driver block.
    //

    W_SEND_HANDLER SendHandler;
    W_TRANSFER_DATA_HANDLER TransferDataHandler;

    //
    // These are optimizations for getting to PROTOCOL routines.  They are not
    // necessary, but are here to save a dereference through the PROTOCOL block.
    //

    SEND_COMPLETE_HANDLER SendCompleteHandler;
    TRANSFER_DATA_COMPLETE_HANDLER TransferDataCompleteHandler;
    RECEIVE_HANDLER ReceiveHandler;
    RECEIVE_COMPLETE_HANDLER ReceiveCompleteHandler;

};

//
// NOTE: THIS STRUCTURE MUST, MUST, MUST ALIGN WITH THE
// NDIS_USER_OPEN_CONTEXT STRUCTURE defined in the wrapper.
//
typedef struct _NDIS_M_USER_OPEN_CONTEXT {
    PDEVICE_OBJECT DeviceObject;
    PNDIS_MINIPORT_BLOCK MiniportBlock;
    ULONG OidCount;
    PNDIS_OID OidArray;
} NDIS_M_USER_OPEN_CONTEXT, *PNDIS_M_USER_OPEN_CONTEXT;


typedef struct _NDIS_REQUEST_RESERVED {
    PNDIS_REQUEST Next;
    struct _NDIS_M_OPEN_BLOCK * Open;
} NDIS_REQUEST_RESERVED, *PNDIS_REQUEST_RESERVED;

#define PNDIS_RESERVED_FROM_PNDIS_REQUEST(_request) \
   ((PNDIS_REQUEST_RESERVED)((_request)->MacReserved))


BOOLEAN
NdisMIsr(
    IN PKINTERRUPT KInterrupt,
    IN PVOID Context
    );

VOID
NdisMDpc(
    IN PVOID SystemSpecific1,
    IN PVOID InterruptContext,
    IN PVOID SystemSpecific2,
    IN PVOID SystemSpecific3
    );

VOID
NdisMDpcTimer(
    IN PVOID SystemSpecific1,
    IN PVOID InterruptContext,
    IN PVOID SystemSpecific2,
    IN PVOID SystemSpecific3
    );

VOID
NdisMWakeUpDpc(
    PKDPC Dpc,
    PVOID Context,
    PVOID SystemContext1,
    PVOID SystemContext2
    );

NDIS_STATUS
NdisMChangeEthAddresses(
    IN UINT OldAddressCount,
    IN CHAR OldAddresses[][6],
    IN UINT NewAddressCount,
    IN CHAR NewAddresses[][6],
    IN NDIS_HANDLE MacBindingHandle,
    IN PNDIS_REQUEST NdisRequest,
    IN BOOLEAN Set
    );

NDIS_STATUS
NdisMChangeClass(
    IN UINT OldFilterClasses,
    IN UINT NewFilterClasses,
    IN NDIS_HANDLE MacBindingHandle,
    IN PNDIS_REQUEST NdisRequest,
    IN BOOLEAN Set
    );

VOID
NdisMCloseAction(
    IN NDIS_HANDLE MacBindingHandle
    );

NDIS_STATUS
NdisMChangeFunctionalAddress(
    IN TR_FUNCTIONAL_ADDRESS OldFunctionalAddress,
    IN TR_FUNCTIONAL_ADDRESS NewFunctionalAddress,
    IN NDIS_HANDLE MacBindingHandle,
    IN PNDIS_REQUEST NdisRequest,
    IN BOOLEAN Set
    );

NDIS_STATUS
NdisMChangeGroupAddress(
    IN TR_FUNCTIONAL_ADDRESS OldGroupAddress,
    IN TR_FUNCTIONAL_ADDRESS NewGroupAddress,
    IN NDIS_HANDLE MacBindingHandle,
    IN PNDIS_REQUEST NdisRequest,
    IN BOOLEAN Set
    );

NDIS_STATUS
NdisMChangeFddiAddresses(
    IN UINT oldLongAddressCount,
    IN CHAR oldLongAddresses[][6],
    IN UINT newLongAddressCount,
    IN CHAR newLongAddresses[][6],
    IN UINT oldShortAddressCount,
    IN CHAR oldShortAddresses[][2],
    IN UINT newShortAddressCount,
    IN CHAR newShortAddresses[][2],
    IN NDIS_HANDLE MacBindingHandle,
    IN PNDIS_REQUEST NdisRequest,
    IN BOOLEAN Set
    );

NDIS_STATUS
NdisMSend(
    IN NDIS_HANDLE NdisBindingHandle,
    IN PNDIS_PACKET Packet
    );

NDIS_STATUS
NdisMTransferData(
    IN NDIS_HANDLE NdisBindingHandle,
    IN NDIS_HANDLE MacReceiveContext,
    IN UINT ByteOffset,
    IN UINT BytesToTransfer,
    IN OUT PNDIS_PACKET Packet,
    OUT PUINT BytesTransferred
    );

NDIS_STATUS
NdisMArcTransferData(
    IN NDIS_HANDLE NdisBindingHandle,
    IN NDIS_HANDLE MacReceiveContext,
    IN UINT ByteOffset,
    IN UINT BytesToTransfer,
    IN OUT PNDIS_PACKET Packet,
    OUT PUINT BytesTransferred
    );

NDIS_STATUS
NdisMReset(
    IN NDIS_HANDLE NdisBindingHandle
    );

NDIS_STATUS
NdisMRequest(
    IN NDIS_HANDLE NdisBindingHandle,
    IN PNDIS_REQUEST NdisRequest
    );


//
// Operating System Requests
//

EXPORT
NDIS_STATUS
NdisMAllocateMapRegisters(
    IN  NDIS_HANDLE MiniportAdapterHandle,
    IN  UINT DmaChannel,
    IN  BOOLEAN Dma32BitAddresses,
    IN  ULONG PhysicalMapRegistersNeeded,
    IN  ULONG MaximumPhysicalMapping
    );

EXPORT
VOID
NdisMFreeMapRegisters(
    IN  NDIS_HANDLE MiniportAdapterHandle
    );

EXPORT
NDIS_STATUS
NdisMRegisterIoPortRange(
    OUT PVOID *PortOffset,
    IN  NDIS_HANDLE MiniportAdapterHandle,
    IN  UINT InitialPort,
    IN  UINT NumberOfPorts
    );

EXPORT
VOID
NdisMDeregisterIoPortRange(
    IN  NDIS_HANDLE MiniportAdapterHandle,
    IN  UINT InitialPort,
    IN  UINT NumberOfPorts,
    IN  PVOID PortOffset
    );

EXPORT
NDIS_STATUS
NdisMMapIoSpace(
    OUT PVOID * VirtualAddress,
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
    IN UINT Length
    );

EXPORT
VOID
NdisMUnmapIoSpace(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN PVOID VirtualAddress,
    IN UINT Length
    );

EXPORT
NDIS_STATUS
NdisMRegisterInterrupt(
    OUT PNDIS_MINIPORT_INTERRUPT Interrupt,
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN UINT InterruptVector,
    IN UINT InterruptLevel,
    IN BOOLEAN RequestIsr,
    IN BOOLEAN SharedInterrupt,
    IN NDIS_INTERRUPT_MODE InterruptMode
    );

EXPORT
VOID
NdisMDeregisterInterrupt(
    IN PNDIS_MINIPORT_INTERRUPT Interrupt
    );

EXPORT
BOOLEAN
NdisMSynchronizeWithInterrupt(
    IN PNDIS_MINIPORT_INTERRUPT Interrupt,
    IN PVOID SynchronizeFunction,
    IN PVOID SynchronizeContext
    );


EXPORT
NDIS_STATUS
NdisMQueryAdapterResources(
    OUT PNDIS_STATUS Status,
    IN NDIS_HANDLE WrapperConfigurationContext,
    OUT PNDIS_RESOURCE_LIST ResourceList,
    IN OUT PUINT BufferSize
	);

//
// Timers
//

/*++
VOID
NdisMSetTimer(
    IN PNDIS_MINIPORT_TIMER Timer,
    IN UINT MillisecondsToDelay
    );
--*/
#define NdisMSetTimer(_Timer, _Delay) NdisSetTimer((PNDIS_TIMER)(_Timer), _Delay)

EXPORT
VOID
NdisMInitializeTimer(
    IN OUT PNDIS_MINIPORT_TIMER Timer,
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN PNDIS_TIMER_FUNCTION TimerFunction,
    IN PVOID FunctionContext
    );

EXPORT
VOID
NdisMCancelTimer(
    IN PNDIS_MINIPORT_TIMER Timer,
    OUT PBOOLEAN TimerCancelled
    );

//
// Physical Mapping
//

#define NdisMStartBufferPhysicalMappingMacro(                                               \
              _MiniportAdapterHandle,                                                       \
              _Buffer,                                                                      \
              _PhysicalMapRegister,                                                         \
              _Write,                                                                       \
              _PhysicalAddressArray,                                                        \
              _ArraySize                                                                    \
              )                                                                             \
{                                                                                           \
    PNDIS_MINIPORT_BLOCK _Miniport = (PNDIS_MINIPORT_BLOCK)(_MiniportAdapterHandle);        \
    PHYSICAL_ADDRESS _LogicalAddress;                                                       \
    PUCHAR _VirtualAddress;                                                                 \
    ULONG _LengthRemaining;                                                                 \
    ULONG _LengthMapped;                                                                    \
    UINT _CurrentArrayLocation;                                                             \
    _VirtualAddress = MmGetMdlVirtualAddress(_Buffer);                                      \
    _LengthRemaining = MmGetMdlByteCount(_Buffer);                                          \
    _CurrentArrayLocation = 0;                                                              \
    while (_LengthRemaining > 0) {                                                          \
        _LengthMapped = _LengthRemaining;                                                   \
        _LogicalAddress =                                                                   \
            IoMapTransfer(                                                                  \
                NULL,                                                                       \
                (_Buffer),                                                                  \
                _Miniport->MapRegisters[_PhysicalMapRegister].MapRegister,                  \
                _VirtualAddress,                                                            \
                &_LengthMapped,                                                             \
                (_Write));                                                                  \
        (_PhysicalAddressArray)[_CurrentArrayLocation].PhysicalAddress = _LogicalAddress;   \
        (_PhysicalAddressArray)[_CurrentArrayLocation].Length = _LengthMapped;              \
        _LengthRemaining -= _LengthMapped;                                                  \
        _VirtualAddress += _LengthMapped;                                                   \
        ++_CurrentArrayLocation;                                                            \
    }                                                                                       \
    _Miniport->MapRegisters[_PhysicalMapRegister].WriteToDevice = (_Write);                 \
    *(_ArraySize) = _CurrentArrayLocation;                                                  \
}

#if BINARY_COMPATIBLE

EXPORT
VOID
NdisMStartBufferPhysicalMapping(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN PNDIS_BUFFER Buffer,
    IN ULONG PhysicalMapRegister,
    IN BOOLEAN WriteToDevice,
    OUT PNDIS_PHYSICAL_ADDRESS_UNIT PhysicalAddressArray,
    OUT PUINT ArraySize
    );

#else

#define NdisMStartBufferPhysicalMapping(                                                    \
              _MiniportAdapterHandle,                                                       \
              _Buffer,                                                                      \
              _PhysicalMapRegister,                                                         \
              _Write,                                                                       \
              _PhysicalAddressArray,                                                        \
              _ArraySize                                                                    \
              )                                                                             \
        NdisMStartBufferPhysicalMappingMacro(                                               \
              (_MiniportAdapterHandle),                                                     \
              (_Buffer),                                                                    \
              (_PhysicalMapRegister),                                                       \
              (_Write),                                                                     \
              (_PhysicalAddressArray),                                                      \
              (_ArraySize)                                                                  \
              )

#endif

#define NdisMCompleteBufferPhysicalMappingMacro(                                            \
            _MiniportAdapterHandle,                                                         \
            _Buffer,                                                                        \
            _PhysicalMapRegister                                                            \
            ) {                                                                             \
    PNDIS_MINIPORT_BLOCK _Miniport = (PNDIS_MINIPORT_BLOCK)(_MiniportAdapterHandle);        \
    IoFlushAdapterBuffers(                                                                  \
        NULL,                                                                               \
        _Buffer,                                                                            \
        _Miniport->MapRegisters[_PhysicalMapRegister].MapRegister,                          \
        MmGetMdlVirtualAddress(_Buffer),                                                    \
        MmGetMdlByteCount(_Buffer),                                                         \
        _Miniport->MapRegisters[_PhysicalMapRegister].WriteToDevice);                       \
}

#if BINARY_COMPATIBLE

EXPORT
VOID
NdisMCompleteBufferPhysicalMapping(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN PNDIS_BUFFER Buffer,
    IN ULONG PhysicalMapRegister
    );

#else

#define NdisMCompleteBufferPhysicalMapping(                                                 \
            _MiniportAdapterHandle,                                                         \
            _Buffer,                                                                        \
            _PhysicalMapRegister                                                            \
            )                                                                               \
        NdisMCompleteBufferPhysicalMappingMacro(                                            \
            (_MiniportAdapterHandle),                                                       \
            (_Buffer),                                                                      \
            (_PhysicalMapRegister)                                                          \
            )

#endif

//
// Shared memory
//

EXPORT
VOID
NdisMAllocateSharedMemory(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN ULONG Length,
    IN BOOLEAN Cached,
    OUT PVOID *VirtualAddress,
    OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress
    );

/*++
VOID
NdisMUpdateSharedMemory(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN ULONG Length,
    IN PVOID VirtualAddress,
    IN NDIS_PHYSICAL_ADDRESS PhysicalAddress
    )
--*/
#define NdisMUpdateSharedMemory(_H, _L, _V, _P) NdisUpdateSharedMemory(_H, _L, _V, _P)


EXPORT
VOID
NdisMFreeSharedMemory(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN ULONG Length,
    IN BOOLEAN Cached,
    IN PVOID VirtualAddress,
    IN NDIS_PHYSICAL_ADDRESS PhysicalAddress
    );


//
// DMA operations.
//

EXPORT
NDIS_STATUS
NdisMRegisterDmaChannel(
    OUT PNDIS_HANDLE MiniportDmaHandle,
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN UINT DmaChannel,
    IN BOOLEAN Dma32BitAddresses,
    IN PNDIS_DMA_DESCRIPTION DmaDescription,
    IN ULONG MaximumLength
    );


EXPORT
VOID
NdisMDeregisterDmaChannel(
    IN PNDIS_HANDLE MiniportDmaHandle
    );

/*++
VOID
NdisMSetupDmaTransfer(
    OUT PNDIS_STATUS Status,
    IN PNDIS_HANDLE MiniportDmaHandle,
    IN PNDIS_BUFFER Buffer,
    IN ULONG Offset,
    IN ULONG Length,
    IN BOOLEAN WriteToDevice
    )
--*/
#define NdisMSetupDmaTransfer(_S, _H, _B, _O, _L, _M_) \
        NdisSetupDmaTransfer(_S, _H, _B, _O, _L, _M_)

/*++
VOID
NdisMCompleteDmaTransfer(
    OUT PNDIS_STATUS Status,
    IN PNDIS_HANDLE MiniportDmaHandle,
    IN PNDIS_BUFFER Buffer,
    IN ULONG Offset,
    IN ULONG Length,
    IN BOOLEAN WriteToDevice
    )
--*/
#define NdisMCompleteDmaTransfer(_S, _H, _B, _O, _L, _M_) \
        NdisCompleteDmaTransfer(_S, _H, _B, _O, _L, _M_)

EXPORT
ULONG
NdisMReadDmaCounter(
    IN NDIS_HANDLE MiniportDmaHandle
    );


//
// Requests Used by Miniport Drivers
//


#define NdisMInitializeWrapper(_a,_b,_c,_d) NdisInitializeWrapper((_a),(_b),(_c),(_d))

EXPORT
NDIS_STATUS
NdisMRegisterMiniport(
    IN NDIS_HANDLE NdisWrapperHandle,
    IN PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics,
    IN UINT CharacteristicsLength
    );

EXPORT
VOID
NdisMSetAttributes(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN NDIS_HANDLE MiniportAdapterContext,
    IN BOOLEAN BusMaster,
    IN NDIS_INTERFACE_TYPE AdapterType
    );

EXPORT
VOID
NdisMSendComplete(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN PNDIS_PACKET Packet,
    IN NDIS_STATUS Status
    );

EXPORT
VOID
NdisMSendResourcesAvailable(
    IN NDIS_HANDLE MiniportAdapterHandle
    );

EXPORT
VOID
NdisMTransferDataComplete(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN PNDIS_PACKET Packet,
    IN NDIS_STATUS Status,
    IN UINT BytesTransferred
    );

EXPORT
VOID
NdisMResetComplete(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN NDIS_STATUS Status,
    IN BOOLEAN AddressingReset
    );

EXPORT
VOID
NdisMSetInformationComplete(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN NDIS_STATUS Status
    );

EXPORT
VOID
NdisMQueryInformationComplete(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN NDIS_STATUS Status
    );


/*++

VOID
NdisMEthIndicateReceive(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN NDIS_HANDLE MiniportReceiveContext,
    IN PVOID HeaderBuffer,
    IN UINT HeaderBufferSize,
    IN PVOID LookaheadBuffer,
    IN UINT LookaheadBufferSize,
    IN UINT PacketSize
    )

--*/
#define NdisMEthIndicateReceive( _H, _C, _B, _SZ, _L, _LSZ, _PSZ ) \
{                                                                  \
    ASSERT(MINIPORT_LOCK_ACQUIRED((PNDIS_MINIPORT_BLOCK)(_H)));    \
    EthFilterDprIndicateReceive(                                   \
        ((PNDIS_MINIPORT_BLOCK)(_H))->EthDB,                       \
        _C,                                                        \
        _B,                                                        \
        _B,                                                        \
        _SZ,                                                       \
        _L,                                                        \
        _LSZ,                                                      \
        _PSZ                                                       \
        );                                                         \
}

/*++

VOID
NdisMTrIndicateReceive(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN NDIS_HANDLE MiniportReceiveContext,
    IN PVOID HeaderBuffer,
    IN UINT HeaderBufferSize,
    IN PVOID LookaheadBuffer,
    IN UINT LookaheadBufferSize,
    IN UINT PacketSize
    )

--*/
#define NdisMTrIndicateReceive( _H, _C, _B, _SZ, _L, _LSZ, _PSZ )  \
{                                                                  \
    ASSERT(MINIPORT_LOCK_ACQUIRED((PNDIS_MINIPORT_BLOCK)(_H)));    \
    TrFilterDprIndicateReceive(                                    \
        ((PNDIS_MINIPORT_BLOCK)(_H))->TrDB,                        \
        _C,                                                        \
        _B,                                                       \
        _SZ,                                                       \
        _L,                                                        \
        _LSZ,                                                      \
        _PSZ                                                       \
        );                                                         \
}

/*++

VOID
NdisMFddiIndicateReceive(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN NDIS_HANDLE MiniportReceiveContext,
    IN PVOID HeaderBuffer,
    IN UINT HeaderBufferSize,
    IN PVOID LookaheadBuffer,
    IN UINT LookaheadBufferSize,
    IN UINT PacketSize
    )

--*/

#define NdisMFddiIndicateReceive( _H, _C, _B, _SZ, _L, _LSZ, _PSZ ) \
{                                                                   \
    ASSERT(MINIPORT_LOCK_ACQUIRED((PNDIS_MINIPORT_BLOCK)(_H)));     \
                                                                    \
    FddiFilterDprIndicateReceive(                                   \
            ((PNDIS_MINIPORT_BLOCK)(_H))->FddiDB,                   \
            _C,                                                     \
            (PUCHAR)_B + 1,                                         \
            ((((PUCHAR)_B)[0] & 0x40) ? FDDI_LENGTH_OF_LONG_ADDRESS \
                             : FDDI_LENGTH_OF_SHORT_ADDRESS),       \
            _B,                                                     \
            _SZ,                                                    \
            _L,                                                     \
            _LSZ,                                                   \
            _PSZ                                                    \
    );                                                              \
}

/*++

VOID
NdisMArcIndicateReceive(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN PUCHAR pRawHeader,           // Pointer to Arcnet frame header
    IN PUCHAR pData,                // Pointer to data portion of Arcnet frame
    IN UINT Length                  // Data Length
    )

--*/
#define NdisMArcIndicateReceive( _H, _HD, _D, _SZ)                 \
{                                                                  \
    ASSERT(MINIPORT_LOCK_ACQUIRED((PNDIS_MINIPORT_BLOCK)(_H)));    \
    ArcFilterDprIndicateReceive(                                   \
        ((PNDIS_MINIPORT_BLOCK)(_H))->ArcDB,                       \
        _HD,                                                       \
        _D,                                                        \
        _SZ                                                        \
        );                                                         \
}

//
// Used only internally by the wrapper and filter package.
//
VOID
NdisMArcIndicateEthEncapsulatedReceive(
    IN PNDIS_MINIPORT_BLOCK Miniport,
    IN PVOID HeaderBuffer,
    IN PVOID DataBuffer,
    IN UINT Length
    );




/*++

VOID
NdisMEthIndicateReceiveComplete(
    IN NDIS_HANDLE MiniportAdapterHandle
    );

--*/

#define NdisMEthIndicateReceiveComplete( _H )                      \
{                                                                  \
    PNDIS_MINIPORT_BLOCK _M_ = (PNDIS_MINIPORT_BLOCK)_H;                \
    ASSERT(MINIPORT_LOCK_ACQUIRED(_M_));                              \
    EthFilterDprIndicateReceiveComplete(_M_->EthDB);                \
}

/*++

VOID
NdisMTrIndicateReceiveComplete(
    IN NDIS_HANDLE MiniportAdapterHandle
    );

--*/

#define NdisMTrIndicateReceiveComplete( _H )                       \
{                                                                  \
    PNDIS_MINIPORT_BLOCK _M_ = (PNDIS_MINIPORT_BLOCK)_H;           \
    ASSERT(MINIPORT_LOCK_ACQUIRED(_M_));                           \
    TrFilterDprIndicateReceiveComplete(_M_->TrDB);                 \
}

/*++

VOID
NdisMFddiIndicateReceiveComplete(
    IN NDIS_HANDLE MiniportAdapterHandle
    );

--*/

#define NdisMFddiIndicateReceiveComplete( _H )                     \
{                                                                  \
    PNDIS_MINIPORT_BLOCK _M_ = (PNDIS_MINIPORT_BLOCK)_H;           \
    ASSERT(MINIPORT_LOCK_ACQUIRED(_M_));                           \
    FddiFilterDprIndicateReceiveComplete(_M_->FddiDB);             \
}

/*++

VOID
NdisMArcIndicateReceiveComplete(
    IN NDIS_HANDLE MiniportAdapterHandle
    );

--*/

#define NdisMArcIndicateReceiveComplete( _H )                       \
{                                                                   \
    PNDIS_MINIPORT_BLOCK _M_ = (PNDIS_MINIPORT_BLOCK)_H;            \
    ASSERT(MINIPORT_LOCK_ACQUIRED(_M_));                            \
                                                                    \
    if ( _M_->EthDB ) {                                             \
        EthFilterDprIndicateReceiveComplete(_M_->EthDB);            \
    }                                                               \
                                                                    \
    ArcFilterDprIndicateReceiveComplete(_M_->ArcDB);                \
}

EXPORT
VOID
NdisMIndicateStatus(
    IN NDIS_HANDLE MiniportAdapterHandle,
    IN NDIS_STATUS GeneralStatus,
    IN PVOID StatusBuffer,
    IN UINT StatusBufferSize
    );

EXPORT
VOID
NdisMIndicateStatusComplete(
    IN NDIS_HANDLE MiniportAdapterHandle
    );

EXPORT
VOID
NdisMRegisterAdapterShutdownHandler(
    IN NDIS_HANDLE MiniportHandle,
    IN PVOID ShutdownContext,
    IN ADAPTER_SHUTDOWN_HANDLER ShutdownHandler
    );

EXPORT
VOID
NdisMDeregisterAdapterShutdownHandler(
    IN NDIS_HANDLE MiniportHandle
    );

EXPORT
NDIS_STATUS
NdisMPciAssignResources(
    IN NDIS_HANDLE MiniportHandle,
    IN ULONG SlotNumber,
    IN PNDIS_RESOURCE_LIST *AssignedResources
    );