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

📄 intproc.c

📁 marvell8385 GSPI开发驱动
💻 C
📖 第 1 页 / 共 3 页
字号:
           DBGPRINT(DBG_ISR,("Upload Host Int Status RDY bit not set\n"));
           return SD_API_STATUS_SUCCESS;
       }
   #endif 
*/
     

    //Disable further interrupts at this point
    //DisableInterrupt(pAdapter);

    // use timer to get into Miniport context
    //NdisMSetTimer(&pAdapter->MrvDrvSdioIntTimer, 0);
    //pAdapter->MrvDrvSdioIntTimerIsSet = TRUE;
    
    //#ifndef MRV_CHIP_8305
    //    DBGPRINT(DBG_ISR,("-INT - SDNdisInterruptCallback(%d)\n", pAdapter->ulINTCount));
    //#endif
    
/*          
    //dralee_1101
    if(pAdapter->RetQTimerIsSet==1)
    {
       pAdapter->RetQTimerIsSet=2;
       NdisMSetTimer(&pAdapter->MrvRetQTimer, 
                      MRVDRV_DEFAULT_RETQ_TIME_OUT);
    }  
*/
           
#endif
    SetEvent(pAdapter->hControllerInterruptEvent);
  
    return SD_API_STATUS_SUCCESS;
}

#ifdef SDIO

///////////////////////////////////////////////////////////////////////////////
//  MrvDrvSdioAsyncBusRequestCB -  handles asynchronous bus call back for
//                                 reading CMD53 from card.
//                                 It is used when the response is discarded
//                                 so it just frees up the buffer
//    
///////////////////////////////////////////////////////////////////////////////
VOID MrvDrvSdioAsyncBusRequestCB(SD_DEVICE_HANDLE hDevice,
                                 PSD_BUS_REQUEST  pRequest,
                                 PVOID            pDeviceContext,
                                 DWORD            DeviceParam)
{
    SDFreeBusRequest(pRequest);
}


#endif //SDIO

static UCHAR acEmergencyBuffer[2000];

///////////////////////////////////////////////////////////////////////////////
//  MrvSdioIstThread -  IST to get back to miniport context during
//                      interrupt
//  Input:  
//  Output: 
//  Returns:  
//  Notes:  
///////////////////////////////////////////////////////////////////////////////
void MrvSdioIstThread(PVOID pContext)
{
    #if defined(SDIO)
    UCHAR                          ucCardStatus;
    #endif ///SDIO
    USHORT                         usLength;
    DWORD waitStatus;    // wait status
#ifdef CONFIG_WLAN_PMU
    HANDLE hEvents[3];
#endif
    PMRVDRV_ADAPTER                pAdapter = (PMRVDRV_ADAPTER) pContext;
    static HostCmd_DS_CODE_DNLD    *p_pkt=NULL;
    static HostCmd_DS_CODE_DNLD      pkt;
  
#ifdef SDIO
    UCHAR                    macEvent;
#else
    WORD                     macEvent;
#endif ///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_SPI
    USHORT      ucLHostIntStatus=0;
    USHORT      ucHostIntStatus=0;
    SD_API_STATUS    status;
    #else
    UCHAR   ucLHostIntStatus=0; 
    #endif ///IF_SPI

    UCHAR   ucLCardStatus=0;
    UCHAR   ucCardStatus=0;
//    WORD dwHostIntStatus = 0;

#ifdef IF_SPI
///    int      status;
///    WORD ucHostIntStatus;
#endif

    V5DbgMsg( (L" [Marvell]++MrvSdioIstThread: pAdapter->SdioIstThread=%d\n",pAdapter->SdioIstThread) );     
    DBGPRINT(DBG_TXDATADUMP,("[Marvell:MrvSdioIstThread] pAdapter->SdioIstThread=%d\n", pAdapter->SdioIstThread));      
    //CeSetThreadPriority(GetCurrentThread(), 101);      // don't set priority higher than 101
    
    CeSetThreadPriority(GetCurrentThread(), 118); 
    {
        V5DbgMsg( (L"IstThread pri: %d\n", CeGetThreadPriority(GetCurrentThread())) );
    }
    // CeSetThreadQuantum(GetCurrentThread(), 10);
    RETAILMSG(1,(TEXT("Enter MrvSdioIstThread : \n")));
    SetEvent(pAdapter->hThreadReadyEvent);  

#ifdef CONFIG_WLAN_PMU
    hEvents[0] = pAdapter->hControllerInterruptEvent;
    hEvents[1] = pAdapter->hPowerNotify;
    hEvents[2] = pAdapter->hPMUEvent;
#endif
     
   while(1) 
   {
#ifdef CONFIG_WLAN_PMU
    waitStatus = WaitForMultipleObjects(3, hEvents, FALSE, INFINITE);
    if(waitStatus == (WAIT_OBJECT_0 + 1)) {
        wlan_PMUProcessPowerNotification(hEvents[1]);
    }
    else if(waitStatus == (WAIT_OBJECT_0 + 2))
    {
//        printf("PMU******************");
        wlan_PMUFsmEntry();
    }
    if (waitStatus != WAIT_OBJECT_0 || pAdapter->SurpriseRemoved == TRUE )
    {
        continue;
    }
#else   
     waitStatus = WaitForSingleObject(pAdapter->hControllerInterruptEvent, INFINITE);
     if (WAIT_OBJECT_0 != waitStatus)
     {
        RETAILMSG(1,(TEXT("call WaitFor SingleObject Fail : \n")));
        return;
     }
#endif
        ///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 1
#ifdef IF_SPI      
      // 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"));
        continue;
    }
    if(0x00 == ucHostIntStatus) 
    {   
        continue;
    }

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

    //#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 
    {
        // card removed?
         //NKDbgPrintfW(TEXT("[WLAN] read 0xff\r\n"));
        DBGPRINT(DBG_ISR,("read 0xff\n"));
        continue;
        //return;
    }
#endif // IF_SPI
#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)
         {          
            //RETAILMSG(1,(TEXT("MrvDrvSdioIstThread: Txdone \r\n")));
            #ifdef MRVL_PSCONFIRM 
            if(pAdapter->bPSConfirm==FALSE)
               HandleTxSingleDoneEvent(pAdapter);
            #else 
             HandleTxSingleDoneEvent(pAdapter);
            #endif //MRVL_PSCONFIRM
            GetCmdFromQueueToExecute (pAdapter);
         }
         //else
            //RETAILMSG(1,(TEXT("MrvDrvSdioIstThread: Packet is NULL \r\n")));
     }
#ifdef IF_SPI
     //////////////////////////////////////////////////////
     // 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 = gspi_read_reg16(SCRATCH_3_REG, &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 || macEvent == MACREG_INT_CODE_PS_SLEEP)
//               if(macEvent==MACREG_INT_CODE_PS_AWAKE || macEvent == MACREG_INT_CODE_HOST_SLEEP_AWAKE)
               {       
                  pAdapter->bPSConfirm=FALSE;
                  gspi_write_reg(CARD_INT_CAUSE_REG, CIC_HostEvent);
                  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)
            {   
                gspi_write_reg(CARD_INT_CAUSE_REG, CIC_RxUpLdOvr);         
                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);
//                    }
    
                    if(pRxBufVM != NULL)
                    {
                    //(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));

⌨️ 快捷键说明

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