ReactOS 0.4.15-dev-8096-ga0eec98
miniport.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _HARDWARE_ADDRESS
 
struct  _NDIS_M_DRIVER_BLOCK
 
struct  _NDIS_M_DEVICE_BLOCK
 
struct  _MINIPORT_RESOURCE
 
struct  _MINIPORT_CONFIGURATION_CONTEXT
 
struct  _MINIPORT_BUGCHECK_CONTEXT
 
struct  _MINIPORT_SHARED_MEMORY
 
struct  _NDIS_WRAPPER_CONTEXT
 
struct  _LOGICAL_ADAPTER
 

Macros

#define MINIPORT_RESOURCE_TYPE_REGISTRY_DATA   0
 
#define MINIPORT_RESOURCE_TYPE_MEMORY   1
 
#define GET_MINIPORT_DRIVER(Handle)   ((PNDIS_M_DRIVER_BLOCK)Handle)
 
#define GET_LOGICAL_ADAPTER(Handle)   ((PLOGICAL_ADAPTER)Handle)
 

Typedefs

typedef struct _HARDWARE_ADDRESS HARDWARE_ADDRESS
 
typedef struct _HARDWARE_ADDRESSPHARDWARE_ADDRESS
 
typedef struct _NDIS_M_DRIVER_BLOCK NDIS_M_DRIVER_BLOCK
 
typedef struct _NDIS_M_DRIVER_BLOCKPNDIS_M_DRIVER_BLOCK
 
typedef struct _NDIS_M_DEVICE_BLOCK NDIS_M_DEVICE_BLOCK
 
typedef struct _NDIS_M_DEVICE_BLOCKPNDIS_M_DEVICE_BLOCK
 
typedef struct _MINIPORT_RESOURCE MINIPORT_RESOURCE
 
typedef struct _MINIPORT_RESOURCEPMINIPORT_RESOURCE
 
typedef struct _MINIPORT_CONFIGURATION_CONTEXT MINIPORT_CONFIGURATION_CONTEXT
 
typedef struct _MINIPORT_CONFIGURATION_CONTEXTPMINIPORT_CONFIGURATION_CONTEXT
 
typedef struct _MINIPORT_BUGCHECK_CONTEXT MINIPORT_BUGCHECK_CONTEXT
 
typedef struct _MINIPORT_BUGCHECK_CONTEXTPMINIPORT_BUGCHECK_CONTEXT
 
typedef struct _MINIPORT_SHARED_MEMORY MINIPORT_SHARED_MEMORY
 
typedef struct _MINIPORT_SHARED_MEMORYPMINIPORT_SHARED_MEMORY
 
typedef struct _NDIS_WRAPPER_CONTEXT NDIS_WRAPPER_CONTEXT
 
typedef struct _NDIS_WRAPPER_CONTEXTPNDIS_WRAPPER_CONTEXT
 
typedef struct _LOGICAL_ADAPTER LOGICAL_ADAPTER
 
typedef struct _LOGICAL_ADAPTERPLOGICAL_ADAPTER
 

Functions

VOID MiniIndicateData (PLOGICAL_ADAPTER Adapter, NDIS_HANDLE MacReceiveContext, PVOID HeaderBuffer, UINT HeaderBufferSize, PVOID LookaheadBuffer, UINT LookaheadBufferSize, UINT PacketSize)
 
BOOLEAN MiniAdapterHasAddress (PLOGICAL_ADAPTER Adapter, PNDIS_PACKET Packet)
 
PLOGICAL_ADAPTER MiniLocateDevice (PNDIS_STRING AdapterName)
 
NDIS_STATUS MiniQueryInformation (PLOGICAL_ADAPTER Adapter, NDIS_OID Oid, ULONG Size, PVOID Buffer, PULONG BytesWritten)
 
VOID FASTCALL MiniQueueWorkItem (PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE WorkItemType, PVOID WorkItemContext, BOOLEAN Top)
 
NDIS_STATUS FASTCALL MiniDequeueWorkItem (PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE *WorkItemType, PVOID *WorkItemContext)
 
NDIS_STATUS MiniDoRequest (PLOGICAL_ADAPTER Adapter, PNDIS_REQUEST NdisRequest)
 
BOOLEAN NdisFindDevice (UINT VendorID, UINT DeviceID, PUINT BusNumber, PUINT SlotNumber)
 
VOID NdisStartDevices (VOID)
 
VOID NTAPI MiniportWorker (IN PDEVICE_OBJECT DeviceObject, IN PVOID WorkItem)
 
VOID NTAPI MiniSendComplete (IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status)
 
BOOLEAN MiniIsBusy (PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE Type)
 
NDIS_STATUS MiniReset (PLOGICAL_ADAPTER Adapter)
 
VOID MiniDoAddressingReset (PLOGICAL_ADAPTER Adapter)
 
VOID MiniWorkItemComplete (PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE WorkItemType)
 

Variables

LIST_ENTRY MiniportListHead
 
KSPIN_LOCK MiniportListLock
 
LIST_ENTRY AdapterListHead
 
KSPIN_LOCK AdapterListLock
 

