ReactOS  0.4.14-dev-52-g6116262
miniport.c File Reference
#include "ndissys.h"
#include <ndisguid.h>
Include dependency graph for miniport.c:

Go to the source code of this file.

Macros

#define BREAK_ON_MINIPORT_INIT   0
 
#define ROUTE_DATA_SIZE   256
 
#define MEDIA_ARRAY_SIZE   15
 

Functions

PNDIS_MINIPORT_WORK_ITEM MiniGetFirstWorkItem (PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE Type)
 
BOOLEAN MiniIsBusy (PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE Type)
 
VOID MiniIndicateData (PLOGICAL_ADAPTER Adapter, NDIS_HANDLE MacReceiveContext, PVOID HeaderBuffer, UINT HeaderBufferSize, PVOID LookaheadBuffer, UINT LookaheadBufferSize, UINT PacketSize)
 
VOID EXPORT NdisReturnPackets (IN PNDIS_PACKET *PacketsToReturn, IN UINT NumberOfPackets)
 
VOID NTAPI MiniIndicateReceivePacket (IN NDIS_HANDLE MiniportAdapterHandle, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets)
 
VOID NTAPI MiniResetComplete (IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status, IN BOOLEAN AddressingReset)
 
VOID NTAPI MiniRequestComplete (IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status)
 
VOID NTAPI MiniSendComplete (IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status)
 
VOID NTAPI MiniSendResourcesAvailable (IN NDIS_HANDLE MiniportAdapterHandle)
 
VOID NTAPI MiniTransferDataComplete (IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status, IN UINT BytesTransferred)
 
BOOLEAN MiniAdapterHasAddress (PLOGICAL_ADAPTER Adapter, PNDIS_PACKET Packet)
 
PLOGICAL_ADAPTER MiniLocateDevice (PNDIS_STRING AdapterName)
 
NDIS_STATUS MiniSetInformation (PLOGICAL_ADAPTER Adapter, NDIS_OID Oid, ULONG Size, PVOID Buffer, PULONG BytesRead)
 
NDIS_STATUS MiniQueryInformation (PLOGICAL_ADAPTER Adapter, NDIS_OID Oid, ULONG Size, PVOID Buffer, PULONG BytesWritten)
 
BOOLEAN MiniCheckForHang (PLOGICAL_ADAPTER Adapter)
 
VOID MiniDoAddressingReset (PLOGICAL_ADAPTER Adapter)
 
NDIS_STATUS MiniReset (PLOGICAL_ADAPTER Adapter)
 
VOID NTAPI MiniportHangDpc (PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
 
VOID MiniWorkItemComplete (PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE WorkItemType)
 
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)
 
VOID EXPORT NdisMSetInformationComplete (IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status)
 
VOID EXPORT NdisMQueryInformationComplete (IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status)
 
VOID NTAPI MiniportWorker (IN PDEVICE_OBJECT DeviceObject, IN PVOID Context)
 
VOID NTAPI MiniStatus (IN NDIS_HANDLE MiniportHandle, IN NDIS_STATUS GeneralStatus, IN PVOID StatusBuffer, IN UINT StatusBufferSize)
 
VOID NTAPI MiniStatusComplete (IN NDIS_HANDLE MiniportAdapterHandle)
 
VOID EXPORT NdisMCloseLog (IN NDIS_HANDLE LogHandle)
 
NDIS_STATUS EXPORT NdisMCreateLog (IN NDIS_HANDLE MiniportAdapterHandle, IN UINT Size, OUT PNDIS_HANDLE LogHandle)
 
VOID EXPORT NdisMDeregisterAdapterShutdownHandler (IN NDIS_HANDLE MiniportHandle)
 
VOID EXPORT NdisMFlushLog (IN NDIS_HANDLE LogHandle)
 
VOID EXPORT NdisMIndicateStatus (IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS GeneralStatus, IN PVOID StatusBuffer, IN UINT StatusBufferSize)
 
VOID EXPORT NdisMIndicateStatusComplete (IN NDIS_HANDLE MiniportAdapterHandle)
 
VOID EXPORT NdisInitializeWrapper (OUT PNDIS_HANDLE NdisWrapperHandle, IN PVOID SystemSpecific1, IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)
 
VOID NTAPI NdisIBugcheckCallback (IN PVOID Buffer, IN ULONG Length)
 
VOID EXPORT NdisMRegisterAdapterShutdownHandler (IN NDIS_HANDLE MiniportHandle, IN PVOID ShutdownContext, IN ADAPTER_SHUTDOWN_HANDLER ShutdownHandler)
 
NDIS_STATUS DoQueries (PLOGICAL_ADAPTER Adapter, NDIS_OID AddressOID)
 
NTSTATUS NTAPI NdisIForwardIrpAndWaitCompletionRoutine (PDEVICE_OBJECT Fdo, PIRP Irp, PVOID Context)
 
NTSTATUS NTAPI NdisIForwardIrpAndWait (PLOGICAL_ADAPTER Adapter, PIRP Irp)
 
