ReactOS 0.4.16-dev-340-g0540c21
miniport.c File Reference
#include "ndissys.h"
#include <ndisguid.h>
Include dependency graph for miniport.c:

Go to the source code of this file.

Macros

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

Functions

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

Variables

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

Macro Definition Documentation

◆ BREAK_ON_MINIPORT_INIT

#define BREAK_ON_MINIPORT_INIT   0

Definition at line 22 of file miniport.c.

◆ MEDIA_ARRAY_SIZE

#define MEDIA_ARRAY_SIZE   15

Definition at line 31 of file miniport.c.

◆ ROUTE_DATA_SIZE

#define ROUTE_DATA_SIZE   256

Definition at line 28 of file miniport.c.

Function Documentation

◆ DoQueries()

NDIS_STATUS DoQueries ( PLOGICAL_ADAPTER  Adapter,
NDIS_OID  AddressOID 
)

Definition at line 1746 of file miniport.c.

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

Referenced by NdisIPnPStartDevice().

◆ MiniAdapterHasAddress()

BOOLEAN MiniAdapterHasAddress ( PLOGICAL_ADAPTER  Adapter,
PNDIS_PACKET  Packet 
)

Definition at line 616 of file miniport.c.

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

Referenced by ProSend().

◆ MiniCheckForHang()

BOOLEAN MiniCheckForHang ( PLOGICAL_ADAPTER  Adapter)

Definition at line 865 of file miniport.c.

874{
875 BOOLEAN Ret = FALSE;
877
879 if (Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CheckForHangHandler)
880 Ret = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CheckForHangHandler)(
883
884 return Ret;
885}
unsigned char BOOLEAN
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
NDIS_HANDLE MiniportAdapterContext
Definition: ndis.h:2510
PNDIS_M_DRIVER_BLOCK DriverHandle
Definition: ndis.h:2509
NDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics
Definition: miniport.h:22
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

Referenced by MiniportHangDpc().

◆ MiniDequeueWorkItem()

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

Definition at line 1050 of file miniport.c.

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

Referenced by MiniportWorker().

◆ MiniDoAddressingReset()

VOID MiniDoAddressingReset ( PLOGICAL_ADAPTER  Adapter)

Definition at line 888 of file miniport.c.

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

Referenced by MiniReset(), and MiniResetComplete().

◆ MiniDoRequest()

NDIS_STATUS MiniDoRequest ( PLOGICAL_ADAPTER  Adapter,
PNDIS_REQUEST  NdisRequest 
)

Definition at line 1107 of file miniport.c.

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

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

◆ MiniGetFirstWorkItem()

PNDIS_MINIPORT_WORK_ITEM MiniGetFirstWorkItem ( PLOGICAL_ADAPTER  Adapter,
NDIS_WORK_ITEM_TYPE  Type 
)

Definition at line 124 of file miniport.c.

127{
128 PNDIS_MINIPORT_WORK_ITEM CurrentEntry = Adapter->WorkQueueHead;
129
130 while (CurrentEntry)
131 {
132 if (CurrentEntry->WorkItemType == Type || Type == NdisMaxWorkItems)
133 return CurrentEntry;
134
135 CurrentEntry = (PNDIS_MINIPORT_WORK_ITEM)CurrentEntry->Link.Next;
136 }
137
138 return NULL;
139}
Type
Definition: Type.h:7
@ NdisMaxWorkItems
Definition: ndis.h:2302

Referenced by MiniIsBusy().

◆ MiniIndicateData()

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

Definition at line 175 of file miniport.c.

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

Referenced by EthFilterDprIndicateReceive(), and ProIndicatePacket().

◆ MiniIndicateReceivePacket()

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

Definition at line 293 of file miniport.c.

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

Referenced by NdisIPnPStartDevice().

◆ MiniIsBusy()

BOOLEAN MiniIsBusy ( PLOGICAL_ADAPTER  Adapter,
NDIS_WORK_ITEM_TYPE  Type 
)

Definition at line 142 of file miniport.c.

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

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

◆ MiniLocateDevice()

PLOGICAL_ADAPTER MiniLocateDevice ( PNDIS_STRING  AdapterName)

Definition at line 690 of file miniport.c.

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

Referenced by ndisBindMiniportsToProtocol(), and NdisOpenAdapter().

◆ MiniportHangDpc()

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

Definition at line 949 of file miniport.c.

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

Referenced by NdisIAddDevice().

◆ MiniportWorker()

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

Definition at line 1223 of file miniport.c.

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

Referenced by MiniWorkItemComplete().

◆ MiniQueryInformation()

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

Definition at line 805 of file miniport.c.

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

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

◆ MiniQueueWorkItem()

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

Definition at line 982 of file miniport.c.

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

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

◆ MiniRequestComplete()

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

Definition at line 481 of file miniport.c.

484{
489
490 NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
491
493
497
498 MacBlock = (PNDIS_REQUEST_MAC_BLOCK)Request->MacReserved;
499
500 /* We may or may not be doing this request on behalf of an adapter binding */
501 if (MacBlock->Binding != NULL)
502 {
503 /* We are, so invoke its request complete handler */
504 if (MacBlock->Binding->RequestCompleteHandler != NULL)
505 {
506 (*MacBlock->Binding->RequestCompleteHandler)(
507 MacBlock->Binding->ProtocolBindingContext,
508 Request,
509 Status);
510 }
511 }
512 else
513 {
514 /* We are doing this internally, so we'll signal this event we've stashed in the MacBlock */
515 ASSERT(MacBlock->Unknown1 != NULL);
516 ASSERT(MacBlock->Unknown3 == NULL);
517 MacBlock->Unknown3 = UlongToPtr(Status);
519 }
520
525
527}
struct _LOGICAL_ADAPTER * PLOGICAL_ADAPTER
#define UlongToPtr(u)
Definition: config.h:106
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
PNDIS_OPEN_BLOCK Binding
Definition: protocol.h:34
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by NdisIPnPStartDevice().

◆ MiniReset()

NDIS_STATUS MiniReset ( PLOGICAL_ADAPTER  Adapter)

Definition at line 902 of file miniport.c.

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

Referenced by MiniportHangDpc(), and ProReset().

◆ MiniResetComplete()

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

Definition at line 435 of file miniport.c.

439{
441 PLIST_ENTRY CurrentEntry;
442 PADAPTER_BINDING AdapterBinding;
444
445 if (AddressingReset)
446 MiniDoAddressingReset(Adapter);
447
450
452
454 {
455 KeBugCheckEx(BUGCODE_ID_DRIVER,
458 (ULONG_PTR)AddressingReset,
459 0);
460 }
461
463
464 CurrentEntry = Adapter->ProtocolListHead.Flink;
465
466 while (CurrentEntry != &Adapter->ProtocolListHead)
467 {
468 AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
469
470 (*AdapterBinding->ProtocolBinding->Chars.ResetCompleteHandler)(
471 AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
472 Status);
473
474 CurrentEntry = CurrentEntry->Flink;
475 }
476
478}
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:108
RESET_COMPLETE_HANDLER ResetCompleteHandler
Definition: ndis.h:1886
uint32_t ULONG_PTR
Definition: typedefs.h:65

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

◆ MiniSendComplete()

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

Definition at line 530 of file miniport.c.

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

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

◆ MiniSendResourcesAvailable()

VOID NTAPI MiniSendResourcesAvailable ( IN NDIS_HANDLE  MiniportAdapterHandle)

Definition at line 583 of file miniport.c.

585{
586 /* Run the work if anything is waiting */
588}

Referenced by NdisIPnPStartDevice(), and NdisMSendResourcesAvailable().

◆ MiniSetInformation()

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

Definition at line 756 of file miniport.c.

762{
763 NDIS_STATUS NdisStatus;
767
768 NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
769
771 if (!NdisRequest) {
772 NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
774 }
775
777
779 NdisRequest->DATA.SET_INFORMATION.Oid = Oid;
780 NdisRequest->DATA.SET_INFORMATION.InformationBuffer = Buffer;
781 NdisRequest->DATA.SET_INFORMATION.InformationBufferLength = Size;
782
783 /* We'll need to give the completion routine some way of letting us know
784 * when it's finished. We'll stash a pointer to an event in the MacBlock */
786 MacBlock = (PNDIS_REQUEST_MAC_BLOCK)NdisRequest->MacReserved;
787 MacBlock->Unknown1 = &Event;
788
789 NdisStatus = MiniDoRequest(Adapter, NdisRequest);
790
791 if (NdisStatus == NDIS_STATUS_PENDING)
792 {
794 NdisStatus = PtrToUlong(MacBlock->Unknown3);
795 }
796
797 *BytesRead = NdisRequest->DATA.SET_INFORMATION.BytesRead;
798
800
801 return NdisStatus;
802}

Referenced by MiniDoAddressingReset().

◆ MiniStatus()

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

Definition at line 1384 of file miniport.c.