Macro Definition Documentation

◆ GET_LOGICAL_ADAPTER

#define GET_LOGICAL_ADAPTER (   Handle)    ((PLOGICAL_ADAPTER)Handle)

Definition at line 101 of file miniport.h.

◆ GET_MINIPORT_DRIVER

#define GET_MINIPORT_DRIVER (   Handle)    ((PNDIS_M_DRIVER_BLOCK)Handle)

Definition at line 84 of file miniport.h.

◆ MINIPORT_RESOURCE_TYPE_MEMORY

#define MINIPORT_RESOURCE_TYPE_MEMORY   1

Definition at line 42 of file miniport.h.

◆ MINIPORT_RESOURCE_TYPE_REGISTRY_DATA

#define MINIPORT_RESOURCE_TYPE_REGISTRY_DATA   0

Definition at line 41 of file miniport.h.

Typedef Documentation

◆ HARDWARE_ADDRESS

◆ LOGICAL_ADAPTER

◆ MINIPORT_BUGCHECK_CONTEXT

◆ MINIPORT_CONFIGURATION_CONTEXT

◆ MINIPORT_RESOURCE

◆ MINIPORT_SHARED_MEMORY

◆ NDIS_M_DEVICE_BLOCK

◆ NDIS_M_DRIVER_BLOCK

◆ NDIS_WRAPPER_CONTEXT

◆ PHARDWARE_ADDRESS

◆ PLOGICAL_ADAPTER

◆ PMINIPORT_BUGCHECK_CONTEXT

◆ PMINIPORT_CONFIGURATION_CONTEXT

◆ PMINIPORT_RESOURCE

◆ PMINIPORT_SHARED_MEMORY

◆ PNDIS_M_DEVICE_BLOCK

◆ PNDIS_M_DRIVER_BLOCK

◆ PNDIS_WRAPPER_CONTEXT

Function Documentation

◆ MiniAdapterHasAddress()

BOOLEAN MiniAdapterHasAddress ( PLOGICAL_ADAPTER  Adapter,
PNDIS_PACKET  Packet 
)

Definition at line 616 of file miniport.c.

627{
628 UINT Length;
629 PUCHAR PacketAddress;
630 PUCHAR AdapterAddress;
631 PNDIS_BUFFER NdisBuffer;
633
634 NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
635
636#if DBG
637 if(!Adapter)
638 {
639 NDIS_DbgPrint(MIN_TRACE, ("Adapter object was null\n"));
640 return FALSE;
641 }
642
643 if(!Packet)
644 {
645 NDIS_DbgPrint(MIN_TRACE, ("Packet was null\n"));
646 return FALSE;
647 }
648#endif
649
650 NdisQueryPacket(Packet, NULL, NULL, &NdisBuffer, NULL);
651
652 if (!NdisBuffer)
653 {
654 NDIS_DbgPrint(MIN_TRACE, ("Packet contains no buffers.\n"));
655 return FALSE;
656 }
657
658 NdisQueryBuffer(NdisBuffer, (PVOID)&PacketAddress, &BufferLength);
659
660 /* FIXME: Should handle fragmented packets */
661
662 switch (Adapter->NdisMiniportBlock.MediaType)
663 {
664 case NdisMedium802_3:
666 /* Destination address is the first field */
667 break;
668
669 default:
670 NDIS_DbgPrint(MIN_TRACE, ("Adapter has unsupported media type (0x%X).\n", Adapter->NdisMiniportBlock.MediaType));
671 return FALSE;
672 }
673
674 if (BufferLength < Length)
675 {
676 NDIS_DbgPrint(MIN_TRACE, ("Buffer is too small.\n"));
677 return FALSE;
678 }
679
680 AdapterAddress = (PUCHAR)&Adapter->Address;
681 NDIS_DbgPrint(MAX_TRACE, ("packet address: %x:%x:%x:%x:%x:%x adapter address: %x:%x:%x:%x:%x:%x\n",
682 *(PacketAddress), *(PacketAddress+1), *(PacketAddress+2), *(PacketAddress+3), *(PacketAddress+4), *(PacketAddress+5),
683 *(AdapterAddress), *(AdapterAddress+1), *(AdapterAddress+2), *(AdapterAddress+3), *(AdapterAddress+4), *(AdapterAddress+5)));
684
685 return (RtlCompareMemory(PacketAddress, AdapterAddress, Length) == Length);
686}
#define MIN_TRACE
Definition: debug.h:14
#define MAX_TRACE
Definition: debug.h:16
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define DEBUG_MINIPORT
Definition: debug.h:17
#define ETH_LENGTH_OF_ADDRESS
Definition: efilter.h:16
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1549
unsigned int UINT
Definition: ndis.h:50
static __inline VOID NdisQueryPacket(IN PNDIS_PACKET Packet, OUT PUINT PhysicalBufferCount OPTIONAL, OUT PUINT BufferCount OPTIONAL, OUT PNDIS_BUFFER *FirstBuffer OPTIONAL, OUT PUINT TotalPacketLength OPTIONAL)
Definition: ndis.h:3593
MDL * PNDIS_BUFFER
Definition: ndis.h:343
#define NdisQueryBuffer(_Buffer, _VirtualAddress, _Length)
Definition: ndis.h:3029
@ NdisMedium802_3
Definition: ntddndis.h:188
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
HARDWARE_ADDRESS Address
Definition: miniport.h:96
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
NDIS_MEDIUM MediaType
Definition: ndis.h:2548
unsigned char * PUCHAR
Definition: typedefs.h:53
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771

