MiniportHalt

VOID
    MiniportHalt(
        IN NDIS_HANDLE
 MiniportAdapterContext
        );

MiniportHalt is a required function that deallocates resources when the NIC is removed and halts the NIC.

Parameters

MiniportAdapterContext
Specifies the handle to a miniport-allocated context area in which the driver maintains per-NIC state, set up by MiniportInitialize.

Comments

MiniportHalt should stop the NIC, if it controls a physical NIC, and must free all resources that the driver allocated for its NIC before MiniportHalt returns control. In effect, MiniportHalt undoes everything that was done by MiniportInitialize for a particular NIC.

If the NIC driver allocated memory, claimed an I/O port range, mapped on-board device memory to host memory, initialized timer(s) and/or spin lock(s), allocated map registers or claimed a DMA channel, and registered an interrupt, that driver must call the reciprocals of the NdisXxx functions with which it originally allocated these resources.

As a general rule, a MiniportHalt function should call reciprocal NdisXxx functions in inverse order to the calls the driver made from MiniportInitialize. That is, if a NIC driver’s MiniportInitialize function called NdisMRegisterAdapterShutdownHandler just before it returned control, its MiniportHalt function would call NdisMDeregisterAdapterShutdownHandler first.

If its NIC generates interrupts or shares an IRQ, a NIC driver’s MiniportHalt function can be pre-empted by its MiniportISR or MiniportDisableInterrupt function until MiniportHalt calls NdisMDeregisterInterrupt. Such a driver’s MiniportHalt function usually disables interrupts on the NIC, if possible, and calls NdisMDeregisterInterrupt as soon as it can.

If the driver has a MiniportTimer function associated with any timer object that might be in the system timer queue, MiniportHalt should call NdisMCancelTimer.

Otherwise, it is unnecessary for the miniport to complete outstanding requests to its NIC before MiniportHalt begins releasing allocated resources. NDIS submits no further requests to the miniport for the NIC designated by the MiniportAdapterContext handle when NDIS has called MiniportHalt. On return from MiniportHalt, NDIS cleans up any state it was maintaining about this NIC and about its driver if this miniport supports no other NICs in the current machine.

An NDIS intermediate driver's call to NdisIMDeinitializeDeviceInstance causes a call to its MiniportHalt function.

By default, MiniportHalt runs at IRQL PASSIVE_LEVEL.

See Also

MiniportInitialize, MiniportShutdown, NdisFreeMemory, NdisFreeSpinLock, NdisIMDeinitializeDeviceInstance, NdisMCancelTimer, NdisMDeregisterAdapterShutdownHandler, NdisMDeregisterDmaChannel, NdisMDeregisterInterrupt, NdisMDeregisterIoPortRange, NdisMFreeMapRegisters, NdisMFreeSharedMemory, NdisMUnmapIoSpace, ProtocolUnbindAdapter