1389{
1390 PLOGICAL_ADAPTER Adapter = MiniportHandle;
1391 PLIST_ENTRY CurrentEntry;
1392 PADAPTER_BINDING AdapterBinding;
1393 KIRQL OldIrql;
1394
1396
1397 CurrentEntry = Adapter->ProtocolListHead.Flink;
1398
1399 while (CurrentEntry != &Adapter->ProtocolListHead)
1400 {
1401 AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
1402
1403 (*AdapterBinding->ProtocolBinding->Chars.StatusHandler)(
1404 AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
1408
1409 CurrentEntry = CurrentEntry->Flink;
1410 }
1411
1413}
_In_opt_ NDIS_HANDLE _In_ NDIS_STATUS _In_ PVOID _In_ UINT StatusBufferSize
Definition: ndis.h:1558
_In_opt_ NDIS_HANDLE _In_ NDIS_STATUS _In_ PVOID StatusBuffer
Definition: ndis.h:1557
_In_opt_ NDIS_HANDLE _In_ NDIS_STATUS GeneralStatus
Definition: ndis.h:1556
STATUS_HANDLER StatusHandler
Definition: ndis.h:1893

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

◆ MiniStatusComplete()

VOID NTAPI MiniStatusComplete ( IN NDIS_HANDLE  MiniportAdapterHandle)

Definition at line 1417 of file miniport.c.

1419{
1421 PLIST_ENTRY CurrentEntry;
1422 PADAPTER_BINDING AdapterBinding;
1423 KIRQL OldIrql;
1424
1426
1427 CurrentEntry = Adapter->ProtocolListHead.Flink;
1428
1429 while (CurrentEntry != &Adapter->ProtocolListHead)
1430 {
1431 AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
1432
1433 (*AdapterBinding->ProtocolBinding->Chars.StatusCompleteHandler)(
1434 AdapterBinding->NdisOpenBlock.ProtocolBindingContext);
1435
1436 CurrentEntry = CurrentEntry->Flink;
1437 }
1438
1440}
STATUS_COMPLETE_HANDLER StatusCompleteHandler
Definition: ndis.h:1894

Referenced by NdisIPnPStartDevice(), and NdisMIndicateStatusComplete().

◆ MiniTransferDataComplete()

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

Definition at line 592 of file miniport.c.

597{
598 PADAPTER_BINDING AdapterBinding;
600
601 NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
602
603 AdapterBinding = (PADAPTER_BINDING)Packet->Reserved[1];
604
607 AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
608 Packet,
609 Status,
612}
TRANSFER_DATA_COMPLETE_HANDLER TransferDataCompleteHandler
Definition: ndis.h:1883
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET _In_opt_ PWDF_MEMORY_DESCRIPTOR _Out_opt_ PULONG BytesTransferred
Definition: wdfusb.h:1342

Referenced by NdisIPnPStartDevice(), and NdisMTransferDataComplete().

◆ MiniWorkItemComplete()

VOID MiniWorkItemComplete ( PLOGICAL_ADAPTER  Adapter,
NDIS_WORK_ITEM_TYPE  WorkItemType 
)

Definition at line 964 of file miniport.c.

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

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

◆ NdisCancelSendPackets()

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

Definition at line 3353 of file miniport.c.

3356{
3357 PADAPTER_BINDING AdapterBinding = NdisBindingHandle;
3358 PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
3359
3360 NDIS_DbgPrint(MAX_TRACE, ("Called for ID %x.\n", CancelId));
3361
3362 if (Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CancelSendPacketsHandler)
3363 {
3364 (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CancelSendPacketsHandler)(
3366 CancelId);
3367 }
3368}
LONG CancelId
Definition: main.c:23
_Must_inspect_result_ _In_ NDIS_HANDLE NdisBindingHandle
Definition: ndis.h:4735
PLOGICAL_ADAPTER Adapter
Definition: protocol.h:29

◆ NdisCompletePnPEvent()

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

Definition at line 3290 of file miniport.c.

3300{
3301 PIRP Irp = (PIRP)NetPnPEvent->NdisReserved[0];
3302 PLIST_ENTRY CurrentEntry = (PLIST_ENTRY)NetPnPEvent->NdisReserved[1];
3303 PADAPTER_BINDING AdapterBinding = NdisBindingHandle;
3304 PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
3305 NDIS_STATUS NdisStatus;
3306
3308 {
3309 if (NetPnPEvent->Buffer) ExFreePool(NetPnPEvent->Buffer);
3311 Irp->IoStatus.Status = Status;
3313 return;
3314 }
3315
3316 while (CurrentEntry != &Adapter->ProtocolListHead)
3317 {
3318 AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
3319
3320 NdisStatus = (*AdapterBinding->ProtocolBinding->Chars.PnPEventHandler)(
3321 AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
3322 NetPnPEvent);
3323
3324 if (NdisStatus == NDIS_STATUS_PENDING)
3325 {
3326 NetPnPEvent->NdisReserved[1] = (ULONG_PTR)CurrentEntry->Flink;
3327 return;
3328 }
3329 else if (NdisStatus != NDIS_STATUS_SUCCESS)
3330 {
3331 if (NetPnPEvent->Buffer) ExFreePool(NetPnPEvent->Buffer);
3333 Irp->IoStatus.Status = NdisStatus;
3335 return;
3336 }
3337
3338 CurrentEntry = CurrentEntry->Flink;
3339 }
3340
3341 if (NetPnPEvent->Buffer) ExFreePool(NetPnPEvent->Buffer);
3343
3344 Irp->IoStatus.Status = NDIS_STATUS_SUCCESS;
3346}
struct _IRP * PIRP
_In_ PIRP Irp
Definition: csq.h:116
_In_ NDIS_HANDLE _In_ PNET_PNP_EVENT NetPnPEvent
Definition: ndis.h:6082
#define IoCompleteRequest
Definition: irp.c:1240
PNP_EVENT_HANDLER PnPEventHandler
Definition: ndis.h:1899

◆ NdisDeregisterAdapterShutdownHandler()

VOID EXPORT NdisDeregisterAdapterShutdownHandler ( IN NDIS_HANDLE  NdisAdapterHandle)

Definition at line 3073 of file miniport.c.

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

◆ NdisGenericIrpHandler()

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

Definition at line 2574 of file miniport.c.

2577{
2579
2580 /* Use the characteristics to classify the device */
2581 if (DeviceObject->DeviceType == FILE_DEVICE_PHYSICAL_NETCARD)
2582 {
2583 if ((IrpSp->MajorFunction == IRP_MJ_CREATE) ||
2586 {
2588 }
2589 else if (IrpSp->MajorFunction == IRP_MJ_PNP)
2590 {
2592 }
2593 else if (IrpSp->MajorFunction == IRP_MJ_SHUTDOWN)
2594 {
2596 }
2598 {
2600 }
2601 else if (IrpSp->MajorFunction == IRP_MJ_POWER)
2602 {
2603 return NdisIPower(DeviceObject, Irp);
2604 }
2605 NDIS_DbgPrint(MIN_TRACE, ("Unexpected IRP MajorFunction 0x%x\n", IrpSp->MajorFunction));
2606 ASSERT(FALSE);
2607 }
2608 else if (DeviceObject->DeviceType == FILE_DEVICE_NETWORK)
2609 {
2610 PNDIS_M_DEVICE_BLOCK DeviceBlock = DeviceObject->DeviceExtension;
2611
2612 ASSERT(DeviceBlock->DeviceObject == DeviceObject);
2613
2614 if (DeviceBlock->MajorFunction[IrpSp->MajorFunction] != NULL)
2615 {
2616 return DeviceBlock->MajorFunction[IrpSp->MajorFunction](DeviceObject, Irp);
2617 }
2618 }
2619 else
2620 {
2621 ASSERT(FALSE);
2622 }
2623
2624 Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
2625 Irp->IoStatus.Information = 0;
2626
2628
2630}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
NTSTATUS NTAPI NdisIShutdown(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: miniport.c:2269
NTSTATUS NTAPI NdisIDispatchPnp(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: miniport.c:2335
NTSTATUS NTAPI NdisICreateClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: miniport.c:1871
NTSTATUS NTAPI NdisIDeviceIoControl(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: miniport.c:2291
NTSTATUS NTAPI NdisIPower(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: miniport.c:2407
#define FILE_DEVICE_PHYSICAL_NETCARD
Definition: winioctl.h:68
#define FILE_DEVICE_NETWORK
Definition: winioctl.h:63
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
PDEVICE_OBJECT DeviceObject
Definition: miniport.h:35
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: miniport.h:37
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define IRP_MJ_SHUTDOWN
#define IRP_MJ_POWER
#define IRP_MJ_CLEANUP

Referenced by NdisMRegisterMiniport().

◆ NdisIAddDevice()

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

Definition at line 2420 of file miniport.c.

2429{
2430 static const WCHAR ClassKeyName[] = {'C','l','a','s','s','\\'};
2431 static const WCHAR LinkageKeyName[] = {'\\','L','i','n','k','a','g','e',0};
2432 PNDIS_M_DRIVER_BLOCK Miniport;
2433 PNDIS_M_DRIVER_BLOCK *MiniportPtr;
2434 WCHAR *LinkageKeyBuffer;
2435 ULONG DriverKeyLength;
2437 UNICODE_STRING ExportName;
2439 PLOGICAL_ADAPTER Adapter;
2441
2442 /*
2443 * Gain the access to the miniport data structure first.
2444 */
2445
2446 MiniportPtr = IoGetDriverObjectExtension(DriverObject, (PVOID)'NMID');
2447 if (MiniportPtr == NULL)
2448 {
2449 NDIS_DbgPrint(MIN_TRACE, ("Can't get driver object extension.\n"));
2450 return NDIS_STATUS_FAILURE;
2451 }
2452 Miniport = *MiniportPtr;
2453
2454 /*
2455 * Get name of the Linkage registry key for our adapter. It's located under
2456 * the driver key for our driver and so we have basicly two ways to do it.
2457 * Either we can use IoOpenDriverRegistryKey or compose it using information
2458 * gathered by IoGetDeviceProperty. I chose the second because
2459 * IoOpenDriverRegistryKey wasn't implemented at the time of writing.
2460 */
2461
2463 0, NULL, &DriverKeyLength);
2465 {
2466 NDIS_DbgPrint(MIN_TRACE, ("Can't get miniport driver key length.\n"));
2467 return Status;
2468 }
2469
2470 LinkageKeyBuffer = ExAllocatePool(PagedPool, DriverKeyLength +
2471 sizeof(ClassKeyName) + sizeof(LinkageKeyName));
2472 if (LinkageKeyBuffer == NULL)
2473 {
2474 NDIS_DbgPrint(MIN_TRACE, ("Can't allocate memory for driver key name.\n"));
2476 }
2477
2479 DriverKeyLength, LinkageKeyBuffer +
2480 (sizeof(ClassKeyName) / sizeof(WCHAR)),
2481 &DriverKeyLength);
2482 if (!NT_SUCCESS(Status))
2483 {
2484 NDIS_DbgPrint(MIN_TRACE, ("Can't get miniport driver key.\n"));
2485 ExFreePool(LinkageKeyBuffer);
2486 return Status;
2487 }
2488
2489 /* Compose the linkage key name. */
2490 RtlCopyMemory(LinkageKeyBuffer, ClassKeyName, sizeof(ClassKeyName));
2491 RtlCopyMemory(LinkageKeyBuffer + ((sizeof(ClassKeyName) + DriverKeyLength) /
2492 sizeof(WCHAR)) - 1, LinkageKeyName, sizeof(LinkageKeyName));
2493
2494 NDIS_DbgPrint(DEBUG_MINIPORT, ("LinkageKey: %S.\n", LinkageKeyBuffer));
2495
2496 /*
2497 * Now open the linkage key and read the "Export" and "RootDevice" values
2498 * which contains device name and root service respectively.
2499 */
2500
2502 RtlInitUnicodeString(&ExportName, NULL);
2504 QueryTable[0].Name = L"Export";
2505 QueryTable[0].EntryContext = &ExportName;
2506
2508 QueryTable, NULL, NULL);
2509 ExFreePool(LinkageKeyBuffer);
2510 if (!NT_SUCCESS(Status))
2511 {
2512 NDIS_DbgPrint(MIN_TRACE, ("Can't get miniport device name. (%x)\n", Status));
2513 return Status;
2514 }
2515
2516 /*
2517 * Create the device object.
2518 */
2519
2520 NDIS_DbgPrint(MAX_TRACE, ("creating device %wZ\n", &ExportName));
2521
2523 &ExportName, FILE_DEVICE_PHYSICAL_NETCARD,
2524 0, FALSE, &DeviceObject);
2525 if (!NT_SUCCESS(Status))
2526 {
2527 NDIS_DbgPrint(MIN_TRACE, ("Could not create device object.\n"));
2528 RtlFreeUnicodeString(&ExportName);
2529 return Status;
2530 }
2531
2532 /*
2533 * Initialize the adapter structure.
2534 */
2535
2536 Adapter = (PLOGICAL_ADAPTER)DeviceObject->DeviceExtension;
2539
2541 &GUID_DEVINTERFACE_NET,
2542 NULL,
2544
2545 if (!NT_SUCCESS(Status))
2546 {
2547 NDIS_DbgPrint(MIN_TRACE, ("Could not create device interface.\n"));
2549 RtlFreeUnicodeString(&ExportName);
2550 return Status;
2551 }
2552
2553 Adapter->NdisMiniportBlock.DriverHandle = Miniport;
2554 Adapter->NdisMiniportBlock.MiniportName = ExportName;
2560
2561 Adapter->NdisMiniportBlock.OldPnPDeviceState = 0;
2562 Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceAdded;
2563
2566
2567 DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
2568
2569 return STATUS_SUCCESS;
2570}
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:712
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
#define PagedPool
Definition: env_spec_w32.h:308
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
@ NdisPnPDeviceAdded
Definition: ndis.h:990
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
Definition: rtlfuncs.h:4220
VOID NTAPI MiniportHangDpc(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
Definition: miniport.c:949
#define RTL_REGISTRY_CONTROL
Definition: nt_native.h:163
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RTL_QUERY_REGISTRY_REQUIRED
Definition: nt_native.h:132
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
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
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:955
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1904
#define L(x)
Definition: ntvdm.h:50
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:1382
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
PDEVICE_OBJECT NextDeviceObject
Definition: ndis.h:2554
UNICODE_STRING SymbolicLinkName
Definition: ndis.h:2537
PDEVICE_OBJECT PhysicalDeviceObject
Definition: ndis.h:2553
NDIS_TIMER WakeUpDpcTimer
Definition: ndis.h:2535
PDRIVER_OBJECT DriverObject
Definition: miniport.h:24
KDPC Dpc
Definition: ndis.h:644
KTIMER Timer
Definition: ndis.h:643
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
@ DevicePropertyDriverKeyName
Definition: iotypes.h:1202
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by NdisMRegisterMiniport().

◆ NdisIBugcheckCallback()

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

Definition at line 1670 of file miniport.c.

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

Referenced by NdisMRegisterAdapterShutdownHandler().

◆ NdisICreateClose()

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

Definition at line 1871 of file miniport.c.

1874{
1875 Irp->IoStatus.Status = STATUS_SUCCESS;
1876 Irp->IoStatus.Information = 0;
1877
1879
1880 return STATUS_SUCCESS;
1881}

Referenced by NdisGenericIrpHandler().

◆ NdisIDeviceIoControl()

NTSTATUS NTAPI NdisIDeviceIoControl ( IN PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 2291 of file miniport.c.

2294{
2295 PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)DeviceObject->DeviceExtension;
2299 ULONG Written;
2300
2301 Irp->IoStatus.Information = 0;
2302
2303 ASSERT(Adapter);
2304
2305 ControlCode = Stack->Parameters.DeviceIoControl.IoControlCode;
2306 switch (ControlCode)
2307 {
2309 Status = MiniQueryInformation(Adapter,
2310 *(PNDIS_OID)Irp->AssociatedIrp.SystemBuffer,
2311 Stack->Parameters.DeviceIoControl.OutputBufferLength,
2312 MmGetSystemAddressForMdl(Irp->MdlAddress),
2313 &Written);
2314 Irp->IoStatus.Information = Written;
2315 break;
2316
2317 default:
2318 NDIS_DbgPrint(MIN_TRACE, ("NdisIDeviceIoControl: unsupported control code 0x%lx\n", ControlCode));
2319 break;
2320 }
2321
2323 {
2324 Irp->IoStatus.Status = Status;
2326 }
2327 else
2329
2330 return Status;
2331}
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
IoMarkIrpPending(Irp)
#define IOCTL_NDIS_QUERY_GLOBAL_STATS
Definition: ntddndis.h:443
ULONG * PNDIS_OID
Definition: ntddndis.h:230
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
#define MmGetSystemAddressForMdl(Mdl)

Referenced by NdisGenericIrpHandler().

◆ NdisIDispatchPnp()

NTSTATUS NTAPI NdisIDispatchPnp ( IN PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 2335 of file miniport.c.

2338{
2340 PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)DeviceObject->DeviceExtension;
2342
2343 switch (Stack->MinorFunction)
2344 {
2346 Status = NdisIForwardIrpAndWait(Adapter, Irp);
2347 if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
2348 {
2350 }
2351 else
2352 NDIS_DbgPrint(MIN_TRACE, ("Lower driver failed device start\n"));
2353 Irp->IoStatus.Status = Status;
2355 return Status;
2356
2357 case IRP_MN_STOP_DEVICE:
2359 if (!NT_SUCCESS(Status))
2360 NDIS_DbgPrint(MIN_TRACE, ("WARNING: Ignoring halt device failure! Passing the IRP down anyway\n"));
2361 Irp->IoStatus.Status = STATUS_SUCCESS;
2362 break;
2363
2367 Irp->IoStatus.Status = Status;
2368 if (Status != STATUS_SUCCESS)
2369 {
2371 NDIS_DbgPrint(MIN_TRACE, ("Failing miniport halt request\n"));
2372 return Status;
2373 }
2374 break;
2375
2378 Status = NdisIForwardIrpAndWait(Adapter, Irp);
2379 if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
2380 {
2382 }
2383 else
2384 {
2385 NDIS_DbgPrint(MIN_TRACE, ("Lower driver failed cancel stop/remove request\n"));
2386 }
2387 Irp->IoStatus.Status = Status;
2389 return Status;
2390
2393 Irp->IoStatus.Status = Status;
2394 Irp->IoStatus.Information |= Adapter->NdisMiniportBlock.PnPFlags;
2395 break;
2396
2397 default:
2398 break;
2399 }
2400
2403}
switch(r->id)
Definition: btrfs.c:3046
NTSTATUS NTAPI NdisIPnPCancelStopDevice(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: protocol.c:172
NTSTATUS NTAPI NdisIPnPQueryStopDevice(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: protocol.c:154
NTSTATUS NTAPI NdisIForwardIrpAndWait(PLOGICAL_ADAPTER Adapter, PIRP Irp)
Definition: miniport.c:1851
NTSTATUS NTAPI NdisIPnPStartDevice(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: miniport.c:1885
NTSTATUS NTAPI NdisIPnPStopDevice(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: miniport.c:2211
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCallDriver
Definition: irp.c:1225
#define IRP_MN_CANCEL_STOP_DEVICE
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_STOP_DEVICE
#define IRP_MN_QUERY_REMOVE_DEVICE

Referenced by NdisGenericIrpHandler().

◆ NdisIForwardIrpAndWait()

NTSTATUS NTAPI NdisIForwardIrpAndWait ( PLOGICAL_ADAPTER  Adapter,
PIRP  Irp 
)

Definition at line 1851 of file miniport.c.

1852{
1853 KEVENT Event;
1855
1859 TRUE, TRUE, TRUE);
1861 if (Status == STATUS_PENDING)
1862 {
1864 Status = Irp->IoStatus.Status;
1865 }
1866 return Status;
1867}
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:490
NTSTATUS NTAPI NdisIForwardIrpAndWaitCompletionRoutine(PDEVICE_OBJECT Fdo, PIRP Irp, PVOID Context)
Definition: miniport.c:1836
#define IoCopyCurrentIrpStackLocationToNext(Irp)
Definition: ntifs_ex.h:413

Referenced by NdisIDispatchPnp().

◆ NdisIForwardIrpAndWaitCompletionRoutine()

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

Definition at line 1836 of file miniport.c.

1840{
1842
1843 if (Irp->PendingReturned)
1845
1847}
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68

Referenced by NdisIForwardIrpAndWait().

◆ NdisIMGetBindingContext()

NDIS_HANDLE EXPORT NdisIMGetBindingContext ( IN NDIS_HANDLE  NdisBindingHandle)

Definition at line 3376 of file miniport.c.

3384{
3385 PADAPTER_BINDING AdapterBinding = NdisBindingHandle;
3386 PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
3387
3388 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
3389
3390 return Adapter->NdisMiniportBlock.DeviceContext;
3391}
NDIS_HANDLE DeviceContext
Definition: ndis.h:2515

◆ NdisIMGetDeviceContext()

NDIS_HANDLE EXPORT NdisIMGetDeviceContext ( IN NDIS_HANDLE  MiniportAdapterHandle)

Definition at line 3399 of file miniport.c.

3407{
3409
3410 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
3411
3412 return Adapter->NdisMiniportBlock.DeviceContext;
3413}

◆ NdisInitializeWrapper()

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

Definition at line 1591 of file miniport.c.

1606{
1607 PNDIS_M_DRIVER_BLOCK Miniport;
1609 WCHAR *RegistryBuffer;
1610
1611 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
1612
1613 ASSERT(NdisWrapperHandle);
1614
1615 *NdisWrapperHandle = NULL;
1616
1617#if BREAK_ON_MINIPORT_INIT
1618 DbgBreakPoint();
1619#endif
1620
1621 Miniport = ExAllocatePool(NonPagedPool, sizeof(NDIS_M_DRIVER_BLOCK));
1622
1623 if (!Miniport)
1624 {
1625 NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1626 return;
1627 }
1628
1629 RtlZeroMemory(Miniport, sizeof(NDIS_M_DRIVER_BLOCK));
1630
1631 KeInitializeSpinLock(&Miniport->Lock);
1632
1633 Miniport->DriverObject = (PDRIVER_OBJECT)SystemSpecific1;
1634
1635 /* set the miniport's driver registry path */
1637 if(!RegistryPath)
1638 {
1639 ExFreePool(Miniport);
1640 NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1641 return;
1642 }
1643
1644 RegistryPath->Length = ((PUNICODE_STRING)SystemSpecific2)->Length;
1645 RegistryPath->MaximumLength = RegistryPath->Length + sizeof(WCHAR); /* room for 0-term */
1646
1647 RegistryBuffer = ExAllocatePool(PagedPool, RegistryPath->MaximumLength);
1648 if(!RegistryBuffer)
1649 {
1650 NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1651 ExFreePool(Miniport);
1653 return;
1654 }
1655
1656 RtlCopyMemory(RegistryBuffer, ((PUNICODE_STRING)SystemSpecific2)->Buffer, RegistryPath->Length);
1657 RegistryBuffer[RegistryPath->Length/sizeof(WCHAR)] = 0;
1658
1659 RegistryPath->Buffer = RegistryBuffer;
1660 Miniport->RegistryPath = RegistryPath;
1661
1662 InitializeListHead(&Miniport->DeviceList);
1663
1664 /* Put miniport in global miniport list */
1666
1667 *NdisWrapperHandle = Miniport;
1668}
UNICODE_STRING * PUNICODE_STRING
Definition: env_spec_w32.h:373
NTSYSAPI void WINAPI DbgBreakPoint(void)
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
_In_ PVOID _In_ PVOID SystemSpecific2
Definition: ndis.h:638
LIST_ENTRY MiniportListHead
Definition: miniport.c:53
KSPIN_LOCK MiniportListLock
Definition: miniport.c:54
LIST_ENTRY DeviceList
Definition: miniport.h:25
LIST_ENTRY ListEntry
Definition: miniport.h:20
PUNICODE_STRING RegistryPath
Definition: miniport.h:26
KSPIN_LOCK Lock
Definition: miniport.h:21
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
struct _DRIVER_OBJECT * PDRIVER_OBJECT

◆ NdisIPnPStartDevice()

NTSTATUS NTAPI NdisIPnPStartDevice ( IN PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 1885 of file miniport.c.

1896{
1898 PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)DeviceObject->DeviceExtension;
1899 NDIS_WRAPPER_CONTEXT WrapperContext;
1900 NDIS_STATUS NdisStatus;
1904 NDIS_OID AddressOID;
1907 ULONG ResourceListSize;
1908 UNICODE_STRING ParamName;
1910 NDIS_HANDLE ConfigHandle;
1911 ULONG Size;
1913 UINT MaxMulticastAddresses;
1915 PLIST_ENTRY CurrentEntry;
1916 PPROTOCOL_BINDING ProtocolBinding;
1917
1918 /*
1919 * Prepare wrapper context used by HW and configuration routines.
1920 */
1921
1922 NDIS_DbgPrint(DEBUG_MINIPORT, ("Start Device %wZ\n", &Adapter->NdisMiniportBlock.MiniportName));
1923
1924 NDIS_DbgPrint(MAX_TRACE, ("Inserting adapter 0x%x into adapter list\n", Adapter));
1925
1926 /* Put adapter in global adapter list */
1928
1931 KEY_ALL_ACCESS, &WrapperContext.RegistryHandle);
1932 if (!NT_SUCCESS(Status))
1933 {
1934 NDIS_DbgPrint(MIN_TRACE,("failed to open adapter-specific reg key\n"));
1936 return Status;
1937 }
1938
1939 NDIS_DbgPrint(MAX_TRACE, ("opened device reg key\n"));
1940
1941 WrapperContext.DeviceObject = Adapter->NdisMiniportBlock.DeviceObject;
1942
1943 /*
1944 * Store the adapter resources used by HW routines such as
1945 * NdisMQueryAdapterResources.
1946 */
1947
1948 if (Stack->Parameters.StartDevice.AllocatedResources != NULL)
1949 {
1950 ResourceCount = Stack->Parameters.StartDevice.AllocatedResources->List[0].
1951 PartialResourceList.Count;
1952 ResourceListSize =
1953 FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
1954 PartialDescriptors[ResourceCount]);
1955
1956 Adapter->NdisMiniportBlock.AllocatedResources =
1957 ExAllocatePool(PagedPool, ResourceListSize);
1958 if (Adapter->NdisMiniportBlock.AllocatedResources == NULL)
1959 {
1960 NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
1963 }
1964
1965 Adapter->NdisMiniportBlock.Resources =
1966 ExAllocatePool(PagedPool, ResourceListSize);
1967 if (!Adapter->NdisMiniportBlock.Resources)
1968 {
1969 NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
1970 ExFreePool(Adapter->NdisMiniportBlock.AllocatedResources);
1973 }
1974
1976 Stack->Parameters.StartDevice.AllocatedResources,
1977 ResourceListSize);
1978
1979 RtlCopyMemory(Adapter->NdisMiniportBlock.AllocatedResources,
1980 Stack->Parameters.StartDevice.AllocatedResources,
1981 ResourceListSize);
1982 }
1983
1984 if (Stack->Parameters.StartDevice.AllocatedResourcesTranslated != NULL)
1985 {
1986 ResourceCount = Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].
1987 PartialResourceList.Count;
1988 ResourceListSize =
1989 FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
1990 PartialDescriptors[ResourceCount]);
1991
1992 Adapter->NdisMiniportBlock.AllocatedResourcesTranslated =
1993 ExAllocatePool(PagedPool, ResourceListSize);
1994 if (Adapter->NdisMiniportBlock.AllocatedResourcesTranslated == NULL)
1995 {
1996 NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
1999 }
2000
2001 RtlCopyMemory(Adapter->NdisMiniportBlock.AllocatedResourcesTranslated,
2002 Stack->Parameters.StartDevice.AllocatedResourcesTranslated,
2003 ResourceListSize);
2004 }
2005
2006 /*
2007 * Store the Bus Type, Bus Number and Slot information. It's used by
2008 * the hardware routines then.
2009 */
2010
2011 NdisOpenConfiguration(&NdisStatus, &ConfigHandle, (NDIS_HANDLE)&WrapperContext);
2012 if (NdisStatus != NDIS_STATUS_SUCCESS)
2013 {
2014 NDIS_DbgPrint(MIN_TRACE, ("Failed to open configuration key\n"));
2016 return NdisStatus;
2017 }
2018
2019 Size = sizeof(ULONG);
2022 &Adapter->NdisMiniportBlock.BusType, &Size);
2024 {
2025 NdisInitUnicodeString(&ParamName, L"BusType");
2026 NdisReadConfiguration(&NdisStatus, &ConfigParam, ConfigHandle,
2027 &ParamName, NdisParameterInteger);
2028 if (NdisStatus == NDIS_STATUS_SUCCESS)
2029 Adapter->NdisMiniportBlock.BusType = ConfigParam->ParameterData.IntegerData;
2030 else
2031 Adapter->NdisMiniportBlock.BusType = Isa;
2032 }
2033
2036 &Adapter->NdisMiniportBlock.BusNumber, &Size);
2037 if (!NT_SUCCESS(Status) || Adapter->NdisMiniportBlock.BusNumber == 0xFFFFFFF0)
2038 {
2039 NdisInitUnicodeString(&ParamName, L"BusNumber");
2040 NdisReadConfiguration(&NdisStatus, &ConfigParam, ConfigHandle,
2041 &ParamName, NdisParameterInteger);
2042 if (NdisStatus == NDIS_STATUS_SUCCESS)
2043 Adapter->NdisMiniportBlock.BusNumber = ConfigParam->ParameterData.IntegerData;
2044 else
2045 Adapter->NdisMiniportBlock.BusNumber = 0;
2046 }
2047 WrapperContext.BusNumber = Adapter->NdisMiniportBlock.BusNumber;
2048
2051 &Adapter->NdisMiniportBlock.SlotNumber, &Size);
2052 if (!NT_SUCCESS(Status) || Adapter->NdisMiniportBlock.SlotNumber == (NDIS_INTERFACE_TYPE)-1)
2053 {
2054 NdisInitUnicodeString(&ParamName, L"SlotNumber");
2055 NdisReadConfiguration(&NdisStatus, &ConfigParam, ConfigHandle,
2056 &ParamName, NdisParameterInteger);
2057 if (NdisStatus == NDIS_STATUS_SUCCESS)
2058 Adapter->NdisMiniportBlock.SlotNumber = ConfigParam->ParameterData.IntegerData;
2059 else
2060 Adapter->NdisMiniportBlock.SlotNumber = 0;
2061 }
2062 else
2063 {
2064 /* Convert slotnumber to PCI_SLOT_NUMBER */
2065 ULONG PciSlotNumber = Adapter->NdisMiniportBlock.SlotNumber;
2067
2068 SlotNumber.u.AsULONG = 0;
2069 SlotNumber.u.bits.DeviceNumber = (PciSlotNumber >> 16) & 0xFFFF;
2070 SlotNumber.u.bits.FunctionNumber = PciSlotNumber & 0xFFFF;
2071
2072 Adapter->NdisMiniportBlock.SlotNumber = SlotNumber.u.AsULONG;
2073 }
2074 WrapperContext.SlotNumber = Adapter->NdisMiniportBlock.SlotNumber;
2075
2076 NdisCloseConfiguration(ConfigHandle);
2077
2078 /* Set handlers (some NDIS macros require these) */
2091
2092 /*
2093 * Call MiniportInitialize.
2094 */
2095
2096 NDIS_DbgPrint(MID_TRACE, ("calling MiniportInitialize\n"));
2097 NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.InitializeHandler)(
2099 MEDIA_ARRAY_SIZE, Adapter, (NDIS_HANDLE)&WrapperContext);
2100
2101 ZwClose(WrapperContext.RegistryHandle);
2102
2103 if (NdisStatus != NDIS_STATUS_SUCCESS)
2104 {
2105 NDIS_DbgPrint(MIN_TRACE, ("MiniportInitialize() failed for an adapter (%lx).\n", NdisStatus));
2107 if (Adapter->NdisMiniportBlock.Interrupt)
2108 {
2109 KeBugCheckEx(BUGCODE_ID_DRIVER,
2110 (ULONG_PTR)Adapter,
2111 (ULONG_PTR)Adapter->NdisMiniportBlock.Interrupt,
2112 (ULONG_PTR)Adapter->NdisMiniportBlock.TimerQueue,
2113 1);
2114 }
2115 if (Adapter->NdisMiniportBlock.TimerQueue)
2116 {
2117 KeBugCheckEx(BUGCODE_ID_DRIVER,
2118 (ULONG_PTR)Adapter,
2119 (ULONG_PTR)Adapter->NdisMiniportBlock.Interrupt,
2120 (ULONG_PTR)Adapter->NdisMiniportBlock.TimerQueue,
2121 1);
2122 }
2123 return NdisStatus;
2124 }
2125
2127 {
2128 NDIS_DbgPrint(MIN_TRACE, ("MiniportInitialize() selected a bad index\n"));
2131 }
2132
2134
2135 switch (Adapter->NdisMiniportBlock.MediaType)
2136 {
2137 case NdisMedium802_3:
2138 Adapter->MediumHeaderSize = 14; /* XXX figure out what to do about LLC */
2139 AddressOID = OID_802_3_CURRENT_ADDRESS;
2141 NdisStatus = DoQueries(Adapter, AddressOID);
2142 if (NdisStatus == NDIS_STATUS_SUCCESS)
2143 {
2144 NdisStatus = MiniQueryInformation(Adapter, OID_802_3_MAXIMUM_LIST_SIZE, sizeof(UINT),
2145 &MaxMulticastAddresses, &BytesWritten);
2146
2147 if (NdisStatus != NDIS_STATUS_SUCCESS)
2148 {
2150 NDIS_DbgPrint(MIN_TRACE, ("MiniQueryInformation failed (%x)\n", NdisStatus));
2151 return NdisStatus;
2152 }
2153
2154 Success = EthCreateFilter(MaxMulticastAddresses,
2155 Adapter->Address.Type.Medium802_3,
2156 &Adapter->NdisMiniportBlock.EthDB);
2157 if (Success)
2158 ((PETHI_FILTER)Adapter->NdisMiniportBlock.EthDB)->Miniport = (PNDIS_MINIPORT_BLOCK)Adapter;
2159 else
2160 NdisStatus = NDIS_STATUS_RESOURCES;
2161 }
2162 break;
2163
2164 default:
2165 /* FIXME: Support other types of media */
2166 NDIS_DbgPrint(MIN_TRACE, ("error: unsupported media\n"));
2167 ASSERT(FALSE);
2169 return STATUS_UNSUCCESSFUL;
2170 }
2171
2172 if (NdisStatus != NDIS_STATUS_SUCCESS)
2173 {
2174 NDIS_DbgPrint(MIN_TRACE, ("couldn't create filter (%x)\n", NdisStatus));
2175 return NdisStatus;
2176 }
2177
2178 /* Check for a hang every two seconds if it wasn't set in MiniportInitialize */
2179 if (Adapter->NdisMiniportBlock.CheckForHangSeconds == 0)
2181
2182 Adapter->NdisMiniportBlock.OldPnPDeviceState = Adapter->NdisMiniportBlock.PnPDeviceState;
2183 Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceStarted;
2184
2186
2187 Timeout.QuadPart = Int32x32To64(Adapter->NdisMiniportBlock.CheckForHangSeconds, -1000000);
2189 Adapter->NdisMiniportBlock.CheckForHangSeconds * 1000,
2191
2192 /* Put adapter in adapter list for this miniport */
2194
2195 /* Refresh bindings for all protocols */
2196 CurrentEntry = ProtocolListHead.Flink;
2197 while (CurrentEntry != &ProtocolListHead)
2198 {
2199 ProtocolBinding = CONTAINING_RECORD(CurrentEntry, PROTOCOL_BINDING, ListEntry);
2200
2201 ndisBindMiniportsToProtocol(&NdisStatus, ProtocolBinding);
2202
2203 CurrentEntry = CurrentEntry->Flink;
2204 }
2205
2206 return STATUS_SUCCESS;
2207}
LIST_ENTRY ProtocolListHead
Definition: protocol.c:19
VOID NTAPI ndisBindMiniportsToProtocol(OUT PNDIS_STATUS Status, IN PPROTOCOL_BINDING Protocol)
Definition: protocol.c:908
VOID NTAPI ProSendPackets(IN NDIS_HANDLE NdisBindingHandle, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets)
Definition: protocol.c:577
VOID EXPORT NdisCloseConfiguration(IN NDIS_HANDLE ConfigurationHandle)
Definition: config.c:136
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 EXPORT NdisOpenConfiguration(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE ConfigurationHandle, IN NDIS_HANDLE WrapperConfigurationContext)
Definition: config.c:197
VOID EXPORT NdisInitUnicodeString(IN OUT PNDIS_STRING DestinationString, IN PCWSTR SourceString)
Definition: string.c:130
VOID NTAPI EthFilterDprIndicateReceiveComplete(IN PETH_FILTER Filter)
Definition: efilter.c:113
struct ETHI_FILTER * PETHI_FILTER
BOOLEAN NTAPI EthCreateFilter(IN UINT MaximumMulticastAddresses, IN PUCHAR AdapterAddress, OUT PETH_FILTER *Filter)
Definition: efilter.c:16
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
@ Success
Definition: eventcreate.c:712
@ InterfaceTypeUndefined
Definition: hwresource.cpp:136
@ Isa
Definition: hwresource.cpp:138
enum _INTERFACE_TYPE INTERFACE_TYPE
static ULONG ResourceCount
Definition: inbv.c:50
@ NdisPnPDeviceStarted
Definition: ndis.h:991
@ NdisParameterInteger
Definition: ndis.h:926
struct _NDIS_MINIPORT_BLOCK * PNDIS_MINIPORT_BLOCK
Definition: ndis.h:319
enum _NDIS_INTERFACE_TYPE NDIS_INTERFACE_TYPE
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT SelectedMediumIndex
Definition: ndis.h:6011
#define NDIS_STATUS_UNSUPPORTED_MEDIA
Definition: ndis.h:490
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS OpenErrorStatus
Definition: ndis.h:6009
#define ExInterlockedRemoveEntryList(_List, _Lock)
Definition: ndissys.h:37
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define MEDIA_ARRAY_SIZE
Definition: miniport.c:31
NDIS_STATUS DoQueries(PLOGICAL_ADAPTER Adapter, NDIS_OID AddressOID)
Definition: miniport.c:1746
VOID NTAPI MiniSendResourcesAvailable(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:583
VOID NTAPI MiniStatus(IN NDIS_HANDLE MiniportHandle, IN NDIS_STATUS GeneralStatus, IN PVOID StatusBuffer, IN UINT StatusBufferSize)
Definition: miniport.c:1384
VOID NTAPI MiniStatusComplete(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:1417
VOID NTAPI MiniTransferDataComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status, IN UINT BytesTransferred)
Definition: miniport.c:592
VOID NTAPI MiniIndicateReceivePacket(IN NDIS_HANDLE MiniportAdapterHandle, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets)
Definition: miniport.c:293
static NDIS_MEDIUM MediaArray[MEDIA_ARRAY_SIZE]
Definition: miniport.c:33
VOID NTAPI MiniRequestComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status)
Definition: miniport.c:481
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define Int32x32To64(a, b)
#define OID_802_3_MAXIMUM_LIST_SIZE
Definition: ntddndis.h:305
#define OID_802_3_CURRENT_ADDRESS
Definition: ntddndis.h:303
ULONG NDIS_OID
Definition: ntddndis.h:230
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
static ULONG Timeout
Definition: ping.c:61
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:1621
LIST_ENTRY ListEntry
Definition: miniport.h:92
ULONG MediumHeaderSize
Definition: miniport.h:95
LIST_ENTRY MiniportListEntry
Definition: miniport.h:93
PCM_RESOURCE_LIST Resources
Definition: ndis.h:2534
NDIS_M_REQ_COMPLETE_HANDLER SetCompleteHandler
Definition: ndis.h:2586
NDIS_M_SEND_COMPLETE_HANDLER SendCompleteHandler
Definition: ndis.h:2545
ETH_RCV_COMPLETE_HANDLER EthRxCompleteHandler
Definition: ndis.h:2579
NDIS_M_STATUS_HANDLER StatusHandler
Definition: ndis.h:2582
ETH_RCV_INDICATE_HANDLER EthRxIndicateHandler
Definition: ndis.h:2576
W_SEND_PACKETS_HANDLER SendPacketsHandler
Definition: ndis.h:2574
NDIS_M_TD_COMPLETE_HANDLER TDCompleteHandler
Definition: ndis.h:2584
NDIS_M_RESET_COMPLETE_HANDLER ResetCompleteHandler
Definition: ndis.h:2547
ULONG CheckForHangSeconds
Definition: ndis.h:2538
NDIS_INTERFACE_TYPE BusType
Definition: ndis.h:2550
NDIS_M_STS_COMPLETE_HANDLER StatusCompleteHandler
Definition: ndis.h:2583
PNDIS_MINIPORT_INTERRUPT Interrupt
Definition: ndis.h:2522
PNDIS_MINIPORT_TIMER TimerQueue
Definition: ndis.h:2564
NDIS_M_SEND_RESOURCES_HANDLER SendResourcesHandler
Definition: ndis.h:2546
FILTERDBS_S FILTER_PACKET_INDICATION_HANDLER PacketIndicateHandler
Definition: ndis.h:2544
NDIS_M_REQ_COMPLETE_HANDLER QueryCompleteHandler
Definition: ndis.h:2585
BOOLEAN NTAPI KeSetTimerEx(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN LONG Period, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:294
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define PLUGPLAY_REGKEY_DRIVER
Definition: usbd.c:42
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:68
@ DevicePropertyAddress
Definition: iotypes.h:1211
@ DevicePropertyBusNumber
Definition: iotypes.h:1209
@ DevicePropertyLegacyBusType
Definition: iotypes.h:1208

Referenced by NdisIDispatchPnp().

◆ NdisIPnPStopDevice()

NTSTATUS NTAPI NdisIPnPStopDevice ( IN PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 2211 of file miniport.c.

2222{
2223 PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)DeviceObject->DeviceExtension;
2224
2225 /* Remove adapter from adapter list for this miniport */
2227
2228 /* Remove adapter from global adapter list */
2230
2232
2233 /* Set this here so MiniportISR will be forced to run for interrupts generated in MiniportHalt */
2234 Adapter->NdisMiniportBlock.OldPnPDeviceState = Adapter->NdisMiniportBlock.PnPDeviceState;
2235 Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceStopped;
2236
2237 (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.HaltHandler)(Adapter);
2238
2240
2241 if (Adapter->NdisMiniportBlock.AllocatedResources)
2242 {
2243 ExFreePool(Adapter->NdisMiniportBlock.AllocatedResources);
2244 Adapter->NdisMiniportBlock.AllocatedResources = NULL;
2245 }
2246 if (Adapter->NdisMiniportBlock.AllocatedResourcesTranslated)
2247 {
2248 ExFreePool(Adapter->NdisMiniportBlock.AllocatedResourcesTranslated);
2249 Adapter->NdisMiniportBlock.AllocatedResourcesTranslated = NULL;
2250 }
2251
2252 if (Adapter->NdisMiniportBlock.Resources)
2253 {
2255 Adapter->NdisMiniportBlock.Resources = NULL;
2256 }
2257
2258 if (Adapter->NdisMiniportBlock.EthDB)
2259 {
2260 EthDeleteFilter(Adapter->NdisMiniportBlock.EthDB);
2261 Adapter->NdisMiniportBlock.EthDB = NULL;
2262 }
2263
2264 return STATUS_SUCCESS;
2265}
VOID NTAPI EthDeleteFilter(IN PETH_FILTER Filter)
Definition: efilter.c:57
@ NdisPnPDeviceStopped
Definition: ndis.h:993
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206

Referenced by NdisIDispatchPnp().

◆ NdisIPower()

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

Definition at line 2407 of file miniport.c.

2410{
2411 PLOGICAL_ADAPTER Adapter = DeviceObject->DeviceExtension;
2412
2415 return PoCallDriver(Adapter->NdisMiniportBlock.NextDeviceObject, Irp);
2416}
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:758

Referenced by NdisGenericIrpHandler().

◆ NdisIShutdown()

NTSTATUS NTAPI NdisIShutdown ( IN PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 2269 of file miniport.c.

2272{
2273 PLOGICAL_ADAPTER Adapter = DeviceObject->DeviceExtension;
2276
2278
2279 ShutdownHandler(Context->DriverContext);
2280
2281 Irp->IoStatus.Status = STATUS_SUCCESS;
2282 Irp->IoStatus.Information = 0;
2283
2285
2286 return STATUS_SUCCESS;
2287}
PMINIPORT_BUGCHECK_CONTEXT BugcheckContext
Definition: miniport.h:98
@ ShutdownHandler
Definition: winlogon.h:263

Referenced by NdisGenericIrpHandler().

◆ NdisMCloseLog()

VOID EXPORT NdisMCloseLog ( IN NDIS_HANDLE  LogHandle)

Definition at line 1447 of file miniport.c.

1449{
1451 PNDIS_MINIPORT_BLOCK Miniport = Log->Miniport;
1452 KIRQL OldIrql;
1453
1454 NDIS_DbgPrint(MAX_TRACE, ("called: LogHandle 0x%x\n", LogHandle));
1455
1456 KeAcquireSpinLock(&(Miniport)->Lock, &OldIrql);
1457 Miniport->Log = NULL;
1458 KeReleaseSpinLock(&(Miniport)->Lock, OldIrql);
1459
1460 ExFreePool(Log);
1461}
struct _NDIS_LOG * PNDIS_LOG
_In_ UINT _Out_ PNDIS_HANDLE LogHandle
Definition: ndis.h:5382
PNDIS_MINIPORT_BLOCK Miniport
Definition: ndis.h:2475
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:127

◆ NdisMCreateLog()

NDIS_STATUS EXPORT NdisMCreateLog ( IN NDIS_HANDLE  MiniportAdapterHandle,
IN UINT  Size,
OUT PNDIS_HANDLE  LogHandle 
)

Definition at line 1468 of file miniport.c.

1472{
1474 PNDIS_LOG Log;
1475 KIRQL OldIrql;
1476
1477 NDIS_DbgPrint(MAX_TRACE, ("called: MiniportAdapterHandle 0x%x, Size %ld\n", MiniportAdapterHandle, Size));
1478
1480
1481 if (Adapter->NdisMiniportBlock.Log)
1482 {
1483 *LogHandle = NULL;
1484 return NDIS_STATUS_FAILURE;
1485 }
1486
1487 Log = ExAllocatePool(NonPagedPool, Size + sizeof(NDIS_LOG));
1488 if (!Log)
1489 {
1490 *LogHandle = NULL;
1491 return NDIS_STATUS_RESOURCES;
1492 }
1493
1494 Adapter->NdisMiniportBlock.Log = Log;
1495
1497
1498 Log->Miniport = &Adapter->NdisMiniportBlock;
1499 Log->TotalSize = Size;
1500 Log->CurrentSize = 0;
1501 Log->OutPtr = 0;
1502 Log->InPtr = 0;
1503 Log->Irp = NULL;
1504
1505 *LogHandle = Log;
1506
1508
1509 return NDIS_STATUS_SUCCESS;
1510}
UINT OutPtr
Definition: ndis.h:2481
KSPIN_LOCK LogLock
Definition: ndis.h:2476
PIRP Irp
Definition: ndis.h:2477
UINT InPtr
Definition: ndis.h:2480
UINT CurrentSize
Definition: ndis.h:2479
UINT TotalSize
Definition: ndis.h:2478

◆ NdisMDeregisterAdapterShutdownHandler()

VOID EXPORT NdisMDeregisterAdapterShutdownHandler ( IN NDIS_HANDLE  MiniportHandle)

Definition at line 1517 of file miniport.c.

1523{
1524 PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportHandle;
1525
1526 NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
1527
1528 if(Adapter->BugcheckContext->ShutdownHandler) {
1531 }
1532}
BOOLEAN NTAPI KeDeregisterBugCheckCallback(IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord)
Definition: bug.c:1205
VOID NTAPI IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1725
PKBUGCHECK_CALLBACK_RECORD CallbackRecord
Definition: miniport.h:60
ADAPTER_SHUTDOWN_HANDLER ShutdownHandler
Definition: miniport.h:59

Referenced by MiniportHalt(), and NdisDeregisterAdapterShutdownHandler().

◆ NdisMDeregisterDevice()

NDIS_STATUS EXPORT NdisMDeregisterDevice ( IN NDIS_HANDLE  NdisDeviceHandle)

Definition at line 3245 of file miniport.c.

3253{
3255
3256 IoDeleteDevice(DeviceBlock->DeviceObject);
3257
3258 IoDeleteSymbolicLink(DeviceBlock->SymbolicName);
3259
3260 return NDIS_STATUS_SUCCESS;
3261}
_In_ PNDIS_STRING _In_ PNDIS_STRING _Out_ PDEVICE_OBJECT _Out_ NDIS_HANDLE * NdisDeviceHandle
Definition: ndis.h:4680
PNDIS_STRING SymbolicName
Definition: miniport.h:36

◆ NdisMFlushLog()

VOID EXPORT NdisMFlushLog ( IN NDIS_HANDLE  LogHandle)

Definition at line 1539 of file miniport.c.

1541{
1543 KIRQL OldIrql;
1544
1545 NDIS_DbgPrint(MAX_TRACE, ("called: LogHandle 0x%x\n", LogHandle));
1546
1547 /* Lock object */
1549
1550 /* Set buffers size */
1551 Log->CurrentSize = 0;
1552 Log->OutPtr = 0;
1553 Log->InPtr = 0;
1554
1555 /* Unlock object */
1557}

◆ NdisMGetDeviceProperty()

Definition at line 3112 of file miniport.c.

3125{
3127
3128 NDIS_DbgPrint(MAX_TRACE, ("Called\n"));
3129
3132
3135
3136 if (NextDeviceObject != NULL)
3138
3139 if (AllocatedResources != NULL)
3140 *AllocatedResources = Adapter->NdisMiniportBlock.AllocatedResources;
3141
3143 *AllocatedResourcesTranslated = Adapter->NdisMiniportBlock.AllocatedResourcesTranslated;
3144}
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT * FunctionalDeviceObject
Definition: ndis.h:4641
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT * NextDeviceObject
Definition: ndis.h:4642
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResources
Definition: ndis.h:4643
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResourcesTranslated
Definition: ndis.h:4644

Referenced by DcInitializeAdapterLocation().

◆ NdisMIndicateStatus()

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

Definition at line 1565 of file miniport.c.

◆ NdisMIndicateStatusComplete()

VOID EXPORT NdisMIndicateStatusComplete ( IN NDIS_HANDLE  MiniportAdapterHandle)

Definition at line 1580 of file miniport.c.

◆ NdisMQueryAdapterInstanceName()

NDIS_STATUS EXPORT NdisMQueryAdapterInstanceName ( OUT PNDIS_STRING  AdapterInstanceName,
IN NDIS_HANDLE  MiniportAdapterHandle 
)

Definition at line 3038 of file miniport.c.

3047{
3050
3051 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
3052
3053 AdapterName.Length = 0;
3055 AdapterName.Buffer = ExAllocatePool(PagedPool, AdapterName.MaximumLength);
3056 if (!AdapterName.Buffer) {
3057 NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
3058 return NDIS_STATUS_RESOURCES;
3059 }
3060
3062
3063 *AdapterInstanceName = AdapterName;
3064
3065 return NDIS_STATUS_SUCCESS;
3066}
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
USHORT MaximumLength
Definition: env_spec_w32.h:370

Referenced by NdisQueryAdapterInstanceName().

◆ NdisMQueryInformationComplete()

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

Definition at line 1207 of file miniport.c.

◆ NdisMRegisterAdapterShutdownHandler()

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

Definition at line 1694 of file miniport.c.

1707{
1708 PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportHandle;
1709 PMINIPORT_BUGCHECK_CONTEXT BugcheckContext;
1710
1711 NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
1712
1713 if (Adapter->BugcheckContext != NULL)
1714 {
1715 NDIS_DbgPrint(MIN_TRACE, ("Attempted to register again for a shutdown callback\n"));
1716 return;
1717 }
1718
1719 BugcheckContext = ExAllocatePool(NonPagedPool, sizeof(MINIPORT_BUGCHECK_CONTEXT));
1720 if(!BugcheckContext)
1721 {
1722 NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1723 return;
1724 }
1725
1726 BugcheckContext->ShutdownHandler = ShutdownHandler;
1727 BugcheckContext->DriverContext = ShutdownContext;
1728
1730 if (!BugcheckContext->CallbackRecord) {
1731 ExFreePool(BugcheckContext);
1732 return;
1733 }
1734
1735 Adapter->BugcheckContext = BugcheckContext;
1736
1738
1740 BugcheckContext, sizeof(*BugcheckContext), (PUCHAR)"Ndis Miniport");
1741
1743}
BOOLEAN NTAPI KeRegisterBugCheckCallback(IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord, IN PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine, IN PVOID Buffer, IN ULONG Length, IN PUCHAR Component)
Definition: bug.c:1260
VOID NTAPI NdisIBugcheckCallback(IN PVOID Buffer, IN ULONG Length)
Definition: miniport.c:1670
NTSTATUS NTAPI IoRegisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1694
#define KeInitializeCallbackRecord(CallbackRecord)
Definition: kefuncs.h:1387

Referenced by MiniportInitialize(), NdisMSetAttributesEx(), and NdisRegisterAdapterShutdownHandler().

◆ NdisMRegisterDevice()

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 
)

