📄 intproc.c
字号:
/******************* ?Marvell Semiconductor, Inc., 2001-2004 *****************
*
* Purpose: This module provides implementaion of ISR, DPC and other
* interrupt related routines
*
* $Author: Cuizt $
*
* $Date: 2007/03/30 08:34:20 $
*
* $Revision: 1.7 $
*
*****************************************************************************/
/*
===============================================================================
INCLUDE FILES
===============================================================================
*/
#include "precomp.h"
#include "If.h"
#ifdef UNDER_CE
#include "pkfuncs.h"
#endif
/******************************************************************************
*
* 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;
// DBGPRINT(DBG_ISR,("INT - Enter MrvDrvDisableInterrupt \n"));
Adapter = (PMRVDRV_ADAPTER)MiniportAdapterContext;
#ifdef SDIO
{
SD_API_STATUS status; // intermediate status
// Though macro names are different in below lines,
// the values defined for them are same. To avoid
// confusion, we have redefined with new names.
// See "sdio.h" for their defenitions.
//
#ifdef PWARE_SDIO_INTR_MODIFICATIONS
UCHAR ucMask = SDIO_DISABLE_INTERRUPT_MASK;
#else // old code follows
UCHAR ucMask = SDIO_ENABLE_INTERRUPT;;
#endif // PWARE_SDIO_INTR_MODIFICATIONS
status = If_WriteRegister(Adapter,
//SD_IO_WRITE ,
1, // function 1
HCR_HOST_INT_MASK_REGISTER, // reg 4
FALSE,
&ucMask,
sizeof(ucMask));
}
#else
DisableInterrupt(Adapter);
#endif //SDIO
}
/******************************************************************************
*
* 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;
// DBGPRINT(DBG_ISR,("INT - Enter MrvDrvEnbleInterrupt \n"));
Adapter = (PMRVDRV_ADAPTER)MiniportAdapterContext;
#ifdef SDIO
{
SD_API_STATUS status; // intermediate status
// Though macro names are different in below lines,
// the values defined for them are same. To avoid
// confusion, we have redefined with new names.
// See "sdio.h" for their defenitions.
//
#ifdef PWARE_SDIO_INTR_MODIFICATIONS
UCHAR ucMask = SDIO_ENABLE_INTERRUPT_MASK;
#else // old code follows
UCHAR ucMask = SDIO_DISABLE_INTERRUPT;;
#endif // PWARE_SDIO_INTR_MODIFICATIONS
status = If_WriteRegister(Adapter,
//SD_IO_WRITE ,
1, // function 1
HCR_HOST_INT_MASK_REGISTER, // reg 4
FALSE,
&ucMask,
sizeof(ucMask));
}
#else //SDIO
EnableInterrupt(Adapter);
#endif //SDIO
}
#ifdef SDIO
///////////////////////////////////////////////////////////////////////////////
// SDNdisSlotEventCallBack - slot event callback for fast-path events
// Input: hDevice - device handle
// pContext - device specific context that was registered
// SlotEventType - slot event type
// pData - Slot event data (can be NULL)
// DataLength - length of slot event data (can be 0)
// Output:
// Returns:
// Notes:
//
// If this callback is registered the client driver can be notified of
// slot events (such as device removal) using a fast path mechanism. This
// is useful if a driver must be notified of device removal
// before its XXX_Deinit is called.
//
// This callback can be called at a high thread priority and should only
// set flags or set events. This callback must not perform any
// bus requests or call any apis that can perform bus requests.
///////////////////////////////////////////////////////////////////////////////
VOID SDNdisSlotEventCallBack(SD_DEVICE_HANDLE hDevice,
PVOID pContext,
SD_SLOT_EVENT_TYPE SlotEventType,
PVOID pData,
DWORD DataLength)
{
PMRVDRV_ADAPTER pAdapter;
//BOOLEAN timerStatus;
DBGPRINT(DBG_OID,("Entered +SDNdisSlotEventCallBack: event 0x%x \n",
SlotEventType));
return;
switch (SlotEventType)
{
case SDCardEjected :
RETAILMSG(1,(TEXT("SDCardEjected Event!\n\r")));
DBGPRINT(DBG_LOAD, ("SDCardEjected Event!\n"));
pAdapter = (PMRVDRV_ADAPTER)pContext;
pAdapter->SurpriseRemoved = TRUE;
SDIODisconnectInterrupt(pAdapter->hDevice);
//pAdapter->MediaConnectStatus = NdisMediaStateDisconnected;
// mark that the card is being ejected, NDIS will shut us down soon
pAdapter->ShutDown = TRUE;
//CleanUpTimers(pAdapter);
NdisMSleep(100);
//ResetDisconnectStatus(pAdapter);
//dralee
//FreeAdapterObject(pAdapter);
// Following code has been copied from NDIS PnP
// handler function: MrvDrvPnPEventNotify() assuming that
// it is handling card-removed event properly
// We should disable bus interrupt
// DisableInterrupt(pAdapter);
// Reset Tx and command queue (Will be called again in CondorHalt())
//CleanUpSingleTxBuffer(pAdapter);
//ResetRxPDQ(pAdapter);
//ResetCmdBuffer(pAdapter);
//SDIODisconnectInterrupt(pAdapter->hDevice);
// Cancel timers
//if (pAdapter->TimerIsSet == TRUE){
// NdisMCancelTimer(&pAdapter->MrvDrvTimer, &timerStatus);
// pAdapter->TimerIsSet = FALSE;
// DBGPRINT(DBG_TIMERS, ("%s:%d: Reconnect timer is canceled\n", __FILE__, __LINE__));
//}
/*
if(pAdapter->TxPktTimerIsSet==TRUE)
{
NdisMCancelTimer(&pAdapter->MrvDrvTxPktTimer, &timerStatus);
pAdapter->TxPktTimerIsSet=FALSE;
}
if (pAdapter->CommandTimerSet)
{
NdisMCancelTimer(&pAdapter->MrvDrvCommandTimer, &timerStatus);
pAdapter->CommandTimerSet = FALSE;
}
*/
break;
}
}
#endif //SDIO
///////////////////////////////////////////////////////////////////////////////
// SDNdisInterruptCallback - interrupt handler
// Input: hDevice - handle to the SDIO device
// pAdapter - adapter context
// Output:
// Returns: SD_API_STATUS code
// Notes:
//
// SD_API_STATUS_SUCCESS is returned for HW to acknowledge the interrupt
///////////////////////////////////////////////////////////////////////////////
#ifdef SDIO
SD_API_STATUS SDNdisInterruptCallback(SD_DEVICE_HANDLE hDevice,
PVOID pContext)
#elif defined(IF_SPI)
///crlo:modify ++
///SD_API_STATUS SDNdisInterruptCallback(IN NDIS_HANDLE MiniportAdapterContext)
SD_API_STATUS SPINdisInterruptCallback(IN NDIS_HANDLE MiniportAdapterContext)
///crlo:modify --
#endif
{
PMRVDRV_ADAPTER pAdapter;
#ifdef SDIO
UCHAR ucHostIntStatus;
UCHAR ucCardStatus;
SD_API_STATUS status;
#endif ///SDIO
#ifdef IF_SPI
// WORD ucHostIntStatus;
// USHORT ucCardStatus;
// SD_API_STATUS status;
#endif
#ifdef SDIO
pAdapter = (PMRVDRV_ADAPTER)pContext;
#elif defined(IF_SPI)
pAdapter = (PMRVDRV_ADAPTER)MiniportAdapterContext;
#endif
pAdapter->ulINTCount++;
/*
if( pAdapter->ulINTCount < 5 )
{
int pri;
pri = CeGetThreadPriority(GetCurrentThread());
DbgMrvPrintFile( ("HCD thread priority: %d\n",pri) );
}
*/
DBGPRINT(DBG_ISR,("INT - SDNdisInterruptCallback(%d)\n", pAdapter->ulINTCount));
//#ifndef MRV_CHIP_8305
// pAdapter->ucGHostIntStatus=0x0;
//#endif
// tt ps chk pAdapter->dwInterruptTick = GetTickCount();
/* dralee 072905
if ( pAdapter->hISRThread == NULL )
{
pAdapter->hISRThread = GetCurrentThread();
}
*/
#if 0
EnterCriticalSection(&pAdapter->IntCriticalSection);
///#ifdef SDIO
// read Host Int Status register (function 1,addr 6)
status = If_ReadRegister(pAdapter,
//SD_IO_READ ,
1, // function 1
HCR_HOST_INT_STATUS_REGISTER,
FALSE,
&ucHostIntStatus,
sizeof(ucHostIntStatus));
if (!SD_API_SUCCESS(status))
{
DBGPRINT(DBG_ISR,("Unable to read Host interrupt status register\n"));
DBGPRINT(DBG_ISR, ("ISR read error 1\n") );
LeaveCriticalSection(&pAdapter->IntCriticalSection);
return status;
}
//EnterCriticalSection(&pAdapter->IntCriticalSection);
pAdapter->ucGHostIntStatus |= ucHostIntStatus;
//LeaveCriticalSection(&pAdapter->IntCriticalSection);
ucCardStatus = ~ucHostIntStatus;
//dralee_1226
ucCardStatus &= 0x1f;
//EnterCriticalSection(&pAdapter->SDIOCriticalSection);
status = If_WriteRegister(pAdapter,
//SD_IO_WRITE,
1,
HCR_HOST_INT_STATUS_REGISTER,
FALSE,
&ucCardStatus, // reg
sizeof(ucCardStatus));
if (!SD_API_SUCCESS(status))
{
DBGPRINT(DBG_ISR,("Unable to clear Host interrupt status register\n"));
DBGPRINT(DBG_ISR, ("ISR read error 2\n") );
LeaveCriticalSection(&pAdapter->IntCriticalSection);
return status;
}
LeaveCriticalSection(&pAdapter->IntCriticalSection);
//#ifndef MRV_CHIP_8305
// pAdapter->ucGHostIntStatus=ucHostIntStatus;
// DBGPRINT(DBG_ISR,("SDNdisInterruptCallback pAdapter->ucGHostIntStatus=%d\n",pAdapter->ucGHostIntStatus));
//#endif
#if defined (IF_SPI)
if (ucHostIntStatus == 0xffff)
#else
if ( ucHostIntStatus == 0xff )
#endif ///IF_SPI
{
// card removed?
DBGPRINT(DBG_ISR,("read 0xff\n"));
return SD_API_STATUS_SUCCESS;
}
///#endif // SDIO
/*
#ifndef MRV_CHIP_8305
if (( ucHostIntStatus & UPLOADDOWNLOAD_HOST_INT_STATUS_RDY))
{ //0x1 or 0x2 or 0x3
//lykao, 053005
//if((ucHostIntStatus== DOWNLOAD_HOST_INT_STATUS_RDY)&&(pAdapter->CurCmd))
// {//=0x2 && pAdapter->CurCmd
// return SD_API_STATUS_SUCCESS;
// }
}else
{
// no interrupt
DBGPRINT(DBG_ISR,("UpldHostIntStatus or DnLdRdy RDY bit not set\n"));
return SD_API_STATUS_SUCCESS;
}
#else
if ( !( ucHostIntStatus & UPLOAD_HOST_INT_STATUS_RDY) )
{
// no interrupt
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -