ReactOS  0.4.14-dev-583-g2a1ba2c
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 }
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
MDL * PNDIS_BUFFER
Definition: ndis.h:343
unsigned char * PUCHAR
Definition: retypes.h:3
#define DEBUG_MINIPORT
Definition: debug.h:17
HARDWARE_ADDRESS Address
Definition: miniport.h:96
_In_ ULONG BufferLength
Definition: usbdlib.h:225
smooth NULL
Definition: ftsmooth.c:416
NDIS_MEDIUM MediaType
Definition: ndis.h:2548
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define MAX_TRACE
Definition: debug.h:16
#define ETH_LENGTH_OF_ADDRESS
Definition: efilter.h:16
unsigned int UINT
Definition: ndis.h:50
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
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
VOID EXPORT NdisQueryBuffer(IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, OUT PUINT Length)
Definition: buffer.c:953
#define MIN_TRACE
Definition: debug.h:14
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465

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 
1074  if ((Packet = Adapter->NdisMiniportBlock.FirstPendingPacket))
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 }
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
PNDIS_MINIPORT_WORK_ITEM WorkQueueHead
Definition: miniport.h:90
NDIS_WORK_ITEM_TYPE WorkItemType
Definition: ndis.h:2310
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
PNDIS_PACKET FirstPendingPacket
Definition: ndis.h:2526
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:636
struct _NDIS_MINIPORT_WORK_ITEM * PNDIS_MINIPORT_WORK_ITEM
#define MAX_TRACE
Definition: debug.h:16
PNDIS_MINIPORT_WORK_ITEM WorkQueueTail
Definition: miniport.h:91
SINGLE_LIST_ENTRY Link
Definition: ndis.h:2309
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define MIN_TRACE
Definition: debug.h:14
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

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
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
UINT CurrentLookahead
Definition: ndis.h:2569
unsigned int ULONG
Definition: retypes.h:1
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:247
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255

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 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
_In_opt_ NDIS_HANDLE _In_opt_ NDIS_HANDLE _Inout_ PNDIS_REQUEST NdisRequest
Definition: ndis.h:1571
VOID MiniWorkItemComplete(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE WorkItemType)
Definition: miniport.c:964
NDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics
Definition: miniport.h:22
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
#define DEBUG_MINIPORT
Definition: debug.h:17
int NDIS_STATUS
Definition: ntddndis.h:471
UCHAR KIRQL
Definition: env_spec_w32.h:591
NDIS_HANDLE MiniportAdapterContext
Definition: ndis.h:2510
smooth NULL
Definition: ftsmooth.c:416
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:215
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Status
Definition: gdiplustypes.h:24
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
PNDIS_REQUEST PendingRequest
Definition: ndis.h:2566
KSPIN_LOCK Lock
Definition: ndis.h:2520
unsigned int * PULONG
Definition: retypes.h:1
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define MIN_TRACE
Definition: debug.h:14
PNDIS_M_DRIVER_BLOCK DriverHandle
Definition: ndis.h:2509
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465

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 {
195  KIRQL OldIrql;
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
NDIS_OPEN_BLOCK NdisOpenBlock
Definition: protocol.h:22
#define DEBUG_MINIPORT
Definition: debug.h:17
UCHAR KIRQL
Definition: env_spec_w32.h:591
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
PPROTOCOL_BINDING ProtocolBinding
Definition: protocol.h:28
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
LIST_ENTRY ProtocolListHead
Definition: miniport.h:94
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
RECEIVE_HANDLER ReceiveHandler
Definition: ndis.h:1889
Definition: typedefs.h:117
#define MAX_TRACE
Definition: debug.h:16
_In_ USHORT PacketSize
Definition: iofuncs.h:1056
KSPIN_LOCK Lock
Definition: ndis.h:2520
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define MIN_TRACE
Definition: debug.h:14
NDIS_PROTOCOL_CHARACTERISTICS Chars
Definition: protocol.h:13

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;
147  KIRQL OldIrql;
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 }
#define TRUE
Definition: types.h:120
Type
Definition: Type.h:6
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
NDIS_STATUS ResetStatus
Definition: ndis.h:2541
PNDIS_MINIPORT_WORK_ITEM MiniGetFirstWorkItem(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE Type)
Definition: miniport.c:124
UCHAR KIRQL
Definition: env_spec_w32.h:591
unsigned char BOOLEAN
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
PNDIS_PACKET FirstPendingPacket
Definition: ndis.h:2526
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
PNDIS_REQUEST PendingRequest
Definition: ndis.h:2566
KSPIN_LOCK Lock
Definition: ndis.h:2520
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627

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

◆ MiniLocateDevice()

PLOGICAL_ADAPTER MiniLocateDevice ( PNDIS_STRING  AdapterName)

Definition at line 690 of file miniport.c.

