📄 intproc.c
字号:
DWORD DeviceParam)
{
SDFreeBusRequest(pRequest);
}
#endif //IF_SDIO
///////////////////////////////////////////////////////////////////////////////
// MrvIstThread - IST to get back to miniport context during
// interrupt
// Input:
// Output:
// Returns:
// Notes:
///////////////////////////////////////////////////////////////////////////////
void MrvIstThread(PVOID pContext)
{
#if defined(IF_SDIO)
UCHAR ucCardStatus;
#endif ///IF_SDIO
USHORT usLength;
DWORD waitStatus; // wait status
PMRVDRV_ADAPTER pAdapter = (PMRVDRV_ADAPTER) pContext;
static HostCmd_DS_CODE_DNLD *p_pkt=NULL;
static HostCmd_DS_CODE_DNLD pkt;
#ifdef IF_SDIO
UCHAR macEvent;
#else
WORD macEvent;
#endif ///IF_SDIO
BOOLEAN ErrorFlag=FALSE;
//ULONG TickDiff;
//dralee -----
PNDIS_PACKET pPacket;
PVOID pRxBufVM;
UINT bufferLength;
PNDIS_BUFFER pBuffer;
MRVDRV_GET_PACKET_STATUS qStatus;
UCHAR usWrongPktLen=0;
#define TT_WRONG_PKT_LEN_TOO_BIG 1
#define TT_WRONG_PKT_LEN_TOO_SMALL 2
//--------------
#ifdef IF_GSPI
USHORT ucLHostIntStatus=0;
#else
UCHAR ucLHostIntStatus=0;
#endif ///IF_GSPI
UCHAR ucLCardStatus=0;
#ifdef IF_GSPI
/// int status;
/// WORD ucHostIntStatus;
#endif
V5DbgMsg( (L" [Marvell]++MrvIstThread: pAdapter->SdioIstThread=%d\n",pAdapter->SdioIstThread) );
DBGPRINT(DBG_TXDATADUMP,("[Marvell:MrvIstThread] pAdapter->SdioIstThread=%d\n", pAdapter->SdioIstThread));
//CeSetThreadPriority(GetCurrentThread(), 101); // don't set priority higher than 101
CeSetThreadPriority(GetCurrentThread(), pAdapter->SdioIstThread);
{
V5DbgMsg( (L"IstThread pri: %d\n", CeGetThreadPriority(GetCurrentThread())) );
}
SetEvent(pAdapter->hThreadReadyEvent);
#if 0
//dralee_20060613
RETAILMSG(1,(L"start WR timer\n\r"));
NdisMSetTimer(&pAdapter->MrvDrvIntWorkAroundTimer,
MRVDRV_DEFAULT_INT_WORKAROUND_TIMEOUT);
#endif
while(1)
{
waitStatus = WaitForSingleObject(pAdapter->hControllerInterruptEvent, INFINITE);
if (WAIT_OBJECT_0 != waitStatus)
{
//RETAILMSG(1,(TEXT("call WaitFor SingleObject Fail : \n")));
return;
}
///crlo:modify ++
///Move it to SDNdisInterruptCallback() above so that we can clean the INTR.
///Otherwise, this function can not be reached, even thought 'hControllerInterruptEvent' has been set
#if 0
#ifdef IF_GSPI
// 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"));
//NKDbgPrintfW(TEXT("Unable to read Host interrupt status register \r\n"));
return;
}
////NKDbgPrintfW(TEXT("ucHostIntStatus is %x \r\n"),ucHostIntStatus);
////NKDbgPrintfW(TEXT("[WLAN] Enter pAdapter->IntCriticalSection\r\n"));
EnterCriticalSection(&pAdapter->IntCriticalSection);
pAdapter->ucGHostIntStatus |= ucHostIntStatus;
LeaveCriticalSection(&pAdapter->IntCriticalSection);
////NKDbgPrintfW(TEXT("[WLAN] Leave pAdapter->IntCriticalSection\r\n"));
ucCardStatus = ~ucHostIntStatus;
//EnterCriticalSection(&pAdapter->SDIOCriticalSection);
status = If_WriteRegister(pAdapter,
//SD_IO_WRITE,
1,
HCR_HOST_INT_STATUS_REGISTER,
FALSE,
&ucCardStatus, // reg
sizeof(ucCardStatus));
////NKDbgPrintfW(TEXT("[WLAN] Before SD_API_SUCCESS, status is %x\r\n"),status);
if (!SD_API_SUCCESS(status))
{
//NKDbgPrintfW(TEXT("[WLAN] Unable to clear Host interrupt status register\r\n"));
DBGPRINT(DBG_ISR,("Unable to clear Host interrupt status register\n"));
return;
}
if ( (ucHostIntStatus & 0xff) == 0xff )
{
// card removed?
//NKDbgPrintfW(TEXT("[WLAN] read 0xff\r\n"));
DBGPRINT(DBG_ISR,("read 0xff\n"));
continue;
//return;
}
#endif //IF_GSPI
#endif ////0
// pAdapter->ulDPCCount++;
EnterCriticalSection(&pAdapter->IntCriticalSection);
ucLHostIntStatus = pAdapter->ucGHostIntStatus;
pAdapter->ucGHostIntStatus &= ~ucLHostIntStatus;
LeaveCriticalSection(&pAdapter->IntCriticalSection);
//#ifndef MRVL_WINCE50
//NdisAcquireSpinLock(&pAdapter->lDPCLock);
//#endif
//DBGPRINT(DBG_ISR,("+MrvDrvSdioIntTimer(%d)\n", pAdapter->ulDPCCount));
//RETAILMSG(1, (L"ulDPCCount is = %d", pAdapter->ulDPCCount));
//pAdapter->MrvDrvSdioIntTimerIsSet = FALSE;
if ( pAdapter->SurpriseRemoved == TRUE )
{
DBGPRINT(DBG_ISR,("MrvDrvSdioIntTimer: Adapter already removed!\n"));
//EnableInterrupt(pAdapter);
//#ifndef MRVL_WINCE50
//NdisFreeSpinLock(&pAdapter->lDPCLock);
//#endif
return;
}
/* dralee, 072905
if ( pAdapter->hTimerThread == NULL )
{
pAdapter->hTimerThread = GetCurrentThread();
}
*/
/////////////////////////////////////////////////////
//HostIntStatus & 0x2
if( ucLHostIntStatus & DOWNLOAD_HOST_INT_STATUS_RDY)
{
if(pAdapter->SentPacket)
{
//if(pAdapter->bPSConfirm==FALSE) //++dralee_20060327
HandleTxSingleDoneEvent(pAdapter);
}
//else
//RETAILMSG(1,(TEXT("MrvDrvSdioIstThread: Packet is NULL \r\n")));
}
#ifdef IF_GSPI
//////////////////////////////////////////////////////
// HostIntStatus &0x1 , dralee_0111
if( ucLHostIntStatus & UPLOAD_HOST_INT_STATUS_RDY )
{
IF_API_STATUS ifStatus;
//dralee_0111
if(pAdapter->bPSConfirm==TRUE)
{
if( ucLHostIntStatus & HIS_CardEvent )
{
int result,i;
macEvent = -1;
for(i=0; i<3; i++ )
{
///result = spi_ReadRegister(SCRATCH_3_REG, &macEvent);
result = If_ReadRegister(NULL, NULL, SCRATCH_3_REG, FALSE, &macEvent, sizeof(macEvent));
if( result == 0 )
break;
RETAILMSG(1,(L"Read Mac Event error, Retry..\n"));
}
if(macEvent==MACREG_INT_CODE_PS_AWAKE || macEvent == MACREG_INT_CODE_HOST_SLEEP_AWAKE)
{
USHORT regval;
pAdapter->bPSConfirm=FALSE;
///spi_WriteRegister(CARD_INT_CAUSE_REG, CIC_HostEvent);
regval = CIC_HostEvent;
If_WriteRegister(NULL, NULL, CARD_INT_CAUSE_REG, FALSE, ®val, 0);
HandleMACEvent(pAdapter,macEvent);
ucLHostIntStatus &= (~HIS_CardEvent);
}
else
RETAILMSG(1,(L"[Warning]:invalid event in ps_confirmed state:%x\n",macEvent));
}
}
if( pAdapter->bPSConfirm==FALSE)
{
//RETAILMSG(1,(TEXT("MrvDrvSdioIstThread: Packet is a UPLOAD_HOST_INT_STATUS_RDY!\n")));
ifStatus = If_GetLengthOfDataBlock( pAdapter, &usLength );
if ( !IF_IS_SUCCESS(ifStatus) )
return;
// Allocate Buffer
qStatus=GetRxPacketDesc(pAdapter, &pPacket);
if (qStatus == GPS_FAILED){
USHORT regval = CIC_RxUpLdOvr;
///spi_WriteRegister(CARD_INT_CAUSE_REG, CIC_RxUpLdOvr);
If_WriteRegister(NULL, NULL, CARD_INT_CAUSE_REG, FALSE, ®val, 0);
RETAILMSG(1,(TEXT("GetRxPacketDesc Fail, drop rx pkt\n")));
}
else //GPS_FAILED
{
// check size
//lykao, 052405, begin
if ( usLength > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE )
{
usLength=MRVDRV_ETH_RX_PACKET_BUFFER_SIZE;
}
if ( usLength < sizeof(RxPD)+14 )
{
usLength = sizeof(RxPD)+14;
}
if(usLength & 0x0001)
usLength++;
pAdapter->pRxCurPkt = pPacket;
NdisQueryPacket(pPacket, NULL, NULL, &pBuffer, NULL);
////NKDbgPrintfW(TEXT("WLAN: [1] pBuffer is %x \n"),pBuffer);
NdisQueryBufferSafe(pBuffer, &pRxBufVM, &bufferLength, HighPagePriority);
////NKDbgPrintfW(TEXT("WLAN: [2] pBuffer is %x \n"),pBuffer);
if(pRxBufVM == NULL)
{
NdisMSleep(5);
NdisQueryBufferSafe(pBuffer, &pRxBufVM, &bufferLength, HighPagePriority);
////NKDbgPrintfW(TEXT("WLAN: [3] pBuffer is %x \n"),pBuffer);
////NKDbgPrintfW(TEXT("WLAN: [3] pRxBufVM is %x \n"),pRxBufVM);
}
//(ULONG)pRxBufVM -= (sizeof(RxPD)+sizeof(pkt.Len)+sizeof(pkt.Type));
//NdisAdjustBufferLength(pBuffer, (usLength-(sizeof(RxPD)+sizeof(pkt.Len)+sizeof(pkt.Type))));
//NdisAdjustBufferLength(pBuffer, (usLength-MRVDRV_ETH_RX_HIDDEN_HEADER_SIZE));
////NKDbgPrintfW(TEXT("WLAN: [1] pBuffer is %x \n"),pBuffer);
////NKDbgPrintfW(TEXT("WLAN: usLength is %x \n"),usLength);
NdisAdjustBufferLength(pBuffer, (usLength-MRVDRV_ETH_RX_HIDDEN_HEADER_SIZE + 4));
////NKDbgPrintfW(TEXT("WLAN: [2] pBuffer is %x \n"),pBuffer);
//p_pkt = (PHostCmd_DS_CODE_DNLD)((ULONG)pRxBufVM - (sizeof(RxPD)+sizeof(pkt.Len)+sizeof(pkt.Type)));
//p_pkt = (PHostCmd_DS_CODE_DNLD)((ULONG)pRxBufVM - MRVDRV_ETH_RX_HIDDEN_HEADER_SIZE + sizeof(pkt.Len) + sizeof(pkt.Type));
////NKDbgPrintfW(TEXT("WLAN: pRxBufVM is %x \n"),pRxBufVM);
p_pkt = (PHostCmd_DS_CODE_DNLD)((ULONG)pRxBufVM - MRVDRV_ETH_RX_HIDDEN_HEADER_SIZE);
//p_pkt = (PHostCmd_DS_CODE_DNLD)pRxBufVM;
pAdapter->pRxPD1 = (PRxPD)p_pkt->Code;
//pAdapter->pRxPD1 = (PRxPD)pkt.Code;
////NKDbgPrintfW(TEXT("WLAN: pRxBufVM is %x \n"),pRxBufVM);
////NKDbgPrintfW(TEXT("WLAN: pAdapter->pRxCurPkt is %x \n"),pAdapter->pRxCurPkt);
////NKDbgPrintfW(TEXT("WLAN: pAdapter->pRxPD1 is %x \n"),pAdapter->pRxPD1);
///gspi_read_data_direct((unsigned char*)p_pkt->Code, DATA_RDWRPORT_REG, (usLength/2));
If_GetDataBlock(pAdapter, (usLength/2), IF_DATA_PKT, (unsigned char*)p_pkt->Code);
{
USHORT regval = CIC_RxUpLdOvr;
///spi_WriteRegister(CARD_INT_CAUSE_REG, CIC_RxUpLdOvr);
If_WriteRegister(NULL, NULL, CARD_INT_CAUSE_REG, FALSE, ®val, 0);
}
// length of the packet content itself
//usLength = usLength - sizeof(pkt.Type) - sizeof(pkt.Len);
#ifdef WPA
if((*((UCHAR *)((ULONG)pRxBufVM + 14)) == 0xaa ) &&
(*((UCHAR *)((ULONG)pRxBufVM + 15)) == 0xaa ) &&
(*((UCHAR *)((ULONG)pRxBufVM + 16)) == 0x03 ) &&
(*((UCHAR *)((ULONG)pRxBufVM + 20)) == 0x88 ) &&
(*((UCHAR *)((ULONG)pRxBufVM + 21)) == 0x8e ) )
{
//RETAILMSG(1,(TEXT("EAPOL Key: Packet is a Rx DATA! \r\n")));
usLength -= 8;
//NdisMoveMemory( ttBuf, pAdapter->pRxBuf+20, pAdapter->ulRxSize-20);
NdisMoveMemory((PUCHAR)((ULONG)pRxBufVM + 12),(PUCHAR)((ULONG)pRxBufVM + 20), (usLength-20));
//NdisMoveMemory( pAdapter->pRxBuf+12, pAdapter->pRxBuf+20, pAdapter->ulRxSize-20);
}
#endif // WPA
//dralee 072705
//pAdapter->ulRxSize = usLength;
pAdapter->ulRxSize = usLength-sizeof(RxPD);
//NdisMoveMemory(pRxBufVM,pkt.Code + sizeof(RxPD), pAdapter->ulRxSize);
//#ifdef MRVL_PSCONFIRM
//if(pAdapter->bPSConfirm==FALSE)
HandleRxReadyEvent(pAdapter);
//else if(pAdapter->bPSConfirm==TRUE)
//{
///Old implementation
#if 0
#ifdef MRVL_PSCONFIRM
if(pAdapter->bPSConfirm==FALSE)
HandleRxReadyEvent(pAdapter);
else if(pAdapter->bPSConfirm==TRUE)
{
//RETAILMSG(1,(TEXT("[Marvell]MrvDrvSdioIntTimerHandler: Error => Receive RxReadyEvent()")));
//NKDbgPrintfW(TEXT("[Marvell]MrvDrvSdioIntTimerHandler: Error => Receive RxReadyEvent()"));
}
#else
HandleRxReadyEvent(pAdapter);
#endif // MRVL_PSCONFIRM
#endif ///0
} //GPS_FAILED
}
else
{
USHORT regval = CIC_RxUpLdOvr;
///spi_WriteRegister(CARD_INT_CAUSE_REG, CIC_RxUpLdOvr);
If_WriteRegister(NULL, NULL, CARD_INT_CAUSE_REG, FALSE, ®val, 0);
RETAILMSG(1,(L"error: UPLOAD_RDY in ps_confimed state,evt=%x\n",ucLHostIntStatus));
}
} //if( ucLHostIntStatus & UPLOAD_HOST_INT_STATUS_RDY )
if( ucLHostIntStatus & HIS_CmdUpLdRdy )
{
if(pAdapter->CurCmd)
{
// Command finished
// IF_API_STATUS ifStatus;
///spi_ReadRegister(SCRATCH_2_REG, &usLength);
If_ReadRegister(NULL, NULL, SCRATCH_2_REG, FALSE, &usLength, sizeof(usLength));
//RETAILMSG(1,(TEXT("MrvDrvSdioIstThread: Packet is a UPLOAD_HOST_INT_STATUS_RDY!\n")));
//ifStatus = If_GetLengthOfDataBlock( pAdapter, &usLength );
// if ( !IF_IS_SUCCESS(ifStatus) )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -