ReactOS  0.4.13-dev-259-g5ca9c9c
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

VOID MiniDisplayPacket (PNDIS_PACKET Packet, PCSTR Reason)
 
VOID MiniDisplayPacket2 (PVOID HeaderBuffer, UINT HeaderBufferSize, PVOID LookaheadBuffer, UINT LookaheadBufferSize)
 
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 1745 of file miniport.c.

1756 {
1758  NDIS_STATUS NdisStatus;
1759 
1760  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
1761 
1762  /* Get MAC options for adapter */
1763  NdisStatus = MiniQueryInformation(Adapter, OID_GEN_MAC_OPTIONS, sizeof(UINT),
1764  &Adapter->NdisMiniportBlock.MacOptions,
1765  &BytesWritten);
1766 
1767  if (NdisStatus != NDIS_STATUS_SUCCESS)
1768  {
1769  NDIS_DbgPrint(MIN_TRACE, ("OID_GEN_MAC_OPTIONS failed. NdisStatus (0x%X).\n", NdisStatus));
1770  return NdisStatus;
1771  }
1772 
1773  NDIS_DbgPrint(DEBUG_MINIPORT, ("MacOptions (0x%X).\n", Adapter->NdisMiniportBlock.MacOptions));
1774 
1775  /* Get current hardware address of adapter */
1776  NdisStatus = MiniQueryInformation(Adapter, AddressOID, Adapter->AddressLength,
1777  &Adapter->Address, &BytesWritten);
1778 
1779  if (NdisStatus != NDIS_STATUS_SUCCESS)
1780  {
1781  NDIS_DbgPrint(MIN_TRACE, ("Address OID (0x%X) failed. NdisStatus (0x%X).\n", AddressOID, NdisStatus));
1782  return NdisStatus;
1783  }
1784 
1785 #if DBG
1786  {
1787  /* 802.3 only */
1788 
1789  PUCHAR A = (PUCHAR)&Adapter->Address.Type.Medium802_3;
1790 
1791  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]));
1792  }
1793 #endif /* DBG */
1794 
1795  /* Get maximum lookahead buffer size of adapter */
1796  NdisStatus = MiniQueryInformation(Adapter, OID_GEN_MAXIMUM_LOOKAHEAD, sizeof(ULONG),
1798 
1799  if (NdisStatus != NDIS_STATUS_SUCCESS)
1800  {
1801  NDIS_DbgPrint(MIN_TRACE, ("OID_GEN_MAXIMUM_LOOKAHEAD failed. NdisStatus (0x%X).\n", NdisStatus));
1802  return NdisStatus;
1803  }
1804 
1805  NDIS_DbgPrint(DEBUG_MINIPORT, ("MaxLookaheadLength (0x%X).\n", Adapter->NdisMiniportBlock.MaximumLookahead));
1806 
1807  /* Get current lookahead buffer size of adapter */
1808  NdisStatus = MiniQueryInformation(Adapter, OID_GEN_CURRENT_LOOKAHEAD, sizeof(ULONG),
1810 
1811  if (NdisStatus != NDIS_STATUS_SUCCESS)
1812  {
1813  NDIS_DbgPrint(MIN_TRACE, ("OID_GEN_CURRENT_LOOKAHEAD failed. NdisStatus (0x%X).\n", NdisStatus));
1814  return NdisStatus;
1815  }
1816 
1817  NdisStatus = MiniQueryInformation(Adapter, OID_GEN_MAXIMUM_SEND_PACKETS, sizeof(ULONG),
1819 
1820  if (NdisStatus != NDIS_STATUS_SUCCESS)
1821  {
1822  NDIS_DbgPrint(MIN_TRACE, ("OID_GEN_MAXIMUM_SEND_PACKETS failed. NdisStatus (0x%X).\n", NdisStatus));
1823 
1824  /* Set it to 1 if it fails because some drivers don't support this (?)*/
1825  Adapter->NdisMiniportBlock.MaxSendPackets = 1;
1826  }
1827 
1828  NDIS_DbgPrint(DEBUG_MINIPORT, ("CurLookaheadLength (0x%X).\n", Adapter->NdisMiniportBlock.CurrentLookahead));
1829 
1830  return STATUS_SUCCESS;
1831 }
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:225
#define DEBUG_MINIPORT
Definition: debug.h:17
int NDIS_STATUS
Definition: ntddndis.h:445
HARDWARE_ADDRESS Address
Definition: miniport.h:96
#define OID_GEN_MAXIMUM_LOOKAHEAD
Definition: ntddndis.h:211
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:804
#define OID_GEN_MAXIMUM_SEND_PACKETS
Definition: ntddndis.h:227
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:2745
UCHAR Medium802_3[ETH_LENGTH_OF_ADDRESS]
Definition: miniport.h:14
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:221
union _HARDWARE_ADDRESS::@965 Type

Referenced by NdisIPnPStartDevice().

◆ MiniAdapterHasAddress()

BOOLEAN MiniAdapterHasAddress ( PLOGICAL_ADAPTER  Adapter,
PNDIS_PACKET  Packet 
)

Definition at line 615 of file miniport.c.

626 {
627  UINT Length;
628  PUCHAR PacketAddress;
629  PUCHAR AdapterAddress;
630  PNDIS_BUFFER NdisBuffer;
632 
633  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
634 
635 #if DBG
636  if(!Adapter)
637  {
638  NDIS_DbgPrint(MIN_TRACE, ("Adapter object was null\n"));
639  return FALSE;
640  }
641 
642  if(!Packet)
643  {
644  NDIS_DbgPrint(MIN_TRACE, ("Packet was null\n"));
645  return FALSE;
646  }
647 #endif
648 
649  NdisQueryPacket(Packet, NULL, NULL, &NdisBuffer, NULL);
650 
651  if (!NdisBuffer)
652  {
653  NDIS_DbgPrint(MIN_TRACE, ("Packet contains no buffers.\n"));
654  return FALSE;
655  }
656 
657  NdisQueryBuffer(NdisBuffer, (PVOID)&PacketAddress, &BufferLength);
658 
659  /* FIXME: Should handle fragmented packets */
660 
661  switch (Adapter->NdisMiniportBlock.MediaType)
662  {
663  case NdisMedium802_3:
665  /* Destination address is the first field */
666  break;
667 
668  default:
669  NDIS_DbgPrint(MIN_TRACE, ("Adapter has unsupported media type (0x%X).\n", Adapter->NdisMiniportBlock.MediaType));
670  return FALSE;
671  }
672 
673  if (BufferLength < Length)
674  {
675  NDIS_DbgPrint(MIN_TRACE, ("Buffer is too small.\n"));
676  return FALSE;
677  }
678 
679  AdapterAddress = (PUCHAR)&Adapter->Address;
680  NDIS_DbgPrint(MAX_TRACE, ("packet address: %x:%x:%x:%x:%x:%x adapter address: %x:%x:%x:%x:%x:%x\n",
681  *(PacketAddress), *(PacketAddress+1), *(PacketAddress+2), *(PacketAddress+3), *(PacketAddress+4), *(PacketAddress+5),
682  *(AdapterAddress), *(AdapterAddress+1), *(AdapterAddress+2), *(AdapterAddress+3), *(AdapterAddress+4), *(AdapterAddress+5)));
683 
684  return (RtlCompareMemory(PacketAddress, AdapterAddress, Length) == Length);
685 }
_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 864 of file miniport.c.

873 {
874  BOOLEAN Ret = FALSE;
875  KIRQL OldIrql;
876 
878  if (Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CheckForHangHandler)
879  Ret = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CheckForHangHandler)(
882 
883  return Ret;
884 }
#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 1049 of file miniport.c.

1065 {
1066  PNDIS_MINIPORT_WORK_ITEM MiniportWorkItem;
1068 
1069  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
1070 
1071  MiniportWorkItem = Adapter->WorkQueueHead;
1072 
1073  if ((Packet = Adapter->NdisMiniportBlock.FirstPendingPacket))
1074  {
1076 
1077  *WorkItemType = NdisWorkItemSend;
1078  *WorkItemContext = Packet;
1079 
1080  return NDIS_STATUS_SUCCESS;
1081  }
1082  else if (MiniportWorkItem)
1083  {
1084  /* safe due to adapter lock held */
1085  Adapter->WorkQueueHead = (PNDIS_MINIPORT_WORK_ITEM)MiniportWorkItem->Link.Next;
1086 
1087  if (MiniportWorkItem == Adapter->WorkQueueTail)
1088  Adapter->WorkQueueTail = NULL;
1089 
1090  *WorkItemType = MiniportWorkItem->WorkItemType;
1091  *WorkItemContext = MiniportWorkItem->WorkItemContext;
1092 
1093  ExFreePool(MiniportWorkItem);
1094 
1095  return NDIS_STATUS_SUCCESS;
1096  }
1097  else
1098  {
1099  NDIS_DbgPrint(MIN_TRACE, ("No work item to dequeue\n"));
1100 
1101  return NDIS_STATUS_FAILURE;
1102  }
1103 }
_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().

◆ MiniDisplayPacket()

VOID MiniDisplayPacket ( PNDIS_PACKET  Packet,
PCSTR  Reason 
)

Definition at line 61 of file miniport.c.

64 {
65 #if DBG
66  ULONG i, Length;
67  UCHAR Buffer[64];
68  if ((DebugTraceLevel & DEBUG_PACKET) > 0) {
70  Buffer,
71  Packet,
72  0,
73  64);
74 
75  DbgPrint("*** %s PACKET START (%p) ***\n", Reason, Packet);
76 
77  for (i = 0; i < Length; i++) {
78  if (i % 16 == 0)
79  DbgPrint("\n%04X ", i);
80  DbgPrint("%02X ", Buffer[i]);
81  }
82 
83  DbgPrint("\n*** %s PACKET STOP ***\n", Reason);
84  }
85 #endif /* DBG */
86 }
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
#define DbgPrint
Definition: loader.c:25
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
Definition: bufpool.h:45
ULONG DebugTraceLevel
Definition: ndis.c:13
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned char UCHAR
Definition: xmlstorage.h:181
UINT CopyPacketToBuffer(PUCHAR DstData, PNDIS_PACKET SrcPacket, UINT SrcOffset, UINT Length)
Definition: buffer.c:170
#define DEBUG_PACKET
Definition: debug.h:19
unsigned int ULONG
Definition: retypes.h:1
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:45

Referenced by ProIndicatePacket(), and proSendPacketToMiniport().

◆ MiniDisplayPacket2()

VOID MiniDisplayPacket2 ( PVOID  HeaderBuffer,
UINT  HeaderBufferSize,
PVOID  LookaheadBuffer,
UINT  LookaheadBufferSize 
)

Definition at line 89 of file miniport.c.

94 {
95 #if DBG
96  if ((DebugTraceLevel & DEBUG_PACKET) > 0) {
97  ULONG i, Length;
98  PUCHAR p;
99 
100  DbgPrint("*** RECEIVE PACKET START ***\n");
101  DbgPrint("HEADER:");
102  p = HeaderBuffer;
103  for (i = 0; i < HeaderBufferSize; i++) {
104  if (i % 16 == 0)
105  DbgPrint("\n%04X ", i);
106  DbgPrint("%02X ", *p++);
107  }
108 
109  DbgPrint("\nFRAME:");
110 
111  p = LookaheadBuffer;
112  Length = (LookaheadBufferSize < 64)? LookaheadBufferSize : 64;
113  for (i = 0; i < Length; i++) {
114  if (i % 16 == 0)
115  DbgPrint("\n%04X ", i);
116  DbgPrint("%02X ", *p++);
117  }
118 
119  DbgPrint("\n*** RECEIVE PACKET STOP ***\n");
120  }
121 #endif /* DBG */
122 }
#define DbgPrint
Definition: loader.c:25
unsigned char * PUCHAR
Definition: retypes.h:3
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
ULONG DebugTraceLevel
Definition: ndis.c:13
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define DEBUG_PACKET
Definition: debug.h:19
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by MiniIndicateData().

◆ MiniDoAddressingReset()

VOID MiniDoAddressingReset ( PLOGICAL_ADAPTER  Adapter)

Definition at line 887 of file miniport.c.

888 {
890 
891  MiniSetInformation(Adapter,
893  sizeof(ULONG),
895  &BytesRead);
896 
897  /* FIXME: Set more stuff */
898 }
NDIS_STATUS MiniSetInformation(PLOGICAL_ADAPTER Adapter, NDIS_OID Oid, ULONG Size, PVOID Buffer, PULONG BytesRead)
Definition: miniport.c:755
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:221
_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 1106 of file miniport.c.

1117 {
1119  KIRQL OldIrql;
1120  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
1121 
1123 
1127 
1128  if (!Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CoRequestHandler)
1129  {
1130  switch (NdisRequest->RequestType)
1131  {
1133  Status = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
1135  NdisRequest->DATA.QUERY_INFORMATION.Oid,
1136  NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer,
1137  NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength,
1138  (PULONG)&NdisRequest->DATA.QUERY_INFORMATION.BytesWritten,
1139  (PULONG)&NdisRequest->DATA.QUERY_INFORMATION.BytesNeeded);
1140  break;
1141 
1143  Status = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SetInformationHandler)(
1145  NdisRequest->DATA.SET_INFORMATION.Oid,
1146  NdisRequest->DATA.SET_INFORMATION.InformationBuffer,
1147  NdisRequest->DATA.SET_INFORMATION.InformationBufferLength,
1148  (PULONG)&NdisRequest->DATA.SET_INFORMATION.BytesRead,
1149  (PULONG)&NdisRequest->DATA.SET_INFORMATION.BytesNeeded);
1150  break;
1151 
1152  default:
1153  NDIS_DbgPrint(MIN_TRACE, ("Bad request type\n"));
1155  }
1156  }
1157  else
1158  {
1159  Status = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CoRequestHandler)(
1161  NULL, /* FIXME */
1162  NdisRequest);
1163  }
1164 
1165  if (Status != NDIS_STATUS_PENDING) {
1169  }
1170 
1172 
1173  if (Status != NDIS_STATUS_PENDING) {
1175  }
1176 
1177  return Status;
1178 }
#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:963
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:445
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 125 of file miniport.c.