701 {
702  KIRQL OldIrql;
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 TRUE
Definition: types.h:120
#define DEBUG_MINIPORT
Definition: debug.h:17
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
UCHAR KIRQL
Definition: env_spec_w32.h:591
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
UNICODE_STRING MiniportName
Definition: ndis.h:2511
Definition: typedefs.h:117
KSPIN_LOCK AdapterListLock
Definition: miniport.c:58
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
LIST_ENTRY AdapterListHead
Definition: miniport.c:57
#define MIN_TRACE
Definition: debug.h:14
_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:6013

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 {
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 
1327  NdisMIndicateStatusComplete(Adapter);
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 
1350  case NdisWorkItemRequest:
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 }
VOID EXPORT NdisMSetInformationComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status)
Definition: miniport.c:1187
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
NDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics
Definition: miniport.h:22
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define NDIS_ATTRIBUTE_DESERIALIZE
Definition: ndis.h:588
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
#define NDIS_STATUS_RESET_START
Definition: ndis.h:354
struct _NDIS_REQUEST * PNDIS_REQUEST
VOID NTAPI IoFreeWorkItem(IN PIO_WORKITEM IoWorkItem)
Definition: iowork.c:64
int NDIS_STATUS
Definition: ntddndis.h:471
enum _NDIS_WORK_ITEM_TYPE NDIS_WORK_ITEM_TYPE
UCHAR KIRQL
Definition: env_spec_w32.h:591
NDIS_STATUS FASTCALL MiniDequeueWorkItem(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE *WorkItemType, PVOID *WorkItemContext)
Definition: miniport.c:1050
VOID NTAPI MiniResetComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status, IN BOOLEAN AddressingReset)
Definition: miniport.c:435
NDIS_HANDLE MiniportAdapterContext
Definition: ndis.h:2510
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
VOID EXPORT NdisMIndicateStatusComplete(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:1580
#define NDIS_GET_PACKET_STATUS(_Packet)
Definition: ndis.h:3436
NDIS_STATUS MiniDoRequest(PLOGICAL_ADAPTER Adapter, PNDIS_REQUEST NdisRequest)
Definition: miniport.c:1107
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:215
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
VOID NTAPI MiniSendComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status)
Definition: miniport.c:530
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define MAX_TRACE
Definition: debug.h:16
KSPIN_LOCK Lock
Definition: ndis.h:2520
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
struct _NDIS_PACKET * PNDIS_PACKET
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
#define MIN_TRACE
Definition: debug.h:14
VOID FASTCALL MiniQueueWorkItem(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE WorkItemType, PVOID WorkItemContext, BOOLEAN Top)
Definition: miniport.c:982
PNDIS_M_DRIVER_BLOCK DriverHandle
Definition: ndis.h:2509
VOID EXPORT NdisMIndicateStatus(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS GeneralStatus, IN PVOID StatusBuffer, IN UINT StatusBufferSize)
Definition: miniport.c:1565
VOID EXPORT NdisMQueryInformationComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status)
Definition: miniport.c:1207
NDIS_STATUS ProIndicatePacket(PLOGICAL_ADAPTER Adapter, PNDIS_PACKET Packet)
Definition: protocol.c:243

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;
825  KEVENT Event;
826  PNDIS_REQUEST_MAC_BLOCK MacBlock;
827 
828  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
829 
831  if (!NdisRequest) {
832  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
833  return NDIS_STATUS_RESOURCES;
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 }
_In_opt_ NDIS_HANDLE _In_opt_ NDIS_HANDLE _Inout_ PNDIS_REQUEST NdisRequest
Definition: ndis.h:1571
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
#define DEBUG_MINIPORT
Definition: debug.h:17
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
int NDIS_STATUS
Definition: ntddndis.h:471
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
#define PtrToUlong(u)
Definition: config.h:107
NDIS_STATUS MiniDoRequest(PLOGICAL_ADAPTER Adapter, PNDIS_REQUEST NdisRequest)
Definition: miniport.c:1107
struct _NDIS_REQUEST_MAC_BLOCK * PNDIS_REQUEST_MAC_BLOCK
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define MIN_TRACE
Definition: debug.h:14
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

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;
998  KIRQL OldIrql;
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 }
PNDIS_MINIPORT_WORK_ITEM WorkQueueHead
Definition: miniport.h:90
UCHAR KIRQL
Definition: env_spec_w32.h:591
NDIS_WORK_ITEM_TYPE WorkItemType
Definition: ndis.h:2310
smooth NULL
Definition: ftsmooth.c:416
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
PNDIS_PACKET FirstPendingPacket
Definition: ndis.h:2526
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:636
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
struct _SINGLE_LIST_ENTRY * PSINGLE_LIST_ENTRY
#define MAX_TRACE
Definition: debug.h:16
PNDIS_MINIPORT_WORK_ITEM WorkQueueTail
Definition: miniport.h:91
KSPIN_LOCK Lock
Definition: ndis.h:2520
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
SINGLE_LIST_ENTRY Link
Definition: ndis.h:2309
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define MIN_TRACE
Definition: debug.h:14
static LPHIST_ENTRY Top
Definition: history.c:53

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

