| /***************************************************************************** |
| * 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_task.c |
| * |
| * Project: |
| * -------- |
| * UMOLYA |
| * |
| * Description: |
| * ------------ |
| * MD Configuration Framework task implementation. |
| * |
| * 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! |
| * |
| *------------------------------------------------------------------------------ |
| * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| *============================================================================== |
| *******************************************************************************/ |
| |
| #include "kal_public_api.h" |
| #include "syscomp_config.h" |
| #include "nvram_interface.h" |
| |
| #include "mcf_if.h" |
| #include "mcf_util.h" |
| #include "mcf_defs.h" |
| #include "mcf_object.h" |
| #include "mcf_debug.h" |
| |
| /*------------------------------------------------------------------------------ |
| * Global variables. |
| *----------------------------------------------------------------------------*/ |
| extern nvram_ltable_entry_struct logical_data_item_table_mcf[]; |
| |
| /*------------------------------------------------------------------------------ |
| * Helper macro. |
| *----------------------------------------------------------------------------*/ |
| |
| /*------------------------------------------------------------------------------ |
| * Private data structure. |
| *----------------------------------------------------------------------------*/ |
| |
| /*------------------------------------------------------------------------------ |
| * Private variables. |
| *----------------------------------------------------------------------------*/ |
| |
| /*------------------------------------------------------------------------------ |
| * Private fucntions. |
| *----------------------------------------------------------------------------*/ |
| static void mcf_dump_boot_trace_timeout(void *event_hf_param) |
| { |
| if (mcf_timer_eventid_g != NULL) { |
| mcf_timer_eventid_g = NULL; |
| } |
| |
| mcf_dump_boot_trace(); |
| } |
| |
| static void mcf_dump_important_info_timeout(void *event_hf_param) |
| { |
| if (mcf_timer_eventid_g != NULL) { |
| mcf_timer_eventid_g = NULL; |
| } |
| |
| mcf_dump_important_info(); |
| |
| mcf_timer_eventid_g = evshed_set_event_userid(mcf_timer_es_g, |
| mcf_dump_important_info_timeout, |
| NULL, KAL_TICKS_5_SEC_REAL * 6, |
| 2); |
| ASSERT(mcf_timer_eventid_g); |
| } |
| |
| static void mcf_task_main(task_entry_struct *task_entry_ptr) |
| { |
| ilm_struct current_ilm; |
| |
| kal_set_active_module_id(MOD_MCF); |
| kal_mem_set(¤t_ilm, 0, sizeof(ilm_struct)); |
| MCF_BOOT_TRACE(MCF_BOOT_TR_TASK_MAIN_OTA_DURATION, com_Mcf.ota_api_duration); |
| |
| mcf_timer_eventid_g = evshed_set_event_userid(mcf_timer_es_g, |
| mcf_dump_boot_trace_timeout, |
| NULL, KAL_TICKS_5_SEC_REAL * 2, |
| 1); |
| |
| mcf_timer_eventid_g = evshed_set_event_userid(mcf_timer_es_g, |
| mcf_dump_important_info_timeout, |
| NULL, KAL_TICKS_5_SEC_REAL * 6, |
| 2); |
| |
| ASSERT(mcf_timer_eventid_g); |
| |
| while(1) { |
| if (KAL_TRUE == msg_receive_extq(¤t_ilm)) { |
| mcf_on_ilm(¤t_ilm); |
| destroy_ilm(¤t_ilm); |
| } |
| } |
| } |
| |
| static kal_bool mcf_init(void) |
| { |
| mcf_t *pMcf; |
| mcf_ota_file_t *ota_file; |
| mcf_tlvota_file_t *tlvota_file; |
| kal_uint32 i; |
| |
| /* Register MCF nvram LID table */ |
| nvram_ltable_register(logical_data_item_table_mcf); |
| |
| pMcf = mcf_get_instance(); |
| ota_file = &(pMcf->ota_file); |
| kal_mem_set(pMcf, 0, sizeof(mcf_t)); |
| kal_mem_set(&com_Mcf, 0, sizeof(mcf_common_t)); |
| |
| /* enh_mutex init */ |
| ASSERT(!mcf_enhmutex_g); |
| mcf_enhmutex_g = kal_create_enh_mutex(MCF_LOCK_NAME); |
| |
| /* 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]); |
| tlvota_file->sbp_id = SBP_ID_INVALID; |
| 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); |
| |
| #if defined(__MCF_UT_FRAMEWORK_SUPPORT__) |
| /* enh_mutex init */ |
| ASSERT(!mcf_utfwk_enhmutex_g); |
| mcf_utfwk_enhmutex_g = kal_create_enh_mutex(MCF_UTFWK_LOCK_NAME); |
| #endif |
| /* Timer init */ |
| mcf_timer_es_g = evshed_create("MCF_TIMER", MOD_MCF, 0, MAX_DELAY_UNLIMITED); |
| |
| if (mcf_timer_es_g == NULL) { |
| ASSERT(KAL_FALSE); |
| } |
| |
| /* Init boot trace buff ptr */ |
| com_Mcf.boot_trace_buff_ptr = (kal_uint32 *)com_Mcf.boot_trace_buff; |
| |
| return KAL_TRUE; |
| } |
| |
| static kal_bool mcf_reset(void) |
| { |
| mcf_t *pMcf; |
| mcf_ota_file_t *ota_file; |
| mcf_tlvota_file_t *tlvota_file; |
| kal_uint32 i; |
| |
| pMcf = mcf_get_instance(); |
| ota_file = &(pMcf->ota_file); |
| |
| /* Cancel Event */ |
| if (mcf_timer_eventid_g != NULL) { |
| evshed_cancel_event(mcf_timer_es_g, &mcf_timer_eventid_g); |
| } |
| |
| /* Object deinit */ |
| MCF_DEINIT_OBJECT_BEGIN(ota_file, mcf_enhmutex_g); |
| MCF_DEINIT_OBJECT_END(ota_file, mcf_enhmutex_g); |
| |
| for (i = 0; i < MAX_SIM_NUM; i++) { |
| tlvota_file = &(pMcf->tlvota_file[i]); |
| MCF_DEINIT_OBJECT_BEGIN(tlvota_file, mcf_enhmutex_g); |
| MCF_DEINIT_OBJECT_END(tlvota_file, mcf_enhmutex_g); |
| } |
| |
| 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]); |
| tlvota_file->sbp_id = SBP_ID_INVALID; |
| MCF_INIT_OBJECT_BEGIN(tlvota_file, mcf_enhmutex_g); |
| MCF_INIT_OBJECT_END(tlvota_file, mcf_enhmutex_g); |
| } |
| |
| return KAL_TRUE; |
| } |
| |
| /*------------------------------------------------------------------------------ |
| * Public fucntions. |
| *----------------------------------------------------------------------------*/ |
| kal_bool mcf_create(comptask_handler_struct **handle) |
| { |
| static const comptask_handler_struct info = |
| { |
| mcf_task_main, /* task entry function */ |
| mcf_init, /* task initialization function */ |
| mcf_reset, /* task reset handler */ |
| }; |
| |
| *handle = (comptask_handler_struct *)&info; |
| return KAL_TRUE; |
| } |
| |