⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 miscproc.c

📁 Windows CE 6.0 BSP for VOIP sample phone. Intel PXA270 platform.
💻 C
📖 第 1 页 / 共 5 页
字号:
//
// 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 miscproc.c
 *  @This module provides the implementation of power managment 
 *   and timer routines
 *
 *  Copyright (c) Marvell Semiconductor, Inc. 
 */

#include "precomp.h"


#ifdef WHQL_FIX
/******************************************************************************
 *
 *  Name: MrvDrvIndicateConnectStatusTimer()
 *
 *  Description: (1) Timer that will be fired after initialize routine is done to indicate disconnect  
 *                    (2) when NDIS call the reset functuion the timer used for indicate connect when reset completely 
 *
 *  Arguments:           
 *	    IN PVOID SystemSpecific1
 *	    IN PVOID FunctionContext
 *	    IN PVOID SystemSpecific2
 *	    IN PVOID SystemSpecific3
 *    
 *  Return Value: None
 * 
 *  Notes:               
 *
 *****************************************************************************/
VOID
MrvDrvIndicateConnectStatusTimer(
	IN PVOID SystemSpecific1,
	IN NDIS_HANDLE MiniportAdapterContext,
	IN PVOID SystemSpecific2,
	IN PVOID SystemSpecific3
	)
{

	PMRVDRV_ADAPTER Adapter = (PMRVDRV_ADAPTER) MiniportAdapterContext;

	if ( Adapter->MediaConnectStatus == NdisMediaStateConnected )
	{
		Adapter->MediaConnectStatus = NdisMediaStateConnected ;
		
		NdisMIndicateStatus(
						Adapter->MrvDrvAdapterHdl,
						NDIS_STATUS_MEDIA_CONNECT,
						(PVOID)NULL,
						0);

		NdisMIndicateStatusComplete(Adapter->MrvDrvAdapterHdl);
	}
	else
	{
		NdisMIndicateStatus(
						Adapter->MrvDrvAdapterHdl,
						NDIS_STATUS_MEDIA_DISCONNECT,
						(PVOID)NULL,
						0);

		NdisMIndicateStatusComplete(Adapter->MrvDrvAdapterHdl);
	}

	Adapter->DisconnectTimerSet = FALSE;
}

#endif

/******************************************************************************
 *
 *  Name: MrvDrvAvoidScanAfterConnectedTimer()
 *
 *  Description: Timer that will be fired after initialize routine is done
 *				 to indicate connected
 *
 *
 *  Arguments:           
 *	    IN PVOID SystemSpecific1
 *	    IN PVOID FunctionContext
 *	    IN PVOID SystemSpecific2
 *	    IN PVOID SystemSpecific3
 *    
 *  Return Value: None
 * 
 *  Notes:               
 *
 *****************************************************************************/
VOID
MrvDrvAvoidScanAfterConnectedTimer(
	IN PVOID SystemSpecific1,
	IN NDIS_HANDLE MiniportAdapterContext,
	IN PVOID SystemSpecific2,
	IN PVOID SystemSpecific3
	)
{

	PMRVDRV_ADAPTER Adapter = (PMRVDRV_ADAPTER) MiniportAdapterContext;

       Adapter->bAvoidScanAfterConnectedforMSecs = FALSE;
}

/******************************************************************************
 *
 *  Name: MrvDrvTxPktTimerFunction()
 *
 *  Description: Tx Timer routine
 *
 *  Conditions for Use: (Not used in the current verison of driver)
 *
 *  Arguments:           
 *	    IN PVOID SystemSpecific1
 *	    IN PVOID FunctionContext
 *	    IN PVOID SystemSpecific2
 *	    IN PVOID SystemSpecific3
 *    
 *  Return Value: None
 * 
 *  Notes:               
 *
 *****************************************************************************/
