blob: 4a6c5b87dda54b7f436125981eb2641b99057289 [file] [log] [blame]
#include "kal_public_api.h"
#include "fs_general_api.h"
#include <direct.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "em_msgid.h"
#include "em_l4_common_public_struct.h"
#include "em_mcf_public_struct.h"
#include "em_struct.h"
#include "nvram_interface.h"
#include "nvram_group_def.h"
#include "mcf_nvram_editor.h"
#include "mcf_msgid.h"
#include "md_svc_sap.h"
#include "mcf_if.h"
#include "mcf_util.h"
#include "mcf_defs.h"
#include "mcf_object.h"
#include "mcf_debug.h"
#include "mcf_utfwk.h"
#include "mcf_custom.h"
#include "mcf_struct.h"
/*------------------------------------------------------------------------------
* Constant definition.
*----------------------------------------------------------------------------*/
#define MCF_FS_DUMMY_AP_FILE_PATH "/nvdata/mdota"
#define MCF_UTFWK_DYN_PTR_NUM 1024
#define MCF_UT_FWK_OTA_FILE_PREFIX "MTK_UTFWK_OTA"
#define MCF_UT_FWK_TLVOTA_FILE_PREFIX "MTK_UTFWK_OPOTA_SBPID"
#define MCF_UT_FWK_GENERAL_TLVOTA_FILE_PREFIX "MTK_UTFWK_GENERAL_OPOTA"
/*------------------------------------------------------------------------------
* Private Helper macros.
*----------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
* Global variables.
*----------------------------------------------------------------------------*/
extern nvram_mcf_lid_info_struct mcf_last_mod_lid_g;
extern nvram_mcf_lid_info_struct mcf_curr_mod_lid_g;
kal_bool execute_ota = KAL_FALSE;
kal_bool execute_op_ota = KAL_FALSE;
kal_bool execute_gen_op_ota = KAL_FALSE;
mcf_utfwk_common_t com_buff;
kal_uint8 mcf_utfwk_dump_buffer[MCF_MAX_DUMP_SIZE + MCF_MAX_RECORD_CNT];
kal_bool is_ut_fwk = KAL_FALSE;
/*------------------------------------------------------------------------------
* Private variables.
*----------------------------------------------------------------------------*/
/* OTA test LID value pattern */
static const nvram_ef_mcf_test_struct mcf_ut_test_lid_value_pattern = {
6, // val_byte_11
6, // val_byte_12
0x6, // val_bit_byte_11
0xf0, // val_bit_byte_12
6, // val_short_11
6, // val_short_12
6, // val_int_1
6, // val_float_1
6, // val_long_1
6.6, // val_double_1
"MCF Test 66", // val_buffer_1
{6, 6, 0x6, 0xf0, 6, 6, 6, 6, 6, 6.6, "MCF Test 66"}, // val_struct_1
6, // val_byte_21
6, // val_byte_22
0x6, // val_bit_byte_21
0xf0, // val_bit_byte_22
6, // val_short_21
6, // val_short_22
6, // val_int_2
6, // val_float_2
6, // val_long_2
6.6, // val_double_2
"MCF Test 66", // val_buffer_2
{6, 6, 0x6, 0xf0, 6, 6, 6, 6, 6, 6.6, "MCF Test 66"}, // val_struct_2
{{6, 6, 0x6, 0x6, 6, 6, 6, 6, 6, 6.6, "MCF"}, // val_struct_3[0]
{6, 6, 0x6, 0x6, 6, 6, 6, 6, 6, 6.6, "MCF"}, // val_struct_3[1]
{6, 6, 0x6, 0x6, 6, 6, 6, 6, 6, 6.6, "MCF"}, // val_struct_3[2]
{6, 6, 0x6, 0x6, 6, 6, 6, 6, 6, 6.6, "MCF"}} // val_struct_3[3]
};
kal_uint8 mcf_dump_buffer[MCF_MAX_DUMP_SIZE + MCF_MAX_RECORD_CNT * MCF_DUMP_LID_HEADER_SIZE];
/*------------------------------------------------------------------------------
* Private fucntions.
*----------------------------------------------------------------------------*/
extern kal_char* release_verno(void);
extern kal_char* build_date_time(void);
extern sim_interface_enum l4c_gemini_get_actual_sim_id(sim_interface_enum simId);
extern kal_bool mcf_set_file_path(l4c_mcf_set_config_req_struct *req);
extern kal_bool mcf_get_applied_file_path(l4c_mcf_get_config_req_struct *req, l4c_mcf_get_config_cnf_struct *resp);
extern kal_bool mcf_em_update_req_hdlr(local_para_struct *local_para_ptr);
extern chmod(const char *_Filename,int _Mode);
extern mcf_dump_param_struct mcf_dump_param_tbl[];
extern kal_uint32 mcf_dump_param_tbl_num;
extern sim_interface_enum l4c_gemini_get_switched_sim_id(sim_interface_enum simId);
#if !defined(__MTK_TARGET__)
kal_bool mcf_utfwk_open_test_data(kal_char *filename, kal_char *data_buff, kal_uint32 size, kal_char *relative_path_name)
{
kal_char test_data_path[512];
FILE *file;
kal_char short_filename[512];
kal_char *pos;
kal_sprintf(test_data_path, "%s%c", filename, '\0');
file = fopen(test_data_path, "rb");
pos = strstr(test_data_path, "mcu");
kal_sprintf(short_filename, "%s%c", pos + strlen("mcu"), '\0');
if(file != NULL)
{
kal_mem_set(data_buff, 0, size);
fread(data_buff, size, 1, file);
fclose(file);
if (strlen(short_filename) < MCF_FILE_MAX_NAME_LEN){
strncpy(relative_path_name, short_filename, strlen(short_filename));
}
} else {
return KAL_FALSE;
}
return KAL_TRUE;
}
#endif
kal_bool mcf_utfwk_spilt_tag(kal_char *tag, kal_uint32 *sbp_id, kal_uint8 *mcc, kal_uint8 *mnc)
{
kal_char *saveptr = NULL, *substr = NULL;
kal_bool ret = KAL_TRUE;
substr = kal_strtok_r(tag, "_", &saveptr);
if (strcmp(substr,"") == 0){
ret = KAL_FALSE;
MD_TRC_MCF_TR_UTFWK_SPILT_TAG_UNKNOWN_SBP_ID();
mcf_utfwk_printf("Unknown sbp_id \r\n");
return ret;
}else if (strcmp(substr,"NA") == 0){
*sbp_id = SBP_ID_INVALID;
}else{
*sbp_id = mcf_atoi(substr);
}
substr = kal_strtok_r(NULL, "_",&saveptr);
strncpy(mcc, substr, MAX_MCC_STR_LEN);
substr = kal_strtok_r(NULL, "_",&saveptr);
strncpy(mnc, substr, MAX_MNC_STR_LEN);
return ret;
}
kal_bool mcf_utfwk_check_tag_match(
mcf_tool_gid_tlvota_file_item_t *pItem,
mcf_tlvota_tag_t *tag_entry,
kal_uint32 tag_num,
kal_uint32 *match_idx)
{
kal_uint32 tag_cnt = 0;
ASSERT(pItem);
ASSERT(tag_entry);
ASSERT(tag_num >= 0);
while(tag_cnt < tag_num) {
if ( (pItem->tag_type == tag_entry[tag_cnt].tag_type) && (strncmp(&(pItem->buff_start), tag_entry[tag_cnt].tag, pItem->tag_len) == 0) ) {
*match_idx = tag_cnt;
return KAL_TRUE;
}
tag_cnt++;
}
return KAL_FALSE;
}
kal_bool mcf_utfwk_check_tag_entry(mcf_tlvota_sbp_tag_t sbp_tag, mcf_tool_gid_tlvota_file_item_t *pItem)
{
mcf_tlvota_tag_t tag_entry[4];
kal_uint32 tag_num = 0;
kal_char tag[4][MCF_MAX_TAG_LEN];
kal_uint32 match_idx;
kal_bool ret;
if(!pItem ){
mcf_utfwk_printf("Invalid parameters!! pItem(%x)\r\n", pItem);
MD_TRC_MCF_TR_UTFWK_CHECK_TAG_ENTRY_INVALID_PARA(pItem);
ASSERT(0);
}
/* Fill tag entry */
if (sbp_tag.sbp_id != SBP_ID_INVALID) {
if (strcmp((kal_char *)sbp_tag.mcc, "") != 0) {
if (strcmp((kal_char *)sbp_tag.mnc, "") != 0) { // sbpid_mcc_mnc case
/* NA_mcc_NA and NA_mcc_mnc case should be updated first */
/* NA_mcc_NA */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "NA_%s_NA", (kal_char *)sbp_tag.mcc);
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
/* NA_mcc_mnc */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "NA_%s_%s", (kal_char *)sbp_tag.mcc, (kal_char *)sbp_tag.mnc);
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
if(mcf_utfwk_check_tag_match(pItem, tag_entry, tag_num, &match_idx) == KAL_TRUE){
com_buff.is_general = KAL_TRUE;
ret = KAL_TRUE;
return ret;
}
/* Reuse tag_entry */
tag_num = 0;
/* NA_NA_NA */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "NA_NA_NA");
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
/* sbpid_NA_NA */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "%d_NA_NA", sbp_tag.sbp_id);
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
/* sbpid_mcc_NA */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "%d_%s_NA", sbp_tag.sbp_id, sbp_tag.mcc);
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
/* sbpid_mcc_mnc */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "%d_%s_%s", sbp_tag.sbp_id, sbp_tag.mcc, sbp_tag.mnc);
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
} else { // sbpid_mcc_NA case
/* NA_mcc_NA case should be updated first */
/* NA_mcc_NA */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "NA_%s_NA", (kal_char *)sbp_tag.mcc);
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
if(mcf_utfwk_check_tag_match(pItem, tag_entry, tag_num, &match_idx) == KAL_TRUE){
com_buff.is_general = KAL_TRUE;
ret = KAL_TRUE;
return ret;
}
/* Reuse tag_entry */
tag_num = 0;
/* NA_NA_NA */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "NA_NA_NA");
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
/* sbpid_NA_NA */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "%d_NA_NA", sbp_tag.sbp_id);
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
/* sbpid_mcc_NA */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "%d_%s_NA", sbp_tag.sbp_id, sbp_tag.mcc);
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
}
} else {
if (strcmp((kal_char *)sbp_tag.mnc, "") == 0) { // sbpid_NA_NA case
/* NA_NA_NA */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "NA_NA_NA");
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
/* sbpid_NA_NA */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "%d_NA_NA", sbp_tag.sbp_id);
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
} else { // sbpid_NA_mnc case is not allowed!!
MD_TRC_MCF_TR_UTFWK_CHECK_TAG_ENTRY_INVALID_SBP_TAG(sbp_tag.sbp_id, sbp_tag.mcc, sbp_tag.mnc);
mcf_utfwk_printf("Invalid SBP tag!! sbp_id(%d), mcc(%s), mnc(%d)\r\n", sbp_tag.sbp_id, sbp_tag.mcc, sbp_tag.mnc);
ret = KAL_FALSE;
return ret;
}
}
} else {
if (strcmp((kal_char *)sbp_tag.mcc, "") != 0) {
if (strcmp((kal_char *)sbp_tag.mnc, "") != 0) { // NA_mcc_mnc case
/* NA_mcc_NA and NA_mcc_mnc case should be updated first */
/* NA_mcc_NA */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "NA_%s_NA", (kal_char *)sbp_tag.mcc);
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
/* NA_mcc_mnc */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "NA_%s_%s", (kal_char *)sbp_tag.mcc, (kal_char *)sbp_tag.mnc);
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
if(mcf_utfwk_check_tag_match(pItem, tag_entry, tag_num, &match_idx) == KAL_TRUE){
com_buff.is_general = KAL_TRUE;
ret = KAL_TRUE;
return ret;
}
/* Reuse tag_entry */
tag_num = 0;
/* NA_NA_NA */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "NA_NA_NA");
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
} else { // NA_mcc_NA case
/* NA_mcc_NA and NA_mcc_mnc case should be updated first */
/* NA_mcc_NA */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "NA_%s_NA", (kal_char *)sbp_tag.mcc);
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
if(mcf_utfwk_check_tag_match(pItem, tag_entry, tag_num, &match_idx) == KAL_TRUE){
com_buff.is_general = KAL_TRUE;
ret = KAL_TRUE;
return ret;
}
/* Reuse tag_entry */
tag_num = 0;
/* NA_NA_NA */
tag_entry[tag_num].tag_type = MCF_TLVOTA_TAG_SBPID;
kal_snprintf(tag[tag_num], MCF_MAX_TAG_LEN, "NA_NA_NA");
tag_entry[tag_num].tag_len = strlen(tag[tag_num]);
tag_entry[tag_num].tag = tag[tag_num];
tag_num++;
}
} else { // NA_NA_mnc cases is not allowed!!
MD_TRC_MCF_TR_UTFWK_CHECK_TAG_ENTRY_INVALID_SBP_TAG(sbp_tag.sbp_id, sbp_tag.mcc, sbp_tag.mnc);
mcf_utfwk_printf("Invalid SBP tag!! sbp_id(%d), mcc(%s), mnc(%d)\r\n", sbp_tag.sbp_id, sbp_tag.mcc, sbp_tag.mnc);
ret = KAL_FALSE;
return ret;
}
}
ret = mcf_utfwk_check_tag_match(pItem, tag_entry, tag_num, &match_idx);
com_buff.is_general = KAL_FALSE;
return ret;
}
kal_bool mcf_utfwk_generate_gid_ota_file(kal_uint8 *buff, mcf_utfwk_ota_input_struct ota_input, kal_bool *is_general, kal_uint16 *buff_size)
{
nvram_ltable_entry_struct lid_info = {0};
kal_char sw_version[MCF_SW_VERNO_LEN] = {0};
kal_char gen_time[MCF_FILE_MAX_GEN_TIME_LEN] = {0};
time_t time_sec;
struct tm tm;
kal_char file_buffer[MCF_SW_VERNO_LEN+MCF_FILE_MAX_GEN_TIME_LEN] = {0};
kal_uint16 dump_byte_offset = 0;
kal_uint16 dump_bit_offset = 0;
kal_uint32 item_size = 0;
kal_bool item_is_bit = KAL_FALSE;
kal_uint16 item_lid = 0;
kal_bool ret = KAL_TRUE;
mcf_tool_file_info_t pFile;
mcf_tool_gid_ota_file_item_t pItem;
mcf_tool_gid_tlvota_file_item_t pItem_op;
kal_char tag[MCF_MAX_TAG_LEN];
kal_uint8 sbp_len = 0;
kal_uint8 array_index[256];
kal_uint32 len = 0;
kal_uint32 item_num = 0;
kal_uint32 align_len = 0;
kal_uint16 item_cnt = 0;
kal_uint16 offset = 0;
kal_uint32 check_sum = 0;
kal_char password[MCF_MAX_PASSWORD_LEN] = {0};
mcf_utfwk_config_variable_info_struct var_info;
kal_bool is_found_lid = KAL_FALSE;
kal_uint32 i = 0;
mcf_utfwk_printf("Start! OTA type(%d)\r\n", ota_input.ota_type);
MD_TRC_MCF_TR_UTFWK_GENERATE_OTA_FILE_START(ota_input.ota_type);
kal_mem_set(sw_version, 0, sizeof(kal_char) * MCF_SW_VERNO_LEN);
kal_mem_set(gen_time, 0, sizeof(kal_char) * MCF_FILE_MAX_GEN_TIME_LEN);
kal_mem_set(file_buffer, 0, sizeof(kal_char) * (MCF_SW_VERNO_LEN+MCF_FILE_MAX_GEN_TIME_LEN));
kal_mem_set(array_index, 0, sizeof(kal_uint8) *256);
kal_mem_set(&var_info, 0, sizeof(mcf_utfwk_config_variable_info_struct));
var_info = ota_input.input_mode.var_info;
item_cnt = 0;
switch (ota_input.ota_type)
{
case MCF_UTFWK_ATTR_OTA:
kal_mem_set(&pFile, 0, sizeof(mcf_tool_file_info_t));
mcf_utfwk_printf("Start to generate OTA file. number of variable(%d), operation_mask(%d) \r\n", var_info.var_cnt, var_info.operation_mask);
MD_TRC_MCF_TR_UTFWK_GENERATE_OTA_FILE_GEN_OTA_START(var_info.var_cnt, var_info.operation_mask);
time(&time_sec);
pFile.file_version = 3;
strcpy(pFile.file_type, MCF_FILE_TYPE_OTA);
pFile.operation_mask = var_info.operation_mask;
pFile.item_num = var_info.var_cnt;
strncpy(sw_version, release_verno(), MCF_SW_VERNO_LEN-1);
pFile.sw_version_len = strlen(sw_version);
tm = *localtime(&time_sec);
sprintf(gen_time,"%04d.%02d.%02d.%02d%02d%02d\0", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
pFile.gen_time_len = strlen(gen_time);
strncpy(file_buffer, sw_version, pFile.sw_version_len);
strncpy(file_buffer+pFile.sw_version_len, gen_time, pFile.gen_time_len);
strncpy(&(pFile.buff_start), file_buffer, 1);
pFile.total_len = 43 + pFile.sw_version_len + pFile.gen_time_len;
pFile.file_size = pFile.total_len;
kal_mem_cpy(buff, &pFile, pFile.total_len);
strncpy(buff+40, file_buffer, pFile.sw_version_len+pFile.gen_time_len);
offset = pFile.total_len;
while (item_cnt < var_info.var_cnt) {
dump_byte_offset = 0;
dump_bit_offset = 0;
item_size = 0;
item_lid = 0;
align_len = 0;
kal_mem_set(&pItem, 0, sizeof(mcf_tool_gid_ota_file_item_t));
mcf_toupper((char *)var_info.var[item_cnt].array_index);
kal_mem_set(array_index, 0, sizeof(kal_uint8) *256);
kal_mem_cpy(array_index, var_info.var[item_cnt].array_index, strlen(var_info.var[item_cnt].array_index));
pItem.global_id = var_info.var[item_cnt].gid;
pItem.record_idx = var_info.var[item_cnt].rec_id;
pItem.array_index_len = strlen(array_index);
/* Find GID corresponding LID */
item_lid = mcf_find_gid_return_lid_num(pItem.global_id);
if (item_lid == 65535){
//-1(65535) means not found
mcf_utfwk_printf("Can not find this gid(%d)\r\n", pItem.global_id);
ret = KAL_FALSE;
return ret;
}
is_found_lid = KAL_FALSE;
for(i = 0; i < ota_input.lid_cnt; i++){
if (item_lid == ota_input.lid[i]){
is_found_lid = KAL_TRUE;
}
}
if (is_found_lid == KAL_FALSE){
mcf_utfwk_printf("LID(%d) of variable is not match given LID\r\n", item_lid);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_OTA_LID_INVALID(item_lid);
ret = KAL_FALSE;
return ret;
}
if(mcf_find_gid_offset(pItem.global_id, array_index, &item_lid, &dump_byte_offset, &dump_bit_offset, &item_size, &item_is_bit) == KAL_FALSE){
kal_mem_set(array_index, 0, sizeof(kal_uint8) *256);
kal_mem_cpy(array_index, var_info.var[item_cnt].array_index, strlen(var_info.var[item_cnt].array_index));
mcf_utfwk_printf("Can not find this gid(%d), array_index(%s) \r\n", pItem.global_id, array_index);
ret = KAL_FALSE;
return ret;
}
if (item_is_bit == 0){
if(var_info.var[item_cnt].value_len > item_size){
mcf_utfwk_printf("Invalid value length! value_len(%d), variable_size(%d) \r\n", var_info.var[item_cnt].value_len, item_size);
MD_TRC_MCF_TR_UTFWK_GENERATE_OTA_FILE_INVALID_VAL_LEN(var_info.var[item_cnt].value_len, item_size);
ret = KAL_FALSE;
return ret;
}
}else{
if(var_info.var[item_cnt].value_len > 4){
mcf_utfwk_printf("Invalid bit_len(%d)!! current bit_value_len(%d) \r\n", var_info.var[item_cnt].value_len, item_size);
MD_TRC_MCF_TR_UTFWK_GENERATE_OTA_FILE_INVALID_BIT_LEN(var_info.var[item_cnt].value_len, item_size);
ret = KAL_FALSE;
return ret;
}
}
pItem.total_len = 16;
pItem.value_len = var_info.var[item_cnt].value_len;
pItem.total_len += pItem.value_len;
if (item_cnt == var_info.var_cnt -1){
if (pFile.file_size % 4 != 0){
align_len = (4-(pFile.file_size % 4));
pItem.total_len += align_len;
}
}
pItem.total_len += pItem.array_index_len;
if (pItem.array_index_len > 0){
strncpy(&(pItem.buff_start), var_info.var[item_cnt].array_index, 1);
}else{
strncpy(&(pItem.buff_start), var_info.var[item_cnt].value, 1);
}
pFile.file_size += pItem.total_len;
if(pFile.file_size > MCF_MAX_OTA_FILE_SIZE){
mcf_utfwk_printf("file size(%d) is larger than allocated buffer size(%d)!! \r\n", pFile.file_size, MCF_MAX_OTA_FILE_SIZE);
MD_TRC_MCF_TR_UTFWK_GENERATE_OTA_FILE_FILE_OVERSIZE(pFile.file_size, MCF_MAX_OTA_FILE_SIZE);
ret = KAL_FALSE;
return ret;
}
kal_mem_cpy(buff+offset, &pItem, pItem.total_len);
strncpy(buff+offset+16, var_info.var[item_cnt].array_index, strlen(var_info.var[item_cnt].array_index));
kal_mem_cpy(buff+offset+16+strlen(var_info.var[item_cnt].array_index), var_info.var[item_cnt].value, var_info.var[item_cnt].value_len);
kal_mem_set(buff+offset+16+strlen(var_info.var[item_cnt].array_index)+var_info.var[item_cnt].value_len, 0, align_len);
offset += pItem.total_len;
item_cnt++;
}
kal_mem_cpy(buff+20, &(pFile.file_size), 4);
*buff_size = pFile.file_size;
if((var_info.operation_mask & MCF_FILE_OP_AES_128) != 0){
if ((pFile.file_size - pFile.total_len) % 16 != 0){
align_len = (16-((pFile.file_size - pFile.total_len) % 16));
kal_mem_set(buff+pFile.file_size, 0, align_len);
pFile.file_size += align_len;
kal_mem_cpy(buff+20, &(pFile.file_size), 4);
*buff_size = pFile.file_size;
}
}
if((var_info.operation_mask & MCF_FILE_OP_CHECKSUM) != 0){
check_sum = mcf_calc_check_sum((kal_uint32 *)buff, pFile.file_size);
pFile.checksum = check_sum;
kal_mem_cpy(buff+36, &(pFile.checksum), 4);
}
if((var_info.operation_mask & MCF_FILE_OP_AES_128) != 0){
mcf_get_custom_aes_password(password);
if (mcf_encrypt_128bit(password, (kal_char *)(buff + pFile.total_len), (pFile.file_size - pFile.total_len) ) != KAL_TRUE) {
mcf_utfwk_printf("OTA file encryption FAIL!!\r\n");
MD_TRC_MCF_TR_UTFWK_GENERATE_OTA_FILE_ENCRYPTION_FAIL();
return KAL_FALSE;
}
}
break;
case MCF_UTFWK_ATTR_OTA_BY_OP:
mcf_utfwk_printf("Start to generate OP-OTA file. number of variable(%d), operation_mask(%d), tag type(%d) \r\n", var_info.var_cnt, var_info.operation_mask, var_info.tag_type);
MD_TRC_MCF_TR_UTFWK_GENERATE_OTA_FILE_GEN_TLVOTA_START(var_info.var_cnt, var_info.operation_mask, var_info.tag_type);
if(var_info.tag_type == 0){
mcf_utfwk_printf("Invalid tag type(%d) \r\n", var_info.tag_type);
MD_TRC_MCF_TR_UTFWK_GENERATE_OTA_FILE_GEN_TLVOTA_INVALID_TAG_TYPE(var_info.tag_type);
var_info.tag_type = 1;
}
kal_mem_set(&pFile, 0, sizeof(mcf_tool_file_info_t));
*is_general = KAL_FALSE;
time(&time_sec);
pFile.file_version = 3;
strcpy(pFile.file_type, MCF_FILE_TYPE_TLVOTA);
pFile.operation_mask = 0;
pFile.item_num = var_info.var_cnt;
strncpy(sw_version, release_verno(), MCF_SW_VERNO_LEN-1);
pFile.sw_version_len = strlen(sw_version);
tm = *localtime(&time_sec);
sprintf(gen_time,"%04d.%02d.%02d.%02d%02d%02d\0", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
pFile.gen_time_len = strlen(gen_time);
strncpy(file_buffer, sw_version, pFile.sw_version_len);
strncpy(file_buffer+pFile.sw_version_len, gen_time, pFile.gen_time_len);
strncpy(&(pFile.buff_start), file_buffer, 1);
pFile.total_len = 43 + pFile.sw_version_len + pFile.gen_time_len;
pFile.file_size = pFile.total_len;
kal_mem_cpy(buff, &pFile, pFile.total_len);
strncpy(buff+40, file_buffer, pFile.sw_version_len+pFile.gen_time_len);
offset = pFile.total_len;
item_cnt = 0;
while (item_cnt < var_info.var_cnt) {
dump_byte_offset = 0;
dump_bit_offset = 0;
item_size = 0;
item_lid = 0;
align_len = 0;
kal_mem_set(&pItem_op, 0, sizeof(mcf_tool_gid_tlvota_file_item_t));
mcf_toupper((char *)var_info.var[item_cnt].array_index);
kal_mem_set(array_index, 0, sizeof(kal_uint8) *256);
kal_mem_cpy(array_index, var_info.var[item_cnt].array_index, strlen(var_info.var[item_cnt].array_index));
pItem_op.global_id = var_info.var[item_cnt].gid;
pItem_op.array_index_len = strlen(array_index);
pItem_op.tag_type = var_info.tag_type;
if(var_info.tag_type == 2){
pItem_op.tag_len = strlen(ota_input.iccid);
strncpy(tag, ota_input.iccid, 21);
*is_general = KAL_TRUE;
}else if (ota_input.sbp_id == SBP_ID_INVALID || ota_input.sbp_id == 0){
*is_general = KAL_TRUE;
}
/* Find GID corresponding LID */
item_lid = mcf_find_gid_return_lid_num(pItem_op.global_id);
if (item_lid == 65535){
//-1(65535) means not found
mcf_utfwk_printf("Can not find this gid(%d)\r\n", pItem_op.global_id);
ret = KAL_FALSE;
return ret;
}
is_found_lid = KAL_FALSE;
for(i = 0; i < ota_input.lid_cnt; i++){
if (item_lid == ota_input.lid[i]){
is_found_lid = KAL_TRUE;
}
MD_TRC_MCF_TR_UTFWK_GENERATE_OTA_FILE_TAKE_TLV_OTA_READ_LOCK_FAIL();
}
if (is_found_lid == KAL_FALSE){
mcf_utfwk_printf("LID(%d) of variable is not match given LID\r\n", item_lid);
MD_TRC_MCF_TR_UTFWK_GENERATE_OTA_FILE_INVALID_LID(item_lid);
ret = KAL_FALSE;
return ret;
}
if(mcf_find_gid_offset(pItem_op.global_id, array_index, &item_lid, &dump_byte_offset, &dump_bit_offset, &item_size, &item_is_bit) == KAL_FALSE){
kal_mem_set(array_index, 0, sizeof(kal_uint8) *256);
kal_mem_cpy(array_index, var_info.var[item_cnt].array_index, strlen(var_info.var[item_cnt].array_index));
mcf_utfwk_printf("Can not find this gid(%d), array_index(%s) \r\n", pItem_op.global_id, array_index);
ret = KAL_FALSE;
return ret;
}
if (item_is_bit == 0){
if(var_info.var[item_cnt].value_len > item_size){
mcf_utfwk_printf("Invalid value length! value_len(%d), variable_size(%d) \r\n", var_info.var[item_cnt].value_len, item_size);
MD_TRC_MCF_TR_UTFWK_GENERATE_OTA_FILE_INVALID_VAL_LEN(var_info.var[item_cnt].value_len, item_size);
ret = KAL_FALSE;
return ret;
}
}else{
if(var_info.var[item_cnt].value_len > 4){
mcf_utfwk_printf("Invalid bit_len(%d)!! current bit_value_len(%d) \r\n", var_info.var[item_cnt].value_len, item_size);
MD_TRC_MCF_TR_UTFWK_GENERATE_OTA_FILE_INVALID_BIT_LEN(var_info.var[item_cnt].value_len, item_size);
ret = KAL_FALSE;
return ret;
}
}
pItem_op.total_len = 16;
pItem_op.value_len = var_info.var[item_cnt].value_len;
pItem_op.total_len += pItem_op.value_len;
pItem_op.total_len += pItem_op.array_index_len;
if (pItem_op.tag_type == 1){
if (ota_input.sbp_id != SBP_ID_INVALID) {
if (strcmp((kal_char *)ota_input.mcc, "") != 0) {
if (strcmp((kal_char *)ota_input.mnc, "") != 0){
kal_snprintf(tag, MCF_MAX_TAG_LEN, "%d_%s_%s%c", ota_input.sbp_id, (kal_char *)ota_input.mcc, (kal_char *)ota_input.mnc, '\0');
}else{
kal_snprintf(tag, MCF_MAX_TAG_LEN, "%d_%s_NA%c", ota_input.sbp_id, (kal_char *)ota_input.mcc, '\0');
}
}else{
if (strcmp((kal_char *)ota_input.mnc, "") != 0){
kal_snprintf(tag, MCF_MAX_TAG_LEN, "%d_NA_%s%c", ota_input.sbp_id, (kal_char *)ota_input.mnc, '\0');
}else{
kal_snprintf(tag, MCF_MAX_TAG_LEN, "%d_NA_NA%c", ota_input.sbp_id, '\0');
}
}
}else{
if (strcmp((kal_char *)ota_input.mcc, "") != 0) {
if (strcmp((kal_char *)ota_input.mnc, "") != 0){
kal_snprintf(tag, MCF_MAX_TAG_LEN, "NA_%s_%s%c", (kal_char *)ota_input.mcc, (kal_char *)ota_input.mnc, '\0');
}else{
kal_snprintf(tag, MCF_MAX_TAG_LEN, "NA_%s_NA%c", (kal_char *)ota_input.mcc, '\0');
}
}else{
if (strcmp((kal_char *)ota_input.mnc, "") != 0){
kal_snprintf(tag, MCF_MAX_TAG_LEN, "NA_NA_%s%c", (kal_char *)ota_input.mnc, '\0');
}else{
*is_general = KAL_FALSE;
kal_snprintf(tag, MCF_MAX_TAG_LEN, "NA_NA_NA%c", '\0');
}
}
}
pItem_op.tag_len = strlen(tag);
}else if (pItem_op.tag_type == 2){
*is_general = KAL_TRUE;
if (strcmp(ota_input.iccid,"") != 0){
kal_snprintf(tag, MCF_MAX_TAG_LEN, "%s%c", ota_input.iccid, '\0');
}
pItem_op.tag_len = strlen(tag);
}
pItem_op.total_len += pItem_op.tag_len;
strncpy(&(pItem_op.buff_start), tag, 1);
if (item_cnt == var_info.var_cnt -1){
if (pFile.file_size % 4 != 0){
align_len = (4-(pFile.file_size % 4));
pItem_op.total_len += align_len;
}
}
pFile.file_size += pItem_op.total_len;
if(pFile.file_size > MCF_MAX_TLVOTA_FILE_SIZE){
mcf_utfwk_printf("file size(%d) is larger than allocated buffer size(%d)!! \r\n", pFile.file_size, MCF_MAX_TLVOTA_FILE_SIZE);
MD_TRC_MCF_TR_UTFWK_GENERATE_OTA_FILE_FILE_OVERSIZE(pFile.file_size, MCF_MAX_TLVOTA_FILE_SIZE);
ret = KAL_FALSE;
return ret;
}
kal_mem_cpy(buff+offset, &pItem_op, pItem_op.total_len);
strncpy(buff+offset+16, tag, strlen(tag));
strncpy(buff+offset+16+strlen(tag), var_info.var[item_cnt].array_index, strlen(var_info.var[item_cnt].array_index));
kal_mem_cpy(buff+offset+16+strlen(tag)+strlen(var_info.var[item_cnt].array_index), var_info.var[item_cnt].value, var_info.var[item_cnt].value_len);
kal_mem_set(buff+offset+16+strlen(tag)+strlen(var_info.var[item_cnt].array_index)+var_info.var[item_cnt].value_len, 0, align_len);
offset += pItem_op.total_len;
item_cnt++;
}
kal_mem_cpy(buff+20, &(pFile.file_size), 4);
*buff_size = pFile.file_size;
if((var_info.operation_mask & MCF_FILE_OP_AES_128) != 0){
if ((pFile.file_size - pFile.total_len) % 16 != 0){
align_len = (16-((pFile.file_size - pFile.total_len) % 16));
kal_mem_set(buff+pFile.file_size, 0, align_len);
pFile.file_size += align_len;
kal_mem_cpy(buff+20, &(pFile.file_size), 4);
*buff_size = pFile.file_size;
}
}
if(var_info.operation_mask & MCF_FILE_OP_CHECKSUM != 0){
check_sum = mcf_calc_check_sum((kal_uint32 *)buff, pFile.file_size);
pFile.checksum = check_sum;
kal_mem_cpy(buff+36, &(pFile.checksum), 4);
}
if(var_info.operation_mask & MCF_FILE_OP_AES_128 != 0){
mcf_get_custom_aes_password(password);
if (mcf_encrypt_128bit(password, (kal_char *)(buff + pFile.total_len), (pFile.file_size - pFile.total_len) ) != KAL_TRUE) {
mcf_utfwk_printf("OTA file encryption FAIL!!\r\n");
MD_TRC_MCF_TR_UTFWK_GENERATE_OTA_FILE_ENCRYPTION_FAIL();
return KAL_FALSE;
}
}
break;
default:
MD_TRC_MCF_TR_UTFWK_GENERATE_OTA_FILE_UNKNOWN_OTA_TYPE(ota_input.ota_type);
mcf_utfwk_printf("Unknown ota type(%d) \r\n", ota_input.ota_type);
break;
}
return ret;
}
kal_bool mcf_utfwk_is_working_status()
{
return is_ut_fwk;
}
kal_bool mcf_utfwk_initial_env(mcf_utfwk_ota_input_struct ota_input)
{
mcf_t *pMcf = mcf_get_instance();
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
mcf_tlvota_file_t *tlvota_file;
kal_uint8 *lid_buffer;
kal_uint32 i;
mcf_tool_file_info_t *pFile;
mcf_tool_gid_ota_file_item_t *pItem;
mcf_tool_gid_tlvota_file_item_t *pItem_op;
kal_char tag[MCF_MAX_TAG_LEN];
kal_uint32 sbp_id;
kal_uint8 mcc[MAX_MCC_STR_LEN];
kal_uint8 mnc[MAX_MNC_STR_LEN];
kal_uint8 iccid[21];
kal_uint32 item_cnt = 0;
nvram_errno_enum nvram_api_ret;
nvram_ltable_entry_struct lid_info = {0};
kal_char password[MCF_MAX_PASSWORD_LEN] = {0};
mcf_tlvota_sbp_tag_t sbp_tag;
kal_uint16 item_byte_offset;
kal_uint16 item_bit_offset;
kal_uint32 item_size;
kal_char array_tag[MCF_FILE_MAX_ARRAY_TAG_LEN]={0};
kal_bool item_is_bit = KAL_FALSE;
kal_uint16 item_lid;
kal_bool is_found_lid = KAL_FALSE;
kal_uint16 buff_size = 0;
mcf_utfwk_printf("Start! OTA type(%d), Operation(%d), SIM(%d)\r\n", ota_input.ota_type, ota_input.input_op, ota_input.sim_id);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_START(ota_input.ota_type, ota_input.input_op, ota_input.sim_id);
kal_take_enh_mutex(mcf_utfwk_enhmutex_g);
if (execute_ota == KAL_FALSE && execute_op_ota == KAL_FALSE && execute_gen_op_ota == KAL_FALSE){
kal_mem_set(pMcf, 0, sizeof(mcf_t));
/* Object init */
MCF_INIT_OBJECT_BEGIN(ota_file, mcf_enhmutex_g);
MCF_INIT_OBJECT_END(ota_file, mcf_enhmutex_g);
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
MCF_INIT_OBJECT_BEGIN(tlvota_file, mcf_enhmutex_g);
MCF_INIT_OBJECT_END(tlvota_file, mcf_enhmutex_g);
}
tlvota_file = &(pMcf->general_tlvota_file);
MCF_INIT_OBJECT_BEGIN(tlvota_file, mcf_enhmutex_g);
MCF_INIT_OBJECT_END(tlvota_file, mcf_enhmutex_g);
kal_mem_set(&com_buff, 0, sizeof(mcf_utfwk_common_t));
com_buff.initial_ret = KAL_TRUE;
com_buff.ota_input = ota_input;
/* UT FWK is working, need to use fread to read file */
is_ut_fwk = KAL_TRUE;
/* Reset NVRAM_EF_MCF_OTA_FILE_LID */
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_ota_file_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_ota_file_info_struct));
for(i = 0; i < NVRAM_EF_MCF_OTA_FILE_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_OTA_FILE_LID, i+1, lid_buffer, sizeof(nvram_ef_mcf_ota_file_info_struct)) ) {
mcf_utfwk_printf("Fail to reset NVRAM_EF_MCF_OTA_FILE_LID!!\r\n");
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_RESET_OTA_FILE_LID_FAIL();
com_buff.initial_ret = KAL_FALSE;
free_ctrl_buffer_set_null(lid_buffer);
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
}
free_ctrl_buffer_set_null(lid_buffer);
/* Reset NVRAM_EF_MCF_TLVOTA_FILE_LID */
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_tlvota_file_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_tlvota_file_info_struct));
for(i = 0; i < NVRAM_EF_MCF_TLVOTA_FILE_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TLVOTA_FILE_LID, i+1, lid_buffer, sizeof(nvram_ef_mcf_tlvota_file_info_struct)) ) {
mcf_utfwk_printf("Fail to reset NVRAM_EF_MCF_TLVOTA_FILE_LID!!\r\n");
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_RESET_TLVOTA_FILE_LID_FAIL();
com_buff.initial_ret = KAL_FALSE;
free_ctrl_buffer_set_null(lid_buffer);
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
}
free_ctrl_buffer_set_null(lid_buffer);
/* Reset NVRAM_EF_MCF_TEST_OTA_LID */
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
for(i = 0; i < NVRAM_EF_MCF_TEST_OTA_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TEST_OTA_LID, i+1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
mcf_utfwk_printf("Fail to reset NVRAM_EF_MCF_TEST_OTA_LID!!\r\n");
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_RESET_TEST_OTA_LID_FAIL();
com_buff.initial_ret = KAL_FALSE;
free_ctrl_buffer_set_null(lid_buffer);
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
}
free_ctrl_buffer_set_null(lid_buffer);
/* Reset NVRAM_EF_MCF_TEST_OTA_QUERY_LID */
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_test_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_test_struct));
for(i = 0; i < NVRAM_EF_MCF_TEST_OTA_QUERY_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_TEST_OTA_QUERY_LID, i+1, lid_buffer, sizeof(nvram_ef_mcf_test_struct)) ) {
mcf_utfwk_printf("Fail to reset NVRAM_EF_MCF_TEST_OTA_QUERY_LID!!\r\n");
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_RESET_TEST_OTA_QUERY_LID_FAIL();
com_buff.initial_ret = KAL_FALSE;
free_ctrl_buffer_set_null(lid_buffer);
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
}
free_ctrl_buffer_set_null(lid_buffer);
/* Reset NVRAM_EF_MCF_SW_INFO_LID */
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_sw_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_sw_info_struct));
for(i = 0; i < NVRAM_EF_MCF_SW_INFO_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_SW_INFO_LID, i+1, lid_buffer, sizeof(nvram_ef_mcf_sw_info_struct)) ) {
mcf_utfwk_printf("Fail to reset NVRAM_EF_MCF_SW_INFO_LID!!\r\n");
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_RESET_SW_INFO_LID_FAIL();
com_buff.initial_ret = KAL_FALSE;
free_ctrl_buffer_set_null(lid_buffer);
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
}
free_ctrl_buffer_set_null(lid_buffer);
/* Reset NVRAM_EF_MCF_INTERNAL_INFO_LID */
lid_buffer = (kal_uint8 *)get_ctrl_buffer(sizeof(nvram_ef_mcf_internal_info_struct));
kal_mem_set(lid_buffer, 0, sizeof(nvram_ef_mcf_internal_info_struct));
for(i = 0; i < NVRAM_EF_MCF_INTERNAL_INFO_TOTAL; i++) {
if ( !nvram_external_write_data(NVRAM_EF_MCF_INTERNAL_INFO_LID, i+1, lid_buffer, sizeof(nvram_ef_mcf_internal_info_struct)) ) {
mcf_utfwk_printf("Fail to reset NVRAM_EF_MCF_INTERNAL_INFO_LID!!\r\n");
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_RESET_INTERNAL_INFO_LID_FAIL();
com_buff.initial_ret = KAL_FALSE;
free_ctrl_buffer_set_null(lid_buffer);
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
}
free_ctrl_buffer_set_null(lid_buffer);
for (i = 0; i < com_buff.ota_input.lid_cnt; i++){
kal_mem_set(&lid_info, 0, sizeof(nvram_ltable_entry_struct));
nvram_api_ret = nvram_external_get_lid_info(com_buff.ota_input.lid[i], &lid_info);
if (nvram_api_ret != NVRAM_ERRNO_SUCCESS) {
mcf_utfwk_printf("Fail to get LID information!! LID(%d), nvram_api_ret(%d) \r\n", com_buff.ota_input.lid[i], nvram_api_ret);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_GET_LID_INFO_FAIL(com_buff.ota_input.lid[i], nvram_api_ret);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
if (com_buff.ota_input.ota_type == MCF_UTFWK_ATTR_OTA){
if ( (lid_info.attr & NVRAM_ATTR_MCF_OTA) == 0 && (lid_info.attr & NVRAM_ATTR_MCF_OTA_FOR_QUERY) == 0) {
mcf_utfwk_printf("Invalid OTA type!! LID(%d), LID attribute(%x), ota_type(%d) \r\n", com_buff.ota_input.lid[i], lid_info.attr, com_buff.ota_input.ota_type);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_INVALID_OTA_TYPE(com_buff.ota_input.lid[i], lid_info.attr, com_buff.ota_input.ota_type);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
}else if (com_buff.ota_input.ota_type == MCF_UTFWK_ATTR_OTA_BY_OP){
if (com_buff.ota_input.sim_id >= MAX_SIM_NUM){
mcf_utfwk_printf("Invalid Parameters! SIM(%d)\r\n", com_buff.ota_input.sim_id);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_INVALID_SIM_ID(com_buff.ota_input.sim_id);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
if ( (lid_info.attr & NVRAM_ATTR_MCF_OTA_BY_OP) == 0 ) {
mcf_utfwk_printf("Invalid OP-OTA type!! LID(%d), LID attribute(%x), ota_type(%d) \r\n", com_buff.ota_input.lid[i], lid_info.attr, com_buff.ota_input.ota_type);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_INVALID_TLVOTA_TYPE(com_buff.ota_input.lid[i], lid_info.attr, com_buff.ota_input.ota_type);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
}
if((lid_info.attr & NVRAM_ATTR_MCF_OTA) != 0) {
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_RESET_LID(com_buff.ota_input.lid[i]);
if ( !nvram_external_reset_data(com_buff.ota_input.lid[i], 1, lid_info.total_records) ) {
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_RESET_LID_FAIL(com_buff.ota_input.lid[i], lid_info.total_records);
mcf_utfwk_printf("Fail to reset LID!! LID(%d), total_record(%d) \r\n", com_buff.ota_input.lid, lid_info.total_records);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
}
}
if (com_buff.ota_input.ota_type == MCF_UTFWK_ATTR_OTA_BY_OP){
for (i = 0; i < MAX_SIM_NUM; i++) {
tlvota_file = &(pMcf->tlvota_file[i]);
tlvota_file->sbp_id = SBP_ID_INVALID;
}
tlvota_file = &(pMcf->tlvota_file[com_buff.ota_input.sim_id]);
tlvota_file->sbp_id = com_buff.ota_input.sbp_id;
if (com_buff.ota_input.sbp_id == SBP_ID_INVALID || com_buff.ota_input.sbp_id == 0){
if (strcmp(com_buff.ota_input.iccid,"") == 0){
mcf_utfwk_printf("Invalid SBP ID! SBP_ID(%d)\r\n", com_buff.ota_input.sbp_id);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_INVALID_SBP_ID(com_buff.ota_input.sbp_id);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
}
strncpy(tlvota_file->mcc, com_buff.ota_input.mcc, MAX_MCC_STR_LEN);
strncpy(tlvota_file->mnc, com_buff.ota_input.mnc, MAX_MNC_STR_LEN);
strncpy(tlvota_file->iccid, com_buff.ota_input.iccid, 21);
}
}
if (com_buff.ota_input.input_op == MCF_UTFWK_OTA_FILE_PATH){
if (com_buff.ota_input.ota_type == MCF_UTFWK_ATTR_OTA){
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
com_buff.initial_ret = mcf_utfwk_open_test_data(com_buff.ota_input.input_mode.file_path_name, (kal_char *)(ota_file->buff), MCF_MAX_OTA_FILE_SIZE, ota_file->relative_path_name);
if (com_buff.initial_ret == KAL_FALSE) {
mcf_utfwk_printf("Open OTA test data(%s) FAIL!! \r\n", com_buff.ota_input.input_mode.file_path_name);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_OPEN_OTA_FAIL(com_buff.ota_input.input_mode.file_path_name);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
com_buff.initial_ret = KAL_FALSE;
return com_buff.initial_ret;
}
pFile = (mcf_tool_file_info_t *)(ota_file->buff);
pItem = (mcf_tool_gid_ota_file_item_t *)(ota_file->buff + pFile->total_len);
if (pFile->file_size > MCF_MAX_OTA_FILE_SIZE) {
mcf_utfwk_printf("file size(%d) is larger than allocated buffer size(%d)!! \r\n", pFile->file_size, MCF_MAX_OTA_FILE_SIZE);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_FILE_OVERSIZE(pFile->file_size, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
if (pFile->file_version == 3) {
/*
* If file is encrypted and has checksum.
* Decrypt file before checking checksum.
*/
if ( (pFile->operation_mask & MCF_FILE_OP_AES_128) != 0) {
mcf_get_custom_aes_password(password);
if (mcf_decrypt_128bit(password, (kal_char *)(ota_file->buff + pFile->total_len), (pFile->file_size - pFile->total_len) ) != KAL_TRUE) {
kal_mem_set(ota_file->buff, 0, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
mcf_utfwk_printf("file(%s) decryption FAIL!! \r\n", com_buff.ota_input.input_mode.file_path_name);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_FILE_DECRYPTION_FAIL(com_buff.ota_input.input_mode.file_path_name);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
}
if ( (pFile->operation_mask & MCF_FILE_OP_CHECKSUM) != 0) {
if (mcf_check_check_sum((kal_uint32 *)(ota_file->buff), pFile->file_size) != 0) {
kal_mem_set(ota_file->buff, 0, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
mcf_utfwk_printf("file(%s) checksum ERROR!! \r\n", com_buff.ota_input.input_mode.file_path_name);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_FILE_CHECKSUM_ERROR(com_buff.ota_input.input_mode.file_path_name);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
}
} else {
mcf_utfwk_printf("file version(%d) is INVALID!! \r\n", pFile->file_version);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_FILE_INVALID_FILE_VERSION(pFile->file_version);
kal_mem_set(ota_file->buff, 0, MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
item_cnt = 0;
while (item_cnt < pFile->item_num) {
if ( (pItem->array_index_len < 0) || (pItem->array_index_len >= MCF_FILE_MAX_ARRAY_TAG_LEN-1) ) {
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_TAG_INVALID_ARRAY_INDEX_LEN(pItem->array_index_len, MCF_FILE_MAX_ARRAY_TAG_LEN);
mcf_utfwk_printf("Invalid array_index_len(%d)!! max array_index_len(%d)", pItem->array_index_len, MCF_FILE_MAX_ARRAY_TAG_LEN);
goto next;
}
strncpy(array_tag, &(pItem->buff_start), pItem->array_index_len);
array_tag[pItem->array_index_len] = '\0';
if(mcf_find_gid_offset(pItem->global_id, array_tag, &item_lid, &item_byte_offset, &item_bit_offset, &item_size, &item_is_bit) == KAL_FALSE){
goto next;
}
is_found_lid = KAL_FALSE;
for(i = 0; i <com_buff.ota_input.lid_cnt; i++){
if (item_lid == com_buff.ota_input.lid[i]){
is_found_lid = KAL_TRUE;
}
}
if (is_found_lid == KAL_FALSE){
mcf_utfwk_printf("LID(%d) in OTA file is not match given LID\r\n", item_lid);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_OTA_LID_INVALID(item_lid);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
next:
pItem = (mcf_tool_gid_ota_file_item_t *)((kal_uint8 *)pItem + pItem->total_len);
item_cnt++;
}
execute_ota = KAL_TRUE;
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
mcf_utfwk_printf("Read OTA test data FAIL!! Fail to take read lock! \r\n");
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_TAKE_OTA_READ_LOCK_FAIL();
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
execute_ota = KAL_TRUE;
}else if(com_buff.ota_input.ota_type == MCF_UTFWK_ATTR_OTA_BY_OP){
tlvota_file = &(pMcf->tlvota_file[com_buff.ota_input.sim_id]);
kal_mem_set(tag, 0, sizeof(kal_char) * MCF_MAX_TAG_LEN);
kal_mem_set(iccid, 0, 21);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
com_buff.initial_ret = mcf_utfwk_open_test_data(com_buff.ota_input.input_mode.file_path_name, (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE, tlvota_file->relative_path_name);
if (com_buff.initial_ret == KAL_FALSE) {
mcf_utfwk_printf("Open OP-OTA test data(%s) FAIL!! \r\n", com_buff.ota_input.input_mode.file_path_name);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_OPEN_TLVOTA_FAIL(com_buff.ota_input.input_mode.file_path_name);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem_op = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + pFile->total_len);
if (pFile->file_size > MCF_MAX_TLVOTA_FILE_SIZE) {
mcf_utfwk_printf("file size(%d) is larger than allocated buffer size(%d)!! \r\n", pFile->file_size, MCF_MAX_TLVOTA_FILE_SIZE);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_FILE_OVERSIZE(pFile->file_size, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
if (pFile->file_version == 3) {
if (pItem_op->tag_type == 1){
strncpy(tag, &(pItem_op->buff_start), pItem_op->tag_len);
com_buff.initial_ret = mcf_utfwk_spilt_tag(tag, &sbp_id, mcc, mnc);
if (sbp_id == SBP_ID_INVALID){
com_buff.is_general = KAL_TRUE;
}
sbp_tag.sbp_id = com_buff.ota_input.sbp_id;
strncpy(sbp_tag.mcc, com_buff.ota_input.mcc, MAX_MCC_STR_LEN);
strncpy(sbp_tag.mnc, com_buff.ota_input.mnc, MAX_MNC_STR_LEN);
if(mcf_utfwk_check_tag_entry(sbp_tag, pItem_op) != KAL_TRUE){
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_TAG_IS_NOT_MATCH(com_buff.ota_input.sbp_id, com_buff.ota_input.mcc, com_buff.ota_input.mnc, sbp_id, mcc, mnc);
mcf_utfwk_printf("Tag(%d_%s_%s) in OP-OTA file is not match given tag(%d_%s_%s)\r\n", com_buff.ota_input.sbp_id, com_buff.ota_input.mcc, com_buff.ota_input.mnc, sbp_id, mcc, mnc);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
}else if(pItem_op->tag_type == 2){
strncpy(iccid, &(pItem_op->buff_start), pItem_op->tag_len);
strncpy(tlvota_file->iccid, iccid, 21);
com_buff.is_general = KAL_TRUE;
}
/*
* If file is encrypted and has checksum.
* Decrypt file before checking checksum.
*/
if ( (pFile->operation_mask & MCF_FILE_OP_AES_128) != 0) {
mcf_get_custom_aes_password(password);
if (mcf_decrypt_128bit(password, (kal_char *)(tlvota_file->buff + pFile->total_len), (pFile->file_size - pFile->total_len) ) != KAL_TRUE) {
kal_mem_set(tlvota_file->buff, 0, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
mcf_utfwk_printf("file(%s) decryption FAIL!! \r\n", com_buff.ota_input.input_mode.file_path_name);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_FILE_DECRYPTION_FAIL(com_buff.ota_input.input_mode.file_path_name);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
}
if ( (pFile->operation_mask & MCF_FILE_OP_CHECKSUM) != 0) {
if (mcf_check_check_sum((kal_uint32 *)(tlvota_file->buff), pFile->file_size) != 0) {
kal_mem_set(tlvota_file->buff, 0, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
mcf_utfwk_printf("file(%s) checksum ERROR!! \r\n", com_buff.ota_input.input_mode.file_path_name);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_FILE_CHECKSUM_ERROR(com_buff.ota_input.input_mode.file_path_name);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
}
} else {
mcf_utfwk_printf("file version(%d) is INVALID!! \r\n", pFile->file_version);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_FILE_INVALID_FILE_VERSION(pFile->file_version);
kal_mem_set(tlvota_file->buff, 0, MCF_MAX_TLVOTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
item_cnt = 0;
while (item_cnt < pFile->item_num) {
if ( (pItem_op->array_index_len < 0) || (pItem_op->array_index_len >= MCF_FILE_MAX_ARRAY_TAG_LEN-1) ) {
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_TAG_INVALID_ARRAY_INDEX_LEN(pItem_op->array_index_len, MCF_FILE_MAX_ARRAY_TAG_LEN);
mcf_utfwk_printf("Invalid array_index_len(%d)!! max array_index_len(%d)", pItem_op->array_index_len, MCF_FILE_MAX_ARRAY_TAG_LEN);
goto next1;
}
strncpy(array_tag, &(pItem_op->buff_start), pItem_op->array_index_len);
array_tag[pItem_op->array_index_len] = '\0';
if(mcf_find_gid_offset(pItem_op->global_id, array_tag, &item_lid, &item_byte_offset, &item_bit_offset, &item_size, &item_is_bit) == KAL_FALSE){
goto next1;
}
is_found_lid = KAL_FALSE;
for(i = 0; i <com_buff.ota_input.lid_cnt; i++){
if (item_lid == com_buff.ota_input.lid[i]){
is_found_lid = KAL_TRUE;
}
}
if (is_found_lid == KAL_FALSE){
mcf_utfwk_printf("LID(%d) in OP-OTA file is not match given\r\n", item_lid);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_TLVOTA_LID_INVALID(item_lid);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
next1:
pItem_op = (mcf_tool_gid_tlvota_file_item_t *)((kal_uint8 *)pItem_op + pItem_op->total_len);
item_cnt++;
}
execute_op_ota = KAL_TRUE;
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
}else {
mcf_utfwk_printf("Read OP-OTA test data FAIL!! Fail to take read lock! \r\n");
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_TAKE_TLV_OTA_READ_LOCK_FAIL();
MCF_R_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
/* General OP-OTA */
if (com_buff.is_general == KAL_TRUE){
tlvota_file = &(pMcf->general_tlvota_file);
kal_mem_set(tag, 0, sizeof(kal_char) * MCF_MAX_TAG_LEN);
kal_mem_set(iccid, 0, 21);
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (tlvota_file) {
com_buff.initial_ret = mcf_utfwk_open_test_data(com_buff.ota_input.input_mode.file_path_name, (kal_char *)(tlvota_file->buff), MCF_MAX_TLVOTA_FILE_SIZE, tlvota_file->relative_path_name);
if (com_buff.initial_ret == KAL_FALSE) {
mcf_utfwk_printf("Open OP-OTA test data(%s) FAIL!! \r\n", com_buff.ota_input.input_mode.file_path_name);
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_OPEN_TLVOTA_FAIL(com_buff.ota_input.input_mode.file_path_name);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
pFile = (mcf_tool_file_info_t *)(tlvota_file->buff);
pItem_op = (mcf_tool_gid_tlvota_file_item_t *)(tlvota_file->buff + pFile->total_len);
if (pItem_op->tag_type == 1){
strncpy(tag, &(pItem_op->buff_start), pItem_op->tag_len);
com_buff.initial_ret = mcf_utfwk_spilt_tag(tag, &sbp_id, mcc, mnc);
if (sbp_id == SBP_ID_INVALID){
com_buff.is_general = KAL_TRUE;
}
tlvota_file->sbp_id = com_buff.ota_input.sbp_id;
strncpy(tlvota_file->mcc, com_buff.ota_input.mcc, MAX_MCC_STR_LEN);
strncpy(tlvota_file->mnc, com_buff.ota_input.mnc, MAX_MNC_STR_LEN);
}else if(pItem_op->tag_type == 2){
strncpy(iccid, &(pItem_op->buff_start), pItem_op->tag_len);
strncpy(tlvota_file->iccid, iccid, 21);
}
execute_gen_op_ota = KAL_TRUE;
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
}else{
mcf_utfwk_printf("Read OP-OTA test data FAIL!! Fail to take read lock! \r\n");
MD_TRC_MCF_TR_UTFWK_INITIAL_ENV_TAKE_TLV_OTA_READ_LOCK_FAIL();
MCF_R_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
com_buff.initial_ret = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
return com_buff.initial_ret;
}
}
}
}else if (com_buff.ota_input.input_op == MCF_UTFWK_OTA_VARIABLE_CONFIG){
if (com_buff.ota_input.ota_type == MCF_UTFWK_ATTR_OTA){
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
com_buff.initial_ret = mcf_utfwk_generate_gid_ota_file(ota_file->buff, com_buff.ota_input, &(com_buff.is_general), &buff_size);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (com_buff.initial_ret == KAL_FALSE){
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
}
}else if (com_buff.ota_input.ota_type == MCF_UTFWK_ATTR_OTA_BY_OP){
MCF_W_LOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
com_buff.initial_ret = mcf_utfwk_generate_gid_ota_file(tlvota_file->buff, com_buff.ota_input, &(com_buff.is_general), &buff_size);
MCF_W_UNLOCK_OBJECT(tlvota_file, mcf_enhmutex_g);
if (com_buff.initial_ret == KAL_FALSE){
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
}
}
}
return com_buff.initial_ret;
}
void mcf_utfwk_initial_dsbp_callback(MCF_UTFWK_DSBP_FUNC dsbp_func_ptr)
{
mcf_utfwk_printf("Start!!\r\n");
MD_TRC_MCF_TR_UTFWK_INITIAL_DSBP_CALLBACK_START();
com_buff.utfwk_dsbp_func_ptr = dsbp_func_ptr;
}
void mcf_utfwk_execute()
{
nvram_ltable_entry_struct lid_info = {0};
sbp_reconfig_custom_param_struct sbp_reconfig_custom_param;
mcf_ota_result_e mcf_ret;
mcf_utfwk_printf("Start! OTA type(%d), SIM(%d)\r\n", com_buff.ota_input.ota_type, com_buff.ota_input.sim_id);
MD_TRC_MCF_TR_UTFWK_EXECUTE_START(com_buff.ota_input.ota_type, com_buff.ota_input.sim_id);
if (com_buff.initial_ret == KAL_FALSE){
mcf_utfwk_printf("Initial env is fail, ret(%d)\r\n", com_buff.initial_ret);
MD_TRC_MCF_TR_UTFWK_EXECUTE_INITIAL_ENV_FAIL(com_buff.initial_ret);
ASSERT(0);
}
if(com_buff.ota_input.ota_type == MCF_UTFWK_ATTR_OTA){
mcf_ret = mcf_do_ota_full();
if (mcf_ret != MCF_OTA_R_SUCCESS) {
mcf_utfwk_printf("Update default OTA FAIL!! ret(%d) \r\n", mcf_ret);
MD_TRC_MCF_TR_UTFWK_EXECUTE_UPDATE_DEFAULT_OTA_FAIL(mcf_ret);
ASSERT(0);
}else{
execute_ota = KAL_FALSE;
return;
}
}else if(com_buff.ota_input.ota_type == MCF_UTFWK_ATTR_OTA_BY_OP){
if (!(com_buff.utfwk_dsbp_func_ptr)){
MD_TRC_MCF_TR_UTFWK_EXECUTE_NOT_REGISTER_DSBP_CALLBACK();
mcf_utfwk_printf("Not register DSBP callback function!!! \r\n");
return;
}
sbp_reconfig_custom_param.sbp_id = com_buff.ota_input.sbp_id;
sbp_reconfig_custom_param.is_in_dynamic_sbp = KAL_TRUE;
sbp_reconfig_custom_param.sbp_sub_id = 0;
sbp_reconfig_custom_param.is_boot_up = KAL_FALSE;
sbp_reconfig_custom_param.trans_id = 250;
sbp_reconfig_custom_param.ps_id = l4c_gemini_get_switched_sim_id(com_buff.ota_input.sim_id);
kal_mem_set(sbp_reconfig_custom_param.mcc, 0, MAX_MCC_STR_LEN);
kal_mem_set(sbp_reconfig_custom_param.mnc, 0, MAX_MNC_STR_LEN);
kal_mem_set(sbp_reconfig_custom_param.iccid, 0, 21);
kal_mem_cpy(sbp_reconfig_custom_param.mcc, com_buff.ota_input.mcc, MAX_MCC_STR_LEN);
kal_mem_cpy(sbp_reconfig_custom_param.mnc, com_buff.ota_input.mnc, MAX_MNC_STR_LEN);
kal_mem_cpy(sbp_reconfig_custom_param.iccid, com_buff.ota_input.iccid, 21);
if (com_buff.utfwk_dsbp_func_ptr(&sbp_reconfig_custom_param) == KAL_FALSE){
MD_TRC_MCF_TR_UTFWK_EXECUTE_UPDATE_OP_OTA_FAIL(KAL_FALSE);
mcf_utfwk_printf("Update OP-OTA FAIL!! ret(%d) \r\n", KAL_FALSE);
ASSERT(0);
}
execute_op_ota = KAL_TRUE;
execute_gen_op_ota = KAL_TRUE;
}
}
kal_bool mcf_utfwk_dump_result(kal_uint16 lid, kal_uint16 rec_id, mcf_utfwk_dump_type_enum dump_type, void *dump_buffer, kal_uint32 size, kal_uint16 gid, kal_char* array_index)
{
nvram_ltable_entry_struct lid_info = {0};
nvram_errno_enum nvram_api_ret;
kal_uint16 item_byte_offset;
kal_uint16 item_bit_offset;
kal_uint32 item_size;
mcf_custom_dump_param_struct dump_para;
kal_uint32 lid_size;
kal_uint32 i;
kal_uint32 j = 0;
kal_uint32 n = 1;
kal_uint32 read_len = 0;
kal_bool invalid_arr_size = KAL_FALSE;
kal_bool next_level_array = KAL_FALSE;
kal_bool is_found = KAL_FALSE;
kal_bool ret = KAL_TRUE;
kal_uint8 *buffer = (kal_uint8*)dump_buffer;
kal_char array_tag[MCF_FILE_MAX_ARRAY_TAG_LEN]={0};
kal_bool item_is_bit = KAL_FALSE;
kal_uint16 item_lid;
if ((!(buffer && (size > 0))) && rec_id == 0) {
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_INVALID_PARA(lid, buffer, size);
mcf_utfwk_printf("Invalid parameters!! LID(%d), buffer(%x), size(%d) \r\n", lid, buffer, size);
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
ret = KAL_FALSE;
return ret;
}
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_START(dump_type, com_buff.ota_input.ota_type, lid, rec_id, com_buff.ota_input.sim_id);
mcf_utfwk_printf("Start! dump type(%d), OTA type(%d), LID(%d), Record(%d), SIM(%d)\r\n", dump_type, com_buff.ota_input.ota_type, lid, rec_id, com_buff.ota_input.sim_id);
kal_mem_set(&dump_para, 0, sizeof(mcf_custom_dump_param_struct));
nvram_api_ret = nvram_external_get_lid_info(lid, &lid_info);
if (nvram_api_ret != NVRAM_ERRNO_SUCCESS) {
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_GET_LID_INFO_FAIL(lid, nvram_api_ret);
mcf_utfwk_printf("Get LID information FAIL!! lid(%d), nvram_ret(%d) \r\n", lid, nvram_api_ret);
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
ret = KAL_FALSE;
return ret;
}
kal_mem_set(mcf_dump_buffer, 0, lid_info.size);
dump_para.sbp_id = com_buff.ota_input.sbp_id;
kal_mem_cpy(&(dump_para.mcc), &(com_buff.ota_input.mcc), MAX_MCC_STR_LEN);
kal_mem_cpy(&(dump_para.mnc), &(com_buff.ota_input.mnc), MAX_MNC_STR_LEN);
kal_mem_cpy(&(dump_para.iccid), &(com_buff.ota_input.iccid), 21);
dump_para.size = &lid_size;
for (i = 0; i < mcf_dump_param_tbl_num; i++) {
if ( (mcf_dump_param_tbl[i].lid == lid) ) {
is_found = KAL_TRUE;
if (com_buff.ota_input.ota_type == MCF_UTFWK_ATTR_OTA){
dump_para.type = MCF_TYPE_OTA;
dump_para.record_idx = rec_id;
if ((mcf_dump_param_tbl[i].ntfy_type & MCF_DUMP_NTFY_TYPE_OTA) != 0) {
dump_para.lid = mcf_dump_param_tbl[i].lid;
dump_para.buffer = mcf_dump_buffer;
*(dump_para.size) = 0;
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_OTA_CALLBACK(dump_para.lid, mcf_dump_param_tbl[i].ntfy_type, dump_para.record_idx);
mcf_utfwk_printf("Read default OTA by callback. LID(%d), type(%d), record_id(%d) \r\n", dump_para.lid, mcf_dump_param_tbl[i].ntfy_type, dump_para.record_idx);
ret = mcf_dump_param_tbl[i].dump_func_ptr(&dump_para);
if ( (ret == KAL_FALSE) || (*(dump_para.size) != lid_info.size) ) {
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_OTA_DUMP_ERROR(mcf_dump_param_tbl[i].lid, ret, lid_info.size, *(dump_para.size));
mcf_utfwk_printf("Read OTA dump LID(%d) FAIL!! ret(%d), lid_size(%d), return_size(%d) \r\n", mcf_dump_param_tbl[i].lid, ret, lid_info.size, *(dump_para.size));
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
ret = KAL_FALSE;
return ret;
}
} else {
/* If not register callback */
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_OTA_NVRAM(lid_info.LID, mcf_dump_param_tbl[i].ntfy_type, dump_para.record_idx);
mcf_utfwk_printf("Read default OTA by NVRAM. LID(%d), type(%d), record_id(%d) \r\n", lid_info.LID, mcf_dump_param_tbl[i].ntfy_type, dump_para.record_idx);
dump_para.buffer = mcf_dump_buffer;
if ( !nvram_external_read_data(lid_info.LID, dump_para.record_idx, dump_para.buffer, lid_info.size) ) {
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_OTA_NVRAM_FAIL(mcf_dump_param_tbl[i].lid, dump_para.record_idx, dump_para.buffer, lid_info.size);
mcf_utfwk_printf("Read default OTA by NVRAM FAIL!! LID(%d), record_idx(%d), buffer(0x%x), size(%d) \r\n", mcf_dump_param_tbl[i].lid, dump_para.record_idx, dump_para.buffer, lid_info.size);
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
ret = KAL_FALSE;
return ret;
}
}
}else if (com_buff.ota_input.ota_type == MCF_UTFWK_ATTR_OTA_BY_OP){
dump_para.type = MCF_TYPE_OTA_BY_OP;
dump_para.record_idx = 1;
dump_para.ps_id = l4c_gemini_get_switched_sim_id(com_buff.ota_input.sim_id);
mcf_utfwk_printf("Read OP OTA. LID(%d), record_id(%d), ps_id(%d), sbp_id(%d), mcc(%s), mnc(%s), iccid(%s) \r\n", dump_para.lid, dump_para.record_idx, dump_para.ps_id, dump_para.sbp_id, dump_para.mnc, dump_para.mcc, dump_para.iccid);
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_OPOTA_USIR(dump_para.lid, dump_para.record_idx, dump_para.ps_id, dump_para.sbp_id, dump_para.mnc, dump_para.mcc, dump_para.iccid);
if ((mcf_dump_param_tbl[i].ntfy_type & MCF_DUMP_NTFY_TYPE_OTA_BY_OP) != 0) {
dump_para.lid = mcf_dump_param_tbl[i].lid;
dump_para.buffer = mcf_dump_buffer;
*(dump_para.size) = 0;
mcf_utfwk_printf("Read OP OTA by callback. LID(%d), type(%d), record_id(%d), sbp_id(%d), mnc(%s), mcc(%s), iccid(%s) \r\n", dump_para.lid, dump_para.type, dump_para.record_idx, dump_para.sbp_id, dump_para.mnc, dump_para.mcc, dump_para.iccid);
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_OPOTA_CALLBACK_USIR(dump_para.lid, dump_para.type, dump_para.record_idx, dump_para.sbp_id, dump_para.mnc, dump_para.mcc, dump_para.iccid);
ret = mcf_dump_param_tbl[i].dump_func_ptr(&dump_para);
if ( (ret == KAL_FALSE) || (*(dump_para.size) != lid_info.size) ) {
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_OPOTA_DUMP_FAIL(mcf_dump_param_tbl[i].lid, ret, lid_info.size, *(dump_para.size));
mcf_utfwk_printf("Read OP OTA dump LID(%d) FAIL!! ret(%d), lid_size(%d), return_size(%d) \r\n", mcf_dump_param_tbl[i].lid, ret, lid_info.size, *(dump_para.size));
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
ret = KAL_FALSE;
return ret;
}
} else {
/* If not register callback */
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_OPOTA_NVRAM(dump_para.lid, mcf_dump_param_tbl[i].ntfy_type);
mcf_utfwk_printf("Read OP OTA by NVRAM. LID(%d), type(%d) \r\n", dump_para.lid, mcf_dump_param_tbl[i].ntfy_type);
dump_para.buffer = mcf_dump_buffer;
if ( !nvram_external_read_data(lid_info.LID, dump_para.record_idx, dump_para.buffer, lid_info.size) ) {
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_OPOTA_NVRAM_FAIL(mcf_dump_param_tbl[i].lid, dump_para.record_idx, dump_para.buffer, lid_info.size);
mcf_utfwk_printf("Read OP OTA by NVRAM FAIL!! LID(%d), record_idx(%d), buffer(0x%x), size(%d) \r\n", mcf_dump_param_tbl[i].lid, dump_para.record_idx, dump_para.buffer, lid_info.size);
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
ret = KAL_FALSE;
return ret;
}
}
}
break;
}
}
if (is_found == KAL_FALSE){
/* If not register callback */
if (com_buff.ota_input.ota_type == MCF_UTFWK_ATTR_OTA){
dump_para.type = MCF_TYPE_OTA;
dump_para.record_idx = rec_id;
mcf_utfwk_printf("Read default OTA by NVRAM (non-register callback). LID(%d), record_id(%d) \r\n", lid, rec_id);
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_OTA_NVRAM_NOT_CALLBACK(lid, rec_id);
dump_para.buffer = mcf_dump_buffer;
if ( !nvram_external_read_data(lid_info.LID, dump_para.record_idx, dump_para.buffer, lid_info.size) ) {
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_OTA_NVRAM_NOT_CALLBACK_FAIL(lid, rec_id, dump_para.buffer, lid_info.size);
mcf_utfwk_printf("Read default OTA by NVRAM FAIL (non-register callback)!!. LID(%d), record_idx(%d), buffer(0x%x), size(%d) \r\n", com_buff.ota_input.lid, rec_id, dump_para.buffer, lid_info.size);
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
ret = KAL_FALSE;
return ret;
}
}else if (com_buff.ota_input.ota_type == MCF_UTFWK_ATTR_OTA_BY_OP){
dump_para.type = MCF_TYPE_OTA_BY_OP;
dump_para.record_idx = 1;
dump_para.ps_id = l4c_gemini_get_switched_sim_id(com_buff.ota_input.sim_id);
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_OPOTA_NVRAM_NOT_CALLBACK_USIR(lid, dump_para.ps_id, dump_para.sbp_id, dump_para.mnc, dump_para.mcc, dump_para.iccid);
mcf_utfwk_printf("Read OP OTA by NVRAM (non-register callback). LID(%d) ps_id(%d), sbp_id(%d), mcc(%s), mnc(%s), iccid(%s) \r\n", lid, dump_para.ps_id, dump_para.sbp_id, dump_para.mcc, dump_para.mnc, dump_para.iccid);
dump_para.buffer = mcf_dump_buffer;
if ( !nvram_external_read_data(lid_info.LID, dump_para.record_idx, dump_para.buffer, lid_info.size) ) {
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_OPOTA_NVRAM_NOT_CALLBACK_FAIL(lid_info.LID, dump_para.record_idx, dump_para.buffer, lid_info.size);
mcf_utfwk_printf("Read OP OTA by NVRAM FAIL (non-register callback)!! LID(%d), record_idx(%d), buffer(0x%x), size(%d) \r\n", lid_info.LID, dump_para.record_idx, dump_para.buffer, lid_info.size);
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
ret = KAL_FALSE;
return ret;
}
}
}
if(dump_type == MCF_UTFWK_DUMP_LID){
if (size != lid_info.size) {
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_INVALID_SIZE(size, lid_info.size);
mcf_utfwk_printf("Invalid buffer_size(%d)!! record_size(%d) \r\n", size, lid_info.size);
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
ret = KAL_FALSE;
return ret;
}
kal_mem_cpy(buffer, mcf_dump_buffer, size);
return ret;
}else if (dump_type == MCF_UTFWK_DUMP_ONE_VARIABLE){
kal_mem_set(array_tag, 0, MCF_FILE_MAX_ARRAY_TAG_LEN);
if (gid == 0){
mcf_utfwk_printf("Dump one variable, Invalid GID(%d)!!! \r\n", gid);
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_INVALID_GID(gid);
ret = KAL_FALSE;
return ret;
}else{
if (array_index != NULL){
mcf_utfwk_printf("GID(%d), array index(%s) \r\n", gid, array_index);
strcpy(array_tag, array_index);
}else{
mcf_utfwk_printf("GID(%d) \r\n", gid);
strcpy(array_tag, "");
}
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_DUMP_ONE_VARIABLE_START(gid, array_tag);
}
/* Find GID corresponding LID */
item_lid = mcf_find_gid_return_lid_num(gid);
if (item_lid == 65535){
//-1(65535) means not found
mcf_utfwk_printf("Can not find this gid(%d) \r\n", gid);
ret = KAL_FALSE;
return ret;
}
if (item_lid != lid){
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_INVALID_LID(item_lid, gid, lid);
mcf_utfwk_printf("LID(%d) of GID(%d) item is not match given LID(%d) \r\n", item_lid, gid, lid);
ret = KAL_FALSE;
return ret;
}
if(mcf_find_gid_offset(gid, array_tag, &item_lid, &item_byte_offset, &item_bit_offset, &item_size, &item_is_bit) == KAL_FALSE){
//Cannot find the tag
kal_mem_set(array_tag, 0, sizeof(kal_uint8) *256);
strcpy(array_tag, array_index);
mcf_utfwk_printf("Can not find this gid(%d), array_index(%s) \r\n", gid, array_tag);
ret = KAL_FALSE;
return ret;
}
if (item_size > size){
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_INVALID_SIZE(size, item_size);
mcf_utfwk_printf("Invalid buffer_size(%d)!! record_size(%d) \r\n", size, item_size);
ret = KAL_FALSE;
return ret;
}
kal_mem_set(buffer, 0, lid_info.size);
if (item_is_bit == KAL_FALSE){
kal_mem_cpy(buffer, (mcf_dump_buffer + item_byte_offset), item_size);
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_VARIABLE_BYTE(buffer, item_size);
mcf_utfwk_printf("Read variable by byte. value(%s), len(%d) \r\n", buffer, item_size);
}else{
if (item_size <= 8){
kal_uint8 bit_value = *(mcf_dump_buffer + item_byte_offset);
kal_uint8 bit_mask = (kal_uint8)MCF_GEN_BIT_MASK(item_size);
bit_value &= (bit_mask << item_bit_offset);
bit_value = ((kal_uint8)bit_value >> item_bit_offset);
size = 1;
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_VARIABLE_BIT(bit_value, size);
mcf_utfwk_printf("Read variable by bit. value(%d), len(%d) \r\n", bit_value, size);
kal_mem_cpy(buffer, &bit_value, size);
}else if (item_size > 8 && item_size <= 16){
kal_uint16 bit_value = *(mcf_dump_buffer + item_byte_offset);
kal_uint16 bit_mask = (kal_uint8)MCF_GEN_BIT_MASK(item_size);
bit_value &= (bit_mask << item_bit_offset);
bit_value = ((kal_uint8)bit_value >> item_bit_offset);
size = 2;
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_VARIABLE_BIT(bit_value, size);
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_VARIABLE_BIT(bit_value, size);
mcf_utfwk_printf("Read variable by bit. value(%d), len(%d) \r\n", bit_value, size);
kal_mem_cpy(buffer, &bit_value, size);
}else if (item_size > 16 && item_size <= 32){
kal_uint32 bit_value = *(mcf_dump_buffer + item_byte_offset);
kal_uint32 bit_mask = (kal_uint8)MCF_GEN_BIT_MASK(item_size);
bit_value &= (bit_mask << item_bit_offset);
bit_value = ((kal_uint8)bit_value >> item_bit_offset);
size = 4;
MD_TRC_MCF_TR_UTFWK_DUMP_RESULT_READ_VARIABLE_BIT(bit_value, size);
mcf_utfwk_printf("Read variable by bit. value(%d), len(%d) \r\n", bit_value, size);
kal_mem_cpy(buffer, &bit_value, size);
}
}
}
return ret;
}
void mcf_utfwk_reset()
{
mcf_t *pMcf = mcf_get_instance();
nvram_errno_enum nvram_api_ret;
nvram_ltable_entry_struct lid_info = {0};
mcf_ota_file_t *ota_file = &(pMcf->ota_file);
kal_uint32 i;
MD_TRC_MCF_TR_UTFWK_RESET_START();
mcf_utfwk_printf("Reset Start!!\r\n");
MCF_W_LOCK_OBJECT(ota_file, mcf_enhmutex_g);
if (ota_file) {
kal_mem_set(ota_file->buff, 0, sizeof(kal_uint8) * MCF_MAX_OTA_FILE_SIZE);
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
} else {
MD_TRC_MCF_TR_UTFWK_RESET_TAKE_WRITE_LOCK_FAIL();
mcf_utfwk_printf("Take write lock FAIL!!\r\n");
MCF_W_UNLOCK_OBJECT(ota_file, mcf_enhmutex_g);
ASSERT(0);
}
for(i = 0; i < com_buff.ota_input.lid_cnt; i++){
kal_mem_set(&lid_info, 0, sizeof(nvram_ltable_entry_struct));
nvram_api_ret = nvram_external_get_lid_info(com_buff.ota_input.lid[i], &lid_info);
if (nvram_api_ret != NVRAM_ERRNO_SUCCESS) {
mcf_utfwk_printf("Fail to get LID information!! LID(%d), nvram_api_ret(%d) \r\n", com_buff.ota_input.lid[i], nvram_api_ret);
MD_TRC_MCF_TR_UTFWK_RESET_GET_LID_INFO_FAIL(com_buff.ota_input.lid[i], nvram_api_ret);
ASSERT(0);
}
/* Reset LID to default value */
if((lid_info.attr & NVRAM_ATTR_MCF_OTA) != 0) {
MD_TRC_MCF_TR_UTFWK_RESET_RESET_LID(com_buff.ota_input.lid[i]);
if ( !nvram_external_reset_data(com_buff.ota_input.lid[i], 1, lid_info.total_records) ) {
MD_TRC_MCF_TR_UTFWK_RESET_RESET_LID_FAIL(com_buff.ota_input.lid[i], lid_info.total_records);
mcf_utfwk_printf("Fail to reset LID!! LID(%d), total_record(%d) \r\n", com_buff.ota_input.lid[i], lid_info.total_records);
ASSERT(0);
}
}
}
kal_mem_set(&com_buff, 0, sizeof(mcf_utfwk_common_t));
execute_ota = KAL_FALSE;
execute_op_ota = KAL_FALSE;
execute_gen_op_ota = KAL_FALSE;
/* UT FWK is done */
is_ut_fwk = KAL_FALSE;
kal_give_enh_mutex(mcf_utfwk_enhmutex_g);
}
void mcf_utfwk_ilm_initial_env(ilm_struct *ilm)
{
mcf_utfwk_initial_env_req_struct *req = (mcf_utfwk_initial_env_req_struct *)ilm->local_para_ptr;
mcf_utfwk_initial_env_resp_struct *resp;
resp = (mcf_utfwk_initial_env_resp_struct *)construct_local_para(sizeof(mcf_utfwk_initial_env_resp_struct), TD_RESET);
if (!resp) {
ASSERT(0);
}
resp->result = mcf_utfwk_initial_env(req->ota_input);
/* Send process result to ATCI */
msg_send6(MOD_MCF, /* src_mod_id */
ilm->src_mod_id, /* dest_mod_id */
MCF_UTFWK_SAP, /* sap_id */
MSG_ID_MCF_UTFWK_INITIAL_ENV_RESP, /* msg_id */
(local_para_struct*)resp, /* local_para_ptr */
NULL); /* peer_buff_ptr */
}
void mcf_utfwk_ilm_initial_dsbp_callback(ilm_struct *ilm)
{
mcf_utfwk_initial_dsbp_callback_req_struct *req = (mcf_utfwk_initial_dsbp_callback_req_struct *)ilm->local_para_ptr;
mcf_utfwk_initial_dsbp_callback(req->utfwk_dsbp_func_ptr);
/* Send process result to ATCI */
msg_send6(MOD_MCF, /* src_mod_id */
ilm->src_mod_id, /* dest_mod_id */
MCF_UTFWK_SAP, /* sap_id */
MSG_ID_MCF_UTFWK_INITIAL_DSBP_CALLBACK_RESP, /* msg_id */
NULL, /* local_para_ptr */
NULL); /* peer_buff_ptr */
}
void mcf_utfwk_ilm_execute(ilm_struct *ilm)
{
mcf_utfwk_execute();
/* Send process result to ATCI */
msg_send6(MOD_MCF, /* src_mod_id */
ilm->src_mod_id, /* dest_mod_id */
MCF_UTFWK_SAP, /* sap_id */
MSG_ID_MCF_UTFWK_EXECUTE_RESP, /* msg_id */
NULL, /* local_para_ptr */
NULL); /* peer_buff_ptr */
}
void mcf_utfwk_ilm_dump_result(ilm_struct *ilm)
{
mcf_utfwk_dump_result_req_struct *req = (mcf_utfwk_dump_result_req_struct *)ilm->local_para_ptr;
mcf_utfwk_dump_result_resp_struct *resp;
resp = (mcf_utfwk_dump_result_resp_struct *)construct_local_para(sizeof(mcf_utfwk_dump_result_resp_struct), TD_RESET);
if (!resp) {
ASSERT(0);
}
resp->result = mcf_utfwk_dump_result(req->lid, req->rec_id, req->dump_type, req->buffer, req->size, req->gid, req->array_index);
/* Send process result to ATCI */
msg_send6(MOD_MCF, /* src_mod_id */
ilm->src_mod_id, /* dest_mod_id */
MCF_UTFWK_SAP, /* sap_id */
MSG_ID_MCF_UTFWK_DUMP_RESULT_RESP, /* msg_id */
(local_para_struct*)resp, /* local_para_ptr */
NULL); /* peer_buff_ptr */
}
void mcf_utfwk_ilm_reset(ilm_struct *ilm)
{
mcf_utfwk_reset();
/* Send process result to ATCI */
msg_send6(MOD_MCF, /* src_mod_id */
ilm->src_mod_id, /* dest_mod_id */
MCF_UTFWK_SAP, /* sap_id */
MSG_ID_MCF_UTFWK_RESET_RESP, /* msg_id */
NULL, /* local_para_ptr */
NULL); /* peer_buff_ptr */
}