| /***************************************************************************** |
| * 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) 2006 |
| * |
| * 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: |
| * --------- |
| * nvram_gen_util.c |
| * |
| * Project: |
| * -------- |
| * MAUI |
| * |
| * Description: |
| * ------------ |
| * This file is intends for generating NVRAM information. |
| * |
| * 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! |
| * 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! |
| * 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! |
| * |
| * |
| * 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 NVRAM_NOT_PRESENT |
| /* |
| * Include |
| */ |
| #include <string.h> |
| #include <stdio.h> |
| #include <stdarg.h> |
| #include <stdlib.h> |
| #include <sys/io.h> |
| #include "kal_public_api.h" |
| |
| #include "nvram_auto_gen.h" |
| #if defined(__MMI_FMI__) |
| #include "nvram_user_defs.h" |
| #endif |
| #include "nvram_defs.h" /* NVRAM_MSP_ALIGNMENT_REMAINDER */ |
| #include "custom_nvram_cat.h" |
| #include "custom_nvram_config.h" /* __NVRAM_VENDOR_SUPPORT__ */ |
| #include "nvram_editor_data_item.h" |
| #include "nvram_group_editor.h" //add for break group files from header file |
| #ifdef __NVRAM_PSEUDO_MERGE__ |
| #include "nvram_pseudo_merge.h" |
| #endif |
| |
| #include "nvram_internal.h" |
| |
| #include "custom_nvram_int_config.h" |
| #ifdef __NV_CHKSUM_ENHANCE__ |
| #include "custom_nvram_sec.h" // add ,get checksum type/size. |
| |
| /* CUSTOM_CHK_ALGO_CONFIG configure*/ |
| extern nvram_checksum_config CUSTOM_CHK_ALGO_CONFIG; |
| kal_uint32 get_checksum_size(nvram_ltable_entry_struct* ldi); |
| #endif |
| |
| kal_uint32 custpack_total_to_verify = 0; |
| |
| #ifdef __NVRAM_VENDOR_SUPPORT__ |
| kal_uint32 nvram_vendor_reserve_size = NVRAM_MAX_VENDOR_LID_SIZE; |
| #endif |
| |
| #ifdef __NVRAM_OTP__ |
| kal_uint32 otp_total_to_verify = 0; |
| kal_uint32 otp_size_to_verify = 0; |
| #endif |
| |
| kal_uint32 secupack_total_to_verify = 0; |
| kal_uint32 secupack_size_to_verify = 0; |
| kal_uint16 secupack_idx = 0; |
| |
| #if defined(__NVRAM_SECURE_DATA_STORAGE__) |
| kal_uint32 sds_total_to_verify = 0; |
| kal_uint32 sds_size_to_verify = 0; |
| #endif |
| |
| kal_uint32 nvram_gen_backup_size = 0; |
| kal_uint32 nvram_gen_backup_total = 0; |
| |
| boot_mode_type system_boot_mode; |
| |
| |
| nvram_ltable_entry_struct *logical_data_item_table; |
| |
| kal_uint32 nvram_gen_total_lid; |
| |
| /* Fake free_ilm */ |
| void free_int_ilm(ilm_struct *ilm_ptr, kal_char* file_name, kal_uint32 line) |
| { |
| } |
| |
| #define IS_POWER_OF_2(v) ((v & (v - 1)) == 0) |
| |
| |
| ltable_entry_struct logical_data_item_table_internal[] = |
| { |
| { |
| NVRAM_EF_SYS_LID, |
| NVRAM_EF_SYS_TOTAL, |
| NVRAM_EF_SYS_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_FF_DEFAULT), |
| NVRAM_CATEGORY_IMPORTANT_L1, |
| NVRAM_ATTR_WRITEPROTECT | NVRAM_ATTR_MULTIPLE, |
| "MT00", |
| VER(NVRAM_EF_SYS_LID) |
| }, |
| #ifdef __NVRAM_SUPPORT_CUSTPACK__ |
| { |
| NVRAM_EF_CUSTPACK_VERNO_LID, |
| NVRAM_EF_CUSTPACK_VERNO_TOTAL, |
| NVRAM_EF_CUSTPACK_VERNO_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_INTERNAL, |
| NVRAM_ATTR_WRITEPROTECT | NVRAM_ATTR_AVERAGE, |
| "MT02", |
| VER(NVRAM_EF_CUSTPACK_VERNO_LID) |
| }, |
| #endif |
| { |
| NVRAM_EF_NVRAM_LOCK_LID, |
| NVRAM_EF_NVRAM_LOCK_TOTAL, |
| NVRAM_EF_NVRAM_LOCK_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_FF_DEFAULT), |
| NVRAM_CATEGORY_IMPORTANT, |
| NVRAM_ATTR_WRITEPROTECT | NVRAM_ATTR_CONFIDENTIAL | NVRAM_ATTR_FAULT_ASSERT | NVRAM_ATTR_COMMITTED |
| #ifdef __NVRAM_BIND_TO_CHIP_CIPHER__ |
| | NVRAM_ATTR_MSP | NVRAM_ATTR_MULTIPLE |
| #endif |
| , |
| "NV01", |
| VER(NVRAM_EF_NVRAM_LOCK_LID) |
| }, |
| #ifdef __NVRAM_READ_RESERVED_FILE__ |
| { |
| NVRAM_EF_READ_RESERVED_LID, |
| NVRAM_EF_READ_RESERVED_TOTAL, |
| NVRAM_EF_READ_RESERVED_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_RESERVED, |
| NVRAM_ATTR_AVERAGE, |
| "NONE", |
| VER(NVRAM_EF_READ_RESERVED_LID) |
| }, |
| #endif |
| #ifdef __NVRAM_UNIT_TEST__ |
| { |
| NVRAM_EF_NVRAM_UNIT_TEST_LID, |
| NVRAM_EF_NVRAM_UNIT_TEST_TOTAL, |
| NVRAM_EF_NVRAM_UNIT_TEST_SIZE, |
| NVRAM_NORMAL((const kal_uint8 *)NVRAM_EF_ZERO_DEFAULT), |
| #ifdef __SECURE_DATA_STORAGE__ |
| NVRAM_CATEGORY_INTERNAL, |
| #else |
| NVRAM_CATEGORY_USER, |
| #endif |
| NVRAM_ATTR_AVERAGE, |
| "MT10", |
| VER(NVRAM_EF_NVRAM_UNIT_TEST_LID) |
| }, |
| #endif |
| |
| #if defined (__NVRAM_UT_TEST__) |
| |
| { |
| NVRAM_EF_NVRAM_TEST_1_LID, |
| NVRAM_EF_TEST_LID_RECORD_TOTAL, |
| NVRAM_EF_TEST_LID_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_USER, |
| NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT, |
| "MTT1", |
| VER(NVRAM_EF_NVRAM_TEST_1_LID) |
| }, |
| |
| { |
| NVRAM_EF_NVRAM_TEST_2_LID, |
| NVRAM_EF_TEST_LID_RECORD_TOTAL, |
| NVRAM_EF_TEST_LID_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_INTERNAL, |
| NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT, |
| "MTT2", |
| VER(NVRAM_EF_NVRAM_TEST_2_LID) |
| }, |
| |
| { |
| NVRAM_EF_NVRAM_TEST_3_LID, |
| NVRAM_EF_TEST_LID_RECORD_TOTAL, |
| NVRAM_EF_TEST_LID_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_CALIBRAT, |
| NVRAM_ATTR_AVERAGE, |
| "MTT3", |
| VER(NVRAM_EF_NVRAM_TEST_3_LID) |
| }, |
| |
| { |
| NVRAM_EF_NVRAM_TEST_4_LID, |
| NVRAM_EF_TEST_LID_RECORD_TOTAL, |
| NVRAM_EF_TEST_LID_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_IMPORTANT, |
| NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT |
| #if defined (__CCCIFS_SUPPORT__) |
| | NVRAM_ATTR_COMMITTED |
| #endif |
| , |
| "MTT4", |
| VER(NVRAM_EF_NVRAM_TEST_4_LID) |
| }, |
| |
| { |
| NVRAM_EF_NVRAM_TEST_5_LID, |
| NVRAM_EF_TEST_LID_RECORD_TOTAL, |
| NVRAM_EF_TEST_LID_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_IMPORTANT_L1, |
| NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT, |
| "MTT5", |
| VER(NVRAM_EF_NVRAM_TEST_5_LID) |
| }, |
| |
| { |
| NVRAM_EF_NVRAM_TEST_6_LID, |
| NVRAM_EF_TEST_LID_RECORD_TOTAL, |
| NVRAM_EF_TEST_LID_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_IMPORTANT_L4, |
| NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT | NVRAM_ATTR_CHKSUM_INTEGRATE |
| #if defined (__CCCIFS_SUPPORT__) |
| | NVRAM_ATTR_COMMITTED |
| #endif |
| , |
| "MTT6", |
| VER(NVRAM_EF_NVRAM_TEST_6_LID) |
| }, |
| |
| { |
| NVRAM_EF_NVRAM_TEST_7_LID, |
| 1, //NVRAM_EF_TEST_LID_RECORD_TOTAL, |
| NVRAM_EF_TEST_LID_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_CALIBRAT, |
| NVRAM_ATTR_AVERAGE | NVRAM_ATTR_RAW_DATA, |
| "MTT7", |
| VER(NVRAM_EF_NVRAM_TEST_7_LID) |
| }, |
| |
| { |
| NVRAM_EF_NVRAM_TEST_8_LID, |
| NVRAM_EF_TEST_8_LID_RECORD_TOTAL, |
| NVRAM_EF_TEST_8_LID_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_USER, |
| NVRAM_ATTR_AVERAGE | NVRAM_ATTR_CHKSUM_INTEGRATE, |
| "MTT8", |
| VER(NVRAM_EF_NVRAM_TEST_8_LID) |
| }, |
| { |
| NVRAM_EF_NVRAM_TEST_9_LID, |
| NVRAM_EF_TEST_LID_RECORD_TOTAL, |
| NVRAM_EF_TEST_LID_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_USER, |
| NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT | NVRAM_ATTR_MCF_OTA_FOR_QUERY, |
| "MTT9", |
| VER(NVRAM_EF_NVRAM_TEST_9_LID) |
| }, |
| { |
| NVRAM_EF_NVRAM_TEST_10_LID, |
| NVRAM_EF_TEST_LID_RECORD_TOTAL, |
| NVRAM_EF_TEST_LID_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_USER, |
| NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT | NVRAM_ATTR_MCF_OTA_BY_OP, |
| "MTTA", |
| VER(NVRAM_EF_NVRAM_TEST_10_LID) |
| }, |
| { |
| NVRAM_EF_NVRAM_TEST_11_LID, |
| NVRAM_EF_TEST_LID_RECORD_TOTAL, |
| NVRAM_EF_TEST_LID_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_USER, |
| NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT | NVRAM_ATTR_MCF_OTA | NVRAM_ATTR_MCF_OTA_BY_OP, |
| "MTTB", |
| VER(NVRAM_EF_NVRAM_TEST_11_LID) |
| }, |
| { |
| NVRAM_EF_NVRAM_TEST_12_LID, |
| NVRAM_EF_TEST_LID_RECORD_TOTAL, |
| NVRAM_EF_TEST_LID_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_USER, |
| NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT | NVRAM_ATTR_MCF_OTA, |
| "MTTC", |
| VER(NVRAM_EF_NVRAM_TEST_12_LID) |
| }, |
| { |
| NVRAM_EF_INTERNAL_13_LID, |
| NVRAM_EF_TEST_13_LID_RECORD_TOTAL, |
| NVRAM_EF_TEST_13_LID_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_IMPORTANT_L1, |
| NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT, |
| "MTTD", |
| VER(NVRAM_EF_INTERNAL_13_LID) |
| }, |
| { |
| NVRAM_EF_INTERNAL_TEST_14_LID, |
| NVRAM_EF_TEST_14_LID_RECORD_TOTAL, |
| NVRAM_EF_TEST_14_LID_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_USER, |
| NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT, |
| "MTTE", |
| VER(NVRAM_EF_INTERNAL_TEST_14_LID) |
| }, |
| { |
| NVRAM_EF_INTERNAL_TEST_16_LID, |
| NVRAM_EF_INTERNAL_TEST_16_LID_RECORD_TOTAL, |
| NVRAM_EF_INTERNAL_TEST_16_LID_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_CALIBRAT, |
| NVRAM_ATTR_AVERAGE | NVRAM_ATTR_CHKSUM_INTEGRATE | NVRAM_ATTR_FAULT_ASSERT, |
| "MTTG", |
| VER(NVRAM_EF_INTERNAL_TEST_16_LID) |
| }, |
| { |
| NVRAM_EF_INTERNAL_TEST_17_LID, |
| NVRAM_EF_TEST_LID_RECORD_TOTAL, |
| NVRAM_EF_TEST_LID_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_USER, |
| NVRAM_ATTR_AVERAGE | NVRAM_ATTR_MULTIPLE, |
| "MTTH", |
| VER(NVRAM_EF_INTERNAL_TEST_17_LID) |
| }, |
| #endif |
| |
| #if defined(__NVRAM_STRUCTURE_CHANGE_RESET__) || defined(__NVRAM_DEFVAL_CHANGE_RESET__) |
| { |
| NVRAM_EF_CHKSUM_RESET_REC_LID, |
| NVRAM_EF_CHKSUM_RESET_REC_LID_TOTAL, |
| NVRAM_EF_CHKSUM_RESET_REC_SIZE, |
| NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT), |
| NVRAM_CATEGORY_INTERNAL, |
| NVRAM_ATTR_AVERAGE, |
| "MTCR", //NVRAM check sum reset |
| VER(NVRAM_EF_CHKSUM_RESET_REC_LID) |
| }, |
| #endif |
| |
| }; |
| |
| /***************************************************************************** |
| * FUNCTION |
| * nvram_gen_assign_entry |
| * DESCRIPTION |
| * construct table |
| * PARAMETERS |
| * position [IN] |
| * ldi [IN] |
| * RETURNS |
| * none |
| *****************************************************************************/ |
| void nvram_gen_assign_entry(nvram_ltable_entry_struct* ldi) |
| { |
| /*----------------------------------------------------------------*/ |
| /* Local Variables */ |
| /*----------------------------------------------------------------*/ |
| kal_int32 value; |
| kal_uint32 section_size; |
| |
| kal_uint32 tbl_idx = 0, entry_idx = 0; |
| kal_uint32 nvram_checksum_size = 0; |
| |
| /*----------------------------------------------------------------*/ |
| /* Code Body */ |
| /*----------------------------------------------------------------*/ |
| |
| #ifdef __NV_CHKSUM_ENHANCE__ |
| nvram_checksum_size = get_checksum_size(ldi); // get nvram_checksum_size , read CUSTOM_CHK_ALGO_CONFIG. |
| #else |
| nvram_checksum_size = NVRAM_CHKSUM_SIZE; |
| #endif |
| |
| /* Step 1: Adjust attr / Category |
| Step 2: Verify |
| Step 3: Statistics */ |
| |
| //Tool check begin: nvram_pre_gen.pl check if it is same as nvram_assign_table_entry() and nvram_gen_assign_entry() |
| //*************************************************************************** |
| // Adjust Attr/Category I |
| // Do not need multiple attribute if nvram saved on nor flash |
| //*************************************************************************** |
| if( (ldi->total_records < 2) && ( (ldi->attr & NVRAM_ATTR_MULTIREC_READ) || (ldi->attr & NVRAM_ATTR_MULTI_DEFAULT))) |
| { |
| fprintf(stderr, |
| "Can't Set the NVRAM_ATTR_MULTIREC_READ or NVRAM_ATTR_MULTI_DEFAULT for the lid with only one record, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| |
| if (ldi->default_value == (kal_uint8 const*)NVRAM_EF_FF_DEFAULT || |
| ldi->default_value == (kal_uint8 const*)NVRAM_EF_ZERO_DEFAULT) |
| { |
| #if defined (__NVRAM_UT_TEST__) |
| // Don't remove test lid gen default attribute |
| if(ldi->LID < NVRAM_EF_NVRAM_UNIT_TEST_LID || ldi->LID > NVRAM_EF_NVRAM_UNIT_TEST_LID_END) |
| #endif |
| if((ldi->attr & NVRAM_ATTR_GEN_DEFAULT) && !(NVRAM_IS_CATEGORY_IMPORTANT_L4(ldi->category))) |
| { |
| fprintf(stderr, |
| "Can't Set the NVRAM_ATTR_GEN_DEFAULT for the lid with Zero or FF default value, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| } |
| |
| if(NVRAM_IS_CATEGORY_IMPORTANT_L4(ldi->category) && !(ldi->attr & NVRAM_ATTR_GEN_DEFAULT)) |
| { |
| fprintf(stderr, |
| "Must Set the NVRAM_ATTR_GEN_DEFAULT for L4 Category LID, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| |
| //*************************************************************************** |
| // Adjust Attr/Category II |
| // MULTIPLE / BACKUP_RAW / BACKUP_FAT are mutually exclusive |
| //*************************************************************************** |
| if (NVRAM_IS_CATEGORY_CALIBRAT(ldi->category)) |
| { |
| if((ldi->attr &NVRAM_ATTR_RESERVE_BACKWARD) || (ldi->attr &NVRAM_ATTR_MULTIPLE)) |
| { |
| fprintf(stderr, |
| "Can't Set NVRAM_ATTR_MULTIPLE/NVRAM_ATTR_RESERVE_BACKWARD for Calibrate Lid, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| #if defined(__NVRAM_BACKUP_DISK_FAT__) |
| |
| if((ldi->attr & NVRAM_ATTR_MULTIPLE) || (ldi->attr & NVRAM_ATTR_BACKUP_RAW)) |
| { |
| fprintf(stderr, |
| "Can't Set the NVRAM_ATTR_MULTIPLE/NVRAM_ATTR_BACKUP_RAW for Calibrat, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| if((ldi->attr & NVRAM_ATTR_BACKUP_FAT) == 0) |
| { |
| fprintf(stderr, |
| "Should set the NVRAM_ATTR_BACKUP_FAT for Calibrat, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| |
| #elif defined(__NVRAM_BACKUP_DISK_RAW__) |
| if((ldi->attr & NVRAM_ATTR_MULTIPLE) || (ldi->attr & NVRAM_ATTR_BACKUP_FAT)) |
| { |
| fprintf(stderr, |
| "Can't Set the NVRAM_ATTR_MULTIPLE/NVRAM_ATTR_BACKUP_FAT for Calibrat, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| if((ldi->attr & NVRAM_ATTR_BACKUP_RAW) == 0) |
| { |
| fprintf(stderr, |
| "Should set the NVRAM_ATTR_BACKUP_RAW for Calibrat, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| #else |
| #if !defined(__LOW_COST_SUPPORT_COMMON__) && !defined(__CCCIFS_SUPPORT__) && !defined(__FS_RAMDISK__) |
| if((ldi->attr & NVRAM_ATTR_MULTIPLE) == 0) |
| { |
| fprintf(stderr, |
| "Should set the NVRAM_ATTR_MULTIPLE for Calibrat under this scenario, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| #endif |
| if((ldi->attr & NVRAM_ATTR_BACKUP_RAW) || (ldi->attr & NVRAM_ATTR_BACKUP_FAT)) |
| { |
| fprintf(stderr, |
| "Can't Set the NVRAM_ATTR_BACKUP_RAW/NVRAM_ATTR_BACKUP_FAT for Calibrat, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| #endif |
| } |
| |
| //*************************************************************************** |
| // Adjust Attr/Category III |
| // Just apply to smartphone |
| // 1: When AP side clean boot, nvram will reset all lid |
| // 2: When Modern side restore factory, nvram only reset data item in NVD_DATA |
| // and don't care about data item in folder A & B |
| // 3: So, turn off NVRAM_CATEGORY_FACTORY |
| //*************************************************************************** |
| #if defined(__CCCIFS_SUPPORT__) |
| if (NVRAM_IS_CATEGORY_IMPORTANT(ldi->category) || NVRAM_IS_CATEGORY_IMPORTANT_L4(ldi->category)) |
| { |
| if((ldi->attr & NVRAM_ATTR_RESERVE_BACKWARD)) |
| { |
| fprintf(stderr, |
| "Can't Set the NVRAM_ATTR_RESERVE_BACKWARD for Important/Impotant_L4, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| if((ldi->attr & NVRAM_ATTR_COMMITTED) == 0) |
| { |
| fprintf(stderr, |
| "Suggest Set the NVRAM_ATTR_COMMITTED for Important/Impotant_L4, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| } |
| #endif |
| |
| //*************************************************************************** |
| // Adjust Attr/Category IV |
| // OTP category cannot use with many attribute together. Because it cannot be reset |
| // OTP category also cannot use with other category together. |
| //*************************************************************************** |
| #ifdef __NVRAM_OTP__ |
| if (NVRAM_IS_CATEGORY_OTP(ldi->category)) |
| { |
| if( (ldi->attr & NVRAM_ATTR_WRITEPROTECT) || (ldi->attr & NVRAM_ATTR_MULTIPLE) || (ldi->attr & NVRAM_ATTR_MSP) || (ldi->attr & NVRAM_ATTR_OTA_RESET) ) |
| { |
| fprintf(stderr, |
| "Can't Set NVRAM_ATTR_WRITEPROTECT/NVRAM_ATTR_MULTIPLE/NVRAM_ATTR_MSP/NVRAM_ATTR_OTA_RESET for OTP, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| } |
| #endif |
| |
| //*************************************************************************** |
| // Adjust Attr/Category V |
| // Add pseudo merge attribute |
| //*************************************************************************** |
| /* Record data item will be restored (end) */ |
| #ifdef __NVRAM_PSEUDO_MERGE__ |
| if (!NVRAM_IS_CATEGORY_INTERNAL(ldi->category) && |
| !NVRAM_IS_CATEGORY_SECUPACK(ldi->category) && |
| !NVRAM_IS_CATEGORY_IMPORTANT(ldi->category) && |
| !NVRAM_IS_CATEGORY_CALIBRAT(ldi->category) && |
| #ifdef __NVRAM_CUSTOM_SENSITIVE__ |
| !NVRAM_IS_CATEGORY_CUSTOM_SENSITIVE(ldi->category) && |
| #endif |
| #ifdef __NVRAM_CUSTOM_DISK__ |
| !NVRAM_IS_CATEGORY_CUSTOM_DISK(ldi->category) && |
| #endif |
| ((ldi->size + nvram_checksum_size) * ldi->total_records < NVRAM_CLUSTER_SIZE)) |
| { |
| if((ldi->attr & NVRAM_ATTR_PACKAGE) == 0) |
| { |
| fprintf(stderr, |
| "Should set the NVRAM_ATTR_PACKAGE for this lid %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| } |
| |
| if (NVRAM_IS_ATTR_PACKAGE(ldi->attr)) |
| { |
| ldi->description = NULL; |
| if( (ldi->attr & NVRAM_ATTR_MULTIPLE) || (ldi->attr & NVRAM_ATTR_MSP)) |
| { |
| fprintf(stderr, |
| "Can't Set NVRAM_ATTR_MULTIPLE/NVRAM_ATTR_MSP for PACKAGE Lid, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| } |
| #endif |
| |
| //*************************************************************************** |
| // Adjust Attr/Category VI |
| // Add MSP, confidential, multiple with secupack item |
| //*************************************************************************** |
| |
| if (NVRAM_IS_CATEGORY_SECUPACK(ldi->category)) |
| { |
| if(!(ldi->attr & NVRAM_ATTR_CONFIDENTIAL) |
| #ifdef __NVRAM_BIND_TO_CHIP_CIPHER__ |
| || !(ldi->attr & NVRAM_ATTR_MSP) |
| #endif |
| ) |
| { |
| fprintf(stderr, |
| "Should set the NVRAM_ATTR_MSP/NVRAM_ATTR_CONFIDENTIAL, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| } |
| |
| //*************************************************************************** |
| // Adjust Attr/Category VII |
| // Add MSP, confidential, multiple with custom sensitve data |
| //*************************************************************************** |
| |
| #ifdef __NVRAM_CUSTOM_SENSITIVE__ |
| if (NVRAM_IS_CATEGORY_CUSTOM_SENSITIVE(ldi->category)) |
| { |
| if( !(ldi->attr & NVRAM_ATTR_MSP) || !(ldi->attr & NVRAM_ATTR_CONFIDENTIAL) || !(ldi->attr & NVRAM_ATTR_MULTIPLE)) |
| { |
| fprintf(stderr, |
| "Should Set the NVRAM_ATTR_MSP/NVRAM_ATTR_CONFIDENTIAL/NVRAM_ATTR_MULTIPLE, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| } |
| #endif |
| |
| //*************************************************************************** |
| // Adjust Attr/Category |
| // Simulation/Palladium/FPGA remove NVRAM_ATTR_GEN_DEFAULT |
| //*************************************************************************** |
| #if defined(_SIMULATION) || defined(__PALLADIUM__) || defined(__FPGA__) |
| if (!NVRAM_IS_CATEGORY_INTERNAL(ldi->category)) |
| { |
| ldi->attr &= ~(NVRAM_ATTR_GEN_DEFAULT); |
| } |
| #endif |
| |
| //*************************************************************************** |
| // Adjust Attr/Category VIII |
| // remove all attribute if the data is in custom disk |
| //*************************************************************************** |
| #ifdef __NVRAM_CUSTOM_DISK__ |
| if (NVRAM_IS_CATEGORY_CUSTOM_DISK(ldi->category)) |
| { |
| if(ldi->attr != NVRAM_ATTR_AVERAGE) |
| { |
| fprintf(stderr, |
| "Can't set other attribute except NVRAM_ATTR_AVERAGE, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| } |
| #endif |
| |
| //*************************************************************************** |
| // Adjust Attr/Category X |
| // 1. Compress the data in MT table and it is in custpack |
| // 2. Compress the default value of the data not in MT table |
| // and its default value is not zero default or ff default |
| // coppress function had phaseout |
| //*************************************************************************** |
| |
| //*************************************************************************** |
| // Adjust Attr/Category XI |
| // Put Internal, Calibration, Important data into SDS |
| //*************************************************************************** |
| #if defined(__NVRAM_SECURE_DATA_STORAGE__) |
| if (NVRAM_IS_CATEGORY_INTERNAL(ldi->category) || |
| NVRAM_IS_CATEGORY_CALIBRAT(ldi->category) || |
| NVRAM_IS_CATEGORY_IMPORTANT(ldi->category) || |
| NVRAM_IS_CATEGORY_IMPORTANT_L4(ldi->category)) |
| { |
| ldi->category |= NVRAM_CATEGORY_BACKUP_SDS; |
| |
| ldi->attr &= ~ NVRAM_ATTR_MULTIPLE; |
| ldi->attr &= ~ NVRAM_ATTR_RING; |
| ldi->attr &= ~ NVRAM_ATTR_PACKAGE; |
| ldi->attr &= ~ NVRAM_ATTR_BACKUP_FAT; |
| ldi->attr &= ~ NVRAM_ATTR_BACKUP_RAW; |
| } |
| #endif |
| //Tool check end: nvram_pre_gen.pl |
| |
| //*************************************************************************** |
| // Check I |
| // cannot put the data into two categories that are mutually exclusive |
| //*************************************************************************** |
| |
| value = (ldi->category & |
| (NVRAM_CATEGORY_INTERNAL |
| | NVRAM_CATEGORY_CALIBRAT |
| | NVRAM_CATEGORY_IMPORTANT |
| | NVRAM_CATEGORY_IMPORTANT_L4 |
| | NVRAM_CATEGORY_IMPORTANT_L1 |
| #ifdef __NVRAM_CUSTOM_SENSITIVE__ |
| | NVRAM_CATEGORY_CUSTOM_SENSITIVE |
| #endif |
| #ifdef __NVRAM_CUSTOM_DISK__ |
| | NVRAM_CATEGORY_CUSTOM_DISK |
| #endif |
| )); |
| |
| /* check if value is power of 2 */ |
| if (!IS_POWER_OF_2(value)) |
| { |
| fprintf(stderr, |
| "Category inernal & calibrate & important & sensitive can't be used at the same time!, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| |
| } |
| |
| |
| //*************************************************************************** |
| // Check II |
| // cannot put the sds data with custom |
| //*************************************************************************** |
| #if defined(__NVRAM_SECURE_DATA_STORAGE__) |
| if (NVRAM_IS_CATEGORY_BACKUP_SDS(ldi->category)) |
| { |
| if (NVRAM_IS_CATEGORY_CUSTOM_SENSITIVE(ldi->category) || |
| NVRAM_IS_CATEGORY_CUSTOM_DISK(ldi->category) || |
| NVRAM_IS_CATEGORY_OTP(ldi->category)) |
| { |
| fprintf(stderr,"Error: Sds use with wrong category LID:%s Desc:%s category %d\n", |
| ldi->str_LID, ldi->str_LID, ldi->category); |
| |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| |
| if ((ldi->attr & NVRAM_ATTR_MULTIPLE) || |
| (ldi->attr & NVRAM_ATTR_RING) || |
| (ldi->attr & NVRAM_ATTR_PACKAGE) || |
| (ldi->attr & NVRAM_ATTR_BACKUP_FAT) || |
| (ldi->attr & NVRAM_ATTR_BACKUP_RAW)) |
| { |
| fprintf(stderr,"Error: Sds use with wrong attribute LID:%s Desc:%s attribute %d\n", |
| ldi->str_LID, ldi->str_LID, ldi->attr); |
| |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| |
| |
| #ifdef __NVRAM_BIND_TO_CHIP_CIPHER__ |
| if (ldi->attr & NVRAM_ATTR_MSP) |
| { |
| /* 16 byte alignment */ |
| section_size = ldi->size + nvram_checksum_size + NVRAM_MSP_ALIGNMENT_REMAINDER(ldi->size + nvram_checksum_size); |
| } |
| else |
| #endif |
| { |
| section_size = ldi->size + nvram_checksum_size; |
| } |
| |
| if (section_size * ldi->total_records > NVRAM_CUSTOM_CFG_MAX_RECORD_SIZE) |
| { |
| fprintf(stderr,"Error: Data is too large to put into sds LID:%s Desc:%s %d %d\n", |
| ldi->str_LID, ldi->str_LID, ldi->size, ldi->total_records); |
| |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| } |
| #endif |
| |
| |
| //*************************************************************************** |
| // Check (III) |
| // Cannot use zero default or ff default with multi default |
| //*************************************************************************** |
| |
| if (ldi->attr & NVRAM_ATTR_MULTI_DEFAULT) |
| { |
| if (strcmp(ldi->str_default_value, "NVRAM_EF_ZERO_DEFAULT") == 0 || |
| strcmp(ldi->str_default_value, "NVRAM_EF_FF_DEFAULT") == 0) |
| { |
| fprintf(stderr, |
| "Cannot set ZERO_DEFAULT or FF_DEFAULT with multi_default!, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); |
| } |
| } |
| |
| //*************************************************************************** |
| // Check (IV) |
| // The record size cannot bigger than the biggest control buffer |
| //*************************************************************************** |
| #ifndef __NVRAM_LARGE_RECORD_SIZE__ |
| |
| #ifdef __NVRAM_BIND_TO_CHIP_CIPHER__ |
| if (ldi->attr & NVRAM_ATTR_MSP) |
| { |
| /* 16 byte alignment */ |
| section_size = ldi->size + nvram_checksum_size + NVRAM_MSP_ALIGNMENT_REMAINDER(ldi->size + nvram_checksum_size); |
| } |
| else |
| #endif |
| { |
| section_size = ldi->size + nvram_checksum_size; |
| } |
| |
| |
| |
| if (section_size > NVRAM_CUSTOM_CFG_MAX_RECORD_SIZE) |
| { |
| fprintf(stderr, |
| "LID Size is too big!, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); |
| } |
| #endif |
| |
| //*************************************************************************** |
| // Check V |
| // Items in custpack cannot use zero default or ff default as the default value |
| //*************************************************************************** |
| if (NVRAM_IS_CATEGORY_CUSTPACK(ldi->category)) |
| { |
| if (strcmp(ldi->str_default_value, "NVRAM_EF_ZERO_DEFAULT") == 0 || |
| strcmp(ldi->str_default_value, "NVRAM_EF_FF_DEFAULT") == 0) |
| { |
| fprintf(stderr, |
| "Cannot set ZERO_DEFAULT or FF_DEFAULT with custpack!, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); |
| |
| } |
| } |
| |
| //*************************************************************************** |
| // Check VI |
| // Build error check: CALIBRAT LID should not have NVRAM_ATTR_OTA_RESET attribute. |
| //*************************************************************************** |
| if (NVRAM_IS_CATEGORY_CALIBRAT(ldi->category) && (ldi->attr&NVRAM_ATTR_OTA_RESET)) |
| { |
| fprintf(stderr, |
| "Error usage: NVRAM_ATTR_SW_VERNO_REST and NVRAM_CATEGORY_CALIBRAT should not use together!, %d, %s\n", ldi->LID, ldi->str_LID); |
| exit(3); |
| |
| } |
| |
| //*************************************************************************** |
| // Statistics I |
| // calculate the custpack |
| //*************************************************************************** |
| if (NVRAM_IS_CATEGORY_CUSTPACK(ldi->category)) |
| { |
| custpack_total_to_verify++; |
| } |
| //*************************************************************************** |
| // Statistics II |
| // calculate the secupack |
| //*************************************************************************** |
| |
| if (NVRAM_IS_CATEGORY_SECUPACK(ldi->category)) |
| { |
| secupack_total_to_verify++; |
| |
| if (ldi->attr & NVRAM_ATTR_MULTI_DEFAULT) |
| { |
| secupack_size_to_verify += ldi->size * ldi->total_records + nvram_checksum_size; |
| } |
| else |
| { |
| secupack_size_to_verify += ldi->size + nvram_checksum_size; |
| } |
| } |
| |
| //*************************************************************************** |
| // Statistics III |
| // calculate the otp |
| //*************************************************************************** |
| #ifdef __NVRAM_OTP__ |
| if (NVRAM_IS_CATEGORY_OTP(ldi->category)) |
| { |
| otp_total_to_verify++; |
| otp_size_to_verify += ldi->size * ldi->total_records; |
| } |
| #endif /* __NVRAM_OTP__ */ |
| |
| |
| //*************************************************************************** |
| // Statistics IV |
| // calculate the vendor reserve size |
| //*************************************************************************** |
| |
| #ifdef __NVRAM_VENDOR_SUPPORT__ |
| if (is_customregion) |
| { |
| kal_uint32 section_size = ldi->size * ldi->total_records + nvram_checksum_size; |
| if (section_size < nvram_vendor_reserve_size) |
| { |
| nvram_vendor_reserve_size -= section_size; |
| } |
| else |
| { |
| fprintf(stderr, |
| "My dear, total size for vendor nvram shouldn't be larger than %d!\n", NVRAM_MAX_VENDOR_LID_SIZE); |
| exit(3); /* NVRAM_EXIT_CODE_ERROR */ |
| } |
| } |
| #endif /* __NVRAM_VENDOR_SUPPORT__ */ |
| |
| //*************************************************************************** |
| // Statistics IV |
| // calculate the vendor reserve size |
| //*************************************************************************** |
| #if defined(__NVRAM_SECURE_DATA_STORAGE__) |
| if (NVRAM_IS_CATEGORY_BACKUP_SDS(ldi->category)) |
| { |
| sds_total_to_verify++; |
| sds_size_to_verify += (ldi->size + nvram_checksum_size + NVRAM_MSP_ALIGNMENT_REMAINDER(ldi->size + nvram_checksum_size)) * ldi->total_records; |
| } |
| #endif |
| |
| } |
| |
| /***************************************************************************** |
| * FUNCTION |
| * nvram_assign_cat_entry |
| * DESCRIPTION |
| * PARAMETERS |
| * RETURNS |
| *****************************************************************************/ |
| static void nvram_gen_assign_cat_default_value(nvram_lid_enum position, nvram_cat_replace_setting* cat_item) |
| { |
| /*----------------------------------------------------------------*/ |
| /* Local Variables */ |
| /*----------------------------------------------------------------*/ |
| |
| /*----------------------------------------------------------------*/ |
| /* Code Body */ |
| /*----------------------------------------------------------------*/ |
| |
| if (cat_item->size != logical_data_item_table[position].size || |
| cat_item->total_records != logical_data_item_table[position].total_records) |
| { |
| return; |
| } |
| |
| logical_data_item_table[position].default_value = cat_item->default_value; |
| |
| if (cat_item->is_multi_default) |
| { |
| logical_data_item_table[position].attr &= NVRAM_ATTR_MULTI_DEFAULT; |
| } |
| else |
| { |
| logical_data_item_table[position].attr &= ~NVRAM_ATTR_MULTI_DEFAULT; |
| } |
| } |
| |
| int ltable_enum_cmp_local(nvram_ltable_entry_struct *ent_a, nvram_ltable_entry_struct *ent_b) |
| { |
| return (int)(ent_a->LID - ent_b->LID); |
| } |
| |
| /***************************************************************************** |
| * FUNCTION |
| * nvram_gen_construct_ltable |
| * DESCRIPTION |
| * To construct ltable. |
| * PARAMETERS |
| * None |
| * RETURNS |
| * None |
| *****************************************************************************/ |
| void nvram_gen_construct_ltable(void) |
| { |
| /*----------------------------------------------------------------*/ |
| /* Local Variables */ |
| /*----------------------------------------------------------------*/ |
| extern unsigned char nvram_ltable_begin, nvram_ltable_end; |
| kal_uint32 i = 0, tbl_idx = 0, tbl_size; |
| nvram_ltable_entry_struct *logical_data_item_table_bak; |
| size_t tbl_entry_size = sizeof(nvram_ltable_entry_struct); |
| |
| /*----------------------------------------------------------------*/ |
| /* Code Body */ |
| /*----------------------------------------------------------------*/ |
| |
| logical_data_item_table_bak = (nvram_ltable_entry_struct *)&nvram_ltable_begin; |
| tbl_size = (kal_uint32)(&nvram_ltable_end - &nvram_ltable_begin); |
| nvram_gen_total_lid = tbl_size/sizeof(nvram_ltable_entry_struct); |
| logical_data_item_table = (nvram_ltable_entry_struct *) malloc(tbl_size); |
| memcpy(logical_data_item_table, logical_data_item_table_bak, tbl_size); |
| qsort(logical_data_item_table, nvram_gen_total_lid, tbl_entry_size, ltable_enum_cmp_local); |
| printf("addr = %x, entry size: %d, real size: %d %s result size:%d\n", logical_data_item_table, sizeof(nvram_ltable_entry_struct), tbl_size, tbl_size%sizeof(nvram_ltable_entry_struct)?"!=":"=",nvram_gen_total_lid * sizeof(nvram_ltable_entry_struct)); |
| |
| do |
| { |
| printf("ltable[%d](0x%x) = %s(%d), size = %d, total_records = %d\n", |
| i, &logical_data_item_table[i], logical_data_item_table[i].str_LID, logical_data_item_table[i].LID, logical_data_item_table[i].size, logical_data_item_table[i].total_records); |
| |
| nvram_gen_assign_entry(&logical_data_item_table[i]); |
| |
| }while(++i < nvram_gen_total_lid); |
| |
| #if 0 |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| /* under construction !*/ |
| #endif |
| } |
| |
| /***************************************************************************** |
| * FUNCTION |
| * nvram_gen_search_entry |
| * DESCRIPTION |
| * To construct ltable. |
| * PARAMETERS |
| * None |
| * RETURNS |
| * None |
| *****************************************************************************/ |
| nvram_ltable_entry_struct* nvram_gen_search_entry(nvram_lid_enum lid) |
| { |
| /*----------------------------------------------------------------*/ |
| /* Local Variables */ |
| /*----------------------------------------------------------------*/ |
| kal_uint32 i = 0; |
| |
| /*----------------------------------------------------------------*/ |
| /* Code Body */ |
| /*----------------------------------------------------------------*/ |
| do |
| { |
| if (logical_data_item_table[i].LID == lid) |
| { |
| return &logical_data_item_table[i]; |
| } |
| |
| }while(++i < nvram_gen_total_lid); |
| |
| return NULL; |
| } |
| |
| |
| #endif /* NVRAM_NOT_PRESENT */ |