/******************************************************************************* * FUNCTION * FT_WriteTo_NVRAM_CNF * * DESCRIPTION * Handle the confirmation of writting * * CALLS * * * PARAMETERS * * RETURNS * None * * GLOBALS AFFECTED * None *******************************************************************************/ void FT_WriteTo_NVRAM_CNF(nvram_write_cnf_struct* cnf_result) { ilm_struct ilm_ptr; ft_nvram_write_cnf_struct_T *ptrMsg ; kal_uint8 ok; if (cnf_result->result ==0) ok = FT_CNF_OK; else ok = FT_CNF_FAIL; if(ok==FT_CNF_OK) { switch(cnf_result->file_idx) { default: /**V \brief 2G update runtime value after wrote nvram */ L1TST_UpdateCalibrationData( cnf_result->file_idx ); #if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__) /**V \brief 3G WCDMA update runtime value after wrote nvram */ FT_UL1TST_UpdateRuntimeReq( cnf_result->file_idx ); #endif // #if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__) break; } } if(!g_b_ft_nvram_proc_locally || cnf_result->file_idx != NVRAM_EF_CAL_DATA_CHECK_LID) { FT_ALLOC_MSG(&ilm_ptr, sizeof(ft_nvram_write_cnf_struct_T)); /* if ptrMsg != NULL*/ ptrMsg = (ft_nvram_write_cnf_struct_T *)ilm_ptr.local_para_ptr; ptrMsg->header.ft_msg_id = FT_NVRAM_WRITE_CNF_ID; ptrMsg->file_idx=cnf_result->file_idx; ptrMsg->para=cnf_result->para; ptrMsg->status = cnf_result->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); } else // write locally complete, return misc confirm to PC side { #if !defined(NVRAM_NOT_PRESENT) ft_misc_cal_data_write_to_nvram_cnf(cnf_result); #endif // #if !defined(NVRAM_NOT_PRESENT) } if(ok == FT_CNF_OK && g_b_ft_nvram_rec) { // get the nvram checksum from nvram kal_uint16 u2_checksum; bool bValid = ft_misc_cal_data_get_checksum((kal_uint16)cnf_result->file_idx, cnf_result->para,&u2_checksum); if(bValid) { // update the misc_buffer ft_misc_cal_data_update_local_buf((kal_uint16)cnf_result->file_idx, cnf_result->para, u2_checksum); } } }
/******************************************************************************* * FUNCTION * FT_WriteTo_NVRAM_CNF * * DESCRIPTION * Handle the confirmation of writting * * CALLS * * * PARAMETERS * * RETURNS * None * * GLOBALS AFFECTED * None *******************************************************************************/ void FT_WriteTo_NVRAM_CNF(nvram_write_cnf_struct* cnf_result) { ilm_struct* ptr_ilm; ft_nvram_write_cnf_struct_T *ptrMsg ; kal_uint8 ok; if (cnf_result->result ==0) ok = FT_CNF_OK; else ok = FT_CNF_FAIL; if(ok==FT_CNF_OK) { switch(cnf_result->file_idx) { #if defined(__WIFI_SUPPORT__) case NVRAM_EF_WNDRV_MAC_ADDRESS_LID: if(wndrv_chip_isOK()) wndrv_cal_macaddr((wndrv_cal_mac_addr_struct *)&ft_rf_data_pt); break; case NVRAM_EF_WNDRV_TX_POWER_2400M_LID: if(wndrv_chip_isOK()) wndrv_cal_txpwr_2400M((wndrv_cal_txpwr_2400M_struct *)&ft_rf_data_pt); break; case NVRAM_EF_WNDRV_TX_POWER_5000M_LID: if(wndrv_chip_isOK()) wndrv_cal_txpwr_5000M((wndrv_cal_txpwr_5000M_struct *)&ft_rf_data_pt); break; case NVRAM_EF_WNDRV_DAC_DC_OFFSET_LID: if(wndrv_chip_isOK()) wndrv_cal_dac_dc_offset((wndrv_cal_dac_dc_offset_struct *)&ft_rf_data_pt); break; case NVRAM_EF_WNDRV_TX_ALC_POWER_LID: if(wndrv_chip_isOK()) wndrv_cal_tx_ALC_power_2400M((wndrv_cal_tx_ALC_2400M_struct *)&ft_rf_data_pt); break; case NVRAM_EF_WNDRV_ALC_SLOPE_LID: if(wndrv_chip_isOK()) wndrv_cal_ALC_Slope_2400M((wndrv_cal_ALC_Slope_2400M_struct *)&ft_rf_data_pt); break; #endif default: /**V \brief 2G update runtime value after wrote nvram */ L1TST_UpdateCalibrationData( cnf_result->file_idx ); #if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__) /* under construction !*/ /* under construction !*/ #endif // #if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__) break; } } if(!g_b_ft_nvram_proc_locally || cnf_result->file_idx != NVRAM_EF_CAL_DATA_CHECK_LID) { #if defined(__WIFI_SUPPORT__) #if defined(__MTK_INTERNAL__) /* 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__) #endif // #if defined(__WIFI_SUPPORT__) ptr_ilm = FT_ALLOC_MSG( sizeof(ft_nvram_write_cnf_struct_T) ); /* if ptrMsg != NULL*/ ptrMsg = (ft_nvram_write_cnf_struct_T *)ptr_ilm->local_para_ptr; ptrMsg->header.ft_msg_id = FT_NVRAM_WRITE_CNF_ID; ptrMsg->file_idx=cnf_result->file_idx; ptrMsg->para=cnf_result->para; ptrMsg->status = cnf_result->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, ptr_ilm); } else // write locally complete, return misc confirm to PC side { #if !defined(NVRAM_NOT_PRESENT) ft_misc_cal_data_write_to_nvram_cnf(cnf_result); #endif // #if !defined(NVRAM_NOT_PRESENT) } if(ok == FT_CNF_OK && g_b_ft_nvram_rec) { // get the nvram checksum from nvram kal_uint16 u2_checksum; bool bValid = ft_misc_cal_data_get_checksum((kal_uint16)cnf_result->file_idx, cnf_result->para,&u2_checksum); if(bValid) { // update the misc_buffer ft_misc_cal_data_update_local_buf((kal_uint16)cnf_result->file_idx, cnf_result->para, u2_checksum); } } }
bool ft_misc_cal_data_read_from_nvram_cnf(nvram_read_cnf_struct* cnf_result, peer_buff_struct* peer_buff ) { #if !defined(NVRAM_NOT_PRESENT) FT_MISC_CNF misc_cnf; //peer_buff_struct *peer_buff_ret = NULL; // default value kal_char *pdu_ptr = NULL; kal_uint16 pdu_length = 0; kal_bool b_ret_cnf_to_pc = KAL_FALSE; misc_cnf.type = (FT_MISC_CMD_TYPE)i4_ft_cur_misc_op; misc_cnf.status = FT_CNF_FAIL; // default value g_b_ft_nvram_proc_locally = false; if(!ft_misc_cal_data_allocate_buf()) return false; pdu_ptr = get_peer_buff_pdu( peer_buff, &pdu_length ); // copy the content from nvram to local buffer kal_mem_cpy(p_ft_misc_buf, pdu_ptr, NVRAM_EF_CAL_DATA_CHECK_SIZE); switch(i4_ft_cur_misc_op) { case FT_MISC_OP_CALDATA_INTEGRITY_START_REC: { nvram_cal_data_check_struct *cal_data = (nvram_cal_data_check_struct*) p_ft_misc_buf; g_b_ft_nvram_rec = true; // true: get the checksum of the nvram LID, rid misc_cnf.result.m_u1CurRecNum = cal_data->u1ValidNum; misc_cnf.status = FT_CNF_OK; b_ret_cnf_to_pc = true; break; } case FT_MISC_OP_CALDATA_INTEGRITY_ADD_ONE: { bool ret; ret = ft_misc_cal_data_get_checksum( ft_misc_cal_data_proc_one.u2LidEnumVal, ft_misc_cal_data_proc_one.u2LidRec, &ft_misc_cal_data_proc_one.u2CheckVal); if(ret) { // update the misc_buffer ft_misc_cal_data_update_local_buf(ft_misc_cal_data_proc_one.u2LidEnumVal, ft_misc_cal_data_proc_one.u2LidRec, ft_misc_cal_data_proc_one.u2CheckVal); // write to nvram ft_misc_cal_data_write_to_nvram(); } else { misc_cnf.status = FT_CNF_FAIL; b_ret_cnf_to_pc = true; } } break; case FT_MISC_OP_CALDATA_INTEGRITY_DEL_ONE: case FT_MISC_OP_CALDATA_INTEGRITY_DEL_ALL: { bool bOne = i4_ft_cur_misc_op == FT_MISC_OP_CALDATA_INTEGRITY_DEL_ONE? true: false; if(!ft_misc_cal_data_del_from_local_buf(bOne)) { misc_cnf.status = FT_CNF_FAIL; b_ret_cnf_to_pc = true; } else // delete success; { // write to nvram ft_misc_cal_data_write_to_nvram(); } break; } case FT_MISC_OP_CALDATA_INTEGRITY_CHECK_ONE: case FT_MISC_OP_CALDATA_INTEGRITY_CHECK_ALL: { bool bret; bool bOne = i4_ft_cur_misc_op == FT_MISC_OP_CALDATA_INTEGRITY_CHECK_ONE? true: false; bret = ft_misc_cal_data_check(bOne); if(bOne) { if(!bret) misc_cnf.status = FT_CNF_FAIL; else { misc_cnf.status = FT_CNF_OK; } } else// if(!bOne) { misc_cnf.result.m_rCalCheckAll.bAllPass = bret; misc_cnf.result.m_rCalCheckAll.u2LastLID = ft_misc_cal_data_proc_one.u2LidEnumVal ; misc_cnf.result.m_rCalCheckAll.u2LastRID = ft_misc_cal_data_proc_one.u2LidRec; misc_cnf.status = FT_CNF_OK; } b_ret_cnf_to_pc = true; // release allocate buffer ft_misc_cal_data_free_alloc_buf(); break; } default: // exFT_MISC_OP_CALDATA_INTEGRITY_STOP_REC: return true; // do nothing } if(b_ret_cnf_to_pc) FT_MISC_SendCnf(&misc_cnf, NULL); // send confirm to PC side #endif // #if !defined(NVRAM_NOT_PRESENT) return true; }