Definition at line 3173 of file miniport.c.

3186{
3187 PNDIS_M_DRIVER_BLOCK DriverBlock = NdisWrapperHandle;
3188 PNDIS_M_DEVICE_BLOCK DeviceBlock;
3191 UINT i;
3192
3193 NDIS_DbgPrint(MAX_TRACE, ("Called\n"));
3194
3195 Status = IoCreateDevice(DriverBlock->DriverObject,
3196 sizeof(NDIS_M_DEVICE_BLOCK),
3197 DeviceName,
3199 0,
3200 FALSE,
3201 &DeviceObject);
3202
3203 if (!NT_SUCCESS(Status))
3204 {
3205 NDIS_DbgPrint(MIN_TRACE, ("IoCreateDevice failed (%x)\n", Status));
3206 return Status;
3207 }
3208
3210
3211 if (!NT_SUCCESS(Status))
3212 {
3213 NDIS_DbgPrint(MIN_TRACE, ("IoCreateSymbolicLink failed (%x)\n", Status));
3215 return Status;
3216 }
3217
3218 DeviceBlock = DeviceObject->DeviceExtension;
3219
3220 if (!DeviceBlock)
3221 {
3222 NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
3225 return NDIS_STATUS_RESOURCES;
3226 }
3227
3228 for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
3229 DeviceBlock->MajorFunction[i] = MajorFunctions[i];
3230
3231 DeviceBlock->DeviceObject = DeviceObject;
3232 DeviceBlock->SymbolicName = SymbolicName;
3233
3235 *NdisDeviceHandle = DeviceBlock;
3236
3237 return NDIS_STATUS_SUCCESS;
3238}
_In_ PNDIS_STRING _In_ PNDIS_STRING _Out_ PDEVICE_OBJECT * pDeviceObject
Definition: ndis.h:4679
_In_ PNDIS_STRING _In_ PNDIS_STRING SymbolicName
Definition: ndis.h:4677
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
#define IRP_MJ_MAXIMUM_FUNCTION