Referenced by ProSend().

◆ MiniDequeueWorkItem()

NDIS_STATUS FASTCALL MiniDequeueWorkItem ( PLOGICAL_ADAPTER  Adapter,
NDIS_WORK_ITEM_TYPE WorkItemType,
PVOID WorkItemContext 
)

Definition at line 1050 of file miniport.c.

1066{
1067 PNDIS_MINIPORT_WORK_ITEM MiniportWorkItem;
1069
1070 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
1071
1072 MiniportWorkItem = Adapter->WorkQueueHead;
1073
1075 {
1077
1078 *WorkItemType = NdisWorkItemSend;
1079 *WorkItemContext = Packet;
1080
1081 return NDIS_STATUS_SUCCESS;
1082 }
1083 else if (MiniportWorkItem)
1084 {
1085 /* safe due to adapter lock held */
1086 Adapter->WorkQueueHead = (PNDIS_MINIPORT_WORK_ITEM)MiniportWorkItem->Link.Next;
1087
1088 if (MiniportWorkItem == Adapter->WorkQueueTail)
1089 Adapter->WorkQueueTail = NULL;
1090
1091 *WorkItemType = MiniportWorkItem->WorkItemType;
1092 *WorkItemContext = MiniportWorkItem->WorkItemContext;
1093
1094 ExFreePool(MiniportWorkItem);
1095
1096 return NDIS_STATUS_SUCCESS;
1097 }
1098 else
1099 {
1100 NDIS_DbgPrint(MIN_TRACE, ("No work item to dequeue\n"));
1101
1102 return NDIS_STATUS_FAILURE;
1103 }
1104}
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
if(dx< 0)
Definition: linetemp.h:194
@ NdisWorkItemSend
Definition: ndis.h:2295
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
struct _NDIS_MINIPORT_WORK_ITEM * PNDIS_MINIPORT_WORK_ITEM
PNDIS_MINIPORT_WORK_ITEM WorkQueueTail
Definition: miniport.h:91
PNDIS_MINIPORT_WORK_ITEM WorkQueueHead
Definition: miniport.h:90
PNDIS_PACKET FirstPendingPacket
Definition: ndis.h:2526
NDIS_WORK_ITEM_TYPE WorkItemType
Definition: ndis.h:2310
SINGLE_LIST_ENTRY Link
Definition: ndis.h:2309
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629

Referenced by MiniportWorker().

◆ MiniDoAddressingReset()

VOID MiniDoAddressingReset ( PLOGICAL_ADAPTER  Adapter)

Definition at line 888 of file miniport.c.

889{
891
892 MiniSetInformation(Adapter,
894 sizeof(ULONG),
896 &BytesRead);
897
898 /* FIXME: Set more stuff */
899}
NDIS_STATUS MiniSetInformation(PLOGICAL_ADAPTER Adapter, NDIS_OID Oid, ULONG Size, PVOID Buffer, PULONG BytesRead)
Definition: miniport.c:756
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:247
UINT CurrentLookahead
Definition: ndis.h:2569
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870

Referenced by MiniReset(), and MiniResetComplete().

◆ MiniDoRequest()

NDIS_STATUS MiniDoRequest ( PLOGICAL_ADAPTER  Adapter,
PNDIS_REQUEST  NdisRequest 
)

Definition at line 1107 of file miniport.c.

