TI_STATUS TWD_Debug (TI_HANDLE hTWD, TI_UINT32 funcType, void *pParam)
{
    TTwd *pTWD			= (TTwd *)hTWD;    
    TI_UINT32 GenericVal;
    TFwDebugParams* pMemDebug	= (TFwDebugParams*)pParam;

    static TI_UINT32 GenericAddr;
#ifdef REPORT_LOG
    static int    iStart[100]; /* Note: it is not used properly anyway */
#endif
	/* check paramemters validity */
	if (pMemDebug == NULL)
	{
		WLAN_OS_REPORT(("TWD_Debug: Error - pParam is NULL\n"));
		return TI_NOK;
	}

    switch (funcType)
    {
	case TWD_PRINT_SYS_INFO:
		WLAN_OS_REPORT(("PLATFORM = TNETW125x\n"));
		WLAN_OS_REPORT(("ACCESS MODE = SLAVE\n"));
		break;

	case TWD_SET_GENERIC_ADDR:
		/* check paramemters validity */
		if (pParam == NULL)
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_SET_GENERIC_ADDR Error: No Perameter received\n"));		
			return TI_NOK;
		}
		GenericAddr = *(TI_UINT32 *)pParam;
        break;

	case TWD_READ_MEM:
        WLAN_OS_REPORT(("TWD_Debug, TWD_READ_MEM, Addr:	0x%X\n", pMemDebug->addr));				

		/* check paramemters validity */
		if (pMemDebug == NULL)
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_READ_MEM Error: No Perameters received\n"));		
			return TI_NOK;
		}
  
		/* validate length */
		*(TI_UINT32*)&pMemDebug->length = 4;		

		/* If Address in valid Memory area and there is enough space for Length to R/W */
		if (TWD_isValidMemoryAddr(hTWD, pMemDebug) == TI_TRUE)
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_READ_MEM: Reading Valid memory Address\n"));		

			/* Init buf before reading */
			os_memorySet(pTWD->hOs, (void*)pMemDebug->UBuf.buf8, 0, 4);
			if ( TWD_readMem (hTWD, pMemDebug, NULL, NULL) != TI_OK )
			{
				WLAN_OS_REPORT(("TWD_Debug, read memory failed\n"));	
				return TI_NOK;
			}
		}

		else if (TWD_isValidRegAddr(hTWD, pMemDebug) == TI_TRUE)
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_READ_MEM: Reading Valid register Address\n"));		

			/* Init buf before reading */
			*(TI_UINT32*)&pMemDebug->UBuf.buf32 = 0;

			if ( TWD_readMem (hTWD, pMemDebug, NULL, NULL) != TI_OK )
			{
				WLAN_OS_REPORT(("TWD_Debug, read register failed\n"));	
				return TI_NOK;
			}

		}

		/* address Not in valid Area */ 
		else
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_READ_MEM Address is not Valid\n"));		
			return TI_NOK;
		}

		/* print read memory */
		{

			WLAN_OS_REPORT(("Read from MEM Addr 0x%x the following values:\n", ((TFwDebugParams*)pMemDebug)->addr));

			WLAN_OS_REPORT(("0x%X	",((TFwDebugParams*)pMemDebug)->UBuf.buf32[0]));
			WLAN_OS_REPORT(("\n"));
		}

		break;

	case TWD_WRITE_MEM:
        WLAN_OS_REPORT(("TWD_Debug, TWD_WRITE_MEM, Addr:	0x%X\n", pMemDebug->addr));				

		/* check paramemters validity */
		if (pMemDebug == NULL)
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_WRITE_MEM Error: No Perameters received\n"));				
			return TI_NOK;
		}

		/* validate length */
		*(TI_UINT32*)&pMemDebug->length = 4;		

		/* If Address in valid Memory area and there is enough space for Length to R/W */
		if (TWD_isValidMemoryAddr(hTWD, pMemDebug) == TI_TRUE)
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_WRITE_MEM:	Writing Valid memory Address\n"));		


			return ( TWD_writeMem (hTWD, pMemDebug, NULL, NULL) );
		}
		
		else if (TWD_isValidRegAddr(hTWD, pMemDebug) == TI_TRUE)
		{

			WLAN_OS_REPORT(("TWD_Debug, TWD_WRITE_MEM: Writing Valid register Address\n"));		

			return ( TWD_writeMem (hTWD, pMemDebug, NULL, NULL) );
		}
		/* address Not in valid Area */ 

		else
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_WRITE_MEM Address is not Valid\n"));		
			return TI_NOK;
		}

		break;

         /*  HAL Control functions */

	case TWD_PRINT_MBOX_QUEUE_INFO:
		cmdQueue_Print (pTWD->hCmdQueue);         
        break;
            
	case TWD_PRINT_MBOX_PRINT_CMD:
		/* check paramemters validity */
		if (pParam == NULL)
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_PRINT_MBOX_PRINT_CMD Error: No Perameter received\n"));				
			return TI_NOK;
		}
		cmdQueue_PrintHistory (pTWD->hCmdQueue, *(int *)pParam);            
        break;

	case TWD_PRINT_EVENT_MBOX_INFO:
		eventMbox_Print (pTWD->hEventMbox);         
        break;
        
	case TWD_PRINT_EVENT_MBOX_MASK:
		/* check paramemters validity */
		if (pParam == NULL)
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_PRINT_EVENT_MBOX_MASK Error: No Perameter received\n"));				
			return TI_NOK;
		}
		if ( eventMbox_MaskEvent (pTWD->hEventMbox, *(int *)pParam, NULL, NULL) == TI_NOK )
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_PRINT_EVENT_MBOX_MASK Error: eventMbox_EvMask failed\n"));				
			return(TI_NOK);
		}
        break;
        
	case TWD_PRINT_EVENT_MBOX_UNMASK:
		/* check paramemters validity */
		if (pParam == NULL)
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_PRINT_EVENT_MBOX_UNMASK Error: No Perameter received\n"));				
			return TI_NOK;
		}
		if ( eventMbox_UnMaskEvent (pTWD->hEventMbox, *(int *)pParam, NULL, NULL) == TI_NOK )
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_PRINT_EVENT_MBOX_UNMASK Error: eventMbox_EvUnMask failed\n"));				
			return(TI_NOK);
		}
        break;

	case TWD_PRINT_ISTART:
		{
			int i;
            for (i=0; i<20; i+=4)
            {
				WLAN_OS_REPORT(("%4d: %08d %08d %08d %08d\n", 
								i, iStart[i+0], iStart[i+1], iStart[i+2], iStart[i+3]));
			}
		}
        break;

	case TWD_PRINT_LIST_REGS_THROG_MBOX:
		{
			int i;
            TI_UINT32 RegAddr;
    
			RegAddr = *(TI_UINT32 *)pParam;
			WLAN_OS_REPORT (("PrintListRegsThroughMbox ---------------------\n"));
    
			for (i = 0; i < 8; i++, RegAddr += 16)
            {
				TWD_PrintMemRegs (hTWD, RegAddr +  0, 4, TNETW_MAC_REGISTERS);
                TWD_PrintMemRegs (hTWD, RegAddr +  4, 4, TNETW_MAC_REGISTERS);
				TWD_PrintMemRegs (hTWD, RegAddr +  8, 4, TNETW_MAC_REGISTERS);
				TWD_PrintMemRegs (hTWD, RegAddr + 12, 4, TNETW_MAC_REGISTERS);
			}
		}
        break;
    
	case TWD_PRINT_LIST_MEM_THROG_MBOX:
		/* check paramemters validity */
		if (pParam == NULL)
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_PRINT_LIST_MEM_THROG_MBOX Error: No Perameter received\n"));				
			return TI_NOK;
		}
		TWD_PrintMemRegs (hTWD, *(TI_UINT32*)pParam, 256, TNETW_INTERNAL_RAM);
        break;
                  
	case TWD_SET_MAC_CLOCK:
		/* check paramemters validity */
		if (pParam == NULL)
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_SET_MAC_CLOCK Error: No Perameter received\n"));				
			return TI_NOK;
		}

		GenericVal = *(TI_UINT32*)pParam;
        TWD_CfgMacClock (hTWD, GenericVal);
        break;