◆ MiniReset()

NDIS_STATUS MiniReset ( PLOGICAL_ADAPTER  Adapter)

Definition at line 902 of file miniport.c.

911 {
913  KIRQL OldIrql;
914  BOOLEAN AddressingReset = TRUE;
915 
916  if (MiniIsBusy(Adapter, NdisWorkItemResetRequested)) {
918  return NDIS_STATUS_PENDING;
919  }
920 
923 
925  Status = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)(
926  &AddressingReset,
928 
932 
934 
935  if (Status != NDIS_STATUS_PENDING) {
936  if (AddressingReset)
937  MiniDoAddressingReset(Adapter);
938 
941 
943  }
944 
945  return Status;
946 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
VOID MiniWorkItemComplete(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE WorkItemType)
Definition: miniport.c:964
NDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics
Definition: miniport.h:22
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
NDIS_STATUS ResetStatus
Definition: ndis.h:2541
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
VOID MiniDoAddressingReset(PLOGICAL_ADAPTER Adapter)
Definition: miniport.c:888
#define NDIS_STATUS_RESET_START
Definition: ndis.h:354
int NDIS_STATUS
Definition: ntddndis.h:471
UCHAR KIRQL
Definition: env_spec_w32.h:591
NDIS_HANDLE MiniportAdapterContext
Definition: ndis.h:2510
unsigned char BOOLEAN
BOOLEAN MiniIsBusy(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE Type)
Definition: miniport.c:142
smooth NULL
Definition: ftsmooth.c:416
VOID EXPORT NdisMIndicateStatusComplete(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:1580
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:215
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Status
Definition: gdiplustypes.h:24
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define NDIS_STATUS_RESET_END
Definition: ndis.h:355
KSPIN_LOCK Lock
Definition: ndis.h:2520
VOID FASTCALL MiniQueueWorkItem(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE WorkItemType, PVOID WorkItemContext, BOOLEAN Top)
Definition: miniport.c:982
PNDIS_M_DRIVER_BLOCK DriverHandle
Definition: ndis.h:2509
VOID EXPORT NdisMIndicateStatus(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS GeneralStatus, IN PVOID StatusBuffer, IN UINT StatusBufferSize)
Definition: miniport.c:1565

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;
545  KIRQL OldIrql;
546  PSCATTER_GATHER_LIST SGList;
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 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
VOID MiniWorkItemComplete(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE WorkItemType)
Definition: miniport.c:964
NDIS_OPEN_BLOCK NdisOpenBlock
Definition: protocol.h:22
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
_In_ NDIS_HANDLE MiniportAdapterHandle
Definition: ndis.h:4668
#define DEBUG_MINIPORT
Definition: debug.h:17
UCHAR KIRQL
Definition: env_spec_w32.h:591
smooth NULL
Definition: ftsmooth.c:416
PPROTOCOL_BINDING ProtocolBinding
Definition: protocol.h:28
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Status
Definition: gdiplustypes.h:24
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
SEND_COMPLETE_HANDLER SendCompleteHandler
Definition: ndis.h:1879
#define MAX_TRACE
Definition: debug.h:16
struct _ADAPTER_BINDING * PADAPTER_BINDING
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
struct _SCATTER_GATHER_LIST * PSCATTER_GATHER_LIST
Definition: iotypes.h:2096
#define NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, InfoType)
Definition: ndis.h:1351
NDIS_PROTOCOL_CHARACTERISTICS Chars
Definition: protocol.h:13

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 }
_In_opt_ PVOID _In_ PIO_WORKITEM IoWorkItem
Definition: iotypes.h:488
PIO_WORKITEM NTAPI IoAllocateWorkItem(IN PDEVICE_OBJECT DeviceObject)
Definition: iowork.c:75
BOOLEAN MiniIsBusy(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE Type)
Definition: miniport.c:142
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
VOID NTAPI IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem, IN PIO_WORKITEM_ROUTINE WorkerRoutine, IN WORK_QUEUE_TYPE QueueType, IN PVOID Context)
Definition: iowork.c:40
PDEVICE_OBJECT DeviceObject
Definition: ndis.h:2552
VOID NTAPI MiniportWorker(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context)
Definition: miniport.c:1223

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

Definition at line 53 of file miniport.c.

Referenced by DriverEntry(), and NdisInitializeWrapper().

◆ MiniportListLock

KSPIN_LOCK MiniportListLock

Definition at line 54 of file miniport.c.

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