1118{
1120 KIRQL OldIrql;
1121 NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
1122
1124
1128
1129 if (!Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CoRequestHandler)
1130 {
1131 switch (NdisRequest->RequestType)
1132 {
1134 Status = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
1136 NdisRequest->DATA.QUERY_INFORMATION.Oid,
1137 NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer,
1138 NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength,
1139 (PULONG)&NdisRequest->DATA.QUERY_INFORMATION.BytesWritten,
1140 (PULONG)&NdisRequest->DATA.QUERY_INFORMATION.BytesNeeded);
1141 break;
1142
1144 Status = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SetInformationHandler)(
1146 NdisRequest->DATA.SET_INFORMATION.Oid,
1147 NdisRequest->DATA.SET_INFORMATION.InformationBuffer,
1148 NdisRequest->DATA.SET_INFORMATION.InformationBufferLength,
1149 (PULONG)&NdisRequest->DATA.SET_INFORMATION.BytesRead,
1150 (PULONG)&NdisRequest->DATA.SET_INFORMATION.BytesNeeded);
1151 break;
1152
1153 default:
1154 NDIS_DbgPrint(MIN_TRACE, ("Bad request type\n"));
1156 }
1157 }
1158 else
1159 {
1160 Status = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CoRequestHandler)(
1162 NULL, /* FIXME */
1163 NdisRequest);
1164 }
1165
1166 if (Status != NDIS_STATUS_PENDING) {
1170 }
1171
1173
1174 if (Status != NDIS_STATUS_PENDING) {
1176 }
1177
1178 return Status;
1179}
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
Status
Definition: gdiplustypes.h:25
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
@ NdisWorkItemRequest
Definition: ndis.h:2294
_In_opt_ NDIS_HANDLE _In_opt_ NDIS_HANDLE _Inout_ PNDIS_REQUEST NdisRequest
Definition: ndis.h:1573
@ NdisRequestQueryInformation
Definition: ndis.h:790
@ NdisRequestSetInformation
Definition: ndis.h:791
VOID MiniWorkItemComplete(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE WorkItemType)
Definition: miniport.c:964
int NDIS_STATUS
Definition: ntddndis.h:475
#define KeAcquireSpinLockAtDpcLevel(SpinLock)
Definition: ke.h:125
#define KeReleaseSpinLockFromDpcLevel(SpinLock)
Definition: ke.h:135
PNDIS_REQUEST PendingRequest
Definition: ndis.h:2566
KSPIN_LOCK Lock
Definition: ndis.h:2520
NDIS_HANDLE MiniportAdapterContext
Definition: ndis.h:2510
PNDIS_M_DRIVER_BLOCK DriverHandle
Definition: ndis.h:2509
NDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics
Definition: miniport.h:22
uint32_t * PULONG
Definition: typedefs.h:59
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

Referenced by MiniportWorker(), MiniQueryInformation(), MiniSetInformation(), and ProRequest().

◆ MiniIndicateData()

VOID MiniIndicateData ( PLOGICAL_ADAPTER  Adapter,
NDIS_HANDLE  MacReceiveContext,
PVOID  HeaderBuffer,
UINT  HeaderBufferSize,
PVOID  LookaheadBuffer,
UINT  LookaheadBufferSize,
UINT  PacketSize 
)

Definition at line 175 of file miniport.c.

194{
196 PLIST_ENTRY CurrentEntry;
197 PADAPTER_BINDING AdapterBinding;
198
199 NDIS_DbgPrint(DEBUG_MINIPORT, ("Called. Adapter (0x%X) HeaderBuffer (0x%X) "
200 "HeaderBufferSize (0x%X) LookaheadBuffer (0x%X) LookaheadBufferSize (0x%X).\n",
201 Adapter, HeaderBuffer, HeaderBufferSize, LookaheadBuffer, LookaheadBufferSize));
202
203#if DBG
204 MiniDisplayPacket2(HeaderBuffer, HeaderBufferSize, LookaheadBuffer, LookaheadBufferSize);
205#endif
206
207 NDIS_DbgPrint(MAX_TRACE, ("acquiring miniport block lock\n"));
209 {
210 CurrentEntry = Adapter->ProtocolListHead.Flink;
211 NDIS_DbgPrint(DEBUG_MINIPORT, ("CurrentEntry = %x\n", CurrentEntry));
212
213 if (CurrentEntry == &Adapter->ProtocolListHead)
214 {
215 NDIS_DbgPrint(MIN_TRACE, ("WARNING: No upper protocol layer.\n"));
216 }
217
218 while (CurrentEntry != &Adapter->ProtocolListHead)
219 {
220 AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
221 NDIS_DbgPrint(DEBUG_MINIPORT, ("AdapterBinding = %x\n", AdapterBinding));
222
224 (MID_TRACE,
225 ("XXX (%x) %x %x %x %x %x %x %x XXX\n",
226 *AdapterBinding->ProtocolBinding->Chars.ReceiveHandler,
227 AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
228 MacReceiveContext,
229 HeaderBuffer,
230 HeaderBufferSize,
231 LookaheadBuffer,
232 LookaheadBufferSize,
233 PacketSize));
234
235 /* call the receive handler */
236 (*AdapterBinding->ProtocolBinding->Chars.ReceiveHandler)(
237 AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
238 MacReceiveContext,
239 HeaderBuffer,
240 HeaderBufferSize,
241 LookaheadBuffer,
242 LookaheadBufferSize,
243 PacketSize);
244
245 CurrentEntry = CurrentEntry->Flink;
246 }
247 }
249
250 NDIS_DbgPrint(MAX_TRACE, ("Leaving.\n"));
251}
#define MID_TRACE
Definition: debug.h:15
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
NDIS_OPEN_BLOCK NdisOpenBlock
Definition: protocol.h:22
PPROTOCOL_BINDING ProtocolBinding
Definition: protocol.h:28
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY ProtocolListHead
Definition: miniport.h:94
RECEIVE_HANDLER ReceiveHandler
Definition: ndis.h:1889
NDIS_PROTOCOL_CHARACTERISTICS Chars
Definition: protocol.h:13
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_In_ USHORT PacketSize
Definition: iofuncs.h:1058

Referenced by EthFilterDprIndicateReceive(), and ProIndicatePacket().

◆ MiniIsBusy()