128 {
129  PNDIS_MINIPORT_WORK_ITEM CurrentEntry = Adapter->WorkQueueHead;
130 
131  while (CurrentEntry)
132  {
133  if (CurrentEntry->WorkItemType == Type || Type == NdisMaxWorkItems)
134  return CurrentEntry;
135 
136  CurrentEntry = (PNDIS_MINIPORT_WORK_ITEM)CurrentEntry->Link.Next;
137  }
138 
139  return NULL;
140 }
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 176 of file miniport.c.

195 {
196  KIRQL OldIrql;
197  PLIST_ENTRY CurrentEntry;
198  PADAPTER_BINDING AdapterBinding;
199 
200  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called. Adapter (0x%X) HeaderBuffer (0x%X) "
201  "HeaderBufferSize (0x%X) LookaheadBuffer (0x%X) LookaheadBufferSize (0x%X).\n",
202  Adapter, HeaderBuffer, HeaderBufferSize, LookaheadBuffer, LookaheadBufferSize));
203 
204  MiniDisplayPacket2(HeaderBuffer, HeaderBufferSize, LookaheadBuffer, LookaheadBufferSize);
205 
206  NDIS_DbgPrint(MAX_TRACE, ("acquiring miniport block lock\n"));
208  {
209  CurrentEntry = Adapter->ProtocolListHead.Flink;
210  NDIS_DbgPrint(DEBUG_MINIPORT, ("CurrentEntry = %x\n", CurrentEntry));
211 
212  if (CurrentEntry == &Adapter->ProtocolListHead)
213  {
214  NDIS_DbgPrint(MIN_TRACE, ("WARNING: No upper protocol layer.\n"));
215  }
216 
217  while (CurrentEntry != &Adapter->ProtocolListHead)
218  {
219  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
220  NDIS_DbgPrint(DEBUG_MINIPORT, ("AdapterBinding = %x\n", AdapterBinding));
221 
223  (MID_TRACE,
224  ("XXX (%x) %x %x %x %x %x %x %x XXX\n",
225  *AdapterBinding->ProtocolBinding->Chars.ReceiveHandler,
226  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
227  MacReceiveContext,
228  HeaderBuffer,
229  HeaderBufferSize,
230  LookaheadBuffer,
231  LookaheadBufferSize,
232  PacketSize));
233 
234  /* call the receive handler */
235  (*AdapterBinding->ProtocolBinding->Chars.ReceiveHandler)(
236  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
237  MacReceiveContext,
238  HeaderBuffer,
239  HeaderBufferSize,
240  LookaheadBuffer,
241  LookaheadBufferSize,
242  PacketSize);
243 
244  CurrentEntry = CurrentEntry->Flink;
245  }
246  }
248 
249  NDIS_DbgPrint(MAX_TRACE, ("Leaving.\n"));
250 }
#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
VOID MiniDisplayPacket2(PVOID HeaderBuffer, UINT HeaderBufferSize, PVOID LookaheadBuffer, UINT LookaheadBufferSize)
Definition: miniport.c:89
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 292 of file miniport.c.