◆ NdisMRegisterMiniport()

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

Definition at line 2637 of file miniport.c.

2650{
2651 UINT MinSize;
2652 PNDIS_M_DRIVER_BLOCK Miniport = GET_MINIPORT_DRIVER(NdisWrapperHandle);
2653 PNDIS_M_DRIVER_BLOCK *MiniportPtr;
2655 ULONG i;
2656
2657 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
2658
2659 switch (MiniportCharacteristics->MajorNdisVersion)
2660 {
2661 case 0x03:
2662 MinSize = sizeof(NDIS30_MINIPORT_CHARACTERISTICS);
2663 break;
2664
2665 case 0x04:
2666 MinSize = sizeof(NDIS40_MINIPORT_CHARACTERISTICS);
2667 break;
2668
2669 case 0x05:
2670 switch (MiniportCharacteristics->MinorNdisVersion)
2671 {
2672 case 0x00:
2673 MinSize = sizeof(NDIS50_MINIPORT_CHARACTERISTICS);
2674 break;
2675
2676 case 0x01:
2677 MinSize = sizeof(NDIS51_MINIPORT_CHARACTERISTICS);
2678 break;
2679
2680 default:
2681 NDIS_DbgPrint(MIN_TRACE, ("Bad 5.x minor characteristics version.\n"));
2683 }
2684 break;
2685
2686 default:
2687 NDIS_DbgPrint(MIN_TRACE, ("Bad miniport characteristics version.\n"));
2689 }
2690
2691 NDIS_DbgPrint(MID_TRACE, ("Initializing an NDIS %u.%u miniport\n",
2692 MiniportCharacteristics->MajorNdisVersion,
2693 MiniportCharacteristics->MinorNdisVersion));
2694
2695 if (CharacteristicsLength < MinSize)
2696 {
2697 NDIS_DbgPrint(MIN_TRACE, ("Bad miniport characteristics length.\n"));
2699 }
2700
2701 /* Check if mandatory MiniportXxx functions are specified */
2702 if ((!MiniportCharacteristics->HaltHandler) ||
2703 (!MiniportCharacteristics->InitializeHandler)||
2704 (!MiniportCharacteristics->ResetHandler))
2705 {
2706 NDIS_DbgPrint(MIN_TRACE, ("Bad miniport characteristics.\n"));
2708 }
2709
2710 if (MiniportCharacteristics->MajorNdisVersion < 0x05)
2711 {
2712 if ((!MiniportCharacteristics->QueryInformationHandler) ||
2713 (!MiniportCharacteristics->SetInformationHandler))
2714 {
2715 NDIS_DbgPrint(MIN_TRACE, ("Bad miniport characteristics. (Set/Query)\n"));
2717 }
2718 }
2719 else
2720 {
2721 if (((!MiniportCharacteristics->QueryInformationHandler) ||
2722 (!MiniportCharacteristics->SetInformationHandler)) &&
2723 (!MiniportCharacteristics->CoRequestHandler))
2724 {
2725 NDIS_DbgPrint(MIN_TRACE, ("Bad miniport characteristics. (Set/Query)\n"));
2727 }
2728 }
2729
2730 if (MiniportCharacteristics->MajorNdisVersion == 0x03)
2731 {
2732 if (!MiniportCharacteristics->SendHandler)
2733 {
2734 NDIS_DbgPrint(MIN_TRACE, ("Bad miniport characteristics. (NDIS 3.0)\n"));
2736 }
2737 }
2738 else if (MiniportCharacteristics->MajorNdisVersion == 0x04)
2739 {
2740 /* NDIS 4.0 */
2741 if ((!MiniportCharacteristics->SendHandler) &&
2742 (!MiniportCharacteristics->SendPacketsHandler))
2743 {
2744 NDIS_DbgPrint(MIN_TRACE, ("Bad miniport characteristics. (NDIS 4.0)\n"));
2746 }
2747 }
2748 else if (MiniportCharacteristics->MajorNdisVersion == 0x05)
2749 {
2750 /* TODO: Add more checks here */
2751
2752 if ((!MiniportCharacteristics->SendHandler) &&
2753 (!MiniportCharacteristics->SendPacketsHandler) &&
2754 (!MiniportCharacteristics->CoSendPacketsHandler))
2755 {
2756 NDIS_DbgPrint(MIN_TRACE, ("Bad miniport characteristics. (NDIS 5.0)\n"));
2758 }
2759 }
2760
2761 RtlCopyMemory(&Miniport->MiniportCharacteristics, MiniportCharacteristics, MinSize);
2762
2763 /*
2764 * NOTE: This is VERY unoptimal! Should we store the NDIS_M_DRIVER_BLOCK
2765 * structure in the driver extension or what?
2766 */
2767
2769 sizeof(PNDIS_M_DRIVER_BLOCK), (PVOID*)&MiniportPtr);
2770 if (!NT_SUCCESS(Status))
2771 {
2772 NDIS_DbgPrint(MIN_TRACE, ("Can't allocate driver object extension.\n"));
2773 return NDIS_STATUS_RESOURCES;
2774 }
2775
2776 *MiniportPtr = Miniport;
2777
2778 /* We have to register for all of these so handler registered in NdisMRegisterDevice work */
2779 for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
2780 {
2782 }
2783
2785
2786 return NDIS_STATUS_SUCCESS;
2787}
#define GET_MINIPORT_DRIVER(Handle)
Definition: miniport.h:84
_Out_ PNDIS_HANDLE _In_ PNDIS_PROTOCOL_CHARACTERISTICS _In_ UINT CharacteristicsLength
Definition: ndis.h:6136
#define NDIS_STATUS_BAD_VERSION
Definition: ndis.h:468
struct _NDIS50_MINIPORT_CHARACTERISTICS NDIS50_MINIPORT_CHARACTERISTICS
#define NDIS_STATUS_BAD_CHARACTERISTICS
Definition: ndis.h:469
struct _NDIS40_MINIPORT_CHARACTERISTICS NDIS40_MINIPORT_CHARACTERISTICS
struct _NDIS51_MINIPORT_CHARACTERISTICS NDIS51_MINIPORT_CHARACTERISTICS
struct _NDIS30_MINIPORT_CHARACTERISTICS NDIS30_MINIPORT_CHARACTERISTICS
NTSTATUS NTAPI NdisGenericIrpHandler(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: miniport.c:2574
NTSTATUS NTAPI NdisIAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: miniport.c:2420
NTSTATUS NTAPI IoAllocateDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress, IN ULONG DriverObjectExtensionSize, OUT PVOID *DriverObjectExtension)
Definition: driver.c:1826
PDRIVER_ADD_DEVICE AddDevice
Definition: iotypes.h:2220
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: iotypes.h:2289
PDRIVER_EXTENSION DriverExtension
Definition: iotypes.h:2282