BOOLEAN MiniIsBusy ( PLOGICAL_ADAPTER  Adapter,
NDIS_WORK_ITEM_TYPE  Type 
)

Definition at line 142 of file miniport.c.

145{
146 BOOLEAN Busy = FALSE;
148
150
151 if (MiniGetFirstWorkItem(Adapter, Type))
152 {
153 Busy = TRUE;
154 }
156 {
157 Busy = TRUE;
158 }
160 {
161 Busy = TRUE;
162 }
163 else if (Type == NdisWorkItemResetRequested &&
165 {
166 Busy = TRUE;
167 }
168
170
171 return Busy;
172}
unsigned char BOOLEAN
Type
Definition: Type.h:7
#define TRUE
Definition: types.h:120
@ NdisWorkItemResetRequested
Definition: ndis.h:2297
PNDIS_MINIPORT_WORK_ITEM MiniGetFirstWorkItem(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE Type)
Definition: miniport.c:124
NDIS_STATUS ResetStatus
Definition: ndis.h:2541

Referenced by MiniReset(), MiniWorkItemComplete(), ProRequest(), and proSendPacketToMiniport().

◆ MiniLocateDevice()

PLOGICAL_ADAPTER MiniLocateDevice ( PNDIS_STRING  AdapterName)

Definition at line 690 of file miniport.c.

701{
703 PLIST_ENTRY CurrentEntry;
704 PLOGICAL_ADAPTER Adapter = 0;
705
707
708 NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
709
711 {
712 NDIS_DbgPrint(MIN_TRACE, ("No registered miniports for protocol to bind to\n"));
713 return NULL;
714 }
715
716 NDIS_DbgPrint(DEBUG_MINIPORT, ("AdapterName = %wZ\n", AdapterName));
717
719 {
720 CurrentEntry = AdapterListHead.Flink;
721
722 while (CurrentEntry != &AdapterListHead)
723 {
724 Adapter = CONTAINING_RECORD(CurrentEntry, LOGICAL_ADAPTER, ListEntry);
725
726 ASSERT(Adapter);
727
728 NDIS_DbgPrint(DEBUG_MINIPORT, ("Examining adapter 0x%lx\n", Adapter));
729
730 /* We're technically not allowed to call this above PASSIVE_LEVEL, but it doesn't break
731 * right now and I'd rather use a working API than reimplement it here */
733 {
734 break;
735 }
736
737 Adapter = NULL;
738 CurrentEntry = CurrentEntry->Flink;
739 }
740 }
742
743 if(Adapter)
744 {
745 NDIS_DbgPrint(DEBUG_MINIPORT, ("Leaving. Adapter found at 0x%x\n", Adapter));
746 }
747 else
748 {
749 NDIS_DbgPrint(MIN_TRACE, ("Leaving (adapter not found for %wZ).\n", AdapterName));
750 }
751
752 return Adapter;
753}
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
#define ASSERT(a)
Definition: mode.c:44
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE _In_ PNDIS_STRING AdapterName
Definition: ndis.h:6016
LIST_ENTRY AdapterListHead
Definition: miniport.c:57
KSPIN_LOCK AdapterListLock
Definition: miniport.c:58
UNICODE_STRING MiniportName
Definition: ndis.h:2511

Referenced by ndisBindMiniportsToProtocol(), and NdisOpenAdapter().

◆ MiniportWorker()

VOID NTAPI MiniportWorker ( IN PDEVICE_OBJECT  DeviceObject,
IN PVOID  WorkItem 
)

Definition at line 1223 of file miniport.c.

1224{
1225 PLOGICAL_ADAPTER Adapter = DeviceObject->DeviceExtension;
1226 KIRQL OldIrql, RaiseOldIrql;
1227 NDIS_STATUS NdisStatus;
1228 PVOID WorkItemContext;
1229 NDIS_WORK_ITEM_TYPE WorkItemType;
1230 BOOLEAN AddressingReset;
1231
1233
1235
1236 NdisStatus =
1238 (Adapter, &WorkItemType, &WorkItemContext);
1239
1241
1242 if (NdisStatus == NDIS_STATUS_SUCCESS)
1243 {
1244 switch (WorkItemType)
1245 {
1246 case NdisWorkItemSend:
1247 /*
1248 * called by ProSend when protocols want to send packets to the miniport
1249 */
1250
1251 if(Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendPacketsHandler)
1252 {
1254 {
1255 NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's SendPackets handler\n"));
1256 (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendPacketsHandler)(
1257 Adapter->NdisMiniportBlock.MiniportAdapterContext, (PPNDIS_PACKET)&WorkItemContext, 1);
1258 NdisStatus = NDIS_STATUS_PENDING;
1259 }
1260 else
1261 {
1262 /* SendPackets is called at DISPATCH_LEVEL for all serialized miniports */
1263 KeRaiseIrql(DISPATCH_LEVEL, &RaiseOldIrql);
1264 {
1265 NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's SendPackets handler\n"));
1266 (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendPacketsHandler)(
1267 Adapter->NdisMiniportBlock.MiniportAdapterContext, (PPNDIS_PACKET)&WorkItemContext, 1);
1268 }
1269 KeLowerIrql(RaiseOldIrql);
1270
1271 NdisStatus = NDIS_GET_PACKET_STATUS((PNDIS_PACKET)WorkItemContext);
1272 if( NdisStatus == NDIS_STATUS_RESOURCES ) {
1273 MiniQueueWorkItem(Adapter, WorkItemType, WorkItemContext, TRUE);
1274 break;
1275 }
1276 }
1277 }
1278 else
1279 {
1281 {
1282 NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's Send handler\n"));
1283 NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendHandler)(
1284 Adapter->NdisMiniportBlock.MiniportAdapterContext, (PNDIS_PACKET)WorkItemContext,
1285 ((PNDIS_PACKET)WorkItemContext)->Private.Flags);
1286 NDIS_DbgPrint(MAX_TRACE, ("back from miniport's send handler\n"));
1287 }
1288 else
1289 {
1290 /* Send is called at DISPATCH_LEVEL for all serialized miniports */
1291 KeRaiseIrql(DISPATCH_LEVEL, &RaiseOldIrql);
1292 NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's Send handler\n"));
1293 NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendHandler)(
1294 Adapter->NdisMiniportBlock.MiniportAdapterContext, (PNDIS_PACKET)WorkItemContext,
1295 ((PNDIS_PACKET)WorkItemContext)->Private.Flags);
1296 NDIS_DbgPrint(MAX_TRACE, ("back from miniport's send handler\n"));
1297 KeLowerIrql(RaiseOldIrql);
1298 if( NdisStatus == NDIS_STATUS_RESOURCES ) {
1299 MiniQueueWorkItem(Adapter, WorkItemType, WorkItemContext, TRUE);
1300 break;
1301 }
1302 }
1303 }
1304
1305 if( NdisStatus != NDIS_STATUS_PENDING ) {
1307 ( Adapter, (PNDIS_PACKET)WorkItemContext, NdisStatus );
1308 }
1309 break;
1310
1312 /*
1313 * called by ProSend when protocols want to send loopback packets
1314 */
1315 /* XXX atm ProIndicatePacket sends a packet up via the loopback adapter only */
1316 NdisStatus = ProIndicatePacket(Adapter, (PNDIS_PACKET)WorkItemContext);
1317
1318 if( NdisStatus != NDIS_STATUS_PENDING )
1319 MiniSendComplete((NDIS_HANDLE)Adapter, (PNDIS_PACKET)WorkItemContext, NdisStatus);
1320 break;
1321
1323 break;
1324
1328
1330 NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)(
1331 &AddressingReset,
1332 Adapter->NdisMiniportBlock.MiniportAdapterContext);
1333
1334 KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
1335 Adapter->NdisMiniportBlock.ResetStatus = NdisStatus;
1336 KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
1337
1339
1340 if (NdisStatus != NDIS_STATUS_PENDING)
1341 MiniResetComplete(Adapter, NdisStatus, AddressingReset);
1342 break;
1343
1345 break;
1346
1348 break;
1349
1351 NdisStatus = MiniDoRequest(Adapter, (PNDIS_REQUEST)WorkItemContext);
1352
1353 if (NdisStatus == NDIS_STATUS_PENDING)
1354 break;
1355
1356 Adapter->NdisMiniportBlock.PendingRequest = (PNDIS_REQUEST)WorkItemContext;
1357 switch (((PNDIS_REQUEST)WorkItemContext)->RequestType)
1358 {
1360 NdisMQueryInformationComplete((NDIS_HANDLE)Adapter, NdisStatus);
1361 break;
1362
1364 NdisMSetInformationComplete((NDIS_HANDLE)Adapter, NdisStatus);
1365 break;
1366
1367 default:
1368 NDIS_DbgPrint(MIN_TRACE, ("Unknown NDIS request type.\n"));
1369 break;
1370 }
1371 Adapter->NdisMiniportBlock.PendingRequest = NULL;
1372 break;
1373
1374 default:
1375 NDIS_DbgPrint(MIN_TRACE, ("Unknown NDIS work item type (%d).\n", WorkItemType));
1376 break;
1377 }
1378 }
1379}
NDIS_STATUS ProIndicatePacket(PLOGICAL_ADAPTER Adapter, PNDIS_PACKET Packet)
Definition: protocol.c:243
VOID NTAPI IoFreeWorkItem(IN PIO_WORKITEM IoWorkItem)
Definition: iowork.c:64
struct _NDIS_PACKET * PNDIS_PACKET
#define NdisMSetInformationComplete(MiniportAdapterHandle, Status)
Definition: ndis.h:5762
#define NdisMIndicateStatusComplete(MiniportAdapterHandle)
Definition: ndis.h:5580
#define NdisMQueryInformationComplete(MiniportAdapterHandle, Status)
Definition: ndis.h:5618
#define NDIS_STATUS_RESET_START
Definition: ndis.h:354
@ NdisWorkItemSendLoopback
Definition: ndis.h:2300
@ NdisWorkItemReturnPackets
Definition: ndis.h:2296
@ NdisWorkItemResetInProgress
Definition: ndis.h:2298
@ NdisWorkItemMiniportCallback
Definition: ndis.h:2301
#define NDIS_ATTRIBUTE_DESERIALIZE
Definition: ndis.h:588
#define NDIS_GET_PACKET_STATUS(_Packet)
Definition: ndis.h:3436
enum _NDIS_WORK_ITEM_TYPE NDIS_WORK_ITEM_TYPE
struct _NDIS_REQUEST * PNDIS_REQUEST
#define NdisMIndicateStatus(MiniportAdapterHandle, GeneralStatus, StatusBuffer, StatusBufferSize)
Definition: ndis.h:5570
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
VOID NTAPI MiniSendComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status)
Definition: miniport.c:530
NDIS_STATUS FASTCALL MiniDequeueWorkItem(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE *WorkItemType, PVOID *WorkItemContext)
Definition: miniport.c:1050
NDIS_STATUS MiniDoRequest(PLOGICAL_ADAPTER Adapter, PNDIS_REQUEST NdisRequest)
Definition: miniport.c:1107
VOID NTAPI MiniResetComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status, IN BOOLEAN AddressingReset)
Definition: miniport.c:435
VOID FASTCALL MiniQueueWorkItem(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE WorkItemType, PVOID WorkItemContext, BOOLEAN Top)
Definition: miniport.c:982
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055

