yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2018 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | /******************************************************************************* |
| 37 | * Filename: |
| 38 | * --------- |
| 39 | * mcf_defs.h |
| 40 | * |
| 41 | * Project: |
| 42 | * -------- |
| 43 | * UMOLYA |
| 44 | * |
| 45 | * Description: |
| 46 | * ------------ |
| 47 | * MD Configuration Framework internal configuration and data structure definition. |
| 48 | * |
| 49 | * Author: |
| 50 | * ------- |
| 51 | * ------- |
| 52 | * |
| 53 | *============================================================================== |
| 54 | * HISTORY |
| 55 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 56 | *------------------------------------------------------------------------------ |
| 57 | * removed! |
| 58 | * |
| 59 | * removed! |
| 60 | * removed! |
| 61 | * removed! |
| 62 | * |
| 63 | * removed! |
| 64 | * removed! |
| 65 | * removed! |
| 66 | * |
| 67 | * removed! |
| 68 | * removed! |
| 69 | * removed! |
| 70 | * removed! |
| 71 | * |
| 72 | * removed! |
| 73 | * removed! |
| 74 | * removed! |
| 75 | * |
| 76 | * removed! |
| 77 | * removed! |
| 78 | * removed! |
| 79 | * |
| 80 | * removed! |
| 81 | * removed! |
| 82 | * removed! |
| 83 | * removed! |
| 84 | * |
| 85 | * removed! |
| 86 | * removed! |
| 87 | * removed! |
| 88 | * removed! |
| 89 | * removed! |
| 90 | * removed! |
| 91 | * |
| 92 | * removed! |
| 93 | * removed! |
| 94 | * |
| 95 | * removed! |
| 96 | * removed! |
| 97 | * removed! |
| 98 | * |
| 99 | * removed! |
| 100 | * removed! |
| 101 | * removed! |
| 102 | * removed! |
| 103 | * |
| 104 | * removed! |
| 105 | * removed! |
| 106 | * removed! |
| 107 | * |
| 108 | * removed! |
| 109 | * removed! |
| 110 | * removed! |
| 111 | * |
| 112 | * removed! |
| 113 | * removed! |
| 114 | * removed! |
| 115 | * |
| 116 | * removed! |
| 117 | * removed! |
| 118 | * removed! |
| 119 | * |
| 120 | * removed! |
| 121 | * removed! |
| 122 | * removed! |
| 123 | * |
| 124 | * removed! |
| 125 | * removed! |
| 126 | * removed! |
| 127 | * removed! |
| 128 | * |
| 129 | * removed! |
| 130 | * removed! |
| 131 | * removed! |
| 132 | * |
| 133 | * removed! |
| 134 | * removed! |
| 135 | * |
| 136 | * removed! |
| 137 | * removed! |
| 138 | * removed! |
| 139 | * |
| 140 | * removed! |
| 141 | * removed! |
| 142 | * removed! |
| 143 | * |
| 144 | * removed! |
| 145 | * removed! |
| 146 | * removed! |
| 147 | * |
| 148 | * removed! |
| 149 | * removed! |
| 150 | * removed! |
| 151 | * |
| 152 | * removed! |
| 153 | * removed! |
| 154 | * removed! |
| 155 | * |
| 156 | * removed! |
| 157 | * removed! |
| 158 | * removed! |
| 159 | * |
| 160 | * removed! |
| 161 | * removed! |
| 162 | * removed! |
| 163 | * removed! |
| 164 | * |
| 165 | * removed! |
| 166 | * removed! |
| 167 | * removed! |
| 168 | * removed! |
| 169 | * |
| 170 | * removed! |
| 171 | * removed! |
| 172 | * removed! |
| 173 | * |
| 174 | *------------------------------------------------------------------------------ |
| 175 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 176 | *============================================================================== |
| 177 | *******************************************************************************/ |
| 178 | #ifndef __INC_MCF_UTIL_H |
| 179 | #define __INC_MCF_UTIL_H |
| 180 | |
| 181 | #include "kal_public_api.h" |
| 182 | #include "em_l4_common_public_struct.h" |
| 183 | #include "mcf_nvram_editor.h" |
| 184 | #include "us_timer.h" |
| 185 | #include "mcf_db.h" |
| 186 | |
| 187 | /*------------------------------------------------------------------------------ |
| 188 | * Configuration. |
| 189 | *----------------------------------------------------------------------------*/ |
| 190 | |
| 191 | /*------------------------------------------------------------------------------ |
| 192 | * Helper Macro. |
| 193 | *----------------------------------------------------------------------------*/ |
| 194 | #define mcf_get_instance() &mcf_inst_g |
| 195 | #define MCF_GEN_BIT_MASK(_len) (pow(2, _len) - 1) |
| 196 | |
| 197 | /* Define time function */ |
| 198 | #if defined(__MTK_TARGET__) |
| 199 | #define GET_CURRENT_TIME ust_get_current_time |
| 200 | #define CALCULATE_LETENCY_DURATION ust_us_duration |
| 201 | #else // MODIS |
| 202 | #define GET_CURRENT_TIME(...) 0 |
| 203 | #define CALCULATE_LETENCY_DURATION(...) 0 |
| 204 | #endif |
| 205 | |
| 206 | #define MCF_ADDR_LINE_SIZE_MASK 0x00000003 |
| 207 | #define MCF_READ_ADDR_GET_ALIGN(_o, _alo) \ |
| 208 | { \ |
| 209 | _alo = (kal_uint32)(_o); \ |
| 210 | if(_alo&MCF_ADDR_LINE_SIZE_MASK) { \ |
| 211 | _alo = (kal_uint32)(_o)&~MCF_ADDR_LINE_SIZE_MASK; \ |
| 212 | } \ |
| 213 | } |
| 214 | |
| 215 | /*------------------------------------------------------------------------------ |
| 216 | * Constant definition. |
| 217 | *----------------------------------------------------------------------------*/ |
| 218 | |
| 219 | /*------------------------------------------------------------------------------ |
| 220 | * Internal data structure defintion. |
| 221 | *----------------------------------------------------------------------------*/ |
| 222 | |
| 223 | /*------------------------------------------------------------------------------ |
| 224 | * Global variables. |
| 225 | *----------------------------------------------------------------------------*/ |
| 226 | extern mcf_t mcf_inst_g; |
| 227 | extern event_scheduler *mcf_timer_es_g; |
| 228 | extern eventid mcf_timer_eventid_g; |
| 229 | extern mcf_t *mcf_utfwk_inst_g; |
| 230 | extern mcf_common_t com_Mcf; |
| 231 | extern kal_enhmutexid mcf_utfwk_enhmutex_g; |
| 232 | extern mcf_file_info_t new_file_info; |
| 233 | extern mcf_file_info_t old_file_info; |
| 234 | /*------------------------------------------------------------------------------ |
| 235 | * Function prototype. |
| 236 | *----------------------------------------------------------------------------*/ |
| 237 | #if !defined(__HIF_CCCI_SUPPORT__) || !defined(__MTK_TARGET__) |
| 238 | #if !defined(ATEST_SYS_MCF) |
| 239 | #define MCF_FS_CMPT_Read MCF_Win_FS_CMPT_Read |
| 240 | #else |
| 241 | #define MCF_FS_CMPT_Read MCF_dummy_FS_CMPT_Read |
| 242 | #endif |
| 243 | #else |
| 244 | #define MCF_FS_CMPT_Read FS_CMPT_Read |
| 245 | #endif |
| 246 | |
| 247 | #if !defined(__MCF_COMBINE_FILE_SUPPORT__) |
| 248 | #define MCF_LAST_MODIFIED_LID nv_int_info.last_mod_lid.lid[i] |
| 249 | #else |
| 250 | #define MCF_LAST_MODIFIED_LID nv_int_info.last_mod_lid.lid_conf[i].lid |
| 251 | #endif |
| 252 | |
| 253 | void mcf_create_custom_folder(mcf_t *pMcf); |
| 254 | mcf_ota_result_e mcf_read_ota_file(kal_bool is_booting, kal_char *req_fs_root_path, kal_char *req_file_path_name, l4c_mcf_path_type_enum *apply_path_type, kal_char *apply_filename, mcf_t *pMcf); |
| 255 | mcf_ota_result_e mcf_read_tlvota_file(kal_bool is_booting, kal_uint8 sim_id, kal_char *req_fs_root_path, kal_char *req_file_path_name, l4c_mcf_path_type_enum *apply_path_type, kal_char *apply_filename, mcf_t *pMcf); |
| 256 | mcf_ota_result_e mcf_read_general_tlvota_file(kal_bool is_booting, kal_char *req_fs_root_path, kal_char *req_file_path_name, l4c_mcf_path_type_enum *apply_path_type, kal_char *apply_filename, mcf_t *pMcf); |
| 257 | mcf_ota_result_e mcf_read_ini_file(kal_char *req_fs_root_path, kal_char *req_file_path_name, l4c_mcf_path_type_enum *apply_path_type, kal_char *apply_filename, mcf_t *pMcf); |
| 258 | kal_bool mcf_find_ini_item(kal_char *buff, kal_char *item, kal_char *value, mcf_t *pMcf); |
| 259 | kal_bool mcf_find_ini_sbp_id(kal_char *tag_str, kal_uint32 *sbp_id, kal_uint16 *sbp_id_num, kal_bool *general); |
| 260 | kal_bool mcf_compose_ini_item(kal_char *orig_buff, kal_char *new_buff, kal_char *item, kal_char *orig_value, kal_char *value); |
| 261 | void mcf_dump_data(kal_bool is_booting, void *p_data, kal_uint32 len); |
| 262 | void mcf_write_boot_trace(kal_uint32 trace_enum, ...); |
| 263 | void mcf_dump_boot_trace(void); |
| 264 | mcf_ota_result_e mcf_write_buffer(kal_char *folder_path, kal_char *file_name, kal_uint8 *buffer, kal_uint32 total_size); |
| 265 | mcf_ota_result_e mcf_get_file_last_mod_time(kal_char *apply_filename, l4c_mcf_path_type_enum apply_path_type, kal_uint64 *last_mod_time); |
| 266 | kal_bool mcf_find_tag_offset(kal_uint32 lid_num, char *tag_name, kal_uint16 *byte_offset, kal_uint16 *bit_offset, kal_uint32 *size, MCF_DB_STRUCT_VARIABLE const **var_ptr, mcf_tag_info_struct *tag_ptr); |
| 267 | kal_bool mcf_find_gid_offset(kal_uint32 gid, char *array_idx_string, kal_uint16 *lid_num, kal_uint16 *byte_offset, kal_uint16 *bit_offset, kal_uint32 *size, kal_bool *is_bit); |
| 268 | kal_uint16 mcf_find_gid_return_lid_num(kal_uint32 gid); |
| 269 | kal_uint32 mcf_calc_check_sum(kal_uint32 *ptr, kal_uint32 len); |
| 270 | kal_uint32 mcf_check_check_sum(kal_uint32 *ptr, kal_uint32 len); |
| 271 | kal_bool mcf_encrypt_128bit(char *password, char *content, kal_uint32 content_length); |
| 272 | kal_bool mcf_decrypt_128bit(char *password, char *content, kal_uint32 content_length); |
| 273 | kal_bool mcf_encrypt_256bit(char *password, char *content, kal_uint32 content_length); |
| 274 | kal_bool mcf_decrypt_256bit(char *password, char *content, kal_uint32 content_length); |
| 275 | void mcf_remove_spaces_and_carrier_return(kal_char* src); |
| 276 | void mcf_toupper(kal_char* src); |
| 277 | kal_int32 mcf_atoi(const void *src); |
| 278 | |
| 279 | kal_int16 mcf_binary_search_lid(kal_uint16 find_lid, kal_uint16 *lid_arr, kal_uint16 lid_size, kal_uint16 *new_pos); |
| 280 | kal_bool mcf_insert_lid(kal_uint16 new_lid, kal_uint16 *lid_arr, kal_uint16 lid_size, kal_uint16 new_pos); |
| 281 | #ifdef __MCF_COMBINE_FILE_SUPPORT__ |
| 282 | kal_int16 mcf_binary_search_lid_struct(kal_uint16 find_lid, nvram_mcf_lid_config_struct *lid_conf, kal_uint16 lid_size, kal_uint16 *new_pos); |
| 283 | kal_bool mcf_insert_lid_struct(kal_uint16 new_lid, nvram_mcf_lid_config_struct *lid_conf, kal_uint16 lid_size, kal_uint16 new_pos, kal_bool not_reset, kal_bool set_combined); |
| 284 | kal_bool mcf_clear_last_modified_lid(nvram_mcf_lid_config_struct *lid_conf, kal_uint16 *lid_size); |
| 285 | #endif |
| 286 | kal_int8* mcf_bytes_to_hex(const void *bytes, kal_int32 length, kal_bool upperCase, void *hex); |
| 287 | kal_int8* mcf_hex_to_bytes(const void *hex, kal_int32 *length, void *bytes); |
| 288 | kal_bool mcf_hex_str_reverse(kal_char *str, kal_uint32 length); |
| 289 | void mcf_replace_char(kal_char* src, kal_char old_ch, kal_char new_ch); |
| 290 | kal_bool mcf_merge_ota_buffer(void *first_buffer, void *second_buffer, void *output_buffer, kal_uint32 output_buffer_size); |
| 291 | kal_bool mcf_merge_one_gid(void *new_gid, mcf_ota_type_enum type, void *output_buffer, kal_uint32 output_buffer_size, kal_uint32 operation_mask); |
| 292 | void mcf_mem_init(void); |
| 293 | void *mcf_malloc(unsigned int size); |
| 294 | void mcf_free(void *ptr); |
| 295 | kal_bool mcf_verify_digest(kal_uint32 digest_tag, mcf_tool_file_info_t *ota_file, mcf_digest *sign); |
| 296 | void mcf_dump_important_info(void); |
| 297 | void mcf_snprintf(kal_char * str, size_t num, const char * fmt, ...); |
| 298 | void mcf_make_file_info(mcf_file_info_t *file_info, kal_uint8 path_type, kal_char *name, kal_char *sw_version, kal_uint8 sw_version_len, kal_char *gen_time, kal_uint8 gen_time_len, kal_uint64 last_mod_time, kal_uint32 checksum); |
| 299 | kal_bool mcf_compare_file_info(mcf_file_info_t *old_file, mcf_file_info_t *new_file); |
| 300 | |
| 301 | #endif /* __INC_MCF_DEFS_H */ |
| 302 | |