#if defined(TNETW1150)
	case TWD_SET_ARM_CLOCK:
		/* check paramemters validity */
		if (pParam == NULL)
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_SET_ARM_CLOCK Error: No Perameter received\n"));				
			return TI_NOK;
		}

		GenericVal = *(TI_UINT32*)pParam;
        TWD_ArmClockSet (hTWD, GenericVal);
        break;
#endif

	/*
    * Rx functions 
    */
#ifdef TI_DBG
    case TWD_PRINT_RX_INFO:
		rxXfer_PrintStats (pTWD->hRxXfer);  
        break;

	case TWD_CLEAR_RX_INFO:
		rxXfer_ClearStats (pTWD->hRxXfer);  
        break;

#endif /* TI_DBG */

	/*
    * Acx functions 
    */
    case TWD_PRINT_ACX_MAP:
		TWD_PrintMemoryMap (hTWD);           
        break;
            
	case TWD_PRINT_ACX_STAT:
		TWD_ItrStatistics (hTWD, (void*)TWD_StatisticsReadCB, hTWD, (void *)&pTWD->acxStatistic);          
        break;
            			
	/*
	* General functions 
    */
    case TWD_PRINT_HELP:

		WLAN_OS_REPORT(("Registers: \n"));
        WLAN_OS_REPORT(("        %02d - TWD_PRINT_SYS_INFO \n\n", TWD_PRINT_SYS_INFO));
        WLAN_OS_REPORT(("        %02d - TWD_SET_GENERIC_ADDR \n", TWD_SET_GENERIC_ADDR));
		WLAN_OS_REPORT(("        %02d - TWD_READ_REG_OR_4_BYTES_MEM <addr (reg base=0x300000, mem base=0x40000)>\n", TWD_READ_MEM));
		WLAN_OS_REPORT(("        %02d - TWD_WRITE_REG_OR_4_BYTES_MEM <addr (reg base=0x300000, mem base=0x40000)> <val (chars<=4)>\n", TWD_WRITE_MEM));

        WLAN_OS_REPORT(("Control: \n"));
        WLAN_OS_REPORT(("        %02d - TWD_PRINT_MBOX_QUEUE_INFO \n",TWD_PRINT_MBOX_QUEUE_INFO));
        WLAN_OS_REPORT(("        %02d - TWD_PRINT_MBOX_QUEUE_PRINT_CMD \n",TWD_PRINT_MBOX_PRINT_CMD));
        WLAN_OS_REPORT(("        %02d - TWD_MAILBOX_HISTORY_PRINT \n", TWD_MAILBOX_HISTORY_PRINT));
        WLAN_OS_REPORT(("        %02d - TWD_MAC_REG \n", TWD_MAC_REG));
        WLAN_OS_REPORT(("        %02d - TWD_SET_ARM_CLOCK \n", TWD_SET_ARM_CLOCK));
        WLAN_OS_REPORT(("        %02d - TWD_SET_MAC_CLOCK \n", TWD_SET_MAC_CLOCK));

        WLAN_OS_REPORT(("Rx: \n"));
        WLAN_OS_REPORT(("        %02d - TWD_PRINT_RX_INFO \n", TWD_PRINT_RX_INFO));
        WLAN_OS_REPORT(("        %02d - TWD_CLEAR_RX_INFO \n", TWD_CLEAR_RX_INFO));

        WLAN_OS_REPORT(("ACX: \n"));
        WLAN_OS_REPORT(("        %02d - TWD_PRINT_ACX_MAP \n", TWD_PRINT_ACX_MAP));
		WLAN_OS_REPORT(("        %02d - TWD_PRINT_ACX_STAT \n", TWD_PRINT_ACX_STAT));

        WLAN_OS_REPORT(("General: \n")); 
        WLAN_OS_REPORT(("        %02d - TWD_PRINT_LIST_REGS_THROG_MBOX \n",  TWD_PRINT_LIST_REGS_THROG_MBOX));
        WLAN_OS_REPORT(("        %02d - TWD_PRINT_LIST_MEM_THROG_MBOX \n",  TWD_PRINT_LIST_MEM_THROG_MBOX));
            
        WLAN_OS_REPORT(("Recovery: \n")); 
        WLAN_OS_REPORT(("        %02d - TWD_CHECK_HW \n", TWD_CHECK_HW));
        WLAN_OS_REPORT(("        %02d - TWD_PRINT_HW_STATUS \n", TWD_PRINT_HW_STATUS));

		WLAN_OS_REPORT(("Event Mail Box: \n"));
        WLAN_OS_REPORT(("        %02d - PRINT EVENT MBOX INFO \n",  TWD_PRINT_EVENT_MBOX_INFO));
        WLAN_OS_REPORT(("        %02d - PRINT EVENT MBOX MASK \n",  TWD_PRINT_EVENT_MBOX_MASK));
        WLAN_OS_REPORT(("        %02d - PRINT EVENT MBOX UNMASK \n",TWD_PRINT_EVENT_MBOX_UNMASK));

		WLAN_OS_REPORT(("Other: \n"));
        WLAN_OS_REPORT(("        %02d - TWD_PRINT_FW_EVENT_INFO \n",  TWD_PRINT_FW_EVENT_INFO));
        WLAN_OS_REPORT(("        %02d - TWD_PRINT_TW_IF_INFO \n",  TWD_PRINT_TW_IF_INFO));
        WLAN_OS_REPORT(("        %02d - TWD_PRINT_MBOX_INFO \n",  TWD_PRINT_MBOX_INFO));
        WLAN_OS_REPORT(("        %02d - TWD_FORCE_TEMPLATES_RATES \n",  TWD_FORCE_TEMPLATES_RATES));
        break;
       
	case TWD_PRINT_FW_EVENT_INFO:
        fwEvent_PrintStat(pTWD->hFwEvent);
        break;
	case TWD_PRINT_TW_IF_INFO:
        twIf_PrintQueues(pTWD->hTwIf);
        break;
	case TWD_PRINT_MBOX_INFO:
        cmdMbox_PrintInfo(pTWD->hCmdMbox);
        break;

    /*
    * Recovery functions 
    */       
	case TWD_CHECK_HW:
		{
			int Stt;

            Stt = TWD_CmdHealthCheck (hTWD);
            WLAN_OS_REPORT(("CheckHwStatus=%d \n", Stt));
		}
        break;

	case TWD_MAILBOX_HISTORY_PRINT:
		WLAN_OS_REPORT (("PrintMailBoxHistory called \n"));