Referenced by MiniWorkItemComplete().

◆ MiniQueryInformation()

NDIS_STATUS MiniQueryInformation ( PLOGICAL_ADAPTER  Adapter,
NDIS_OID  Oid,
ULONG  Size,
PVOID  Buffer,
PULONG  BytesWritten 
)

Definition at line 805 of file miniport.c.

822{
823 NDIS_STATUS NdisStatus;
827
828 NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
829
831 if (!NdisRequest) {
832 NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
834 }
835
837
839 NdisRequest->DATA.QUERY_INFORMATION.Oid = Oid;
840 NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer = Buffer;
841 NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength = Size;
842
843 /* We'll need to give the completion routine some way of letting us know
844 * when it's finished. We'll stash a pointer to an event in the MacBlock */
846 MacBlock = (PNDIS_REQUEST_MAC_BLOCK)NdisRequest->MacReserved;
847 MacBlock->Unknown1 = &Event;
848
849 NdisStatus = MiniDoRequest(Adapter, NdisRequest);
850
851 if (NdisStatus == NDIS_STATUS_PENDING)
852 {
854 NdisStatus = PtrToUlong(MacBlock->Unknown3);
855 }
856
857 *BytesWritten = NdisRequest->DATA.QUERY_INFORMATION.BytesWritten;
858
860
861 return NdisStatus;
862}
Definition: bufpool.h:45
struct _NDIS_REQUEST_MAC_BLOCK * PNDIS_REQUEST_MAC_BLOCK
#define PtrToUlong(u)
Definition: config.h:107
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define NonPagedPool
Definition: env_spec_w32.h:307
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define KernelMode
Definition: asm.h:34
@ NotificationEvent
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960
@ Executive
Definition: ketypes.h:415