Referenced by DriverEntry().

◆ NdisMRegisterUnloadHandler()

VOID EXPORT NdisMRegisterUnloadHandler ( IN NDIS_HANDLE  NdisWrapperHandle,
IN PDRIVER_UNLOAD  UnloadHandler 
)

Definition at line 3151 of file miniport.c.

3160{
3161 PNDIS_M_DRIVER_BLOCK DriverBlock = NdisWrapperHandle;
3162
3163 NDIS_DbgPrint(MAX_TRACE, ("Miniport registered unload handler\n"));
3164
3165 DriverBlock->DriverObject->DriverUnload = UnloadHandler;
3166}
_In_ PDRIVER_UNLOAD UnloadHandler
Definition: ndis.h:4688
PDRIVER_UNLOAD DriverUnload
Definition: iotypes.h:2288

Referenced by DriverEntry().

◆ NdisMResetComplete()

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

Definition at line 2795 of file miniport.c.

2799{
2801}

◆ NdisMSendComplete()

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

Definition at line 2809 of file miniport.c.

◆ NdisMSendResourcesAvailable()

VOID EXPORT NdisMSendResourcesAvailable ( IN NDIS_HANDLE  MiniportAdapterHandle)

Definition at line 2831 of file miniport.c.

◆ NdisMSetAttributes()

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