304 {
306  PLIST_ENTRY CurrentEntry;
307  PADAPTER_BINDING AdapterBinding;
308  KIRQL OldIrql;
309  UINT i;
310 
312 
313  CurrentEntry = Adapter->ProtocolListHead.Flink;
314 
315  while (CurrentEntry != &Adapter->ProtocolListHead)
316  {
317  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
318 
319  for (i = 0; i < NumberOfPackets; i++)
320  {
321  /* Store the indicating miniport in the packet */
322  PacketArray[i]->Reserved[1] = (ULONG_PTR)Adapter;
323 
324  if (AdapterBinding->ProtocolBinding->Chars.ReceivePacketHandler &&
326  {
327  NDIS_DbgPrint(MID_TRACE, ("Indicating packet to protocol's ReceivePacket handler\n"));
329  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
330  PacketArray[i]);
331  NDIS_DbgPrint(MID_TRACE, ("Protocol is holding %d references to the packet\n", PacketArray[i]->WrapperReserved[0]));
332  }
333  else
334  {
335  UINT FirstBufferLength, TotalBufferLength, LookAheadSize, HeaderSize;
336  PNDIS_BUFFER NdisBuffer;
337  PVOID NdisBufferVA, LookAheadBuffer;
338 
340  &NdisBuffer,
341  &NdisBufferVA,
342  &FirstBufferLength,
343  &TotalBufferLength);
344 
346 
347  LookAheadSize = TotalBufferLength - HeaderSize;
348 
349  LookAheadBuffer = ExAllocatePool(NonPagedPool, LookAheadSize);
350  if (!LookAheadBuffer)
351  {
352  NDIS_DbgPrint(MIN_TRACE, ("Failed to allocate lookahead buffer!\n"));
354  return;
355  }
356 
357  CopyBufferChainToBuffer(LookAheadBuffer,
358  NdisBuffer,
359  HeaderSize,
360  LookAheadSize);
361 
362  NDIS_DbgPrint(MID_TRACE, ("Indicating packet to protocol's legacy Receive handler\n"));
363  (*AdapterBinding->ProtocolBinding->Chars.ReceiveHandler)(
364  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
365  AdapterBinding->NdisOpenBlock.MacHandle,
366  NdisBufferVA,
367  HeaderSize,
368  LookAheadBuffer,
369  LookAheadSize,
370  TotalBufferLength - HeaderSize);
371 
372  ExFreePool(LookAheadBuffer);
373  }
374  }
375 
376  CurrentEntry = CurrentEntry->Flink;
377  }
378 
379  /* Loop the packet array to get everything
380  * set up for return the packets to the miniport */
381  for (i = 0; i < NumberOfPackets; i++)
382  {
383  /* First, check the initial packet status */
385  {
386  /* The miniport driver gets it back immediately so nothing to do here */
387  NDIS_DbgPrint(MID_TRACE, ("Miniport needs the packet back immediately\n"));
388  continue;
389  }
390 
391  /* Different behavior depending on whether it's serialized or not */
393  {
394  /* We need to check the reference count */
395  if (PacketArray[i]->WrapperReserved[0] == 0)
396  {
397  /* NOTE: Unlike serialized miniports, this is REQUIRED to be called for each
398  * packet received that can be reused immediately, it is not implied! */
399  Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ReturnPacketHandler(
401  PacketArray[i]);
402  NDIS_DbgPrint(MID_TRACE, ("Packet has been returned to miniport (Deserialized)\n"));
403  }
404  else
405  {
406  /* Packet will be returned by the protocol's call to NdisReturnPackets */
407  NDIS_DbgPrint(MID_TRACE, ("Packet will be returned to miniport later (Deserialized)\n"));
408  }
409  }
410  else
411  {
412  /* Check the reference count */
413  if (PacketArray[i]->WrapperReserved[0] == 0)
414  {
415  /* NDIS_STATUS_SUCCESS means the miniport can have the packet back immediately */
417 
418  NDIS_DbgPrint(MID_TRACE, ("Packet has been returned to miniport (Serialized)\n"));
419  }
420  else
421  {
422  /* NDIS_STATUS_PENDING means the miniport needs to wait for MiniportReturnPacket */
424 
425  NDIS_DbgPrint(MID_TRACE, ("Packet will be returned to miniport later (Serialized)\n"));
426  }
427  }
428  }
429 
431 }
_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 143 of file miniport.c.

146 {
147  BOOLEAN Busy = FALSE;
148  KIRQL OldIrql;
149 
151 
152  if (MiniGetFirstWorkItem(Adapter, Type))
153  {
154  Busy = TRUE;
155  }
157  {
158  Busy = TRUE;
159  }
161  {
162  Busy = TRUE;
163  }
164  else if (Type == NdisWorkItemResetRequested &&
166  {
167  Busy = TRUE;
168  }
169 
171 
172  return Busy;
173 }
#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:125
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 689 of file miniport.c.

700 {
701  KIRQL OldIrql;
702  PLIST_ENTRY CurrentEntry;
703  PLOGICAL_ADAPTER Adapter = 0;
704 
706 
707  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
708 
710  {
711  NDIS_DbgPrint(MIN_TRACE, ("No registered miniports for protocol to bind to\n"));
712  return NULL;
713  }
714 
715  NDIS_DbgPrint(DEBUG_MINIPORT, ("AdapterName = %wZ\n", AdapterName));
716 
718  {
719  CurrentEntry = AdapterListHead.Flink;
720 
721  while (CurrentEntry != &AdapterListHead)
722  {
723  Adapter = CONTAINING_RECORD(CurrentEntry, LOGICAL_ADAPTER, ListEntry);
724 
725  ASSERT(Adapter);
726 
727  NDIS_DbgPrint(DEBUG_MINIPORT, ("Examining adapter 0x%lx\n", Adapter));
728 
729  /* We're technically not allowed to call this above PASSIVE_LEVEL, but it doesn't break
730  * right now and I'd rather use a working API than reimplement it here */
732  {
733  break;
734  }
735 
736  Adapter = NULL;
737  CurrentEntry = CurrentEntry->Flink;
738  }
739  }
741 
742  if(Adapter)
743  {
744  NDIS_DbgPrint(DEBUG_MINIPORT, ("Leaving. Adapter found at 0x%x\n", Adapter));
745  }
746  else
747  {
748  NDIS_DbgPrint(MIN_TRACE, ("Leaving (adapter not found for %wZ).\n", AdapterName));
749  }
750 
751  return Adapter;
752 }
#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 948 of file miniport.c.

953 {
955 
956  if (MiniCheckForHang(Adapter)) {
957  NDIS_DbgPrint(MIN_TRACE, ("Miniport detected adapter hang\n"));
958  MiniReset(Adapter);
959  }
960 }
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define MIN_TRACE
Definition: debug.h:14
BOOLEAN MiniCheckForHang(PLOGICAL_ADAPTER Adapter)
Definition: miniport.c:864
NDIS_STATUS MiniReset(PLOGICAL_ADAPTER Adapter)
Definition: miniport.c:901
_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 1222 of file miniport.c.

1223 {
1225  KIRQL OldIrql, RaiseOldIrql;
1226  NDIS_STATUS NdisStatus;
1227  PVOID WorkItemContext;
1228  NDIS_WORK_ITEM_TYPE WorkItemType;
1229  BOOLEAN AddressingReset;
1230 
1232 
1234 
1235  NdisStatus =
1237  (Adapter, &WorkItemType, &WorkItemContext);
1238 
1240 
1241  if (NdisStatus == NDIS_STATUS_SUCCESS)
1242  {
1243  switch (WorkItemType)
1244  {
1245  case NdisWorkItemSend:
1246  /*
1247  * called by ProSend when protocols want to send packets to the miniport
1248  */
1249 
1250  if(Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendPacketsHandler)
1251  {
1253  {
1254  NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's SendPackets handler\n"));
1255  (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendPacketsHandler)(
1256  Adapter->NdisMiniportBlock.MiniportAdapterContext, (PPNDIS_PACKET)&WorkItemContext, 1);
1257  NdisStatus = NDIS_STATUS_PENDING;
1258  }
1259  else
1260  {
1261  /* SendPackets is called at DISPATCH_LEVEL for all serialized miniports */
1262  KeRaiseIrql(DISPATCH_LEVEL, &RaiseOldIrql);
1263  {
1264  NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's SendPackets handler\n"));
1265  (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendPacketsHandler)(
1266  Adapter->NdisMiniportBlock.MiniportAdapterContext, (PPNDIS_PACKET)&WorkItemContext, 1);
1267  }
1268  KeLowerIrql(RaiseOldIrql);
1269 
1270  NdisStatus = NDIS_GET_PACKET_STATUS((PNDIS_PACKET)WorkItemContext);
1271  if( NdisStatus == NDIS_STATUS_RESOURCES ) {
1272  MiniQueueWorkItem(Adapter, WorkItemType, WorkItemContext, TRUE);
1273  break;
1274  }
1275  }
1276  }
1277  else
1278  {
1280  {
1281  NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's Send handler\n"));
1282  NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendHandler)(
1283  Adapter->NdisMiniportBlock.MiniportAdapterContext, (PNDIS_PACKET)WorkItemContext,
1284  ((PNDIS_PACKET)WorkItemContext)->Private.Flags);
1285  NDIS_DbgPrint(MAX_TRACE, ("back from miniport's send handler\n"));
1286  }
1287  else
1288  {
1289  /* Send is called at DISPATCH_LEVEL for all serialized miniports */
1290  KeRaiseIrql(DISPATCH_LEVEL, &RaiseOldIrql);
1291  NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's Send handler\n"));
1292  NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendHandler)(
1293  Adapter->NdisMiniportBlock.MiniportAdapterContext, (PNDIS_PACKET)WorkItemContext,
1294  ((PNDIS_PACKET)WorkItemContext)->Private.Flags);
1295  NDIS_DbgPrint(MAX_TRACE, ("back from miniport's send handler\n"));
1296  KeLowerIrql(RaiseOldIrql);
1297  if( NdisStatus == NDIS_STATUS_RESOURCES ) {
1298  MiniQueueWorkItem(Adapter, WorkItemType, WorkItemContext, TRUE);
1299  break;
1300  }
1301  }
1302  }
1303 
1304  if( NdisStatus != NDIS_STATUS_PENDING ) {
1306  ( Adapter, (PNDIS_PACKET)WorkItemContext, NdisStatus );
1307  }
1308  break;
1309 
1311  /*
1312  * called by ProSend when protocols want to send loopback packets
1313  */
1314  /* XXX atm ProIndicatePacket sends a packet up via the loopback adapter only */
1315  NdisStatus = ProIndicatePacket(Adapter, (PNDIS_PACKET)WorkItemContext);
1316 
1317  if( NdisStatus != NDIS_STATUS_PENDING )
1318  MiniSendComplete((NDIS_HANDLE)Adapter, (PNDIS_PACKET)WorkItemContext, NdisStatus);
1319  break;
1320 
1322  break;
1323 
1326  NdisMIndicateStatusComplete(Adapter);
1327 
1329  NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)(
1330  &AddressingReset,
1331  Adapter->NdisMiniportBlock.MiniportAdapterContext);
1332 
1333  KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
1334  Adapter->NdisMiniportBlock.ResetStatus = NdisStatus;
1335  KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
1336 
1338 
1339  if (NdisStatus != NDIS_STATUS_PENDING)
1340  MiniResetComplete(Adapter, NdisStatus, AddressingReset);
1341  break;
1342 
1344  break;
1345 
1347  break;
1348 
1349  case NdisWorkItemRequest:
1350  NdisStatus = MiniDoRequest(Adapter, (PNDIS_REQUEST)WorkItemContext);
1351 
1352  if (NdisStatus == NDIS_STATUS_PENDING)
1353  break;
1354 
1355  Adapter->NdisMiniportBlock.PendingRequest = (PNDIS_REQUEST)WorkItemContext;
1356  switch (((PNDIS_REQUEST)WorkItemContext)->RequestType)
1357  {
1359  NdisMQueryInformationComplete((NDIS_HANDLE)Adapter, NdisStatus);
1360  break;
1361 
1363  NdisMSetInformationComplete((NDIS_HANDLE)Adapter, NdisStatus);
1364  break;
1365 
1366  default:
1367  NDIS_DbgPrint(MIN_TRACE, ("Unknown NDIS request type.\n"));
1368  break;
1369  }
1370  Adapter->NdisMiniportBlock.PendingRequest = NULL;
1371  break;
1372 
1373  default:
1374  NDIS_DbgPrint(MIN_TRACE, ("Unknown NDIS work item type (%d).\n", WorkItemType));
1375  break;
1376  }
1377  }
1378 }
VOID EXPORT NdisMSetInformationComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status)
Definition: miniport.c:1186
#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:445
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:1049
VOID NTAPI MiniResetComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status, IN BOOLEAN AddressingReset)
Definition: miniport.c:434
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:1579
#define NDIS_GET_PACKET_STATUS(_Packet)
Definition: ndis.h:3436
NDIS_STATUS MiniDoRequest(PLOGICAL_ADAPTER Adapter, PNDIS_REQUEST NdisRequest)
Definition: miniport.c:1106
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:529
_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:981
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:1564
VOID EXPORT NdisMQueryInformationComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status)
Definition: miniport.c:1206
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 804 of file miniport.c.