Referenced by DoQueries(), NdisIDeviceIoControl(), and NdisIPnPStartDevice().

◆ MiniQueueWorkItem()

VOID FASTCALL MiniQueueWorkItem ( PLOGICAL_ADAPTER  Adapter,
NDIS_WORK_ITEM_TYPE  WorkItemType,
PVOID  WorkItemContext,
BOOLEAN  Top 
)

Definition at line 982 of file miniport.c.

996{
997 PNDIS_MINIPORT_WORK_ITEM MiniportWorkItem;
999
1000 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
1001
1002 ASSERT(Adapter);
1003
1005 if (Top)
1006 {
1007 if (WorkItemType == NdisWorkItemSend)
1008 {
1009 NDIS_DbgPrint(MIN_TRACE, ("Requeuing failed packet (%x).\n", WorkItemContext));
1010 Adapter->NdisMiniportBlock.FirstPendingPacket = WorkItemContext;
1011 }
1012 else
1013 {
1014 //This should never happen
1015 ASSERT(FALSE);
1016 }
1017 }
1018 else
1019 {
1020 MiniportWorkItem = ExAllocatePool(NonPagedPool, sizeof(NDIS_MINIPORT_WORK_ITEM));
1021 if (!MiniportWorkItem)
1022 {
1024 NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1025 return;
1026 }
1027
1028 MiniportWorkItem->WorkItemType = WorkItemType;
1029 MiniportWorkItem->WorkItemContext = WorkItemContext;
1030
1031 /* safe due to adapter lock held */
1032 MiniportWorkItem->Link.Next = NULL;
1033 if (!Adapter->WorkQueueHead)
1034 {
1035 Adapter->WorkQueueHead = MiniportWorkItem;
1036 Adapter->WorkQueueTail = MiniportWorkItem;
1037 }
1038 else
1039 {
1040 Adapter->WorkQueueTail->Link.Next = (PSINGLE_LIST_ENTRY)MiniportWorkItem;
1041 Adapter->WorkQueueTail = MiniportWorkItem;
1042 }
1043 }
1044
1046}
static LPHIST_ENTRY Top
Definition: history.c:53
struct _SINGLE_LIST_ENTRY * PSINGLE_LIST_ENTRY

