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

📄 intproc.c

📁 marvell wifi driver CF-8385PN-NDIS-ARM4-WINCE50-5.24.17.p5-27.p11.src.zip
💻 C
字号:
/******************* ?Marvell Semiconductor, Inc., 2001-2004 *****************
 *
 *  Purpose:    This module provides implementaion of ISR, DPC and other 
 *              interrupt related routines
 *
 *	$Author: schiu $
 *
 *	$Date: 2004/10/27 $
 *
 *	$Revision: #3 $
 *
 *****************************************************************************/

#include "precomp.h"

/******************************************************************************
*
*  Name: MrvDrvIsr()
*
*  Description: Miniport driver interrupt service routine
*
*  Conditions for Use: Will be called when HW interrupt occurred
*
*  Arguments:           
*	    OUT PBOOLEAN InterruptRecognized
*	    OUT PBOOLEAN QueueMiniportHandleInterrupt
*	    IN NDIS_HANDLE MiniportAdapterContext
*    
*  Return Value: Miniport driver needs to determine whether the interrupt is from MrvDrv HW
*                and set both InterruptRecognized and QueueMiniportHandleInterrupt flags
* 
*  Notes:               
*
*****************************************************************************/
VOID
MrvDrvIsr(
	OUT PBOOLEAN InterruptRecognized,
       OUT PBOOLEAN QueueMiniportHandleInterrupt,
	IN NDIS_HANDLE MiniportAdapterContext
    )
{
    	PMRVDRV_ADAPTER Adapter;
    	USHORT usLOCAL_INTCause;
    	// USHORT usRegVal;
    	static UCHAR uc_SleepConfirmCmdReply=0;
    
    	*InterruptRecognized = FALSE;
   	*QueueMiniportHandleInterrupt = FALSE;    

    	DBGPRINT(DBG_ISR | DBG_SP,("+MrvDrvIsr\n"));
    	Adapter = (PMRVDRV_ADAPTER)MiniportAdapterContext;

/*
#ifdef DEEP_SLEEP 
    	if (Adapter->IsDeepSleepRequired == FALSE &&
           Adapter->IsDeepSleep)
    	{
    		*InterruptRecognized = TRUE;
		return;
    	}
#endif
*/
        
       // under CE, the timing of the thread is causing the interrupt to remain disabled
    	// in power save mode
    	if ((Adapter->PSMode == Ndis802_11PowerModeCAM) ||
           (Adapter->MediaConnectStatus == NdisMediaStateDisconnected))
    	{
		DBGPRINT(DBG_SP,("+MrvDrvIsr call DisableInterrupt\n"));
		DisableInterrupt(Adapter); 
    	}

    	// Read Interrupt cause register
    	usLOCAL_INTCause = 0;
    	NdisRawReadPortUshort(
       	 	Adapter->ulMrvDrvVirtualIoBase + CFMACREG_CCR_HOST_INT_CAUSE,
        		&usLOCAL_INTCause);
    
  	DBGPRINT(DBG_SP,("ISR:usLOCAL_INTCause:\n",usLOCAL_INTCause ));
      
    	// If interrupt is all ones, then card is probably gone.		
    	if ((usLOCAL_INTCause == 0xffff) || (usLOCAL_INTCause == 0x007f) ||(usLOCAL_INTCause == 0x0000))
    	{
            	*InterruptRecognized = TRUE;

		DBGPRINT(DBG_ISR,("-MrvDrvIsr\n"));
        	return;
    	}
        
       EnterCriticalSection(&Adapter->IntCriticalSection);   
      
       Adapter->usINTCause |= (usLOCAL_INTCause & CFMACREG_CCR_HIC_MASK);

       LeaveCriticalSection(&Adapter->IntCriticalSection);   
      		
       DBGPRINT(DBG_ISR ,("ISR %x \n",usLOCAL_INTCause));
       
       usLOCAL_INTCause &= CFMACREG_CCR_HIC_MASK;
    	
       // Clear the source of the interrupt
       NdisRawWritePortUshort(
       Adapter->ulMrvDrvVirtualIoBase + CFMACREG_CCR_HOST_INT_CAUSE,
       				 usLOCAL_INTCause);

    	// Claim the interrupt
    	*InterruptRecognized = TRUE;
    	*QueueMiniportHandleInterrupt = TRUE;
	
   	DBGPRINT(DBG_ISR,("-MrvDrvIsr\n"));
	return;
}

/******************************************************************************
*
*  Name: MrvDrvHandleInterrupt()
*
*  Description: 
*
*  Conditions for Use:   
*
*  Arguments:           
*    
*  Return Value:        
* 
*  Notes:               
*
*****************************************************************************/
VOID
MrvDrvHandleInterrupt(
    IN NDIS_HANDLE MiniportAdapterContext
    )
{
	// UINT INTCode;
       PMRVDRV_ADAPTER Adapter = (PMRVDRV_ADAPTER)MiniportAdapterContext;
       USHORT usCardStatus ; // ,usRegValue;
       PCF_OBJECT pCf = Adapter->hwIface;			// hw interface object.
       USHORT  usINTCause = 0;
       USHORT  usLOCAL_INTCause=0;
    
    	DBGPRINT(DBG_ISR | DBG_SP,("+MrvDrvHandleInterrupt() %x \n",Adapter->usINTCause));

#ifdef DEEP_SLEEP 

    	if ((Adapter->IsDeepSleepRequired == FALSE) &&
	     Adapter->IsDeepSleep)
    	{
    		if (!(Adapter->usINTCause & CFMACREG_CCR_HIC_CardEvent))
			return;

		DBGPRINT(DBG_DEEPSLEEP,("DPC --> Deep Sleep WakeUp event \n"));
    	}
	else if ((Adapter->IsDeepSleepRequired ) &&
	            Adapter->IsDeepSleep== FALSE)
	{
		if (!(Adapter->usINTCause & CFMACREG_CCR_HIC_CmdRspRdy))
			return;
	}
	
#endif

    	// Check device removal status
    	if ( Adapter->SurpriseRemoved == TRUE )
    	{
       	DBGPRINT(DBG_ISR, ("MrvDrvHandleInterrupt() SurpriseRemoved is TRUE, ignore interrupt!\n"));
        	return;
    	}

  	//DisableInterrupt(Adapter); 
		
	if ( Adapter->CurPowerState == NdisDeviceStateD3 )
		Adapter->usINTCause = 0;
	
       EnterCriticalSection(&Adapter->IntCriticalSection);   
         
	usINTCause = Adapter->usINTCause;
	Adapter->usINTCause = 0;

       LeaveCriticalSection(&Adapter->IntCriticalSection);   

//       DBGPRINT(DBG_DRALEE | DBG_SP,("usINTCause ++ 0x%x\n", usINTCause));  
		  
    	// Handle interrupts
    	while( usINTCause )    
    	{
        	// Handle RX packet ready interrupt.
		do {
			if (usINTCause & CFMACREG_CCR_HIC_RxUpLdRdy )
        		{    
				if (Adapter->psState == PS_STATE_SLEEP) 
						break;
			
				if (Adapter->psState == PS_STATE_SLEEP_PENDING) 
						break;
			
             			// RX ready
             			usINTCause &= ~CFMACREG_CCR_HIC_RxUpLdRdy;
             
//             			DBGPRINT(DBG_ISR  | DBG_NEWPS | DBG_SP,("INTR - RxUpLdRdy \n"));
             			HandleRxReadyEvent(Adapter);
        		}
		} while(0);
		
        	// Handle TX packet ready interrupt.	
        	do {
        		if (usINTCause & CFMACREG_CCR_HIC_TxDnLdRdy )
        		{
				if (Adapter->psState == PS_STATE_SLEEP) 
						break;
			
				if (Adapter->psState == PS_STATE_SLEEP_PENDING) 
						break;

				// TX Done
             			usINTCause &= ~CFMACREG_CCR_HIC_TxDnLdRdy;
                    
             			//cf_UshortRegSetBits(pCf, CFMACREG_HCR_HOST_INT_MASK,CFMACREG_HCR_HIM_TxDnLdRdy);
                   
//             			DBGPRINT(DBG_ISR  | DBG_NEWPS |DBG_SP,("INTR - TxDnLdRdy \n"));
             			HandleTxSingleDoneEvent(Adapter); 
        		}
		} while(0);

              // Handle Command response interrupt.
		do {
			if (usINTCause & CFMACREG_CCR_HIC_CmdRspRdy )
        		{   
				if (Adapter->psState == PS_STATE_SLEEP) 
						break;
			
				if (Adapter->psState == PS_STATE_SLEEP_PENDING) 
						break;
			
				// Command finished
             			usINTCause &= ~CFMACREG_CCR_HIC_CmdRspRdy;

             			//DBGPRINT(DBG_ISR  | DBG_NEWPS|DBG_SP,("INTR - CmdRspRdy \n"));
             			HandleCommandFinishedEvent(Adapter);
        		}
		} while(0);

		// Handle MAC event interrupt.	
		do {	
			if ( usINTCause & CFMACREG_CCR_HIC_CardEvent  )
        		{ 
				// if (Adapter->psState == PS_STATE_SLEEP) 
				//		break;
			
				// if (Adapter->psState == PS_STATE_SLEEP_PENDING) 
				//		break;

				usINTCause &= ~CFMACREG_CCR_HIC_CardEvent;
             
            			// MAC event
            			DBGPRINT(DBG_ISR| DBG_NEWPS,("INTR - CardEvent \n"));
            
				// Read Card status register
            			NdisRawReadPortUshort(
                				Adapter->ulMrvDrvVirtualIoBase + CFMACREG_CCR_CARD_STATUS,
                				&usCardStatus);
				
#if 0	//ahan[2005-12-08], remove for firmware version 5.0.11.0
    				NdisRawWritePortUshort(
                				Adapter->ulMrvDrvVirtualIoBase + CFMACREG_CCR_CARD_STATUS,
                				0);
#endif
				usCardStatus &= CFMACREG_CCR_CS_STATUS_MASK;
            			usCardStatus = usCardStatus >> 8;

#if 1	//ahan[2005-12-08], for firmware version 5.0.11.0
                		// trigger firmware to send next event 
                NdisRawWritePortUshort(
                        Adapter->ulMrvDrvVirtualIoBase + CFMACREG_HCR_CARD_INT_CAUSE,
                        CFMACREG_HCR_CIC_HstEvent);
#endif

#if 0  
                if ( (Adapter->psState == PS_STATE_SLEEP) &&
                     (usCardStatus == MACREG_INT_CODE_PS_SLEEP) )
			          	break;

                if ( (Adapter->psState == PS_STATE_WAKEUP) && 
                     (usCardStatus == MACREG_INT_CODE_PS_AWAKE) )
			          	break;	
#endif 
			       
				if ((usCardStatus) &&  (usCardStatus != 0x7f))  
            				HandleMACEvent(Adapter, usCardStatus);

        		}
		}while(0);

        	if ( usINTCause & CFMACREG_CCR_HIC_CmdDnLdRdy )
        	{  
             		usINTCause &= ~CFMACREG_CCR_HIC_CmdDnLdRdy;

			// Command download ready
             		DBGPRINT(DBG_ISR,("INTR - CmdDnlRdy \n"));
        	}
	
    	}
      
	// Enable PC Card interrupt
	EnableInterrupt(Adapter);  // unmask all masked interrupts
	
    	DBGPRINT(DBG_ISR,("INTR DPC - Exit MrvDrvHandleInterrupt \n"));
    
}


/******************************************************************************
*
*  Name: MrvDrvDisableInterrupt()
*
*  Description: Miniport HW interrupt disable routine
*
*  Conditions for Use: Will be called to disable HW PCI/CardBus interrupt
*
*  Arguments:
*      IN NDIS_HANDLE MiniportAdapterContext
*    
*  Return Value: None
* 
*  Notes:               
*
*****************************************************************************/
VOID
MrvDrvDisableInterrupt(
    IN NDIS_HANDLE MiniportAdapterContext
    )
{
    	PMRVDRV_ADAPTER Adapter;
    
    	
    	Adapter = (PMRVDRV_ADAPTER)MiniportAdapterContext;
      //Adapter->intcc++;
    
    	DisableInterrupt(Adapter);
      
      
      //DBGPRINT(DBG_DRALEE,("INT:--\n"));
}

/******************************************************************************
*
*  Name: MrvDrvEnableInterrupt()
*
*  Description: Miniport HW interrupt enable routine
*
*  Conditions for Use: Will be called to enable HW PCI/CardBus interrupt
*
*  Arguments:
*      IN NDIS_HANDLE MiniportAdapterContext
*    
*  Return Value: None
* 
*  Notes:               
*
*****************************************************************************/
VOID
MrvDrvEnableInterrupt(
	IN NDIS_HANDLE MiniportAdapterContext
    )
{
    	PMRVDRV_ADAPTER Adapter;
    
    
   	Adapter = (PMRVDRV_ADAPTER)MiniportAdapterContext;
    
    //Adapter->intcc--; 
    //DBGPRINT(DBG_DRALEE,("INT++:0x%x\n",Adapter->intcc ));

    	EnableInterrupt(Adapter);
     

}

⌨️ 快捷键说明

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