| /***************************************************************************** |
| * Copyright Statement: |
| * -------------------- |
| * This software is protected by Copyright and the information contained |
| * herein is confidential. The software may not be copied and the information |
| * contained herein may not be used or disclosed except with the written |
| * permission of MediaTek Inc. (C) 2018 |
| * |
| * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| * |
| * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| * |
| * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| * |
| *****************************************************************************/ |
| |
| /******************************************************************************* |
| * Filename: |
| * --------- |
| * mcf_defs.h |
| * |
| * Project: |
| * -------- |
| * UMOLYA |
| * |
| * Description: |
| * ------------ |
| * MD Configuration Framework internal configuration and data structure definition. |
| * |
| * Author: |
| * ------- |
| * ------- |
| * |
| *============================================================================== |
| * HISTORY |
| * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| *------------------------------------------------------------------------------ |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| *------------------------------------------------------------------------------ |
| * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| *============================================================================== |
| *******************************************************************************/ |
| #ifndef __INC_MCF_UTIL_H |
| #define __INC_MCF_UTIL_H |
| |
| #include "kal_public_api.h" |
| #include "em_l4_common_public_struct.h" |
| #include "mcf_nvram_editor.h" |
| #include "us_timer.h" |
| #include "mcf_db.h" |
| |
| /*------------------------------------------------------------------------------ |
| * Configuration. |
| *----------------------------------------------------------------------------*/ |
| |
| /*------------------------------------------------------------------------------ |
| * Helper Macro. |
| *----------------------------------------------------------------------------*/ |
| #define mcf_get_instance() &mcf_inst_g |
| #define MCF_GEN_BIT_MASK(_len) (pow(2, _len) - 1) |
| |
| /* Define time function */ |
| #if defined(__MTK_TARGET__) |
| #define GET_CURRENT_TIME ust_get_current_time |
| #define CALCULATE_LETENCY_DURATION ust_us_duration |
| #else // MODIS |
| #define GET_CURRENT_TIME(...) 0 |
| #define CALCULATE_LETENCY_DURATION(...) 0 |
| #endif |
| |
| #define MCF_ADDR_LINE_SIZE_MASK 0x00000003 |
| #define MCF_READ_ADDR_GET_ALIGN(_o, _alo) \ |
| { \ |
| _alo = (kal_uint32)(_o); \ |
| if(_alo&MCF_ADDR_LINE_SIZE_MASK) { \ |
| _alo = (kal_uint32)(_o)&~MCF_ADDR_LINE_SIZE_MASK; \ |
| } \ |
| } |
| |
| /*------------------------------------------------------------------------------ |
| * Constant definition. |
| *----------------------------------------------------------------------------*/ |
| |
| /*------------------------------------------------------------------------------ |
| * Internal data structure defintion. |
| *----------------------------------------------------------------------------*/ |
| |
| /*------------------------------------------------------------------------------ |
| * Global variables. |
| *----------------------------------------------------------------------------*/ |
| extern mcf_t mcf_inst_g; |
| extern event_scheduler *mcf_timer_es_g; |
| extern eventid mcf_timer_eventid_g; |
| extern mcf_t *mcf_utfwk_inst_g; |
| extern mcf_common_t com_Mcf; |
| extern kal_enhmutexid mcf_utfwk_enhmutex_g; |
| extern mcf_file_info_t new_file_info; |
| extern mcf_file_info_t old_file_info; |
| /*------------------------------------------------------------------------------ |
| * Function prototype. |
| *----------------------------------------------------------------------------*/ |
| #if !defined(__HIF_CCCI_SUPPORT__) || !defined(__MTK_TARGET__) |
| #if !defined(ATEST_SYS_MCF) |
| #define MCF_FS_CMPT_Read MCF_Win_FS_CMPT_Read |
| #else |
| #define MCF_FS_CMPT_Read MCF_dummy_FS_CMPT_Read |
| #endif |
| #else |
| #define MCF_FS_CMPT_Read FS_CMPT_Read |
| #endif |
| |
| #if !defined(__MCF_COMBINE_FILE_SUPPORT__) |
| #define MCF_LAST_MODIFIED_LID nv_int_info.last_mod_lid.lid[i] |
| #else |
| #define MCF_LAST_MODIFIED_LID nv_int_info.last_mod_lid.lid_conf[i].lid |
| #endif |
| |
| void mcf_create_custom_folder(mcf_t *pMcf); |
| 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); |
| 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); |
| 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); |
| 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); |
| kal_bool mcf_find_ini_item(kal_char *buff, kal_char *item, kal_char *value, mcf_t *pMcf); |
| kal_bool mcf_find_ini_sbp_id(kal_char *tag_str, kal_uint32 *sbp_id, kal_uint16 *sbp_id_num, kal_bool *general); |
| kal_bool mcf_compose_ini_item(kal_char *orig_buff, kal_char *new_buff, kal_char *item, kal_char *orig_value, kal_char *value); |
| void mcf_dump_data(kal_bool is_booting, void *p_data, kal_uint32 len); |
| void mcf_write_boot_trace(kal_uint32 trace_enum, ...); |
| void mcf_dump_boot_trace(void); |
| mcf_ota_result_e mcf_write_buffer(kal_char *folder_path, kal_char *file_name, kal_uint8 *buffer, kal_uint32 total_size); |
| 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); |
| 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); |
| 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); |
| kal_uint16 mcf_find_gid_return_lid_num(kal_uint32 gid); |
| kal_uint32 mcf_calc_check_sum(kal_uint32 *ptr, kal_uint32 len); |
| kal_uint32 mcf_check_check_sum(kal_uint32 *ptr, kal_uint32 len); |
| kal_bool mcf_encrypt_128bit(char *password, char *content, kal_uint32 content_length); |
| kal_bool mcf_decrypt_128bit(char *password, char *content, kal_uint32 content_length); |
| kal_bool mcf_encrypt_256bit(char *password, char *content, kal_uint32 content_length); |
| kal_bool mcf_decrypt_256bit(char *password, char *content, kal_uint32 content_length); |
| void mcf_remove_spaces_and_carrier_return(kal_char* src); |
| void mcf_toupper(kal_char* src); |
| kal_int32 mcf_atoi(const void *src); |
| |
| kal_int16 mcf_binary_search_lid(kal_uint16 find_lid, kal_uint16 *lid_arr, kal_uint16 lid_size, kal_uint16 *new_pos); |
| kal_bool mcf_insert_lid(kal_uint16 new_lid, kal_uint16 *lid_arr, kal_uint16 lid_size, kal_uint16 new_pos); |
| #ifdef __MCF_COMBINE_FILE_SUPPORT__ |
| 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); |
| 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); |
| kal_bool mcf_clear_last_modified_lid(nvram_mcf_lid_config_struct *lid_conf, kal_uint16 *lid_size); |
| #endif |
| kal_int8* mcf_bytes_to_hex(const void *bytes, kal_int32 length, kal_bool upperCase, void *hex); |
| kal_int8* mcf_hex_to_bytes(const void *hex, kal_int32 *length, void *bytes); |
| kal_bool mcf_hex_str_reverse(kal_char *str, kal_uint32 length); |
| void mcf_replace_char(kal_char* src, kal_char old_ch, kal_char new_ch); |
| kal_bool mcf_merge_ota_buffer(void *first_buffer, void *second_buffer, void *output_buffer, kal_uint32 output_buffer_size); |
| 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); |
| void mcf_mem_init(void); |
| void *mcf_malloc(unsigned int size); |
| void mcf_free(void *ptr); |
| kal_bool mcf_verify_digest(kal_uint32 digest_tag, mcf_tool_file_info_t *ota_file, mcf_digest *sign); |
| void mcf_dump_important_info(void); |
| void mcf_snprintf(kal_char * str, size_t num, const char * fmt, ...); |
| 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); |
| kal_bool mcf_compare_file_info(mcf_file_info_t *old_file, mcf_file_info_t *new_file); |
| |
| #endif /* __INC_MCF_DEFS_H */ |
| |