Referenced by MiniportWorker(), MiniReset(), ProRequest(), ProSend(), and proSendPacketToMiniport().

◆ MiniReset()

NDIS_STATUS MiniReset ( PLOGICAL_ADAPTER  Adapter)

Definition at line 902 of file miniport.c.

911{
914 BOOLEAN AddressingReset = TRUE;
915
918 return NDIS_STATUS_PENDING;
919 }
920
923
926 &AddressingReset,
928
932
934
936 if (AddressingReset)
937 MiniDoAddressingReset(Adapter);
938
941
943 }
944
945 return Status;
946}
#define NDIS_STATUS_RESET_END
Definition: ndis.h:355
BOOLEAN MiniIsBusy(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE Type)
Definition: miniport.c:142
VOID MiniDoAddressingReset(PLOGICAL_ADAPTER Adapter)
Definition: miniport.c:888

Referenced by MiniportHangDpc(), and ProReset().

◆ MiniSendComplete()

VOID NTAPI MiniSendComplete ( IN NDIS_HANDLE  MiniportAdapterHandle,
IN PNDIS_PACKET  Packet,
IN NDIS_STATUS  Status 
)

Definition at line 530 of file miniport.c.

542{
544 PADAPTER_BINDING AdapterBinding;
547
548 NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
549
550 AdapterBinding = (PADAPTER_BINDING)Packet->Reserved[1];
551
553
554 if (Adapter->NdisMiniportBlock.ScatterGatherListSize != 0)
555 {
556 NDIS_DbgPrint(MAX_TRACE, ("Freeing Scatter/Gather list\n"));
557
560
561 Adapter->NdisMiniportBlock.SystemAdapterObject->
562 DmaOperations->PutScatterGatherList(
563 Adapter->NdisMiniportBlock.SystemAdapterObject,
564 SGList,
565 TRUE);
566
569 }
570
571 (*AdapterBinding->ProtocolBinding->Chars.SendCompleteHandler)(
572 AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
573 Packet,
574 Status);
575
577
579}
struct _ADAPTER_BINDING * PADAPTER_BINDING
#define NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, InfoType)
Definition: ndis.h:1351
@ ScatterGatherListPacketInfo
Definition: ndis.h:1183
_In_ NDIS_HANDLE MiniportAdapterHandle
Definition: ndis.h:4668
SEND_COMPLETE_HANDLER SendCompleteHandler
Definition: ndis.h:1879
struct _SCATTER_GATHER_LIST * PSCATTER_GATHER_LIST
Definition: iotypes.h:2204

Referenced by MiniportWorker(), NdisIPnPStartDevice(), NdisMSendComplete(), ProSendPackets(), and ScatterGatherSendPacket().

◆ MiniWorkItemComplete()

VOID MiniWorkItemComplete ( PLOGICAL_ADAPTER  Adapter,
NDIS_WORK_ITEM_TYPE  WorkItemType 
)

Definition at line 964 of file miniport.c.

967{
969
970 /* Check if there's anything queued to run after this work item */
971 if (!MiniIsBusy(Adapter, WorkItemType))
972 return;
973
974 /* There is, so fire the worker */
976 if (IoWorkItem)
978}
VOID NTAPI IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem, IN PIO_WORKITEM_ROUTINE WorkerRoutine, IN WORK_QUEUE_TYPE QueueType, IN PVOID Context)
Definition: iowork.c:40
PIO_WORKITEM NTAPI IoAllocateWorkItem(IN PDEVICE_OBJECT DeviceObject)
Definition: iowork.c:75
VOID NTAPI MiniportWorker(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context)
Definition: miniport.c:1223
PDEVICE_OBJECT DeviceObject
Definition: ndis.h:2552
@ DelayedWorkQueue
Definition: extypes.h:190
_In_opt_ PVOID _In_ PIO_WORKITEM IoWorkItem
Definition: iotypes.h:521

Referenced by MiniDoRequest(), MiniRequestComplete(), MiniReset(), MiniSendComplete(), MiniSendResourcesAvailable(), and proSendPacketToMiniport().

◆ NdisFindDevice()

BOOLEAN NdisFindDevice ( UINT  VendorID,
UINT  DeviceID,
PUINT  BusNumber,
PUINT  SlotNumber 
)

◆ NdisStartDevices()

VOID NdisStartDevices ( VOID  )

Variable Documentation

◆ AdapterListHead

◆ AdapterListLock

◆ MiniportListHead

LIST_ENTRY MiniportListHead
extern

Definition at line 53 of file miniport.c.

Referenced by DriverEntry(), and NdisInitializeWrapper().

◆ MiniportListLock

KSPIN_LOCK MiniportListLock
extern

Definition at line 54 of file miniport.c.

Referenced by DriverEntry(), NdisInitializeWrapper(), and NdisTerminateWrapper().