821 {
822  NDIS_STATUS NdisStatus;
824  KEVENT Event;
825  PNDIS_REQUEST_MAC_BLOCK MacBlock;
826 
827  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
828 
830  if (!NdisRequest) {
831  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
832  return NDIS_STATUS_RESOURCES;
833  }
834 
836 
838  NdisRequest->DATA.QUERY_INFORMATION.Oid = Oid;
839  NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer = Buffer;
840  NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength = Size;
841 
842  /* We'll need to give the completion routine some way of letting us know
843  * when it's finished. We'll stash a pointer to an event in the MacBlock */
845  MacBlock = (PNDIS_REQUEST_MAC_BLOCK)NdisRequest->MacReserved;
846  MacBlock->Unknown1 = &Event;
847 
848  NdisStatus = MiniDoRequest(Adapter, NdisRequest);
849 
850  if (NdisStatus == NDIS_STATUS_PENDING)
851  {
853  NdisStatus = PtrToUlong(MacBlock->Unknown3);
854  }
855 
856  *BytesWritten = NdisRequest->DATA.QUERY_INFORMATION.BytesWritten;
857 
859 
860  return NdisStatus;
861 }
_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:445
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
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:1106
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 981 of file miniport.c.

995 {
996  PNDIS_MINIPORT_WORK_ITEM MiniportWorkItem;
997  KIRQL OldIrql;
998 
999  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
1000 
1001  ASSERT(Adapter);
1002 
1004  if (Top)
1005  {
1006  if (WorkItemType == NdisWorkItemSend)
1007  {
1008  NDIS_DbgPrint(MIN_TRACE, ("Requeuing failed packet (%x).\n", WorkItemContext));
1009  Adapter->NdisMiniportBlock.FirstPendingPacket = WorkItemContext;
1010  }
1011  else
1012  {
1013  //This should never happen
1014  ASSERT(FALSE);
1015  }
1016  }
1017  else
1018  {
1019  MiniportWorkItem = ExAllocatePool(NonPagedPool, sizeof(NDIS_MINIPORT_WORK_ITEM));
1020  if (!MiniportWorkItem)
1021  {
1023  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1024  return;
1025  }
1026 
1027  MiniportWorkItem->WorkItemType = WorkItemType;
1028  MiniportWorkItem->WorkItemContext = WorkItemContext;
1029 
1030  /* safe due to adapter lock held */
1031  MiniportWorkItem->Link.Next = NULL;
1032  if (!Adapter->WorkQueueHead)
1033  {
1034  Adapter->WorkQueueHead = MiniportWorkItem;
1035  Adapter->WorkQueueTail = MiniportWorkItem;
1036  }
1037  else
1038  {
1039  Adapter->WorkQueueTail->Link.Next = (PSINGLE_LIST_ENTRY)MiniportWorkItem;
1040  Adapter->WorkQueueTail = MiniportWorkItem;
1041  }
1042  }
1043 
1045 }
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 480 of file miniport.c.

