- Implement a MiniportShutdown routine for both NIC drivers

svn path=/branches/aicom-network-fixes/; revision=36669
This commit is contained in:
Cameron Gutman 2008-10-06 21:39:39 +00:00
parent b3443bcbb9
commit a033d44691
3 changed files with 36 additions and 1 deletions

View file

@ -175,6 +175,7 @@ typedef struct _NIC_ADAPTER
/* Flags used for driver cleanup */
BOOLEAN IOPortRangeRegistered;
BOOLEAN InterruptRegistered;
BOOLEAN ShutdownHandlerRegistered;
} NIC_ADAPTER, *PNIC_ADAPTER;
/* Global driver information */

View file

@ -141,10 +141,13 @@ static VOID STDCALL MiniportHalt(
0x20,
Adapter->IOBase);
if (Adapter->ShutdownHandlerRegistered)
NdisMDeregisterAdapterShutdownHandler(Adapter->MiniportAdapterHandle);
/* Remove adapter from global adapter list */
if ((&Adapter->ListEntry)->Blink != NULL) {
RemoveEntryList(&Adapter->ListEntry);
}
}
/* Free adapter context area */
NdisFreeMemory(Adapter, sizeof(NIC_ADAPTER), 0);
@ -203,6 +206,14 @@ static VOID STDCALL MiQueryResources(
}
}
VOID
STDCALL
MiniportShutdown(PVOID Context)
{
#ifndef NOCARD
NICStop((PNIC_ADAPTER)Context);
#endif
}
static NDIS_STATUS STDCALL MiniportInitialize(
OUT PNDIS_STATUS OpenErrorStatus,
@ -414,6 +425,12 @@ static NDIS_STATUS STDCALL MiniportInitialize(
/* Start the NIC */
NICStart(Adapter);
#endif
/* Register the shutdown handler */
NdisMRegisterAdapterShutdownHandler(MiniportAdapterHandle, Adapter, MiniportShutdown);
Adapter->ShutdownHandlerRegistered = TRUE;
/* Add adapter to the global adapter list */
InsertTailList(&DriverInfo.AdapterListHead, &Adapter->ListEntry);

View file

@ -573,6 +573,9 @@ MiniportHalt(
/* deregister i/o port range */
NdisMDeregisterIoPortRange(Adapter->MiniportAdapterHandle, Adapter->IoBaseAddress, NUMBER_OF_PORTS, (PVOID)Adapter->PortOffset);
/* deregister the shutdown routine */
NdisMDeregisterAdapterShutdownHandler(Adapter->MiniportAdapterHandle);
/* free shared memory */
MiFreeSharedMemory(Adapter);
@ -781,6 +784,18 @@ MiTestCard(
}
#endif
VOID
STDCALL
MiniportShutdown( PVOID Context )
{
PADAPTER Adapter = Context;
DPRINT("Stopping the chip\n");
NdisRawWritePortUshort(Adapter->PortOffset + RAP, CSR0);
NdisRawWritePortUshort(Adapter->PortOffset + RDP, CSR0_STOP);
}
static NDIS_STATUS
STDCALL
MiniportInitialize(
@ -952,6 +967,8 @@ MiniportInitialize(
ASSERT(0);
#endif
NdisMRegisterAdapterShutdownHandler(Adapter->MiniportAdapterHandle, Adapter, MiniportShutdown);
DPRINT("returning 0x%x\n", Status);
*OpenErrorStatus = Status;
return Status;