Exemple #1
0
/********************************************************************************
//FUNCTION:
//		FT_DispatchMessage
//DESCRIPTION:
//		this function is called to switch the testcase, del the header of peer buf.
//
//PARAMETERS:
//		Local_buf:	[IN]	local buf (cnf cmd)
//		Local_len: 	[IN]	local buf size
//		pPeerBuf		[IN]	peer buff
//		Peer_len:		[IN]	peer buff size
//RETURN VALUE:
//		TRUE is success, otherwise is fail
//
//DEPENDENCY:
//		the FT module must have been loaded.
//
//GLOBALS AFFECTED
//		None
********************************************************************************/
void FT_DispatchMessage(void *pLocalBuf, void *pPeerBuf, int local_len, int peer_len)
{
    FT_H  *ft_header;
    ft_header =(FT_H *)pLocalBuf;
    kal_int16 ft_peer_len = peer_len -8;	//del the size of peer buf header
    char *pft_PeerBuf = (char *)pPeerBuf;
    
    pft_PeerBuf += 8; // skip the header of peer buffer
    
    FT_LOG("[FTT_Drv:] FTMainThread ID : %d ", ft_header->id);
    
    switch (ft_header->id)
    {
        case FT_IS_ALIVE_REQ_ID:				//test alive
            FT_TestAlive((FT_IS_ALIVE_REQ *)pLocalBuf);
            break;
        #ifdef FT_WIFI_FEATURE
        case FT_WIFI_REQ_ID:					//wifi test
            FT_WIFI_OP((FT_WM_WIFI_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        #endif
        case FT_SDCARD_REQ_ID:                  //sdcard test
            FT_SDcard_OP((SDCARD_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_NVRAM_READ_REQ_ID:				//nvram read
            FT_APEditorRead_OP((FT_AP_Editor_read_req *)pLocalBuf);
            break;
        case FT_NVRAM_WRITE_REQ_ID:				//nvram write
            FT_APEditorWrite_OP((FT_AP_Editor_write_req *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_NVRAM_RESET_REQ_ID:				//nvram reset
            FT_APEditorReset_OP((FT_AP_Editor_reset_req *)pLocalBuf);
            break;
        case FT_GPIO_REQ_ID:
            FT_GPIO_OP((GPIO_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_VER_INFO_REQ_ID:				//get version info
            FT_GetVersionInfo((FT_VER_INFO_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        /*
        case FT_CHECK_META_VER_REQ_ID:			//require meta dll version
            FT_CheckMetaDllVersion((FT_CHECK_META_VER_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        */
        case FT_POWER_OFF_REQ_ID:				//power off target
            FT_PowerOff((FT_POWER_OFF_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_REG_WRITE_ID:					//baseband reg wirte
            FT_CPURegW_OP((FT_REG_WRITE_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_REG_READ_ID:					//baseband reg read
            FT_CPURegR_OP((FT_REG_READ_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_CCT_REQ_ID:
            FT_CCAP_OP((FT_CCT_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_UTILITY_COMMAND_REQ_ID:			//utility command
            FT_Peripheral_OP((FT_UTILITY_COMMAND_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_PMIC_REG_READ_ID:				//pmic read
            FT_PMICRegR_OP((FT_PMIC_REG_READ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_PMIC_REG_WRITE_ID:				//pmic write
            FT_PMICRegW_OP((FT_PMIC_REG_WRITE *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
    #ifdef FT_BT_FEATURE 
        case FT_BT_REQ_ID:						//bt test
            FT_BT_OP((BT_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
	#endif
        /*
        case FT_WM_DVB_REQ_ID:					//dvb test
            FT_DVBT_OP((FT_DVB_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_WM_BAT_REQ_ID:
            FT_BAT_OP((FT_BATT_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        */
        case FT_ADC_GETMEADATA_ID:				//adc test
            FT_AUXADC_OP((AUXADC_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
	#ifdef FT_GPS_FEATURE		
        case FT_GPS_REQ_ID:
            FT_GPS_OP((GPS_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
    #endif
        case FT_BATT_READ_INFO_REQ_ID:
            FT_BAT_FW_OP((FT_BATT_READ_INFO_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_BAT_CHIPUPDATE_REQ_ID:
            FT_BAT_ChipUpdate_OP((FT_BATT_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
	#ifdef FT_FM_FEATURE 	
        case FT_FM_REQ_ID:
            FT_FM_OP((FM_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
	#endif
        case FT_L4AUD_REQ_ID:
            FT_L4AUDIO_OP((FT_L4AUD_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_LOW_POWER_REQ_ID:
            FT_LOW_POWER_OP((FT_LOW_POWER_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_NVRAM_BACKUP_REQ_ID:
            FT_NVRAM_Backup_OP((FT_NVRAM_BACKUP_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_NVRAM_RESTORE_REQ_ID:
            FT_NVRAM_Restore_OP((FT_NVRAM_RESTORE_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_GSENSOR_REQ_ID:
            FT_GSENSOR_OP((GS_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_MATV_CMD_REQ_ID:
        #ifdef FT_MATV_FEATURE		
            FT_MATV_OP((FT_MATV_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
		#else
            FT_MATV_CNF matv_cnf;
	       memset(&matv_cnf, 0, sizeof(FT_MATV_CNF));
           matv_cnf.header.id = FT_MATV_CMD_CNF_ID;
	       matv_cnf.header.token = ((FT_MATV_REQ *)pLocalBuf)->header.token;
           matv_cnf.status = META_NOT_SUPPORT;
           matv_cnf.type = ((FT_MATV_REQ *)pLocalBuf)->type;
		  WriteDataToPC(&matv_cnf, sizeof(matv_cnf), NULL, 0);
        #endif
            break;
        // Reboot device
        case FT_REBOOT_REQ_ID:
        FT_Reboot((FT_META_REBOOT_REQ *)pLocalBuf);
        break;
        case FT_CUSTOMER_REQ_ID:
            FT_CUSTOMER_OP((FT_CUSTOMER_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_GET_CHIPID_REQ_ID:
            FT_GET_CHIPID_OP((FT_GET_CHIPID_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_MSENSOR_REQ_ID:
            FT_MSENSOR_OP((FT_MSENSOR_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_ALSPS_REQ_ID:
            FT_ALSPS_OP((FT_ALSPS_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_GYROSCOPE_REQ_ID:
            FT_GYROSENSOR_OP((GYRO_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
		// Touch panel
		case FT_CTP_REQ_ID:
			FT_CTP_OP((Touch_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
		break;
	// Get version info V2
    	case FT_VER_INFO_V2_REQ_ID:
        	FT_GetVersionInfoV2((FT_VER_INFO_V2_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
        	break;
        	
        #ifdef FT_NFC_FEATURE
        case FT_NFC_REQ_ID:
               FT_NFC_OP((NFC_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
               break;
        #endif
    #ifdef FT_EMMC_FEATURE
		case FT_EMMC_REQ_ID:
			FT_CLR_EMMC_OP((FT_EMMC_REQ *)pLocalBuf,(char *)pft_PeerBuf, ft_peer_len);
			break;
		case FT_CRYPTFS_REQ_ID:
			FT_CRYPTFS_OP((FT_CRYPTFS_REQ *)pLocalBuf,(char *)pft_PeerBuf, ft_peer_len);
			break;
		#endif
		
		case FT_BUILD_PROP_REQ_ID:
			FT_BUILD_PROP_OP((FT_BUILD_PROP_REQ *)pLocalBuf,(char *)pft_PeerBuf, ft_peer_len);
			break;
		case FT_MODEM_REQ_ID:
			FT_MODEM_INFO_OP((FT_MODEM_REQ *)pLocalBuf,(char *)pft_PeerBuf, ft_peer_len);
			break;

		case FT_SIM_NUM_REQ_ID:
			FT_SIM_NUM_OP((FT_GET_SIM_REQ *)pLocalBuf,(char *)pft_PeerBuf, ft_peer_len);
			break;
		case FT_DFO_REQ_ID:
			FT_DFO_OP((FT_DFO_REQ *)pLocalBuf,(char *)pft_PeerBuf, ft_peer_len);
			break;
		case FT_ADC_REQ_ID:
			FT_ADC_OP((ADC_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
			break;
        default:
            //printf((TEXT("[FTT_Drv:] FTMainThread Error:!!! ID: %hu "), ft_header->id));
            FT_LOG("[FTT_Drv:] FTMainThread Error:!!! ID ");
        break;
    }
}
/********************************************************************************
//FUNCTION:
//		FT_DispatchMessage
//DESCRIPTION:
//		this function is called to switch the testcase, del the header of peer buf.
//
//PARAMETERS:
//		Local_buf:	[IN]	local buf (cnf cmd)
//		Local_len: 	[IN]	local buf size
//		pPeerBuf		[IN]	peer buff
//		Peer_len:		[IN]	peer buff size
//RETURN VALUE:
//		TRUE is success, otherwise is fail
//
//DEPENDENCY:
//		the FT module must have been loaded.
//
//GLOBALS AFFECTED
//		None
********************************************************************************/
void FT_DispatchMessage(void *pLocalBuf, void *pPeerBuf, int local_len, int peer_len)
{
    FT_H  *ft_header;
    ft_header =(FT_H *)pLocalBuf;
    kal_int16 ft_peer_len = peer_len -8;	//del the size of peer buf header
    char *pft_PeerBuf = (char *)pPeerBuf;
    
    pft_PeerBuf += 8; // skip the header of peer buffer
    
    FT_LOG("[FTT_Drv:] FTMainThread ID : %d ", ft_header->id);
    
    switch (ft_header->id)
    {

        case FT_IS_ALIVE_REQ_ID:				//test alive
            FT_TestAlive((FT_IS_ALIVE_REQ *)pLocalBuf);
            break;
        #ifdef FT_WIFI_FEATURE
        case FT_WIFI_REQ_ID:					//wifi test
            FT_WIFI_OP((FT_WM_WIFI_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        #endif
        case FT_SDCARD_REQ_ID:                  //sdcard test
            FT_SDcard_OP((SDCARD_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_NVRAM_READ_REQ_ID:				//nvram read
            FT_APEditorRead_OP((FT_AP_Editor_read_req *)pLocalBuf);
            break;
        case FT_NVRAM_WRITE_REQ_ID:				//nvram write
            FT_APEditorWrite_OP((FT_AP_Editor_write_req *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_NVRAM_RESET_REQ_ID:				//nvram reset
            FT_APEditorReset_OP((FT_AP_Editor_reset_req *)pLocalBuf);
            break;
	case FT_VER_INFO_REQ_ID:				//get version info
            FT_GetVersionInfo((FT_VER_INFO_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_GPIO_REQ_ID:
            FT_GPIO_OP((GPIO_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;

        /*
        case FT_CHECK_META_VER_REQ_ID:			//require meta dll version
            FT_CheckMetaDllVersion((FT_CHECK_META_VER_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        */
        case FT_POWER_OFF_REQ_ID:				//power off target
            FT_PowerOff();
            break;
        case FT_REG_WRITE_ID:					//baseband reg wirte
            FT_CPURegW_OP((FT_REG_WRITE_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_REG_READ_ID:					//baseband reg read
            FT_CPURegR_OP((FT_REG_READ_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_CCT_REQ_ID:
            FT_CCAP_OP((FT_CCT_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;

        case FT_UTILITY_COMMAND_REQ_ID:			//utility command
            FT_Peripheral_OP((FT_UTILITY_COMMAND_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
    #ifdef FT_BT_FEATURE 
        case FT_BT_REQ_ID:						//bt test
            FT_BT_OP((BT_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
	#endif
        case FT_ADC_GETMEADATA_ID:				//adc test
            FT_AUXADC_OP((AUXADC_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
	#ifdef FT_GPS_FEATURE		
        case FT_GPS_REQ_ID:
            FT_GPS_OP((GPS_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
    #endif
	#ifdef FT_FM_FEATURE 	
        case FT_FM_REQ_ID:
            FT_FM_OP((FM_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
	#endif
        case FT_L4AUD_REQ_ID:
            FT_L4AUDIO_OP((FT_L4AUD_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_NVRAM_BACKUP_REQ_ID:
            FT_NVRAM_Backup_OP((FT_NVRAM_BACKUP_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_NVRAM_RESTORE_REQ_ID:
            FT_NVRAM_Restore_OP((FT_NVRAM_RESTORE_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_GSENSOR_REQ_ID:
            FT_GSENSOR_OP((GS_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_META_MODE_LOCK_REQ_ID:
            FT_META_MODE_LOCK((FT_META_MODE_LOCK_REQ *)pLocalBuf);
            break;
        #ifdef FT_MATV_FEATURE		
        case FT_MATV_CMD_REQ_ID:
            FT_MATV_OP((FT_MATV_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        #endif		
        case FT_REBOOT_REQ_ID:
        FT_Reboot((FT_META_REBOOT_REQ *)pLocalBuf);
        break;
        case FT_CUSTOMER_REQ_ID:
            FT_CUSTOMER_OP((FT_CUSTOMER_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_GET_CHIPID_REQ_ID:
            FT_GET_CHIPID_OP((FT_GET_CHIPID_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_MSENSOR_REQ_ID:
            FT_MSENSOR_OP((FT_MSENSOR_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_ALSPS_REQ_ID:
            FT_ALSPS_OP((FT_ALSPS_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
        case FT_GYROSCOPE_REQ_ID:
            FT_GYROSENSOR_OP((GYRO_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
            break;
		case FT_CTP_REQ_ID:
			FT_CTP_OP((Touch_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
		break;
    	case FT_VER_INFO_V2_REQ_ID:
        	FT_GetVersionInfoV2((FT_VER_INFO_V2_REQ *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
        	break;
#ifdef FT_CMMB_FEATURE
	case FT_CMMB_REQ_ID:
		FT_CMMB_OP((MetaCmmbReq *)pLocalBuf, (char *)pft_PeerBuf, ft_peer_len);
		break;
#endif
		case FT_BUILD_PROP_REQ_ID:
			FT_BUILD_PROP_OP((FT_BUILD_PROP_REQ *)pLocalBuf,(char *)pft_PeerBuf, ft_peer_len);
			break;
		#ifdef FT_EMMC_FEATURE
		case FT_EMMC_REQ_ID:
			FT_CLR_EMMC_OP((FT_EMMC_REQ *)pLocalBuf,(char *)pft_PeerBuf, ft_peer_len);
			break;
		case FT_CRYPTFS_REQ_ID:
			FT_CRYPTFS_OP((FT_CRYPTFS_REQ *)pLocalBuf,(char *)pft_PeerBuf, ft_peer_len);
			break;
		#endif
        default:
            FT_LOG("[FTT_Drv:] FTMainThread Error:!!! ID ");
        break;
    }
}
void FT_DispatchMessage(ilm_struct* ptrMsg)
{
    FT_H  *ft_header;
    ft_header=(FT_H *)(ptrMsg->local_para_ptr);
    if( (ptrMsg->src_mod_id == MOD_TST_READER) )
    {
        ft_gl_token=ft_header->token;
#ifdef __TOOL_ACCESS_CTRL__
        // if it's not basic META mode operation, check the limited operation state
        if(!FT_META_IsBasicOperation(ft_header->ft_msg_id))
        {
            // check if the operation is allowed
            if(KAL_TRUE != Custom_META_IsAllowedLimitedStateOperation(ptrMsg))
            {
                return;
            }
        }
#endif // #ifdef __TOOL_ACCESS_CTRL__
        switch (ft_header->ft_msg_id)
        {
            /********************************************
             * L1 RF test functionality
             ********************************************/
            case FT_RF_TEST_REQ_ID:
            {
                FT_FtRfTestReq((ft_rf_test_req_T*)ptrMsg->local_para_ptr, ptrMsg->peer_buff_ptr);
                break;
            }
            /********************************************
             * BB test functionality
             ********************************************/
            case FT_REG_READ_ID:
            {
                FT_FtRegisterRead((ft_RegisterRead_req_T*)ptrMsg->local_para_ptr,FT_BaseBandReg);
                break;
            }
            case FT_REG_WRITE_ID:
            {
                FT_FtRegisterWrite((ft_RegisterWrite_req_T*)ptrMsg->local_para_ptr,FT_BaseBandReg);
                break;
            }
            case FT_PMIC_REG_READ_ID:
            {
                FT_FtPMICRegisterRead((ft_PMICRegisterRead_req_T*)ptrMsg->local_para_ptr,FT_PMICReg);
                break;
            }
            case FT_PMIC_REG_WRITE_ID:
            {
                FT_FtPMICRegisterWrite((ft_PMICRegisterWrite_req_T*)ptrMsg->local_para_ptr,FT_PMICReg);
                break;
            }
            case FT_ADC_GETMEADATA_ID:
            {
                FT_FtADC_GetMeaData((ft_FtADC_GetMeaData_req_T*)ptrMsg->local_para_ptr);
                break;
            }
            /********************************************
             * UL1 RF test functionality
             ********************************************/
#if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
            case FT_URF_TEST_REQ_ID:
            {
                if(KAL_TRUE == UL1_IS_3G_FDD_EXIST())  //20130206
                {
                FT_FtURfTestReq( (ft_urf_test_req_T*)ptrMsg->local_para_ptr, ptrMsg->peer_buff_ptr );
                }
                else
                {
                    sprintf(g_FT_debug_buf, "[FT_DispatchMessage][FT_URF_TEST_REQ_ID] HW FDD does not exist.");
            	  tst_sys_trace(g_FT_debug_buf);
                }    
                break;
            }
#endif // #if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
            /********************************************
             *
             *  NVRAM functionality
             *
             ********************************************/
            case FT_NVRAM_GET_DISK_INFO_REQ_ID:
            {
                ilm_struct ptr_ilm;
                FT_NVRAM_GET_DISK_INFO_CNF *ptr_loc_para;
                // store nvram token id, because any of NVRAM command won't return immediately.
                ft_gl_nvram_token = ft_header->token;
                FT_ALLOC_OTHER_MSG(&ptr_ilm,sizeof(FT_NVRAM_GET_DISK_INFO_CNF));                
                ptr_loc_para=(FT_NVRAM_GET_DISK_INFO_CNF *)(ptr_ilm.local_para_ptr);
                /* if ptr_ilm != NULL*/
                ptr_loc_para->header.ft_msg_id=FT_NVRAM_GET_DISK_INFO_CNF_ID;
#if defined(__MOD_NVRAM__)
                if(nvram_get_disk_file_info(&(ptr_loc_para->diskfilesize), &(ptr_loc_para->freespace), &(ptr_loc_para->overhead))) {
                    ptr_loc_para->status = 0;
                }
                else {
                    ptr_loc_para->diskfilesize = 0;
                    ptr_loc_para->freespace = 0;
                    ptr_loc_para->overhead = 0;
                    ptr_loc_para->status = 1;
                }
#endif // #if defined(__MOD_NVRAM__)
                /* FT_SEND_MSG(src_mod, dest_mod, sap_id, msg_id, ilm_ptr) */
                FT_SEND_MSG(MOD_FT, MOD_TST, FT_TST_SAP, MSG_ID_FT_TO_TST, &ptr_ilm);
                break;
            }
            case FT_NVRAM_RESET_REQ_ID:
            {   
                ilm_struct ptr_ilm;
                nvram_reset_req_struct *ptr_loc_para;
                // store nvram token id, because any of NVRAM command won't return immediately.
                ft_gl_nvram_token = ft_header->token;
                FT_ALLOC_OTHER_MSG(&ptr_ilm,sizeof( nvram_reset_req_struct));
                /* if ptr_ilm != NULL*/
                ptr_loc_para=(nvram_reset_req_struct *)(ptr_ilm.local_para_ptr);

                if( ((ft_nvram_reset_req_struct_T*)ptrMsg->local_para_ptr)->reset_category == 0) // reset all
                {

                    ptr_loc_para->reset_category= NVRAM_RESET_ALL; 
                } 
                else if( ((ft_nvram_reset_req_struct_T*)ptrMsg->local_para_ptr)->reset_category == 3) // reset certain
                {

                    ptr_loc_para->reset_category= NVRAM_RESET_CERTAIN; 
                } 
                else if( ((ft_nvram_reset_req_struct_T*)ptrMsg->local_para_ptr)->reset_category == 4) // reset factory
                {
                    ptr_loc_para->reset_category= NVRAM_RESET_FACTORY; 
                }
                else
                {
                    destroy_ilm(&ptr_ilm);
                    break; // directly break!, Let PC side timeout!
                }
                ptr_loc_para->app_id = NVRAM_APP_RESERVED;
                ptr_loc_para->LID=((ft_nvram_reset_req_struct_T*)ptrMsg->local_para_ptr)->file_idx;
                /* FT_SEND_MSG(src_mod, dest_mod, sap_id, msg_id, ilm_ptr) */
                FT_SEND_MSG(MOD_FT, MOD_NVRAM, PS_NVRAM_SAP, MSG_ID_NVRAM_RESET_REQ, &ptr_ilm);
                break;
            }
            case FT_NVRAM_READ_REQ_ID:
            {
                // store nvram token id, because any of NVRAM command won't return immediately.
                ft_gl_nvram_token = ft_header->token;
                FT_ReadFrom_NVRAM((ft_nvram_read_req_struct_T*)ptrMsg->local_para_ptr);
                break;
            }
            case FT_NVRAM_WRITE_REQ_ID:
            {
                ft_nvram_write_req_struct_T  *ptr_msg = (ft_nvram_write_req_struct_T*)( ptrMsg->local_para_ptr );
                // store nvram token id, because any of NVRAM command won't return immediately.
                ft_gl_nvram_token = ft_header->token;
                FT_WriteTo_NVRAM(ptr_msg,ptrMsg->peer_buff_ptr, ptrMsg);
                // ptrMsg->peer_buff_ptr=NULL;/* make sure the NVRAM will release the mem*/
                break;
            }
            case FT_NVRAM_LOCK_REQ_ID:
            {
                ilm_struct ptr_ilm;
                nvram_set_lock_req_struct *ptr_loc_para;
                ft_nvram_lock_req_struct_T  *ptr_msg = (ft_nvram_lock_req_struct_T *)(ptrMsg->local_para_ptr);
                // store nvram token id, because NVRAM command won't return immediately.
                ft_gl_nvram_token = ft_header->token;
                FT_ALLOC_OTHER_MSG(&ptr_ilm, sizeof(nvram_set_lock_req_struct));
                /* if ptr_ilm != NULL*/
                ptr_loc_para=(nvram_set_lock_req_struct *)(ptr_ilm.local_para_ptr);
                // if OTP lock or NVRAM lock
                if( NVRAM_LOCK_OTP == ptr_msg->lock_en ) {
                    ptr_loc_para->lock_en = NVRAM_LOCK_OTP;
                }
                else {
                    ptr_loc_para->lock_en = NVRAM_LOCK_ENABLE;
                }
                /* FT_SEND_MSG(src_mod, dest_mod, sap_id, msg_id, ilm_ptr) */
                FT_SEND_MSG(MOD_FT, MOD_NVRAM, PS_NVRAM_SAP, MSG_ID_NVRAM_SET_LOCK_REQ, &ptr_ilm);
                break;
            }
            /********************************************
             *
             *  FAT functionality
             *
             ********************************************/
            case FT_FAT_OPERATION_ID:
            {
                FT_FAT_Operation((FT_FAT_OPERATION *)ptrMsg->local_para_ptr, ptrMsg->peer_buff_ptr);
                break;
            }
            /********************************************
             *
             *  Version Info functionality
             *
             ********************************************/
            case FT_VER_INFO_REQ_ID:
            {
                FT_GetVersionInfo();
                break;
            }

            /********************************************
             *
             *  FT task test alive
             *
             ********************************************/
            case FT_IS_ALIVE_REQ_ID:
            {
                FT_TestAlive();
                break;
            }
            /********************************************
             *
             *  FT task Power Off
             *
             ********************************************/
            case FT_POWER_OFF_REQ_ID:
            {
                FT_PowerOff();
                break;
            }
            /********************************************
             *
             *  FT task utility command
             *
             ********************************************/
            case FT_UTILITY_COMMAND_REQ_ID:
            {
                FT_UtilityCommand(ptrMsg);
                break;
            }
            /********************************************
             *
             *  Misc utility command
             *
             ********************************************/
            case FT_MISC_CMD_REQ_ID:
            {
                FT_MISC_Operation(ptrMsg);
                break;
            }

            /********************************************
             *
             *  Misc EX utility command
             *
             ********************************************/
            case FT_MISC_EX_CMD_REQ_ID:
            {
                FT_MISC_EX_Operation(ptrMsg);
                break;
            }
            case FT_CUSTOM_REQ_ID:
            {
                // send message to FTC task
                ft_gl_customer_token = ft_header->token;
                FT_Custom_Operation(ptrMsg);
                break;
            }
#if defined(__UMTS_TDD128_MODE__) && defined(__AST_TL1_TDD__)
            case FT_AUX_REQ_ID:
            {
                if(KAL_TRUE == tl1_is_tdd_hw_exist())  //20130206
                {
                // send message to FTA task
                ft_gl_customer_token = ft_header->token;
                FT_Aux_Operation(ptrMsg);
                }
                else
                {
                    sprintf(g_FT_debug_buf, "[FT_DispatchMessage][FT_AUX_REQ_ID] HW TDD does not exist.");
            	  tst_sys_trace(g_FT_debug_buf);
                }               
                break;
            }
#endif // #if defined(__UMTS_TDD128_MODE__) && defined(__AST_TL1_TDD__)
            default:
            break;
        }
    }
    else if( (ptrMsg->src_mod_id == MOD_FTC) )
    {
        ft_gl_token = ft_gl_customer_token;
        FT_Handle_FTC_CNF(ptrMsg);
        ptrMsg->peer_buff_ptr=NULL; /* make sure the TST will release the mem*/
    }
#if defined(__UMTS_TDD128_MODE__) && defined(__AST_TL1_TDD__)
    else if( (ptrMsg->src_mod_id == MOD_FTA) )
    {
        ft_gl_token = ft_gl_customer_token;
        FT_Handle_FTA_CNF(ptrMsg);
        ptrMsg->peer_buff_ptr=NULL; /* make sure the TST will release the mem*/
    }
#endif // #if defined(__UMTS_TDD128_MODE__) && defined(__AST_TL1_TDD__)

#if defined(__MOD_NVRAM__)

    else if( (ptrMsg->src_mod_id == MOD_NVRAM) )
    {
       switch (ptrMsg->msg_id)
       {
           case MSG_ID_NVRAM_READ_CNF:
           {
               nvram_read_cnf_struct *msg_ptr = NULL;
               // restore the previous token id to ft_gl_token, ft_gl_token will be used in FT_SEND_MSG().
               ft_gl_token = ft_gl_nvram_token;
               msg_ptr=(nvram_read_cnf_struct*)ptrMsg->local_para_ptr;
               FT_ReadFrom_NVRAM_CNF(msg_ptr, ptrMsg->peer_buff_ptr );
               ptrMsg->peer_buff_ptr=NULL; /* make sure the TST will release the mem*/
               break;
           }
#if defined(__MOD_NVRAM__)&& defined(__SYSDRV_BACKUP_DISK_RAW__)
           case MSG_ID_NVRAM_CREATE_IMAGE_CNF:
           case MSG_ID_NVRAM_VERIFY_IMAGE_CNF:
           {
               FT_Handle_CNF_From_NVRAM(ptrMsg);
               break;
           }
#endif // #if defined(__MOD_NVRAM__)&& defined(__SYSDRV_BACKUP_DISK_RAW__)

           case MSG_ID_NVRAM_WRITE_CNF:
           {
               nvram_write_cnf_struct*  msg_ptr = NULL;
               // restore the previous token id to ft_gl_token, ft_gl_token will be used in FT_SEND_MSG().
               ft_gl_token = ft_gl_nvram_token;
               msg_ptr=(nvram_write_cnf_struct*)ptrMsg->local_para_ptr;
               FT_WriteTo_NVRAM_CNF(msg_ptr);
               break;
           }
           case MSG_ID_NVRAM_RESET_CNF:
           {
               nvram_reset_cnf_struct*       msg_ptr;
               ilm_struct                    ilm_ptr;
               ft_nvram_reset_cnf_struct_T*  pMsg;
               // restore the previous token id to ft_gl_token, ft_gl_token will be used in FT_SEND_MSG().
               ft_gl_token = ft_gl_nvram_token;
               msg_ptr=(nvram_reset_cnf_struct*)ptrMsg->local_para_ptr;
               FT_ALLOC_MSG(&ilm_ptr, sizeof(ft_nvram_reset_cnf_struct_T));
               /* if ptrMsg != NULL*/
               pMsg=(ft_nvram_reset_cnf_struct_T*)ilm_ptr.local_para_ptr;
               pMsg->header.ft_msg_id=FT_NVRAM_RESET_CNF_ID;
               pMsg->status = msg_ptr->result;
               /* FT_SEND_MSG(src_mod, dest_mod, sap_id, msg_id, ilm_ptr) */
               FT_SEND_MSG(MOD_FT, MOD_TST, FT_TST_SAP, MSG_ID_FT_TO_TST, &ilm_ptr);
               break;
           }
           case MSG_ID_NVRAM_SET_LOCK_CNF:
           {
               nvram_set_lock_cnf_struct*    msg_ptr;
               ilm_struct                    ilm_ptr;
               ft_nvram_lock_cnf_struct_T*   pMsg;
               // restore the previous token id to ft_gl_token, ft_gl_token will be used in FT_SEND_MSG().
               ft_gl_token = ft_gl_nvram_token;
               msg_ptr=(nvram_set_lock_cnf_struct*)ptrMsg->local_para_ptr;
               FT_ALLOC_MSG(&ilm_ptr, sizeof(ft_nvram_lock_cnf_struct_T));
               /* if ptrMsg != NULL*/
               pMsg=(ft_nvram_lock_cnf_struct_T*)ilm_ptr.local_para_ptr;
               pMsg->header.ft_msg_id=FT_NVRAM_LOCK_CNF_ID;
               pMsg->status = msg_ptr->result;
               /* FT_SEND_MSG(src_mod, dest_mod, sap_id, msg_id, ilm_ptr) */
               FT_SEND_MSG(MOD_FT, MOD_TST, FT_TST_SAP, MSG_ID_FT_TO_TST, &ilm_ptr);
               break;
           }
#if defined(__MTK_INTERNAL__)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif  //#if defined(__MTK_INTERNAL__)
           case MSG_ID_NVRAM_SDS_CNF:
           case MSG_ID_NVRAM_BIN_REGION_CNF:           	
           {
               FT_Handle_CNF_From_NVRAM(ptrMsg);
               break;
           }
           default:
               break;
       }
    }
#endif // end of #if defined(__MOD_NVRAM__)
#if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
    else if( (ptrMsg->src_mod_id == MOD_UL1TST) )
    {
       FT_UL1TST_SEND_CNF_BACK(ptrMsg);
    }
#endif // #if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
    else if(  MOD_L1HISR == ptrMsg->src_mod_id && MSG_ID_L1TASK_WAKEUP == ptrMsg->msg_id )
    {
        /********************************************
         *
         *  Dispatch report from L1
         *
         ********************************************/
        L1T_DispatchReports();
    }
#ifndef SIM_NOT_PRESENT
    else if( (ptrMsg->src_mod_id == MOD_SIM) && (ft_gl_sim_cmd_type != FT_MISC_OP_CHECK_GEMINI_PLUS_SIM_INSERTED))
    {
       switch (ptrMsg->msg_id)
       {
           case MSG_ID_SIM_RESET_CNF:
           {
               FT_MISC_CNF misc_cnf;
               sim_reset_cnf_struct *msg_ptr;
               msg_ptr=(sim_reset_cnf_struct*)ptrMsg->local_para_ptr;
               misc_cnf.type = FT_MISC_OP_CHECK_SIM1_INSERTED;
               misc_cnf.result.m_u1SIMInserted = (kal_bool)msg_ptr->is_sim_inserted; // get SIM inserted status here.  1:insert  , 0: not insert
               misc_cnf.status = FT_CNF_OK;
               FT_MISC_SendCnf(&misc_cnf, NULL);
           }
               break;
           default:
               break;
       }
    }
#ifdef __GEMINI__
    else if((ptrMsg->src_mod_id == MOD_SIM_2) && (ft_gl_sim_cmd_type != FT_MISC_OP_CHECK_GEMINI_PLUS_SIM_INSERTED))
    {
        switch (ptrMsg->msg_id)
        {
            case MSG_ID_SIM_RESET_CNF:
            {
                FT_MISC_CNF misc_cnf;
                sim_reset_cnf_struct *msg_ptr;
                msg_ptr=(sim_reset_cnf_struct*)ptrMsg->local_para_ptr;
                misc_cnf.type = FT_MISC_OP_CHECK_SIM2_INSERTED;
                misc_cnf.result.m_u1SIMInserted = (kal_bool)msg_ptr->is_sim_inserted; // get SIM inserted status here.  1:insert  , 0: not insert
                misc_cnf.status = FT_CNF_OK;
                FT_MISC_SendCnf(&misc_cnf, NULL);
                break;
            }
            default:
                break;
        }
    }
#endif // __GEMINI__
#ifdef GEMINI_PLUS
    else if((ptrMsg->src_mod_id >= MOD_SIM) && (ptrMsg->src_mod_id < MOD_SIM + GEMINI_PLUS) && 
            (ft_gl_sim_cmd_type == FT_MISC_OP_CHECK_GEMINI_PLUS_SIM_INSERTED))
    {
        switch (ptrMsg->msg_id)
        {
            case MSG_ID_SIM_RESET_CNF:
            {
                FT_MISC_CNF misc_cnf;
                sim_reset_cnf_struct *msg_ptr;
                msg_ptr=(sim_reset_cnf_struct*)ptrMsg->local_para_ptr;
                misc_cnf.type = FT_MISC_OP_CHECK_GEMINI_PLUS_SIM_INSERTED;
                misc_cnf.result.m_u1SIMInserted = (kal_bool)msg_ptr->is_sim_inserted; // get SIM inserted status here.  1:insert  , 0: not insert
                misc_cnf.status = FT_CNF_OK;
                FT_MISC_SendCnf(&misc_cnf, NULL);
                break;
            }
            default:
                break;
        }
    }
#endif // GEMINI_PLUS
#endif // SIM_NOT_PRESENT
}