Definition at line 2858 of file miniport.c.

2871{
2872 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
2873 NdisMSetAttributesEx(MiniportAdapterHandle, MiniportAdapterContext, 0,
2874 BusMaster ? NDIS_ATTRIBUTE_BUS_MASTER : 0,
2875 AdapterType);
2876}
#define NDIS_ATTRIBUTE_BUS_MASTER
Definition: ndis.h:586
VOID EXPORT NdisMSetAttributesEx(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE MiniportAdapterContext, IN UINT CheckForHangTimeInSeconds OPTIONAL, IN ULONG AttributeFlags, IN NDIS_INTERFACE_TYPE AdapterType)
Definition: miniport.c:2883
@ AdapterType
Definition: cmtypes.h:991

◆ NdisMSetAttributesEx()

VOID EXPORT NdisMSetAttributesEx ( IN NDIS_HANDLE  MiniportAdapterHandle,
IN NDIS_HANDLE  MiniportAdapterContext,
IN UINT CheckForHangTimeInSeconds  OPTIONAL,
IN ULONG  AttributeFlags,
IN NDIS_INTERFACE_TYPE  AdapterType 
)

Definition at line 2883 of file miniport.c.

2899{
2901
2902 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
2903
2904 Adapter->NdisMiniportBlock.MiniportAdapterContext = MiniportAdapterContext;
2905 Adapter->NdisMiniportBlock.Flags = AttributeFlags;
2907 if (CheckForHangTimeInSeconds > 0)
2908 Adapter->NdisMiniportBlock.CheckForHangSeconds = CheckForHangTimeInSeconds;
2909 if (AttributeFlags & NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER)
2910 NDIS_DbgPrint(MIN_TRACE, ("Intermediate drivers not supported yet.\n"));
2911
2912 NDIS_DbgPrint(MID_TRACE, ("Miniport attribute flags: 0x%x\n", AttributeFlags));
2913
2914 if (Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.AdapterShutdownHandler)
2915 {
2916 NDIS_DbgPrint(MAX_TRACE, ("Miniport set AdapterShutdownHandler in MiniportCharacteristics\n"));
2919 Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.AdapterShutdownHandler);
2920 }
2921}
#define GET_LOGICAL_ADAPTER(Handle)
Definition: miniport.h:101
#define NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER
Definition: ndis.h:587
VOID EXPORT NdisMRegisterAdapterShutdownHandler(IN NDIS_HANDLE MiniportHandle, IN PVOID ShutdownContext, IN ADAPTER_SHUTDOWN_HANDLER ShutdownHandler)
Definition: miniport.c:1694
NDIS_INTERFACE_TYPE AdapterType
Definition: ndis.h:2551