483 {
486  PNDIS_REQUEST_MAC_BLOCK MacBlock;
487  KIRQL OldIrql;
488 
489  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
490 
492 
496 
497  MacBlock = (PNDIS_REQUEST_MAC_BLOCK)Request->MacReserved;
498 
499  /* We may or may not be doing this request on behalf of an adapter binding */
500  if (MacBlock->Binding != NULL)
501  {
502  /* We are, so invoke its request complete handler */
503  if (MacBlock->Binding->RequestCompleteHandler != NULL)
504  {
505  (*MacBlock->Binding->RequestCompleteHandler)(
506  MacBlock->Binding->ProtocolBindingContext,
507  Request,
508  Status);
509  }
510  }
511  else
512  {
513  /* We are doing this internally, so we'll signal this event we've stashed in the MacBlock */
514  ASSERT(MacBlock->Unknown1 != NULL);
515  ASSERT(MacBlock->Unknown3 == NULL);
516  MacBlock->Unknown3 = UlongToPtr(Status);
518  }
519 
524 
526 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
VOID MiniWorkItemComplete(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE WorkItemType)
Definition: miniport.c:963
#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:565

Referenced by NdisIPnPStartDevice().

◆ MiniReset()

NDIS_STATUS MiniReset ( PLOGICAL_ADAPTER  Adapter)

Definition at line 901 of file miniport.c.

910 {
912  KIRQL OldIrql;
913  BOOLEAN AddressingReset = TRUE;
914 
915  if (MiniIsBusy(Adapter, NdisWorkItemResetRequested)) {
917  return NDIS_STATUS_PENDING;
918  }
919 
922 
924  Status = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)(
925  &AddressingReset,
927 
931 
933 
934  if (Status != NDIS_STATUS_PENDING) {
935  if (AddressingReset)
936  MiniDoAddressingReset(Adapter);
937 
940 
942  }
943 
944  return Status;
945 }
#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:963
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:887
#define NDIS_STATUS_RESET_START
Definition: ndis.h:354
int NDIS_STATUS
Definition: ntddndis.h:445
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:143
smooth NULL
Definition: ftsmooth.c:416
VOID EXPORT NdisMIndicateStatusComplete(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:1579
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:981
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:1564

Referenced by MiniportHangDpc(), and ProReset().

◆ MiniResetComplete()

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

Definition at line 434 of file miniport.c.

438 {
440  PLIST_ENTRY CurrentEntry;
441  PADAPTER_BINDING AdapterBinding;
442  KIRQL OldIrql;
443 
444  if (AddressingReset)
445  MiniDoAddressingReset(Adapter);
446 
449 
451 
453  {
454  KeBugCheckEx(BUGCODE_ID_DRIVER,
456  (ULONG_PTR)Status,
457  (ULONG_PTR)AddressingReset,
458  0);
459  }
460 
462 
463  CurrentEntry = Adapter->ProtocolListHead.Flink;
464 
465  while (CurrentEntry != &Adapter->ProtocolListHead)
466  {
467  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
468 
469  (*AdapterBinding->ProtocolBinding->Chars.ResetCompleteHandler)(
470  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
471  Status);
472 
473  CurrentEntry = CurrentEntry->Flink;
474  }
475 
477 }
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:887
_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:1579
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:1564
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 529 of file miniport.c.

541 {
543  PADAPTER_BINDING AdapterBinding;
544  KIRQL OldIrql;
545  PSCATTER_GATHER_LIST SGList;
546 
547  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
548 
549  AdapterBinding = (PADAPTER_BINDING)Packet->Reserved[1];
550 
552 
553  if (Adapter->NdisMiniportBlock.ScatterGatherListSize != 0)
554  {
555  NDIS_DbgPrint(MAX_TRACE, ("Freeing Scatter/Gather list\n"));
556 
559 
560  Adapter->NdisMiniportBlock.SystemAdapterObject->
561  DmaOperations->PutScatterGatherList(
562  Adapter->NdisMiniportBlock.SystemAdapterObject,
563  SGList,
564  TRUE);
565 
568  }
569 
570  (*AdapterBinding->ProtocolBinding->Chars.SendCompleteHandler)(
571  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
572  Packet,
573  Status);
574 
576 
578 }
#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:963
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:2095
#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 582 of file miniport.c.

584 {
585  /* Run the work if anything is waiting */
587 }
VOID MiniWorkItemComplete(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE WorkItemType)
Definition: miniport.c:963
_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 755 of file miniport.c.

761 {
762  NDIS_STATUS NdisStatus;
764  KEVENT Event;
765  PNDIS_REQUEST_MAC_BLOCK MacBlock;
766 
767  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
768 
770  if (!NdisRequest) {
771  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
772  return NDIS_STATUS_RESOURCES;
773  }
774 
776 
777  NdisRequest->RequestType = NdisRequestSetInformation;
778  NdisRequest->DATA.SET_INFORMATION.Oid = Oid;
779  NdisRequest->DATA.SET_INFORMATION.InformationBuffer = Buffer;
780  NdisRequest->DATA.SET_INFORMATION.InformationBufferLength = Size;
781 
782  /* We'll need to give the completion routine some way of letting us know
783  * when it's finished. We'll stash a pointer to an event in the MacBlock */
785  MacBlock = (PNDIS_REQUEST_MAC_BLOCK)NdisRequest->MacReserved;
786  MacBlock->Unknown1 = &Event;
787 
788  NdisStatus = MiniDoRequest(Adapter, NdisRequest);
789 
790  if (NdisStatus == NDIS_STATUS_PENDING)
791  {
793  NdisStatus = PtrToUlong(MacBlock->Unknown3);
794  }
795 
796  *BytesRead = NdisRequest->DATA.SET_INFORMATION.BytesRead;
797 
799 
800  return NdisStatus;
801 }
_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:445
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
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:1106
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 1383 of file miniport.c.

1388 {
1389  PLOGICAL_ADAPTER Adapter = MiniportHandle;
1390  PLIST_ENTRY CurrentEntry;
1391  PADAPTER_BINDING AdapterBinding;
1392  KIRQL OldIrql;
1393 
1395 
1396  CurrentEntry = Adapter->ProtocolListHead.Flink;
1397 
1398  while (CurrentEntry != &Adapter->ProtocolListHead)
1399  {
1400  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
1401 
1402  (*AdapterBinding->ProtocolBinding->Chars.StatusHandler)(
1403  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
1404  GeneralStatus,
1405  StatusBuffer,
1407 
1408  CurrentEntry = CurrentEntry->Flink;
1409  }
1410 
1412 }
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 1416 of file miniport.c.

1418 {
1420  PLIST_ENTRY CurrentEntry;
1421  PADAPTER_BINDING AdapterBinding;
1422  KIRQL OldIrql;
1423 
1425 
1426  CurrentEntry = Adapter->ProtocolListHead.Flink;
1427 
1428  while (CurrentEntry != &Adapter->ProtocolListHead)
1429  {
1430  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
1431 
1432  (*AdapterBinding->ProtocolBinding->Chars.StatusCompleteHandler)(
1433  AdapterBinding->NdisOpenBlock.ProtocolBindingContext);
1434 
1435  CurrentEntry = CurrentEntry->Flink;
1436  }
1437 
1439 }
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 591 of file miniport.c.

596 {
597  PADAPTER_BINDING AdapterBinding;
598  KIRQL OldIrql;
599 
600  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
601 
602  AdapterBinding = (PADAPTER_BINDING)Packet->Reserved[1];
603 
606  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
607  Packet,
608  Status,
609  BytesTransferred);
611 }
#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 963 of file miniport.c.

966 {
968 
969  /* Check if there's anything queued to run after this work item */
970  if (!MiniIsBusy(Adapter, WorkItemType))
971  return;
972 
973  /* There is, so fire the worker */
975  if (IoWorkItem)
977 }
_In_opt_ PVOID _In_ PIO_WORKITEM IoWorkItem
Definition: iotypes.h:487
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:143
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:1222

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

◆ NdisCancelSendPackets()

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

Definition at line 3352 of file miniport.c.

3355 {
3356  PADAPTER_BINDING AdapterBinding = NdisBindingHandle;
3357  PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
3358 
3359  NDIS_DbgPrint(MAX_TRACE, ("Called for ID %x.\n", CancelId));
3360 
3361  if (Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CancelSendPacketsHandler)
3362  {
3363  (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CancelSendPacketsHandler)(
3365  CancelId);
3366  }
3367 }
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 3289 of file miniport.c.

3299 {
3300  PIRP Irp = (PIRP)NetPnPEvent->NdisReserved[0];
3301  PLIST_ENTRY CurrentEntry = (PLIST_ENTRY)NetPnPEvent->NdisReserved[1];
3302  PADAPTER_BINDING AdapterBinding = NdisBindingHandle;
3303  PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
3304  NDIS_STATUS NdisStatus;
3305 
3306  if (Status != NDIS_STATUS_SUCCESS)
3307  {
3308  if (NetPnPEvent->Buffer) ExFreePool(NetPnPEvent->Buffer);
3310  Irp->IoStatus.Status = Status;
3312  return;
3313  }
3314 
3315  while (CurrentEntry != &Adapter->ProtocolListHead)
3316  {
3317  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
3318 
3319  NdisStatus = (*AdapterBinding->ProtocolBinding->Chars.PnPEventHandler)(
3320  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
3321  NetPnPEvent);
3322 
3323  if (NdisStatus == NDIS_STATUS_PENDING)
3324  {
3325  NetPnPEvent->NdisReserved[1] = (ULONG_PTR)CurrentEntry->Flink;
3326  return;
3327  }
3328  else if (NdisStatus != NDIS_STATUS_SUCCESS)
3329  {
3330  if (NetPnPEvent->Buffer) ExFreePool(NetPnPEvent->Buffer);
3332  Irp->IoStatus.Status = NdisStatus;
3334  return;
3335  }
3336 
3337  CurrentEntry = CurrentEntry->Flink;
3338  }
3339 
3340  if (NetPnPEvent->Buffer) ExFreePool(NetPnPEvent->Buffer);
3342 
3343  Irp->IoStatus.Status = NDIS_STATUS_SUCCESS;
3345 }
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:445
#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:565
#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 3072 of file miniport.c.

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

◆ NdisGenericIrpHandler()

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

Definition at line 2573 of file miniport.c.

2576 {
2578 
2579  /* Use the characteristics to classify the device */
2580  if (DeviceObject->DeviceType == FILE_DEVICE_PHYSICAL_NETCARD)
2581  {
2582  if ((IrpSp->MajorFunction == IRP_MJ_CREATE) ||
2585  {
2587  }
2588  else if (IrpSp->MajorFunction == IRP_MJ_PNP)
2589  {
2591  }
2592  else if (IrpSp->MajorFunction == IRP_MJ_SHUTDOWN)
2593  {
2594  return NdisIShutdown(DeviceObject, Irp);
2595  }
2597  {
2599  }
2600  else if (IrpSp->MajorFunction == IRP_MJ_POWER)
2601  {
2602  return NdisIPower(DeviceObject, Irp);
2603  }
2604  NDIS_DbgPrint(MIN_TRACE, ("Unexpected IRP MajorFunction 0x%x\n", IrpSp->MajorFunction));
2605  ASSERT(FALSE);
2606  }
2607  else if (DeviceObject->DeviceType == FILE_DEVICE_NETWORK)
2608  {
2610 
2611  ASSERT(DeviceBlock->DeviceObject == DeviceObject);
2612 
2613  if (DeviceBlock->MajorFunction[IrpSp->MajorFunction] != NULL)
2614  {
2615  return DeviceBlock->MajorFunction[IrpSp->MajorFunction](DeviceObject, Irp);
2616  }
2617  }
2618  else
2619  {
2620  ASSERT(FALSE);
2621  }
2622 
2623  Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
2624  Irp->IoStatus.Information = 0;
2625 
2627 
2629 }
#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:1870
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:2268
#define FILE_DEVICE_PHYSICAL_NETCARD
Definition: winioctl.h:128
NTSTATUS NTAPI NdisIPower(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: miniport.c:2406
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:2334
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:2290
#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:565
#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 2419 of file miniport.c.

2428 {
2429  static const WCHAR ClassKeyName[] = {'C','l','a','s','s','\\'};
2430  static const WCHAR LinkageKeyName[] = {'\\','L','i','n','k','a','g','e',0};
2431  PNDIS_M_DRIVER_BLOCK Miniport;
2432  PNDIS_M_DRIVER_BLOCK *MiniportPtr;
2433  WCHAR *LinkageKeyBuffer;
2434  ULONG DriverKeyLength;
2436  UNICODE_STRING ExportName;
2438  PLOGICAL_ADAPTER Adapter;
2439  NTSTATUS Status;
2440 
2441  /*
2442  * Gain the access to the miniport data structure first.
2443  */
2444 
2445  MiniportPtr = IoGetDriverObjectExtension(DriverObject, (PVOID)'NMID');
2446  if (MiniportPtr == NULL)
2447  {
2448  NDIS_DbgPrint(MIN_TRACE, ("Can't get driver object extension.\n"));
2449  return NDIS_STATUS_FAILURE;
2450  }
2451  Miniport = *MiniportPtr;
2452 
2453  /*
2454  * Get name of the Linkage registry key for our adapter. It's located under
2455  * the driver key for our driver and so we have basicly two ways to do it.
2456  * Either we can use IoOpenDriverRegistryKey or compose it using information
2457  * gathered by IoGetDeviceProperty. I chose the second because
2458  * IoOpenDriverRegistryKey wasn't implemented at the time of writing.
2459  */
2460 
2462  0, NULL, &DriverKeyLength);
2464  {
2465  NDIS_DbgPrint(MIN_TRACE, ("Can't get miniport driver key length.\n"));
2466  return Status;
2467  }
2468 
2469  LinkageKeyBuffer = ExAllocatePool(PagedPool, DriverKeyLength +
2470  sizeof(ClassKeyName) + sizeof(LinkageKeyName));
2471  if (LinkageKeyBuffer == NULL)
2472  {
2473  NDIS_DbgPrint(MIN_TRACE, ("Can't allocate memory for driver key name.\n"));
2475  }
2476 
2478  DriverKeyLength, LinkageKeyBuffer +
2479  (sizeof(ClassKeyName) / sizeof(WCHAR)),
2480  &DriverKeyLength);
2481  if (!NT_SUCCESS(Status))
2482  {
2483  NDIS_DbgPrint(MIN_TRACE, ("Can't get miniport driver key.\n"));
2484  ExFreePool(LinkageKeyBuffer);
2485  return Status;
2486  }
2487 
2488  /* Compose the linkage key name. */
2489  RtlCopyMemory(LinkageKeyBuffer, ClassKeyName, sizeof(ClassKeyName));
2490  RtlCopyMemory(LinkageKeyBuffer + ((sizeof(ClassKeyName) + DriverKeyLength) /
2491  sizeof(WCHAR)) - 1, LinkageKeyName, sizeof(LinkageKeyName));
2492 
2493  NDIS_DbgPrint(DEBUG_MINIPORT, ("LinkageKey: %S.\n", LinkageKeyBuffer));
2494 
2495  /*
2496  * Now open the linkage key and read the "Export" and "RootDevice" values
2497  * which contains device name and root service respectively.
2498  */
2499 
2501  RtlInitUnicodeString(&ExportName, NULL);
2503  QueryTable[0].Name = L"Export";
2504  QueryTable[0].EntryContext = &ExportName;
2505 
2507  QueryTable, NULL, NULL);
2508  ExFreePool(LinkageKeyBuffer);
2509  if (!NT_SUCCESS(Status))
2510  {
2511  NDIS_DbgPrint(MIN_TRACE, ("Can't get miniport device name. (%x)\n", Status));
2512  return Status;
2513  }
2514 
2515  /*
2516  * Create the device object.
2517  */
2518 
2519  NDIS_DbgPrint(MAX_TRACE, ("creating device %wZ\n", &ExportName));
2520 
2521  Status = IoCreateDevice(Miniport->DriverObject, sizeof(LOGICAL_ADAPTER),
2522  &ExportName, FILE_DEVICE_PHYSICAL_NETCARD,
2523  0, FALSE, &DeviceObject);
2524  if (!NT_SUCCESS(Status))
2525  {
2526  NDIS_DbgPrint(MIN_TRACE, ("Could not create device object.\n"));
2527  RtlFreeUnicodeString(&ExportName);
2528  return Status;
2529  }
2530 
2531  /*
2532  * Initialize the adapter structure.
2533  */
2534 
2538 
2540  &GUID_DEVINTERFACE_NET,
2541  NULL,
2543 
2544  if (!NT_SUCCESS(Status))
2545  {
2546  NDIS_DbgPrint(MIN_TRACE, ("Could not create device interface.\n"));
2548  RtlFreeUnicodeString(&ExportName);
2549  return Status;
2550  }
2551 
2552  Adapter->NdisMiniportBlock.DriverHandle = Miniport;
2553  Adapter->NdisMiniportBlock.MiniportName = ExportName;
2559 
2560  Adapter->NdisMiniportBlock.OldPnPDeviceState = 0;
2561  Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceAdded;
2562 
2565 
2567 
2568  return STATUS_SUCCESS;
2569 }
#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:3988
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
#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:4210
#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:948
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:1250
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:2745
#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 1669 of file miniport.c.

1678 {
1681 
1682  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
1683 
1684  if(sh)
1685  sh(Context->DriverContext);
1686 }
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 1870 of file miniport.c.

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

Referenced by NdisGenericIrpHandler().

◆ NdisIDeviceIoControl()

NTSTATUS NTAPI NdisIDeviceIoControl ( IN PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 2290 of file miniport.c.

2293 {
2298  ULONG Written;
2299 
2300  Irp->IoStatus.Information = 0;
2301 
2302  ASSERT(Adapter);
2303 
2304  ControlCode = Stack->Parameters.DeviceIoControl.IoControlCode;
2305  switch (ControlCode)
2306  {
2308  Status = MiniQueryInformation(Adapter,
2309  *(PNDIS_OID)Irp->AssociatedIrp.SystemBuffer,
2310  Stack->Parameters.DeviceIoControl.OutputBufferLength,
2311  MmGetSystemAddressForMdl(Irp->MdlAddress),
2312  &Written);
2313  Irp->IoStatus.Information = Written;
2314  break;
2315 
2316  default:
2317  NDIS_DbgPrint(MIN_TRACE, ("NdisIDeviceIoControl: unsupported control code 0x%lx\n", ControlCode));
2318  break;
2319  }
2320 
2321  if (Status != NDIS_STATUS_PENDING)
2322  {
2323  Irp->IoStatus.Status = Status;
2325  }
2326  else
2328 
2329  return Status;
2330 }
#define IOCTL_NDIS_QUERY_GLOBAL_STATS
Definition: ntddndis.h:413
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
_In_ PIRP Irp
Definition: csq.h:116
int NDIS_STATUS
Definition: ntddndis.h:445
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:204
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:804
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:565
#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 2334 of file miniport.c.

2337 {
2340  NTSTATUS Status;
2341 
2342  switch (Stack->MinorFunction)
2343  {
2344  case IRP_MN_START_DEVICE:
2345  Status = NdisIForwardIrpAndWait(Adapter, Irp);
2346  if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
2347  {
2349  }
2350  else
2351  NDIS_DbgPrint(MIN_TRACE, ("Lower driver failed device start\n"));
2352  Irp->IoStatus.Status = Status;
2354  return Status;
2355 
2356  case IRP_MN_STOP_DEVICE:
2358  if (!NT_SUCCESS(Status))
2359  NDIS_DbgPrint(MIN_TRACE, ("WARNING: Ignoring halt device failure! Passing the IRP down anyway\n"));
2360  Irp->IoStatus.Status = STATUS_SUCCESS;
2361  break;
2362 
2366  Irp->IoStatus.Status = Status;
2367  if (Status != STATUS_SUCCESS)
2368  {
2370  NDIS_DbgPrint(MIN_TRACE, ("Failing miniport halt request\n"));
2371  return Status;
2372  }
2373  break;
2374 
2377  Status = NdisIForwardIrpAndWait(Adapter, Irp);
2378  if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
2379  {
2381  }
2382  else
2383  {
2384  NDIS_DbgPrint(MIN_TRACE, ("Lower driver failed cancel stop/remove request\n"));
2385  }
2386  Irp->IoStatus.Status = Status;
2388  return Status;
2389 
2392  Irp->IoStatus.Status = Status;
2393  Irp->IoStatus.Information |= Adapter->NdisMiniportBlock.PnPFlags;
2394  break;
2395 
2396  default:
2397  break;
2398  }
2399 
2402 }
#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:2210
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:2711
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:1850
#define IO_NO_INCREMENT
Definition: iotypes.h:565
#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:1884
return STATUS_SUCCESS
Definition: btrfs.c:2745
#define IRP_MN_QUERY_PNP_DEVICE_STATE

Referenced by NdisGenericIrpHandler().

◆ NdisIForwardIrpAndWait()

NTSTATUS NTAPI NdisIForwardIrpAndWait ( PLOGICAL_ADAPTER  Adapter,
PIRP  Irp 
)

Definition at line 1850 of file miniport.c.

1851 {
1852  KEVENT Event;
1853  NTSTATUS Status;
1854 
1858  TRUE, TRUE, TRUE);
1860  if (Status == STATUS_PENDING)
1861  {
1863  Status = Irp->IoStatus.Status;
1864  }
1865  return Status;
1866 }
#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:1835
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:434
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 1835 of file miniport.c.

1839 {
1840  PKEVENT Event = Context;
1841 
1842  if (Irp->PendingReturned)
1844 
1846 }
#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:1012
#define IO_NO_INCREMENT
Definition: iotypes.h:565

Referenced by NdisIForwardIrpAndWait().

◆ NdisIMGetBindingContext()

NDIS_HANDLE EXPORT NdisIMGetBindingContext ( IN NDIS_HANDLE  NdisBindingHandle)

Definition at line 3375 of file miniport.c.

3383 {
3384  PADAPTER_BINDING AdapterBinding = NdisBindingHandle;
3385  PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
3386 
3387  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
3388 
3389  return Adapter->NdisMiniportBlock.DeviceContext;
3390 }
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 3398 of file miniport.c.

3406 {
3408 
3409  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
3410 
3411  return Adapter->NdisMiniportBlock.DeviceContext;
3412 }
_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 1590 of file miniport.c.

1605 {
1606  PNDIS_M_DRIVER_BLOCK Miniport;
1608  WCHAR *RegistryBuffer;
1609 
1610  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
1611 
1612  ASSERT(NdisWrapperHandle);
1613 
1614  *NdisWrapperHandle = NULL;
1615 
1616 #if BREAK_ON_MINIPORT_INIT
1617  DbgBreakPoint();
1618 #endif
1619 
1620  Miniport = ExAllocatePool(NonPagedPool, sizeof(NDIS_M_DRIVER_BLOCK));
1621 
1622  if (!Miniport)
1623  {
1624  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1625  return;
1626  }
1627 
1628  RtlZeroMemory(Miniport, sizeof(NDIS_M_DRIVER_BLOCK));
1629 
1630  KeInitializeSpinLock(&Miniport->Lock);
1631 
1632  Miniport->DriverObject = (PDRIVER_OBJECT)SystemSpecific1;
1633 
1634  /* set the miniport's driver registry path */
1636  if(!RegistryPath)
1637  {
1638  ExFreePool(Miniport);
1639  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1640  return;
1641  }
1642 
1644  RegistryPath->MaximumLength = RegistryPath->Length + sizeof(WCHAR); /* room for 0-term */
1645 
1646  RegistryBuffer = ExAllocatePool(PagedPool, RegistryPath->MaximumLength);
1647  if(!RegistryBuffer)
1648  {
1649  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1650  ExFreePool(Miniport);
1652  return;
1653  }
1654 
1656  RegistryBuffer[RegistryPath->Length/sizeof(WCHAR)] = 0;
1657 
1658  RegistryPath->Buffer = RegistryBuffer;
1659  Miniport->RegistryPath = RegistryPath;
1660 
1661  InitializeListHead(&Miniport->DeviceList);
1662 
1663  /* Put miniport in global miniport list */
1665 
1666  *NdisWrapperHandle = Miniport;
1667 }
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:558
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 1884 of file miniport.c.

1895 {
1898  NDIS_WRAPPER_CONTEXT WrapperContext;
1899  NDIS_STATUS NdisStatus;
1901  NTSTATUS Status;
1903  NDIS_OID AddressOID;
1904  BOOLEAN Success = FALSE;
1906  ULONG ResourceListSize;
1907  UNICODE_STRING ParamName;
1908  PNDIS_CONFIGURATION_PARAMETER ConfigParam;
1909  NDIS_HANDLE ConfigHandle;
1910  ULONG Size;
1912  UINT MaxMulticastAddresses;
1914  PLIST_ENTRY CurrentEntry;
1915  PPROTOCOL_BINDING ProtocolBinding;
1916 
1917  /*
1918  * Prepare wrapper context used by HW and configuration routines.
1919  */
1920 
1921  NDIS_DbgPrint(DEBUG_MINIPORT, ("Start Device %wZ\n", &Adapter->NdisMiniportBlock.MiniportName));
1922 
1923  NDIS_DbgPrint(MAX_TRACE, ("Inserting adapter 0x%x into adapter list\n", Adapter));
1924 
1925  /* Put adapter in global adapter list */
1927 
1930  KEY_ALL_ACCESS, &WrapperContext.RegistryHandle);
1931  if (!NT_SUCCESS(Status))
1932  {
1933  NDIS_DbgPrint(MIN_TRACE,("failed to open adapter-specific reg key\n"));
1935  return Status;
1936  }
1937 
1938  NDIS_DbgPrint(MAX_TRACE, ("opened device reg key\n"));
1939 
1940  WrapperContext.DeviceObject = Adapter->NdisMiniportBlock.DeviceObject;
1941 
1942  /*
1943  * Store the adapter resources used by HW routines such as
1944  * NdisMQueryAdapterResources.
1945  */
1946 
1947  if (Stack->Parameters.StartDevice.AllocatedResources != NULL)
1948  {
1949  ResourceCount = Stack->Parameters.StartDevice.AllocatedResources->List[0].
1950  PartialResourceList.Count;
1951  ResourceListSize =
1952  FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
1953  PartialDescriptors[ResourceCount]);
1954 
1955  Adapter->NdisMiniportBlock.AllocatedResources =
1956  ExAllocatePool(PagedPool, ResourceListSize);
1957  if (Adapter->NdisMiniportBlock.AllocatedResources == NULL)
1958  {
1959  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
1962  }
1963 
1964  Adapter->NdisMiniportBlock.Resources =
1965  ExAllocatePool(PagedPool, ResourceListSize);
1966  if (!Adapter->NdisMiniportBlock.Resources)
1967  {
1968  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
1969  ExFreePool(Adapter->NdisMiniportBlock.AllocatedResources);
1972  }
1973 
1975  Stack->Parameters.StartDevice.AllocatedResources,
1976  ResourceListSize);
1977 
1978  RtlCopyMemory(Adapter->NdisMiniportBlock.AllocatedResources,
1979  Stack->Parameters.StartDevice.AllocatedResources,
1980  ResourceListSize);
1981  }
1982 
1983  if (Stack->Parameters.StartDevice.AllocatedResourcesTranslated != NULL)
1984  {
1985  ResourceCount = Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].
1986  PartialResourceList.Count;
1987  ResourceListSize =
1988  FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
1989  PartialDescriptors[ResourceCount]);
1990 
1991  Adapter->NdisMiniportBlock.AllocatedResourcesTranslated =
1992  ExAllocatePool(PagedPool, ResourceListSize);
1993  if (Adapter->NdisMiniportBlock.AllocatedResourcesTranslated == NULL)
1994  {
1995  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
1998  }
1999 
2000  RtlCopyMemory(Adapter->NdisMiniportBlock.AllocatedResourcesTranslated,
2001  Stack->Parameters.StartDevice.AllocatedResourcesTranslated,
2002  ResourceListSize);
2003  }
2004 
2005  /*
2006  * Store the Bus Type, Bus Number and Slot information. It's used by
2007  * the hardware routines then.
2008  */
2009 
2010  NdisOpenConfiguration(&NdisStatus, &ConfigHandle, (NDIS_HANDLE)&WrapperContext);
2011  if (NdisStatus != NDIS_STATUS_SUCCESS)
2012  {
2013  NDIS_DbgPrint(MIN_TRACE, ("Failed to open configuration key\n"));
2015  return NdisStatus;
2016  }
2017 
2018  Size = sizeof(ULONG);
2021  &Adapter->NdisMiniportBlock.BusType, &Size);
2023  {
2024  NdisInitUnicodeString(&ParamName, L"BusType");
2025  NdisReadConfiguration(&NdisStatus, &ConfigParam, ConfigHandle,
2026  &ParamName, NdisParameterInteger);
2027  if (NdisStatus == NDIS_STATUS_SUCCESS)
2028  Adapter->NdisMiniportBlock.BusType = ConfigParam->ParameterData.IntegerData;
2029  else
2030  Adapter->NdisMiniportBlock.BusType = Isa;
2031  }
2032 
2035  &Adapter->NdisMiniportBlock.BusNumber, &Size);
2036  if (!NT_SUCCESS(Status) || Adapter->NdisMiniportBlock.BusNumber == 0xFFFFFFF0)
2037  {
2038  NdisInitUnicodeString(&ParamName, L"BusNumber");
2039  NdisReadConfiguration(&NdisStatus, &ConfigParam, ConfigHandle,
2040  &ParamName, NdisParameterInteger);
2041  if (NdisStatus == NDIS_STATUS_SUCCESS)
2042  Adapter->NdisMiniportBlock.BusNumber = ConfigParam->ParameterData.IntegerData;
2043  else
2044  Adapter->NdisMiniportBlock.BusNumber = 0;
2045  }
2046  WrapperContext.BusNumber = Adapter->NdisMiniportBlock.BusNumber;
2047 
2050  &Adapter->NdisMiniportBlock.SlotNumber, &Size);
2051  if (!NT_SUCCESS(Status) || Adapter->NdisMiniportBlock.SlotNumber == (NDIS_INTERFACE_TYPE)-1)
2052  {
2053  NdisInitUnicodeString(&ParamName, L"SlotNumber");
2054  NdisReadConfiguration(&NdisStatus, &ConfigParam, ConfigHandle,
2055  &ParamName, NdisParameterInteger);
2056  if (NdisStatus == NDIS_STATUS_SUCCESS)
2057  Adapter->NdisMiniportBlock.SlotNumber = ConfigParam->ParameterData.IntegerData;
2058  else
2059  Adapter->NdisMiniportBlock.SlotNumber = 0;
2060  }
2061  else
2062  {
2063  /* Convert slotnumber to PCI_SLOT_NUMBER */
2064  ULONG PciSlotNumber = Adapter->NdisMiniportBlock.SlotNumber;
2066 
2067  SlotNumber.u.AsULONG = 0;
2068  SlotNumber.u.bits.DeviceNumber = (PciSlotNumber >> 16) & 0xFFFF;
2069  SlotNumber.u.bits.FunctionNumber = PciSlotNumber & 0xFFFF;
2070 
2071  Adapter->NdisMiniportBlock.SlotNumber = SlotNumber.u.AsULONG;
2072  }
2073  WrapperContext.SlotNumber = Adapter->NdisMiniportBlock.SlotNumber;
2074 
2075  NdisCloseConfiguration(ConfigHandle);
2076 
2077  /* Set handlers (some NDIS macros require these) */
2090 
2091  /*
2092  * Call MiniportInitialize.
2093  */
2094 
2095  NDIS_DbgPrint(MID_TRACE, ("calling MiniportInitialize\n"));
2096  NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.InitializeHandler)(
2098  MEDIA_ARRAY_SIZE, Adapter, (NDIS_HANDLE)&WrapperContext);
2099 
2100  ZwClose(WrapperContext.RegistryHandle);
2101 
2102  if (NdisStatus != NDIS_STATUS_SUCCESS)
2103  {
2104  NDIS_DbgPrint(MIN_TRACE, ("MiniportInitialize() failed for an adapter (%lx).\n", NdisStatus));
2106  if (Adapter->NdisMiniportBlock.Interrupt)
2107  {
2108  KeBugCheckEx(BUGCODE_ID_DRIVER,
2109  (ULONG_PTR)Adapter,
2110  (ULONG_PTR)Adapter->NdisMiniportBlock.Interrupt,
2111  (ULONG_PTR)Adapter->NdisMiniportBlock.TimerQueue,
2112  1);
2113  }
2114  if (Adapter->NdisMiniportBlock.TimerQueue)
2115  {
2116  KeBugCheckEx(BUGCODE_ID_DRIVER,
2117  (ULONG_PTR)Adapter,
2118  (ULONG_PTR)Adapter->NdisMiniportBlock.Interrupt,
2119  (ULONG_PTR)Adapter->NdisMiniportBlock.TimerQueue,
2120  1);
2121  }
2122  return NdisStatus;
2123  }
2124 
2126  {
2127  NDIS_DbgPrint(MIN_TRACE, ("MiniportInitialize() selected a bad index\n"));
2130  }
2131 
2133 
2134  switch (Adapter->NdisMiniportBlock.MediaType)
2135  {
2136  case NdisMedium802_3:
2137  Adapter->MediumHeaderSize = 14; /* XXX figure out what to do about LLC */
2138  AddressOID = OID_802_3_CURRENT_ADDRESS;
2140  NdisStatus = DoQueries(Adapter, AddressOID);
2141  if (NdisStatus == NDIS_STATUS_SUCCESS)
2142  {
2143  NdisStatus = MiniQueryInformation(Adapter, OID_802_3_MAXIMUM_LIST_SIZE, sizeof(UINT),
2144  &MaxMulticastAddresses, &BytesWritten);
2145 
2146  if (NdisStatus != NDIS_STATUS_SUCCESS)
2147  {
2149  NDIS_DbgPrint(MIN_TRACE, ("MiniQueryInformation failed (%x)\n", NdisStatus));
2150  return NdisStatus;
2151  }
2152 
2153  Success = EthCreateFilter(MaxMulticastAddresses,
2154  Adapter->Address.Type.Medium802_3,
2155  &Adapter->NdisMiniportBlock.EthDB);
2156  if (Success)
2157  ((PETHI_FILTER)Adapter->NdisMiniportBlock.EthDB)->Miniport = (PNDIS_MINIPORT_BLOCK)Adapter;
2158  else
2159  NdisStatus = NDIS_STATUS_RESOURCES;
2160  }
2161  break;
2162 
2163  default:
2164  /* FIXME: Support other types of media */
2165  NDIS_DbgPrint(MIN_TRACE, ("error: unsupported media\n"));
2166  ASSERT(FALSE);
2168  return STATUS_UNSUCCESSFUL;
2169  }
2170 
2171  if (NdisStatus != NDIS_STATUS_SUCCESS)
2172  {
2173  NDIS_DbgPrint(MIN_TRACE, ("couldn't create filter (%x)\n", NdisStatus));
2174  return NdisStatus;
2175  }
2176 
2177  /* Check for a hang every two seconds if it wasn't set in MiniportInitialize */
2178  if (Adapter->NdisMiniportBlock.CheckForHangSeconds == 0)
2180 
2181  Adapter->NdisMiniportBlock.OldPnPDeviceState = Adapter->NdisMiniportBlock.PnPDeviceState;
2182  Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceStarted;
2183 
2185 
2186  Timeout.QuadPart = Int32x32To64(Adapter->NdisMiniportBlock.CheckForHangSeconds, -1000000);
2188  Adapter->NdisMiniportBlock.CheckForHangSeconds * 1000,
2190 
2191  /* Put adapter in adapter list for this miniport */
2193 
2194  /* Refresh bindings for all protocols */
2195  CurrentEntry = ProtocolListHead.Flink;
2196  while (CurrentEntry != &ProtocolListHead)
2197  {
2198  ProtocolBinding = CONTAINING_RECORD(CurrentEntry, PROTOCOL_BINDING, ListEntry);
2199 
2200  ndisBindMiniportsToProtocol(&NdisStatus, ProtocolBinding);
2201 
2202  CurrentEntry = CurrentEntry->Flink;
2203  }
2204 
2205  return STATUS_SUCCESS;
2206 }
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:1745
_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:204
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
#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:445
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:279
#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:434
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:591
VOID NTAPI MiniStatus(IN NDIS_HANDLE MiniportHandle, IN NDIS_STATUS GeneralStatus, IN PVOID StatusBuffer, IN UINT StatusBufferSize)
Definition: miniport.c:1383
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:4210
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:480
NDIS_MEDIUM MediaType
Definition: ndis.h:2548
VOID NTAPI MiniIndicateReceivePacket(IN NDIS_HANDLE MiniportAdapterHandle, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets)
Definition: miniport.c:292
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:582
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:47
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:529
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:1416
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:575
#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:804
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:906
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:4565
#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:277
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
ULONG MediumHeaderSize
Definition: miniport.h:95
return STATUS_SUCCESS
Definition: btrfs.c:2745
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
union _HARDWARE_ADDRESS::@965 Type
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 2210 of file miniport.c.

2221 {
2223 
2224  /* Remove adapter from adapter list for this miniport */
2226 
2227  /* Remove adapter from global adapter list */
2229 
2231 
2232  /* Set this here so MiniportISR will be forced to run for interrup