📄 exitproc.c
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
/** @file exitproc.c
* @This module provides NDIS shutdown routines
*
* Copyright (c) Marvell Semiconductor, Inc.
*/
/*
===============================================================================
INCLUDE FILES
===============================================================================
*/
#include "precomp.h"
extern NDIS_HANDLE gNdisWrapperHandle;
/*
===============================================================================
CODED PUBLIC PROCEDURES
===============================================================================
/******************************************************************************
*
* Name: MrvDrvReset()
*
* Description:
* NDIS miniport reset routine.
*
* Conditions for Use:
* Will be called by NDIS wrapper to reset the device
*
* Arguments:
* OUT PBOOLEAN AddressingReset
* IN NDIS_HANDLE MiniportAdapterContext
*
* Return Value:
*
* Notes:
*
*****************************************************************************/
NDIS_STATUS
MrvDrvReset(
OUT PBOOLEAN AddressingReset,
IN NDIS_HANDLE MiniportAdapterContext
)
{
PMRVDRV_ADAPTER Adapter;
BOOLEAN bDoNotify = FALSE;
//AllenDBGPRINT(1,("WARNING: -MrvDrvReset()\n"));
Adapter = (PMRVDRV_ADAPTER)MiniportAdapterContext;
Adapter->bIsPendingReset = TRUE;
ResetCmdBuffer(Adapter);
CleanUpSingleTxBuffer(Adapter);
*AddressingReset = FALSE;
//Adapter->MediaConnectStatus = NdisMediaStateDisconnected;
//NdisMSetTimer(&Adapter->MrvDrvIndicateConnectStatusTimer, 100);
//Adapter->DisconnectTimerSet = TRUE;
Adapter->bIsPendingReset = FALSE;
return NDIS_STATUS_SUCCESS;
}
/******************************************************************************
*
* Name: MrvDrvCheckForHang()
*
* Description:
* NDIS miniport check for hang routine.
*
* Conditions for Use:
* Will be called by NDIS wrapper to determine current station operation status.
* If the station is not responding, NDIS wrapper will call MrvDrvReset() to reset
* the station. Driver first check and use current HW status stored in device
* object to report system then update the status and send command to query HW status.
*
* Arguments:
* IN NDIS_HANDLE MiniportAdapterContext
*
* Return Value:
* TRUE if the NIC HW is not operating properly
* FALSE if the NIC HW is OK
*
* Notes: According to Microsoft NDIS document, this function is normally called
* by NDIS wrapper approximately every 2 seconds.
*
*****************************************************************************/
BOOLEAN
MrvDrvCheckForHang(
IN NDIS_HANDLE MiniportAdapterContext
)
{
PMRVDRV_ADAPTER Adapter;
DBGPRINT(DBG_LOAD,("INIT - Enter MrvDrvCheckForHang\n"));
Adapter = (PMRVDRV_ADAPTER)MiniportAdapterContext;
/// AllenDBGPRINT(DBG_OID,("REQUEST - OID_802_11_RSSI (%d)****\n", Adapter->LastRSSI));
if ( (Adapter->psState != PS_STATE_FULL_POWER) &&
(Adapter->psState != PS_STATE_WAKEUP) )
{
DBGPRINT(DBG_LOAD, ("Not in wake mode \n"));
return FALSE;
}
if (Adapter->IsDeepSleep || Adapter->IsDeepSleepRequired)
{
DBGPRINT(DBG_LOAD, ("Now in deepsleep mode \n"));
return FALSE;
}
return FALSE;
#ifdef DEEP_SLEEP
// In Deep Sleep Mode no packet can be sent out
if (Adapter->IsDeepSleep)
{
return FALSE;
}
#endif
/// check card removed
if ( Adapter->SurpriseRemoved == TRUE )
{
DBGPRINT(DBG_WARNING |DBG_TXDATA, ("Adapter is removed, return TRUE in CheckForHang\n"));
return TRUE;
}
#ifdef UNDER_CE
/// when D3 don't check for hang
if ( Adapter->CurPowerState != NdisDeviceStateD0 )
{
return FALSE;
}
/// check the timeout times , may be we need to set the bigger number than '2' in longer check for hang period
if ( Adapter->ucNumCmdTimeOut > 2 )
{
DBGPRINT(DBG_LOAD | DBG_WARNING |DBG_TXDATA,
("CheckForHang: %d cmd time out in last period, reset!\n",
Adapter->ucNumCmdTimeOut));
// more than 2 cmd time out in the last period, something is wrong
Adapter->ucNumCmdTimeOut = 0;
return TRUE;
}
Adapter->ucNumCmdTimeOut = 0;
/*
/// read the card to check for hang
if ( (Adapter->psState == PS_STATE_FULL_POWER) ||
(Adapter->psState == PS_STATE_WAKEUP) )
{
USHORT usVal;
NdisRawReadPortUshort(
((PCF_OBJECT)Adapter->hwIface)->ulMrvDrvVirtualIoBase + CFMACREG_CCR_SCRATCH_PORT-1,
&usVal);
DBGPRINT(DBG_LOAD, ("CheckForHang Read back 0x%x\n", usVal));
if ( usVal == 0x0 )
{
DBGPRINT(DBG_LOAD | DBG_WARNING,
("CheckForHang read back 0x0 from scratch port! reset the queues\n"));
return TRUE;
}
}
*/
#endif
/*
/// driver background scan
if ( Adapter->MediaConnectStatus == NdisMediaStateConnected )
{
Adapter->usTimeElapsedSinceLastScan += MRVL_CHECK_FOR_HANG_TIME;
if ( (Adapter->ulTxByteInLastPeriod + Adapter->ulRxByteInLastPeriod) <
MRVL_SCAN_ALLOW_THRESHOLD )
{
if ( Adapter->usTimeElapsedSinceLastScan > MRVL_BACKGOUND_SCAN_TIME )
{
Adapter->usTimeElapsedSinceLastScan = 0;
if (!Adapter->bIsAssociateInProgress && !Adapter->bIsScanInProgress)
{
DBGPRINT(DBG_OID, ("period scan in MrvDrvCheckForHang()"));
Adapter->bIsScanWhileConnect = TRUE;
// scan
PrepareAndSendCommand(
Adapter,
HostCmd_CMD_802_11_SCAN,
0,
HostCmd_OPTION_USE_INT,
(NDIS_OID)0,
HostCmd_PENDING_ON_NONE,
0,
FALSE,
NULL,
NULL,
NULL,
NULL);
}
// update RSSI value
PrepareAndSendCommand(
Adapter,
HostCmd_CMD_802_11_RSSI,
0,
HostCmd_OPTION_USE_INT,
(NDIS_OID)0,
HostCmd_PENDING_ON_NONE,
0,
FALSE,
NULL,
NULL,
NULL,
NULL);
}
}
Adapter->ulTxByteInLastPeriod =
Adapter->ulRxByteInLastPeriod = 0;
}
*/
return FALSE;
}
/******************************************************************************
*
* Name: MrvDrvHalt()
*
* Description: NDIS miniport halt event handler
*
*
* Arguments: IN NDIS_HANDLE MiniportAdapterContext
* Miniport context
*
* Return Value: None
*
* Notes:
*
*****************************************************************************/
VOID
MrvDrvHalt(
IN NDIS_HANDLE MiniportAdapterContext
)
{
PMRVDRV_ADAPTER Adapter = (PMRVDRV_ADAPTER)MiniportAdapterContext;
// AllenDBGPRINT(DBG_UNLOAD |DBG_SP,("Enter MrvDrvHalt >>\n"));
//RETAILMSG(1, (TEXT("Enter MrvDrvHalt >> ")));
if (Adapter->MediaConnectStatus == NdisMediaStateConnected)
{
USHORT usCommand;
// Adapter is connected and there is a mode change
// Disconnect first
if ( Adapter->InfrastructureMode == Ndis802_11Infrastructure )
usCommand = HostCmd_CMD_802_11_DEAUTHENTICATE;
else
usCommand = HostCmd_CMD_802_11_AD_HOC_STOP;
//RETAILMSG(1, (TEXT("usCommand = %d \r\n "), usCommand));
// completely clean up
PrepareAndSendCommand(
Adapter,
usCommand,
0,
HostCmd_OPTION_USE_INT,
(NDIS_OID)0,
HostCmd_PENDING_ON_NONE,
0,
FALSE,
NULL,
NULL,
NULL,
Adapter->CurrentBSSID);
NdisMSleep(10000);
}
Adapter->SurpriseRemoved = TRUE;
// report link status change
ResetDisconnectStatus(Adapter);
#ifndef UNDER_CE
// Issue reset command to HW
if ( !Adapter->SurpriseRemoved )
{
PrepareAndSendCommand(
Adapter,
HostCmd_CMD_802_11_RESET,
HostCmd_ACT_HALT,
HostCmd_OPTION_NO_INT,
(NDIS_OID)0,
HostCmd_PENDING_ON_NONE,
0,
FALSE,
NULL,
NULL,
NULL,
NULL);
}
// Wait for reset command to finish
NdisMSleep(10000);
#endif
Adapter->bIsFreeNow = TRUE;
FreeAdapter(Adapter);
if (gNdisWrapperHandle!=NULL)
{
NdisTerminateWrapper(gNdisWrapperHandle, NULL);
gNdisWrapperHandle=NULL;
}
return;
}
/******************************************************************************
*
* Name: MrvDrvShutdownHandler()
*
* Description: NDIS miniport shutdown event handler
*
*
* Arguments: IN NDIS_HANDLE MiniportAdapterContext
* Miniport context
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -