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

📄 intproc.c

📁 Windows CE 6.0 BSP for VOIP sample phone. Intel PXA270 platform.
💻 C
📖 第 1 页 / 共 2 页
字号:
//
// 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 intproc.c
 *  @This module provides implementaion of ISR, DPC and other 
 *   interrupt related routines
 *
 *  Copyright (c) Marvell Semiconductor, Inc. 
 */
 
#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;    

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

	//if (Adapter->bIsInDPC == TRUE)	
	//		return;
        
//	DisableInterrupt(Adapter); 

  	EnterCriticalSection(&Adapter->IntCriticalSection);   
    	// Read Interrupt cause register
    	usLOCAL_INTCause = 0;
    	NdisRawReadPortUshort(
       	 	Adapter->ulMrvDrvVirtualIoBase + CFMACREG_CCR_HOST_INT_CAUSE,
        		&usLOCAL_INTCause);
    
 	usLOCAL_INTCause &= CFMACREG_CCR_HIC_MASK;

     	Adapter->usINTCause |= usLOCAL_INTCause;

	// Clear the source of the interrupt
       NdisRawWritePortUshort(
       Adapter->ulMrvDrvVirtualIoBase + CFMACREG_CCR_HOST_INT_CAUSE,
       				 usLOCAL_INTCause);
  
  	DBGPRINT(DBG_SP,("ISR:usLOCAL_INTCause:\n",usLOCAL_INTCause ));
       //RETAILMSG(1, (TEXT("ISR:usLOCAL_INTCause: 0x%x\r\n "), usLOCAL_INTCause));
	//DEBUGMSG(1, (TEXT("ISR:usLOCAL_INTCause: 0x%x\r\n "), usLOCAL_INTCause));  
      
 	LeaveCriticalSection(&Adapter->IntCriticalSection);   

	// Claim the interrupt
       if ((usLOCAL_INTCause & 0xffe0) ||(usLOCAL_INTCause == 0x0000))
       {
    		*InterruptRecognized = FALSE;
    		*QueueMiniportHandleInterrupt = FALSE;

              //AllenDBGPRINT(DBG_ISR | DBG_SP,("QueueDPC = 0\n"));
		//DEBUGMSG(1, (TEXT("QueueDPC = 0\r\n")));
		//RETAILMSG(1, (TEXT("QueueDPC = 0\r\n")));
	
		EnableInterrupt(Adapter);
		return;
       }
	else
    	{
            	*InterruptRecognized = TRUE;
    		*QueueMiniportHandleInterrupt = TRUE;

		//AllenDBGPRINT(DBG_ISR | DBG_SP,("QueueDPC = 1\n"));	
		//DEBUGMSG(1, (TEXT("QueueDPC = 1\r\n")));
		//RETAILMSG(1, (TEXT("QueueDPC = 1\r\n")));	
	}

       // Add for Moto-Semco
/*       
       if ((*InterruptRecognized == TRUE) && 
          (Adapter->bIsEnterD3 == TRUE))
       {
       	*InterruptRecognized = FALSE;
    		*QueueMiniportHandleInterrupt = FALSE;
		MyDPC(Adapter);
		
              //AllenDBGPRINT(DBG_ISR | DBG_SP,("QueueDPC = 0\n"));
		//DEBUGMSG(1, (TEXT("QueueDPC = 0\r\n")));
		//RETAILMSG(1, (TEXT("QueueDPC = 0\r\n")));
       }	
*/

   	DBGPRINT(DBG_ISR,("-MrvDrvIsr\n"));
// 	RETAILMSG(1, (TEXT("MrvDrvIsr <<\r\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));
       //RETAILMSG(1, (TEXT("DPC_1: 0x%x\r\n "), Adapter->usINTCause));

	Adapter->bIsInDPC = TRUE;	
	   
#ifdef DEEP_SLEEP 

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

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

		Adapter->bIsInDPC = FALSE;	
		EnableInterrupt(Adapter);
        	return;
    	}

		
	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));  

       EnterCriticalSection(&Adapter->DpcCriticalSection);

    	// 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"));
        	}

		EnterCriticalSection(&Adapter->IntCriticalSection);   

		// Read Interrupt cause register
    		usLOCAL_INTCause = 0;
    	       NdisRawReadPortUshort(
       	   	      Adapter->ulMrvDrvVirtualIoBase + CFMACREG_CCR_HOST_INT_CAUSE,
        		      &usLOCAL_INTCause);

⌨️ 快捷键说明

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