VOID MrvDrvTxPktTimerFunction(
	IN PVOID SystemSpecific1,
	IN PVOID FunctionContext,
	IN PVOID SystemSpecific2,
	IN PVOID SystemSpecific3
	)
{
       USHORT usLOCAL_INTCause;
	   
	PMRVDRV_ADAPTER Adapter = (PMRVDRV_ADAPTER) FunctionContext;

	DBGPRINT(DBG_TIMERS | DBG_WARNING,("- TX Pkt timeout, Tx Done does not response \n"));
///	AllenDBGPRINT(DBG_TIMERS | DBG_WARNING,("- TX Pkt timeout, Tx Done does not response \n"));

//	RETAILMSG(1, (TEXT("- MrvDrvTxPktTimerFunction --TX Pkt timeout \r\n")));

	EnterCriticalSection(&Adapter->IntCriticalSection);   
	   
    	usLOCAL_INTCause = 0;
    	NdisRawReadPortUshort(
       	 	Adapter->ulMrvDrvVirtualIoBase + CFMACREG_CCR_HOST_INT_CAUSE,
        		&usLOCAL_INTCause);
       
 	usLOCAL_INTCause &= CFMACREG_CCR_HIC_MASK;

 	NdisRawWritePortUshort(
       Adapter->ulMrvDrvVirtualIoBase + CFMACREG_CCR_HOST_INT_CAUSE,
       				 usLOCAL_INTCause);

	LeaveCriticalSection(&Adapter->IntCriticalSection);   	
   
       ///RETAILMSG(1, (TEXT("usLOCAL_INTCause = %x \r\n"),usLOCAL_INTCause));
       EnterCriticalSection(&Adapter->DpcCriticalSection);
   
       if (usLOCAL_INTCause & CFMACREG_CCR_HIC_RxUpLdRdy )
       {    	
             HandleRxReadyEvent(Adapter);
       }

	if (( Adapter->SentPacket !=NULL ) ||(usLOCAL_INTCause & CFMACREG_CCR_HIC_TxDnLdRdy ))
	{
      		DBGPRINT(DBG_TXDATA,("Tx Timeout: #%d pkts in Queue\n\r",Adapter->TxPacketCount));

		// clean up the timed out pkt
 		HandleTxSingleDoneEvent(Adapter);	 				
	}
       Adapter->bIsDoingTx = FALSE;

   	Adapter->TxPktTimerIsSet = FALSE;

       LeaveCriticalSection(&Adapter->DpcCriticalSection);   
	   
	EnableInterrupt(Adapter);  // unmask all masked interrupts
	   
       return;
    	
}

VOID MrvDrvReConnectTimerFunction(
	IN PVOID SystemSpecific1,
	IN PVOID FunctionContext,
	IN PVOID SystemSpecific2,
	IN PVOID SystemSpecific3
	)
{

//    	NDIS_STATUS Status;
	
	PMRVDRV_ADAPTER Adapter = (PMRVDRV_ADAPTER) FunctionContext;

	DBGPRINT(DBG_TIMERS | DBG_ALLEN,("++ MrvDrvReConnectTimerFunction\n"));

    	ReConnectHandler(Adapter);
	
	//Adapter->ReConnectTimerIsSet = FALSE;
	
	DBGPRINT(DBG_TIMERS | DBG_ALLEN,("-- MrvDrvReConnectTimerFunction\n"));
	
	return;
}

#ifdef ACTIVE_ROAMING
VOID MrvDrvActiveRoamingTimerFunction(
	IN PVOID SystemSpecific1,
	IN PVOID FunctionContext,
	IN PVOID SystemSpecific2,
	IN PVOID SystemSpecific3
	)
{

	PMRVDRV_ADAPTER Adapter = (PMRVDRV_ADAPTER) FunctionContext;
	
	ActiveRoamingHandler(Adapter);
	
	return;
}