Referenced by DcInitialize(), MiniportInitialize(), NdisMSetAttributes(), and ParaNdis5_Initialize().

◆ NdisMSetInformationComplete()

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

Definition at line 1187 of file miniport.c.

◆ NdisMSleep()

VOID EXPORT NdisMSleep ( IN ULONG  MicrosecondsToSleep)

Definition at line 2928 of file miniport.c.

2937{
2938 KTIMER Timer;
2940
2941 PAGED_CODE();
2942
2943 DueTime.QuadPart = (-1) * 10 * MicrosecondsToSleep;
2944
2946 KeSetTimer(&Timer, DueTime, 0);
2948}
#define PAGED_CODE()
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
_In_ WDFTIMER _In_ LONGLONG DueTime
Definition: wdftimer.h:190

Referenced by DcInitialize(), DcSoftReset(), DcStopReceivePath(), MediaSelectMiiPort(), NICSoftReset(), PhyInitRealtek8211c(), PhyReset(), PreventDPCServicing(), SidebandUnitAcquireSemaphore(), SRomAcquireListMutex(), vdev_sleep(), and VirtIONetRelease().

◆ NdisMSynchronizeWithInterrupt()

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

Definition at line 2955 of file miniport.c.

2959{
2960 return(KeSynchronizeExecution(Interrupt->InterruptObject,
2961 (PKSYNCHRONIZE_ROUTINE)SynchronizeFunction,
2963}
BOOLEAN NTAPI KeSynchronizeExecution(IN OUT PKINTERRUPT Interrupt, IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, IN PVOID SynchronizeContext OPTIONAL)
Definition: interrupt.c:237
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:379
_In_ PKSYNCHRONIZE_ROUTINE _In_opt_ __drv_aliasesMem PVOID SynchronizeContext
Definition: kefuncs.h:525
KSYNCHRONIZE_ROUTINE * PKSYNCHRONIZE_ROUTINE
Definition: ketypes.h:875

Referenced by MiniportHalt(), MiniportMediaDetectionTimer(), MiniportSend(), NvNetStartAdapter(), and ParaNdis_SynchronizeWithInterrupt().

◆ NdisMTransferDataComplete()

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

Definition at line 2843 of file miniport.c.

◆ NdisMWriteLogData()

NDIS_STATUS EXPORT NdisMWriteLogData ( IN NDIS_HANDLE  LogHandle,
IN PVOID  LogBuffer,
IN UINT  LogBufferSize 
)

Definition at line 2970 of file miniport.c.

2974{
2975 PUCHAR Buffer = LogBuffer;
2976 UINT i, j, idx;
2977
2979 for (i = 0; i < LogBufferSize; i += 16)
2980 {
2981 DbgPrint("%08x |", i);
2982 for (j = 0; j < 16; j++)
2983 {
2984 idx = i + j;
2985 if (idx < LogBufferSize)
2986 DbgPrint(" %02x", Buffer[idx]);
2987 else
2988 DbgPrint(" ");
2989 }
2990 DbgPrint(" | ");
2991 for (j = 0; j < 16; j++)
2992 {
2993 idx = i + j;
2994 if (idx == LogBufferSize)
2995 break;
2996 if (Buffer[idx] >= ' ') /* FIXME: not portable! replace by if (isprint(Buffer[idx])) ? */
2997 DbgPrint("%c", Buffer[idx]);
2998 else
2999 DbgPrint(".");
3000 }
3001 DbgPrint("\n");
3002 }
3003
3004 return NDIS_STATUS_FAILURE;
3005}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
unsigned int idx
Definition: utils.c:41
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 GLint GLint j
Definition: glfuncs.h:250
#define DbgPrint
Definition: hal.h:12
_In_ UINT LogBufferSize
Definition: ndis.h:5822

◆ NdisQueryAdapterInstanceName()

NDIS_STATUS EXPORT NdisQueryAdapterInstanceName ( OUT PNDIS_STRING  AdapterInstanceName,
IN NDIS_HANDLE  NdisBindingHandle 
)

Definition at line 3268 of file miniport.c.

3277{
3278 PADAPTER_BINDING AdapterBinding = NdisBindingHandle;
3279 PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
3280
3281 return NdisMQueryAdapterInstanceName(AdapterInstanceName,
3282 Adapter);
3283}
NDIS_STATUS EXPORT NdisMQueryAdapterInstanceName(OUT PNDIS_STRING AdapterInstanceName, IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:3038

◆ NdisRegisterAdapterShutdownHandler()

VOID EXPORT NdisRegisterAdapterShutdownHandler ( IN NDIS_HANDLE  NdisAdapterHandle,
IN PVOID  ShutdownContext,
IN ADAPTER_SHUTDOWN_HANDLER  ShutdownHandler 
)

Definition at line 3091 of file miniport.c.

3101{
3102 NdisMRegisterAdapterShutdownHandler(NdisAdapterHandle,
3103 ShutdownContext,
3105}

◆ NdisReturnPackets()

VOID EXPORT NdisReturnPackets ( IN PNDIS_PACKET PacketsToReturn,
IN UINT  NumberOfPackets 
)

Definition at line 258 of file miniport.c.

267{
268 UINT i;
269 PLOGICAL_ADAPTER Adapter;
271
272 NDIS_DbgPrint(MID_TRACE, ("Returning %d packets\n", NumberOfPackets));
273
274 for (i = 0; i < NumberOfPackets; i++)
275 {
276 PacketsToReturn[i]->WrapperReserved[0]--;
277 if (PacketsToReturn[i]->WrapperReserved[0] == 0)
278 {
279 Adapter = (PVOID)(ULONG_PTR)PacketsToReturn[i]->Reserved[1];
280
281 NDIS_DbgPrint(MAX_TRACE, ("Freeing packet %d (adapter = 0x%p)\n", i, Adapter));
282
284 Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ReturnPacketHandler(
286 PacketsToReturn[i]);
288 }
289 }
290}
void * PVOID
Definition: typedefs.h:50

Referenced by DeinitializePacket(), and FreeIPDR().

◆ NdisTerminateWrapper()

VOID EXPORT NdisTerminateWrapper ( IN NDIS_HANDLE  NdisWrapperHandle,
IN PVOID  SystemSpecific 
)

Definition at line 3012 of file miniport.c.

3021{
3022 PNDIS_M_DRIVER_BLOCK Miniport = GET_MINIPORT_DRIVER(NdisWrapperHandle);
3023
3024 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
3025
3026 ExFreePool(Miniport->RegistryPath->Buffer);
3027 ExFreePool(Miniport->RegistryPath);
3029 ExFreePool(Miniport);
3030}

Referenced by DriverEntry().

Variable Documentation

◆ AdapterListHead

LIST_ENTRY AdapterListHead

Definition at line 57 of file miniport.c.

Referenced by MiniLocateDevice(), and NdisIPnPStartDevice().

◆ AdapterListLock

KSPIN_LOCK AdapterListLock

Definition at line 58 of file miniport.c.

Referenced by MiniLocateDevice(), NdisIPnPStartDevice(), and NdisIPnPStopDevice().

◆ MediaArray

NDIS_MEDIUM MediaArray[MEDIA_ARRAY_SIZE]
static
Initial value:
=
{
}
@ NdisMedium802_5
Definition: ntddndis.h:189
@ NdisMediumArcnetRaw
Definition: ntddndis.h:194
@ NdisMediumMax
Definition: ntddndis.h:202
@ NdisMediumIrda
Definition: ntddndis.h:198
@ NdisMediumWan
Definition: ntddndis.h:191
@ NdisMediumCoWan
Definition: ntddndis.h:200
@ NdisMediumDix
Definition: ntddndis.h:193
@ NdisMediumFddi
Definition: ntddndis.h:190
@ NdisMediumArcnet878_2
Definition: ntddndis.h:195
@ NdisMedium1394
Definition: ntddndis.h:201
@ NdisMediumWirelessWan
Definition: ntddndis.h:197
@ NdisMediumLocalTalk
Definition: ntddndis.h:192
@ NdisMediumAtm
Definition: ntddndis.h:196
@ NdisMediumBpc
Definition: ntddndis.h:199

Definition at line 33 of file miniport.c.

Referenced by LANRegisterAdapter(), and NdisIPnPStartDevice().

◆ MiniportListHead

LIST_ENTRY MiniportListHead

Definition at line 53 of file miniport.c.

Referenced by DriverEntry(), and NdisInitializeWrapper().

◆ MiniportListLock

KSPIN_LOCK MiniportListLock

Definition at line 54 of file miniport.c.

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