예제 #1
0
파일: irmini.c 프로젝트: BillTheBest/WinNT4
/*
 *************************************************************************
 *  MiniportHalt
 *************************************************************************
 *
 *  Halts the network interface card.
 *
 */
VOID MiniportHalt(IN NDIS_HANDLE MiniportAdapterContext)
{
	IrDevice *thisDev = CONTEXT_TO_DEV(MiniportAdapterContext);

	DBGOUT(("MiniportHalt(0x%x)", (UINT)MiniportAdapterContext));

	/*
	 *  Remove this device from our global list
	 */

	if (thisDev == firstIrDevice){
		firstIrDevice = firstIrDevice->next;
	}
	else {
		IrDevice *dev;
		for (dev = firstIrDevice; dev && (dev->next != thisDev); dev = dev->next){ }
		if (dev){
			dev->next = dev->next->next;
		}
		else {
			/*
			 *  Don't omit this error check.  I've seen NDIS call MiniportHalt with
			 *  a bogus context when the system gets corrupted.
			 */
			DBGERR(("Bad context in MiniportHalt"));
			return;
		}
	}


	/*
	 *  Now destroy the device object.
	 */
	DoClose(thisDev);

	NdisMDeregisterIoPortRange(	thisDev->ndisAdapterHandle,
								thisDev->portInfo.ioBase,
								8,
								(PVOID)thisDev->mappedPortRange);
	FreeDevice(thisDev);


}
예제 #2
0
파일: ndis.c 프로젝트: hoangduit/reactos
VOID
NTAPI
MiniportHalt (
    IN NDIS_HANDLE MiniportAdapterContext
    )
{
    PRTL_ADAPTER adapter = (PRTL_ADAPTER)MiniportAdapterContext;

    ASSERT(adapter != NULL);
    
    //
    // Interrupts need to stop first
    //
    if (adapter->InterruptRegistered != FALSE)
    {
        NdisMDeregisterInterrupt(&adapter->Interrupt);
    }

    //
    // If we have a mapped IO port range, we can talk to the NIC
    //
    if (adapter->IoBase != NULL)
    {   
        if (adapter->ReceiveBuffer != NULL)
        {
            //
            // Disassociate our shared buffer before freeing it to avoid
            // NIC-induced memory corruption
            //
            NICRemoveReceiveBuffer(adapter);

            NdisMFreeSharedMemory(adapter->MiniportAdapterHandle,
                                  adapter->ReceiveBufferLength,
                                  FALSE,
                                  adapter->ReceiveBuffer,
                                  adapter->ReceiveBufferPa);
        }
        
        if (adapter->RuntTxBuffers != NULL)
        {
            NdisMFreeSharedMemory(adapter->MiniportAdapterHandle,
                                  MINIMUM_FRAME_SIZE * TX_DESC_COUNT,
                                  FALSE,
                                  adapter->RuntTxBuffers,
                                  adapter->RuntTxBuffersPa);
        }
        
        //
        // Unregister the IO range
        //
        NdisMDeregisterIoPortRange(adapter->MiniportAdapterHandle,
                                   adapter->IoRangeStart,
                                   adapter->IoRangeLength,
                                   adapter->IoBase);
    }
    
    //
    // Destroy the adapter context
    //
    NdisFreeMemory(adapter, sizeof(*adapter), 0);
}