NTSTATUS NTAPI NdisICreateClose (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI NdisIPnPStartDevice (IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI NdisIPnPStopDevice (IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI NdisIShutdown (IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI NdisIDeviceIoControl (IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI NdisIDispatchPnp (IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI NdisIPower (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
 
NTSTATUS NTAPI NdisIAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
 
NTSTATUS NTAPI NdisGenericIrpHandler (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NDIS_STATUS EXPORT NdisMRegisterMiniport (IN NDIS_HANDLE NdisWrapperHandle, IN PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics, IN UINT CharacteristicsLength)
 
VOID EXPORT NdisMResetComplete (IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status, IN BOOLEAN AddressingReset)
 
VOID EXPORT NdisMSendComplete (IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status)
 
VOID EXPORT NdisMSendResourcesAvailable (IN NDIS_HANDLE MiniportAdapterHandle)
 
VOID EXPORT NdisMTransferDataComplete (IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status, IN UINT BytesTransferred)
 
VOID EXPORT NdisMSetAttributes (IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE MiniportAdapterContext, IN BOOLEAN BusMaster, IN NDIS_INTERFACE_TYPE AdapterType)
 
VOID EXPORT NdisMSetAttributesEx (IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE MiniportAdapterContext, IN UINT CheckForHangTimeInSeconds OPTIONAL, IN ULONG AttributeFlags, IN NDIS_INTERFACE_TYPE AdapterType)
 
VOID EXPORT NdisMSleep (IN ULONG MicrosecondsToSleep)
 
BOOLEAN EXPORT NdisMSynchronizeWithInterrupt (IN PNDIS_MINIPORT_INTERRUPT Interrupt, IN PVOID SynchronizeFunction, IN PVOID SynchronizeContext)
 
NDIS_STATUS EXPORT NdisMWriteLogData (IN NDIS_HANDLE LogHandle, IN PVOID LogBuffer, IN UINT LogBufferSize)
 
VOID EXPORT NdisTerminateWrapper (IN NDIS_HANDLE NdisWrapperHandle, IN PVOID SystemSpecific)
 
NDIS_STATUS EXPORT NdisMQueryAdapterInstanceName (OUT PNDIS_STRING AdapterInstanceName, IN NDIS_HANDLE MiniportAdapterHandle)
 
VOID EXPORT NdisDeregisterAdapterShutdownHandler (IN NDIS_HANDLE NdisAdapterHandle)
 
VOID EXPORT NdisRegisterAdapterShutdownHandler (IN NDIS_HANDLE NdisAdapterHandle, IN PVOID ShutdownContext, IN ADAPTER_SHUTDOWN_HANDLER ShutdownHandler)
 
VOID EXPORT NdisMGetDeviceProperty (IN NDIS_HANDLE MiniportAdapterHandle, IN OUT PDEVICE_OBJECT *PhysicalDeviceObject OPTIONAL, IN OUT PDEVICE_OBJECT *FunctionalDeviceObject OPTIONAL, IN OUT PDEVICE_OBJECT *NextDeviceObject OPTIONAL, IN OUT PCM_RESOURCE_LIST *AllocatedResources OPTIONAL, IN OUT PCM_RESOURCE_LIST *AllocatedResourcesTranslated OPTIONAL)
 
VOID EXPORT NdisMRegisterUnloadHandler (IN NDIS_HANDLE NdisWrapperHandle, IN PDRIVER_UNLOAD UnloadHandler)
 
NDIS_STATUS EXPORT NdisMRegisterDevice (IN NDIS_HANDLE NdisWrapperHandle, IN PNDIS_STRING DeviceName, IN PNDIS_STRING SymbolicName, IN PDRIVER_DISPATCH MajorFunctions[], OUT PDEVICE_OBJECT *pDeviceObject, OUT NDIS_HANDLE *NdisDeviceHandle)
 
NDIS_STATUS EXPORT NdisMDeregisterDevice (IN NDIS_HANDLE NdisDeviceHandle)
 
NDIS_STATUS EXPORT NdisQueryAdapterInstanceName (OUT PNDIS_STRING AdapterInstanceName, IN NDIS_HANDLE NdisBindingHandle)
 
VOID EXPORT NdisCompletePnPEvent (IN NDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle, IN PNET_PNP_EVENT NetPnPEvent)
 
VOID EXPORT NdisCancelSendPackets (IN NDIS_HANDLE NdisBindingHandle, IN PVOID CancelId)
 
NDIS_HANDLE EXPORT NdisIMGetBindingContext (IN NDIS_HANDLE NdisBindingHandle)
 
NDIS_HANDLE EXPORT NdisIMGetDeviceContext (IN NDIS_HANDLE MiniportAdapterHandle)
 

Variables

static NDIS_MEDIUM MediaArray [MEDIA_ARRAY_SIZE]
 
LIST_ENTRY MiniportListHead
 
KSPIN_LOCK MiniportListLock
 
LIST_ENTRY AdapterListHead
 
KSPIN_LOCK AdapterListLock
 

Macro Definition Documentation

◆ BREAK_ON_MINIPORT_INIT

#define BREAK_ON_MINIPORT_INIT   0

Definition at line 22 of file miniport.c.

◆ MEDIA_ARRAY_SIZE

#define MEDIA_ARRAY_SIZE   15

Definition at line 31 of file miniport.c.

◆ ROUTE_DATA_SIZE

#define ROUTE_DATA_SIZE   256

Definition at line 28 of file miniport.c.

Function Documentation

◆ DoQueries()

NDIS_STATUS DoQueries ( PLOGICAL_ADAPTER  Adapter,
NDIS_OID  AddressOID 
)

Definition at line 1746 of file miniport.c.

1757 {
1759  NDIS_STATUS NdisStatus;
1760 
1761  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
1762 
1763  /* Get MAC options for adapter */
1764  NdisStatus = MiniQueryInformation(Adapter, OID_GEN_MAC_OPTIONS, sizeof(UINT),
1765  &Adapter->NdisMiniportBlock.MacOptions,
1766  &BytesWritten);
1767 
1768  if (NdisStatus != NDIS_STATUS_SUCCESS)
1769  {
1770  NDIS_DbgPrint(MIN_TRACE, ("OID_GEN_MAC_OPTIONS failed. NdisStatus (0x%X).\n", NdisStatus));
1771  return NdisStatus;
1772  }
1773 
1774  NDIS_DbgPrint(DEBUG_MINIPORT, ("MacOptions (0x%X).\n", Adapter->NdisMiniportBlock.MacOptions));
1775 
1776  /* Get current hardware address of adapter */
1777  NdisStatus = MiniQueryInformation(Adapter, AddressOID, Adapter->AddressLength,
1778  &Adapter->Address, &BytesWritten);
1779 
1780  if (NdisStatus != NDIS_STATUS_SUCCESS)
1781  {
1782  NDIS_DbgPrint(MIN_TRACE, ("Address OID (0x%X) failed. NdisStatus (0x%X).\n", AddressOID, NdisStatus));
1783  return NdisStatus;
1784  }
1785 
1786 #if DBG
1787  {
1788  /* 802.3 only */
1789 
1790  PUCHAR A = (PUCHAR)&Adapter->Address.Type.Medium802_3;
1791 
1792  NDIS_DbgPrint(MAX_TRACE, ("Adapter address is (%02X %02X %02X %02X %02X %02X).\n", A[0], A[1], A[2], A[3], A[4], A[5]));
1793  }
1794 #endif /* DBG */
1795 
1796  /* Get maximum lookahead buffer size of adapter */
1797  NdisStatus = MiniQueryInformation(Adapter, OID_GEN_MAXIMUM_LOOKAHEAD, sizeof(ULONG),
1799 
1800  if (NdisStatus != NDIS_STATUS_SUCCESS)
1801  {
1802  NDIS_DbgPrint(MIN_TRACE, ("OID_GEN_MAXIMUM_LOOKAHEAD failed. NdisStatus (0x%X).\n", NdisStatus));
1803  return NdisStatus;
1804  }
1805 
1806  NDIS_DbgPrint(DEBUG_MINIPORT, ("MaxLookaheadLength (0x%X).\n", Adapter->NdisMiniportBlock.MaximumLookahead));
1807 
1808  /* Get current lookahead buffer size of adapter */
1809  NdisStatus = MiniQueryInformation(Adapter, OID_GEN_CURRENT_LOOKAHEAD, sizeof(ULONG),
1811 
1812  if (NdisStatus != NDIS_STATUS_SUCCESS)
1813  {
1814  NDIS_DbgPrint(MIN_TRACE, ("OID_GEN_CURRENT_LOOKAHEAD failed. NdisStatus (0x%X).\n", NdisStatus));
1815  return NdisStatus;
1816  }
1817 
1818  NdisStatus = MiniQueryInformation(Adapter, OID_GEN_MAXIMUM_SEND_PACKETS, sizeof(ULONG),
1820 
1821  if (NdisStatus != NDIS_STATUS_SUCCESS)
1822  {
1823  NDIS_DbgPrint(MIN_TRACE, ("OID_GEN_MAXIMUM_SEND_PACKETS failed. NdisStatus (0x%X).\n", NdisStatus));
1824 
1825  /* Set it to 1 if it fails because some drivers don't support this (?)*/
1826  Adapter->NdisMiniportBlock.MaxSendPackets = 1;
1827  }
1828 
1829  NDIS_DbgPrint(DEBUG_MINIPORT, ("CurLookaheadLength (0x%X).\n", Adapter->NdisMiniportBlock.CurrentLookahead));
1830 
1831  return STATUS_SUCCESS;
1832 }
UINT MaximumLookahead
Definition: ndis.h:2570
_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
unsigned char * PUCHAR
Definition: retypes.h:3
#define OID_GEN_MAC_OPTIONS
Definition: ntddndis.h:251
union _HARDWARE_ADDRESS::@974 Type
#define DEBUG_MINIPORT
Definition: debug.h:17
int NDIS_STATUS
Definition: ntddndis.h:471
HARDWARE_ADDRESS Address
Definition: miniport.h:96
#define OID_GEN_MAXIMUM_LOOKAHEAD
Definition: ntddndis.h:237
ULONG AddressLength
Definition: miniport.h:97
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
USHORT MaxSendPackets
Definition: ndis.h:2560
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
Definition: ttei1.cpp:12
NDIS_STATUS MiniQueryInformation(PLOGICAL_ADAPTER Adapter, NDIS_OID Oid, ULONG Size, PVOID Buffer, PULONG BytesWritten)
Definition: miniport.c:805
#define OID_GEN_MAXIMUM_SEND_PACKETS
Definition: ntddndis.h:253
UINT CurrentLookahead
Definition: ndis.h:2569
#define MAX_TRACE
Definition: debug.h:16
unsigned int UINT
Definition: ndis.h:50
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
unsigned int ULONG
Definition: retypes.h:1
#define MIN_TRACE
Definition: debug.h:14
return STATUS_SUCCESS
Definition: btrfs.c:2966
UCHAR Medium802_3[ETH_LENGTH_OF_ADDRESS]
Definition: miniport.h:14
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:247

Referenced by NdisIPnPStartDevice().

◆ 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().

◆ MiniCheckForHang()

BOOLEAN MiniCheckForHang ( PLOGICAL_ADAPTER  Adapter)

Definition at line 865 of file miniport.c.

874 {
875  BOOLEAN Ret = FALSE;
876  KIRQL OldIrql;
877 
879  if (Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CheckForHangHandler)
880  Ret = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CheckForHangHandler)(
883 
884  return Ret;
885 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
NDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics
Definition: miniport.h:22
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
UCHAR KIRQL
Definition: env_spec_w32.h:591
NDIS_HANDLE MiniportAdapterContext
Definition: ndis.h:2510
unsigned char BOOLEAN
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
_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
PNDIS_M_DRIVER_BLOCK DriverHandle
Definition: ndis.h:2509

Referenced by MiniportHangDpc().

◆ 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().

◆ MiniGetFirstWorkItem()

PNDIS_MINIPORT_WORK_ITEM MiniGetFirstWorkItem ( PLOGICAL_ADAPTER  Adapter,
NDIS_WORK_ITEM_TYPE  Type 
)

Definition at line 124 of file miniport.c.

127 {
128  PNDIS_MINIPORT_WORK_ITEM CurrentEntry = Adapter->WorkQueueHead;
129 
130  while (CurrentEntry)
131  {
132  if (CurrentEntry->WorkItemType == Type || Type == NdisMaxWorkItems)
133  return CurrentEntry;
134 
135  CurrentEntry = (PNDIS_MINIPORT_WORK_ITEM)CurrentEntry->Link.Next;
136  }
137 
138  return NULL;
139 }
Type
Definition: Type.h:6
PNDIS_MINIPORT_WORK_ITEM WorkQueueHead
Definition: miniport.h:90
NDIS_WORK_ITEM_TYPE WorkItemType
Definition: ndis.h:2310
smooth NULL
Definition: ftsmooth.c:416
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:636
struct _NDIS_MINIPORT_WORK_ITEM * PNDIS_MINIPORT_WORK_ITEM
SINGLE_LIST_ENTRY Link
Definition: ndis.h:2309

Referenced by MiniIsBusy().

◆ 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().

◆ MiniIndicateReceivePacket()

VOID NTAPI MiniIndicateReceivePacket ( IN NDIS_HANDLE  MiniportAdapterHandle,
IN PPNDIS_PACKET  PacketArray,
IN UINT  NumberOfPackets 
)

Definition at line 293 of file miniport.c.

305 {
307  PLIST_ENTRY CurrentEntry;
308  PADAPTER_BINDING AdapterBinding;
309  KIRQL OldIrql;
310  UINT i;
311 
313 
314  CurrentEntry = Adapter->ProtocolListHead.Flink;
315 
316  while (CurrentEntry != &Adapter->ProtocolListHead)
317  {
318  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
319 
320  for (i = 0; i < NumberOfPackets; i++)
321  {
322  /* Store the indicating miniport in the packet */
323  PacketArray[i]->Reserved[1] = (ULONG_PTR)Adapter;
324 
325  if (AdapterBinding->ProtocolBinding->Chars.ReceivePacketHandler &&
327  {
328  NDIS_DbgPrint(MID_TRACE, ("Indicating packet to protocol's ReceivePacket handler\n"));
330  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
331  PacketArray[i]);
332  NDIS_DbgPrint(MID_TRACE, ("Protocol is holding %d references to the packet\n", PacketArray[i]->WrapperReserved[0]));
333  }
334  else
335  {
336  UINT FirstBufferLength, TotalBufferLength, LookAheadSize, HeaderSize;
337  PNDIS_BUFFER NdisBuffer;
338  PVOID NdisBufferVA, LookAheadBuffer;
339 
341  &NdisBuffer,
342  &NdisBufferVA,
343  &FirstBufferLength,
344  &TotalBufferLength);
345 
347 
348  LookAheadSize = TotalBufferLength - HeaderSize;
349 
350  LookAheadBuffer = ExAllocatePool(NonPagedPool, LookAheadSize);
351  if (!LookAheadBuffer)
352  {
353  NDIS_DbgPrint(MIN_TRACE, ("Failed to allocate lookahead buffer!\n"));
355  return;
356  }
357 
358  CopyBufferChainToBuffer(LookAheadBuffer,
359  NdisBuffer,
360  HeaderSize,
361  LookAheadSize);
362 
363  NDIS_DbgPrint(MID_TRACE, ("Indicating packet to protocol's legacy Receive handler\n"));
364  (*AdapterBinding->ProtocolBinding->Chars.ReceiveHandler)(
365  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
366  AdapterBinding->NdisOpenBlock.MacHandle,
367  NdisBufferVA,
368  HeaderSize,
369  LookAheadBuffer,
370  LookAheadSize,
371  TotalBufferLength - HeaderSize);
372 
373  ExFreePool(LookAheadBuffer);
374  }
375  }
376 
377  CurrentEntry = CurrentEntry->Flink;
378  }
379 
380  /* Loop the packet array to get everything
381  * set up for return the packets to the miniport */
382  for (i = 0; i < NumberOfPackets; i++)
383  {
384  /* First, check the initial packet status */
386  {
387  /* The miniport driver gets it back immediately so nothing to do here */
388  NDIS_DbgPrint(MID_TRACE, ("Miniport needs the packet back immediately\n"));
389  continue;
390  }
391 
392  /* Different behavior depending on whether it's serialized or not */
394  {
395  /* We need to check the reference count */
396  if (PacketArray[i]->WrapperReserved[0] == 0)
397  {
398  /* NOTE: Unlike serialized miniports, this is REQUIRED to be called for each
399  * packet received that can be reused immediately, it is not implied! */
400  Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ReturnPacketHandler(
402  PacketArray[i]);
403  NDIS_DbgPrint(MID_TRACE, ("Packet has been returned to miniport (Deserialized)\n"));
404  }
405  else
406  {
407  /* Packet will be returned by the protocol's call to NdisReturnPackets */
408  NDIS_DbgPrint(MID_TRACE, ("Packet will be returned to miniport later (Deserialized)\n"));
409  }
410  }
411  else
412  {
413  /* Check the reference count */
414  if (PacketArray[i]->WrapperReserved[0] == 0)
415  {
416  /* NDIS_STATUS_SUCCESS means the miniport can have the packet back immediately */
418 
419  NDIS_DbgPrint(MID_TRACE, ("Packet has been returned to miniport (Serialized)\n"));
420  }
421  else
422  {
423  /* NDIS_STATUS_PENDING means the miniport needs to wait for MiniportReturnPacket */
425 
426  NDIS_DbgPrint(MID_TRACE, ("Packet will be returned to miniport later (Serialized)\n"));
427  }
428  }
429  }
430 
432 }
_In_ PPNDIS_PACKET _In_ UINT NumberOfPackets
Definition: ndis.h:5120
#define MID_TRACE
Definition: debug.h:15
NDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics
Definition: miniport.h:22
NDIS_OPEN_BLOCK NdisOpenBlock
Definition: protocol.h:22
#define NDIS_ATTRIBUTE_DESERIALIZE
Definition: ndis.h:588
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
MDL * PNDIS_BUFFER
Definition: ndis.h:343
_In_ NDIS_HANDLE MiniportAdapterHandle
Definition: ndis.h:4668
UCHAR KIRQL
Definition: env_spec_w32.h:591
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ PPNDIS_PACKET PacketArray
Definition: ndis.h:5120
NDIS_HANDLE MiniportAdapterContext
Definition: ndis.h:2510
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
VOID EXPORT NdisGetFirstBufferFromPacket(IN PNDIS_PACKET _Packet, OUT PNDIS_BUFFER *_FirstBuffer, OUT PVOID *_FirstBufferVA, OUT PUINT _FirstBufferLength, OUT PUINT _TotalBufferLength)
Definition: buffer.c:871
PPROTOCOL_BINDING ProtocolBinding
Definition: protocol.h:28
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define NDIS_GET_PACKET_STATUS(_Packet)
Definition: ndis.h:3436
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
RECEIVE_PACKET_HANDLER ReceivePacketHandler
Definition: ndis.h:1896
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
ULONG_PTR Reserved[2]
Definition: ndis.h:749
LIST_ENTRY ProtocolListHead
Definition: miniport.h:94
UCHAR WrapperReserved[2 *sizeof(PVOID)]
Definition: ndis.h:739
#define NDIS_GET_PACKET_HEADER_SIZE(_Packet)
Definition: ndis.h:3427
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define NDIS_SET_PACKET_STATUS(_Packet, _Status)
Definition: ndis.h:3509
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
RECEIVE_HANDLER ReceiveHandler
Definition: ndis.h:1889
Definition: typedefs.h:117
UINT CopyBufferChainToBuffer(PUCHAR DstData, PNDIS_BUFFER SrcBuffer, UINT SrcOffset, UINT Length)
Definition: buffer.c:111
KSPIN_LOCK Lock
Definition: ndis.h:2520
unsigned int UINT
Definition: ndis.h:50
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
#define MIN_TRACE
Definition: debug.h:14
#define ULONG_PTR
Definition: config.h:101
PNDIS_M_DRIVER_BLOCK DriverHandle
Definition: ndis.h:2509
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
NDIS_PROTOCOL_CHARACTERISTICS Chars
Definition: protocol.h:13

Referenced by NdisIPnPStartDevice().

◆ 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().

◆ MiniportHangDpc()

VOID NTAPI MiniportHangDpc ( PKDPC  Dpc,
PVOID  DeferredContext,
PVOID  SystemArgument1,
PVOID  SystemArgument2 
)

Definition at line 949 of file miniport.c.

954 {
956 
957  if (MiniCheckForHang(Adapter)) {
958  NDIS_DbgPrint(MIN_TRACE, ("Miniport detected adapter hang\n"));
959  MiniReset(Adapter);
960  }
961 }
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define MIN_TRACE
Definition: debug.h:14
BOOLEAN MiniCheckForHang(PLOGICAL_ADAPTER Adapter)
Definition: miniport.c:865
NDIS_STATUS MiniReset(PLOGICAL_ADAPTER Adapter)
Definition: miniport.c:902
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:675

Referenced by NdisIAddDevice().

◆ MiniportWorker()

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

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().

◆ MiniRequestComplete()

VOID NTAPI MiniRequestComplete ( IN NDIS_HANDLE  MiniportAdapterHandle,
IN NDIS_STATUS  Status 
)

Definition at line 481 of file miniport.c.

484 {
487  PNDIS_REQUEST_MAC_BLOCK MacBlock;
488  KIRQL OldIrql;
489 
490  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
491 
493 
497 
498  MacBlock = (PNDIS_REQUEST_MAC_BLOCK)Request->MacReserved;
499 
500  /* We may or may not be doing this request on behalf of an adapter binding */
501  if (MacBlock->Binding != NULL)
502  {
503  /* We are, so invoke its request complete handler */
504  if (MacBlock->Binding->RequestCompleteHandler != NULL)
505  {
506  (*MacBlock->Binding->RequestCompleteHandler)(
507  MacBlock->Binding->ProtocolBindingContext,
508  Request,
509  Status);
510  }
511  }
512  else
513  {
514  /* We are doing this internally, so we'll signal this event we've stashed in the MacBlock */
515  ASSERT(MacBlock->Unknown1 != NULL);
516  ASSERT(MacBlock->Unknown3 == NULL);
517  MacBlock->Unknown3 = UlongToPtr(Status);
519  }
520 
525 
527 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
VOID MiniWorkItemComplete(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE WorkItemType)
Definition: miniport.c:964
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
_In_ NDIS_HANDLE MiniportAdapterHandle
Definition: ndis.h:4668
#define DEBUG_MINIPORT
Definition: debug.h:17
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
UCHAR KIRQL
Definition: env_spec_w32.h:591
smooth NULL
Definition: ftsmooth.c:416
#define UlongToPtr(u)
Definition: config.h:106
if(!(yy_init))
Definition: macro.lex.yy.c:714
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:215
struct _NDIS_REQUEST_MAC_BLOCK * PNDIS_REQUEST_MAC_BLOCK
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PNDIS_OPEN_BLOCK Binding
Definition: protocol.h:34
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
struct _LOGICAL_ADAPTER * PLOGICAL_ADAPTER
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
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define IO_NO_INCREMENT
Definition: iotypes.h:566

Referenced by NdisIPnPStartDevice().

◆ 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().

◆ MiniResetComplete()

VOID NTAPI MiniResetComplete ( IN NDIS_HANDLE  MiniportAdapterHandle,
IN NDIS_STATUS  Status,
IN BOOLEAN  AddressingReset 
)

Definition at line 435 of file miniport.c.

439 {
441  PLIST_ENTRY CurrentEntry;
442  PADAPTER_BINDING AdapterBinding;
443  KIRQL OldIrql;
444 
445  if (AddressingReset)
446  MiniDoAddressingReset(Adapter);
447 
450 
452 
454  {
455  KeBugCheckEx(BUGCODE_ID_DRIVER,
457  (ULONG_PTR)Status,
458  (ULONG_PTR)AddressingReset,
459  0);
460  }
461 
463 
464  CurrentEntry = Adapter->ProtocolListHead.Flink;
465 
466  while (CurrentEntry != &Adapter->ProtocolListHead)
467  {
468  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
469 
470  (*AdapterBinding->ProtocolBinding->Chars.ResetCompleteHandler)(
471  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
472  Status);
473 
474  CurrentEntry = CurrentEntry->Flink;
475  }
476 
478 }
NDIS_OPEN_BLOCK NdisOpenBlock
Definition: protocol.h:22
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
NDIS_STATUS ResetStatus
Definition: ndis.h:2541
VOID MiniDoAddressingReset(PLOGICAL_ADAPTER Adapter)
Definition: miniport.c:888
_In_ NDIS_HANDLE MiniportAdapterHandle
Definition: ndis.h:4668
uint32_t ULONG_PTR
Definition: typedefs.h:63
UCHAR KIRQL
Definition: env_spec_w32.h:591
smooth NULL
Definition: ftsmooth.c:416
RESET_COMPLETE_HANDLER ResetCompleteHandler
Definition: ndis.h:1886
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
VOID EXPORT NdisMIndicateStatusComplete(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:1580
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
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
#define NDIS_STATUS_RESET_END
Definition: ndis.h:355
KSPIN_LOCK Lock
Definition: ndis.h:2520
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
VOID EXPORT NdisMIndicateStatus(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS GeneralStatus, IN PVOID StatusBuffer, IN UINT StatusBufferSize)
Definition: miniport.c:1565
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:107
NDIS_PROTOCOL_CHARACTERISTICS Chars
Definition: protocol.h:13

Referenced by MiniportWorker(), NdisIPnPStartDevice(), and NdisMResetComplete().

◆ 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().

◆ MiniSendResourcesAvailable()

VOID NTAPI MiniSendResourcesAvailable ( IN NDIS_HANDLE  MiniportAdapterHandle)

Definition at line 583 of file miniport.c.

585 {
586  /* Run the work if anything is waiting */
588 }
VOID MiniWorkItemComplete(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE WorkItemType)
Definition: miniport.c:964
_In_ NDIS_HANDLE MiniportAdapterHandle
Definition: ndis.h:4668

Referenced by NdisIPnPStartDevice(), and NdisMSendResourcesAvailable().

◆ MiniSetInformation()

NDIS_STATUS MiniSetInformation ( PLOGICAL_ADAPTER  Adapter,
NDIS_OID  Oid,
ULONG  Size,
PVOID  Buffer,
PULONG  BytesRead 
)

Definition at line 756 of file miniport.c.

762 {
763  NDIS_STATUS NdisStatus;
765  KEVENT Event;
766  PNDIS_REQUEST_MAC_BLOCK MacBlock;
767 
768  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
769 
771  if (!NdisRequest) {
772  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
773  return NDIS_STATUS_RESOURCES;
774  }
775 
777 
778  NdisRequest->RequestType = NdisRequestSetInformation;
779  NdisRequest->DATA.SET_INFORMATION.Oid = Oid;
780  NdisRequest->DATA.SET_INFORMATION.InformationBuffer = Buffer;
781  NdisRequest->DATA.SET_INFORMATION.InformationBufferLength = Size;
782 
783  /* We'll need to give the completion routine some way of letting us know
784  * when it's finished. We'll stash a pointer to an event in the MacBlock */
786  MacBlock = (PNDIS_REQUEST_MAC_BLOCK)NdisRequest->MacReserved;
787  MacBlock->Unknown1 = &Event;
788 
789  NdisStatus = MiniDoRequest(Adapter, NdisRequest);
790 
791  if (NdisStatus == NDIS_STATUS_PENDING)
792  {
794  NdisStatus = PtrToUlong(MacBlock->Unknown3);
795  }
796 
797  *BytesRead = NdisRequest->DATA.SET_INFORMATION.BytesRead;
798 
800 
801  return NdisStatus;
802 }
_In_opt_ NDIS_HANDLE _In_opt_ NDIS_HANDLE _Inout_ PNDIS_REQUEST NdisRequest
Definition: ndis.h:1571
#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
_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
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by MiniDoAddressingReset().

◆ MiniStatus()

VOID NTAPI MiniStatus ( IN NDIS_HANDLE  MiniportHandle,
IN NDIS_STATUS  GeneralStatus,
IN PVOID  StatusBuffer,
IN UINT  StatusBufferSize 
)

Definition at line 1384 of file miniport.c.

1389 {
1390  PLOGICAL_ADAPTER Adapter = MiniportHandle;
1391  PLIST_ENTRY CurrentEntry;
1392  PADAPTER_BINDING AdapterBinding;
1393  KIRQL OldIrql;
1394 
1396 
1397  CurrentEntry = Adapter->ProtocolListHead.Flink;
1398 
1399  while (CurrentEntry != &Adapter->ProtocolListHead)
1400  {
1401  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
1402 
1403  (*AdapterBinding->ProtocolBinding->Chars.StatusHandler)(
1404  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
1405  GeneralStatus,
1406  StatusBuffer,
1408 
1409  CurrentEntry = CurrentEntry->Flink;
1410  }
1411 
1413 }
NDIS_OPEN_BLOCK NdisOpenBlock
Definition: protocol.h:22
_In_opt_ NDIS_HANDLE _In_ NDIS_STATUS GeneralStatus
Definition: ndis.h:1555
STATUS_HANDLER StatusHandler
Definition: ndis.h:1893
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
Definition: typedefs.h:117
_In_opt_ NDIS_HANDLE _In_ NDIS_STATUS _In_ PVOID _In_ UINT StatusBufferSize
Definition: ndis.h:1555
KSPIN_LOCK Lock
Definition: ndis.h:2520
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
_In_opt_ NDIS_HANDLE _In_ NDIS_STATUS _In_ PVOID StatusBuffer
Definition: ndis.h:1555
NDIS_PROTOCOL_CHARACTERISTICS Chars
Definition: protocol.h:13

Referenced by NdisIPnPStartDevice(), NdisMIndicateStatus(), and RxChangeBufferingState().

◆ MiniStatusComplete()

VOID NTAPI MiniStatusComplete ( IN NDIS_HANDLE  MiniportAdapterHandle)

Definition at line 1417 of file miniport.c.

1419 {
1421  PLIST_ENTRY CurrentEntry;
1422  PADAPTER_BINDING AdapterBinding;
1423  KIRQL OldIrql;
1424 
1426 
1427  CurrentEntry = Adapter->ProtocolListHead.Flink;
1428 
1429  while (CurrentEntry != &Adapter->ProtocolListHead)
1430  {
1431  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
1432 
1433  (*AdapterBinding->ProtocolBinding->Chars.StatusCompleteHandler)(
1434  AdapterBinding->NdisOpenBlock.ProtocolBindingContext);
1435 
1436  CurrentEntry = CurrentEntry->Flink;
1437  }
1438 
1440 }
NDIS_OPEN_BLOCK NdisOpenBlock
Definition: protocol.h:22
_In_ NDIS_HANDLE MiniportAdapterHandle
Definition: ndis.h:4668
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
STATUS_COMPLETE_HANDLER StatusCompleteHandler
Definition: ndis.h:1894
LIST_ENTRY ProtocolListHead
Definition: miniport.h:94
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Definition: typedefs.h:117
KSPIN_LOCK Lock
Definition: ndis.h:2520
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
NDIS_PROTOCOL_CHARACTERISTICS Chars
Definition: protocol.h:13

Referenced by NdisIPnPStartDevice(), and NdisMIndicateStatusComplete().

◆ MiniTransferDataComplete()

VOID NTAPI MiniTransferDataComplete ( IN NDIS_HANDLE  MiniportAdapterHandle,
IN PNDIS_PACKET  Packet,
IN NDIS_STATUS  Status,
IN UINT  BytesTransferred 
)

Definition at line 592 of file miniport.c.

597 {
598  PADAPTER_BINDING AdapterBinding;
599  KIRQL OldIrql;
600 
601  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
602 
603  AdapterBinding = (PADAPTER_BINDING)Packet->Reserved[1];
604 
607  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
608  Packet,
609  Status,
610  BytesTransferred);
612 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
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
#define DEBUG_MINIPORT
Definition: debug.h:17
UCHAR KIRQL
Definition: env_spec_w32.h:591
PPROTOCOL_BINDING ProtocolBinding
Definition: protocol.h:28
TRANSFER_DATA_COMPLETE_HANDLER TransferDataCompleteHandler
Definition: ndis.h:1883
_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
struct _ADAPTER_BINDING * PADAPTER_BINDING
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
NDIS_PROTOCOL_CHARACTERISTICS Chars
Definition: protocol.h:13

Referenced by NdisIPnPStartDevice(), and NdisMTransferDataComplete().

◆ 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().

◆ NdisCancelSendPackets()

VOID EXPORT NdisCancelSendPackets ( IN NDIS_HANDLE  NdisBindingHandle,
IN PVOID  CancelId 
)

Definition at line 3353 of file miniport.c.

3356 {
3357  PADAPTER_BINDING AdapterBinding = NdisBindingHandle;
3358  PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
3359 
3360  NDIS_DbgPrint(MAX_TRACE, ("Called for ID %x.\n", CancelId));
3361 
3362  if (Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CancelSendPacketsHandler)
3363  {
3364  (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CancelSendPacketsHandler)(
3366  CancelId);
3367  }
3368 }
NDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics
Definition: miniport.h:22
LONG CancelId
Definition: main.c:23
NDIS_HANDLE MiniportAdapterContext
Definition: ndis.h:2510
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
PLOGICAL_ADAPTER Adapter
Definition: protocol.h:29
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
_Must_inspect_result_ _In_ NDIS_HANDLE NdisBindingHandle
Definition: ndis.h:4735
PNDIS_M_DRIVER_BLOCK DriverHandle
Definition: ndis.h:2509

◆ NdisCompletePnPEvent()

VOID EXPORT NdisCompletePnPEvent ( IN NDIS_STATUS  Status,
IN NDIS_HANDLE  NdisBindingHandle,
IN PNET_PNP_EVENT  NetPnPEvent 
)

Definition at line 3290 of file miniport.c.

3300 {
3301  PIRP Irp = (PIRP)NetPnPEvent->NdisReserved[0];
3302  PLIST_ENTRY CurrentEntry = (PLIST_ENTRY)NetPnPEvent->NdisReserved[1];
3303  PADAPTER_BINDING AdapterBinding = NdisBindingHandle;
3304  PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
3305  NDIS_STATUS NdisStatus;
3306 
3307  if (Status != NDIS_STATUS_SUCCESS)
3308  {
3309  if (NetPnPEvent->Buffer) ExFreePool(NetPnPEvent->Buffer);
3311  Irp->IoStatus.Status = Status;
3313  return;
3314  }
3315 
3316  while (CurrentEntry != &Adapter->ProtocolListHead)
3317  {
3318  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
3319 
3320  NdisStatus = (*AdapterBinding->ProtocolBinding->Chars.PnPEventHandler)(
3321  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
3322  NetPnPEvent);
3323 
3324  if (NdisStatus == NDIS_STATUS_PENDING)
3325  {
3326  NetPnPEvent->NdisReserved[1] = (ULONG_PTR)CurrentEntry->Flink;
3327  return;
3328  }
3329  else if (NdisStatus != NDIS_STATUS_SUCCESS)
3330  {
3331  if (NetPnPEvent->Buffer) ExFreePool(NetPnPEvent->Buffer);
3333  Irp->IoStatus.Status = NdisStatus;
3335  return;
3336  }
3337 
3338  CurrentEntry = CurrentEntry->Flink;
3339  }
3340 
3341  if (NetPnPEvent->Buffer) ExFreePool(NetPnPEvent->Buffer);
3343 
3344  Irp->IoStatus.Status = NDIS_STATUS_SUCCESS;
3346 }
NDIS_OPEN_BLOCK NdisOpenBlock
Definition: protocol.h:22
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
_In_ PIRP Irp
Definition: csq.h:116
_In_ NDIS_HANDLE _In_ PNET_PNP_EVENT NetPnPEvent
Definition: ndis.h:6081
int NDIS_STATUS
Definition: ntddndis.h:471
#define IoCompleteRequest
Definition: irp.c:1240
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
PLOGICAL_ADAPTER Adapter
Definition: protocol.h:29
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
LIST_ENTRY ProtocolListHead
Definition: miniport.h:94
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
PVOID PIRP
Definition: usb.h:38
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define ULONG_PTR
Definition: config.h:101
_Must_inspect_result_ _In_ NDIS_HANDLE NdisBindingHandle
Definition: ndis.h:4735
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
PNP_EVENT_HANDLER PnPEventHandler
Definition: ndis.h:1899
NDIS_PROTOCOL_CHARACTERISTICS Chars
Definition: protocol.h:13

◆ NdisDeregisterAdapterShutdownHandler()

VOID EXPORT NdisDeregisterAdapterShutdownHandler ( IN NDIS_HANDLE  NdisAdapterHandle)

Definition at line 3073 of file miniport.c.

3081 {
3082  NdisMDeregisterAdapterShutdownHandler(NdisAdapterHandle);
3083 }
VOID EXPORT NdisMDeregisterAdapterShutdownHandler(IN NDIS_HANDLE MiniportHandle)
Definition: miniport.c:1517

◆ NdisGenericIrpHandler()

NTSTATUS NTAPI NdisGenericIrpHandler ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 2574 of file miniport.c.

2577 {
2579 
2580  /* Use the characteristics to classify the device */
2581  if (DeviceObject->DeviceType == FILE_DEVICE_PHYSICAL_NETCARD)
2582  {
2583  if ((IrpSp->MajorFunction == IRP_MJ_CREATE) ||
2586  {
2588  }
2589  else if (IrpSp->MajorFunction == IRP_MJ_PNP)
2590  {
2592  }
2593  else if (IrpSp->MajorFunction == IRP_MJ_SHUTDOWN)
2594  {
2595  return NdisIShutdown(DeviceObject, Irp);
2596  }
2598  {
2600  }
2601  else if (IrpSp->MajorFunction == IRP_MJ_POWER)
2602  {
2603  return NdisIPower(DeviceObject, Irp);
2604  }
2605  NDIS_DbgPrint(MIN_TRACE, ("Unexpected IRP MajorFunction 0x%x\n", IrpSp->MajorFunction));
2606  ASSERT(FALSE);
2607  }
2608  else if (DeviceObject->DeviceType == FILE_DEVICE_NETWORK)
2609  {
2611 
2612  ASSERT(DeviceBlock->DeviceObject == DeviceObject);
2613 
2614  if (DeviceBlock->MajorFunction[IrpSp->MajorFunction] != NULL)
2615  {
2616  return DeviceBlock->MajorFunction[IrpSp->MajorFunction](DeviceObject, Irp);
2617  }
2618  }
2619  else
2620  {
2621  ASSERT(FALSE);
2622  }
2623 
2624  Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
2625  Irp->IoStatus.Information = 0;
2626 
2628 
2630 }
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define FILE_DEVICE_NETWORK
Definition: winioctl.h:123
#define IRP_MJ_SHUTDOWN
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
NTSTATUS NTAPI NdisICreateClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: miniport.c:1871
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
NTSTATUS NTAPI NdisIShutdown(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: miniport.c:2269
#define FILE_DEVICE_PHYSICAL_NETCARD
Definition: winioctl.h:128
NTSTATUS NTAPI NdisIPower(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: miniport.c:2407
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define IRP_MJ_POWER
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
NTSTATUS NTAPI NdisIDispatchPnp(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: miniport.c:2335
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: miniport.h:37
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
NTSTATUS NTAPI NdisIDeviceIoControl(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: miniport.c:2291
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
PDEVICE_OBJECT DeviceObject
Definition: miniport.h:35
#define IRP_MJ_CLEANUP
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define MIN_TRACE
Definition: debug.h:14
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

Referenced by NdisMRegisterMiniport().

◆ NdisIAddDevice()

NTSTATUS NTAPI NdisIAddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  PhysicalDeviceObject 
)

Definition at line 2420 of file miniport.c.

2429 {
2430  static const WCHAR ClassKeyName[] = {'C','l','a','s','s','\\'};
2431  static const WCHAR LinkageKeyName[] = {'\\','L','i','n','k','a','g','e',0};
2432  PNDIS_M_DRIVER_BLOCK Miniport;
2433  PNDIS_M_DRIVER_BLOCK *MiniportPtr;
2434  WCHAR *LinkageKeyBuffer;
2435  ULONG DriverKeyLength;
2437  UNICODE_STRING ExportName;
2439  PLOGICAL_ADAPTER Adapter;
2440  NTSTATUS Status;
2441 
2442  /*
2443  * Gain the access to the miniport data structure first.
2444  */
2445 
2446  MiniportPtr = IoGetDriverObjectExtension(DriverObject, (PVOID)'NMID');
2447  if (MiniportPtr == NULL)
2448  {
2449  NDIS_DbgPrint(MIN_TRACE, ("Can't get driver object extension.\n"));
2450  return NDIS_STATUS_FAILURE;
2451  }
2452  Miniport = *MiniportPtr;
2453 
2454  /*
2455  * Get name of the Linkage registry key for our adapter. It's located under
2456  * the driver key for our driver and so we have basicly two ways to do it.
2457  * Either we can use IoOpenDriverRegistryKey or compose it using information
2458  * gathered by IoGetDeviceProperty. I chose the second because
2459  * IoOpenDriverRegistryKey wasn't implemented at the time of writing.
2460  */
2461 
2463  0, NULL, &DriverKeyLength);
2465  {
2466  NDIS_DbgPrint(MIN_TRACE, ("Can't get miniport driver key length.\n"));
2467  return Status;
2468  }
2469 
2470  LinkageKeyBuffer = ExAllocatePool(PagedPool, DriverKeyLength +
2471  sizeof(ClassKeyName) + sizeof(LinkageKeyName));
2472  if (LinkageKeyBuffer == NULL)
2473  {
2474  NDIS_DbgPrint(MIN_TRACE, ("Can't allocate memory for driver key name.\n"));
2476  }
2477 
2479  DriverKeyLength, LinkageKeyBuffer +
2480  (sizeof(ClassKeyName) / sizeof(WCHAR)),
2481  &DriverKeyLength);
2482  if (!NT_SUCCESS(Status))
2483  {
2484  NDIS_DbgPrint(MIN_TRACE, ("Can't get miniport driver key.\n"));
2485  ExFreePool(LinkageKeyBuffer);
2486  return Status;
2487  }
2488 
2489  /* Compose the linkage key name. */
2490  RtlCopyMemory(LinkageKeyBuffer, ClassKeyName, sizeof(ClassKeyName));
2491  RtlCopyMemory(LinkageKeyBuffer + ((sizeof(ClassKeyName) + DriverKeyLength) /
2492  sizeof(WCHAR)) - 1, LinkageKeyName, sizeof(LinkageKeyName));
2493 
2494  NDIS_DbgPrint(DEBUG_MINIPORT, ("LinkageKey: %S.\n", LinkageKeyBuffer));
2495 
2496  /*
2497  * Now open the linkage key and read the "Export" and "RootDevice" values
2498  * which contains device name and root service respectively.
2499  */
2500 
2502  RtlInitUnicodeString(&ExportName, NULL);
2504  QueryTable[0].Name = L"Export";
2505  QueryTable[0].EntryContext = &ExportName;
2506 
2508  QueryTable, NULL, NULL);
2509  ExFreePool(LinkageKeyBuffer);
2510  if (!NT_SUCCESS(Status))
2511  {
2512  NDIS_DbgPrint(MIN_TRACE, ("Can't get miniport device name. (%x)\n", Status));
2513  return Status;
2514  }
2515 
2516  /*
2517  * Create the device object.
2518  */
2519 
2520  NDIS_DbgPrint(MAX_TRACE, ("creating device %wZ\n", &ExportName));
2521 
2522  Status = IoCreateDevice(Miniport->DriverObject, sizeof(LOGICAL_ADAPTER),
2523  &ExportName, FILE_DEVICE_PHYSICAL_NETCARD,
2524  0, FALSE, &DeviceObject);
2525  if (!NT_SUCCESS(Status))
2526  {
2527  NDIS_DbgPrint(MIN_TRACE, ("Could not create device object.\n"));
2528  RtlFreeUnicodeString(&ExportName);
2529  return Status;
2530  }
2531 
2532  /*
2533  * Initialize the adapter structure.
2534  */
2535 
2539 
2541  &GUID_DEVINTERFACE_NET,
2542  NULL,
2544 
2545  if (!NT_SUCCESS(Status))
2546  {
2547  NDIS_DbgPrint(MIN_TRACE, ("Could not create device interface.\n"));
2549  RtlFreeUnicodeString(&ExportName);
2550  return Status;
2551  }
2552 
2553  Adapter->NdisMiniportBlock.DriverHandle = Miniport;
2554  Adapter->NdisMiniportBlock.MiniportName = ExportName;
2560 
2561  Adapter->NdisMiniportBlock.OldPnPDeviceState = 0;
2562  Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceAdded;
2563 
2566 
2568 
2569  return STATUS_SUCCESS;
2570 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
Definition: rtlfuncs.h:4004
PDEVICE_OBJECT PhysicalDeviceObject
Definition: ndis.h:2553
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
#define RTL_REGISTRY_CONTROL
Definition: nt_native.h:163
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1114
#define DEBUG_MINIPORT
Definition: debug.h:17
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:4228
#define FILE_DEVICE_PHYSICAL_NETCARD
Definition: winioctl.h:128
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
__wchar_t WCHAR
Definition: xmlstorage.h:180
VOID NTAPI MiniportHangDpc(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
Definition: miniport.c:949
PDEVICE_OBJECT NextDeviceObject
Definition: ndis.h:2554
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
KDPC Dpc
Definition: ndis.h:644
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
LIST_ENTRY ProtocolListHead
Definition: miniport.h:94
static const WCHAR L[]
Definition: oid.c:1250
struct _LOGICAL_ADAPTER * PLOGICAL_ADAPTER
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1842
UNICODE_STRING MiniportName
Definition: ndis.h:2511
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:955
KTIMER Timer
Definition: ndis.h:643
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
#define MAX_TRACE
Definition: debug.h:16
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PDEVICE_OBJECT DeviceObject
Definition: ndis.h:2552
KSPIN_LOCK Lock
Definition: ndis.h:2520
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
NDIS_TIMER WakeUpDpcTimer
Definition: ndis.h:2535
UNICODE_STRING SymbolicLinkName
Definition: ndis.h:2537
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
PDRIVER_OBJECT DriverObject
Definition: miniport.h:24
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define MIN_TRACE
Definition: debug.h:14
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define RTL_QUERY_REGISTRY_REQUIRED
Definition: nt_native.h:132
PNDIS_M_DRIVER_BLOCK DriverHandle
Definition: ndis.h:2509
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144

Referenced by NdisMRegisterMiniport().

◆ NdisIBugcheckCallback()

VOID NTAPI NdisIBugcheckCallback ( IN PVOID  Buffer,
IN ULONG  Length 
)

Definition at line 1670 of file miniport.c.

1679 {
1682 
1683  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
1684 
1685  if(sh)
1686  sh(Context->DriverContext);
1687 }
struct _MINIPORT_BUGCHECK_CONTEXT * PMINIPORT_BUGCHECK_CONTEXT
#define DEBUG_MINIPORT
Definition: debug.h:17
Definition: bufpool.h:45
VOID(NTAPI * ADAPTER_SHUTDOWN_HANDLER)(_In_ PVOID ShutdownContext)
Definition: ndis.h:2025
short sh
Definition: format.c:272
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40

Referenced by NdisMRegisterAdapterShutdownHandler().

◆ NdisICreateClose()

NTSTATUS NTAPI NdisICreateClose ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 1871 of file miniport.c.

1874 {
1875  Irp->IoStatus.Status = STATUS_SUCCESS;
1876  Irp->IoStatus.Information = 0;
1877 
1879 
1880  return STATUS_SUCCESS;
1881 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
#define IO_NO_INCREMENT
Definition: iotypes.h:566
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by NdisGenericIrpHandler().

◆ NdisIDeviceIoControl()

NTSTATUS NTAPI NdisIDeviceIoControl ( IN PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 2291 of file miniport.c.

2294 {
2299  ULONG Written;
2300 
2301  Irp->IoStatus.Information = 0;
2302 
2303  ASSERT(Adapter);
2304 
2305  ControlCode = Stack->Parameters.DeviceIoControl.IoControlCode;
2306  switch (ControlCode)
2307  {
2309  Status = MiniQueryInformation(Adapter,
2310  *(PNDIS_OID)Irp->AssociatedIrp.SystemBuffer,
2311  Stack->Parameters.DeviceIoControl.OutputBufferLength,
2312  MmGetSystemAddressForMdl(Irp->MdlAddress),
2313  &Written);
2314  Irp->IoStatus.Information = Written;
2315  break;
2316 
2317  default:
2318  NDIS_DbgPrint(MIN_TRACE, ("NdisIDeviceIoControl: unsupported control code 0x%lx\n", ControlCode));
2319  break;
2320  }
2321 
2322  if (Status != NDIS_STATUS_PENDING)
2323  {
2324  Irp->IoStatus.Status = Status;
2326  }
2327  else
2329 
2330  return Status;
2331 }
#define IOCTL_NDIS_QUERY_GLOBAL_STATS
Definition: ntddndis.h:439
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
_In_ PIRP Irp
Definition: csq.h:116
int NDIS_STATUS
Definition: ntddndis.h:471
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
ULONG * PNDIS_OID
Definition: ntddndis.h:230
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
struct _LOGICAL_ADAPTER * PLOGICAL_ADAPTER
NDIS_STATUS MiniQueryInformation(PLOGICAL_ADAPTER Adapter, NDIS_OID Oid, ULONG Size, PVOID Buffer, PULONG BytesWritten)
Definition: miniport.c:805
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define MmGetSystemAddressForMdl(Mdl)
#define MIN_TRACE
Definition: debug.h:14
IoMarkIrpPending(Irp)

Referenced by NdisGenericIrpHandler().

◆ NdisIDispatchPnp()

NTSTATUS NTAPI NdisIDispatchPnp ( IN PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 2335 of file miniport.c.

2338 {
2341  NTSTATUS Status;
2342 
2343  switch (Stack->MinorFunction)
2344  {
2345  case IRP_MN_START_DEVICE:
2346  Status = NdisIForwardIrpAndWait(Adapter, Irp);
2347  if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
2348  {
2350  }
2351  else
2352  NDIS_DbgPrint(MIN_TRACE, ("Lower driver failed device start\n"));
2353  Irp->IoStatus.Status = Status;
2355  return Status;
2356 
2357  case IRP_MN_STOP_DEVICE:
2359  if (!NT_SUCCESS(Status))
2360  NDIS_DbgPrint(MIN_TRACE, ("WARNING: Ignoring halt device failure! Passing the IRP down anyway\n"));
2361  Irp->IoStatus.Status = STATUS_SUCCESS;
2362  break;
2363 
2367  Irp->IoStatus.Status = Status;
2368  if (Status != STATUS_SUCCESS)
2369  {
2371  NDIS_DbgPrint(MIN_TRACE, ("Failing miniport halt request\n"));
2372  return Status;
2373  }
2374  break;
2375 
2378  Status = NdisIForwardIrpAndWait(Adapter, Irp);
2379  if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
2380  {
2382  }
2383  else
2384  {
2385  NDIS_DbgPrint(MIN_TRACE, ("Lower driver failed cancel stop/remove request\n"));
2386  }
2387  Irp->IoStatus.Status = Status;
2389  return Status;
2390 
2393  Irp->IoStatus.Status = Status;
2394  Irp->IoStatus.Information |= Adapter->NdisMiniportBlock.PnPFlags;
2395  break;
2396 
2397  default:
2398  break;
2399  }
2400 
2403 }
#define IRP_MN_CANCEL_REMOVE_DEVICE
NTSTATUS NTAPI NdisIPnPQueryStopDevice(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: protocol.c:154
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS NTAPI NdisIPnPStopDevice(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: miniport.c:2211
LONG NTSTATUS
Definition: precomp.h:26
#define IRP_MN_QUERY_REMOVE_DEVICE
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
switch(r->id)
Definition: btrfs.c:2932
NTSTATUS NTAPI NdisIPnPCancelStopDevice(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: protocol.c:172
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_STOP_DEVICE
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
PDEVICE_OBJECT NextDeviceObject
Definition: ndis.h:2554
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IRP_MN_START_DEVICE
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
struct _LOGICAL_ADAPTER * PLOGICAL_ADAPTER
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
NTSTATUS NTAPI NdisIForwardIrpAndWait(PLOGICAL_ADAPTER Adapter, PIRP Irp)
Definition: miniport.c:1851
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define MIN_TRACE
Definition: debug.h:14
#define IRP_MN_CANCEL_STOP_DEVICE
NTSTATUS NTAPI NdisIPnPStartDevice(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: miniport.c:1885
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define IRP_MN_QUERY_PNP_DEVICE_STATE

Referenced by NdisGenericIrpHandler().

◆ NdisIForwardIrpAndWait()

NTSTATUS NTAPI NdisIForwardIrpAndWait ( PLOGICAL_ADAPTER  Adapter,
PIRP  Irp 
)

Definition at line 1851 of file miniport.c.

1852 {
1853  KEVENT Event;
1854  NTSTATUS Status;
1855 
1859  TRUE, TRUE, TRUE);
1861  if (Status == STATUS_PENDING)
1862  {
1864  Status = Irp->IoStatus.Status;
1865  }
1866  return Status;
1867 }
#define TRUE
Definition: types.h:120
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS NTAPI NdisIForwardIrpAndWaitCompletionRoutine(PDEVICE_OBJECT Fdo, PIRP Irp, PVOID Context)
Definition: miniport.c:1836
LONG NTSTATUS
Definition: precomp.h:26
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
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
PDEVICE_OBJECT NextDeviceObject
Definition: ndis.h:2554
#define STATUS_PENDING
Definition: ntstatus.h:82
Status
Definition: gdiplustypes.h:24
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218

Referenced by NdisIDispatchPnp().

◆ NdisIForwardIrpAndWaitCompletionRoutine()

NTSTATUS NTAPI NdisIForwardIrpAndWaitCompletionRoutine ( PDEVICE_OBJECT  Fdo,
PIRP  Irp,
PVOID  Context 
)

Definition at line 1836 of file miniport.c.

1840 {
1841  PKEVENT Event = Context;
1842 
1843  if (Irp->PendingReturned)
1845 
1847 }
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:63
_In_ PIRP Irp
Definition: csq.h:116
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
struct tagContext Context
Definition: acpixf.h:1024
#define IO_NO_INCREMENT
Definition: iotypes.h:566

Referenced by NdisIForwardIrpAndWait().

◆ NdisIMGetBindingContext()

NDIS_HANDLE EXPORT NdisIMGetBindingContext ( IN NDIS_HANDLE  NdisBindingHandle)

Definition at line 3376 of file miniport.c.

3384 {
3385  PADAPTER_BINDING AdapterBinding = NdisBindingHandle;
3386  PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
3387 
3388  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
3389 
3390  return Adapter->NdisMiniportBlock.DeviceContext;
3391 }
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
PLOGICAL_ADAPTER Adapter
Definition: protocol.h:29
NDIS_HANDLE DeviceContext
Definition: ndis.h:2515
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
_Must_inspect_result_ _In_ NDIS_HANDLE NdisBindingHandle
Definition: ndis.h:4735

◆ NdisIMGetDeviceContext()

NDIS_HANDLE EXPORT NdisIMGetDeviceContext ( IN NDIS_HANDLE  MiniportAdapterHandle)

Definition at line 3399 of file miniport.c.

3407 {
3409 
3410  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
3411 
3412  return Adapter->NdisMiniportBlock.DeviceContext;
3413 }
_In_ NDIS_HANDLE MiniportAdapterHandle
Definition: ndis.h:4668
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
NDIS_HANDLE DeviceContext
Definition: ndis.h:2515
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40

◆ NdisInitializeWrapper()

VOID EXPORT NdisInitializeWrapper ( OUT PNDIS_HANDLE  NdisWrapperHandle,
IN PVOID  SystemSpecific1,
IN PVOID  SystemSpecific2,
IN PVOID  SystemSpecific3 
)

Definition at line 1591 of file miniport.c.

1606 {
1607  PNDIS_M_DRIVER_BLOCK Miniport;
1609  WCHAR *RegistryBuffer;
1610 
1611  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
1612 
1613  ASSERT(NdisWrapperHandle);
1614 
1615  *NdisWrapperHandle = NULL;
1616 
1617 #if BREAK_ON_MINIPORT_INIT
1618  DbgBreakPoint();
1619 #endif
1620 
1621  Miniport = ExAllocatePool(NonPagedPool, sizeof(NDIS_M_DRIVER_BLOCK));
1622 
1623  if (!Miniport)
1624  {
1625  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1626  return;
1627  }
1628 
1629  RtlZeroMemory(Miniport, sizeof(NDIS_M_DRIVER_BLOCK));
1630 
1631  KeInitializeSpinLock(&Miniport->Lock);
1632 
1633  Miniport->DriverObject = (PDRIVER_OBJECT)SystemSpecific1;
1634 
1635  /* set the miniport's driver registry path */
1637  if(!RegistryPath)
1638  {
1639  ExFreePool(Miniport);
1640  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1641  return;
1642  }
1643 
1645  RegistryPath->MaximumLength = RegistryPath->Length + sizeof(WCHAR); /* room for 0-term */
1646 
1647  RegistryBuffer = ExAllocatePool(PagedPool, RegistryPath->MaximumLength);
1648  if(!RegistryBuffer)
1649  {
1650  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1651  ExFreePool(Miniport);
1653  return;
1654  }
1655 
1657  RegistryBuffer[RegistryPath->Length/sizeof(WCHAR)] = 0;
1658 
1659  RegistryPath->Buffer = RegistryBuffer;
1660  Miniport->RegistryPath = RegistryPath;
1661 
1662  InitializeListHead(&Miniport->DeviceList);
1663 
1664  /* Put miniport in global miniport list */
1666 
1667  *NdisWrapperHandle = Miniport;
1668 }
LIST_ENTRY DeviceList
Definition: miniport.h:25
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
USHORT MaximumLength
Definition: env_spec_w32.h:370
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
void DbgBreakPoint()
Definition: mach.c:553
LIST_ENTRY MiniportListHead
Definition: miniport.c:53
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
KSPIN_LOCK MiniportListLock
Definition: miniport.c:54
KSPIN_LOCK Lock
Definition: miniport.h:21
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
_In_ PVOID _In_ PVOID SystemSpecific2
Definition: ndis.h:637
#define MAX_TRACE
Definition: debug.h:16
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PUNICODE_STRING RegistryPath
Definition: miniport.h:26
LIST_ENTRY ListEntry
Definition: miniport.h:20
UNICODE_STRING * PUNICODE_STRING
Definition: env_spec_w32.h:373
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
PDRIVER_OBJECT DriverObject
Definition: miniport.h:24
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define MIN_TRACE
Definition: debug.h:14
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
struct _DRIVER_OBJECT * PDRIVER_OBJECT
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

◆ NdisIPnPStartDevice()

NTSTATUS NTAPI NdisIPnPStartDevice ( IN PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 1885 of file miniport.c.

1896 {
1899  NDIS_WRAPPER_CONTEXT WrapperContext;
1900  NDIS_STATUS NdisStatus;
1902  NTSTATUS Status;
1904  NDIS_OID AddressOID;
1905  BOOLEAN Success = FALSE;
1907  ULONG ResourceListSize;
1908  UNICODE_STRING ParamName;
1909  PNDIS_CONFIGURATION_PARAMETER ConfigParam;
1910  NDIS_HANDLE ConfigHandle;
1911  ULONG Size;
1913  UINT MaxMulticastAddresses;
1915  PLIST_ENTRY CurrentEntry;
1916  PPROTOCOL_BINDING ProtocolBinding;
1917 
1918  /*
1919  * Prepare wrapper context used by HW and configuration routines.
1920  */
1921 
1922  NDIS_DbgPrint(DEBUG_MINIPORT, ("Start Device %wZ\n", &Adapter->NdisMiniportBlock.MiniportName));
1923 
1924  NDIS_DbgPrint(MAX_TRACE, ("Inserting adapter 0x%x into adapter list\n", Adapter));
1925 
1926  /* Put adapter in global adapter list */
1928 
1931  KEY_ALL_ACCESS, &WrapperContext.RegistryHandle);
1932  if (!NT_SUCCESS(Status))
1933  {
1934  NDIS_DbgPrint(MIN_TRACE,("failed to open adapter-specific reg key\n"));
1936  return Status;
1937  }
1938 
1939  NDIS_DbgPrint(MAX_TRACE, ("opened device reg key\n"));
1940 
1941  WrapperContext.DeviceObject = Adapter->NdisMiniportBlock.DeviceObject;
1942 
1943  /*
1944  * Store the adapter resources used by HW routines such as
1945  * NdisMQueryAdapterResources.
1946  */
1947 
1948  if (Stack->Parameters.StartDevice.AllocatedResources != NULL)
1949  {
1950  ResourceCount = Stack->Parameters.StartDevice.AllocatedResources->List[0].
1951  PartialResourceList.Count;
1952  ResourceListSize =
1953  FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
1954  PartialDescriptors[ResourceCount]);
1955 
1956  Adapter->NdisMiniportBlock.AllocatedResources =
1957  ExAllocatePool(PagedPool, ResourceListSize);
1958  if (Adapter->NdisMiniportBlock.AllocatedResources == NULL)
1959  {
1960  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
1963  }
1964 
1965  Adapter->NdisMiniportBlock.Resources =
1966  ExAllocatePool(PagedPool, ResourceListSize);
1967  if (!Adapter->NdisMiniportBlock.Resources)
1968  {
1969  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
1970  ExFreePool(Adapter->NdisMiniportBlock.AllocatedResources);
1973  }
1974 
1976  Stack->Parameters.StartDevice.AllocatedResources,
1977  ResourceListSize);
1978 
1979  RtlCopyMemory(Adapter->NdisMiniportBlock.AllocatedResources,
1980  Stack->Parameters.StartDevice.AllocatedResources,
1981  ResourceListSize);
1982  }
1983 
1984  if (Stack->Parameters.StartDevice.AllocatedResourcesTranslated != NULL)
1985  {
1986  ResourceCount = Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].
1987  PartialResourceList.Count;
1988  ResourceListSize =
1989  FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
1990  PartialDescriptors[ResourceCount]);
1991 
1992  Adapter->NdisMiniportBlock.AllocatedResourcesTranslated =
1993  ExAllocatePool(PagedPool, ResourceListSize);
1994  if (Adapter->NdisMiniportBlock.AllocatedResourcesTranslated == NULL)
1995  {
1996  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
1999  }
2000 
2001  RtlCopyMemory(Adapter->NdisMiniportBlock.AllocatedResourcesTranslated,
2002  Stack->Parameters.StartDevice.AllocatedResourcesTranslated,
2003  ResourceListSize);
2004  }
2005 
2006  /*
2007  * Store the Bus Type, Bus Number and Slot information. It's used by
2008  * the hardware routines then.
2009  */
2010 
2011  NdisOpenConfiguration(&NdisStatus, &ConfigHandle, (NDIS_HANDLE)&WrapperContext);
2012  if (NdisStatus != NDIS_STATUS_SUCCESS)
2013  {
2014  NDIS_DbgPrint(MIN_TRACE, ("Failed to open configuration key\n"));
2016  return NdisStatus;
2017  }
2018 
2019  Size = sizeof(ULONG);
2022  &Adapter->NdisMiniportBlock.BusType, &Size);
2024  {
2025  NdisInitUnicodeString(&ParamName, L"BusType");
2026  NdisReadConfiguration(&NdisStatus, &ConfigParam, ConfigHandle,
2027  &ParamName, NdisParameterInteger);
2028  if (NdisStatus == NDIS_STATUS_SUCCESS)
2029  Adapter->NdisMiniportBlock.BusType = ConfigParam->ParameterData.IntegerData;
2030  else
2031  Adapter->NdisMiniportBlock.BusType = Isa;
2032  }
2033 
2036  &Adapter->NdisMiniportBlock.BusNumber, &Size);
2037  if (!NT_SUCCESS(Status) || Adapter->NdisMiniportBlock.BusNumber == 0xFFFFFFF0)
2038  {
2039  NdisInitUnicodeString(&ParamName, L"BusNumber");
2040  NdisReadConfiguration(&NdisStatus, &ConfigParam, ConfigHandle,
2041  &ParamName, NdisParameterInteger);
2042  if (NdisStatus == NDIS_STATUS_SUCCESS)
2043  Adapter->NdisMiniportBlock.BusNumber = ConfigParam->ParameterData.IntegerData;
2044  else
2045  Adapter->NdisMiniportBlock.BusNumber = 0;
2046  }
2047  WrapperContext.BusNumber = Adapter->NdisMiniportBlock.BusNumber;
2048 
2051  &Adapter->NdisMiniportBlock.SlotNumber, &Size);
2052  if (!NT_SUCCESS(Status) || Adapter->NdisMiniportBlock.SlotNumber == (NDIS_INTERFACE_TYPE)-1)
2053  {
2054  NdisInitUnicodeString(&ParamName, L"SlotNumber");
2055  NdisReadConfiguration(&NdisStatus, &ConfigParam, ConfigHandle,
2056  &ParamName, NdisParameterInteger);
2057  if (NdisStatus == NDIS_STATUS_SUCCESS)
2058  Adapter->NdisMiniportBlock.SlotNumber = ConfigParam->ParameterData.IntegerData;
2059  else
2060  Adapter->NdisMiniportBlock.SlotNumber = 0;
2061  }
2062  else
2063  {
2064  /* Convert slotnumber to PCI_SLOT_NUMBER */
2065  ULONG PciSlotNumber = Adapter->NdisMiniportBlock.SlotNumber;
2067 
2068  SlotNumber.u.AsULONG = 0;
2069  SlotNumber.u.bits.DeviceNumber = (PciSlotNumber >> 16) & 0xFFFF;
2070  SlotNumber.u.bits.FunctionNumber = PciSlotNumber & 0xFFFF;
2071 
2072  Adapter->NdisMiniportBlock.SlotNumber = SlotNumber.u.AsULONG;
2073  }
2074  WrapperContext.SlotNumber = Adapter->NdisMiniportBlock.SlotNumber;
2075 
2076  NdisCloseConfiguration(ConfigHandle);
2077 
2078  /* Set handlers (some NDIS macros require these) */
2091 
2092  /*
2093  * Call MiniportInitialize.
2094  */
2095 
2096  NDIS_DbgPrint(MID_TRACE, ("calling MiniportInitialize\n"));
2097  NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.InitializeHandler)(
2099  MEDIA_ARRAY_SIZE, Adapter, (NDIS_HANDLE)&WrapperContext);
2100 
2101  ZwClose(WrapperContext.RegistryHandle);
2102 
2103  if (NdisStatus != NDIS_STATUS_SUCCESS)
2104  {
2105  NDIS_DbgPrint(MIN_TRACE, ("MiniportInitialize() failed for an adapter (%lx).\n", NdisStatus));
2107  if (Adapter->NdisMiniportBlock.Interrupt)
2108  {
2109  KeBugCheckEx(BUGCODE_ID_DRIVER,
2110  (ULONG_PTR)Adapter,
2111  (ULONG_PTR)Adapter->NdisMiniportBlock.Interrupt,
2112  (ULONG_PTR)Adapter->NdisMiniportBlock.TimerQueue,
2113  1);
2114  }
2115  if (Adapter->NdisMiniportBlock.TimerQueue)
2116  {
2117  KeBugCheckEx(BUGCODE_ID_DRIVER,
2118  (ULONG_PTR)Adapter,
2119  (ULONG_PTR)Adapter->NdisMiniportBlock.Interrupt,
2120  (ULONG_PTR)Adapter->NdisMiniportBlock.TimerQueue,
2121  1);
2122  }
2123  return NdisStatus;
2124  }
2125 
2127  {
2128  NDIS_DbgPrint(MIN_TRACE, ("MiniportInitialize() selected a bad index\n"));
2131  }
2132 
2134 
2135  switch (Adapter->NdisMiniportBlock.MediaType)
2136  {
2137  case NdisMedium802_3:
2138  Adapter->MediumHeaderSize = 14; /* XXX figure out what to do about LLC */
2139  AddressOID = OID_802_3_CURRENT_ADDRESS;
2141  NdisStatus = DoQueries(Adapter, AddressOID);
2142  if (NdisStatus == NDIS_STATUS_SUCCESS)
2143  {
2144  NdisStatus = MiniQueryInformation(Adapter, OID_802_3_MAXIMUM_LIST_SIZE, sizeof(UINT),
2145  &MaxMulticastAddresses, &BytesWritten);
2146 
2147  if (NdisStatus != NDIS_STATUS_SUCCESS)
2148  {
2150  NDIS_DbgPrint(MIN_TRACE, ("MiniQueryInformation failed (%x)\n", NdisStatus));
2151  return NdisStatus;
2152  }
2153 
2154  Success = EthCreateFilter(MaxMulticastAddresses,
2155  Adapter->Address.Type.Medium802_3,
2156  &Adapter->NdisMiniportBlock.EthDB);
2157  if (Success)
2158  ((PETHI_FILTER)Adapter->NdisMiniportBlock.EthDB)->Miniport = (PNDIS_MINIPORT_BLOCK)Adapter;
2159  else
2160  NdisStatus = NDIS_STATUS_RESOURCES;
2161  }
2162  break;
2163 
2164  default:
2165  /* FIXME: Support other types of media */
2166  NDIS_DbgPrint(MIN_TRACE, ("error: unsupported media\n"));
2167  ASSERT(FALSE);
2169  return STATUS_UNSUCCESSFUL;
2170  }
2171 
2172  if (NdisStatus != NDIS_STATUS_SUCCESS)
2173  {
2174  NDIS_DbgPrint(MIN_TRACE, ("couldn't create filter (%x)\n", NdisStatus));
2175  return NdisStatus;
2176  }
2177 
2178  /* Check for a hang every two seconds if it wasn't set in MiniportInitialize */
2179  if (Adapter->NdisMiniportBlock.CheckForHangSeconds == 0)
2181 
2182  Adapter->NdisMiniportBlock.OldPnPDeviceState = Adapter->NdisMiniportBlock.PnPDeviceState;
2183  Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceStarted;
2184 
2186 
2187  Timeout.QuadPart = Int32x32To64(Adapter->NdisMiniportBlock.CheckForHangSeconds, -1000000);
2189  Adapter->NdisMiniportBlock.CheckForHangSeconds * 1000,
2191 
2192  /* Put adapter in adapter list for this miniport */
2194 
2195  /* Refresh bindings for all protocols */
2196  CurrentEntry = ProtocolListHead.Flink;
2197  while (CurrentEntry != &ProtocolListHead)
2198  {
2199  ProtocolBinding = CONTAINING_RECORD(CurrentEntry, PROTOCOL_BINDING, ListEntry);
2200 
2201  ndisBindMiniportsToProtocol(&NdisStatus, ProtocolBinding);
2202 
2203  CurrentEntry = CurrentEntry->Flink;
2204  }
2205 
2206  return STATUS_SUCCESS;
2207 }
LIST_ENTRY DeviceList
Definition: miniport.h:25
LIST_ENTRY MiniportListEntry
Definition: miniport.h:93
NDIS_M_REQ_COMPLETE_HANDLER QueryCompleteHandler
Definition: ndis.h:2585
NDIS_M_TD_COMPLETE_HANDLER TDCompleteHandler
Definition: ndis.h:2584
#define ExInterlockedRemoveEntryList(_List, _Lock)
Definition: ndissys.h:37
PDEVICE_OBJECT PhysicalDeviceObject
Definition: ndis.h:2553
_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 TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define MID_TRACE
Definition: debug.h:15
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics
Definition: miniport.h:22
PNDIS_MINIPORT_TIMER TimerQueue
Definition: ndis.h:2564
enum _INTERFACE_TYPE INTERFACE_TYPE
NDIS_STATUS DoQueries(PLOGICAL_ADAPTER Adapter, NDIS_OID AddressOID)
Definition: miniport.c:1746
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS OpenErrorStatus
Definition: ndis.h:6008
VOID NTAPI EthFilterDprIndicateReceiveComplete(IN PETH_FILTER Filter)
Definition: efilter.c:113
_In_ PIRP Irp
Definition: csq.h:116
LIST_ENTRY ProtocolListHead
Definition: protocol.c:19
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
VOID EXPORT NdisOpenConfiguration(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE ConfigurationHandle, IN NDIS_HANDLE WrapperConfigurationContext)
Definition: config.c:197
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
LONG NTSTATUS
Definition: precomp.h:26
ULONG NDIS_OID
Definition: ntddndis.h:230
BOOLEAN NTAPI KeSetTimerEx(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN LONG Period, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:294
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT SelectedMediumIndex
Definition: ndis.h:6008
union _HARDWARE_ADDRESS::@974 Type
#define NDIS_STATUS_UNSUPPORTED_MEDIA
Definition: ndis.h:490
#define DEBUG_MINIPORT
Definition: debug.h:17
NDIS_M_REQ_COMPLETE_HANDLER SetCompleteHandler
Definition: ndis.h:2586
VOID NTAPI EthFilterDprIndicateReceive(IN PETH_FILTER Filter, IN NDIS_HANDLE MacReceiveContext, IN PCHAR Address, IN PVOID HeaderBuffer, IN UINT HeaderBufferSize, IN PVOID LookaheadBuffer, IN UINT LookaheadBufferSize, IN UINT PacketSize)
Definition: efilter.c:69
int NDIS_STATUS
Definition: ntddndis.h:471
uint32_t ULONG_PTR
Definition: typedefs.h:63
HARDWARE_ADDRESS Address
Definition: miniport.h:96
FILTERDBS_S FILTER_PACKET_INDICATION_HANDLER PacketIndicateHandler
Definition: ndis.h:2544
#define OID_802_3_MAXIMUM_LIST_SIZE
Definition: ntddndis.h:305
#define MEDIA_ARRAY_SIZE
Definition: miniport.c:31
ETH_RCV_COMPLETE_HANDLER EthRxCompleteHandler
Definition: ndis.h:2579
VOID NTAPI MiniResetComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status, IN BOOLEAN AddressingReset)
Definition: miniport.c:435
VOID EXPORT NdisReadConfiguration(OUT PNDIS_STATUS Status, OUT PNDIS_CONFIGURATION_PARAMETER *ParameterValue, IN NDIS_HANDLE ConfigurationHandle, IN PNDIS_STRING Keyword, IN NDIS_PARAMETER_TYPE ParameterType)
Definition: config.c:414
VOID NTAPI MiniTransferDataComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status, IN UINT BytesTransferred)
Definition: miniport.c:592
VOID NTAPI MiniStatus(IN NDIS_HANDLE MiniportHandle, IN NDIS_STATUS GeneralStatus, IN PVOID StatusBuffer, IN UINT StatusBufferSize)
Definition: miniport.c:1384
PNDIS_MINIPORT_INTERRUPT Interrupt
Definition: ndis.h:2522
W_SEND_PACKETS_HANDLER SendPacketsHandler
Definition: ndis.h:2574
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
NDIS_M_SEND_RESOURCES_HANDLER SendResourcesHandler
Definition: ndis.h:2546
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:4228
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
ULONG AddressLength
Definition: miniport.h:97
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
VOID EXPORT NdisCloseConfiguration(IN NDIS_HANDLE ConfigurationHandle)
Definition: config.c:136
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
VOID NTAPI MiniRequestComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status)
Definition: miniport.c:481
NDIS_MEDIUM MediaType
Definition: ndis.h:2548
VOID NTAPI MiniIndicateReceivePacket(IN NDIS_HANDLE MiniportAdapterHandle, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets)
Definition: miniport.c:293
LIST_ENTRY List
Definition: psmgr.c:57
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
KDPC Dpc
Definition: ndis.h:644
VOID NTAPI MiniSendResourcesAvailable(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:583
ULONG CheckForHangSeconds
Definition: ndis.h:2538
NDIS_M_STS_COMPLETE_HANDLER StatusCompleteHandler
Definition: ndis.h:2583
LIST_ENTRY ListEntry
Definition: miniport.h:92
KSPIN_LOCK Lock
Definition: miniport.h:21
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG _In_ ULONG SlotNumber
Definition: halfuncs.h:156
static ULONG ResourceCount
Definition: inbv.c:95
PCM_RESOURCE_LIST Resources
Definition: ndis.h:2534
VOID NTAPI MiniSendComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status)
Definition: miniport.c:530
VOID EXPORT NdisInitUnicodeString(IN OUT PNDIS_STRING DestinationString, IN PCWSTR SourceString)
Definition: string.c:130
VOID NTAPI MiniStatusComplete(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:1417
static const WCHAR L[]
Definition: oid.c:1250
struct _LOGICAL_ADAPTER * PLOGICAL_ADAPTER
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
VOID NTAPI ProSendPackets(IN NDIS_HANDLE NdisBindingHandle, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets)
Definition: protocol.c:577
#define PLUGPLAY_REGKEY_DRIVER
Definition: usbd.c:42
UNICODE_STRING MiniportName
Definition: ndis.h:2511
Definition: typedefs.h:117
struct _NDIS_MINIPORT_BLOCK * PNDIS_MINIPORT_BLOCK
Definition: ndis.h:319
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
BOOLEAN NTAPI EthCreateFilter(IN UINT MaximumMulticastAddresses, IN PUCHAR AdapterAddress, OUT PETH_FILTER *Filter)
Definition: efilter.c:16
NDIS_STATUS MiniQueryInformation(PLOGICAL_ADAPTER Adapter, NDIS_OID Oid, ULONG Size, PVOID Buffer, PULONG BytesWritten)
Definition: miniport.c:805
KSPIN_LOCK AdapterListLock
Definition: miniport.c:58
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
VOID NTAPI ndisBindMiniportsToProtocol(OUT PNDIS_STATUS Status, IN PPROTOCOL_BINDING Protocol)
Definition: protocol.c:908
static ULONG Timeout
Definition: ping.c:61
KTIMER Timer
Definition: ndis.h:643
#define MAX_TRACE
Definition: debug.h:16
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
PDEVICE_OBJECT DeviceObject
Definition: ndis.h:2552
#define ETH_LENGTH_OF_ADDRESS
Definition: efilter.h:16
unsigned int UINT
Definition: ndis.h:50
NDIS_M_SEND_COMPLETE_HANDLER SendCompleteHandler
Definition: ndis.h:2545
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:4583
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
NDIS_M_RESET_COMPLETE_HANDLER ResetCompleteHandler
Definition: ndis.h:2547
enum _NDIS_INTERFACE_TYPE NDIS_INTERFACE_TYPE
NDIS_TIMER WakeUpDpcTimer
Definition: ndis.h:2535
UNICODE_STRING SymbolicLinkName
Definition: ndis.h:2537
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
unsigned int ULONG
Definition: retypes.h:1
LIST_ENTRY AdapterListHead
Definition: miniport.c:57
ETH_RCV_INDICATE_HANDLER EthRxIndicateHandler
Definition: ndis.h:2576
#define MIN_TRACE
Definition: debug.h:14
#define OID_802_3_CURRENT_ADDRESS
Definition: ntddndis.h:303
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
ULONG MediumHeaderSize
Definition: miniport.h:95
return STATUS_SUCCESS
Definition: btrfs.c:2966
PNDIS_M_DRIVER_BLOCK DriverHandle
Definition: ndis.h:2509
NDIS_INTERFACE_TYPE BusType
Definition: ndis.h:2550
UCHAR Medium802_3[ETH_LENGTH_OF_ADDRESS]
Definition: miniport.h:14
#define Int32x32To64(a, b)
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:107
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
static NDIS_MEDIUM MediaArray[MEDIA_ARRAY_SIZE]
Definition: miniport.c:33
struct ETHI_FILTER * PETHI_FILTER
NDIS_M_STATUS_HANDLER StatusHandler
Definition: ndis.h:2582

Referenced by NdisIDispatchPnp().

◆ NdisIPnPStopDevice()

NTSTATUS NTAPI NdisIPnPStopDevice ( IN PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 2211 of file miniport.c.

2222 {
2224 
2225  /* Remove adapter from adapter list for this miniport */
2227 
2228  /* Remove adapter from global adapter list */
2230 
2232 
2233  /* Set this here so MiniportISR will be forced to run for interrupts generated in MiniportHalt */
2234  Adapter->NdisMiniportBlock.OldPnPDeviceState = Adapter->NdisMiniportBlock.PnPDeviceState;
2235  Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceStopped;
2236 
2237  (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.HaltHandler)(Adapter);
2238 
2240 
2241  if (Adapter->NdisMiniportBlock.AllocatedResources)
2242  {
2243  ExFreePool(Adapter->NdisMiniportBlock.AllocatedResources);
2244  Adapter->NdisMiniportBlock.AllocatedResources = NULL;
2245  }
2246  if (Adapter->NdisMiniportBlock.AllocatedResourcesTranslated)
2247  {
2248  ExFreePool(Adapter->NdisMiniportBlock.AllocatedResourcesTranslated);
2249  Adapter->NdisMiniportBlock.AllocatedResourcesTranslated = NULL;
2250  }
2251 
2252  if (Adapter->NdisMiniportBlock.Resources)
2253  {
2255  Adapter->NdisMiniportBlock.Resources = NULL;
2256  }
2257 
2258  if (Adapter->NdisMiniportBlock.EthDB)
2259  {
2260  EthDeleteFilter(Adapter->NdisMiniportBlock.EthDB);
2261  Adapter->NdisMiniportBlock.EthDB = NULL;
2262  }
2263 
2264  return STATUS_SUCCESS;
2265 }
LIST_ENTRY MiniportListEntry
Definition: miniport.h:93
#define ExInterlockedRemoveEntryList(_List, _Lock)
Definition: ndissys.h:37
NDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics
Definition: miniport.h:22
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
LIST_ENTRY ListEntry
Definition: miniport.h:92
KSPIN_LOCK Lock
Definition: miniport.h:21
PCM_RESOURCE_LIST Resources
Definition: ndis.h:2534
struct _LOGICAL_ADAPTER * PLOGICAL_ADAPTER
KSPIN_LOCK AdapterListLock
Definition: miniport.c:58
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
VOID NTAPI EthDeleteFilter(IN PETH_FILTER Filter)
Definition: efilter.c:57
KTIMER Timer
Definition: ndis.h:643
NDIS_TIMER WakeUpDpcTimer
Definition: ndis.h:2535
UNICODE_STRING SymbolicLinkName
Definition: ndis.h:2537
return STATUS_SUCCESS
Definition: btrfs.c:2966
PNDIS_M_DRIVER_BLOCK DriverHandle
Definition: ndis.h:2509
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by NdisIDispatchPnp().

◆ NdisIPower()

NTSTATUS NTAPI NdisIPower ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp 
)

Definition at line 2407 of file miniport.c.

2410 {
2412 
2416 }
NTSTATUS NTAPI PoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: power.c:485
_In_ PIRP Irp
Definition: csq.h:116
PVOID DeviceExtension
Definition: env_spec_w32.h:418
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
PDEVICE_OBJECT NextDeviceObject
Definition: ndis.h:2554
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:626
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421

Referenced by NdisGenericIrpHandler().

◆ NdisIShutdown()

NTSTATUS NTAPI NdisIShutdown ( IN PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 2269 of file miniport.c.

2272 {
2276 
2278 
2279  ShutdownHandler(Context->DriverContext);
2280 
2281  Irp->IoStatus.Status = STATUS_SUCCESS;
2282  Irp->IoStatus.Information = 0;
2283 
2285 
2286  return