NdisMRegisterMiniport registers a miniport's MiniportXxx entry points with the NDIS library as the first step in NIC driver initialization.
NDIS_STATUS
NdisMRegisterMiniport(
IN NDIS_HANDLE NdisWrapperHandle,
IN PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics,
IN UINT CharacteristicsLength
);
typedef struct _NDIS_MINIPORT_CHARACTERISTICS {
UCHAR MajorNdisVersion;
UCHAR MinorNdisVersion;
UINT Reserved;
W_CHECK_FOR_HANG_HANDLER CheckForHangHandler;
W_DISABLE_INTERRUPT_HANDLER DisableInterruptHandler;
W_ENABLE_INTERRUPT_HANDLER EnableInterruptHandler;
W_HALT_HANDLER HaltHandler;
W_HANDLE_INTERRUPT_HANDLER HandleInterruptHandler;
W_INITIALIZE_HANDLER InitializeHandler;
W_ISR_HANDLER ISRHandler;
W_QUERY_INFORMATION_HANDLER QueryInformationHandler;
W_RECONFIGURE_HANDLER ReconfigureHandler;
W_RESET_HANDLER ResetHandler;
W_SEND_HANDLER SendHandler;
W_SET_INFORMATION_HANDLER SetInformationHandler;
W_TRANSFER_DATA_HANDLER TransferDataHandler;
//
// Version used is V4.0 or V5.0
// with following members
//
W_RETURN_PACKET_HANDLER ReturnPacketHandler;
W_SEND_PACKETS_HANDLER SendPacketsHandler;
W_ALLOCATE_COMPLETE_HANDLER AllocateCompleteHandler;
//
// Version used is V5.0 with the following members
//
W_CO_CREATE_VC_HANDLER CoCreateVcHandler;
W_CO_DELETE_VC_HANDLER CoDeleteVcHandler;
W_CO_ACTIVATE_VC_HANDLER CoActivateVcHandler;
W_CO_DEACTIVATE_VC_HANDLER CoDeactivateVcHandler;
W_CO_SEND_PACKETS_HANDLER CoSendPacketsHandler;
W_CO_REQUEST_HANDLER CoRequestHandler;
//
// Version used is V5.1 with the following members
//
W_CANCEL_SEND_PACKETS_HANDLER CancelSendPacketsHandler;
W_PNP_EVENT_NOTIFY_HANDLER PnPEventNotifyHandler;
W_MINIPORT_SHUTDOWN_HANDLER AdapterShutdownHandler;
} NDIS_MINIPORT_CHARACTERISTICS, *PNDIS_MINIPORT_CHARACTERISTICS;The driver should initialize this structure with zeros before setting up any of the following members:
This member must be set to 0x05 or 0x04 if the caller sets entry points in any members following TransferDataHandler; it must be set to 0x05 if the caller sets entry points in any members following AllocateCompleteHandler.
If the miniport driver supports multipacket sends or controls a connection-oriented NIC, it sets the SendPacketsHandler or CoSendPacketsHandler member, respectively, and sets this member to NULL.
For example, the following shows the appropriate compiler directives to embed at the start of a miniport driver's source code if the driver uses an NDIS 5.0 NDIS_MINIPORT_CHARACTERISTICS structure:
#define NDIS_MINIPORT_DRIVER #define NDIS50_MINIPORT 1 #include <Ndis.h> // AFTER preceding directives
The inclusion of ndis.h must occur after the NDIS_MINIPORT_DRIVER and NDISXX_MINIPORT directives, where XX can be 40, as well as the 50 shown here. If the NDISXX_MINIPORT directive is omitted, the NDIS_MINIPORT_CHARACTERISTICS structure size defaults to version 3.0.
As an alternative, the same driver could set the following build directive in its sources file, instead of using the preceding compiler directives:
... C_FLAGS=$(C_FLAGS) -DNDIS_MINIPORT_DRIVER -DNDIS50_MINIPORT_DRIVER ...
As for the corresponding compiler directive, the driver writer can specify a -DNDISXX_MINIPORT_DRIVER directive, where XX can be 40, as well as the 50 shown here.
Setting the appropriate compiler/build directives sets the CharacteristicsLength automatically. The values set in the MajorNdisVersion and MinorNdisVersion members of the characteristics structure must be consistent with the compiler/build directives set for the miniport driver.
NdisMRegisterMiniport returns NDIS_STATUS_SUCCESS if it registered the miniport driver, or it can return one of the following status values:
Declared in Ndis.h. Include Ndis.h.
A NIC driver calls NdisMRegisterMiniport from its DriverEntry function, following its call to NdisMInitializeWrapper.
Every NIC driver exports a set of standard MiniportXxx functions by setting up the characteristics structure and calling NdisMRegisterMiniport. This structure is copied in the NdisMRegisterMiniport request to the NDIS library’s internal storage. Thus, once it has registered, a miniport driver cannot change its MiniportXxx functions.
After the driver has called NdisMRegisterMiniport and after its DriverEntry function returns control, it should be prepared to be called back at the MiniportInitialize entry point specified in the characteristics structure. In the PnP environment, a NIC driver's call to NdisMRegisterMiniport simply registers the miniport driver's entry points with NDIS, which defers calling the driver's MiniportInitialize function until the PnP Manager sends NDIS a request to start the NIC. For more information about PnP, see Driver Setup, Plug and Play, & Power Management.
The NDIS library currently does not call MiniportReconfigure functions, so such a function in an existing miniport driver is dead code unless the miniport driver makes internal calls to its MiniportReconfigure function from MiniportInitialize.
NDIS intermediate drivers, which export both MiniportXxx and ProtocolXxx functions, must call NdisIMRegisterLayeredMiniport instead of NdisMRegisterMiniport. Connection-oriented MCM drivers, however, which export MiniportXxx and ProtocolCmXxx functions, call NdisMRegisterMiniport.
Callers of NdisMRegisterMiniport run at IRQL = PASSIVE_LEVEL.
DriverEntry of NDIS Miniport Drivers, MiniportAllocateComplete, MiniportCheckForHang, MiniportCoActivateVc, MiniportCoCreateVc, MiniportCoDeactivateVc, MiniportCoDeleteVc, MiniportCoRequest, MiniportCoSendPackets, MiniportDisableInterrupt, MiniportEnableInterrupt, MiniportHalt, MiniportHandleInterrupt, MiniportInitialize, MiniportISR, MiniportQueryInformation, MiniportReconfigure, MiniportReset, MiniportReturnPacket, MiniportSend, MiniportSendPackets, MiniportSetInformation, MiniportTransferData, MiniportWanSend, NdisIMRegisterLayeredMiniport, NdisMCmRegisterAddressFamily, NdisMRegisterAdapterShutdownHandler, NdisZeroMemory, ProtocolCoCreateVc, ProtocolCoDeleteVc