#ifdef TI_DBG
		/* check paramemters validity */
		if (pParam == NULL)
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_MAILBOX_HISTORY_PRINT Error: No Perameter received\n"));				
			return TI_NOK;
		}

        cmdQueue_PrintHistory (pTWD->hCmdQueue, *(int *)pParam);
#endif
        break;

	case TWD_FORCE_TEMPLATES_RATES:
		if (pParam == NULL)
		{
			WLAN_OS_REPORT(("TWD_Debug, TWD_FORCE_TEMPLATES_RATES Error: No Perameter received\n"));		
			return TI_NOK;
		}
		cmdBld_DbgForceTemplatesRates (pTWD->hCmdBld, *(TI_UINT32 *)pParam);
        break;


	default:
		WLAN_OS_REPORT (("Invalid function type=%d\n\n", funcType));
        break;

	} /* switch (funcType) */

    return TI_OK;
} 
Esempio n. 2
0
TI_STATUS TWD_Debug (TI_HANDLE hTWD, TI_UINT32 funcType, void *pParam)
{
    TTwd *pTWD 					= (TTwd *)hTWD;    
    TI_UINT32 GenericVal;
	TFwDebugParams* pMemDebug	= (TFwDebugParams*)pParam;

    static TI_UINT32 GenericAddr;

	/* check paramemters validity */
	if (pMemDebug == NULL)
	{	
		return TI_NOK;
	}

    switch (funcType)
    {
	case TWD_PRINT_SYS_INFO:
		break;

	case TWD_SET_GENERIC_ADDR:
		/* check paramemters validity */
		if (pParam == NULL)
		{	
			return TI_NOK;
		}
		GenericAddr = *(TI_UINT32 *)pParam;
        break;

	case TWD_READ_MEM:		

		/* check paramemters validity */
		if (pMemDebug == NULL)
		{
			return TI_NOK;
		}
  
		/* validate length */
		*(TI_UINT32*)&pMemDebug->length = 4;		

		/* If Address in valid Memory area and there is enough space for Length to R/W */
		if (TWD_isValidMemoryAddr(hTWD, pMemDebug) == TI_TRUE)
		{		

			/* Init buf before reading */
			os_memorySet(pTWD->hOs, (void*)pMemDebug->UBuf.buf8, 0, 4);
			if ( TWD_readMem (hTWD, pMemDebug, NULL, NULL) != TI_OK )
			{
				return TI_NOK;
			}
		}

		else if (TWD_isValidRegAddr(hTWD, pMemDebug) == TI_TRUE)
		{
			/* Init buf before reading */
			*(TI_UINT32*)&pMemDebug->UBuf.buf32 = 0;

			if ( TWD_readMem (hTWD, pMemDebug, NULL, NULL) != TI_OK )
			{
				return TI_NOK;
			}

		}

		/* address Not in valid Area */ 
		else
		{	
			return TI_NOK;
		}

		/* print read memory */
		{
		}

		break;

	case TWD_WRITE_MEM:		

		/* check paramemters validity */
		if (pMemDebug == NULL)
		{			
			return TI_NOK;
		}

		/* validate length */
		*(TI_UINT32*)&pMemDebug->length = 4;		

		/* If Address in valid Memory area and there is enough space for Length to R/W */
		if (TWD_isValidMemoryAddr(hTWD, pMemDebug) == TI_TRUE)
		{
			return ( TWD_writeMem (hTWD, pMemDebug, NULL, NULL) );
		}
		
		else if (TWD_isValidRegAddr(hTWD, pMemDebug) == TI_TRUE)
		{		
			return ( TWD_writeMem (hTWD, pMemDebug, NULL, NULL) );
		}
		/* address Not in valid Area */ 

		else
		{
			return TI_NOK;
		}

		break;

         /*  HAL Control functions */

	case TWD_PRINT_MBOX_QUEUE_INFO:
		cmdQueue_Print (pTWD->hCmdQueue);         
        break;
            
	case TWD_PRINT_MBOX_PRINT_CMD:
		/* check paramemters validity */
		if (pParam == NULL)
		{			
			return TI_NOK;
		}
		cmdQueue_PrintHistory (pTWD->hCmdQueue, *(int *)pParam);            
        break;

	case TWD_PRINT_EVENT_MBOX_INFO:
		eventMbox_Print (pTWD->hEventMbox);         
        break;
        
	case TWD_PRINT_EVENT_MBOX_MASK:
		/* check paramemters validity */
		if (pParam == NULL)
		{		
			return TI_NOK;
		}
		if ( eventMbox_MaskEvent (pTWD->hEventMbox, *(int *)pParam, NULL, NULL) == TI_NOK )
		{
			return(TI_NOK);
		}
        break;
        
	case TWD_PRINT_EVENT_MBOX_UNMASK:
		/* check paramemters validity */
		if (pParam == NULL)
		{
			return TI_NOK;
		}
		if ( eventMbox_UnMaskEvent (pTWD->hEventMbox, *(int *)pParam, NULL, NULL) == TI_NOK )
		{	
			return(TI_NOK);
		}
        break;

	case TWD_PRINT_ISTART:
		{
		}
        break;

	case TWD_PRINT_LIST_REGS_THROG_MBOX:
		{
			int i;
            TI_UINT32 RegAddr;
    
			RegAddr = *(TI_UINT32 *)pParam;
    
			for (i = 0; i < 8; i++, RegAddr += 16)
            {
				TWD_PrintMemRegs (hTWD, RegAddr +  0, 4, TNETW_MAC_REGISTERS);
                TWD_PrintMemRegs (hTWD, RegAddr +  4, 4, TNETW_MAC_REGISTERS);
				TWD_PrintMemRegs (hTWD, RegAddr +  8, 4, TNETW_MAC_REGISTERS);
				TWD_PrintMemRegs (hTWD, RegAddr + 12, 4, TNETW_MAC_REGISTERS);
			}
		}
        break;
    
	case TWD_PRINT_LIST_MEM_THROG_MBOX:
		/* check paramemters validity */
		if (pParam == NULL)
		{			
			return TI_NOK;
		}
		TWD_PrintMemRegs (hTWD, *(TI_UINT32*)pParam, 256, TNETW_INTERNAL_RAM);
        break;
                  
	case TWD_SET_MAC_CLOCK:
		/* check paramemters validity */
		if (pParam == NULL)
		{		
			return TI_NOK;
		}

		GenericVal = *(TI_UINT32*)pParam;
        TWD_CfgMacClock (hTWD, GenericVal);
        break;

#if defined(TNETW1150)
	case TWD_SET_ARM_CLOCK:
		/* check paramemters validity */
		if (pParam == NULL)
		{			
			return TI_NOK;
		}

		GenericVal = *(TI_UINT32*)pParam;
        TWD_ArmClockSet (hTWD, GenericVal);
        break;
#endif

	/*
    * Rx functions 
    */
#ifdef TI_DBG
    case TWD_PRINT_RX_INFO:
		rxXfer_PrintStats (pTWD->hRxXfer);  
        break;

	case TWD_CLEAR_RX_INFO:
		rxXfer_ClearStats (pTWD->hRxXfer);  
        break;

#endif /* TI_DBG */

	/*
    * Acx functions 
    */
    case TWD_PRINT_ACX_MAP:
		TWD_PrintMemoryMap (hTWD);           
        break;
            
	case TWD_PRINT_ACX_STAT:
		TWD_ItrStatistics (hTWD, (void*)TWD_StatisticsReadCB, hTWD, (void *)&pTWD->acxStatistic);          
        break;
            			
	/*
	* General functions 
    */
    case TWD_PRINT_HELP:

        break;
       
	case TWD_PRINT_FW_EVENT_INFO:
        fwEvent_PrintStat(pTWD->hFwEvent);
        break;
	case TWD_PRINT_TW_IF_INFO:
        twIf_PrintQueues(pTWD->hTwIf);
        break;
	case TWD_PRINT_MBOX_INFO:
        cmdMbox_PrintInfo(pTWD->hCmdMbox);
        break;

    /*
    * Recovery functions 
    */       
	case TWD_CHECK_HW:
		{
			int Stt;

            Stt = TWD_CmdHealthCheck (hTWD);
		}
        break;

	case TWD_MAILBOX_HISTORY_PRINT:
#ifdef TI_DBG
		/* check paramemters validity */
		if (pParam == NULL)
		{		
			return TI_NOK;
		}

        cmdQueue_PrintHistory (pTWD->hCmdQueue, *(int *)pParam);
#endif
        break;

	case TWD_FORCE_TEMPLATES_RATES:
		if (pParam == NULL)
		{
			return TI_NOK;
		}
		cmdBld_DbgForceTemplatesRates (pTWD->hCmdBld, *(TI_UINT32 *)pParam);
        break;


	default:
        break;

	} /* switch (funcType) */

    return TI_OK;
}