#ifdef BG_SCAN
VOID MrvDrvBGActiveRoamingTimerFunction(
	IN PVOID SystemSpecific1,
	IN PVOID FunctionContext,
	IN PVOID SystemSpecific2,
	IN PVOID SystemSpecific3
	)
{
       BOOLEAN  timerStatus;
	PMRVDRV_ADAPTER Adapter = (PMRVDRV_ADAPTER) FunctionContext;
	
	//ActiveRoamingHandler(Adapter);
	   	
       if ( Adapter->MediaConnectStatus == NdisMediaStateConnected )
       {
		//preset	
           	if ((Adapter->bBgScanEnabled==TRUE) )
           	{
           		EnableBgScan(Adapter,FALSE);
		}
		SetupBgScanCurrentSSID(Adapter,Adapter->ulScanInterval);   
	 
		EnableBgScan(Adapter,TRUE);
       }
		
       NdisMCancelTimer(&Adapter->MrvBGActiveRoamingTimer, &timerStatus);
	Adapter->BGActiveRoamingTimerIsSet = FALSE;

	return;
}
#endif  //BG_SCAN
#endif  //ACTIVE_ROAMING
/******************************************************************************
 *
 *  Name: MrvDrvCommandTimerFunction()
 *
 *  Description: Command time-out routine
 *
 *  Conditions for Use: When current command exceeds expected execution time limit,
 *                      commad will expire and call the command time-out ruotine
 *
 *  Arguments:           
 *	    IN PVOID SystemSpecific1
 *	    IN PVOID FunctionContext
 *	    IN PVOID SystemSpecific2
 *	    IN PVOID SystemSpecific3
 *    
 *  Return Value: None
 * 
 *  Notes:               
 *
 *****************************************************************************/
VOID MrvDrvCommandTimerFunction(
	IN PVOID SystemSpecific1,
	IN PVOID FunctionContext,
	IN PVOID SystemSpecific2,
	IN PVOID SystemSpecific3
	)
{
	CmdCtrlNode *pTempNode;
	PHostCmd_DS_GEN pRetPtr;
 	USHORT  usLOCAL_INTCause;

	// get the adpater context
	PMRVDRV_ADAPTER Adapter = (PMRVDRV_ADAPTER) FunctionContext;

//	RETAILMSG(1, (TEXT("MrvDrvCommandTimerFunction \r\n")));

       Adapter->CommandTimerSet = FALSE;

	if( !Adapter->CurCmd )
	{
    	        DBGPRINT(DBG_TIMERS,("MrvDrvCommandTimerFunction() Timer fired, but no current command.\n"));
	        return;
	}

       Adapter->ucNumCmdTimeOut++;
	
	DBGPRINT(DBG_TIMERS | DBG_CMDRESP | DBG_ERROR,("MISC - Command TIME OUT !! \n"));
	//AllenDBGPRINT(DBG_TIMERS | DBG_CMDRESP | DBG_ERROR,("MISC - Command TIME OUT !! \n"));
	//RETAILMSG(1, (TEXT("MISC - Command TIME OUT !!\r\n")));
	//DEBUGMSG(1, (TEXT("MISC - Command TIME OUT !!\r\n")));
	
	pTempNode = Adapter->CurCmd;
	pRetPtr = (PHostCmd_DS_GEN)(pTempNode->BufVirtualAddr);

///	RETAILMSG(1, (TEXT("MrvDrvCommandTimerFunction  %02x \r\n "),  pRetPtr->Command ));
	DBGPRINT(DBG_TIMERS | DBG_CMDRESP | DBG_ERROR,("pRetPtr->Command 0x%x !! \n", pRetPtr->Command));

	EnterCriticalSection(&Adapter->IntCriticalSection);  
 
       usLOCAL_INTCause = 0;
       NdisRawReadPortUshort(
           		Adapter->ulMrvDrvVirtualIoBase + CFMACREG_CCR_HOST_INT_CAUSE,
           		&usLOCAL_INTCause);

 	usLOCAL_INTCause &= CFMACREG_CCR_HIC_MASK;

       NdisRawWritePortUshort(
       		Adapter->ulMrvDrvVirtualIoBase + CFMACREG_CCR_HOST_INT_CAUSE,
       		usLOCAL_INTCause);

       LeaveCriticalSection(&Adapter->IntCriticalSection);  

///    RETAILMSG(1, (TEXT("CMDTimer: Int cause read: 0x%x \r\n "),  usLOCAL_INTCause ));   
       //AllenDBGPRINT(DBG_CMDRESP | DBG_ERROR, ("CMDTimer: Int cause read: 0x%x\n", usLOCAL_INTCause));

       EnterCriticalSection(&Adapter->DpcCriticalSection);                			

       if (usLOCAL_INTCause & CFMACREG_CCR_HIC_RxUpLdRdy )
       {    	
             HandleRxReadyEvent(Adapter);
       }

       if (( Adapter->SentPacket !=NULL ) ||(usLOCAL_INTCause & CFMACREG_CCR_HIC_TxDnLdRdy ))
       {
             DBGPRINT(DBG_TXDATA,("Tx Timeout: #%d pkts in Queue\n\r",Adapter->TxPacketCount));

  	     // clean up the timed out pkt
 	     HandleTxSingleDoneEvent(Adapter);	 				
       }
       Adapter->bIsDoingTx = FALSE;

	HandleCommandFinishedEvent(Adapter);		

       LeaveCriticalSection(&Adapter->DpcCriticalSection);  
			  
       EnableInterrupt(Adapter);      

	if ((pRetPtr->Command == HostCmd_CMD_802_11_SCAN ) 
	    // && (Adapter->CurCmd->Pad[2] |= MRVDRV_SCAN_CMD_END)
	)
	{
              NdisMSendResourcesAvailable(Adapter->MrvDrvAdapterHdl); 

		Adapter->bIsScanInProgress = FALSE;
              Adapter->bIsAssociationBlockedByScan = FALSE;

		if (Adapter->bTXRESOURCES==TRUE)
		{
			   NdisMSendResourcesAvailable(Adapter->MrvDrvAdapterHdl); 
                        Adapter->bTXRESOURCES=FALSE;
		}
				  
	}	
       else if ((pRetPtr->Command == HostCmd_CMD_802_11_ASSOCIATE)   ||
	   	     (pRetPtr->Command == HostCmd_CMD_802_11_ASSOCIATE_EXT) ||	
	    	     (pRetPtr->Command == HostCmd_CMD_802_11_REASSOCIATE) ||
	            (pRetPtr->Command == HostCmd_CMD_802_11_AD_HOC_START))
       {
///		 RETAILMSG(1, (TEXT("HostCmd_CMD_802_11_ASSOCIATE_EXT timeout \r\n ")));   
	        Adapter->bIsAssociateInProgress = FALSE;
               Adapter->bIsAssociationBlockedByScan = FALSE;
	}
        else
        {

		if ( pTempNode->PendingInfo == HostCmd_PENDING_ON_GET_OID )
       	{
	       	NdisMQueryInformationComplete(
					Adapter->MrvDrvAdapterHdl,
						NDIS_STATUS_SUCCESS);
		}
		else if( pTempNode->PendingInfo == HostCmd_PENDING_ON_SET_OID )
       	{
			NdisMSetInformationComplete(
					Adapter->MrvDrvAdapterHdl,
					NDIS_STATUS_SUCCESS	);
		}
		
        }
		
	// set the timer state variable to TRUE
	Adapter->isCommandTimerExpired = TRUE;

	Adapter->bIsDoingCmd = FALSE;

	// Clean up 
	if ( Adapter->CurCmd)
	{
	ReturnCmdNode (Adapter,Adapter->CurCmd);
	Adapter->CurCmd = NULL;
	}

	//// ExecuteNextCommand(Adapter);
	GetCmdFromQueueToExecute (Adapter);

	return;
}

/******************************************************************************
 *
 *  Name: SetStationPowerState()
 *
 *  Description: Set MrvDrv power state
 *
 *  Conditions for Use: Called by power state set OID handler
 *
 *  Arguments:           
 *      PMRVDRV_ADAPTER Adapter
 *      NDIS_DEVICE_POWER_STATE NewPowerState
 *      IN NDIS_OID Oid
 *      IN PULONG BytesRead
 *      IN PULONG BytesNeeded
 *      IN PVOID InformationBuffer
 *    
 *  Return Value:        
 * 
 *  Notes:               
 *
 *****************************************************************************/
NDIS_STATUS
SetStationPowerState(
    	PMRVDRV_ADAPTER Adapter,
	NDIS_DEVICE_POWER_STATE NewPowerState,
	IN NDIS_OID Oid,
	IN PULONG BytesRead,
	IN PULONG BytesNeeded,
	IN PVOID InformationBuffer
)
{ 
	BOOLEAN     bFwReloaded = FALSE;
	IX_STATUS   ixStatus = IX_STATUS_SUCCESS;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -