MiniportInitialize (Windows Embedded CE 6.0)


This function is a required function that sets up a network adapter, or virtual network adapter, for network I/O operations, claims all hardware resources necessary to the network adapter in the registry, and allocates resources the driver needs to carry out network I/O operations.


NDIS_STATUS MiniportInitialize(
  PNDIS_STATUS OpenErrorStatus,
  PUINT SelectedMediumIndex,
  PNDIS_MEDIUM MediumArray,
  UINT MediumArraySize,
  NDIS_HANDLE MiniportAdapterHandle,
  NDIS_HANDLE WrapperConfigurationContext


  • OpenErrorStatus
    [out] Points to a variable that MiniportInitialize sets to an NDIS_STATUS_XXX code specifying additional information about the error if MiniportInitialize will return NDIS_STATUS_OPEN_ERROR.
  • SelectedMediumIndex
    [out] Points to a variable in which MiniportInitialize sets the index of the MediumArray element that specifies the medium type the driver or its network adapter uses.
  • MediumArray
    [in] Specifies an array of NdisMediumXXX values from which MiniportInitialize selects one that its network adapter supports or that the driver supports as an interface to higher-level drivers.
  • MediumArraySize
    [in] Specifies the number of elements at MediumArray.
  • MiniportAdapterHandle
    [in] Specifies a handle identifying the miniport's network adapter, which is assigned by the NDIS library. MiniportInitialize should save this handle; it is a required parameter in subsequent calls to NdisXXX functions.
  • WrapperConfigurationContext
    [in] Specifies a handle used only during initialization for calls to NdisXXX configuration and initialization functions. For example, this handle is a required parameter to NdisOpenConfiguration and the NdisImmediateReadXXX and NdisImmediateWriteXXX functions.

Return Value

The following table shows status values that MiniportInitialize can return.

Value Description


MiniportInitialize configured and set up the network adapter, and it allocated all the resources the driver needs to carry out network I/O operations.


MiniportInitialize could not set up the network adapter to an operational state or could not allocate needed resources.


The values at MediumArray did not include a medium the driver (or its network adapter) can support.


MiniportInitialize did not recognize the network adapter either from its description in the registry, using NdisOpenConfiguration and NdisReadConfiguration, or by probing the network adapter on a particular I/O bus, using one of the NdisImmediateXXX or bus-type-specific NdisXXX configuration functions. This return can be propagated from the miniport's call to certain NdisXXX functions, such as NdisOpenConfiguration.


MiniportInitialize attempted to set up a network adapter but was unsuccessful.


MiniportInitialize could not get its network adapter to accept the configuration parameters that it got from the registry or from a bus-type-specific NdisXXX configuration function.


Either MiniportInitialize could not allocate sufficient resources to carry out network I/O operations or an attempt to claim bus-relative hardware resources in the registry for the network adapter failed. This return can be propagated from the miniport's call to an NdisXXX function.


NDIS submits no requests to a driver until its initialization is completed.

In network adapter and intermediate drivers that call NdisMRegisterMiniport from their DriverEntry functions, NDIS calls MiniportInitialize in the context of NdisMRegisterMiniport. The underlying device driver must initialize before an intermediate driver that depends on that device calls NdisMRegisterMiniport.

For NDIS intermediate drivers that export both ProtocolXXX and MiniportXXX functions and that call NdisIMRegisterLayeredMiniport from their DriverEntry functions, NDIS calls MiniportInitialize in the context of NdisIMInitializeDeviceInstance. Such a driver's ProtocolBindAdapter function usually makes the call to NdisIMInitializeDeviceInstance.

In general, drivers of ISA network adapters call NdisOpenConfiguration and NdisReadConfiguration to get the bus-relative configuration parameters for their network adapters from the registry. Drivers for network adapters on other types of I/O buses usually call the appropriate bus-type-specific NdisReadXXX function. Drivers of PCMCIA network adapters should call NdisReadConfiguration to maintain their binary compatibility across Microsoft operating systems that support Microsoft® Win32®.

When it calls MiniportInitialize, the NDIS library supplies an array of supported media types, specified as system-defined NdisMediumXXX values. MiniportInitialize reads the array elements and provides the index of the medium type that NDIS should use with this driver for its network adapter. If the miniport is emulating a medium type, its emulation must be transparent to NDIS.

The MiniportInitialize function of a network adapter driver must call NdisMSetAttributes or NdisMSetAttributesEx before it calls any NdisXXX function, such as NdisMRegisterIoPortRange or NdisMMapIoSpace that claims hardware resources in the registry for the network adapter.

Intermediate driver MiniportInitialize functions must call NdisMSetAttributesEx with NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER set in the AttributeFlags argument. Setting this flag causes NDIS to treat every intermediate driver as a full-duplex miniport, thereby preventing rare but intermittent deadlocks when concurrent send and receive events occur. Consequently, every intermediate driver must be written as a full-duplex driver capable of handling concurrent sends and indications.

If the NDIS library's default four-second time-out interval on outstanding sends and requests is too short for the driver's network adapter, MiniportInitialize can call NdisMSetAttributesEx to extend the interval. Every intermediate driver also should call NdisMSetAttributesEx with NDIS_ATTRIBUTE_IGNORE_PACKET_TIMEOUT and NDIS_ATTRIBUTE_IGNORE_REQUEST_TIMEOUT set in the AttributeFlags so that NDIS will not attempt to time out sends and requests that NDIS holds queued to the intermediate driver.

The call to NdisMSetAttributes or NdisMSetAttributesEx includes a MiniportAdapterContext handle to a driver-allocated context area, in which the miniport maintains runtime state information. NDIS subsequently passes the supplied MiniportAdapterContext handle as an input parameter to other MiniportXXX functions.

Consequently, the MiniportInitialize function of an intermediate driver must call NdisMSetAttributesEx to set up the MiniportAdapterContext handle for a driver-allocated per-virtual-network adapter context area. Otherwise, NDIS would pass a NULL MiniportAdapterContext handle in its subsequent calls to the intermediate driver's other MiniportXXX functions.

After a call to NdisMRegisterIoPortRange, a miniport must call the NdisRawXXX functions with the PortOffset value returned by NdisMRegisterIoPortRange to communicate with its network adapter. The network adapter driver can no longer call the NdisImmediateRead/WritePortXXX functions. Similarly, after a call to NdisMMapIoSpace, a network adapter driver can no longer call NdisImmediateRead/WriteSharedMemory.

After it has claimed any bus-relative hardware resources for its network adapter in the registry, a miniport should no longer call any bus-type-specific NdisReadXXX function.

After MiniportInitialize calls NdisMRegisterInterrupt, the driver's MiniportISR function is called if the driver's network adapter generates an interrupt or if any other device with which the network adapter shares an IRQ interrupts. NDIS does not call the MiniportDisableInterrupt and MiniportEnableInterrupt functions, if the driver supplied them, during initialization, so it is such a miniport's responsibility to acknowledge and clear any interrupts its network adapter generates. If the network adapter shares an IRQ, the driver must first determine whether its network adapter generated the interrupt; if not, the miniport must return FALSE as soon as possible.

If the network adapter does not generate interrupts, MiniportInitialize should call NdisMInitializeTimer with a driver-supplied polling MiniportTimer function and a pointer to driver-allocated memory for a timer object. Drivers of network adapters that generate interrupts and intermediate drivers also can set up one or more MiniportTimer functions, each with its own timer object. MiniportInitialize usually calls NdisMSetPeriodicTimer to enable a polling MiniportTimer function; a driver calls NdisMSetTimer subsequently when conditions occur such that the driver's non-polling MiniportTimer function should be run.

If the driver subsequently indicates receives with NdisMIndicateReceivePacket, the MiniportInitialize function should call NdisAllocatePacketPool and NdisAllocateBufferPool and save the handles returned by these NDIS functions. The packets that the driver subsequently indicates with NdisMIndicateReceivePacket must reference descriptors that were allocated with NdisAllocatePacket and NdisAllocateBuffer.

If driver functions other than MiniportISR or MiniportDisableInterrupt share resources, MiniportInitialize should call NdisAllocateSpinLock to set up any spin lock necessary to synchronize access to such a set of shared resources, particularly in a full-duplex driver or in a driver with a polling MiniportTimer function rather than an ISR. Resources shared by other driver functions with MiniportISR or the interrupt object set up when MiniportInitialize calls NdisMRegisterInterrupt and accessed subsequently by calling NdisMSynchronizeWithInterrupt protects MiniportDisableInterrupt, such as network adapter registers.

Any network adapter driver's MiniportInitialize function should test the network adapter to be sure the hardware is configured correctly to carry out subsequent network I/O operations. If it must wait for state changes to occur in the hardware, MiniportInitialize can call NdisMSleep.

Unless the MiniportInitialize function of a network adapter driver will return an error status, it should call NdisMRegisterAdapterShutdownHandler with a driver-supplied MiniportShutdown function.

If MiniportInitialize will fail the initialization, it must release all resources it has already allocated before it returns control.

If MiniportInitialize returns NDIS_STATUS_OPEN_ERROR, NDIS can examine the value returned at OpenErrorStatus to obtain more information about the error.

When MiniportInitialize returns NDIS_STATUS_SUCCESS, the NDIS library calls the driver's MiniportQueryInformation function next.


Header externs.h
Windows Embedded CE Windows CE .NET 4.0 and later

See Also


NDIS Upper-Edge Functions