rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [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) 2005 |
| 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 | * |
| 38 | * Filename: |
| 39 | * --------- |
| 40 | * nvram_ut_test.c |
| 41 | * |
| 42 | * Author: |
| 43 | * ------- |
| 44 | * ------- |
| 45 | * |
| 46 | ****************************************************************************/ |
| 47 | #if defined (__NVRAM_UT_TEST__) |
| 48 | |
| 49 | |
| 50 | #include "nvram_main.h" |
| 51 | #include "nvram_interface.h" |
| 52 | #include "nvram_struct.h" |
| 53 | #include "nvram_msgid.h" |
| 54 | #include "nvram_io.h" |
| 55 | #include "syscomp_config.h" |
| 56 | #include "svc_sap.h" |
| 57 | #include "nvram_editor_data_item.h" |
| 58 | #include "nvram_group_editor.h" //add for break group files from header file |
| 59 | #include "us_timer.h" |
| 60 | #include "tst_sap.h" |
| 61 | #include "tst_msgid.h" |
| 62 | #include "math.h" |
| 63 | #include "stdlib.h" |
| 64 | |
| 65 | #ifdef __NVRAM_LID_CACHE__ |
| 66 | #include "nvram_cache_interface.h" |
| 67 | #endif |
| 68 | |
| 69 | #include "ex_public.h" |
| 70 | |
| 71 | #define nvram_ut_trace(...) kal_prompt_trace(MOD_NVRAM, __VA_ARGS__) |
| 72 | #define NVRAM_MAX_OP_BUFFER_SIZE 63*1024 |
| 73 | #define NVRAM_EF_SW_VERNO_LID NVRAM_EF_SYS_LID |
| 74 | #define SW_VERNO_RECORD_NUMBER 1 |
| 75 | #define RECORD_CHANGE_SIZE 2 |
| 76 | |
| 77 | |
| 78 | /* |
| 79 | 2 is an error number |
| 80 | this define is used to make meesage and external API return back value agreement |
| 81 | External API: KAL_TRUE: success, KAL_FALSE: fail |
| 82 | Message: 0: success, others: fail |
| 83 | */ |
| 84 | #define agreement_return_value(value) \ |
| 85 | if(KAL_TRUE == value)\ |
| 86 | value = NVRAM_ERRNO_SUCCESS;\ |
| 87 | else\ |
| 88 | value = 0x2\ |
| 89 | |
| 90 | typedef kal_bool (*ut_testcase_fn_ptr)(kal_uint32 flags, void *param); |
| 91 | typedef struct |
| 92 | { |
| 93 | ut_testcase_fn_ptr _main_fn; |
| 94 | kal_uint32 flags; |
| 95 | void *para; |
| 96 | kal_char *description; |
| 97 | kal_char *testplan_section; |
| 98 | }ut_testcase_struct; |
| 99 | |
| 100 | typedef struct |
| 101 | { |
| 102 | kal_uint32 test_case_lst[10][20]; |
| 103 | kal_uint8 break_test_case_num; //user may set test case list as: 2.1 2.2 2.3 |
| 104 | kal_uint8 sub_test_case_num; //test may break at 2.2.1.1, and this is sub case of 2.2 |
| 105 | kal_uint8 valid_test_case_num_total; |
| 106 | kal_uint8 context_is_valid; //mark whether this log is valid |
| 107 | kal_uint32 tst_time_consume; |
| 108 | kal_uint32 total_case_number; |
| 109 | kal_uint32 fail_case_number; |
| 110 | }factory_test_context_struct; |
| 111 | |
| 112 | typedef struct |
| 113 | { |
| 114 | kal_uint32 start_record_size; //from start_record_size to end_record_size will full cover |
| 115 | kal_uint32 end_record_size; |
| 116 | }record_size_boundary_struct; |
| 117 | |
| 118 | typedef struct |
| 119 | { |
| 120 | kal_uint32 start_record_number; //from start_record_size to end_record_size will full cover |
| 121 | kal_uint32 end_record_number; |
| 122 | }record_number_boundary_struct; |
| 123 | |
| 124 | |
| 125 | kal_uint32 test_lid_enum[]= |
| 126 | { |
| 127 | NVRAM_EF_NVRAM_TEST_1_LID, |
| 128 | NVRAM_EF_NVRAM_TEST_2_LID, |
| 129 | NVRAM_EF_NVRAM_TEST_3_LID, |
| 130 | NVRAM_EF_NVRAM_TEST_4_LID, |
| 131 | NVRAM_EF_NVRAM_TEST_5_LID, |
| 132 | NVRAM_EF_NVRAM_TEST_6_LID, |
| 133 | }; |
| 134 | |
| 135 | #ifdef __NVRAM_LID_CACHE__ |
| 136 | kal_uint32 cache_test_lid_enum[]= |
| 137 | { |
| 138 | NVRAM_EF_INTERNAL_13_LID, |
| 139 | NVRAM_EF_INTERNAL_TEST_14_LID, |
| 140 | NVRAM_EF_INTERNAL_TEST_16_LID, |
| 141 | }; |
| 142 | kal_uint8 cache_test_lid_number = sizeof(cache_test_lid_enum)/sizeof(kal_uint32); |
| 143 | #endif |
| 144 | |
| 145 | // __NVRAM_ENHANCE_CHKSUM_ALGORITHM__ |
| 146 | #ifdef __NV_CHKSUM_ENHANCE__ |
| 147 | kal_uint32 chksum_algo_test_lid_list[] = |
| 148 | { |
| 149 | NVRAM_EF_NVRAM_TEST_1_LID, |
| 150 | NVRAM_EF_NVRAM_TEST_2_LID, |
| 151 | NVRAM_EF_NVRAM_TEST_3_LID, //calibrate |
| 152 | NVRAM_EF_NVRAM_TEST_4_LID, //important |
| 153 | NVRAM_EF_NVRAM_TEST_5_LID, |
| 154 | NVRAM_EF_NVRAM_TEST_6_LID, |
| 155 | NVRAM_EF_NVRAM_TEST_8_LID, |
| 156 | NVRAM_EF_INTERNAL_TEST_14_LID, |
| 157 | NVRAM_EF_INTERNAL_TEST_16_LID, //calibrate |
| 158 | NVRAM_EF_INTERNAL_TEST_17_LID, |
| 159 | }; |
| 160 | |
| 161 | kal_uint32 chksum_algo_normal_list[] = |
| 162 | { |
| 163 | NVRAM_EF_NVRAM_TEST_1_LID, |
| 164 | NVRAM_EF_NVRAM_TEST_2_LID, |
| 165 | NVRAM_EF_NVRAM_TEST_5_LID, |
| 166 | NVRAM_EF_NVRAM_TEST_6_LID, |
| 167 | NVRAM_EF_NVRAM_TEST_8_LID, |
| 168 | NVRAM_EF_INTERNAL_13_LID, |
| 169 | NVRAM_EF_INTERNAL_TEST_17_LID |
| 170 | }; |
| 171 | |
| 172 | kal_uint32 chksum_algo_special_list[] = |
| 173 | { |
| 174 | NVRAM_EF_NVRAM_TEST_3_LID, |
| 175 | NVRAM_EF_NVRAM_TEST_4_LID, |
| 176 | NVRAM_EF_INTERNAL_TEST_16_LID |
| 177 | }; |
| 178 | |
| 179 | kal_uint8 chksum_algo_test_lid_number = sizeof(chksum_algo_test_lid_list)/sizeof(kal_uint32); |
| 180 | kal_uint8 chksum_algo_normal_len = sizeof(chksum_algo_normal_list)/ sizeof(kal_uint32); |
| 181 | kal_uint8 chksum_algo_special_len = sizeof(chksum_algo_special_list)/sizeof(kal_uint32); |
| 182 | #endif |
| 183 | // ------ |
| 184 | |
| 185 | kal_uint8 test_case_list[10][20]; |
| 186 | kal_uint8 valid_test_case_num; |
| 187 | kal_uint8 is_clean_boot_test; |
| 188 | kal_taskid nvram_test_task1_id; |
| 189 | kal_uint8 is_insulation_access; |
| 190 | kal_uint32 nvram_ut_assert_flag; |
| 191 | kal_uint8 factory_test_reboot_finish; //factory reset will reboot SP, this flag is used for mark reboot finish |
| 192 | kal_uint8 manual_ota_reboot_finish; |
| 193 | kal_uint8 test_number, sub_test_number; //mark test which test case is runing |
| 194 | kal_uint32 nvram_boot_trace; |
| 195 | kal_uint8 test_lid_number = sizeof(test_lid_enum)/sizeof(kal_uint32); |
| 196 | //-------------------------------------------------------------------------------------------------------------------- |
| 197 | //kal_uint32 data_buffer[NVRAM_EF_TEST_LID_RECORD_TOTAL*NVRAM_EF_TEST_LID_SIZE/4 + 256]; //test LID total size + 4KB |
| 198 | //kal_uint32 cmp_buffer[NVRAM_EF_TEST_LID_RECORD_TOTAL*NVRAM_EF_TEST_LID_SIZE/4 + 256]; |
| 199 | #define NVRAM_UT_BUFFER_SIZE (70 * 1024) |
| 200 | kal_uint8 large_buffer[NVRAM_UT_BUFFER_SIZE]; // large buffer is for RAW data test, shared with data_buffer & cmp_buffer |
| 201 | kal_uint32 *data_buffer = (kal_uint32*)large_buffer; |
| 202 | kal_uint32 *cmp_buffer = (kal_uint32*)(large_buffer + (NVRAM_EF_TEST_LID_RECORD_TOTAL*NVRAM_EF_TEST_LID_SIZE + 8192)); |
| 203 | #ifdef __NV_CHKSUM_ENHANCE__ |
| 204 | nvram_checksum_config chksum_config_backup; // |
| 205 | #endif |
| 206 | |
| 207 | typedef unsigned int nvram_large_buffer_check[NVRAM_UT_BUFFER_SIZE - 2*(NVRAM_EF_TEST_LID_RECORD_TOTAL*NVRAM_EF_TEST_LID_SIZE + 4096)]; |
| 208 | //-------------------------------------------------------------------------------------------------------------------- |
| 209 | kal_uint32 fail_case_num, total_case_num; |
| 210 | kal_uint32 start_test_time, end_test_time, test_time_consume; |
| 211 | kal_uint8 const table_default[NVRAM_EF_TEST_LID_RECORD_TOTAL][NVRAM_EF_TEST_LID_SIZE] = { |
| 212 | {0x01, }, |
| 213 | {0x02, }, |
| 214 | {0x03, }, |
| 215 | {0x04, }, |
| 216 | {0x05, }, |
| 217 | {0x06, }, |
| 218 | {0x07, }, |
| 219 | {0x08, }, |
| 220 | {0x09, }, |
| 221 | {0x0A, }, |
| 222 | }; |
| 223 | |
| 224 | extern void SST_Secure_Algo(kal_uint8 Direction, kal_uint32 ContentAddr, |
| 225 | kal_uint32 ContentLen, kal_uint8 *CustomSeed, |
| 226 | kal_uint8 *ResText); |
| 227 | extern kal_bool nvram_external_read_chksum_8b(nvram_lid_enum LID, kal_uint16 rec_index, kal_uint16 rec_amount, kal_uint8 *buffer, kal_uint32 buffer_size); |
| 228 | extern module_type stack_get_active_module_id( void ); |
| 229 | extern void nvram_internal_test_fun_default_value(nvram_lid_enum file_id, kal_uint8 *buffer, kal_uint16 buffer_size); |
| 230 | extern kal_mutexid g_nvram_fs_mutex; |
| 231 | |
| 232 | extern nvram_ee_info_type* nvram_ee_info; |
| 233 | extern kal_char nvram_trace_dump_temp_buffer[]; |
| 234 | extern kal_char nvram_trace_dump_buffer[]; |
| 235 | extern kal_mutexid g_nvram_dump_trace_mutex; |
| 236 | extern kal_wchar nvram_trace_filename[]; |
| 237 | extern FS_HANDLE nvram_trace_file_hdl; |
| 238 | extern kal_uint32 nvram_trace_dump_buffer_offset; |
| 239 | #ifdef __NV_CHKSUM_ENHANCE__ |
| 240 | extern nvram_algo_info *chksum_algo_ptr; |
| 241 | extern nvram_checksum_config NVRAM_CHK_CONFIG; |
| 242 | #endif |
| 243 | |
| 244 | |
| 245 | |
| 246 | #ifdef __NVRAM_LID_CACHE__ |
| 247 | kal_bool check_lid_all_record_is_undirty_bit(nvram_ltable_entry_struct* ldi); |
| 248 | kal_bool check_lid_all_record_is_invalid_bit(nvram_ltable_entry_struct* ldi); |
| 249 | kal_bool unmask_lid_all_record_valid_bit(nvram_ltable_entry_struct* ldi); |
| 250 | kal_bool unmask_lid_all_record_dirty_bit(nvram_ltable_entry_struct* ldi); |
| 251 | kal_bool check_lid_all_record_is_valid_bit(nvram_ltable_entry_struct* ldi); |
| 252 | kal_bool check_lid_all_record_is_dirty_bit(nvram_ltable_entry_struct* ldi); |
| 253 | #endif |
| 254 | |
| 255 | void nvram_ut_get_default_value(nvram_lid_core_enum lid, kal_uint8 *buffer, kal_uint16 buffer_size) |
| 256 | { |
| 257 | kal_mem_set(buffer, 0x55, buffer_size); |
| 258 | } |
| 259 | |
| 260 | /* |
| 261 | For factory reset, we want to the LIDs backup to binregion is not default value. |
| 262 | So this function will be called at nvram_init() end to modify the LID value. |
| 263 | */ |
| 264 | kal_bool nvram_write_test_lids() |
| 265 | { |
| 266 | kal_uint8 i, j; |
| 267 | nvram_ltable_entry_struct *ldi = NULL; |
| 268 | |
| 269 | kal_mem_set(data_buffer, 0, NVRAM_EF_TEST_LID_SIZE); |
| 270 | data_buffer[0] = 0x1; //modify one data |
| 271 | |
| 272 | for(i = 0; i < test_lid_number; i++) |
| 273 | { |
| 274 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 275 | for(j = 1; j <= NVRAM_EF_TEST_LID_RECORD_TOTAL; j++) |
| 276 | { |
| 277 | if(!nvram_external_write_data(ldi->LID, j, (kal_uint8 *)data_buffer, ldi->size)) |
| 278 | { |
| 279 | return KAL_FALSE; |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | for(i = 0; i < cache_test_lid_number; i++) |
| 284 | { |
| 285 | nvram_util_get_data_item(&ldi, cache_test_lid_enum[i]); |
| 286 | nvram_ut_trace("[NVUT] %s()ldi->LID:%x LID->attr=(%x) default_attr\n\r", __FUNCTION__, ldi->LID, ldi->attr); |
| 287 | for(j = 1; j <= ldi->total_records; j++) |
| 288 | { |
| 289 | kal_mem_set(data_buffer, 0, ldi->size); |
| 290 | data_buffer[0] = j; |
| 291 | if(!nvram_external_write_data(ldi->LID, j, (kal_uint8 *)data_buffer, ldi->size)) |
| 292 | { |
| 293 | return KAL_FALSE; |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | return KAL_TRUE; |
| 299 | |
| 300 | } |
| 301 | |
| 302 | /* |
| 303 | Description: nvram_lid_cmpt_operation is used to merge several LID operations together and return result. |
| 304 | Parameters: |
| 305 | LID: LID enum value |
| 306 | operation_flag: this is 32-bit parameter and each 8-bit stand one kind of operation, parsing will start from high 8-bit -> low 8-bit |
| 307 | 0x1: reset, 0x2: read(just read API return success), 0x3: write, 0x4: read(read back default value)--------0x01020300 stands do reset, read, write one by one |
| 308 | access_way: by message or external API |
| 309 | 0x1: external API, 0x2: message |
| 310 | Return Value: |
| 311 | return value is a 32-bit vaule and each 8-bit respond to the operation_flag result. |
| 312 | 0x0: success, 0x1: fail--------0x00000000 stands all the operations are success |
| 313 | Important Note: |
| 314 | To simple the flow, this API make some assue: if send a message to NVRAM to read/write/reset, |
| 315 | the next message in the task extq we assue it is the result of the last operation. |
| 316 | */ |
| 317 | #define CMPT_OP_FLAG_NULL 0x0 |
| 318 | #define CMPT_OP_FLAG_RESET 0x1 |
| 319 | #define CMPT_OP_FLAG_READ 0x2 |
| 320 | #define CMPT_OP_FLAG_WRITE 0x3 |
| 321 | #define CMPT_OP_FLAG_READBACK 0x4 |
| 322 | #define CMPT_OP_FLAG_SET_LOCK 0x5 |
| 323 | #define CMPT_OP_FLAG_SET_UNLOCK 0x6 |
| 324 | |
| 325 | #define CMPT_OP_WAY_API 0x1 |
| 326 | #define CMPT_OP_WAY_MSG 0x2 |
| 327 | |
| 328 | #define CMPT_OP_FLAG_GEN(v1, v2, v3, v4) ((v1 << 24) | (v2 << 16) | (v3 << 8) | v4) |
| 329 | |
| 330 | kal_uint32 nvram_lid_cmpt_op_push(kal_uint32 value, kal_uint8 operation_flag) |
| 331 | { |
| 332 | value <<= 8; |
| 333 | value |= (operation_flag & 0xFF); |
| 334 | return value; |
| 335 | } |
| 336 | |
| 337 | kal_uint32 nvram_lid_cmpt_op_pop(kal_uint32 value, kal_uint8 *operation_flag) |
| 338 | { |
| 339 | *operation_flag = (value >> 24); |
| 340 | return (value << 8); |
| 341 | } |
| 342 | |
| 343 | kal_uint32 nvram_lid_cmpt_operation(nvram_lid_enum LID, kal_uint32 operation_flag, kal_uint8 access_way, kal_uint32 start_record, kal_uint32 end_record) |
| 344 | { |
| 345 | nvram_ltable_entry_struct *ldi = NULL; |
| 346 | kal_uint32 temp_result = 0, final_result = 0, i; |
| 347 | kal_uint8 *d_buffer, *c_buffer; |
| 348 | nvram_reset_req_struct *reset_req; |
| 349 | nvram_reset_cnf_struct *nvram_reset_cnf; |
| 350 | nvram_read_req_struct *read_req; |
| 351 | nvram_read_cnf_struct *nvram_read_cnf; |
| 352 | nvram_write_req_struct *write_req; |
| 353 | nvram_write_cnf_struct *nvram_write_cnf; |
| 354 | nvram_set_lock_req_struct *nvram_set_lock_req; |
| 355 | nvram_set_lock_cnf_struct *nvram_set_lock_cnf; |
| 356 | kal_uint8 *pdu_write_buffer; |
| 357 | ilm_struct current_ilm; |
| 358 | kal_uint8 op_val; |
| 359 | |
| 360 | if((access_way != CMPT_OP_WAY_API) && (access_way != CMPT_OP_WAY_MSG)) |
| 361 | { |
| 362 | return 0xFFFFFFFF; |
| 363 | } |
| 364 | |
| 365 | if(!NVRAM_IS_LID_VALID(LID)) |
| 366 | { |
| 367 | return 0x0FFFFFFF; |
| 368 | } |
| 369 | nvram_util_get_data_item(&ldi, LID); |
| 370 | |
| 371 | if(start_record < 1 || start_record > ldi->total_records) |
| 372 | { |
| 373 | return 0xFF0FFFFF; |
| 374 | } |
| 375 | |
| 376 | if(end_record < 1 || end_record > ldi->total_records) |
| 377 | { |
| 378 | return 0xFFF0FFFF; |
| 379 | } |
| 380 | |
| 381 | if(ldi->size > NVRAM_MAX_OP_BUFFER_SIZE) |
| 382 | { |
| 383 | return 0xF0FFFFFF; |
| 384 | } |
| 385 | |
| 386 | do |
| 387 | { |
| 388 | operation_flag = nvram_lid_cmpt_op_pop(operation_flag, &op_val); |
| 389 | switch(op_val) |
| 390 | { |
| 391 | case CMPT_OP_FLAG_RESET: //reset |
| 392 | #ifdef __NVRAM_LID_CACHE__ |
| 393 | if (check_nvram_cache_ready()) |
| 394 | { |
| 395 | while(check_lid_all_record_is_undirty_bit(ldi) != KAL_TRUE) |
| 396 | { |
| 397 | } |
| 398 | } |
| 399 | #endif |
| 400 | if(CMPT_OP_WAY_API == access_way) //external API |
| 401 | { |
| 402 | temp_result = nvram_external_reset_data(ldi->LID, start_record, end_record-start_record+1); |
| 403 | agreement_return_value(temp_result); |
| 404 | } |
| 405 | else if(CMPT_OP_WAY_MSG == access_way) //message |
| 406 | { |
| 407 | reset_req = (nvram_reset_req_struct *)construct_local_para(sizeof(nvram_reset_req_struct), TD_CTRL); |
| 408 | reset_req->ref_count = 1; |
| 409 | reset_req->LID = ldi->LID; |
| 410 | reset_req->rec_index = start_record; |
| 411 | reset_req->rec_amount = end_record-start_record+1; |
| 412 | reset_req->reset_category = NVRAM_RESET_CERTAIN; |
| 413 | reset_req->app_id = NVRAM_APP_RESERVED; |
| 414 | |
| 415 | msg_send6(kal_get_active_module_id(), MOD_NVRAM, PS_NVRAM_SAP, MSG_ID_NVRAM_RESET_REQ, |
| 416 | (local_para_struct*)reset_req, NULL); |
| 417 | msg_receive_extq(¤t_ilm); |
| 418 | nvram_reset_cnf = (nvram_reset_cnf_struct*)current_ilm.local_para_ptr; |
| 419 | temp_result = nvram_reset_cnf->result; //NVRAM_ERRNO_SUCCESS(0) stands success |
| 420 | destroy_ilm(¤t_ilm); |
| 421 | } |
| 422 | |
| 423 | if(NVRAM_ERRNO_SUCCESS == temp_result) |
| 424 | { |
| 425 | d_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 426 | c_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 427 | for(i = start_record; i <= end_record; i++) |
| 428 | { |
| 429 | kal_mem_set(d_buffer, 0, ldi->size); |
| 430 | kal_mem_set(c_buffer, 0, ldi->size); |
| 431 | nvram_get_default_value_to_write(ldi, i, c_buffer, ldi->size); |
| 432 | temp_result = nvram_external_read_data(ldi->LID, i, d_buffer, ldi->size); |
| 433 | agreement_return_value(temp_result); |
| 434 | if(NVRAM_ERRNO_SUCCESS == temp_result) |
| 435 | { |
| 436 | /*if buffer data is the same kal_mem_cmp will return 0 (NVRAM_ERRNO_SUCCESS)*/ |
| 437 | temp_result = kal_mem_cmp((kal_char*)d_buffer, (kal_char*)c_buffer, ldi->size); |
| 438 | } |
| 439 | else |
| 440 | { |
| 441 | nvram_ut_trace("[NVUT] nvram_lid_cmpt_operation(): reset-read fail!\n\r"); |
| 442 | } |
| 443 | |
| 444 | if(NVRAM_ERRNO_SUCCESS != temp_result) |
| 445 | { |
| 446 | nvram_ut_trace("[NVUT] nvram_lid_cmpt_operation(): reset-read is not default value!\n\r"); |
| 447 | break; |
| 448 | } |
| 449 | } |
| 450 | free_ctrl_buffer(d_buffer); |
| 451 | free_ctrl_buffer(c_buffer); |
| 452 | d_buffer = NULL; |
| 453 | c_buffer = NULL; |
| 454 | } |
| 455 | else |
| 456 | { |
| 457 | nvram_ut_trace("[NVUT] nvram_lid_cmpt_operation(): reset-reset fail!\n\r"); |
| 458 | } |
| 459 | break; |
| 460 | |
| 461 | case CMPT_OP_FLAG_READ: //read |
| 462 | if(CMPT_OP_WAY_API == access_way) //external API |
| 463 | { |
| 464 | d_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 465 | kal_mem_set(d_buffer, 0, ldi->size); |
| 466 | /*for read operation we just judge return value, if it is NVRAM_ERRNO_SUCCESS, we assue it success*/ |
| 467 | for(i = start_record; i <= end_record; i++) |
| 468 | { |
| 469 | temp_result = nvram_external_read_data(ldi->LID, i, d_buffer, ldi->size); |
| 470 | agreement_return_value(temp_result); |
| 471 | if(NVRAM_ERRNO_SUCCESS != temp_result) |
| 472 | { |
| 473 | nvram_ut_trace("[NVUT] nvram_lid_cmpt_operation(): api_read-read fail!\n\r"); |
| 474 | break; |
| 475 | } |
| 476 | } |
| 477 | free_ctrl_buffer(d_buffer); |
| 478 | } |
| 479 | else if(CMPT_OP_WAY_MSG == access_way) //message |
| 480 | { |
| 481 | for(i = start_record; i <= end_record; i++) |
| 482 | { |
| 483 | read_req = (nvram_read_req_struct *)construct_local_para(sizeof(nvram_read_req_struct), TD_CTRL); |
| 484 | read_req->ref_count = 1; |
| 485 | read_req->file_idx = ldi->LID; |
| 486 | read_req->para = i; |
| 487 | read_req->rec_amount = 1; |
| 488 | msg_send6(kal_get_active_module_id(), MOD_NVRAM, PS_NVRAM_SAP, MSG_ID_NVRAM_READ_REQ, |
| 489 | (local_para_struct*)read_req, NULL); |
| 490 | msg_receive_extq(¤t_ilm); |
| 491 | nvram_read_cnf = (nvram_read_cnf_struct*)current_ilm.local_para_ptr; |
| 492 | temp_result = nvram_read_cnf->result; //NVRAM_ERRNO_SUCCESS(0) stands success |
| 493 | destroy_ilm(¤t_ilm); |
| 494 | if(NVRAM_ERRNO_SUCCESS != temp_result) |
| 495 | { |
| 496 | nvram_ut_trace("[NVUT] nvram_lid_cmpt_operation(): msg_read-read fail!\n\r"); |
| 497 | break; |
| 498 | } |
| 499 | } |
| 500 | } |
| 501 | break; |
| 502 | |
| 503 | case CMPT_OP_FLAG_WRITE: //write |
| 504 | if(CMPT_OP_WAY_API == access_way) //external API |
| 505 | { |
| 506 | d_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 507 | kal_mem_set(d_buffer, 0, ldi->size); |
| 508 | d_buffer[0] = 0x1; //modify some data |
| 509 | if(ldi->size >= 3) |
| 510 | { |
| 511 | d_buffer[1] = 0x2; |
| 512 | d_buffer[2] = 0x3; |
| 513 | } |
| 514 | for(i = start_record; i <= end_record; i++) |
| 515 | { |
| 516 | temp_result = nvram_external_write_data(ldi->LID, i, d_buffer, ldi->size); |
| 517 | agreement_return_value(temp_result); |
| 518 | if(NVRAM_ERRNO_SUCCESS != temp_result) |
| 519 | { |
| 520 | nvram_ut_trace("[NVUT] nvram_lid_cmpt_operation(): api_write-write fail!\n\r"); |
| 521 | break; |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | if(NVRAM_ERRNO_SUCCESS == temp_result) |
| 526 | { |
| 527 | c_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 528 | for(i = start_record; i <= end_record; i++) |
| 529 | { |
| 530 | kal_mem_set(c_buffer, 0, ldi->size); |
| 531 | temp_result = nvram_external_read_data(ldi->LID, i, c_buffer, ldi->size); |
| 532 | agreement_return_value(temp_result); |
| 533 | if(NVRAM_ERRNO_SUCCESS == temp_result) |
| 534 | { |
| 535 | /*if buffer data is the same kal_mem_cmp will return 0 (NVRAM_ERRNO_SUCCESS)*/ |
| 536 | temp_result = kal_mem_cmp((kal_char*)d_buffer, (kal_char*)c_buffer, ldi->size); |
| 537 | } |
| 538 | else |
| 539 | { |
| 540 | nvram_ut_trace("[NVUT] nvram_lid_cmpt_operation(): api_write-read fail!\n\r"); |
| 541 | } |
| 542 | |
| 543 | if(NVRAM_ERRNO_SUCCESS != temp_result) |
| 544 | { |
| 545 | nvram_ut_trace("[NVUT] nvram_lid_cmpt_operation(): api_write-read back is not expect!\n\r"); |
| 546 | break; |
| 547 | } |
| 548 | } |
| 549 | free_ctrl_buffer(d_buffer); |
| 550 | free_ctrl_buffer(c_buffer); |
| 551 | d_buffer = NULL; |
| 552 | c_buffer = NULL; |
| 553 | } |
| 554 | else |
| 555 | { |
| 556 | free_ctrl_buffer(d_buffer); |
| 557 | d_buffer = NULL; |
| 558 | } |
| 559 | } |
| 560 | else if(CMPT_OP_WAY_MSG == access_way) //message |
| 561 | { |
| 562 | d_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 563 | kal_mem_set(d_buffer, 0, ldi->size); |
| 564 | d_buffer[0] = 0x1; //make some modify |
| 565 | if(ldi->size >= 3) |
| 566 | { |
| 567 | d_buffer[1] = 0x2; |
| 568 | d_buffer[2] = 0x3; |
| 569 | } |
| 570 | for(i = start_record; i <= end_record; i++) |
| 571 | { |
| 572 | write_req = (nvram_write_req_struct *)construct_local_para(sizeof(nvram_write_req_struct), TD_CTRL); |
| 573 | pdu_write_buffer = (kal_uint8 *)construct_peer_buff(ldi->size, 0, 0, TD_CTRL); |
| 574 | kal_mem_cpy(get_peer_buff_pdu((peer_buff_struct*)pdu_write_buffer, 0), d_buffer, ldi->size); |
| 575 | write_req->ref_count = 1; |
| 576 | write_req->file_idx = ldi->LID; |
| 577 | write_req->para = i; |
| 578 | msg_send6(kal_get_active_module_id(), MOD_NVRAM, PS_NVRAM_SAP, MSG_ID_NVRAM_WRITE_REQ, |
| 579 | (local_para_struct*)write_req, (peer_buff_struct*)pdu_write_buffer); |
| 580 | msg_receive_extq(¤t_ilm); |
| 581 | nvram_write_cnf = (nvram_write_cnf_struct*)current_ilm.local_para_ptr; |
| 582 | temp_result = nvram_write_cnf->result; //NVRAM_ERRNO_SUCCESS(0) stands success |
| 583 | destroy_ilm(¤t_ilm); |
| 584 | if(NVRAM_ERRNO_SUCCESS != temp_result) |
| 585 | { |
| 586 | nvram_ut_trace("[NVUT] nvram_lid_cmpt_operation(): msg_write-write fail!\n\r"); |
| 587 | break; |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | if(NVRAM_ERRNO_SUCCESS == temp_result) |
| 592 | { |
| 593 | c_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 594 | for(i = start_record; i <= end_record; i++) |
| 595 | { |
| 596 | kal_mem_set(c_buffer, 0, ldi->size); |
| 597 | temp_result = nvram_external_read_data(ldi->LID, i, c_buffer, ldi->size); |
| 598 | agreement_return_value(temp_result); |
| 599 | if(NVRAM_ERRNO_SUCCESS == temp_result) |
| 600 | { |
| 601 | /*if buffer data is the same kal_mem_cmp will return 0 (NVRAM_ERRNO_SUCCESS)*/ |
| 602 | temp_result = kal_mem_cmp((kal_char*)d_buffer, (kal_char*)c_buffer, ldi->size); |
| 603 | } |
| 604 | else |
| 605 | { |
| 606 | nvram_ut_trace("[NVUT] nvram_lid_cmpt_operation(): msg_write-read fail!\n\r"); |
| 607 | } |
| 608 | if(NVRAM_ERRNO_SUCCESS != temp_result) |
| 609 | { |
| 610 | nvram_ut_trace("[NVUT] nvram_lid_cmpt_operation(): msg_write-read is not expect!\n\r"); |
| 611 | break; |
| 612 | } |
| 613 | } |
| 614 | free_ctrl_buffer(d_buffer); |
| 615 | free_ctrl_buffer(c_buffer); |
| 616 | d_buffer = NULL; |
| 617 | c_buffer = NULL; |
| 618 | } |
| 619 | else |
| 620 | { |
| 621 | free_ctrl_buffer(d_buffer); |
| 622 | d_buffer = NULL; |
| 623 | } |
| 624 | } |
| 625 | break; |
| 626 | |
| 627 | case CMPT_OP_FLAG_READBACK: //read back default value |
| 628 | if(CMPT_OP_WAY_API == access_way) //external API |
| 629 | { |
| 630 | d_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 631 | c_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 632 | /*for read operation we just judge return value, if it is NVRAM_ERRNO_SUCCESS, we assue it success*/ |
| 633 | for(i = start_record; i <= end_record; i++) |
| 634 | { |
| 635 | kal_mem_set(d_buffer, 0, ldi->size); |
| 636 | kal_mem_set(c_buffer, 0, ldi->size); |
| 637 | temp_result = nvram_external_read_data(ldi->LID, i, d_buffer, ldi->size); |
| 638 | agreement_return_value(temp_result); |
| 639 | if(NVRAM_ERRNO_SUCCESS != temp_result) |
| 640 | { |
| 641 | nvram_ut_trace("[NVUT] nvram_lid_cmpt_operation(): api_dread-read fail!\n\r"); |
| 642 | break; |
| 643 | } |
| 644 | |
| 645 | nvram_get_default_value_to_write(ldi, i, c_buffer, ldi->size); |
| 646 | temp_result = kal_mem_cmp(c_buffer, d_buffer, ldi->size); |
| 647 | if(0 != temp_result) |
| 648 | { |
| 649 | nvram_ut_trace("[NVUT] nvram_lid_cmpt_operation(): api_dread-read back is not default value!\n\r"); |
| 650 | break; |
| 651 | } |
| 652 | } |
| 653 | free_ctrl_buffer(d_buffer); |
| 654 | free_ctrl_buffer(c_buffer); |
| 655 | d_buffer = NULL; |
| 656 | c_buffer = NULL; |
| 657 | } |
| 658 | else if(CMPT_OP_WAY_MSG == access_way) //message |
| 659 | { |
| 660 | c_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 661 | for(i = start_record; i <= end_record; i++) |
| 662 | { |
| 663 | read_req = (nvram_read_req_struct *)construct_local_para(sizeof(nvram_read_req_struct), TD_CTRL); |
| 664 | read_req->ref_count = 1; |
| 665 | read_req->file_idx = ldi->LID; |
| 666 | read_req->para = i; |
| 667 | read_req->rec_amount = 1; |
| 668 | msg_send6(kal_get_active_module_id(), MOD_NVRAM, PS_NVRAM_SAP, MSG_ID_NVRAM_READ_REQ, |
| 669 | (local_para_struct*)read_req, NULL); |
| 670 | msg_receive_extq(¤t_ilm); |
| 671 | nvram_read_cnf = (nvram_read_cnf_struct*)current_ilm.local_para_ptr; |
| 672 | temp_result = nvram_read_cnf->result; //NVRAM_ERRNO_SUCCESS(0) stands success |
| 673 | if(NVRAM_ERRNO_SUCCESS != temp_result) |
| 674 | { |
| 675 | nvram_ut_trace("[NVUT] nvram_lid_cmpt_operation(): msg_dread-read fail!\n\r"); |
| 676 | break; |
| 677 | } |
| 678 | kal_mem_set(c_buffer, 0, ldi->size); |
| 679 | nvram_get_default_value_to_write(ldi, i, c_buffer, ldi->size); |
| 680 | temp_result = kal_mem_cmp(c_buffer, |
| 681 | get_peer_buff_pdu((peer_buff_struct*)current_ilm.peer_buff_ptr, 0), |
| 682 | ldi->size); |
| 683 | destroy_ilm(¤t_ilm); |
| 684 | if(0 != temp_result) |
| 685 | { |
| 686 | nvram_ut_trace("[NVUT] nvram_lid_cmpt_operation(): msg_dread-read back is not defalut value!\n\r"); |
| 687 | break; |
| 688 | } |
| 689 | } |
| 690 | free_ctrl_buffer(c_buffer); |
| 691 | c_buffer = NULL; |
| 692 | } |
| 693 | break; |
| 694 | case CMPT_OP_FLAG_SET_LOCK: |
| 695 | if(CMPT_OP_WAY_MSG == access_way) //message |
| 696 | { |
| 697 | nvram_set_lock_req = (nvram_set_lock_req_struct *)construct_local_para(sizeof(nvram_set_lock_req_struct), TD_CTRL); |
| 698 | nvram_set_lock_req->lock_en = NVRAM_LOCK_ENABLE; |
| 699 | msg_send6(kal_get_active_module_id(), MOD_NVRAM, PS_NVRAM_SAP, MSG_ID_NVRAM_SET_LOCK_REQ, |
| 700 | (local_para_struct*)nvram_set_lock_req, NULL); |
| 701 | msg_receive_extq(¤t_ilm); |
| 702 | nvram_set_lock_cnf = (nvram_set_lock_cnf_struct*)current_ilm.local_para_ptr; |
| 703 | temp_result = nvram_set_lock_cnf->result; //NVRAM_ERRNO_SUCCESS(0) stands success |
| 704 | destroy_ilm(¤t_ilm); |
| 705 | } |
| 706 | break; |
| 707 | case CMPT_OP_FLAG_SET_UNLOCK: |
| 708 | if(CMPT_OP_WAY_MSG == access_way) //message |
| 709 | { |
| 710 | nvram_set_lock_req = (nvram_set_lock_req_struct *)construct_local_para(sizeof(nvram_set_lock_req_struct), TD_CTRL); |
| 711 | nvram_set_lock_req->lock_en = NVRAM_LOCK_DISABLE; |
| 712 | msg_send6(kal_get_active_module_id(), MOD_NVRAM, PS_NVRAM_SAP, MSG_ID_NVRAM_SET_LOCK_REQ, |
| 713 | (local_para_struct*)nvram_set_lock_req, NULL); |
| 714 | msg_receive_extq(¤t_ilm); |
| 715 | nvram_set_lock_cnf = (nvram_set_lock_cnf_struct*)current_ilm.local_para_ptr; |
| 716 | temp_result = nvram_set_lock_cnf->result; //NVRAM_ERRNO_SUCCESS(0) stands success |
| 717 | destroy_ilm(¤t_ilm); |
| 718 | } |
| 719 | break; |
| 720 | default: |
| 721 | break; |
| 722 | } |
| 723 | final_result = nvram_lid_cmpt_op_push(final_result, temp_result); |
| 724 | |
| 725 | }while(operation_flag != CMPT_OP_FLAG_NULL); |
| 726 | |
| 727 | return final_result; |
| 728 | |
| 729 | } |
| 730 | |
| 731 | |
| 732 | /* |
| 733 | This function is used to reset the NVRAM UT test LIDs to default seetings. |
| 734 | Default settings value please refer to test plan. |
| 735 | Input: |
| 736 | One of NVRAM_EF_NVRAM_TEST_1_LID~NVRAM_EF_NVRAM_TEST_6_LID |
| 737 | Output: |
| 738 | KAL_TRUE: success |
| 739 | KAL_FALSE: fail |
| 740 | */ |
| 741 | extern kal_uint8 NVRAM_EF_TEST_8_DEFAULT[NVRAM_EF_TEST_8_LID_RECORD_TOTAL][NVRAM_EF_TEST_8_LID_SIZE]; |
| 742 | kal_bool reset_test_lid_default_setting(nvram_lid_enum LID) |
| 743 | { |
| 744 | nvram_ltable_entry_struct *ldi = NULL; |
| 745 | |
| 746 | if(!NVRAM_IS_LID_VALID(LID)) |
| 747 | { |
| 748 | return KAL_FALSE; |
| 749 | } |
| 750 | nvram_util_get_data_item(&ldi, LID); |
| 751 | |
| 752 | switch(ldi->LID) |
| 753 | { |
| 754 | case NVRAM_EF_NVRAM_TEST_1_LID: |
| 755 | ldi->category = NVRAM_CATEGORY_USER; |
| 756 | ldi->attr = NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT; |
| 757 | ldi->size = 1024; |
| 758 | ldi->total_records = 10; |
| 759 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 760 | kal_mem_cpy(ldi->fileverno, NVRAM_EF_NVRAM_TEST_1_LID_VERNO, 3); |
| 761 | break; |
| 762 | case NVRAM_EF_NVRAM_TEST_2_LID: |
| 763 | ldi->category = NVRAM_CATEGORY_INTERNAL; |
| 764 | ldi->attr = NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT; |
| 765 | ldi->size = 1024; |
| 766 | ldi->total_records = 10; |
| 767 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 768 | kal_mem_cpy(ldi->fileverno, NVRAM_EF_NVRAM_TEST_2_LID_VERNO, 3); |
| 769 | break; |
| 770 | case NVRAM_EF_NVRAM_TEST_3_LID: |
| 771 | ldi->category = NVRAM_CATEGORY_CALIBRAT; |
| 772 | ldi->attr = NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT; |
| 773 | ldi->size = 1024; |
| 774 | ldi->total_records = 10; |
| 775 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 776 | kal_mem_cpy(ldi->fileverno, NVRAM_EF_NVRAM_TEST_3_LID_VERNO, 3); |
| 777 | break; |
| 778 | case NVRAM_EF_NVRAM_TEST_4_LID: |
| 779 | ldi->category = NVRAM_CATEGORY_IMPORTANT; |
| 780 | ldi->attr = NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT; |
| 781 | ldi->size = 1024; |
| 782 | ldi->total_records = 10; |
| 783 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 784 | kal_mem_cpy(ldi->fileverno, NVRAM_EF_NVRAM_TEST_4_LID_VERNO, 3); |
| 785 | break; |
| 786 | case NVRAM_EF_NVRAM_TEST_5_LID: |
| 787 | ldi->category = NVRAM_CATEGORY_IMPORTANT_L1; |
| 788 | ldi->attr = NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT; |
| 789 | ldi->size = 1024; |
| 790 | ldi->total_records = 10; |
| 791 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 792 | kal_mem_cpy(ldi->fileverno, NVRAM_EF_NVRAM_TEST_5_LID_VERNO, 3); |
| 793 | break; |
| 794 | case NVRAM_EF_NVRAM_TEST_6_LID: |
| 795 | ldi->category = NVRAM_CATEGORY_IMPORTANT_L4; |
| 796 | ldi->attr = NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT | NVRAM_ATTR_CHKSUM_INTEGRATE; |
| 797 | ldi->size = 1024; |
| 798 | ldi->total_records = 10; |
| 799 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 800 | kal_mem_cpy(ldi->fileverno, NVRAM_EF_NVRAM_TEST_6_LID_VERNO, 3); |
| 801 | break; |
| 802 | case NVRAM_EF_NVRAM_TEST_7_LID: |
| 803 | ldi->category = NVRAM_CATEGORY_CALIBRAT; |
| 804 | ldi->attr = NVRAM_ATTR_AVERAGE | NVRAM_ATTR_RAW_DATA; |
| 805 | ldi->size = NVRAM_EF_TEST_LID_SIZE; |
| 806 | ldi->total_records = 1; |
| 807 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 808 | kal_mem_cpy(ldi->fileverno, NVRAM_EF_NVRAM_TEST_7_LID_VERNO, 3); |
| 809 | break; |
| 810 | case NVRAM_EF_NVRAM_TEST_8_LID: |
| 811 | ldi->category = NVRAM_CATEGORY_USER; |
| 812 | ldi->attr = NVRAM_ATTR_AVERAGE | NVRAM_ATTR_MULTI_DEFAULT | NVRAM_ATTR_CHKSUM_INTEGRATE; |
| 813 | ldi->size = NVRAM_EF_TEST_8_LID_SIZE; |
| 814 | ldi->total_records = NVRAM_EF_TEST_8_LID_RECORD_TOTAL; |
| 815 | ldi->default_value = NVRAM_NORMAL(NVRAM_EF_TEST_8_DEFAULT); |
| 816 | kal_mem_cpy(ldi->fileverno, NVRAM_EF_NVRAM_TEST_8_LID_VERNO, 3); |
| 817 | break; |
| 818 | case NVRAM_EF_INTERNAL_13_LID: |
| 819 | ldi->category = NVRAM_CATEGORY_IMPORTANT_L1; |
| 820 | ldi->attr = NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT | NVRAM_ATTR_MULTI_DEFAULT; |
| 821 | ldi->size = NVRAM_EF_TEST_13_LID_SIZE; |
| 822 | ldi->total_records = NVRAM_EF_TEST_13_LID_RECORD_TOTAL; |
| 823 | ldi->default_value = NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT); |
| 824 | kal_mem_cpy(ldi->fileverno, NVRAM_EF_INTERNAL_13_LID_VERNO, 3); |
| 825 | break; |
| 826 | case NVRAM_EF_INTERNAL_TEST_14_LID: |
| 827 | ldi->category = NVRAM_CATEGORY_USER | NVRAM_CATEGORY_FUNC_DEFAULT; |
| 828 | ldi->attr = NVRAM_ATTR_AVERAGE | NVRAM_ATTR_GEN_DEFAULT | NVRAM_ATTR_MULTI_DEFAULT; |
| 829 | ldi->size = NVRAM_EF_TEST_14_LID_SIZE; |
| 830 | ldi->total_records = NVRAM_EF_TEST_14_LID_RECORD_TOTAL; |
| 831 | ldi->default_value = NVRAM_DEFAULT_FUNC(nvram_internal_test_fun_default_value); |
| 832 | kal_mem_cpy(ldi->fileverno, NVRAM_EF_INTERNAL_TEST_14_LID_VERNO, 3); |
| 833 | break; |
| 834 | case NVRAM_EF_INTERNAL_TEST_16_LID: |
| 835 | ldi->category = NVRAM_CATEGORY_CALIBRAT; |
| 836 | ldi->attr = NVRAM_ATTR_AVERAGE | NVRAM_ATTR_CHKSUM_INTEGRATE | NVRAM_ATTR_FAULT_ASSERT; |
| 837 | ldi->size = NVRAM_EF_INTERNAL_TEST_16_LID_SIZE; |
| 838 | ldi->total_records = NVRAM_EF_INTERNAL_TEST_16_LID_RECORD_TOTAL; |
| 839 | ldi->default_value = NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT); |
| 840 | kal_mem_cpy(ldi->fileverno, NVRAM_EF_INTERNAL_TEST_16_LID_VERNO, 3); |
| 841 | break; |
| 842 | case NVRAM_EF_INTERNAL_TEST_17_LID: |
| 843 | ldi->category = NVRAM_CATEGORY_USER; |
| 844 | ldi->attr = NVRAM_ATTR_AVERAGE | NVRAM_ATTR_MULTIPLE; |
| 845 | ldi->size = NVRAM_EF_TEST_LID_SIZE; |
| 846 | ldi->total_records = NVRAM_EF_TEST_LID_RECORD_TOTAL; |
| 847 | ldi->default_value = NVRAM_NORMAL(NVRAM_EF_ZERO_DEFAULT); |
| 848 | kal_mem_cpy(ldi->fileverno, NVRAM_EF_INTERNAL_TEST_17_LID_VERNO, 3); |
| 849 | break; |
| 850 | default: |
| 851 | return KAL_FALSE; |
| 852 | } |
| 853 | |
| 854 | return KAL_TRUE; |
| 855 | } |
| 856 | |
| 857 | kal_bool lid_verno_increase_one(nvram_lid_enum LID) |
| 858 | { |
| 859 | nvram_ltable_entry_struct *ldi = NULL; |
| 860 | kal_uint8 overflow_flag, i; |
| 861 | |
| 862 | if(!NVRAM_IS_LID_VALID(LID)) |
| 863 | { |
| 864 | return KAL_FALSE; |
| 865 | } |
| 866 | nvram_util_get_data_item(&ldi, LID); |
| 867 | |
| 868 | for(i = 0, overflow_flag = 1; (i < 3) && (overflow_flag); i++) |
| 869 | { |
| 870 | if((ldi->fileverno[2-i] - '0') < 9) |
| 871 | { |
| 872 | ldi->fileverno[2-i] += 1; |
| 873 | overflow_flag = 0; |
| 874 | } |
| 875 | else |
| 876 | { |
| 877 | ldi->fileverno[2-i] = '0'; |
| 878 | overflow_flag = 1; |
| 879 | } |
| 880 | } |
| 881 | |
| 882 | return KAL_TRUE; |
| 883 | } |
| 884 | |
| 885 | kal_bool modify_md_sw_version() |
| 886 | { |
| 887 | kal_uint8 *d_buffer; |
| 888 | nvram_ltable_entry_struct *ldi = NULL; |
| 889 | |
| 890 | nvram_util_get_data_item(&ldi, NVRAM_EF_SW_VERNO_LID); |
| 891 | d_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 892 | if(!nvram_external_read_data(ldi->LID, SW_VERNO_RECORD_NUMBER, d_buffer, ldi->size)) |
| 893 | { |
| 894 | free_ctrl_buffer(d_buffer); |
| 895 | return KAL_FALSE; |
| 896 | } |
| 897 | d_buffer[0] += 0x1; //modify one uint in the buffer |
| 898 | if(!nvram_external_write_data(ldi->LID, SW_VERNO_RECORD_NUMBER, d_buffer, ldi->size)) |
| 899 | { |
| 900 | free_ctrl_buffer(d_buffer); |
| 901 | return KAL_FALSE; |
| 902 | } |
| 903 | free_ctrl_buffer(d_buffer); |
| 904 | #ifdef __NVRAM_LID_CACHE__ |
| 905 | if (check_nvram_cache_ready()) |
| 906 | { |
| 907 | while(check_lid_all_record_is_undirty_bit(ldi)) |
| 908 | { |
| 909 | } |
| 910 | } |
| 911 | #endif |
| 912 | return KAL_TRUE; |
| 913 | } |
| 914 | |
| 915 | kal_bool delete_special_version_lid(nvram_lid_enum LID, kal_uint32 start_version, kal_uint32 end_version) |
| 916 | { |
| 917 | nvram_ltable_entry_struct *ldi = NULL; |
| 918 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 919 | nvram_folder_enum folder_index; |
| 920 | NVRAM_FILE_NAME nvramname; |
| 921 | kal_uint32 i; |
| 922 | kal_uint8 lid_verno_bak[3]; |
| 923 | |
| 924 | if(!NVRAM_IS_LID_VALID(LID)) |
| 925 | { |
| 926 | return KAL_FALSE; |
| 927 | } |
| 928 | |
| 929 | if((start_version > end_version) || (end_version > 999)) |
| 930 | { |
| 931 | return KAL_FALSE; |
| 932 | } |
| 933 | |
| 934 | nvram_util_get_data_item(&ldi, LID); |
| 935 | #ifdef __NVRAM_LID_CACHE__ |
| 936 | if (check_nvram_cache_ready()) |
| 937 | { |
| 938 | while(check_lid_all_record_is_undirty_bit(ldi) != KAL_TRUE) |
| 939 | { |
| 940 | } |
| 941 | } |
| 942 | #endif |
| 943 | kal_mem_cpy(lid_verno_bak, ldi->fileverno, 3); |
| 944 | ldi->fileverno[0] = '0'; //set LID verno as "000" |
| 945 | ldi->fileverno[1] = '0'; |
| 946 | ldi->fileverno[2] = '0'; |
| 947 | |
| 948 | for(i = 0; i < start_version; i++) //skip to start_version |
| 949 | { |
| 950 | lid_verno_increase_one(LID); |
| 951 | } |
| 952 | |
| 953 | for(i = start_version; i <= end_version; i++) //delete related LID version |
| 954 | { |
| 955 | folder_index = nvram_query_folder_index(ldi->category); |
| 956 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 957 | nvram_query_file_name(folder_index, nvramname, filename); |
| 958 | #ifdef __NVRAM_LID_CACHE__ |
| 959 | nvram_util_take_mutex(g_nvram_fs_mutex); |
| 960 | #endif |
| 961 | nvram_util_mark_file_uncreated(ldi); |
| 962 | FS_Delete(filename); |
| 963 | |
| 964 | if(ldi->attr & NVRAM_ATTR_MULTIPLE) |
| 965 | { |
| 966 | nvram_util_make_lid_filename(ldi, nvramname, KAL_FALSE); |
| 967 | nvram_query_file_name(folder_index, nvramname, filename); |
| 968 | FS_Delete(filename); |
| 969 | } |
| 970 | #ifdef __NVRAM_LID_CACHE__ |
| 971 | nvram_util_give_mutex(g_nvram_fs_mutex); |
| 972 | #endif |
| 973 | lid_verno_increase_one(LID); |
| 974 | } |
| 975 | kal_mem_cpy(ldi->fileverno, lid_verno_bak, 3); |
| 976 | |
| 977 | return KAL_TRUE; |
| 978 | } |
| 979 | |
| 980 | kal_bool first_boot_basic_access(kal_uint32 flags, void *param) |
| 981 | { |
| 982 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 983 | kal_uint8 i; |
| 984 | |
| 985 | /* default settings is OK |
| 986 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 987 | ldi->category = NVRAM_CATEGORY_USER; |
| 988 | ldi->attr = NVRAM_ATTR_AVERAGE; |
| 989 | ldi->size = 1024; |
| 990 | ldi->total_records = 10; |
| 991 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 992 | |
| 993 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_2_LID); |
| 994 | ldi->category = NVRAM_CATEGORY_INTERNAL; |
| 995 | ldi->attr = NVRAM_ATTR_AVERAGE; |
| 996 | ldi->size = 1024; |
| 997 | ldi->total_records = 10; |
| 998 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 999 | |
| 1000 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_3_LID); |
| 1001 | ldi->category = NVRAM_CATEGORY_CALIBRAT; |
| 1002 | ldi->attr = NVRAM_ATTR_AVERAGE; |
| 1003 | ldi->size = 1024; |
| 1004 | ldi->total_records = 10; |
| 1005 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 1006 | |
| 1007 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_4_LID); |
| 1008 | ldi->category = NVRAM_CATEGORY_IMPORTANT; |
| 1009 | ldi->attr = NVRAM_ATTR_AVERAGE; |
| 1010 | ldi->size = 1024; |
| 1011 | ldi->total_records = 10; |
| 1012 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 1013 | |
| 1014 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_5_LID); |
| 1015 | ldi->category = NVRAM_CATEGORY_IMPORTANT_L1; |
| 1016 | ldi->attr = NVRAM_ATTR_AVERAGE; |
| 1017 | ldi->size = 1024; |
| 1018 | ldi->total_records = 10; |
| 1019 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 1020 | |
| 1021 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_6_LID); |
| 1022 | ldi->category = NVRAM_CATEGORY_IMPORTANT_L4; |
| 1023 | ldi->attr = NVRAM_ATTR_AVERAGE; |
| 1024 | ldi->size = 1024; |
| 1025 | ldi->total_records = 10; |
| 1026 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 1027 | */ |
| 1028 | #ifdef __NVRAM_LID_CACHE__ |
| 1029 | nvram_cache_reset();//Disable NVRAM Cache |
| 1030 | #endif |
| 1031 | is_insulation_access = 1; |
| 1032 | |
| 1033 | NVRAM_FS_MAKE_ROOT_PATH(filename); |
| 1034 | FS_XDelete(filename, (FS_FILE_TYPE | FS_DIR_TYPE | FS_RECURSIVE_TYPE), NULL, 0); |
| 1035 | #if defined(__MTK_TARGET__) && defined(__NVRAM_IMPORTANT_PARTITIONS__) |
| 1036 | FS_XDelete((const WCHAR*)L"X:\\NV_TEST", (FS_FILE_TYPE|FS_DIR_TYPE|FS_RECURSIVE_TYPE), NULL, 0); |
| 1037 | FS_XDelete((const WCHAR*)L"Y:\\NV_TEST", (FS_FILE_TYPE|FS_DIR_TYPE|FS_RECURSIVE_TYPE), NULL, 0); |
| 1038 | #endif |
| 1039 | |
| 1040 | nvram_init(); |
| 1041 | |
| 1042 | for(i = 0; i < test_lid_number; i++) |
| 1043 | { |
| 1044 | if(0 != nvram_lid_cmpt_operation(test_lid_enum[i], |
| 1045 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 1046 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 1047 | { |
| 1048 | nvram_ut_trace("[NVUT] first_boot_basic_access(): LID cmpt operations fail!\n\r"); |
| 1049 | is_insulation_access = 0; |
| 1050 | return KAL_FALSE; |
| 1051 | } |
| 1052 | } |
| 1053 | |
| 1054 | FS_XDelete(filename, (FS_FILE_TYPE | FS_DIR_TYPE | FS_RECURSIVE_TYPE), NULL, 0); |
| 1055 | #if defined(__MTK_TARGET__) && defined(__NVRAM_IMPORTANT_PARTITIONS__) |
| 1056 | FS_XDelete((const WCHAR*)L"X:\\NV_TEST", (FS_FILE_TYPE|FS_DIR_TYPE|FS_RECURSIVE_TYPE), NULL, 0); |
| 1057 | FS_XDelete((const WCHAR*)L"Y:\\NV_TEST", (FS_FILE_TYPE|FS_DIR_TYPE|FS_RECURSIVE_TYPE), NULL, 0); |
| 1058 | #endif |
| 1059 | |
| 1060 | is_insulation_access = 0; |
| 1061 | |
| 1062 | return KAL_TRUE; |
| 1063 | } |
| 1064 | |
| 1065 | |
| 1066 | /* |
| 1067 | store test logs to LID6, and this LID is stored in protect_f partition |
| 1068 | */ |
| 1069 | void save_context_notify_tester() |
| 1070 | { |
| 1071 | nvram_ltable_entry_struct *ldi = NULL; |
| 1072 | factory_test_context_struct *test_context; |
| 1073 | |
| 1074 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_6_LID); |
| 1075 | test_context = (factory_test_context_struct*)data_buffer; |
| 1076 | test_context->context_is_valid = 0xAB; //a special value we appoint |
| 1077 | test_context->break_test_case_num = test_number; |
| 1078 | test_context->sub_test_case_num = sub_test_number; |
| 1079 | test_context->valid_test_case_num_total = valid_test_case_num; |
| 1080 | test_context->total_case_number = total_case_num; |
| 1081 | test_context->fail_case_number = fail_case_num; |
| 1082 | test_context->tst_time_consume = ust_get_current_time() - start_test_time; |
| 1083 | kal_mem_cpy(test_context->test_case_lst, test_case_list, sizeof(test_case_list)); |
| 1084 | |
| 1085 | nvram_external_write_data(ldi->LID, 1, (kal_uint8 *)data_buffer, ldi->size); //write context to record 1 |
| 1086 | |
| 1087 | nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size); |
| 1088 | if(0 == kal_mem_cmp(data_buffer, cmp_buffer, sizeof(test_case_list))) |
| 1089 | { |
| 1090 | nvram_ut_trace("[NVRAM UT] Save test context success!\n\r"); |
| 1091 | } |
| 1092 | |
| 1093 | while(1) |
| 1094 | { |
| 1095 | nvram_ut_trace("[NVRAM UT] Please do SP \"Factory Reset Operation\" manually!\n\r"); |
| 1096 | kal_sleep_task(kal_milli_secs_to_ticks(5000)); |
| 1097 | } |
| 1098 | } |
| 1099 | |
| 1100 | void ota_save_context() |
| 1101 | { |
| 1102 | nvram_ltable_entry_struct *ldi = NULL; |
| 1103 | factory_test_context_struct *test_context; |
| 1104 | |
| 1105 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_6_LID); |
| 1106 | test_context = (factory_test_context_struct*)data_buffer; |
| 1107 | test_context->context_is_valid = 0xCD; //a special value we appoint |
| 1108 | test_context->break_test_case_num = test_number; |
| 1109 | test_context->sub_test_case_num = sub_test_number; |
| 1110 | test_context->valid_test_case_num_total = valid_test_case_num; |
| 1111 | test_context->total_case_number = total_case_num; |
| 1112 | test_context->fail_case_number = fail_case_num; |
| 1113 | test_context->tst_time_consume = ust_get_current_time() - start_test_time; |
| 1114 | kal_mem_cpy(test_context->test_case_lst, test_case_list, sizeof(test_case_list)); |
| 1115 | |
| 1116 | nvram_external_write_data(ldi->LID, 1, (kal_uint8 *)data_buffer, ldi->size); //write context to record 1 |
| 1117 | |
| 1118 | nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size); |
| 1119 | if(0 == kal_mem_cmp(data_buffer, cmp_buffer, sizeof(test_case_list))) |
| 1120 | { |
| 1121 | nvram_ut_trace("[NVRAM UT] Save test context success!\n\r"); |
| 1122 | } |
| 1123 | } |
| 1124 | |
| 1125 | void ota_notify_tester(char *ptr) |
| 1126 | { |
| 1127 | while(1) |
| 1128 | { |
| 1129 | nvram_ut_trace("[NVRAM UT] %s\n\r", ptr); |
| 1130 | kal_sleep_task(kal_milli_secs_to_ticks(5000)); |
| 1131 | } |
| 1132 | } |
| 1133 | |
| 1134 | |
| 1135 | |
| 1136 | kal_bool factory_reset_user_access(kal_uint32 flags, void *param) |
| 1137 | { |
| 1138 | nvram_ltable_entry_struct *ldi = NULL; |
| 1139 | |
| 1140 | if(!factory_test_reboot_finish) |
| 1141 | { |
| 1142 | save_context_notify_tester(); |
| 1143 | } |
| 1144 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 1145 | |
| 1146 | //read, write and reset test |
| 1147 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 1148 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 1149 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 1150 | { |
| 1151 | nvram_ut_trace("[NVUT] factory_reset_user_access(): access fail!\n\r"); |
| 1152 | return KAL_FALSE; |
| 1153 | } |
| 1154 | |
| 1155 | return KAL_TRUE; |
| 1156 | } |
| 1157 | |
| 1158 | kal_bool factory_reset_internal_access(kal_uint32 flags, void *param) |
| 1159 | { |
| 1160 | nvram_ltable_entry_struct *ldi = NULL; |
| 1161 | |
| 1162 | if(!factory_test_reboot_finish) |
| 1163 | { |
| 1164 | save_context_notify_tester(); |
| 1165 | } |
| 1166 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_2_LID); |
| 1167 | |
| 1168 | //read, write and reset test |
| 1169 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_2_LID, |
| 1170 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 1171 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 1172 | { |
| 1173 | nvram_ut_trace("[NVUT] factory_reset_internal_access(): access fail!\n\r"); |
| 1174 | return KAL_FALSE; |
| 1175 | } |
| 1176 | |
| 1177 | return KAL_TRUE; |
| 1178 | } |
| 1179 | |
| 1180 | kal_bool factory_reset_calibrat_access(kal_uint32 flags, void *param) |
| 1181 | { |
| 1182 | nvram_ltable_entry_struct *ldi = NULL; |
| 1183 | kal_uint32 i; |
| 1184 | |
| 1185 | if(!factory_test_reboot_finish) |
| 1186 | { |
| 1187 | save_context_notify_tester(); |
| 1188 | } |
| 1189 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_3_LID); |
| 1190 | |
| 1191 | //read test |
| 1192 | for(i = 1; i <= ldi->total_records; i++) |
| 1193 | { |
| 1194 | kal_mem_set(data_buffer, 0, NVRAM_EF_TEST_LID_SIZE); |
| 1195 | data_buffer[0] = 0x1; //modify data_buffer to special value write before binregion backup |
| 1196 | kal_mem_set(cmp_buffer, 0, ldi->size); |
| 1197 | if(!nvram_external_read_data(ldi->LID, i, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 1198 | { |
| 1199 | nvram_ut_trace("[NVUT] factory_reset_calibrat_access(): read fail!\n\r"); |
| 1200 | return KAL_FALSE; |
| 1201 | } |
| 1202 | |
| 1203 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, ldi->size)) |
| 1204 | { |
| 1205 | nvram_ut_trace("[NVUT] factory_reset_calibrat_access(): read back value is not expect!\n\r"); |
| 1206 | return KAL_FALSE; |
| 1207 | } |
| 1208 | } |
| 1209 | |
| 1210 | if(i <= ldi->total_records) |
| 1211 | { |
| 1212 | nvram_ut_trace("[NVUT] factory_reset_calibrat_access(): read fail!\n\r"); |
| 1213 | return KAL_FALSE; //return error number |
| 1214 | } |
| 1215 | |
| 1216 | //write and reset test |
| 1217 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_3_LID, |
| 1218 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0, 0), |
| 1219 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 1220 | { |
| 1221 | nvram_ut_trace("[NVUT] factory_reset_calibrat_access(): write/reset fail!\n\r"); |
| 1222 | return KAL_FALSE; |
| 1223 | } |
| 1224 | |
| 1225 | return KAL_TRUE; |
| 1226 | } |
| 1227 | |
| 1228 | kal_bool factory_reset_important_access(kal_uint32 flags, void *param) |
| 1229 | { |
| 1230 | nvram_ltable_entry_struct *ldi = NULL; |
| 1231 | kal_uint32 i; |
| 1232 | |
| 1233 | if(!factory_test_reboot_finish) |
| 1234 | { |
| 1235 | save_context_notify_tester(); |
| 1236 | } |
| 1237 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_4_LID); |
| 1238 | |
| 1239 | //read test |
| 1240 | for(i = 1; i <= ldi->total_records; i++) |
| 1241 | { |
| 1242 | kal_mem_set(data_buffer, 0, NVRAM_EF_TEST_LID_SIZE); |
| 1243 | data_buffer[0] = 0x1; //modify data_buffer to special value write before binregion backup |
| 1244 | kal_mem_set(cmp_buffer, 0, ldi->size); |
| 1245 | if(!nvram_external_read_data(ldi->LID, i, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 1246 | { |
| 1247 | nvram_ut_trace("[NVUT] factory_reset_important_access(): read fail!\n\r"); |
| 1248 | return KAL_FALSE; |
| 1249 | } |
| 1250 | |
| 1251 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, ldi->size)) |
| 1252 | { |
| 1253 | nvram_ut_trace("[NVUT] factory_reset_important_access(): read back value is not expect!\n\r"); |
| 1254 | return KAL_FALSE; |
| 1255 | } |
| 1256 | } |
| 1257 | |
| 1258 | //write and reset test |
| 1259 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_4_LID, |
| 1260 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0, 0), |
| 1261 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 1262 | { |
| 1263 | nvram_ut_trace("[NVUT] factory_reset_important_access(): write/reset fail!\n\r"); |
| 1264 | return KAL_FALSE; |
| 1265 | } |
| 1266 | |
| 1267 | return KAL_TRUE; |
| 1268 | } |
| 1269 | |
| 1270 | |
| 1271 | kal_bool factory_reset_importantl1_access(kal_uint32 flags, void *param) |
| 1272 | { |
| 1273 | nvram_ltable_entry_struct *ldi = NULL; |
| 1274 | kal_uint32 i; |
| 1275 | |
| 1276 | if(!factory_test_reboot_finish) |
| 1277 | { |
| 1278 | save_context_notify_tester(); |
| 1279 | } |
| 1280 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_5_LID); |
| 1281 | |
| 1282 | //read test |
| 1283 | for(i = 1; i <= ldi->total_records; i++) |
| 1284 | { |
| 1285 | kal_mem_set(data_buffer, 0, NVRAM_EF_TEST_LID_SIZE); |
| 1286 | data_buffer[0] = 0x1; //modify data_buffer to special value write before binregion backup |
| 1287 | kal_mem_set(cmp_buffer, 0, ldi->size); |
| 1288 | if(!nvram_external_read_data(ldi->LID, i, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 1289 | { |
| 1290 | nvram_ut_trace("[NVUT] factory_reset_importantl1_access(): read fail!\n\r"); |
| 1291 | return KAL_FALSE; |
| 1292 | } |
| 1293 | |
| 1294 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, ldi->size)) |
| 1295 | { |
| 1296 | nvram_ut_trace("[NVUT] factory_reset_importantl1_access(): read back value is not expect!\n\r"); |
| 1297 | return KAL_FALSE; |
| 1298 | } |
| 1299 | } |
| 1300 | |
| 1301 | //write test and reset test |
| 1302 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_5_LID, |
| 1303 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0, 0), |
| 1304 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 1305 | { |
| 1306 | nvram_ut_trace("[NVUT] factory_reset_importantl1_access(): write/reset fail!\n\r"); |
| 1307 | return KAL_FALSE; |
| 1308 | } |
| 1309 | |
| 1310 | return KAL_TRUE; |
| 1311 | } |
| 1312 | |
| 1313 | kal_bool factory_reset_importantl4_access(kal_uint32 flags, void *param) |
| 1314 | { |
| 1315 | nvram_ltable_entry_struct *ldi = NULL; |
| 1316 | kal_uint32 i; |
| 1317 | |
| 1318 | if(!factory_test_reboot_finish) |
| 1319 | { |
| 1320 | save_context_notify_tester(); |
| 1321 | } |
| 1322 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_6_LID); |
| 1323 | |
| 1324 | //read test, record 1 stores the factory reset context so read test start from record 2 |
| 1325 | for(i = 2; i <= ldi->total_records; i++) |
| 1326 | { |
| 1327 | kal_mem_set(data_buffer, 0, NVRAM_EF_TEST_LID_SIZE); |
| 1328 | data_buffer[0] = 0x1; //modify data_buffer to special value write before binregion backup |
| 1329 | kal_mem_set(cmp_buffer, 0, ldi->size); |
| 1330 | if(!nvram_external_read_data(ldi->LID, i, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 1331 | { |
| 1332 | nvram_ut_trace("[NVUT] factory_reset_importantl4_access(): read fail!\n\r"); |
| 1333 | return KAL_FALSE; |
| 1334 | } |
| 1335 | |
| 1336 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, ldi->size)) |
| 1337 | { |
| 1338 | nvram_ut_trace("[NVUT] factory_reset_importantl4_access(): read back value is not expect!\n\r"); |
| 1339 | return KAL_FALSE; |
| 1340 | } |
| 1341 | } |
| 1342 | |
| 1343 | //write and reset test |
| 1344 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_6_LID, |
| 1345 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0, 0), |
| 1346 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 1347 | { |
| 1348 | nvram_ut_trace("[NVUT] factory_reset_importantl4_access(): write/reset fail!\n\r"); |
| 1349 | return KAL_FALSE; |
| 1350 | } |
| 1351 | |
| 1352 | return KAL_TRUE; |
| 1353 | } |
| 1354 | |
| 1355 | kal_bool ota_boot_basic_access(kal_uint32 flags, void *param) |
| 1356 | { |
| 1357 | nvram_ltable_entry_struct *ldi = NULL; |
| 1358 | kal_uint8 i; |
| 1359 | #ifdef __NVRAM_LID_CACHE__ |
| 1360 | nvram_cache_reset();//Disable NVRAM Cache |
| 1361 | #endif |
| 1362 | //reset test LIDs to default settings |
| 1363 | for(i = 0; i < test_lid_number; i++) |
| 1364 | { |
| 1365 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 1366 | { |
| 1367 | nvram_ut_trace("[NVUT] ota_boot_basic_access(): reset LIDs to default setting fail!\n\r"); |
| 1368 | return KAL_FALSE; |
| 1369 | } |
| 1370 | } |
| 1371 | |
| 1372 | //reset test LIDs |
| 1373 | for(i = 0; i < test_lid_number; i++) |
| 1374 | { |
| 1375 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1376 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 1377 | { |
| 1378 | nvram_ut_trace("[NVUT] ota_boot_basic_access(): reset test LIDs fail!\n\r"); |
| 1379 | return KAL_FALSE; |
| 1380 | } |
| 1381 | } |
| 1382 | |
| 1383 | //reset SYS LID |
| 1384 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 1385 | { |
| 1386 | nvram_ut_trace("[NVUT] ota_boot_basic_access(): reset SYS LID fail!\n\r"); |
| 1387 | return KAL_FALSE; |
| 1388 | } |
| 1389 | |
| 1390 | //modify MD SW version |
| 1391 | if(!modify_md_sw_version()) |
| 1392 | { |
| 1393 | nvram_ut_trace("[NVUT] ota_boot_basic_access(): modify MD SW version fail!\n\r"); |
| 1394 | return KAL_FALSE; |
| 1395 | } |
| 1396 | |
| 1397 | //call nvram_init() |
| 1398 | nvram_boot_trace = 0; |
| 1399 | |
| 1400 | nvram_init(); |
| 1401 | |
| 1402 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 1403 | { |
| 1404 | nvram_ut_trace("[NVUT] ota_boot_basic_access(): enter version conflict fail!\n\r"); |
| 1405 | return KAL_FALSE; |
| 1406 | } |
| 1407 | |
| 1408 | //lid access |
| 1409 | for(i = 0; i < test_lid_number; i++) |
| 1410 | { |
| 1411 | if(0 != nvram_lid_cmpt_operation(test_lid_enum[i], |
| 1412 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 1413 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 1414 | { |
| 1415 | nvram_ut_trace("[NVUT] ota_boot_basic_access(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 1416 | } |
| 1417 | } |
| 1418 | #ifdef __NVRAM_LID_CACHE__ |
| 1419 | mark_nvram_cache_ready(); |
| 1420 | #endif |
| 1421 | return KAL_TRUE; |
| 1422 | |
| 1423 | } |
| 1424 | |
| 1425 | kal_bool ota_boot_lid_verno_change_access(kal_uint32 flags, void *param) |
| 1426 | { |
| 1427 | nvram_ltable_entry_struct *ldi = NULL; |
| 1428 | kal_uint8 i; |
| 1429 | #ifdef __NVRAM_LID_CACHE__ |
| 1430 | nvram_cache_reset();//Disable NVRAM Cache |
| 1431 | #endif |
| 1432 | //reset test LIDs to default settings |
| 1433 | for(i = 0; i < test_lid_number; i++) |
| 1434 | { |
| 1435 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 1436 | { |
| 1437 | nvram_ut_trace("[NVUT] ota_boot_lid_verno_change_access(): reset LIDs to default setting fail!\n\r"); |
| 1438 | return KAL_FALSE; |
| 1439 | } |
| 1440 | } |
| 1441 | |
| 1442 | //reset test LIDs |
| 1443 | for(i = 0; i < test_lid_number; i++) |
| 1444 | { |
| 1445 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1446 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 1447 | { |
| 1448 | nvram_ut_trace("[NVUT] ota_boot_lid_verno_change_access(): reset test LIDs fail!\n\r"); |
| 1449 | return KAL_FALSE; |
| 1450 | } |
| 1451 | } |
| 1452 | |
| 1453 | //reset SYS LID |
| 1454 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 1455 | { |
| 1456 | nvram_ut_trace("[NVUT] ota_boot_lid_verno_change_access(): reset SYS LID fail!\n\r"); |
| 1457 | return KAL_FALSE; |
| 1458 | } |
| 1459 | |
| 1460 | //modify MD SW version |
| 1461 | if(!modify_md_sw_version()) |
| 1462 | { |
| 1463 | nvram_ut_trace("[NVUT] ota_boot_lid_verno_change_access(): modify MD SW version fail!\n\r"); |
| 1464 | return KAL_FALSE; |
| 1465 | } |
| 1466 | |
| 1467 | //test LID1~LID6 verno +1 |
| 1468 | for(i = 0; i < test_lid_number; i++) |
| 1469 | { |
| 1470 | if(!lid_verno_increase_one(test_lid_enum[i])) |
| 1471 | { |
| 1472 | nvram_ut_trace("[NVUT] ota_boot_lid_verno_change_access(): increase verno fail!\n\r"); |
| 1473 | return KAL_FALSE; |
| 1474 | } |
| 1475 | } |
| 1476 | |
| 1477 | //call nvram_init() |
| 1478 | nvram_boot_trace = 0; |
| 1479 | |
| 1480 | nvram_init(); |
| 1481 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 1482 | { |
| 1483 | nvram_ut_trace("[NVUT] ota_boot_lid_verno_change_access(): enter version conflict fail!\n\r"); |
| 1484 | return KAL_FALSE; |
| 1485 | } |
| 1486 | //lid access |
| 1487 | for(i = 0; i < test_lid_number; i++) |
| 1488 | { |
| 1489 | if(0 != nvram_lid_cmpt_operation(test_lid_enum[i], |
| 1490 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 1491 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 1492 | { |
| 1493 | nvram_ut_trace("NVUT] ota_boot_lid_verno_change_access(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 1494 | return KAL_FALSE; |
| 1495 | } |
| 1496 | } |
| 1497 | #ifdef __NVRAM_LID_CACHE__ |
| 1498 | mark_nvram_cache_ready(); |
| 1499 | #endif |
| 1500 | return KAL_TRUE; |
| 1501 | } |
| 1502 | |
| 1503 | kal_bool ota_boot_add_record_read(kal_uint32 flags, void *param) |
| 1504 | { |
| 1505 | nvram_ltable_entry_struct *ldi = NULL; |
| 1506 | kal_uint8 i; |
| 1507 | |
| 1508 | //reset test LIDs to default settings |
| 1509 | for(i = 0; i < test_lid_number; i++) |
| 1510 | { |
| 1511 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 1512 | { |
| 1513 | nvram_ut_trace("[NVUT] ota_boot_add_record_read(): reset LIDs to default setting fail!\n\r"); |
| 1514 | return KAL_FALSE; |
| 1515 | } |
| 1516 | } |
| 1517 | |
| 1518 | //reset test LIDs |
| 1519 | for(i = 0; i < test_lid_number; i++) |
| 1520 | { |
| 1521 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1522 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 1523 | { |
| 1524 | nvram_ut_trace("[NVUT] ota_boot_add_record_read(): reset test LIDs fail!\n\r"); |
| 1525 | return KAL_FALSE; |
| 1526 | } |
| 1527 | } |
| 1528 | |
| 1529 | //reset SYS LID |
| 1530 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 1531 | { |
| 1532 | nvram_ut_trace("[NVUT] ota_boot_add_record_read(): reset SYS LID fail!\n\r"); |
| 1533 | return KAL_FALSE; |
| 1534 | } |
| 1535 | |
| 1536 | //modify MD SW version |
| 1537 | if(!modify_md_sw_version()) |
| 1538 | { |
| 1539 | nvram_ut_trace("[NVUT] ota_boot_add_record_read(): modify MD SW version fail!\n\r"); |
| 1540 | return KAL_FALSE; |
| 1541 | } |
| 1542 | |
| 1543 | //modify LID's value |
| 1544 | kal_mem_set(cmp_buffer, 0x0, ldi->size); |
| 1545 | cmp_buffer[0] = 0x1; //modify some value |
| 1546 | cmp_buffer[1] = 0x2; |
| 1547 | cmp_buffer[2] = 0x3; |
| 1548 | for(i = 0; i < test_lid_number; i++) |
| 1549 | { |
| 1550 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1551 | if(!(nvram_external_write_data(test_lid_enum[i], ldi->total_records, (kal_uint8 *)cmp_buffer, ldi->size))) |
| 1552 | { |
| 1553 | nvram_ut_trace("[NVUT] ota_boot_add_record_read(): modify LID's value fail!\n\r"); |
| 1554 | return KAL_FALSE; |
| 1555 | } |
| 1556 | } |
| 1557 | |
| 1558 | //test LID1~LID6 record number +1 |
| 1559 | for(i = 0; i < test_lid_number; i++) |
| 1560 | { |
| 1561 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1562 | ldi->total_records += 1; |
| 1563 | } |
| 1564 | |
| 1565 | //call nvram_init() |
| 1566 | nvram_boot_trace = 0; |
| 1567 | nvram_init(); |
| 1568 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 1569 | { |
| 1570 | nvram_ut_trace("[NVUT] ota_boot_add_record_read(): enter version conflict fail!\n\r"); |
| 1571 | return KAL_FALSE; |
| 1572 | } |
| 1573 | |
| 1574 | //lid access |
| 1575 | for(i = 0; i < test_lid_number; i++) |
| 1576 | { |
| 1577 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1578 | if(!(nvram_external_read_data(test_lid_enum[i], ldi->total_records - 1, (kal_uint8 *)data_buffer, ldi->size))) |
| 1579 | { |
| 1580 | nvram_ut_trace("[NVUT] ota_boot_add_record_read(): read old record fail!\n\r"); |
| 1581 | return KAL_FALSE; |
| 1582 | } |
| 1583 | //old record should keep value |
| 1584 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 1585 | { |
| 1586 | nvram_ut_trace("[NVUT] ota_boot_add_record_read(): old record value change!\n\r"); |
| 1587 | return KAL_FALSE; |
| 1588 | } |
| 1589 | |
| 1590 | if(!(nvram_external_read_data(test_lid_enum[i], ldi->total_records, (kal_uint8 *)data_buffer, ldi->size))) |
| 1591 | { |
| 1592 | nvram_ut_trace("[NVUT] ota_boot_add_record_read(): read old record fail!\n\r"); |
| 1593 | return KAL_FALSE; |
| 1594 | } |
| 1595 | nvram_get_default_value_to_write(ldi, ldi->total_records, (kal_uint8 *)cmp_buffer, ldi->size); |
| 1596 | //new record should be default value |
| 1597 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 1598 | { |
| 1599 | nvram_ut_trace("[NVUT] ota_boot_add_record_read(): old record value change!\n\r"); |
| 1600 | return KAL_FALSE; |
| 1601 | } |
| 1602 | } |
| 1603 | |
| 1604 | return KAL_TRUE; |
| 1605 | |
| 1606 | } |
| 1607 | |
| 1608 | kal_bool ota_boot_add_record_write(kal_uint32 flags, void *param) |
| 1609 | { |
| 1610 | nvram_ltable_entry_struct *ldi = NULL; |
| 1611 | kal_uint8 i; |
| 1612 | |
| 1613 | //reset test LIDs to default settings |
| 1614 | for(i = 0; i < test_lid_number; i++) |
| 1615 | { |
| 1616 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 1617 | { |
| 1618 | nvram_ut_trace("[NVUT] ota_boot_add_record_write(): reset LIDs to default setting fail!\n\r"); |
| 1619 | return KAL_FALSE; |
| 1620 | } |
| 1621 | } |
| 1622 | |
| 1623 | //reset test LIDs |
| 1624 | for(i = 0; i < test_lid_number; i++) |
| 1625 | { |
| 1626 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1627 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 1628 | { |
| 1629 | nvram_ut_trace("[NVUT] ota_boot_add_record_write(): reset test LIDs fail!\n\r"); |
| 1630 | return KAL_FALSE; |
| 1631 | } |
| 1632 | } |
| 1633 | |
| 1634 | //reset SYS LID |
| 1635 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 1636 | { |
| 1637 | nvram_ut_trace("[NVUT] ota_boot_add_record_write(): reset SYS LID fail!\n\r"); |
| 1638 | return KAL_FALSE; |
| 1639 | } |
| 1640 | |
| 1641 | //modify MD SW version |
| 1642 | if(!modify_md_sw_version()) |
| 1643 | { |
| 1644 | nvram_ut_trace("[NVUT] ota_boot_add_record_write(): modify MD SW version fail!\n\r"); |
| 1645 | return KAL_FALSE; |
| 1646 | } |
| 1647 | |
| 1648 | //test LID1~LID6 record number +1 |
| 1649 | for(i = 0; i < test_lid_number; i++) |
| 1650 | { |
| 1651 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1652 | ldi->total_records += 1; |
| 1653 | } |
| 1654 | |
| 1655 | //call nvram_init() |
| 1656 | nvram_boot_trace = 0; |
| 1657 | nvram_init(); |
| 1658 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 1659 | { |
| 1660 | nvram_ut_trace("[NVUT] ota_boot_add_record_write(): enter version conflict fail!\n\r"); |
| 1661 | return KAL_FALSE; |
| 1662 | } |
| 1663 | |
| 1664 | //lid access |
| 1665 | for(i = 0; i < test_lid_number; i++) |
| 1666 | { |
| 1667 | if(0 != nvram_lid_cmpt_operation(test_lid_enum[i], |
| 1668 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 1669 | CMPT_OP_WAY_API, 1, ldi->total_records)) |
| 1670 | { |
| 1671 | nvram_ut_trace("[NVUT] ota_boot_add_record_write(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 1672 | return KAL_FALSE; |
| 1673 | } |
| 1674 | } |
| 1675 | |
| 1676 | return KAL_TRUE; |
| 1677 | |
| 1678 | } |
| 1679 | |
| 1680 | kal_bool ota_boot_add_record_reset(kal_uint32 flags, void *param) |
| 1681 | { |
| 1682 | nvram_ltable_entry_struct *ldi = NULL; |
| 1683 | kal_uint8 i; |
| 1684 | |
| 1685 | //reset test LIDs to default settings |
| 1686 | for(i = 0; i < test_lid_number; i++) |
| 1687 | { |
| 1688 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 1689 | { |
| 1690 | nvram_ut_trace("[NVUT] ota_boot_add_record_reset(): reset LIDs to default setting fail!\n\r"); |
| 1691 | return KAL_FALSE; |
| 1692 | } |
| 1693 | } |
| 1694 | |
| 1695 | //reset test LIDs |
| 1696 | for(i = 0; i < test_lid_number; i++) |
| 1697 | { |
| 1698 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1699 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 1700 | { |
| 1701 | nvram_ut_trace("[NVUT] ota_boot_add_record_reset(): reset test LIDs fail!\n\r"); |
| 1702 | return KAL_FALSE; |
| 1703 | } |
| 1704 | } |
| 1705 | |
| 1706 | //reset SYS LID |
| 1707 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 1708 | { |
| 1709 | nvram_ut_trace("[NVUT] ota_boot_add_record_reset(): reset SYS LID fail!\n\r"); |
| 1710 | return KAL_FALSE; |
| 1711 | } |
| 1712 | |
| 1713 | //modify MD SW version |
| 1714 | if(!modify_md_sw_version()) |
| 1715 | { |
| 1716 | nvram_ut_trace("[NVUT] ota_boot_add_record_reset(): modify MD SW version fail!\n\r"); |
| 1717 | return KAL_FALSE; |
| 1718 | } |
| 1719 | |
| 1720 | //test LID1~LID6 record number +1 |
| 1721 | for(i = 0; i < test_lid_number; i++) |
| 1722 | { |
| 1723 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1724 | ldi->total_records += 1; |
| 1725 | } |
| 1726 | |
| 1727 | //call nvram_init() |
| 1728 | nvram_boot_trace = 0; |
| 1729 | nvram_init(); |
| 1730 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 1731 | { |
| 1732 | nvram_ut_trace("[NVUT] ota_boot_add_record_reset(): enter version conflict fail!\n\r"); |
| 1733 | return KAL_FALSE; |
| 1734 | } |
| 1735 | |
| 1736 | //lid access |
| 1737 | for(i = 0; i<test_lid_number; i++) |
| 1738 | { |
| 1739 | if(0 != nvram_lid_cmpt_operation(test_lid_enum[i], |
| 1740 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 1741 | CMPT_OP_WAY_API, 1, ldi->total_records)) |
| 1742 | { |
| 1743 | nvram_ut_trace("[NVUT] ota_boot_add_record_reset(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 1744 | return KAL_FALSE; |
| 1745 | } |
| 1746 | } |
| 1747 | |
| 1748 | return KAL_TRUE; |
| 1749 | |
| 1750 | } |
| 1751 | |
| 1752 | kal_bool ota_boot_delete_record_read(kal_uint32 flags, void *param) |
| 1753 | { |
| 1754 | nvram_ltable_entry_struct *ldi = NULL; |
| 1755 | kal_uint8 i; |
| 1756 | |
| 1757 | //reset test LIDs to default settings |
| 1758 | for(i = 0; i < test_lid_number; i++) |
| 1759 | { |
| 1760 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 1761 | { |
| 1762 | nvram_ut_trace("[NVUT] ota_boot_delete_record_read(): reset LIDs to default setting fail!\n\r"); |
| 1763 | return KAL_FALSE; |
| 1764 | } |
| 1765 | } |
| 1766 | |
| 1767 | //reset test LIDs |
| 1768 | for(i = 0; i < test_lid_number; i++) |
| 1769 | { |
| 1770 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1771 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 1772 | { |
| 1773 | nvram_ut_trace("[NVUT] ota_boot_delete_record_read(): reset test LIDs fail!\n\r"); |
| 1774 | return KAL_FALSE; |
| 1775 | } |
| 1776 | } |
| 1777 | |
| 1778 | //reset SYS LID |
| 1779 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 1780 | { |
| 1781 | nvram_ut_trace("[NVUT] ota_boot_delete_record_read(): reset SYS LID fail!\n\r"); |
| 1782 | return KAL_FALSE; |
| 1783 | } |
| 1784 | |
| 1785 | //modify MD SW version |
| 1786 | if(!modify_md_sw_version()) |
| 1787 | { |
| 1788 | nvram_ut_trace("[NVUT] ota_boot_delete_record_read(): modify MD SW version fail!\n\r"); |
| 1789 | return KAL_FALSE; |
| 1790 | } |
| 1791 | |
| 1792 | //modify LID's value |
| 1793 | kal_mem_set(cmp_buffer, 0x0, ldi->size); |
| 1794 | cmp_buffer[0] = 0x1; //modify some value |
| 1795 | cmp_buffer[1] = 0x2; |
| 1796 | cmp_buffer[2] = 0x3; |
| 1797 | for(i = 0; i < test_lid_number; i++) |
| 1798 | { |
| 1799 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1800 | if(!(nvram_external_write_data(test_lid_enum[i], ldi->total_records - 1, (kal_uint8 *)cmp_buffer, ldi->size))) |
| 1801 | { |
| 1802 | nvram_ut_trace("[NVUT] ota_boot_delete_record_read(): modify LID's value fail!\n\r"); |
| 1803 | return KAL_FALSE; |
| 1804 | } |
| 1805 | } |
| 1806 | |
| 1807 | //test LID1~LID6 record number -1 |
| 1808 | for(i = 0; i < test_lid_number; i++) |
| 1809 | { |
| 1810 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1811 | ldi->total_records -= 1; |
| 1812 | } |
| 1813 | |
| 1814 | //call nvram_init() |
| 1815 | nvram_boot_trace = 0; |
| 1816 | nvram_init(); |
| 1817 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 1818 | { |
| 1819 | nvram_ut_trace("[NVUT] ota_boot_delete_record_read(): enter version conflict fail!\n\r"); |
| 1820 | return KAL_FALSE; |
| 1821 | } |
| 1822 | |
| 1823 | //lid access |
| 1824 | for(i = 0; i < test_lid_number; i++) |
| 1825 | { |
| 1826 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1827 | if(!(nvram_external_read_data(test_lid_enum[i], ldi->total_records, (kal_uint8 *)data_buffer, ldi->size))) |
| 1828 | { |
| 1829 | nvram_ut_trace("[NVUT] ota_boot_delete_record_read(): read old record fail!\n\r"); |
| 1830 | return KAL_FALSE; |
| 1831 | } |
| 1832 | //old record should keep value |
| 1833 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 1834 | { |
| 1835 | nvram_ut_trace("[NVUT] ota_boot_delete_record_read(): old record value change!\n\r"); |
| 1836 | return KAL_FALSE; |
| 1837 | } |
| 1838 | } |
| 1839 | |
| 1840 | return KAL_TRUE; |
| 1841 | |
| 1842 | } |
| 1843 | |
| 1844 | kal_bool ota_boot_delete_record_write(kal_uint32 flags, void *param) |
| 1845 | { |
| 1846 | nvram_ltable_entry_struct *ldi = NULL; |
| 1847 | kal_uint8 i; |
| 1848 | |
| 1849 | //reset test LIDs to default settings |
| 1850 | for(i = 0; i < test_lid_number; i++) |
| 1851 | { |
| 1852 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 1853 | { |
| 1854 | nvram_ut_trace("[NVUT] ota_boot_delete_record_write(): reset LIDs to default setting fail!\n\r"); |
| 1855 | return KAL_FALSE; |
| 1856 | } |
| 1857 | } |
| 1858 | |
| 1859 | //reset test LIDs |
| 1860 | for(i = 0; i < test_lid_number; i++) |
| 1861 | { |
| 1862 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1863 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 1864 | { |
| 1865 | nvram_ut_trace("[NVUT] ota_boot_delete_record_write(): reset test LIDs fail!\n\r"); |
| 1866 | return KAL_FALSE; |
| 1867 | } |
| 1868 | } |
| 1869 | |
| 1870 | //reset SYS LID |
| 1871 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 1872 | { |
| 1873 | nvram_ut_trace("[NVUT] ota_boot_delete_record_write(): reset SYS LID fail!\n\r"); |
| 1874 | return KAL_FALSE; |
| 1875 | } |
| 1876 | |
| 1877 | //modify MD SW version |
| 1878 | if(!modify_md_sw_version()) |
| 1879 | { |
| 1880 | nvram_ut_trace("[NVUT] ota_boot_delete_record_write(): modify MD SW version fail!\n\r"); |
| 1881 | return KAL_FALSE; |
| 1882 | } |
| 1883 | |
| 1884 | //test LID1~LID6 record number -1 |
| 1885 | for(i = 0; i < test_lid_number; i++) |
| 1886 | { |
| 1887 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1888 | ldi->total_records -= 1; |
| 1889 | } |
| 1890 | |
| 1891 | //call nvram_init() |
| 1892 | nvram_boot_trace = 0; |
| 1893 | nvram_init(); |
| 1894 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 1895 | { |
| 1896 | nvram_ut_trace("[NVUT] ota_boot_delete_record_write(): enter version conflict fail!\n\r"); |
| 1897 | return KAL_FALSE; |
| 1898 | } |
| 1899 | |
| 1900 | //lid access |
| 1901 | for(i = 0; i < test_lid_number; i++) |
| 1902 | { |
| 1903 | if(0 != nvram_lid_cmpt_operation(test_lid_enum[i], |
| 1904 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 1905 | CMPT_OP_WAY_API, 1, ldi->total_records)) |
| 1906 | { |
| 1907 | nvram_ut_trace("[NVUT] ota_boot_delete_record_write(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 1908 | return KAL_FALSE; |
| 1909 | } |
| 1910 | } |
| 1911 | |
| 1912 | return KAL_TRUE; |
| 1913 | |
| 1914 | } |
| 1915 | |
| 1916 | kal_bool ota_boot_delete_record_reset(kal_uint32 flags, void *param) |
| 1917 | { |
| 1918 | nvram_ltable_entry_struct *ldi = NULL; |
| 1919 | kal_uint8 i; |
| 1920 | |
| 1921 | //reset test LIDs to default settings |
| 1922 | for(i = 0; i < test_lid_number; i++) |
| 1923 | { |
| 1924 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 1925 | { |
| 1926 | nvram_ut_trace("[NVUT] ota_boot_delete_record_reset(): reset LIDs to default setting fail!\n\r"); |
| 1927 | return KAL_FALSE; |
| 1928 | } |
| 1929 | } |
| 1930 | |
| 1931 | //reset test LIDs |
| 1932 | for(i = 0; i < test_lid_number; i++) |
| 1933 | { |
| 1934 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1935 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 1936 | { |
| 1937 | nvram_ut_trace("[NVUT] ota_boot_delete_record_reset(): reset test LIDs fail!\n\r"); |
| 1938 | return KAL_FALSE; |
| 1939 | } |
| 1940 | } |
| 1941 | |
| 1942 | //reset SYS LID |
| 1943 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 1944 | { |
| 1945 | nvram_ut_trace("[NVUT] ota_boot_delete_record_reset(): reset SYS LID fail!\n\r"); |
| 1946 | return KAL_FALSE; |
| 1947 | } |
| 1948 | |
| 1949 | //modify MD SW version |
| 1950 | if(!modify_md_sw_version()) |
| 1951 | { |
| 1952 | nvram_ut_trace("[NVUT] ota_boot_delete_record_reset(): modify MD SW version fail!\n\r"); |
| 1953 | return KAL_FALSE; |
| 1954 | } |
| 1955 | |
| 1956 | //test LID1~LID6 record number -1 |
| 1957 | for(i = 0; i < test_lid_number; i++) |
| 1958 | { |
| 1959 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 1960 | ldi->total_records -= 1; |
| 1961 | } |
| 1962 | |
| 1963 | //call nvram_init() |
| 1964 | nvram_boot_trace = 0; |
| 1965 | nvram_init(); |
| 1966 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 1967 | { |
| 1968 | nvram_ut_trace("[NVUT] ota_boot_delete_record_reset(): enter version conflict fail!\n\r"); |
| 1969 | return KAL_FALSE; |
| 1970 | } |
| 1971 | |
| 1972 | //lid access |
| 1973 | for(i = 0; i < test_lid_number; i++) |
| 1974 | { |
| 1975 | if(0 != nvram_lid_cmpt_operation(test_lid_enum[i], |
| 1976 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 1977 | CMPT_OP_WAY_API, 1, ldi->total_records)) |
| 1978 | { |
| 1979 | nvram_ut_trace("[NVUT] ota_boot_delete_record_reset(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 1980 | return KAL_FALSE; |
| 1981 | } |
| 1982 | } |
| 1983 | |
| 1984 | return KAL_TRUE; |
| 1985 | |
| 1986 | } |
| 1987 | |
| 1988 | kal_bool ota_boot_verno_change_previous_lid_access(kal_uint32 flags, void *param) |
| 1989 | { |
| 1990 | nvram_ltable_entry_struct *ldi = NULL; |
| 1991 | kal_uint8 i, j; |
| 1992 | #ifdef __NVRAM_LID_CACHE__ |
| 1993 | nvram_cache_reset();//Disable NVRAM Cache |
| 1994 | #endif |
| 1995 | //delete all files in Z:/BACKUP folder |
| 1996 | FS_XDelete((const WCHAR*)L"Z:\\NVRAM\\BACKUP", (FS_FILE_TYPE|FS_RECURSIVE_TYPE), NULL, 0); |
| 1997 | |
| 1998 | //this test will use LID verno "000"~"001" total 2 version |
| 1999 | for(i = 0; i < test_lid_number; i++) |
| 2000 | { |
| 2001 | if(!delete_special_version_lid(test_lid_enum[i], 0, 1)) |
| 2002 | { |
| 2003 | nvram_ut_trace("[NVUT] ota_boot_verno_change_previous_lid_access(): delete old version LID fail!\n\r"); |
| 2004 | return KAL_FALSE; |
| 2005 | } |
| 2006 | } |
| 2007 | |
| 2008 | //reset test LIDs to default settings |
| 2009 | for(i = 0; i < test_lid_number; i++) |
| 2010 | { |
| 2011 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 2012 | { |
| 2013 | nvram_ut_trace("[NVUT] ota_boot_verno_change_previous_lid_access(): reset LIDs to default setting fail!\n\r"); |
| 2014 | return KAL_FALSE; |
| 2015 | } |
| 2016 | //add NVRAM_ATTR_RESERVE_BACKWARD to test LID |
| 2017 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2018 | ldi->attr |= NVRAM_ATTR_RESERVE_BACKWARD; |
| 2019 | } |
| 2020 | |
| 2021 | //reset test LIDs |
| 2022 | for(i = 0; i < test_lid_number; i++) |
| 2023 | { |
| 2024 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2025 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 2026 | { |
| 2027 | nvram_ut_trace("[NVUT] ota_boot_verno_change_previous_lid_access(): reset test LIDs fail!\n\r"); |
| 2028 | return KAL_FALSE; |
| 2029 | } |
| 2030 | } |
| 2031 | |
| 2032 | //write old LID with non-default value |
| 2033 | cmp_buffer[0] = 0x1; //modify some value |
| 2034 | cmp_buffer[1] = 0x2; |
| 2035 | cmp_buffer[2] = 0x3; |
| 2036 | for(i = 0; i < test_lid_number; i++) |
| 2037 | { |
| 2038 | for(j = 1; j <= NVRAM_EF_TEST_LID_RECORD_TOTAL; j++) |
| 2039 | { |
| 2040 | if(!nvram_external_write_data(test_lid_enum[i], j, (kal_uint8 *)cmp_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 2041 | { |
| 2042 | break; |
| 2043 | } |
| 2044 | } |
| 2045 | |
| 2046 | if(j <= NVRAM_EF_TEST_LID_RECORD_TOTAL) |
| 2047 | { |
| 2048 | nvram_ut_trace("[NVUT] ota_boot_verno_change_previous_lid_access(): write previous LID fail!\n\r"); |
| 2049 | return KAL_FALSE; |
| 2050 | } |
| 2051 | } |
| 2052 | |
| 2053 | //reset SYS LID |
| 2054 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 2055 | { |
| 2056 | nvram_ut_trace("[NVUT] ota_boot_verno_change_previous_lid_access(): reset SYS LID fail!\n\r"); |
| 2057 | return KAL_FALSE; |
| 2058 | } |
| 2059 | |
| 2060 | //modify MD SW version |
| 2061 | if(!modify_md_sw_version()) |
| 2062 | { |
| 2063 | nvram_ut_trace("[NVUT] ota_boot_verno_change_previous_lid_access(): modify MD SW version fail!\n\r"); |
| 2064 | return KAL_FALSE; |
| 2065 | } |
| 2066 | |
| 2067 | //test LID1~LID6 verno +1 |
| 2068 | for(i = 0; i < test_lid_number; i++) |
| 2069 | { |
| 2070 | if(!lid_verno_increase_one(test_lid_enum[i])) |
| 2071 | { |
| 2072 | nvram_ut_trace("[NVUT] ota_boot_verno_change_previous_lid_access(): change LID verno fail!\n\r"); |
| 2073 | return KAL_FALSE; |
| 2074 | } |
| 2075 | } |
| 2076 | |
| 2077 | //call nvram_init() |
| 2078 | nvram_boot_trace = 0; |
| 2079 | |
| 2080 | nvram_init(); |
| 2081 | |
| 2082 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 2083 | { |
| 2084 | nvram_ut_trace("[NVUT] ota_boot_verno_change_previous_lid_access(): enter version conflict fail!\n\r"); |
| 2085 | return KAL_FALSE; |
| 2086 | } |
| 2087 | |
| 2088 | //old version lid access |
| 2089 | for(i = 0; i < test_lid_number; i++) |
| 2090 | { |
| 2091 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2092 | if(!nvram_external_search_reserved_lid(ldi->LID, "000", NVRAM_EF_TEST_LID_RECORD_TOTAL, NVRAM_EF_TEST_LID_SIZE)) |
| 2093 | { |
| 2094 | nvram_ut_trace("[NVUT] ota_boot_verno_change_previous_lid_access(): cannot find previous LID!\n\r"); |
| 2095 | return KAL_FALSE; |
| 2096 | } |
| 2097 | for(j = 1; j <= NVRAM_EF_TEST_LID_RECORD_TOTAL; j++) |
| 2098 | { |
| 2099 | kal_mem_set(data_buffer, 0, ldi->size); |
| 2100 | if(! nvram_external_read_data(NVRAM_EF_READ_RESERVED_LID, j, (kal_uint8 *)data_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 2101 | { |
| 2102 | nvram_ut_trace("[NVUT] ota_boot_verno_change_previous_lid_access(): read reserve LID fail!\n\r"); |
| 2103 | return KAL_FALSE; |
| 2104 | } |
| 2105 | |
| 2106 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 2107 | { |
| 2108 | nvram_ut_trace("[NVUT] ota_boot_verno_change_previous_lid_access(): read back reserve LID changed!\n\r"); |
| 2109 | return KAL_FALSE; |
| 2110 | } |
| 2111 | } |
| 2112 | } |
| 2113 | #ifdef __NVRAM_LID_CACHE__ |
| 2114 | mark_nvram_cache_ready(); |
| 2115 | #endif |
| 2116 | return KAL_TRUE; |
| 2117 | |
| 2118 | } |
| 2119 | |
| 2120 | kal_bool ota_boot_size_change_previous_lid_access(kal_uint32 flags, void *param) |
| 2121 | { |
| 2122 | nvram_ltable_entry_struct *ldi = NULL; |
| 2123 | kal_uint8 i, j; |
| 2124 | |
| 2125 | #ifdef __NVRAM_LID_CACHE__ |
| 2126 | nvram_cache_reset();//Disable NVRAM Cache |
| 2127 | #endif |
| 2128 | |
| 2129 | //delete all files in Z:/BACKUP folder |
| 2130 | FS_XDelete((const WCHAR*)L"Z:\\NVRAM\\BACKUP", (FS_FILE_TYPE|FS_RECURSIVE_TYPE), NULL, 0); |
| 2131 | |
| 2132 | //this test will use LID verno "000"~"001" total 2 version |
| 2133 | for(i = 0; i < test_lid_number; i++) |
| 2134 | { |
| 2135 | if(!delete_special_version_lid(test_lid_enum[i], 0, 1)) |
| 2136 | { |
| 2137 | nvram_ut_trace("[NVUT] ota_boot_size_change_previous_lid_access(): delete old version LID fail!\n\r"); |
| 2138 | return KAL_FALSE; |
| 2139 | } |
| 2140 | } |
| 2141 | |
| 2142 | //reset test LIDs to default settings |
| 2143 | for(i = 0; i < test_lid_number; i++) |
| 2144 | { |
| 2145 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 2146 | { |
| 2147 | nvram_ut_trace("[NVUT] ota_boot_size_change_previous_lid_access(): reset LIDs to default setting fail!\n\r"); |
| 2148 | return KAL_FALSE; |
| 2149 | } |
| 2150 | //add NVRAM_ATTR_RESERVE_BACKWARD to test LID |
| 2151 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2152 | if( NVRAM_IS_CATEGORY_IMPORTANT_L4(ldi->category) || NVRAM_IS_CATEGORY_IN_BIN_REGION(ldi->category)) |
| 2153 | { |
| 2154 | continue; |
| 2155 | } |
| 2156 | ldi->attr |= NVRAM_ATTR_RESERVE_BACKWARD; |
| 2157 | } |
| 2158 | |
| 2159 | //reset test LIDs |
| 2160 | for(i = 0; i < test_lid_number; i++) |
| 2161 | { |
| 2162 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2163 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 2164 | { |
| 2165 | nvram_ut_trace("[NVUT] ota_boot_size_change_previous_lid_access(): reset test LIDs fail!\n\r"); |
| 2166 | return KAL_FALSE; |
| 2167 | } |
| 2168 | } |
| 2169 | |
| 2170 | //write old LID with non-default value |
| 2171 | cmp_buffer[0] = 0x4; //modify some value |
| 2172 | cmp_buffer[1] = 0x5; |
| 2173 | cmp_buffer[2] = 0x6; |
| 2174 | for(i = 0; i < test_lid_number; i++) |
| 2175 | { |
| 2176 | for(j = 1; j <= NVRAM_EF_TEST_LID_RECORD_TOTAL; j++) |
| 2177 | { |
| 2178 | if(!nvram_external_write_data(test_lid_enum[i], j, (kal_uint8 *)cmp_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 2179 | { |
| 2180 | break; |
| 2181 | } |
| 2182 | } |
| 2183 | |
| 2184 | if(j <= NVRAM_EF_TEST_LID_RECORD_TOTAL) |
| 2185 | { |
| 2186 | nvram_ut_trace("[NVUT] ota_boot_size_change_previous_lid_access(): write previous LID fail!\n\r"); |
| 2187 | return KAL_FALSE; |
| 2188 | } |
| 2189 | } |
| 2190 | |
| 2191 | //reset SYS LID |
| 2192 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 2193 | { |
| 2194 | nvram_ut_trace("[NVUT] ota_boot_size_change_previous_lid_access(): reset SYS LID fail!\n\r"); |
| 2195 | return KAL_FALSE; |
| 2196 | } |
| 2197 | |
| 2198 | //modify MD SW version |
| 2199 | if(!modify_md_sw_version()) |
| 2200 | { |
| 2201 | nvram_ut_trace("[NVUT] ota_boot_size_change_previous_lid_access(): modify MD SW version fail!\n\r"); |
| 2202 | return KAL_FALSE; |
| 2203 | } |
| 2204 | |
| 2205 | //test LID1~LID6 verno +1 |
| 2206 | for(i = 0; i < test_lid_number; i++) |
| 2207 | { |
| 2208 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2209 | if( NVRAM_IS_CATEGORY_IMPORTANT_L4(ldi->category) || NVRAM_IS_CATEGORY_IN_BIN_REGION(ldi->category)) |
| 2210 | { |
| 2211 | continue; |
| 2212 | } |
| 2213 | ldi->size += RECORD_CHANGE_SIZE; |
| 2214 | } |
| 2215 | |
| 2216 | //call nvram_init() |
| 2217 | nvram_boot_trace = 0; |
| 2218 | nvram_init(); |
| 2219 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 2220 | { |
| 2221 | nvram_ut_trace("[NVUT] ota_boot_size_change_previous_lid_access(): enter version conflict fail!\n\r"); |
| 2222 | return KAL_FALSE; |
| 2223 | } |
| 2224 | |
| 2225 | //old version lid access |
| 2226 | for(i = 0; i < test_lid_number; i++) |
| 2227 | { |
| 2228 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2229 | if( NVRAM_IS_CATEGORY_IMPORTANT_L4(ldi->category) || NVRAM_IS_CATEGORY_IN_BIN_REGION(ldi->category)) |
| 2230 | { |
| 2231 | continue; |
| 2232 | } |
| 2233 | if(!nvram_external_search_reserved_lid(ldi->LID, "000", NVRAM_EF_TEST_LID_RECORD_TOTAL, NVRAM_EF_TEST_LID_SIZE)) |
| 2234 | { |
| 2235 | nvram_ut_trace("[NVUT]ldi->LID(0x%x) ota_boot_size_change_previous_lid_access(): cannot find previous LID!\n\r", ldi->LID); |
| 2236 | return KAL_FALSE; |
| 2237 | } |
| 2238 | for(j = 1; j <= NVRAM_EF_TEST_LID_RECORD_TOTAL; j++) |
| 2239 | { |
| 2240 | kal_mem_set(data_buffer, 0, ldi->size); |
| 2241 | if(! nvram_external_read_data(NVRAM_EF_READ_RESERVED_LID, j, (kal_uint8 *)data_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 2242 | { |
| 2243 | nvram_ut_trace("[NVUT] ota_boot_size_change_previous_lid_access(): read reserve LID fail!\n\r"); |
| 2244 | return KAL_FALSE; |
| 2245 | } |
| 2246 | |
| 2247 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 2248 | { |
| 2249 | nvram_ut_trace("[NVUT] ota_boot_size_change_previous_lid_access(): read back reserve LID changed!\n\r"); |
| 2250 | return KAL_FALSE; |
| 2251 | } |
| 2252 | } |
| 2253 | } |
| 2254 | #ifdef __NVRAM_LID_CACHE__ |
| 2255 | mark_nvram_cache_ready(); |
| 2256 | #endif |
| 2257 | return KAL_TRUE; |
| 2258 | |
| 2259 | } |
| 2260 | |
| 2261 | |
| 2262 | kal_bool ota_boot_record_change_previous_lid_access(kal_uint32 flags, void *param) |
| 2263 | { |
| 2264 | nvram_ltable_entry_struct *ldi = NULL; |
| 2265 | kal_uint8 i, j; |
| 2266 | |
| 2267 | #ifdef __NVRAM_LID_CACHE__ |
| 2268 | nvram_cache_reset();//Disable NVRAM Cache |
| 2269 | #endif |
| 2270 | |
| 2271 | //delete all files in Z:/BACKUP folder |
| 2272 | FS_XDelete((const WCHAR*)L"Z:\\NVRAM\\BACKUP", (FS_FILE_TYPE|FS_RECURSIVE_TYPE), NULL, 0); |
| 2273 | |
| 2274 | //this test will use LID verno "000"~"001" total 2 version |
| 2275 | for(i = 0; i < test_lid_number; i++) |
| 2276 | { |
| 2277 | if(!delete_special_version_lid(test_lid_enum[i], 0, 1)) |
| 2278 | { |
| 2279 | nvram_ut_trace("[NVUT] ota_boot_record_change_previous_lid_access(): delete old version LID fail!\n\r"); |
| 2280 | return KAL_FALSE; |
| 2281 | } |
| 2282 | } |
| 2283 | |
| 2284 | //reset test LIDs to default settings |
| 2285 | for(i = 0; i < test_lid_number; i++) |
| 2286 | { |
| 2287 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 2288 | { |
| 2289 | nvram_ut_trace("[NVUT] ota_boot_record_change_previous_lid_access(): reset LIDs to default setting fail!\n\r"); |
| 2290 | return KAL_FALSE; |
| 2291 | } |
| 2292 | //add NVRAM_ATTR_RESERVE_BACKWARD to test LID |
| 2293 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2294 | if( NVRAM_IS_CATEGORY_IMPORTANT_L4(ldi->category) || NVRAM_IS_CATEGORY_IN_BIN_REGION(ldi->category)) |
| 2295 | { |
| 2296 | continue; |
| 2297 | } |
| 2298 | ldi->attr |= NVRAM_ATTR_RESERVE_BACKWARD; |
| 2299 | } |
| 2300 | |
| 2301 | //reset test LIDs |
| 2302 | for(i = 0; i < test_lid_number; i++) |
| 2303 | { |
| 2304 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2305 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 2306 | { |
| 2307 | nvram_ut_trace("[NVUT] ota_boot_record_change_previous_lid_access(): reset test LIDs fail!\n\r"); |
| 2308 | return KAL_FALSE; |
| 2309 | } |
| 2310 | } |
| 2311 | |
| 2312 | //write old LID with non-default value |
| 2313 | cmp_buffer[0] = 0x4; //modify some value |
| 2314 | cmp_buffer[1] = 0x5; |
| 2315 | cmp_buffer[2] = 0x6; |
| 2316 | for(i = 0; i < test_lid_number; i++) |
| 2317 | { |
| 2318 | for(j = 1; j <= NVRAM_EF_TEST_LID_RECORD_TOTAL; j++) |
| 2319 | { |
| 2320 | if(!nvram_external_write_data(test_lid_enum[i], j, (kal_uint8 *)cmp_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 2321 | { |
| 2322 | break; |
| 2323 | } |
| 2324 | } |
| 2325 | |
| 2326 | if(j <= NVRAM_EF_TEST_LID_RECORD_TOTAL) |
| 2327 | { |
| 2328 | nvram_ut_trace("[NVUT] ota_boot_record_change_previous_lid_access(): write previous LID fail!\n\r"); |
| 2329 | return KAL_FALSE; |
| 2330 | } |
| 2331 | } |
| 2332 | |
| 2333 | //reset SYS LID |
| 2334 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 2335 | { |
| 2336 | nvram_ut_trace("[NVUT] ota_boot_record_change_previous_lid_access(): reset SYS LID fail!\n\r"); |
| 2337 | return KAL_FALSE; |
| 2338 | } |
| 2339 | |
| 2340 | //modify MD SW version |
| 2341 | if(!modify_md_sw_version()) |
| 2342 | { |
| 2343 | nvram_ut_trace("[NVUT] ota_boot_record_change_previous_lid_access(): modify MD SW version fail!\n\r"); |
| 2344 | return KAL_FALSE; |
| 2345 | } |
| 2346 | |
| 2347 | //test LID1~LID6 verno +1 |
| 2348 | for(i = 0; i < test_lid_number; i++) |
| 2349 | { |
| 2350 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2351 | if( NVRAM_IS_CATEGORY_IMPORTANT_L4(ldi->category) || NVRAM_IS_CATEGORY_IN_BIN_REGION(ldi->category)) |
| 2352 | { |
| 2353 | continue; |
| 2354 | } |
| 2355 | ldi->total_records += 1; |
| 2356 | } |
| 2357 | |
| 2358 | //call nvram_init() |
| 2359 | nvram_boot_trace = 0; |
| 2360 | nvram_init(); |
| 2361 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 2362 | { |
| 2363 | nvram_ut_trace("[NVUT]ldi->LID(0x%x) ota_boot_record_change_previous_lid_access(): enter version conflict fail!\n\r", ldi->LID); |
| 2364 | return KAL_FALSE; |
| 2365 | } |
| 2366 | |
| 2367 | //old version lid access |
| 2368 | for(i = 0; i < test_lid_number; i++) |
| 2369 | { |
| 2370 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2371 | if( NVRAM_IS_CATEGORY_IMPORTANT_L4(ldi->category) || NVRAM_IS_CATEGORY_IN_BIN_REGION(ldi->category)) |
| 2372 | { |
| 2373 | continue; |
| 2374 | } |
| 2375 | if(!nvram_external_search_reserved_lid(ldi->LID, "000", NVRAM_EF_TEST_LID_RECORD_TOTAL, NVRAM_EF_TEST_LID_SIZE)) |
| 2376 | { |
| 2377 | nvram_ut_trace("[NVUT] ota_boot_record_change_previous_lid_access(): cannot find previous LID!\n\r"); |
| 2378 | return KAL_FALSE; |
| 2379 | } |
| 2380 | for(j = 1; j <= NVRAM_EF_TEST_LID_RECORD_TOTAL; j++) |
| 2381 | { |
| 2382 | kal_mem_set(data_buffer, 0, ldi->size); |
| 2383 | if(! nvram_external_read_data(NVRAM_EF_READ_RESERVED_LID, j, (kal_uint8 *)data_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 2384 | { |
| 2385 | nvram_ut_trace("[NVUT] ota_boot_record_change_previous_lid_access(): read reserve LID fail!\n\r"); |
| 2386 | return KAL_FALSE; |
| 2387 | } |
| 2388 | |
| 2389 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 2390 | { |
| 2391 | nvram_ut_trace("[NVUT] ota_boot_record_change_previous_lid_access(): read back reserve LID changed!\n\r"); |
| 2392 | return KAL_FALSE; |
| 2393 | } |
| 2394 | } |
| 2395 | } |
| 2396 | #ifdef __NVRAM_LID_CACHE__ |
| 2397 | mark_nvram_cache_ready(); |
| 2398 | #endif |
| 2399 | return KAL_TRUE; |
| 2400 | |
| 2401 | } |
| 2402 | |
| 2403 | |
| 2404 | kal_bool ota_boot_extend_record_read(kal_uint32 flags, void *param) |
| 2405 | { |
| 2406 | nvram_ltable_entry_struct *ldi = NULL; |
| 2407 | kal_uint8 i; |
| 2408 | |
| 2409 | //reset test LIDs to default settings |
| 2410 | for(i = 0; i < test_lid_number; i++) |
| 2411 | { |
| 2412 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 2413 | { |
| 2414 | nvram_ut_trace("[NVUT] ota_boot_extend_record_read(): reset LIDs to default setting fail!\n\r"); |
| 2415 | return KAL_FALSE; |
| 2416 | } |
| 2417 | } |
| 2418 | |
| 2419 | //set test LID1~LID6 record number to 1, reset LID, write LID, extend record size |
| 2420 | cmp_buffer[0] = 0x1; //modify some value |
| 2421 | cmp_buffer[1] = 0x2; |
| 2422 | cmp_buffer[2] = 0x3; |
| 2423 | for(i = 0; i < test_lid_number; i++) |
| 2424 | { |
| 2425 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2426 | ldi->total_records = 1; |
| 2427 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 2428 | { |
| 2429 | nvram_ut_trace("[NVUT] ota_boot_extend_record_read(): reset LID fail!\n\r"); |
| 2430 | return KAL_FALSE; |
| 2431 | } |
| 2432 | if(!nvram_external_write_data(test_lid_enum[i], 1, (kal_uint8 *)cmp_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 2433 | { |
| 2434 | nvram_ut_trace("[NVUT] ota_boot_extend_record_read(): write previous LID fail!\n\r"); |
| 2435 | return KAL_FALSE; |
| 2436 | } |
| 2437 | ldi->size += RECORD_CHANGE_SIZE; |
| 2438 | } |
| 2439 | |
| 2440 | //reset SYS LID |
| 2441 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 2442 | { |
| 2443 | nvram_ut_trace("[NVUT] ota_boot_extend_record_read(): reset SYS LID fail!\n\r"); |
| 2444 | return KAL_FALSE; |
| 2445 | } |
| 2446 | |
| 2447 | //modify MD SW version |
| 2448 | if(!modify_md_sw_version()) |
| 2449 | { |
| 2450 | nvram_ut_trace("[NVUT] ota_boot_extend_record_read(): modify MD SW version fail!\n\r"); |
| 2451 | return KAL_FALSE; |
| 2452 | } |
| 2453 | |
| 2454 | //call nvram_init() |
| 2455 | nvram_boot_trace = 0; |
| 2456 | nvram_init(); |
| 2457 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 2458 | { |
| 2459 | nvram_ut_trace("[NVUT] ota_boot_extend_record_read(): enter version conflict fail!\n\r"); |
| 2460 | return KAL_FALSE; |
| 2461 | } |
| 2462 | |
| 2463 | //new LID access |
| 2464 | for(i = 0; i < test_lid_number; i++) |
| 2465 | { |
| 2466 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2467 | if(!nvram_external_read_data(test_lid_enum[i], 1, (kal_uint8 *)data_buffer, NVRAM_EF_TEST_LID_SIZE + RECORD_CHANGE_SIZE)) |
| 2468 | { |
| 2469 | nvram_ut_trace("[NVUT] ota_boot_extend_record_read(): read fail!\n\r"); |
| 2470 | return KAL_FALSE; |
| 2471 | } |
| 2472 | |
| 2473 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 2474 | { |
| 2475 | nvram_ut_trace("[NVUT] ota_boot_extend_record_read(): old data changed!\n\r"); |
| 2476 | return KAL_FALSE; |
| 2477 | } |
| 2478 | |
| 2479 | nvram_get_default_value_to_write(ldi, i, (kal_uint8 *)cmp_buffer, ldi->size); |
| 2480 | if(0 != kal_mem_cmp((kal_char*)(&data_buffer[NVRAM_EF_TEST_LID_SIZE]), (kal_char*)(&cmp_buffer[NVRAM_EF_TEST_LID_SIZE]), RECORD_CHANGE_SIZE)) |
| 2481 | { |
| 2482 | nvram_ut_trace("[NVUT] ota_boot_extend_record_read(): extend data is not as expect!\n\r"); |
| 2483 | return KAL_FALSE; |
| 2484 | } |
| 2485 | } |
| 2486 | |
| 2487 | return KAL_TRUE; |
| 2488 | |
| 2489 | } |
| 2490 | |
| 2491 | kal_bool ota_boot_extend_record_write(kal_uint32 flags, void *param) |
| 2492 | { |
| 2493 | nvram_ltable_entry_struct *ldi = NULL; |
| 2494 | kal_uint8 i; |
| 2495 | |
| 2496 | //reset test LIDs to default settings |
| 2497 | for(i = 0; i < test_lid_number; i++) |
| 2498 | { |
| 2499 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 2500 | { |
| 2501 | nvram_ut_trace("[NVUT] ota_boot_extend_record_write(): reset LIDs to default setting fail!\n\r"); |
| 2502 | return KAL_FALSE; |
| 2503 | } |
| 2504 | } |
| 2505 | |
| 2506 | //extend record size |
| 2507 | for(i = 0; i < test_lid_number; i++) |
| 2508 | { |
| 2509 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2510 | ldi->total_records = 1; |
| 2511 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 2512 | { |
| 2513 | |
| 2514 | return KAL_FALSE; |
| 2515 | } |
| 2516 | ldi->size += RECORD_CHANGE_SIZE; |
| 2517 | } |
| 2518 | |
| 2519 | //reset SYS LID |
| 2520 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 2521 | { |
| 2522 | nvram_ut_trace("[NVUT] ota_boot_extend_record_write(): reset SYS LID fail!\n\r"); |
| 2523 | return KAL_FALSE; |
| 2524 | } |
| 2525 | |
| 2526 | //modify MD SW version |
| 2527 | if(!modify_md_sw_version()) |
| 2528 | { |
| 2529 | nvram_ut_trace("[NVUT] ota_boot_extend_record_write(): modify MD SW version fail!\n\r"); |
| 2530 | return KAL_FALSE; |
| 2531 | } |
| 2532 | |
| 2533 | //call nvram_init() |
| 2534 | nvram_boot_trace = 0; |
| 2535 | nvram_init(); |
| 2536 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 2537 | { |
| 2538 | nvram_ut_trace("[NVUT] ota_boot_extend_record_write(): enter version conflict fail!\n\r"); |
| 2539 | return KAL_FALSE; |
| 2540 | } |
| 2541 | |
| 2542 | //new LID access |
| 2543 | data_buffer[0] = 0x1; |
| 2544 | data_buffer[1] = 0x2; |
| 2545 | data_buffer[2] = 0x3; |
| 2546 | for(i = 0; i < test_lid_number; i++) |
| 2547 | { |
| 2548 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2549 | if(!nvram_external_write_data(test_lid_enum[i], 1, (kal_uint8 *)data_buffer, NVRAM_EF_TEST_LID_SIZE + RECORD_CHANGE_SIZE)) |
| 2550 | { |
| 2551 | nvram_ut_trace("[NVUT] ota_boot_extend_record_write(): write extend LID fail!\n\r"); |
| 2552 | return KAL_FALSE; |
| 2553 | } |
| 2554 | |
| 2555 | if(!nvram_external_read_data(test_lid_enum[i], 1, (kal_uint8 *)cmp_buffer, NVRAM_EF_TEST_LID_SIZE + RECORD_CHANGE_SIZE)) |
| 2556 | { |
| 2557 | nvram_ut_trace("[NVUT] ota_boot_extend_record_write(): read extend LID fail!\n\r"); |
| 2558 | return KAL_FALSE; |
| 2559 | } |
| 2560 | |
| 2561 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, NVRAM_EF_TEST_LID_SIZE + RECORD_CHANGE_SIZE)) |
| 2562 | { |
| 2563 | nvram_ut_trace("[NVUT] ota_boot_extend_record_write(): read back value is not expect!\n\r"); |
| 2564 | return KAL_FALSE; |
| 2565 | } |
| 2566 | } |
| 2567 | |
| 2568 | return KAL_TRUE; |
| 2569 | |
| 2570 | } |
| 2571 | |
| 2572 | kal_bool ota_boot_extend_record_reset(kal_uint32 flags, void *param) |
| 2573 | { |
| 2574 | nvram_ltable_entry_struct *ldi = NULL; |
| 2575 | kal_uint8 i; |
| 2576 | |
| 2577 | //reset test LIDs to default settings |
| 2578 | for(i = 0; i < test_lid_number; i++) |
| 2579 | { |
| 2580 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 2581 | { |
| 2582 | nvram_ut_trace("[NVUT] ota_boot_extend_record_reset(): reset LIDs to default setting fail!\n\r"); |
| 2583 | return KAL_FALSE; |
| 2584 | } |
| 2585 | } |
| 2586 | |
| 2587 | //set test LID1~LID6 record number to 1, reset LID, write LID, extend record size |
| 2588 | cmp_buffer[0] = 0x1; //modify some value |
| 2589 | cmp_buffer[1] = 0x2; |
| 2590 | cmp_buffer[2] = 0x3; |
| 2591 | for(i = 0; i < test_lid_number; i++) |
| 2592 | { |
| 2593 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2594 | ldi->total_records = 1; |
| 2595 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 2596 | { |
| 2597 | nvram_ut_trace("[NVUT] ota_boot_extend_record_reset(): reset previous LID fail!\n\r"); |
| 2598 | return KAL_FALSE; |
| 2599 | } |
| 2600 | if(!nvram_external_write_data(test_lid_enum[i], 1, (kal_uint8 *)cmp_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 2601 | { |
| 2602 | nvram_ut_trace("[NVUT] ota_boot_extend_record_reset(): write previous LID fail!\n\r"); |
| 2603 | return KAL_FALSE; |
| 2604 | } |
| 2605 | ldi->size += RECORD_CHANGE_SIZE; |
| 2606 | } |
| 2607 | |
| 2608 | //reset SYS LID |
| 2609 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 2610 | { |
| 2611 | nvram_ut_trace("[NVUT] ota_boot_extend_record_reset(): reset SYS LID fail!\n\r"); |
| 2612 | return KAL_FALSE; |
| 2613 | } |
| 2614 | |
| 2615 | //modify MD SW version |
| 2616 | if(!modify_md_sw_version()) |
| 2617 | { |
| 2618 | nvram_ut_trace("[NVUT] ota_boot_extend_record_reset(): modify MD SW version fail!\n\r"); |
| 2619 | return KAL_FALSE; |
| 2620 | } |
| 2621 | |
| 2622 | //call nvram_init() |
| 2623 | nvram_boot_trace = 0; |
| 2624 | nvram_init(); |
| 2625 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 2626 | { |
| 2627 | nvram_ut_trace("[NVUT] ota_boot_extend_record_reset(): enter version conflict fail!\n\r"); |
| 2628 | return KAL_FALSE; |
| 2629 | } |
| 2630 | |
| 2631 | //new LID access |
| 2632 | for(i = 0; i < test_lid_number; i++) |
| 2633 | { |
| 2634 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2635 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 2636 | { |
| 2637 | nvram_ut_trace("[NVUT] ota_boot_extend_record_reset(): reset extend LID fail!\n\r"); |
| 2638 | return KAL_FALSE; |
| 2639 | } |
| 2640 | |
| 2641 | if(!nvram_external_read_data(test_lid_enum[i], 1, (kal_uint8 *)data_buffer, NVRAM_EF_TEST_LID_SIZE + RECORD_CHANGE_SIZE)) |
| 2642 | { |
| 2643 | nvram_ut_trace("[NVUT] ota_boot_extend_record_reset(): read extend LID fail!\n\r"); |
| 2644 | return KAL_FALSE; |
| 2645 | } |
| 2646 | |
| 2647 | nvram_get_default_value_to_write(ldi, i, (kal_uint8 *)cmp_buffer, ldi->size); |
| 2648 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, NVRAM_EF_TEST_LID_SIZE + RECORD_CHANGE_SIZE)) |
| 2649 | { |
| 2650 | nvram_ut_trace("[NVUT] ota_boot_extend_record_reset(): read extend LID fail!\n\r"); |
| 2651 | return KAL_FALSE; |
| 2652 | } |
| 2653 | } |
| 2654 | |
| 2655 | return KAL_TRUE; |
| 2656 | |
| 2657 | } |
| 2658 | |
| 2659 | kal_bool ota_boot_minish_record_read(kal_uint32 flags, void *param) |
| 2660 | { |
| 2661 | nvram_ltable_entry_struct *ldi = NULL; |
| 2662 | kal_uint8 i; |
| 2663 | |
| 2664 | //reset test LIDs to default settings |
| 2665 | for(i = 0; i < test_lid_number; i++) |
| 2666 | { |
| 2667 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 2668 | { |
| 2669 | nvram_ut_trace("[NVUT] ota_boot_minish_record_read(): reset LIDs to default setting fail!\n\r"); |
| 2670 | return KAL_FALSE; |
| 2671 | } |
| 2672 | } |
| 2673 | |
| 2674 | //set test LID1~LID6 record number to 1, reset LID, write LID, minish record size |
| 2675 | cmp_buffer[0] = 0x1; //modify some value |
| 2676 | cmp_buffer[1] = 0x2; |
| 2677 | cmp_buffer[2] = 0x3; |
| 2678 | for(i = 0; i < test_lid_number; i++) |
| 2679 | { |
| 2680 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2681 | ldi->total_records = 1; |
| 2682 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 2683 | { |
| 2684 | nvram_ut_trace("[NVUT] ota_boot_minish_record_read(): reset previous LID fail!\n\r"); |
| 2685 | return KAL_FALSE; |
| 2686 | } |
| 2687 | if(!nvram_external_write_data(test_lid_enum[i], 1, (kal_uint8 *)cmp_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 2688 | { |
| 2689 | nvram_ut_trace("[NVUT] ota_boot_minish_record_read(): write previous LID fail!\n\r"); |
| 2690 | return KAL_FALSE; |
| 2691 | } |
| 2692 | ldi->size -= RECORD_CHANGE_SIZE; |
| 2693 | } |
| 2694 | |
| 2695 | //reset SYS LID |
| 2696 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 2697 | { |
| 2698 | nvram_ut_trace("[NVUT] ota_boot_minish_record_read(): reset SYS LID fail!\n\r"); |
| 2699 | return KAL_FALSE; |
| 2700 | } |
| 2701 | |
| 2702 | //modify MD SW version |
| 2703 | if(!modify_md_sw_version()) |
| 2704 | { |
| 2705 | nvram_ut_trace("[NVUT] ota_boot_minish_record_read(): modify MD SW version fail!\n\r"); |
| 2706 | return KAL_FALSE; |
| 2707 | } |
| 2708 | |
| 2709 | //call nvram_init() |
| 2710 | nvram_boot_trace = 0; |
| 2711 | nvram_init(); |
| 2712 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 2713 | { |
| 2714 | nvram_ut_trace("[NVUT] ota_boot_minish_record_read(): enter version conflict fail!\n\r"); |
| 2715 | return KAL_FALSE; |
| 2716 | } |
| 2717 | |
| 2718 | //new LID access |
| 2719 | for(i = 0; i < test_lid_number; i++) |
| 2720 | { |
| 2721 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2722 | if(!nvram_external_read_data(test_lid_enum[i], 1, (kal_uint8 *)data_buffer, NVRAM_EF_TEST_LID_SIZE - RECORD_CHANGE_SIZE)) |
| 2723 | { |
| 2724 | nvram_ut_trace("[NVUT] ota_boot_minish_record_read(): read extend record fail!\n\r"); |
| 2725 | return KAL_FALSE; |
| 2726 | } |
| 2727 | |
| 2728 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, ldi->size)) |
| 2729 | { |
| 2730 | nvram_ut_trace("[NVUT] ota_boot_minish_record_read(): read back extend LID not expect!\n\r"); |
| 2731 | return KAL_FALSE; |
| 2732 | } |
| 2733 | } |
| 2734 | |
| 2735 | return KAL_TRUE; |
| 2736 | |
| 2737 | } |
| 2738 | |
| 2739 | kal_bool ota_boot_minish_record_write(kal_uint32 flags, void *param) |
| 2740 | { |
| 2741 | nvram_ltable_entry_struct *ldi = NULL; |
| 2742 | kal_uint8 i; |
| 2743 | |
| 2744 | //reset test LIDs to default settings |
| 2745 | for(i = 0; i < test_lid_number; i++) |
| 2746 | { |
| 2747 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 2748 | { |
| 2749 | nvram_ut_trace("[NVUT] ota_boot_minish_record_write(): reset LIDs to default setting fail!\n\r"); |
| 2750 | return KAL_FALSE; |
| 2751 | } |
| 2752 | } |
| 2753 | |
| 2754 | //minish record size |
| 2755 | for(i = 0; i < test_lid_number; i++) |
| 2756 | { |
| 2757 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2758 | ldi->total_records = 1; |
| 2759 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 2760 | { |
| 2761 | nvram_ut_trace("[NVUT] ota_boot_minish_record_write(): reset previous LID fail!\n\r"); |
| 2762 | return KAL_FALSE; |
| 2763 | } |
| 2764 | ldi->size -= RECORD_CHANGE_SIZE; |
| 2765 | } |
| 2766 | |
| 2767 | //reset SYS LID |
| 2768 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 2769 | { |
| 2770 | nvram_ut_trace("[NVUT] ota_boot_minish_record_write(): reset SYS LID fail!\n\r"); |
| 2771 | return KAL_FALSE; |
| 2772 | } |
| 2773 | |
| 2774 | //modify MD SW version |
| 2775 | if(!modify_md_sw_version()) |
| 2776 | { |
| 2777 | nvram_ut_trace("[NVUT] ota_boot_minish_record_write(): modify MD SW version fail!\n\r"); |
| 2778 | return KAL_FALSE; |
| 2779 | } |
| 2780 | |
| 2781 | //call nvram_init() |
| 2782 | nvram_boot_trace = 0; |
| 2783 | nvram_init(); |
| 2784 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 2785 | { |
| 2786 | nvram_ut_trace("[NVUT] ota_boot_minish_record_write(): enter version conflict fail!\n\r"); |
| 2787 | return KAL_FALSE; |
| 2788 | } |
| 2789 | |
| 2790 | //new LID access |
| 2791 | data_buffer[0] = 0x1; |
| 2792 | data_buffer[1] = 0x2; |
| 2793 | data_buffer[2] = 0x3; |
| 2794 | for(i = 0; i < test_lid_number; i++) |
| 2795 | { |
| 2796 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2797 | if(!nvram_external_write_data(test_lid_enum[i], 1, (kal_uint8 *)data_buffer, NVRAM_EF_TEST_LID_SIZE - RECORD_CHANGE_SIZE)) |
| 2798 | { |
| 2799 | nvram_ut_trace("[NVUT] ota_boot_minish_record_write(): write extend LID fail!\n\r"); |
| 2800 | return KAL_FALSE; |
| 2801 | } |
| 2802 | |
| 2803 | if(!nvram_external_read_data(test_lid_enum[i], 1, (kal_uint8 *)cmp_buffer, NVRAM_EF_TEST_LID_SIZE - RECORD_CHANGE_SIZE)) |
| 2804 | { |
| 2805 | nvram_ut_trace("[NVUT] ota_boot_minish_record_write(): read extend LID fail!\n\r"); |
| 2806 | return KAL_FALSE; |
| 2807 | } |
| 2808 | |
| 2809 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, NVRAM_EF_TEST_LID_SIZE - RECORD_CHANGE_SIZE)) |
| 2810 | { |
| 2811 | nvram_ut_trace("[NVUT] ota_boot_minish_record_write(): read back extend LID not expect!\n\r"); |
| 2812 | return KAL_FALSE; |
| 2813 | } |
| 2814 | } |
| 2815 | |
| 2816 | return KAL_TRUE; |
| 2817 | |
| 2818 | } |
| 2819 | |
| 2820 | kal_bool ota_boot_minish_record_reset(kal_uint32 flags, void *param) |
| 2821 | { |
| 2822 | nvram_ltable_entry_struct *ldi = NULL; |
| 2823 | kal_uint8 i; |
| 2824 | |
| 2825 | //reset test LIDs to default settings |
| 2826 | for(i = 0; i < test_lid_number; i++) |
| 2827 | { |
| 2828 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 2829 | { |
| 2830 | nvram_ut_trace("[NVUT] ota_boot_minish_record_reset(): reset LIDs to default setting fail!\n\r"); |
| 2831 | return KAL_FALSE; |
| 2832 | } |
| 2833 | } |
| 2834 | |
| 2835 | //set test LID1~LID6 record number to 1, reset LID, write LID, minish record size |
| 2836 | cmp_buffer[0] = 0x1; //modify some value |
| 2837 | cmp_buffer[1] = 0x2; |
| 2838 | cmp_buffer[2] = 0x3; |
| 2839 | for(i = 0; i < test_lid_number; i++) |
| 2840 | { |
| 2841 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2842 | ldi->total_records = 1; |
| 2843 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 2844 | { |
| 2845 | nvram_ut_trace("[NVUT] ota_boot_minish_record_reset(): reset previous LID fail!\n\r"); |
| 2846 | return KAL_FALSE; |
| 2847 | } |
| 2848 | if(!nvram_external_write_data(test_lid_enum[i], 1, (kal_uint8 *)cmp_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 2849 | { |
| 2850 | nvram_ut_trace("[NVUT] ota_boot_minish_record_reset(): write previous LID fail!\n\r"); |
| 2851 | return KAL_FALSE; |
| 2852 | } |
| 2853 | ldi->size -= RECORD_CHANGE_SIZE; |
| 2854 | } |
| 2855 | |
| 2856 | //reset SYS LID |
| 2857 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 2858 | { |
| 2859 | nvram_ut_trace("[NVUT] ota_boot_minish_record_reset(): reset SYS LID fail!\n\r"); |
| 2860 | return KAL_FALSE; |
| 2861 | } |
| 2862 | |
| 2863 | //modify MD SW version |
| 2864 | if(!modify_md_sw_version()) |
| 2865 | { |
| 2866 | nvram_ut_trace("[NVUT] ota_boot_minish_record_reset(): modify MD SW version fail!\n\r"); |
| 2867 | return KAL_FALSE; |
| 2868 | } |
| 2869 | |
| 2870 | //call nvram_init() |
| 2871 | nvram_boot_trace = 0; |
| 2872 | nvram_init(); |
| 2873 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 2874 | { |
| 2875 | nvram_ut_trace("[NVUT] ota_boot_minish_record_reset(): enter version conflict fail!\n\r"); |
| 2876 | return KAL_FALSE; |
| 2877 | } |
| 2878 | |
| 2879 | //new LID access |
| 2880 | for(i = 0; i < test_lid_number; i++) |
| 2881 | { |
| 2882 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 2883 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 2884 | { |
| 2885 | nvram_ut_trace("[NVUT] ota_boot_minish_record_reset(): reset extend LID fail!\n\r"); |
| 2886 | return KAL_FALSE; |
| 2887 | } |
| 2888 | |
| 2889 | if(!nvram_external_read_data(test_lid_enum[i], 1, (kal_uint8 *)data_buffer, NVRAM_EF_TEST_LID_SIZE - RECORD_CHANGE_SIZE)) |
| 2890 | { |
| 2891 | nvram_ut_trace("[NVUT] ota_boot_minish_record_reset(): read extend LID fail!\n\r"); |
| 2892 | return KAL_FALSE; |
| 2893 | } |
| 2894 | |
| 2895 | nvram_get_default_value_to_write(ldi, i, (kal_uint8 *)cmp_buffer, ldi->size); |
| 2896 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, NVRAM_EF_TEST_LID_SIZE - RECORD_CHANGE_SIZE)) |
| 2897 | { |
| 2898 | nvram_ut_trace("[NVUT] ota_boot_minish_record_reset(): read back extend LID not expect!\n\r"); |
| 2899 | return KAL_FALSE; |
| 2900 | } |
| 2901 | } |
| 2902 | |
| 2903 | return KAL_TRUE; |
| 2904 | |
| 2905 | } |
| 2906 | |
| 2907 | kal_bool ota_boot_user_size_change_read(kal_uint32 flags, void *param) |
| 2908 | { |
| 2909 | nvram_ltable_entry_struct *ldi = NULL; |
| 2910 | |
| 2911 | #ifdef __NVRAM_LID_CACHE__ |
| 2912 | nvram_cache_reset();//Disable NVRAM Cache |
| 2913 | #endif |
| 2914 | |
| 2915 | //reset test LIDs to default settings |
| 2916 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID)) |
| 2917 | { |
| 2918 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_read(): reset LIDs to default setting fail!\n\r"); |
| 2919 | return KAL_FALSE; |
| 2920 | } |
| 2921 | |
| 2922 | //delete old LID |
| 2923 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 2924 | { |
| 2925 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_read(): delete test LID fail!\n\r"); |
| 2926 | } |
| 2927 | |
| 2928 | //change test LID record size |
| 2929 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 2930 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 2931 | { |
| 2932 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_read(): reset test LID fail!\n\r"); |
| 2933 | return KAL_FALSE; |
| 2934 | } |
| 2935 | ldi->size += RECORD_CHANGE_SIZE; |
| 2936 | |
| 2937 | //reset SYS LID |
| 2938 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 2939 | { |
| 2940 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_read(): reset SYS LID fail!\n\r"); |
| 2941 | return KAL_FALSE; |
| 2942 | } |
| 2943 | |
| 2944 | //modify MD SW version |
| 2945 | if(!modify_md_sw_version()) |
| 2946 | { |
| 2947 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_read(): modify MD SW version fail!\n\r"); |
| 2948 | return KAL_FALSE; |
| 2949 | } |
| 2950 | |
| 2951 | //call nvram_init() |
| 2952 | nvram_boot_trace = 0; |
| 2953 | nvram_init(); |
| 2954 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 2955 | { |
| 2956 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_read(): enter version conflict fail!\n\r"); |
| 2957 | return KAL_FALSE; |
| 2958 | } |
| 2959 | |
| 2960 | //new LID access |
| 2961 | nvram_ut_assert_flag = 0; |
| 2962 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 2963 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, 0, 0, 0), |
| 2964 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 2965 | { |
| 2966 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_read(): read LID fail!\n\r"); |
| 2967 | return KAL_FALSE; |
| 2968 | } |
| 2969 | |
| 2970 | if(0 != nvram_ut_assert_flag) |
| 2971 | { |
| 2972 | nvram_ut_trace("nvram_ut_assert_flag: %d.\n\r", nvram_ut_assert_flag); |
| 2973 | return KAL_FALSE; |
| 2974 | } |
| 2975 | #ifdef __NVRAM_LID_CACHE__ |
| 2976 | mark_nvram_cache_ready(); |
| 2977 | #endif |
| 2978 | return KAL_TRUE; |
| 2979 | |
| 2980 | } |
| 2981 | |
| 2982 | |
| 2983 | kal_bool ota_boot_user_size_change_write(kal_uint32 flags, void *param) |
| 2984 | { |
| 2985 | nvram_ltable_entry_struct *ldi = NULL; |
| 2986 | |
| 2987 | #ifdef __NVRAM_LID_CACHE__ |
| 2988 | nvram_cache_reset();//Disable NVRAM Cache |
| 2989 | #endif |
| 2990 | |
| 2991 | //reset test LIDs to default settings |
| 2992 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID)) |
| 2993 | { |
| 2994 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_write(): reset LIDs to default setting fail!\n\r"); |
| 2995 | return KAL_FALSE; |
| 2996 | } |
| 2997 | |
| 2998 | //delete old LID |
| 2999 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 3000 | { |
| 3001 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_write(): delete test LID fail!\n\r"); |
| 3002 | } |
| 3003 | |
| 3004 | //change test LID record size |
| 3005 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 3006 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 3007 | { |
| 3008 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_write(): reset test LID fail!\n\r"); |
| 3009 | return KAL_FALSE; |
| 3010 | } |
| 3011 | ldi->size += RECORD_CHANGE_SIZE; |
| 3012 | |
| 3013 | //reset SYS LID |
| 3014 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 3015 | { |
| 3016 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_write(): reset SYS LID fail!\n\r"); |
| 3017 | return KAL_FALSE; |
| 3018 | } |
| 3019 | |
| 3020 | //modify MD SW version |
| 3021 | if(!modify_md_sw_version()) |
| 3022 | { |
| 3023 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_write(): modify MD SW version fail!\n\r"); |
| 3024 | return KAL_FALSE; |
| 3025 | } |
| 3026 | |
| 3027 | //call nvram_init() |
| 3028 | nvram_boot_trace = 0; |
| 3029 | nvram_init(); |
| 3030 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 3031 | { |
| 3032 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_write(): enter version conflict fail!\n\r"); |
| 3033 | return KAL_FALSE; |
| 3034 | } |
| 3035 | |
| 3036 | //new LID access |
| 3037 | nvram_ut_assert_flag = 0; |
| 3038 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 3039 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 3040 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 3041 | { |
| 3042 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_write(): write LID fail!\n\r"); |
| 3043 | return KAL_FALSE; |
| 3044 | } |
| 3045 | |
| 3046 | if(0 != nvram_ut_assert_flag) |
| 3047 | { |
| 3048 | nvram_ut_trace("nvram_ut_assert_flag: %d.\n\r", nvram_ut_assert_flag); |
| 3049 | return KAL_FALSE; |
| 3050 | } |
| 3051 | #ifdef __NVRAM_LID_CACHE__ |
| 3052 | mark_nvram_cache_ready(); |
| 3053 | #endif |
| 3054 | return KAL_TRUE; |
| 3055 | |
| 3056 | } |
| 3057 | |
| 3058 | kal_bool ota_boot_user_size_change_reset(kal_uint32 flags, void *param) |
| 3059 | { |
| 3060 | nvram_ltable_entry_struct *ldi = NULL; |
| 3061 | |
| 3062 | #ifdef __NVRAM_LID_CACHE__ |
| 3063 | nvram_cache_reset();//Disable NVRAM Cache |
| 3064 | #endif |
| 3065 | |
| 3066 | //reset test LIDs to default settings |
| 3067 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID)) |
| 3068 | { |
| 3069 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_reset(): reset LIDs to default setting fail!\n\r"); |
| 3070 | return KAL_FALSE; |
| 3071 | } |
| 3072 | |
| 3073 | //delete old LID |
| 3074 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 3075 | { |
| 3076 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_reset(): delete test LID fail!\n\r"); |
| 3077 | } |
| 3078 | |
| 3079 | //change test LID record size |
| 3080 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 3081 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 3082 | { |
| 3083 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_reset(): reset test LID fail!\n\r"); |
| 3084 | return KAL_FALSE; |
| 3085 | } |
| 3086 | ldi->size += RECORD_CHANGE_SIZE; |
| 3087 | |
| 3088 | //reset SYS LID |
| 3089 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 3090 | { |
| 3091 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_reset(): reset SYS LID fail!\n\r"); |
| 3092 | return KAL_FALSE; |
| 3093 | } |
| 3094 | |
| 3095 | //modify MD SW version |
| 3096 | if(!modify_md_sw_version()) |
| 3097 | { |
| 3098 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_reset(): modify MD SW version fail!\n\r"); |
| 3099 | return KAL_FALSE; |
| 3100 | } |
| 3101 | |
| 3102 | //call nvram_init() |
| 3103 | nvram_boot_trace = 0; |
| 3104 | nvram_init(); |
| 3105 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 3106 | { |
| 3107 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_reset(): enter version conflict fail!\n\r"); |
| 3108 | return KAL_FALSE; |
| 3109 | } |
| 3110 | |
| 3111 | //new LID access |
| 3112 | nvram_ut_assert_flag = 0; |
| 3113 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 3114 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 3115 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 3116 | { |
| 3117 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_reset(): reset LID fail!\n\r"); |
| 3118 | return KAL_FALSE; |
| 3119 | } |
| 3120 | if(0 != nvram_ut_assert_flag) |
| 3121 | { |
| 3122 | nvram_ut_trace("nvram_ut_assert_flag: %d.\n\r", nvram_ut_assert_flag); |
| 3123 | return KAL_FALSE; |
| 3124 | } |
| 3125 | |
| 3126 | #ifdef __NVRAM_LID_CACHE__ |
| 3127 | mark_nvram_cache_ready(); |
| 3128 | #endif |
| 3129 | return KAL_TRUE; |
| 3130 | |
| 3131 | } |
| 3132 | |
| 3133 | kal_bool ota_boot_internal_size_change_read(kal_uint32 flags, void *param) |
| 3134 | { |
| 3135 | nvram_ltable_entry_struct *ldi = NULL; |
| 3136 | |
| 3137 | #ifdef __NVRAM_LID_CACHE__ |
| 3138 | nvram_cache_reset();//Disable NVRAM Cache |
| 3139 | #endif |
| 3140 | |
| 3141 | //reset test LIDs to default settings |
| 3142 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_2_LID)) |
| 3143 | { |
| 3144 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_read(): reset LIDs to default setting fail!\n\r"); |
| 3145 | return KAL_FALSE; |
| 3146 | } |
| 3147 | |
| 3148 | //delete old LID |
| 3149 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_2_LID, 0, 0) ) |
| 3150 | { |
| 3151 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_read(): delete test LID fail!\n\r"); |
| 3152 | } |
| 3153 | |
| 3154 | //change test LID record size |
| 3155 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_2_LID); |
| 3156 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 3157 | { |
| 3158 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_read(): reset test LID fail!\n\r"); |
| 3159 | return KAL_FALSE; |
| 3160 | } |
| 3161 | ldi->size += RECORD_CHANGE_SIZE; |
| 3162 | |
| 3163 | //reset SYS LID |
| 3164 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 3165 | { |
| 3166 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_read(): reset SYS LID fail!\n\r"); |
| 3167 | return KAL_FALSE; |
| 3168 | } |
| 3169 | |
| 3170 | //modify MD SW version |
| 3171 | if(!modify_md_sw_version()) |
| 3172 | { |
| 3173 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_read(): modify MD SW version fail!\n\r"); |
| 3174 | return KAL_FALSE; |
| 3175 | } |
| 3176 | |
| 3177 | //call nvram_init() |
| 3178 | nvram_boot_trace = 0; |
| 3179 | nvram_init(); |
| 3180 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 3181 | { |
| 3182 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_read(): enter version conflict fail!\n\r"); |
| 3183 | return KAL_FALSE; |
| 3184 | } |
| 3185 | |
| 3186 | //new LID access |
| 3187 | nvram_ut_assert_flag = 0; |
| 3188 | //internal LID size change expect read fail, internal will not run reset flow in nvram_read_data_item() |
| 3189 | if(0 == nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_2_LID, |
| 3190 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READ, 0, 0, 0), |
| 3191 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 3192 | { |
| 3193 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_read(): read fail do not happen!\n\r"); |
| 3194 | return KAL_FALSE; |
| 3195 | } |
| 3196 | if(0 != nvram_ut_assert_flag) |
| 3197 | { |
| 3198 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_read(): unexpect assert happen!\n\r"); |
| 3199 | return KAL_FALSE; |
| 3200 | } |
| 3201 | #ifdef __NVRAM_LID_CACHE__ |
| 3202 | mark_nvram_cache_ready(); |
| 3203 | #endif |
| 3204 | return KAL_TRUE; |
| 3205 | |
| 3206 | } |
| 3207 | |
| 3208 | kal_bool ota_boot_internal_size_change_write(kal_uint32 flags, void *param) |
| 3209 | { |
| 3210 | nvram_ltable_entry_struct *ldi = NULL; |
| 3211 | |
| 3212 | #ifdef __NVRAM_LID_CACHE__ |
| 3213 | nvram_cache_reset();//Disable NVRAM Cache |
| 3214 | #endif |
| 3215 | |
| 3216 | //reset test LIDs to default settings |
| 3217 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_2_LID)) |
| 3218 | { |
| 3219 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_write(): reset LIDs to default setting fail!\n\r"); |
| 3220 | return KAL_FALSE; |
| 3221 | } |
| 3222 | |
| 3223 | //delete old LID |
| 3224 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_2_LID, 0, 0) ) |
| 3225 | { |
| 3226 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_write(): delete test LID fail!\n\r"); |
| 3227 | } |
| 3228 | |
| 3229 | //change test LID record size |
| 3230 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_2_LID); |
| 3231 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 3232 | { |
| 3233 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_write(): reset test LID fail!\n\r"); |
| 3234 | return KAL_FALSE; |
| 3235 | } |
| 3236 | ldi->size += RECORD_CHANGE_SIZE; |
| 3237 | |
| 3238 | //reset SYS LID |
| 3239 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 3240 | { |
| 3241 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_write(): reset SYS LID fail!\n\r"); |
| 3242 | return KAL_FALSE; |
| 3243 | } |
| 3244 | |
| 3245 | //modify MD SW version |
| 3246 | if(!modify_md_sw_version()) |
| 3247 | { |
| 3248 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_write(): modify MD SW version fail!\n\r"); |
| 3249 | return KAL_FALSE; |
| 3250 | } |
| 3251 | |
| 3252 | //call nvram_init() |
| 3253 | nvram_boot_trace = 0; |
| 3254 | nvram_init(); |
| 3255 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 3256 | { |
| 3257 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_write(): enter version conflict fail!\n\r"); |
| 3258 | return KAL_FALSE; |
| 3259 | } |
| 3260 | |
| 3261 | //new LID access |
| 3262 | nvram_ut_assert_flag = 0; |
| 3263 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_2_LID, |
| 3264 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 3265 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 3266 | { |
| 3267 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_write(): write LID fail!\n\r"); |
| 3268 | return KAL_FALSE; |
| 3269 | } |
| 3270 | if(0 != nvram_ut_assert_flag) |
| 3271 | { |
| 3272 | nvram_ut_trace("[NVUT] nvram_ut_assert_flag: %d.\n\r", nvram_ut_assert_flag); |
| 3273 | return KAL_FALSE; |
| 3274 | } |
| 3275 | #ifdef __NVRAM_LID_CACHE__ |
| 3276 | mark_nvram_cache_ready(); |
| 3277 | #endif |
| 3278 | return KAL_TRUE; |
| 3279 | |
| 3280 | } |
| 3281 | |
| 3282 | kal_bool ota_boot_internal_size_change_reset(kal_uint32 flags, void *param) |
| 3283 | { |
| 3284 | nvram_ltable_entry_struct *ldi = NULL; |
| 3285 | |
| 3286 | #ifdef __NVRAM_LID_CACHE__ |
| 3287 | nvram_cache_reset();//Disable NVRAM Cache |
| 3288 | #endif |
| 3289 | |
| 3290 | //reset test LIDs to default settings |
| 3291 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_2_LID)) |
| 3292 | { |
| 3293 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_reset(): reset LIDs to default setting fail!\n\r"); |
| 3294 | return KAL_FALSE; |
| 3295 | } |
| 3296 | |
| 3297 | //delete old LID |
| 3298 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_2_LID, 0, 0) ) |
| 3299 | { |
| 3300 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_reset(): delete test LID fail!\n\r"); |
| 3301 | } |
| 3302 | |
| 3303 | //change test LID record size |
| 3304 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_2_LID); |
| 3305 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 3306 | { |
| 3307 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_reset(): reset test LID fail!\n\r"); |
| 3308 | return KAL_FALSE; |
| 3309 | } |
| 3310 | ldi->size += RECORD_CHANGE_SIZE; |
| 3311 | |
| 3312 | //reset SYS LID |
| 3313 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 3314 | { |
| 3315 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_reset(): reset SYS LID fail!\n\r"); |
| 3316 | return KAL_FALSE; |
| 3317 | } |
| 3318 | |
| 3319 | //modify MD SW version |
| 3320 | if(!modify_md_sw_version()) |
| 3321 | { |
| 3322 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_reset(): modify MD SW version fail!\n\r"); |
| 3323 | return KAL_FALSE; |
| 3324 | } |
| 3325 | |
| 3326 | //call nvram_init() |
| 3327 | nvram_boot_trace = 0; |
| 3328 | nvram_init(); |
| 3329 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 3330 | { |
| 3331 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_reset(): enter version conflict fail!\n\r"); |
| 3332 | return KAL_FALSE; |
| 3333 | } |
| 3334 | |
| 3335 | //new LID access |
| 3336 | nvram_ut_assert_flag = 0; |
| 3337 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_2_LID, |
| 3338 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 3339 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 3340 | { |
| 3341 | nvram_ut_trace("[NVUT] ota_boot_internal_size_change_reset(): reset LID fail!\n\r"); |
| 3342 | return KAL_FALSE; |
| 3343 | } |
| 3344 | if(0 != nvram_ut_assert_flag) |
| 3345 | { |
| 3346 | nvram_ut_trace("[NVUT] nvram_ut_assert_flag: %d.\n\r", nvram_ut_assert_flag); |
| 3347 | return KAL_FALSE; |
| 3348 | } |
| 3349 | #ifdef __NVRAM_LID_CACHE__ |
| 3350 | mark_nvram_cache_ready(); |
| 3351 | #endif |
| 3352 | return KAL_TRUE; |
| 3353 | |
| 3354 | } |
| 3355 | |
| 3356 | //OTA file size change, CALIBRAT & IMPORTANT will assert(with FATAL_ASSERT) |
| 3357 | kal_bool ota_boot_calibrat_size_change(kal_uint32 flags, void *param) |
| 3358 | { |
| 3359 | nvram_ltable_entry_struct *ldi = NULL; |
| 3360 | |
| 3361 | #ifdef __NVRAM_LID_CACHE__ |
| 3362 | nvram_cache_reset();//Disable NVRAM Cache |
| 3363 | #endif |
| 3364 | |
| 3365 | //reset test LIDs to default settings |
| 3366 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_3_LID)) |
| 3367 | { |
| 3368 | nvram_ut_trace("[NVUT] ota_boot_calibrat_size_change_read(): reset LIDs to default setting fail!\n\r"); |
| 3369 | return KAL_FALSE; |
| 3370 | } |
| 3371 | |
| 3372 | //delete old LID |
| 3373 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_3_LID, 0, 0) ) |
| 3374 | { |
| 3375 | nvram_ut_trace("[NVUT] ota_boot_calibrat_size_change_read(): delete test LID fail!\n\r"); |
| 3376 | } |
| 3377 | |
| 3378 | //change test LID record size |
| 3379 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_3_LID); |
| 3380 | ldi->attr |= NVRAM_ATTR_FAULT_ASSERT; |
| 3381 | |
| 3382 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 3383 | { |
| 3384 | nvram_ut_trace("[NVUT] ota_boot_calibrat_size_change_read(): reset test LID fail!\n\r"); |
| 3385 | return KAL_FALSE; |
| 3386 | } |
| 3387 | ldi->size += RECORD_CHANGE_SIZE; |
| 3388 | |
| 3389 | //reset SYS LID |
| 3390 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 3391 | { |
| 3392 | nvram_ut_trace("[NVUT] ota_boot_calibrat_size_change_read(): reset SYS LID fail!\n\r"); |
| 3393 | return KAL_FALSE; |
| 3394 | } |
| 3395 | |
| 3396 | //modify MD SW version |
| 3397 | if(!modify_md_sw_version()) |
| 3398 | { |
| 3399 | nvram_ut_trace("[NVUT] ota_boot_calibrat_size_change_read(): modify MD SW version fail!\n\r"); |
| 3400 | return KAL_FALSE; |
| 3401 | } |
| 3402 | |
| 3403 | //call nvram_init() |
| 3404 | nvram_ut_assert_flag = 0; |
| 3405 | nvram_boot_trace = 0; |
| 3406 | nvram_init(); |
| 3407 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 3408 | { |
| 3409 | nvram_ut_trace("[NVUT] ota_boot_calibrat_size_change_read(): enter version conflict fail!\n\r"); |
| 3410 | return KAL_FALSE; |
| 3411 | } |
| 3412 | |
| 3413 | if(0 == nvram_ut_assert_flag) |
| 3414 | { |
| 3415 | nvram_ut_trace("[NVUT] ota_boot_calibrat_size_change_read(): calibration LID(with FAULT_ASSERT) size change OTA do not assert.\n\r"); |
| 3416 | return KAL_FALSE; |
| 3417 | } |
| 3418 | #ifdef __NVRAM_LID_CACHE__ |
| 3419 | mark_nvram_cache_ready(); |
| 3420 | #endif |
| 3421 | return KAL_TRUE; |
| 3422 | |
| 3423 | } |
| 3424 | |
| 3425 | //OTA file size change, CALIBRAT & IMPORTANT will assert(with FATAL_ASSERT) |
| 3426 | kal_bool ota_boot_important_size_change(kal_uint32 flags, void *param) |
| 3427 | { |
| 3428 | nvram_ltable_entry_struct *ldi = NULL; |
| 3429 | |
| 3430 | #ifdef __NVRAM_LID_CACHE__ |
| 3431 | nvram_cache_reset();//Disable NVRAM Cache |
| 3432 | #endif |
| 3433 | |
| 3434 | //reset test LIDs to default settings |
| 3435 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_4_LID)) |
| 3436 | { |
| 3437 | nvram_ut_trace("[NVUT] ota_boot_important_size_change_read(): reset LIDs to default setting fail!\n\r"); |
| 3438 | return KAL_FALSE; |
| 3439 | } |
| 3440 | |
| 3441 | //delete old LID |
| 3442 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_4_LID, 0, 0) ) |
| 3443 | { |
| 3444 | nvram_ut_trace("[NVUT] ota_boot_important_size_change_read(): delete test LID fail!\n\r"); |
| 3445 | } |
| 3446 | |
| 3447 | //change test LID record size |
| 3448 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_4_LID); |
| 3449 | ldi->attr |= NVRAM_ATTR_FAULT_ASSERT; |
| 3450 | |
| 3451 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 3452 | { |
| 3453 | nvram_ut_trace("[NVUT] ota_boot_important_size_change_read(): reset test LID fail!\n\r"); |
| 3454 | return KAL_FALSE; |
| 3455 | } |
| 3456 | ldi->size += RECORD_CHANGE_SIZE; |
| 3457 | |
| 3458 | //reset SYS LID |
| 3459 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 3460 | { |
| 3461 | nvram_ut_trace("[NVUT] ota_boot_important_size_change_read(): reset SYS LID fail!\n\r"); |
| 3462 | return KAL_FALSE; |
| 3463 | } |
| 3464 | |
| 3465 | //modify MD SW version |
| 3466 | if(!modify_md_sw_version()) |
| 3467 | { |
| 3468 | nvram_ut_trace("[NVUT] ota_boot_important_size_change_read(): modify MD SW version fail!\n\r"); |
| 3469 | return KAL_FALSE; |
| 3470 | } |
| 3471 | |
| 3472 | //call nvram_init() |
| 3473 | nvram_boot_trace = 0; |
| 3474 | nvram_ut_assert_flag = 0; |
| 3475 | nvram_init(); |
| 3476 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 3477 | { |
| 3478 | nvram_ut_trace("[NVUT] ota_boot_important_size_change_read(): enter version conflict fail!\n\r"); |
| 3479 | nvram_ut_trace("[NVUT] ota_boot_calibrat_size_change_read(): enter version conflict fail!\n\r"); |
| 3480 | return KAL_FALSE; |
| 3481 | } |
| 3482 | |
| 3483 | if(0 == nvram_ut_assert_flag) |
| 3484 | { |
| 3485 | nvram_ut_trace("[NVUT] ota_boot_important_size_change_read(): important LID(with FAULT_ASSERT) size change OTA do not assert.\n\r"); |
| 3486 | return KAL_FALSE; |
| 3487 | } |
| 3488 | |
| 3489 | #ifdef __NVRAM_LID_CACHE__ |
| 3490 | mark_nvram_cache_ready(); |
| 3491 | #endif |
| 3492 | |
| 3493 | return KAL_TRUE; |
| 3494 | |
| 3495 | } |
| 3496 | |
| 3497 | //OTA boot file lost will try to restore from binregion(IMPORTANT & CALIBRAT) |
| 3498 | kal_bool ota_boot_calibrat_lost_access(kal_uint32 flags, void *param) |
| 3499 | { |
| 3500 | nvram_ltable_entry_struct *ldi = NULL; |
| 3501 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 3502 | nvram_folder_enum folder_index; |
| 3503 | NVRAM_FILE_NAME nvramname; |
| 3504 | kal_uint8 i; |
| 3505 | |
| 3506 | #ifdef __NVRAM_LID_CACHE__ |
| 3507 | nvram_cache_reset();//Disable NVRAM Cache |
| 3508 | #endif |
| 3509 | |
| 3510 | //reset test LIDs to default settings |
| 3511 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_3_LID)) |
| 3512 | { |
| 3513 | nvram_ut_trace("[NVUT] ota_boot_calibrat_lost_access(): reset LIDs to default setting fail!\n\r"); |
| 3514 | return KAL_FALSE; |
| 3515 | } |
| 3516 | |
| 3517 | //delete old LID |
| 3518 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_3_LID, 0, 0) ) |
| 3519 | { |
| 3520 | nvram_ut_trace("[NVUT] ota_boot_calibrat_lost_access(): delete test LID fail!\n\r"); |
| 3521 | } |
| 3522 | |
| 3523 | //change test LID record size |
| 3524 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_3_LID); |
| 3525 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 3526 | { |
| 3527 | nvram_ut_trace("[NVUT] ota_boot_calibrat_lost_access(): reset test LID fail!\n\r"); |
| 3528 | return KAL_FALSE; |
| 3529 | } |
| 3530 | |
| 3531 | folder_index = nvram_query_folder_index(ldi->category); |
| 3532 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 3533 | nvram_query_file_name(folder_index, nvramname, filename); |
| 3534 | FS_Delete(filename); |
| 3535 | |
| 3536 | //reset SYS LID |
| 3537 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 3538 | { |
| 3539 | nvram_ut_trace("[NVUT] ota_boot_calibrat_lost_access(): reset SYS LID fail!\n\r"); |
| 3540 | return KAL_FALSE; |
| 3541 | } |
| 3542 | |
| 3543 | //modify MD SW version |
| 3544 | if(!modify_md_sw_version()) |
| 3545 | { |
| 3546 | nvram_ut_trace("[NVUT] ota_boot_calibrat_lost_access(): modify MD SW version fail!\n\r"); |
| 3547 | return KAL_FALSE; |
| 3548 | } |
| 3549 | |
| 3550 | //call nvram_init() |
| 3551 | nvram_boot_trace = 0; |
| 3552 | nvram_init(); |
| 3553 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 3554 | { |
| 3555 | nvram_ut_trace("[NVUT] ota_boot_calibrat_lost_access(): enter version conflict fail!\n\r"); |
| 3556 | return KAL_FALSE; |
| 3557 | } |
| 3558 | |
| 3559 | //lid access |
| 3560 | kal_mem_set(data_buffer, 0, ldi->size); |
| 3561 | data_buffer[0] = 0x1; //modify to the value before binregion backup |
| 3562 | for(i = 1; i <= ldi->total_records; i++) |
| 3563 | { |
| 3564 | if(!nvram_external_read_data(ldi->LID, i, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 3565 | { |
| 3566 | nvram_ut_trace("[NVUT] ota_boot_calibrat_lost_access(): read LID fail!\n\r"); |
| 3567 | return KAL_FALSE; |
| 3568 | } |
| 3569 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 3570 | { |
| 3571 | nvram_ut_trace("[NVUT] ota_boot_calibrat_lost_access(): read back value not expect!\n\r"); |
| 3572 | return KAL_FALSE; |
| 3573 | } |
| 3574 | } |
| 3575 | #ifdef __NVRAM_LID_CACHE__ |
| 3576 | mark_nvram_cache_ready(); |
| 3577 | #endif |
| 3578 | return KAL_TRUE; |
| 3579 | |
| 3580 | } |
| 3581 | |
| 3582 | //OTA boot file lost will try to restore from binregion(IMPORTANT & CALIBRAT) |
| 3583 | kal_bool ota_boot_important_lost_access(kal_uint32 flags, void *param) |
| 3584 | { |
| 3585 | nvram_ltable_entry_struct *ldi = NULL; |
| 3586 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 3587 | nvram_folder_enum folder_index; |
| 3588 | NVRAM_FILE_NAME nvramname; |
| 3589 | kal_uint8 i; |
| 3590 | |
| 3591 | #ifdef __NVRAM_LID_CACHE__ |
| 3592 | nvram_cache_reset();//Disable NVRAM Cache |
| 3593 | #endif |
| 3594 | |
| 3595 | //reset test LIDs to default settings |
| 3596 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_4_LID)) |
| 3597 | { |
| 3598 | nvram_ut_trace("[NVUT] ota_boot_important_lost_access(): reset LIDs to default setting fail!\n\r"); |
| 3599 | return KAL_FALSE; |
| 3600 | } |
| 3601 | |
| 3602 | //delete old LID |
| 3603 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_4_LID, 0, 0) ) |
| 3604 | { |
| 3605 | nvram_ut_trace("[NVUT] ota_boot_important_lost_access(): delete test LID fail!\n\r"); |
| 3606 | } |
| 3607 | |
| 3608 | //change test LID record size |
| 3609 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_4_LID); |
| 3610 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 3611 | { |
| 3612 | nvram_ut_trace("[NVUT] ota_boot_important_lost_access(): reset test LID fail!\n\r"); |
| 3613 | return KAL_FALSE; |
| 3614 | } |
| 3615 | |
| 3616 | folder_index = nvram_query_folder_index(ldi->category); |
| 3617 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 3618 | nvram_query_file_name(folder_index, nvramname, filename); |
| 3619 | FS_Delete(filename); |
| 3620 | |
| 3621 | //reset SYS LID |
| 3622 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 3623 | { |
| 3624 | nvram_ut_trace("[NVUT] ota_boot_important_lost_access(): reset SYS LID fail!\n\r"); |
| 3625 | return KAL_FALSE; |
| 3626 | } |
| 3627 | |
| 3628 | //modify MD SW version |
| 3629 | if(!modify_md_sw_version()) |
| 3630 | { |
| 3631 | nvram_ut_trace("[NVUT] ota_boot_important_lost_access(): modify MD SW version fail!\n\r"); |
| 3632 | return KAL_FALSE; |
| 3633 | } |
| 3634 | |
| 3635 | //call nvram_init() |
| 3636 | nvram_boot_trace = 0; |
| 3637 | nvram_init(); |
| 3638 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 3639 | { |
| 3640 | nvram_ut_trace("[NVUT] ota_boot_important_lost_access(): enter version conflict fail!\n\r"); |
| 3641 | return KAL_FALSE; |
| 3642 | } |
| 3643 | |
| 3644 | //lid access |
| 3645 | kal_mem_set(data_buffer, 0, ldi->size); |
| 3646 | data_buffer[0] = 0x1; //modify to the value before binregion backup |
| 3647 | for(i = 1; i <= ldi->total_records; i++) |
| 3648 | { |
| 3649 | if(!nvram_external_read_data(ldi->LID, i, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 3650 | { |
| 3651 | nvram_ut_trace("[NVUT] ota_boot_important_lost_access(): read LID fail!\n\r"); |
| 3652 | return KAL_FALSE; |
| 3653 | } |
| 3654 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 3655 | { |
| 3656 | nvram_ut_trace("[NVUT] ota_boot_important_lost_access(): read back value not expect!\n\r"); |
| 3657 | return KAL_FALSE; |
| 3658 | } |
| 3659 | } |
| 3660 | #ifdef __NVRAM_LID_CACHE__ |
| 3661 | mark_nvram_cache_ready(); |
| 3662 | #endif |
| 3663 | |
| 3664 | return KAL_TRUE; |
| 3665 | |
| 3666 | } |
| 3667 | |
| 3668 | #if 0 |
| 3669 | /* under construction !*/ |
| 3670 | /* under construction !*/ |
| 3671 | /* under construction !*/ |
| 3672 | /* under construction !*/ |
| 3673 | /* under construction !*/ |
| 3674 | /* under construction !*/ |
| 3675 | /* under construction !*/ |
| 3676 | /* under construction !*/ |
| 3677 | /* under construction !*/ |
| 3678 | /* under construction !*/ |
| 3679 | /* under construction !*/ |
| 3680 | /* under construction !*/ |
| 3681 | /* under construction !*/ |
| 3682 | /* under construction !*/ |
| 3683 | /* under construction !*/ |
| 3684 | /* under construction !*/ |
| 3685 | /* under construction !*/ |
| 3686 | /* under construction !*/ |
| 3687 | /* under construction !*/ |
| 3688 | /* under construction !*/ |
| 3689 | /* under construction !*/ |
| 3690 | /* under construction !*/ |
| 3691 | /* under construction !*/ |
| 3692 | /* under construction !*/ |
| 3693 | /* under construction !*/ |
| 3694 | /* under construction !*/ |
| 3695 | /* under construction !*/ |
| 3696 | /* under construction !*/ |
| 3697 | /* under construction !*/ |
| 3698 | /* under construction !*/ |
| 3699 | /* under construction !*/ |
| 3700 | /* under construction !*/ |
| 3701 | /* under construction !*/ |
| 3702 | /* under construction !*/ |
| 3703 | /* under construction !*/ |
| 3704 | /* under construction !*/ |
| 3705 | /* under construction !*/ |
| 3706 | /* under construction !*/ |
| 3707 | /* under construction !*/ |
| 3708 | /* under construction !*/ |
| 3709 | /* under construction !*/ |
| 3710 | /* under construction !*/ |
| 3711 | /* under construction !*/ |
| 3712 | /* under construction !*/ |
| 3713 | /* under construction !*/ |
| 3714 | /* under construction !*/ |
| 3715 | /* under construction !*/ |
| 3716 | /* under construction !*/ |
| 3717 | /* under construction !*/ |
| 3718 | /* under construction !*/ |
| 3719 | /* under construction !*/ |
| 3720 | /* under construction !*/ |
| 3721 | /* under construction !*/ |
| 3722 | /* under construction !*/ |
| 3723 | /* under construction !*/ |
| 3724 | /* under construction !*/ |
| 3725 | /* under construction !*/ |
| 3726 | /* under construction !*/ |
| 3727 | /* under construction !*/ |
| 3728 | /* under construction !*/ |
| 3729 | /* under construction !*/ |
| 3730 | /* under construction !*/ |
| 3731 | /* under construction !*/ |
| 3732 | /* under construction !*/ |
| 3733 | /* under construction !*/ |
| 3734 | /* under construction !*/ |
| 3735 | /* under construction !*/ |
| 3736 | /* under construction !*/ |
| 3737 | /* under construction !*/ |
| 3738 | /* under construction !*/ |
| 3739 | /* under construction !*/ |
| 3740 | /* under construction !*/ |
| 3741 | /* under construction !*/ |
| 3742 | /* under construction !*/ |
| 3743 | /* under construction !*/ |
| 3744 | /* under construction !*/ |
| 3745 | /* under construction !*/ |
| 3746 | /* under construction !*/ |
| 3747 | /* under construction !*/ |
| 3748 | /* under construction !*/ |
| 3749 | /* under construction !*/ |
| 3750 | /* under construction !*/ |
| 3751 | /* under construction !*/ |
| 3752 | /* under construction !*/ |
| 3753 | /* under construction !*/ |
| 3754 | /* under construction !*/ |
| 3755 | /* under construction !*/ |
| 3756 | /* under construction !*/ |
| 3757 | /* under construction !*/ |
| 3758 | /* under construction !*/ |
| 3759 | /* under construction !*/ |
| 3760 | /* under construction !*/ |
| 3761 | /* under construction !*/ |
| 3762 | /* under construction !*/ |
| 3763 | /* under construction !*/ |
| 3764 | /* under construction !*/ |
| 3765 | /* under construction !*/ |
| 3766 | /* under construction !*/ |
| 3767 | /* under construction !*/ |
| 3768 | /* under construction !*/ |
| 3769 | /* under construction !*/ |
| 3770 | /* under construction !*/ |
| 3771 | /* under construction !*/ |
| 3772 | /* under construction !*/ |
| 3773 | /* under construction !*/ |
| 3774 | /* under construction !*/ |
| 3775 | /* under construction !*/ |
| 3776 | /* under construction !*/ |
| 3777 | /* under construction !*/ |
| 3778 | /* under construction !*/ |
| 3779 | /* under construction !*/ |
| 3780 | /* under construction !*/ |
| 3781 | /* under construction !*/ |
| 3782 | /* under construction !*/ |
| 3783 | /* under construction !*/ |
| 3784 | /* under construction !*/ |
| 3785 | /* under construction !*/ |
| 3786 | /* under construction !*/ |
| 3787 | /* under construction !*/ |
| 3788 | /* under construction !*/ |
| 3789 | /* under construction !*/ |
| 3790 | /* under construction !*/ |
| 3791 | /* under construction !*/ |
| 3792 | /* under construction !*/ |
| 3793 | /* under construction !*/ |
| 3794 | /* under construction !*/ |
| 3795 | /* under construction !*/ |
| 3796 | /* under construction !*/ |
| 3797 | /* under construction !*/ |
| 3798 | /* under construction !*/ |
| 3799 | /* under construction !*/ |
| 3800 | /* under construction !*/ |
| 3801 | /* under construction !*/ |
| 3802 | /* under construction !*/ |
| 3803 | /* under construction !*/ |
| 3804 | /* under construction !*/ |
| 3805 | /* under construction !*/ |
| 3806 | /* under construction !*/ |
| 3807 | /* under construction !*/ |
| 3808 | /* under construction !*/ |
| 3809 | /* under construction !*/ |
| 3810 | /* under construction !*/ |
| 3811 | /* under construction !*/ |
| 3812 | /* under construction !*/ |
| 3813 | /* under construction !*/ |
| 3814 | /* under construction !*/ |
| 3815 | /* under construction !*/ |
| 3816 | /* under construction !*/ |
| 3817 | /* under construction !*/ |
| 3818 | /* under construction !*/ |
| 3819 | /* under construction !*/ |
| 3820 | /* under construction !*/ |
| 3821 | /* under construction !*/ |
| 3822 | /* under construction !*/ |
| 3823 | /* under construction !*/ |
| 3824 | /* under construction !*/ |
| 3825 | /* under construction !*/ |
| 3826 | /* under construction !*/ |
| 3827 | /* under construction !*/ |
| 3828 | /* under construction !*/ |
| 3829 | /* under construction !*/ |
| 3830 | /* under construction !*/ |
| 3831 | /* under construction !*/ |
| 3832 | /* under construction !*/ |
| 3833 | /* under construction !*/ |
| 3834 | /* under construction !*/ |
| 3835 | /* under construction !*/ |
| 3836 | /* under construction !*/ |
| 3837 | /* under construction !*/ |
| 3838 | /* under construction !*/ |
| 3839 | /* under construction !*/ |
| 3840 | /* under construction !*/ |
| 3841 | /* under construction !*/ |
| 3842 | /* under construction !*/ |
| 3843 | /* under construction !*/ |
| 3844 | /* under construction !*/ |
| 3845 | /* under construction !*/ |
| 3846 | /* under construction !*/ |
| 3847 | /* under construction !*/ |
| 3848 | /* under construction !*/ |
| 3849 | /* under construction !*/ |
| 3850 | /* under construction !*/ |
| 3851 | /* under construction !*/ |
| 3852 | /* under construction !*/ |
| 3853 | /* under construction !*/ |
| 3854 | /* under construction !*/ |
| 3855 | /* under construction !*/ |
| 3856 | /* under construction !*/ |
| 3857 | /* under construction !*/ |
| 3858 | /* under construction !*/ |
| 3859 | /* under construction !*/ |
| 3860 | /* under construction !*/ |
| 3861 | /* under construction !*/ |
| 3862 | /* under construction !*/ |
| 3863 | /* under construction !*/ |
| 3864 | /* under construction !*/ |
| 3865 | /* under construction !*/ |
| 3866 | /* under construction !*/ |
| 3867 | /* under construction !*/ |
| 3868 | /* under construction !*/ |
| 3869 | /* under construction !*/ |
| 3870 | /* under construction !*/ |
| 3871 | /* under construction !*/ |
| 3872 | /* under construction !*/ |
| 3873 | /* under construction !*/ |
| 3874 | /* under construction !*/ |
| 3875 | /* under construction !*/ |
| 3876 | /* under construction !*/ |
| 3877 | /* under construction !*/ |
| 3878 | /* under construction !*/ |
| 3879 | /* under construction !*/ |
| 3880 | /* under construction !*/ |
| 3881 | /* under construction !*/ |
| 3882 | /* under construction !*/ |
| 3883 | /* under construction !*/ |
| 3884 | /* under construction !*/ |
| 3885 | /* under construction !*/ |
| 3886 | /* under construction !*/ |
| 3887 | /* under construction !*/ |
| 3888 | /* under construction !*/ |
| 3889 | /* under construction !*/ |
| 3890 | /* under construction !*/ |
| 3891 | /* under construction !*/ |
| 3892 | /* under construction !*/ |
| 3893 | /* under construction !*/ |
| 3894 | /* under construction !*/ |
| 3895 | /* under construction !*/ |
| 3896 | /* under construction !*/ |
| 3897 | /* under construction !*/ |
| 3898 | /* under construction !*/ |
| 3899 | /* under construction !*/ |
| 3900 | /* under construction !*/ |
| 3901 | /* under construction !*/ |
| 3902 | /* under construction !*/ |
| 3903 | /* under construction !*/ |
| 3904 | /* under construction !*/ |
| 3905 | /* under construction !*/ |
| 3906 | /* under construction !*/ |
| 3907 | /* under construction !*/ |
| 3908 | /* under construction !*/ |
| 3909 | /* under construction !*/ |
| 3910 | /* under construction !*/ |
| 3911 | /* under construction !*/ |
| 3912 | /* under construction !*/ |
| 3913 | /* under construction !*/ |
| 3914 | /* under construction !*/ |
| 3915 | /* under construction !*/ |
| 3916 | /* under construction !*/ |
| 3917 | /* under construction !*/ |
| 3918 | /* under construction !*/ |
| 3919 | /* under construction !*/ |
| 3920 | /* under construction !*/ |
| 3921 | /* under construction !*/ |
| 3922 | /* under construction !*/ |
| 3923 | /* under construction !*/ |
| 3924 | /* under construction !*/ |
| 3925 | /* under construction !*/ |
| 3926 | /* under construction !*/ |
| 3927 | /* under construction !*/ |
| 3928 | /* under construction !*/ |
| 3929 | /* under construction !*/ |
| 3930 | /* under construction !*/ |
| 3931 | /* under construction !*/ |
| 3932 | /* under construction !*/ |
| 3933 | /* under construction !*/ |
| 3934 | /* under construction !*/ |
| 3935 | /* under construction !*/ |
| 3936 | /* under construction !*/ |
| 3937 | /* under construction !*/ |
| 3938 | /* under construction !*/ |
| 3939 | /* under construction !*/ |
| 3940 | /* under construction !*/ |
| 3941 | /* under construction !*/ |
| 3942 | /* under construction !*/ |
| 3943 | /* under construction !*/ |
| 3944 | /* under construction !*/ |
| 3945 | /* under construction !*/ |
| 3946 | /* under construction !*/ |
| 3947 | /* under construction !*/ |
| 3948 | /* under construction !*/ |
| 3949 | /* under construction !*/ |
| 3950 | /* under construction !*/ |
| 3951 | /* under construction !*/ |
| 3952 | /* under construction !*/ |
| 3953 | /* under construction !*/ |
| 3954 | /* under construction !*/ |
| 3955 | /* under construction !*/ |
| 3956 | /* under construction !*/ |
| 3957 | /* under construction !*/ |
| 3958 | /* under construction !*/ |
| 3959 | /* under construction !*/ |
| 3960 | /* under construction !*/ |
| 3961 | /* under construction !*/ |
| 3962 | /* under construction !*/ |
| 3963 | /* under construction !*/ |
| 3964 | /* under construction !*/ |
| 3965 | /* under construction !*/ |
| 3966 | /* under construction !*/ |
| 3967 | /* under construction !*/ |
| 3968 | /* under construction !*/ |
| 3969 | /* under construction !*/ |
| 3970 | /* under construction !*/ |
| 3971 | /* under construction !*/ |
| 3972 | /* under construction !*/ |
| 3973 | /* under construction !*/ |
| 3974 | /* under construction !*/ |
| 3975 | /* under construction !*/ |
| 3976 | /* under construction !*/ |
| 3977 | /* under construction !*/ |
| 3978 | /* under construction !*/ |
| 3979 | /* under construction !*/ |
| 3980 | /* under construction !*/ |
| 3981 | /* under construction !*/ |
| 3982 | /* under construction !*/ |
| 3983 | /* under construction !*/ |
| 3984 | /* under construction !*/ |
| 3985 | /* under construction !*/ |
| 3986 | /* under construction !*/ |
| 3987 | /* under construction !*/ |
| 3988 | /* under construction !*/ |
| 3989 | /* under construction !*/ |
| 3990 | /* under construction !*/ |
| 3991 | /* under construction !*/ |
| 3992 | /* under construction !*/ |
| 3993 | /* under construction !*/ |
| 3994 | /* under construction !*/ |
| 3995 | /* under construction !*/ |
| 3996 | /* under construction !*/ |
| 3997 | /* under construction !*/ |
| 3998 | /* under construction !*/ |
| 3999 | /* under construction !*/ |
| 4000 | /* under construction !*/ |
| 4001 | /* under construction !*/ |
| 4002 | /* under construction !*/ |
| 4003 | /* under construction !*/ |
| 4004 | /* under construction !*/ |
| 4005 | /* under construction !*/ |
| 4006 | /* under construction !*/ |
| 4007 | /* under construction !*/ |
| 4008 | /* under construction !*/ |
| 4009 | /* under construction !*/ |
| 4010 | /* under construction !*/ |
| 4011 | /* under construction !*/ |
| 4012 | /* under construction !*/ |
| 4013 | /* under construction !*/ |
| 4014 | /* under construction !*/ |
| 4015 | /* under construction !*/ |
| 4016 | /* under construction !*/ |
| 4017 | /* under construction !*/ |
| 4018 | /* under construction !*/ |
| 4019 | /* under construction !*/ |
| 4020 | /* under construction !*/ |
| 4021 | /* under construction !*/ |
| 4022 | /* under construction !*/ |
| 4023 | /* under construction !*/ |
| 4024 | /* under construction !*/ |
| 4025 | /* under construction !*/ |
| 4026 | /* under construction !*/ |
| 4027 | /* under construction !*/ |
| 4028 | /* under construction !*/ |
| 4029 | /* under construction !*/ |
| 4030 | /* under construction !*/ |
| 4031 | /* under construction !*/ |
| 4032 | /* under construction !*/ |
| 4033 | /* under construction !*/ |
| 4034 | /* under construction !*/ |
| 4035 | /* under construction !*/ |
| 4036 | /* under construction !*/ |
| 4037 | /* under construction !*/ |
| 4038 | /* under construction !*/ |
| 4039 | /* under construction !*/ |
| 4040 | /* under construction !*/ |
| 4041 | /* under construction !*/ |
| 4042 | /* under construction !*/ |
| 4043 | /* under construction !*/ |
| 4044 | /* under construction !*/ |
| 4045 | /* under construction !*/ |
| 4046 | /* under construction !*/ |
| 4047 | /* under construction !*/ |
| 4048 | /* under construction !*/ |
| 4049 | /* under construction !*/ |
| 4050 | /* under construction !*/ |
| 4051 | /* under construction !*/ |
| 4052 | /* under construction !*/ |
| 4053 | /* under construction !*/ |
| 4054 | /* under construction !*/ |
| 4055 | /* under construction !*/ |
| 4056 | /* under construction !*/ |
| 4057 | /* under construction !*/ |
| 4058 | /* under construction !*/ |
| 4059 | /* under construction !*/ |
| 4060 | /* under construction !*/ |
| 4061 | /* under construction !*/ |
| 4062 | /* under construction !*/ |
| 4063 | /* under construction !*/ |
| 4064 | /* under construction !*/ |
| 4065 | /* under construction !*/ |
| 4066 | /* under construction !*/ |
| 4067 | /* under construction !*/ |
| 4068 | /* under construction !*/ |
| 4069 | /* under construction !*/ |
| 4070 | /* under construction !*/ |
| 4071 | /* under construction !*/ |
| 4072 | /* under construction !*/ |
| 4073 | /* under construction !*/ |
| 4074 | /* under construction !*/ |
| 4075 | /* under construction !*/ |
| 4076 | /* under construction !*/ |
| 4077 | /* under construction !*/ |
| 4078 | #endif |
| 4079 | |
| 4080 | kal_bool ota_boot_importantl1_size_change_read(kal_uint32 flags, void *param) |
| 4081 | { |
| 4082 | nvram_ltable_entry_struct *ldi = NULL; |
| 4083 | |
| 4084 | #ifdef __NVRAM_LID_CACHE__ |
| 4085 | nvram_cache_reset();//Disable NVRAM Cache |
| 4086 | #endif |
| 4087 | |
| 4088 | //reset test LIDs to default settings |
| 4089 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_5_LID)) |
| 4090 | { |
| 4091 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_read(): reset LIDs to default setting fail!\n\r"); |
| 4092 | return KAL_FALSE; |
| 4093 | } |
| 4094 | |
| 4095 | //delete old LID |
| 4096 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_5_LID, 0, 0) ) |
| 4097 | { |
| 4098 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_read(): delete test LID fail!\n\r"); |
| 4099 | } |
| 4100 | |
| 4101 | //change test LID record size |
| 4102 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_5_LID); |
| 4103 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 4104 | { |
| 4105 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_read(): reset test LID fail!\n\r"); |
| 4106 | return KAL_FALSE; |
| 4107 | } |
| 4108 | ldi->size += RECORD_CHANGE_SIZE; |
| 4109 | |
| 4110 | //reset SYS LID |
| 4111 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 4112 | { |
| 4113 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_read(): reset SYS LID fail!\n\r"); |
| 4114 | return KAL_FALSE; |
| 4115 | } |
| 4116 | |
| 4117 | //modify MD SW version |
| 4118 | if(!modify_md_sw_version()) |
| 4119 | { |
| 4120 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_read(): modify MD SW version fail!\n\r"); |
| 4121 | return KAL_FALSE; |
| 4122 | } |
| 4123 | |
| 4124 | //call nvram_init() |
| 4125 | nvram_boot_trace = 0; |
| 4126 | nvram_init(); |
| 4127 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 4128 | { |
| 4129 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_read(): enter version conflict fail!\n\r"); |
| 4130 | return KAL_FALSE; |
| 4131 | } |
| 4132 | |
| 4133 | //new LID access |
| 4134 | nvram_ut_assert_flag = 0; |
| 4135 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_5_LID, |
| 4136 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READ, 0, 0, 0), |
| 4137 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 4138 | { |
| 4139 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_read(): read LID fail!\n\r"); |
| 4140 | return KAL_FALSE; |
| 4141 | } |
| 4142 | if(0 != nvram_ut_assert_flag) |
| 4143 | { |
| 4144 | nvram_ut_trace("[NVUT] nvram_ut_assert_flag: %d.\n\r", nvram_ut_assert_flag); |
| 4145 | return KAL_FALSE; |
| 4146 | } |
| 4147 | |
| 4148 | #ifdef __NVRAM_LID_CACHE__ |
| 4149 | mark_nvram_cache_ready(); |
| 4150 | #endif |
| 4151 | |
| 4152 | return KAL_TRUE; |
| 4153 | |
| 4154 | } |
| 4155 | |
| 4156 | kal_bool ota_boot_importantl1_size_change_write(kal_uint32 flags, void *param) |
| 4157 | { |
| 4158 | nvram_ltable_entry_struct *ldi = NULL; |
| 4159 | #ifdef __NVRAM_LID_CACHE__ |
| 4160 | nvram_cache_reset();//Disable NVRAM Cache |
| 4161 | #endif |
| 4162 | //reset test LIDs to default settings |
| 4163 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_5_LID)) |
| 4164 | { |
| 4165 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_write(): reset LIDs to default setting fail!\n\r"); |
| 4166 | return KAL_FALSE; |
| 4167 | } |
| 4168 | |
| 4169 | //delete old LID |
| 4170 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_5_LID, 0, 0) ) |
| 4171 | { |
| 4172 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_write(): delete test LID fail!\n\r"); |
| 4173 | } |
| 4174 | |
| 4175 | //change test LID record size |
| 4176 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_5_LID); |
| 4177 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 4178 | { |
| 4179 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_write(): reset test LID fail!\n\r"); |
| 4180 | return KAL_FALSE; |
| 4181 | } |
| 4182 | ldi->size += RECORD_CHANGE_SIZE; |
| 4183 | |
| 4184 | //reset SYS LID |
| 4185 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 4186 | { |
| 4187 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_write(): reset SYS LID fail!\n\r"); |
| 4188 | return KAL_FALSE; |
| 4189 | } |
| 4190 | |
| 4191 | //modify MD SW version |
| 4192 | if(!modify_md_sw_version()) |
| 4193 | { |
| 4194 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_write(): modify MD SW version fail!\n\r"); |
| 4195 | return KAL_FALSE; |
| 4196 | } |
| 4197 | |
| 4198 | //call nvram_init() |
| 4199 | nvram_boot_trace = 0; |
| 4200 | nvram_init(); |
| 4201 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 4202 | { |
| 4203 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_write(): enter version conflict fail!\n\r"); |
| 4204 | return KAL_FALSE; |
| 4205 | } |
| 4206 | |
| 4207 | //new LID access |
| 4208 | nvram_ut_assert_flag = 0; |
| 4209 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_5_LID, |
| 4210 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 4211 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 4212 | { |
| 4213 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_write(): write LID fail!\n\r"); |
| 4214 | return KAL_FALSE; |
| 4215 | } |
| 4216 | if(0 != nvram_ut_assert_flag) |
| 4217 | { |
| 4218 | nvram_ut_trace("[NVUT] nvram_ut_assert_flag: %d.\n\r", nvram_ut_assert_flag); |
| 4219 | return KAL_FALSE; |
| 4220 | } |
| 4221 | #ifdef __NVRAM_LID_CACHE__ |
| 4222 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 4223 | #endif |
| 4224 | return KAL_TRUE; |
| 4225 | |
| 4226 | } |
| 4227 | |
| 4228 | kal_bool ota_boot_importantl1_size_change_reset(kal_uint32 flags, void *param) |
| 4229 | { |
| 4230 | nvram_ltable_entry_struct *ldi = NULL; |
| 4231 | #ifdef __NVRAM_LID_CACHE__ |
| 4232 | nvram_cache_reset();//Disable NVRAM Cache |
| 4233 | #endif |
| 4234 | //reset test LIDs to default settings |
| 4235 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_5_LID)) |
| 4236 | { |
| 4237 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_reset(): reset LIDs to default setting fail!\n\r"); |
| 4238 | return KAL_FALSE; |
| 4239 | } |
| 4240 | |
| 4241 | //delete old LID |
| 4242 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_5_LID, 0, 0) ) |
| 4243 | { |
| 4244 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_reset(): delete test LID fail!\n\r"); |
| 4245 | } |
| 4246 | |
| 4247 | //change test LID record size |
| 4248 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_5_LID); |
| 4249 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 4250 | { |
| 4251 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_reset(): reset test LID fail!\n\r"); |
| 4252 | return KAL_FALSE; |
| 4253 | } |
| 4254 | ldi->size += RECORD_CHANGE_SIZE; |
| 4255 | |
| 4256 | //reset SYS LID |
| 4257 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 4258 | { |
| 4259 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_reset(): reset SYS LID fail!\n\r"); |
| 4260 | return KAL_FALSE; |
| 4261 | } |
| 4262 | |
| 4263 | //modify MD SW version |
| 4264 | if(!modify_md_sw_version()) |
| 4265 | { |
| 4266 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_reset(): modify MD SW version fail!\n\r"); |
| 4267 | return KAL_FALSE; |
| 4268 | } |
| 4269 | |
| 4270 | //call nvram_init() |
| 4271 | nvram_boot_trace = 0; |
| 4272 | nvram_init(); |
| 4273 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 4274 | { |
| 4275 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_reset(): enter version conflict fail!\n\r"); |
| 4276 | return KAL_FALSE; |
| 4277 | } |
| 4278 | |
| 4279 | //new LID access |
| 4280 | nvram_ut_assert_flag = 0; |
| 4281 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_5_LID, |
| 4282 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 4283 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 4284 | { |
| 4285 | nvram_ut_trace("[NVUT] ota_boot_importantl1_size_change_reset(): reset LID fail!\n\r"); |
| 4286 | return KAL_FALSE; |
| 4287 | } |
| 4288 | if(0 != nvram_ut_assert_flag) |
| 4289 | { |
| 4290 | nvram_ut_trace("[NVUT] nvram_ut_assert_flag: %d.\n\r", nvram_ut_assert_flag); |
| 4291 | return KAL_FALSE; |
| 4292 | } |
| 4293 | #ifdef __NVRAM_LID_CACHE__ |
| 4294 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 4295 | #endif |
| 4296 | return KAL_TRUE; |
| 4297 | |
| 4298 | } |
| 4299 | |
| 4300 | kal_bool ota_boot_importantl4_size_change_read(kal_uint32 flags, void *param) |
| 4301 | { |
| 4302 | nvram_ltable_entry_struct *ldi = NULL; |
| 4303 | #ifdef __NVRAM_LID_CACHE__ |
| 4304 | nvram_cache_reset();//Disable NVRAM Cache |
| 4305 | #endif |
| 4306 | |
| 4307 | //reset test LIDs to default settings |
| 4308 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_6_LID)) |
| 4309 | { |
| 4310 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_read(): reset LIDs to default setting fail!\n\r"); |
| 4311 | return KAL_FALSE; |
| 4312 | } |
| 4313 | |
| 4314 | //delete old LID |
| 4315 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_6_LID, 0, 0) ) |
| 4316 | { |
| 4317 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_read(): delete test LID fail!\n\r"); |
| 4318 | } |
| 4319 | |
| 4320 | //change test LID record size |
| 4321 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_6_LID); |
| 4322 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 4323 | { |
| 4324 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_read(): reset test LID fail!\n\r"); |
| 4325 | return KAL_FALSE; |
| 4326 | } |
| 4327 | ldi->size += RECORD_CHANGE_SIZE; |
| 4328 | |
| 4329 | //reset SYS LID |
| 4330 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 4331 | { |
| 4332 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_read(): reset SYS LID fail!\n\r"); |
| 4333 | return KAL_FALSE; |
| 4334 | } |
| 4335 | |
| 4336 | //modify MD SW version |
| 4337 | if(!modify_md_sw_version()) |
| 4338 | { |
| 4339 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_read(): modify MD SW version fail!\n\r"); |
| 4340 | return KAL_FALSE; |
| 4341 | } |
| 4342 | |
| 4343 | //call nvram_init() |
| 4344 | nvram_boot_trace = 0; |
| 4345 | nvram_init(); |
| 4346 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 4347 | { |
| 4348 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_read(): enter version conflict fail!\n\r"); |
| 4349 | return KAL_FALSE; |
| 4350 | } |
| 4351 | |
| 4352 | //new LID access |
| 4353 | nvram_ut_assert_flag = 0; |
| 4354 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_6_LID, |
| 4355 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READ, 0, 0, 0), |
| 4356 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 4357 | { |
| 4358 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_read(): read fail happen!\n\r"); |
| 4359 | return KAL_FALSE; |
| 4360 | } |
| 4361 | if(0 != nvram_ut_assert_flag) |
| 4362 | { |
| 4363 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_read(): unexpect assert happen!\n\r"); |
| 4364 | return KAL_FALSE; |
| 4365 | } |
| 4366 | #ifdef __NVRAM_LID_CACHE__ |
| 4367 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 4368 | #endif |
| 4369 | return KAL_TRUE; |
| 4370 | |
| 4371 | } |
| 4372 | |
| 4373 | kal_bool ota_boot_importantl4_size_change_write(kal_uint32 flags, void *param) |
| 4374 | { |
| 4375 | nvram_ltable_entry_struct *ldi = NULL; |
| 4376 | #ifdef __NVRAM_LID_CACHE__ |
| 4377 | nvram_cache_reset();//Disable NVRAM Cache |
| 4378 | #endif |
| 4379 | //reset test LIDs to default settings |
| 4380 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_6_LID)) |
| 4381 | { |
| 4382 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_write(): reset LIDs to default setting fail!\n\r"); |
| 4383 | return KAL_FALSE; |
| 4384 | } |
| 4385 | |
| 4386 | //delete old LID |
| 4387 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_6_LID, 0, 0) ) |
| 4388 | { |
| 4389 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_write(): delete test LID fail!\n\r"); |
| 4390 | } |
| 4391 | |
| 4392 | //change test LID record size |
| 4393 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_6_LID); |
| 4394 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 4395 | { |
| 4396 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_write(): reset test LID fail!\n\r"); |
| 4397 | return KAL_FALSE; |
| 4398 | } |
| 4399 | ldi->size += RECORD_CHANGE_SIZE; |
| 4400 | |
| 4401 | //reset SYS LID |
| 4402 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 4403 | { |
| 4404 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_write(): reset SYS LID fail!\n\r"); |
| 4405 | return KAL_FALSE; |
| 4406 | } |
| 4407 | |
| 4408 | //modify MD SW version |
| 4409 | if(!modify_md_sw_version()) |
| 4410 | { |
| 4411 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_write(): modify MD SW version fail!\n\r"); |
| 4412 | return KAL_FALSE; |
| 4413 | } |
| 4414 | |
| 4415 | //call nvram_init() |
| 4416 | nvram_boot_trace = 0; |
| 4417 | nvram_init(); |
| 4418 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 4419 | { |
| 4420 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_write(): enter version conflict fail!\n\r"); |
| 4421 | return KAL_FALSE; |
| 4422 | } |
| 4423 | |
| 4424 | //new LID access |
| 4425 | nvram_ut_assert_flag = 0; |
| 4426 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_6_LID, |
| 4427 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 4428 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 4429 | { |
| 4430 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_write(): write LID fail!\n\r"); |
| 4431 | return KAL_FALSE; |
| 4432 | } |
| 4433 | if(0 != nvram_ut_assert_flag) |
| 4434 | { |
| 4435 | nvram_ut_trace("[NVUT] nvram_ut_assert_flag: %d.\n\r", nvram_ut_assert_flag); |
| 4436 | return KAL_FALSE; |
| 4437 | } |
| 4438 | #ifdef __NVRAM_LID_CACHE__ |
| 4439 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 4440 | #endif |
| 4441 | return KAL_TRUE; |
| 4442 | |
| 4443 | } |
| 4444 | |
| 4445 | kal_bool ota_boot_importantl4_size_change_reset(kal_uint32 flags, void *param) |
| 4446 | { |
| 4447 | nvram_ltable_entry_struct *ldi = NULL; |
| 4448 | #ifdef __NVRAM_LID_CACHE__ |
| 4449 | nvram_cache_reset();//Disable NVRAM Cache |
| 4450 | #endif |
| 4451 | //reset test LIDs to default settings |
| 4452 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_6_LID)) |
| 4453 | { |
| 4454 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_reset(): reset LIDs to default setting fail!\n\r"); |
| 4455 | return KAL_FALSE; |
| 4456 | } |
| 4457 | |
| 4458 | //delete old LID |
| 4459 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_6_LID, 0, 0) ) |
| 4460 | { |
| 4461 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_reset(): delete test LID fail!\n\r"); |
| 4462 | } |
| 4463 | |
| 4464 | //change test LID record size |
| 4465 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_6_LID); |
| 4466 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 4467 | { |
| 4468 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_reset(): reset test LID fail!\n\r"); |
| 4469 | return KAL_FALSE; |
| 4470 | } |
| 4471 | ldi->size += RECORD_CHANGE_SIZE; |
| 4472 | |
| 4473 | //reset SYS LID |
| 4474 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 4475 | { |
| 4476 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_reset(): reset SYS LID fail!\n\r"); |
| 4477 | return KAL_FALSE; |
| 4478 | } |
| 4479 | |
| 4480 | //modify MD SW version |
| 4481 | if(!modify_md_sw_version()) |
| 4482 | { |
| 4483 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_reset(): modify MD SW version fail!\n\r"); |
| 4484 | return KAL_FALSE; |
| 4485 | } |
| 4486 | |
| 4487 | //call nvram_init() |
| 4488 | nvram_boot_trace = 0; |
| 4489 | nvram_init(); |
| 4490 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 4491 | { |
| 4492 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_reset(): enter version conflict fail!\n\r"); |
| 4493 | return KAL_FALSE; |
| 4494 | } |
| 4495 | |
| 4496 | //new LID access |
| 4497 | nvram_ut_assert_flag = 0; |
| 4498 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_6_LID, |
| 4499 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 4500 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 4501 | { |
| 4502 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_reset(): reset LID fail!\n\r"); |
| 4503 | return KAL_FALSE; |
| 4504 | } |
| 4505 | if(0 != nvram_ut_assert_flag) |
| 4506 | { |
| 4507 | nvram_ut_trace("[NVUT] nvram_ut_assert_flag: %d.\n\r", nvram_ut_assert_flag); |
| 4508 | return KAL_FALSE; |
| 4509 | } |
| 4510 | #ifdef __NVRAM_LID_CACHE__ |
| 4511 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 4512 | #endif |
| 4513 | return KAL_TRUE; |
| 4514 | |
| 4515 | } |
| 4516 | |
| 4517 | kal_bool ota_boot_ota_reset_attr(kal_uint32 flags, void *param) |
| 4518 | { |
| 4519 | nvram_ltable_entry_struct *ldi = NULL; |
| 4520 | kal_uint8 i; |
| 4521 | #ifdef __NVRAM_LID_CACHE__ |
| 4522 | nvram_cache_reset();//Disable NVRAM Cache |
| 4523 | #endif |
| 4524 | //reset test LIDs to default settings |
| 4525 | for(i = 0; i < test_lid_number; i++) |
| 4526 | { |
| 4527 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 4528 | { |
| 4529 | nvram_ut_trace("[NVUT] ota_boot_ota_reset_attr(): reset LIDs to default seeting fail!\n\r"); |
| 4530 | return KAL_FALSE; |
| 4531 | } |
| 4532 | } |
| 4533 | |
| 4534 | //write LID, add OTA_RESET attr |
| 4535 | data_buffer[0] = 0x1; //modify some value |
| 4536 | data_buffer[1] = 0x2; |
| 4537 | data_buffer[2] = 0x3; |
| 4538 | for(i = 0; i < test_lid_number; i++) |
| 4539 | { |
| 4540 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 4541 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 4542 | { |
| 4543 | nvram_ut_trace("[NVUT] ota_boot_ota_reset_attr(): reset LID fail!\n\r"); |
| 4544 | return KAL_FALSE; |
| 4545 | } |
| 4546 | ldi->attr |= NVRAM_ATTR_OTA_RESET; |
| 4547 | if(!nvram_external_write_data(test_lid_enum[i], 1, (kal_uint8 *)data_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 4548 | { |
| 4549 | nvram_ut_trace("[NVUT] ota_boot_ota_reset_attr(): write LID fail!\n\r"); |
| 4550 | return KAL_FALSE; |
| 4551 | } |
| 4552 | } |
| 4553 | |
| 4554 | //reset SYS LID |
| 4555 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 4556 | { |
| 4557 | nvram_ut_trace("[NVUT] ota_boot_ota_reset_attr(): reset SYS LID fail!\n\r"); |
| 4558 | return KAL_FALSE; |
| 4559 | } |
| 4560 | |
| 4561 | //modify MD SW version |
| 4562 | if(!modify_md_sw_version()) |
| 4563 | { |
| 4564 | nvram_ut_trace("[NVUT] ota_boot_ota_reset_attr(): modify MD SW version fail!\n\r"); |
| 4565 | return KAL_FALSE; |
| 4566 | } |
| 4567 | |
| 4568 | //call nvram_init() |
| 4569 | nvram_boot_trace = 0; |
| 4570 | nvram_init(); |
| 4571 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 4572 | { |
| 4573 | nvram_ut_trace("[NVUT] ota_boot_ota_reset_attr(): enter version conflict fail!\n\r"); |
| 4574 | return KAL_FALSE; |
| 4575 | } |
| 4576 | |
| 4577 | //lid access |
| 4578 | for(i = 0; i < test_lid_number; i++) |
| 4579 | { |
| 4580 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 4581 | nvram_get_default_value_to_write(ldi, 1, (kal_uint8 *)cmp_buffer, ldi->size); |
| 4582 | if(!nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)data_buffer, ldi->size)) |
| 4583 | { |
| 4584 | nvram_ut_trace("[NVUT] ota_boot_ota_reset_attr(): read OTA LID fail!\n\r"); |
| 4585 | return KAL_FALSE; |
| 4586 | } |
| 4587 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, ldi->size)) |
| 4588 | { |
| 4589 | nvram_ut_trace("[NVUT] ota_boot_ota_reset_attr(): read back value not expect!\n\r"); |
| 4590 | return KAL_FALSE; |
| 4591 | } |
| 4592 | } |
| 4593 | #ifdef __NVRAM_LID_CACHE__ |
| 4594 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 4595 | #endif |
| 4596 | return KAL_TRUE; |
| 4597 | |
| 4598 | } |
| 4599 | |
| 4600 | kal_bool ota_boot_reserve_backward_verno_change(kal_uint32 flags, void *param) |
| 4601 | { |
| 4602 | nvram_ltable_entry_struct *ldi = NULL; |
| 4603 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 4604 | nvram_folder_enum folder_index; |
| 4605 | NVRAM_FILE_NAME nvramname; |
| 4606 | kal_uint8 i, ota_time, j; |
| 4607 | kal_uint8 lid_ver[4] = "000"; |
| 4608 | |
| 4609 | #ifdef __NVRAM_LID_CACHE__ |
| 4610 | nvram_cache_reset();//Disable NVRAM Cache |
| 4611 | #endif |
| 4612 | |
| 4613 | //delete all files in Z:/BACKUP folder |
| 4614 | FS_XDelete((const WCHAR*)L"Z:\\NVRAM\\BACKUP", (FS_FILE_TYPE|FS_RECURSIVE_TYPE), NULL, 0); |
| 4615 | |
| 4616 | //reset test LIDs to default settings |
| 4617 | for(i = 0; i < test_lid_number; i++) |
| 4618 | { |
| 4619 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 4620 | { |
| 4621 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): reset to default setting fail!\n\r"); |
| 4622 | return KAL_FALSE; |
| 4623 | } |
| 4624 | } |
| 4625 | |
| 4626 | //remove GEN_DEFAULT and add RESERVE_BACKWARD |
| 4627 | for(i = 0; i < test_lid_number; i++) |
| 4628 | { |
| 4629 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 4630 | ldi->attr &= (~NVRAM_ATTR_GEN_DEFAULT); |
| 4631 | ldi->attr |= NVRAM_ATTR_RESERVE_BACKWARD; |
| 4632 | if(0 == i) |
| 4633 | { |
| 4634 | ldi->attr |= NVRAM_ATTR_MULTIPLE; //add multiple for LID1 |
| 4635 | } |
| 4636 | } |
| 4637 | |
| 4638 | //this test will use LID verno "000"~"012" total 12 version |
| 4639 | for(i = 0; i < test_lid_number; i++) |
| 4640 | { |
| 4641 | if(!delete_special_version_lid(test_lid_enum[i], 0, 12)) |
| 4642 | { |
| 4643 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): delete old version LID fail!\n\r"); |
| 4644 | return KAL_FALSE; |
| 4645 | } |
| 4646 | } |
| 4647 | |
| 4648 | //reset test LIDs |
| 4649 | for(i = 0; i < test_lid_number; i++) |
| 4650 | { |
| 4651 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 4652 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 4653 | { |
| 4654 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): reset test LIDs fail!\n\r"); |
| 4655 | return KAL_FALSE; |
| 4656 | } |
| 4657 | } |
| 4658 | |
| 4659 | //reset SYS LID |
| 4660 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 4661 | { |
| 4662 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): reset SYS LID fail!\n\r"); |
| 4663 | return KAL_FALSE; |
| 4664 | } |
| 4665 | |
| 4666 | //write LID |
| 4667 | for(ota_time = 0; ota_time < 12; ota_time++) |
| 4668 | { |
| 4669 | if(0 == ota_time%2) //even loop time write LID of record 1 first |
| 4670 | { |
| 4671 | cmp_buffer[0] = ota_time + 0x30; |
| 4672 | for(i = 0; i < test_lid_number; i++) |
| 4673 | { |
| 4674 | if(!nvram_external_write_data(test_lid_enum[i], 1, (kal_uint8 *)cmp_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 4675 | { |
| 4676 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): write previous LID fail!\n\r"); |
| 4677 | return KAL_FALSE; |
| 4678 | } |
| 4679 | } |
| 4680 | } |
| 4681 | //increase LID verno |
| 4682 | for(i = 0; i < test_lid_number; i++) |
| 4683 | { |
| 4684 | if(!lid_verno_increase_one(test_lid_enum[i])) |
| 4685 | { |
| 4686 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): increase verno fail!\n\r"); |
| 4687 | return KAL_FALSE; |
| 4688 | } |
| 4689 | } |
| 4690 | //modify MD SW version |
| 4691 | if(!modify_md_sw_version()) |
| 4692 | { |
| 4693 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): modify MD SW version location1 fail!\n\r"); |
| 4694 | } |
| 4695 | //call nvram_init() |
| 4696 | nvram_boot_trace = 0; |
| 4697 | nvram_init(); |
| 4698 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 4699 | { |
| 4700 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): enter version conflict fail!\n\r"); |
| 4701 | return KAL_FALSE; |
| 4702 | } |
| 4703 | |
| 4704 | } |
| 4705 | |
| 4706 | //test nvram_external_search_reserved_lid() API only give first two parameters |
| 4707 | for(j = 0; j < test_lid_number; j++) |
| 4708 | { |
| 4709 | nvram_util_get_data_item(&ldi, test_lid_enum[j]); |
| 4710 | for(i = 0; i <= 10; i+=2) //version 2,4,6,8,10 should in backup folder, version 0 will be deleted |
| 4711 | { |
| 4712 | lid_ver[0] = i/100 + '0'; |
| 4713 | lid_ver[1] = i%100/10 + '0'; |
| 4714 | lid_ver[2] = i%10 + '0'; |
| 4715 | |
| 4716 | if(0 == i) |
| 4717 | { |
| 4718 | if(nvram_external_search_reserved_lid(ldi->LID, (kal_char *)lid_ver, 0, 0)) |
| 4719 | { |
| 4720 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): too old versions not deleted!\n\r"); |
| 4721 | return KAL_FALSE; |
| 4722 | } |
| 4723 | } |
| 4724 | else |
| 4725 | { |
| 4726 | if(! nvram_external_search_reserved_lid(ldi->LID, (kal_char *)lid_ver, 0, 0)) |
| 4727 | { |
| 4728 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): old versions not in backup folder!\n\r"); |
| 4729 | return KAL_FALSE; |
| 4730 | } |
| 4731 | } |
| 4732 | } |
| 4733 | } |
| 4734 | |
| 4735 | //check old versions delete or not(version 12 exist, version 0~14 not exist ) |
| 4736 | for(i = 0; i < test_lid_number; i++) |
| 4737 | { |
| 4738 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 4739 | ldi->fileverno[0] = '0'; |
| 4740 | ldi->fileverno[1] = '0'; |
| 4741 | ldi->fileverno[2] = '0'; |
| 4742 | } |
| 4743 | for(i = 0; i <= 12; i++) |
| 4744 | { |
| 4745 | for(j = 0; j < test_lid_number; j++) |
| 4746 | { |
| 4747 | nvram_util_get_data_item(&ldi, test_lid_enum[j]); |
| 4748 | folder_index = nvram_query_folder_index(ldi->category); |
| 4749 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 4750 | nvram_query_file_name(folder_index, nvramname, filename); |
| 4751 | |
| 4752 | if (FS_GetAttributes(filename) >= FS_NO_ERROR) //all files expect not exist |
| 4753 | { |
| 4754 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): old version LID not delete!\n\r"); |
| 4755 | return KAL_FALSE; |
| 4756 | } |
| 4757 | |
| 4758 | if(ldi->attr & NVRAM_ATTR_MULTIPLE) |
| 4759 | { |
| 4760 | nvram_util_make_lid_filename(ldi, nvramname, KAL_FALSE); |
| 4761 | nvram_query_file_name(folder_index, nvramname, filename); |
| 4762 | |
| 4763 | if (FS_GetAttributes(filename) >= FS_NO_ERROR) |
| 4764 | { |
| 4765 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): old version LID not delete!\n\r"); |
| 4766 | return KAL_FALSE; |
| 4767 | } |
| 4768 | } |
| 4769 | lid_verno_increase_one(test_lid_enum[j]); |
| 4770 | } |
| 4771 | } |
| 4772 | |
| 4773 | //downgrade to MD SW version 3 -> related LID verno is "002" |
| 4774 | for(i = 0; i < test_lid_number; i++) //set LID verno to "002" |
| 4775 | { |
| 4776 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 4777 | ldi->fileverno[0] = '0'; |
| 4778 | ldi->fileverno[1] = '0'; |
| 4779 | ldi->fileverno[2] = '2'; |
| 4780 | } |
| 4781 | //modify MD SW version |
| 4782 | if(!modify_md_sw_version()) |
| 4783 | { |
| 4784 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): modify MD SW version location2 fail!\n\r"); |
| 4785 | } |
| 4786 | //call nvram_init() |
| 4787 | nvram_boot_trace = 0; |
| 4788 | nvram_init(); |
| 4789 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 4790 | { |
| 4791 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): second enter version conflict fail!\n\r"); |
| 4792 | return KAL_FALSE; |
| 4793 | } |
| 4794 | //check LID record 1 value |
| 4795 | cmp_buffer[0] = 0x32; //expect value is 0x32 |
| 4796 | for(i = 0; i < test_lid_number; i++) |
| 4797 | { |
| 4798 | if(!nvram_external_read_data(test_lid_enum[i], 1, (kal_uint8 *)data_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 4799 | { |
| 4800 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): second read LID fail!\n\r"); |
| 4801 | return KAL_FALSE; |
| 4802 | } |
| 4803 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 4804 | { |
| 4805 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): second read not expect!\n\r"); |
| 4806 | return KAL_FALSE; |
| 4807 | } |
| 4808 | } |
| 4809 | |
| 4810 | //downgrade to MD SW version 1 -> related LID verno is "000" |
| 4811 | for(i = 0; i < test_lid_number; i++) |
| 4812 | { |
| 4813 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 4814 | ldi->fileverno[0] = '0'; |
| 4815 | ldi->fileverno[1] = '0'; |
| 4816 | ldi->fileverno[2] = '0'; |
| 4817 | } |
| 4818 | //modify MD SW version |
| 4819 | if(!modify_md_sw_version()) |
| 4820 | { |
| 4821 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): modify MD SW version location3 fail!\n\r"); |
| 4822 | } |
| 4823 | //call nvram_init() |
| 4824 | nvram_boot_trace = 0; |
| 4825 | nvram_init(); |
| 4826 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 4827 | { |
| 4828 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): third enter version conflict fail!\n\r"); |
| 4829 | return KAL_FALSE; |
| 4830 | } |
| 4831 | //check LID record 1 value |
| 4832 | for(i = 0; i < test_lid_number; i++) |
| 4833 | { |
| 4834 | if(!nvram_external_read_data(test_lid_enum[i], 1, (kal_uint8 *)data_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 4835 | { |
| 4836 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): third read fail!\n\r"); |
| 4837 | return KAL_FALSE; |
| 4838 | } |
| 4839 | |
| 4840 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 4841 | nvram_get_default_value_to_write(ldi, 1, (kal_uint8 *)cmp_buffer, ldi->size); |
| 4842 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 4843 | { |
| 4844 | cmp_buffer[0] += 1; |
| 4845 | if (NVRAM_IS_CATEGORY_IN_BIN_REGION(ldi->category) && |
| 4846 | !kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, NVRAM_EF_TEST_LID_SIZE) ) |
| 4847 | { |
| 4848 | continue; |
| 4849 | } |
| 4850 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_verno_change(): third read not expect!\n\r"); |
| 4851 | return KAL_FALSE; |
| 4852 | } |
| 4853 | } |
| 4854 | #ifdef __NVRAM_LID_CACHE__ |
| 4855 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 4856 | #endif |
| 4857 | return KAL_TRUE; |
| 4858 | |
| 4859 | } |
| 4860 | |
| 4861 | kal_bool ota_boot_reserve_backward_size_change(kal_uint32 flags, void *param) |
| 4862 | { |
| 4863 | nvram_ltable_entry_struct *ldi = NULL; |
| 4864 | kal_uint8 i, ota_time; |
| 4865 | |
| 4866 | #ifdef __NVRAM_LID_CACHE__ |
| 4867 | nvram_cache_reset();//Disable NVRAM Cache |
| 4868 | #endif |
| 4869 | |
| 4870 | //delete all files in Z:/BACKUP folder |
| 4871 | FS_XDelete((const WCHAR*)L"Z:\\NVRAM\\BACKUP", (FS_FILE_TYPE|FS_RECURSIVE_TYPE), NULL, 0); |
| 4872 | |
| 4873 | //reset test LIDs to default settings |
| 4874 | for(i = 0; i < test_lid_number; i++) |
| 4875 | { |
| 4876 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 4877 | { |
| 4878 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_size_change(): reset to default setting fail!\n\r"); |
| 4879 | return KAL_FALSE; |
| 4880 | } |
| 4881 | } |
| 4882 | |
| 4883 | //remove GEN_DEFAULT and add RESERVE_BACKWARD |
| 4884 | for(i = 0; i < test_lid_number; i++) |
| 4885 | { |
| 4886 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 4887 | ldi->attr &= (~NVRAM_ATTR_GEN_DEFAULT); |
| 4888 | if( NVRAM_IS_CATEGORY_IMPORTANT_L4(ldi->category) || NVRAM_IS_CATEGORY_IN_BIN_REGION(ldi->category)) |
| 4889 | { |
| 4890 | continue; |
| 4891 | } |
| 4892 | ldi->attr |= NVRAM_ATTR_RESERVE_BACKWARD; |
| 4893 | if(0 == i) |
| 4894 | { |
| 4895 | ldi->attr |= NVRAM_ATTR_MULTIPLE; //add multiple for LID1 |
| 4896 | } |
| 4897 | } |
| 4898 | |
| 4899 | //this test will use LID verno "000" version |
| 4900 | for(i = 0; i < test_lid_number; i++) |
| 4901 | { |
| 4902 | if(!delete_special_version_lid(test_lid_enum[i], 0, 0)) |
| 4903 | { |
| 4904 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_size_change(): delete old version LID fail!\n\r"); |
| 4905 | return KAL_FALSE; |
| 4906 | } |
| 4907 | } |
| 4908 | |
| 4909 | //reset test LIDs |
| 4910 | for(i = 0; i < test_lid_number; i++) |
| 4911 | { |
| 4912 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 4913 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 4914 | { |
| 4915 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_size_change(): reset test LIDs fail!\n\r"); |
| 4916 | return KAL_FALSE; |
| 4917 | } |
| 4918 | } |
| 4919 | |
| 4920 | //reset SYS LID |
| 4921 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 4922 | { |
| 4923 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_size_change(): reset SYS LID fail!\n\r"); |
| 4924 | return KAL_FALSE; |
| 4925 | } |
| 4926 | |
| 4927 | //write LID |
| 4928 | for(ota_time = 0; ota_time < 12; ota_time++) |
| 4929 | { |
| 4930 | if(0 == ota_time%2) //even loop time write LID of record 1 first |
| 4931 | { |
| 4932 | cmp_buffer[0] = ota_time + 0x30; |
| 4933 | for(i = 0; i < test_lid_number; i++) |
| 4934 | { |
| 4935 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 4936 | if(!nvram_external_write_data(test_lid_enum[i], 1, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 4937 | { |
| 4938 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_size_change(): write previous LID fail!\n\r"); |
| 4939 | return KAL_FALSE; |
| 4940 | } |
| 4941 | } |
| 4942 | } |
| 4943 | //change LID size |
| 4944 | for(i = 0; i < test_lid_number; i++) |
| 4945 | { |
| 4946 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 4947 | if( NVRAM_IS_CATEGORY_IMPORTANT_L4(ldi->category) || NVRAM_IS_CATEGORY_IN_BIN_REGION(ldi->category)) |
| 4948 | { |
| 4949 | continue; |
| 4950 | } |
| 4951 | ldi->size += 2; //add record size |
| 4952 | } |
| 4953 | //modify MD SW version |
| 4954 | if(!modify_md_sw_version()) |
| 4955 | { |
| 4956 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_size_change(): modify MD SW version location1 fail!\n\r"); |
| 4957 | } |
| 4958 | //call nvram_init() |
| 4959 | nvram_boot_trace = 0; |
| 4960 | nvram_init(); |
| 4961 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 4962 | { |
| 4963 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_size_change(): first enter version conflict fail!\n\r"); |
| 4964 | return KAL_FALSE; |
| 4965 | } |
| 4966 | |
| 4967 | } |
| 4968 | |
| 4969 | //downgrade to MD SW version 2 -> related LID record size is (NVRAM_EF_TEST_LID_SIZE + 4) |
| 4970 | for(i = 0; i < test_lid_number; i++) |
| 4971 | { |
| 4972 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 4973 | if( NVRAM_IS_CATEGORY_IMPORTANT_L4(ldi->category) || NVRAM_IS_CATEGORY_IN_BIN_REGION(ldi->category)) |
| 4974 | { |
| 4975 | continue; |
| 4976 | } |
| 4977 | ldi->size = NVRAM_EF_TEST_LID_SIZE + 4; |
| 4978 | } |
| 4979 | //modify MD SW version |
| 4980 | if(!modify_md_sw_version()) |
| 4981 | { |
| 4982 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_size_change(): modify MD SW version location2 fail!\n\r"); |
| 4983 | } |
| 4984 | //call nvram_init() |
| 4985 | nvram_boot_trace = 0; |
| 4986 | nvram_init(); |
| 4987 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 4988 | { |
| 4989 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_size_change(): second enter version conflict fail!\n\r"); |
| 4990 | return KAL_FALSE; |
| 4991 | } |
| 4992 | //check LID record 1 value |
| 4993 | cmp_buffer[0] = 0x32; //expect value is 0x32 |
| 4994 | for(i = 0; i < test_lid_number; i++) |
| 4995 | { |
| 4996 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 4997 | if( NVRAM_IS_CATEGORY_IMPORTANT_L4(ldi->category) || NVRAM_IS_CATEGORY_IN_BIN_REGION(ldi->category)) |
| 4998 | { |
| 4999 | continue; |
| 5000 | } |
| 5001 | if(!nvram_external_read_data(test_lid_enum[i], 1, (kal_uint8 *)data_buffer, ldi->size)) |
| 5002 | { |
| 5003 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_size_change(): second read fail!\n\r"); |
| 5004 | return KAL_FALSE; |
| 5005 | } |
| 5006 | |
| 5007 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, ldi->size)) |
| 5008 | { |
| 5009 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_size_change(): second read not expect!\n\r"); |
| 5010 | return KAL_FALSE; |
| 5011 | } |
| 5012 | } |
| 5013 | |
| 5014 | //downgrade to MD SW version 1 -> related LID record size is (NVRAM_EF_TEST_LID_SIZE) |
| 5015 | for(i = 0; i < test_lid_number; i++) |
| 5016 | { |
| 5017 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 5018 | ldi->size = NVRAM_EF_TEST_LID_SIZE; |
| 5019 | } |
| 5020 | //modify MD SW version |
| 5021 | if(!modify_md_sw_version()) |
| 5022 | { |
| 5023 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_size_change(): modify MD SW version location3 fail!\n\r"); |
| 5024 | } |
| 5025 | //call nvram_init() |
| 5026 | nvram_boot_trace = 0; |
| 5027 | nvram_init(); |
| 5028 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 5029 | { |
| 5030 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_size_change(): third enter version conflict fail!\n\r"); |
| 5031 | return KAL_FALSE; |
| 5032 | } |
| 5033 | //check LID record 1 value |
| 5034 | for(i = 0; i < test_lid_number; i++) |
| 5035 | { |
| 5036 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 5037 | if( NVRAM_IS_CATEGORY_IMPORTANT_L4(ldi->category) || NVRAM_IS_CATEGORY_IN_BIN_REGION(ldi->category)) |
| 5038 | { |
| 5039 | continue; |
| 5040 | } |
| 5041 | if(!nvram_external_read_data(test_lid_enum[i], 1, (kal_uint8 *)data_buffer, ldi->size)) |
| 5042 | { |
| 5043 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_size_change(): third read fail!\n\r"); |
| 5044 | return KAL_FALSE; |
| 5045 | } |
| 5046 | |
| 5047 | nvram_get_default_value_to_write(ldi, 1, (kal_uint8 *)cmp_buffer, ldi->size); |
| 5048 | if(0 != kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, ldi->size)) |
| 5049 | { |
| 5050 | nvram_ut_trace("[NVUT] ota_boot_reserve_backward_size_change(): third read not expect!\n\r"); |
| 5051 | return KAL_FALSE; |
| 5052 | } |
| 5053 | } |
| 5054 | #ifdef __NVRAM_LID_CACHE__ |
| 5055 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 5056 | #endif |
| 5057 | return KAL_TRUE; |
| 5058 | |
| 5059 | } |
| 5060 | |
| 5061 | kal_bool normal_boot_basic_access(kal_uint32 flags, void *param) |
| 5062 | { |
| 5063 | nvram_ltable_entry_struct *ldi = NULL; |
| 5064 | kal_uint8 i; |
| 5065 | |
| 5066 | //reset test LIDs to default settings |
| 5067 | for(i = 0; i < test_lid_number; i++) |
| 5068 | { |
| 5069 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 5070 | { |
| 5071 | nvram_ut_trace("[NVUT] normal_boot_basic_access(): reset LIDs to default setting fail!\n\r"); |
| 5072 | return KAL_FALSE; |
| 5073 | } |
| 5074 | } |
| 5075 | |
| 5076 | //this test will use LID verno "000" only |
| 5077 | for(i = 0; i < test_lid_number; i++) |
| 5078 | { |
| 5079 | if(!delete_special_version_lid(test_lid_enum[i], 0, 0)) |
| 5080 | { |
| 5081 | nvram_ut_trace("[NVUT] normal_boot_basic_access(): delete old version LID fail!\n\r"); |
| 5082 | return KAL_FALSE; |
| 5083 | } |
| 5084 | } |
| 5085 | #ifdef __NVRAM_LID_CACHE__ |
| 5086 | nvram_cache_reset();//Disable NVRAM Cache |
| 5087 | #endif |
| 5088 | //reset(create) test LIDs |
| 5089 | for(i = 0; i < test_lid_number; i++) |
| 5090 | { |
| 5091 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 5092 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 5093 | { |
| 5094 | nvram_ut_trace("[NVUT] normal_boot_basic_access(): reset test LIDs fail!\n\r"); |
| 5095 | return KAL_FALSE; |
| 5096 | } |
| 5097 | } |
| 5098 | |
| 5099 | //reset SYS LID to default value |
| 5100 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 5101 | { |
| 5102 | nvram_ut_trace("[NVUT] normal_boot_basic_access(): reset SYS LID fail!\n\r"); |
| 5103 | return KAL_FALSE; |
| 5104 | } |
| 5105 | |
| 5106 | //call nvram_init() |
| 5107 | nvram_boot_trace = 0; |
| 5108 | nvram_init(); |
| 5109 | #ifdef __NVRAM_LID_CACHE__ |
| 5110 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 5111 | #endif |
| 5112 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 5113 | { |
| 5114 | nvram_ut_trace("[NVUT] normal_boot_basic_access(): enter version conflict fail!\n\r"); |
| 5115 | return KAL_FALSE; |
| 5116 | } |
| 5117 | |
| 5118 | //lid access |
| 5119 | for(i = 0; i < test_lid_number; i++) |
| 5120 | { |
| 5121 | if(0 != nvram_lid_cmpt_operation(test_lid_enum[i], |
| 5122 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 5123 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 5124 | { |
| 5125 | nvram_ut_trace("[NVUT] normal_boot_basic_access(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 5126 | return KAL_FALSE; |
| 5127 | } |
| 5128 | } |
| 5129 | |
| 5130 | return KAL_TRUE; |
| 5131 | |
| 5132 | } |
| 5133 | |
| 5134 | kal_bool normal_boot_user_lost_read(kal_uint32 flags, void *param) |
| 5135 | { |
| 5136 | nvram_ltable_entry_struct *ldi = NULL; |
| 5137 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 5138 | nvram_folder_enum folder_index; |
| 5139 | NVRAM_FILE_NAME nvramname; |
| 5140 | #ifdef __NVRAM_LID_CACHE__ |
| 5141 | nvram_cache_reset();//Disable NVRAM Cache |
| 5142 | #endif |
| 5143 | //reset test LIDs to default settings |
| 5144 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 5145 | { |
| 5146 | nvram_ut_trace("[NVUT] normal_boot_user_lost_read(): reset test LID settings fail!\n\r"); |
| 5147 | } |
| 5148 | |
| 5149 | //this test will use LID verno "000" only |
| 5150 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 5151 | { |
| 5152 | nvram_ut_trace("[NVUT] normal_boot_user_lost_read(): delete test LID fail!\n\r"); |
| 5153 | } |
| 5154 | |
| 5155 | //reset LID and then delete it |
| 5156 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 5157 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 5158 | { |
| 5159 | nvram_ut_trace("[NVUT] normal_boot_user_lost_read(): reset test LID fail!\n\r"); |
| 5160 | return KAL_FALSE; |
| 5161 | } |
| 5162 | folder_index = nvram_query_folder_index(ldi->category); |
| 5163 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 5164 | nvram_query_file_name(folder_index, nvramname, filename); |
| 5165 | FS_Delete(filename); |
| 5166 | |
| 5167 | //reset SYS LID to default value |
| 5168 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 5169 | { |
| 5170 | nvram_ut_trace("[NVUT] normal_boot_user_lost_read(): reset SYS LID fail!\n\r"); |
| 5171 | return KAL_FALSE; |
| 5172 | } |
| 5173 | |
| 5174 | //call nvram_init() |
| 5175 | nvram_boot_trace = 0; |
| 5176 | nvram_init(); |
| 5177 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 5178 | { |
| 5179 | nvram_ut_trace("[NVUT] normal_boot_user_lost_read(): enter version conflict fail!\n\r"); |
| 5180 | return KAL_FALSE; |
| 5181 | } |
| 5182 | |
| 5183 | //lid access |
| 5184 | nvram_ut_assert_flag = 0; |
| 5185 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 5186 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, 0, 0, 0), |
| 5187 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 5188 | { |
| 5189 | nvram_ut_trace("[NVUT] normal_boot_user_lost_read(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 5190 | return KAL_FALSE; |
| 5191 | } |
| 5192 | if(nvram_ut_assert_flag) |
| 5193 | { |
| 5194 | nvram_ut_trace("[NVUT] normal_boot_user_lost_read(): unexpect assert happen!\n\r"); |
| 5195 | return KAL_FALSE; |
| 5196 | } |
| 5197 | #ifdef __NVRAM_LID_CACHE__ |
| 5198 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 5199 | #endif |
| 5200 | return KAL_TRUE; |
| 5201 | |
| 5202 | } |
| 5203 | |
| 5204 | kal_bool normal_boot_user_lost_write(kal_uint32 flags, void *param) |
| 5205 | { |
| 5206 | nvram_ltable_entry_struct *ldi = NULL; |
| 5207 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 5208 | nvram_folder_enum folder_index; |
| 5209 | NVRAM_FILE_NAME nvramname; |
| 5210 | |
| 5211 | #ifdef __NVRAM_LID_CACHE__ |
| 5212 | nvram_cache_reset();//Disable NVRAM Cache |
| 5213 | #endif |
| 5214 | //reset test LIDs to default settings |
| 5215 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 5216 | { |
| 5217 | nvram_ut_trace("[NVUT] normal_boot_user_lost_write(): reset test LID settings fail!\n\r"); |
| 5218 | } |
| 5219 | |
| 5220 | //this test will use LID verno "000" only |
| 5221 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 5222 | { |
| 5223 | nvram_ut_trace("[NVUT] normal_boot_user_lost_write(): delete test LID fail!\n\r"); |
| 5224 | } |
| 5225 | |
| 5226 | //reset LID and then delete it |
| 5227 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 5228 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 5229 | { |
| 5230 | nvram_ut_trace("[NVUT] normal_boot_user_lost_write(): reset test LID fail!\n\r"); |
| 5231 | return KAL_FALSE; |
| 5232 | } |
| 5233 | folder_index = nvram_query_folder_index(ldi->category); |
| 5234 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 5235 | nvram_query_file_name(folder_index, nvramname, filename); |
| 5236 | FS_Delete(filename); |
| 5237 | |
| 5238 | //reset SYS LID to default value |
| 5239 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 5240 | { |
| 5241 | nvram_ut_trace("[NVUT] normal_boot_user_lost_write(): reset SYS LID fail!\n\r"); |
| 5242 | return KAL_FALSE; |
| 5243 | } |
| 5244 | |
| 5245 | //call nvram_init() |
| 5246 | nvram_boot_trace = 0; |
| 5247 | nvram_init(); |
| 5248 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 5249 | { |
| 5250 | nvram_ut_trace("[NVUT] normal_boot_user_lost_write(): enter version conflict fail!\n\r"); |
| 5251 | return KAL_FALSE; |
| 5252 | } |
| 5253 | |
| 5254 | //lid access |
| 5255 | nvram_ut_assert_flag = 0; |
| 5256 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 5257 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 5258 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 5259 | { |
| 5260 | nvram_ut_trace("[NVUT] normal_boot_user_lost_write(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 5261 | return KAL_FALSE; |
| 5262 | } |
| 5263 | if(nvram_ut_assert_flag) |
| 5264 | { |
| 5265 | nvram_ut_trace("[NVUT] normal_boot_user_lost_write(): unexpect assert happen!\n\r"); |
| 5266 | return KAL_FALSE; |
| 5267 | } |
| 5268 | #ifdef __NVRAM_LID_CACHE__ |
| 5269 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 5270 | #endif |
| 5271 | return KAL_TRUE; |
| 5272 | |
| 5273 | } |
| 5274 | |
| 5275 | kal_bool normal_boot_user_lost_reset(kal_uint32 flags, void *param) |
| 5276 | { |
| 5277 | nvram_ltable_entry_struct *ldi = NULL; |
| 5278 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 5279 | nvram_folder_enum folder_index; |
| 5280 | NVRAM_FILE_NAME nvramname; |
| 5281 | |
| 5282 | #ifdef __NVRAM_LID_CACHE__ |
| 5283 | nvram_cache_reset();//Disable NVRAM Cache |
| 5284 | #endif |
| 5285 | |
| 5286 | //reset test LIDs to default settings |
| 5287 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 5288 | { |
| 5289 | nvram_ut_trace("[NVUT] normal_boot_user_lost_reset(): reset test LID settings fail!\n\r"); |
| 5290 | } |
| 5291 | |
| 5292 | //this test will use LID verno "000" only |
| 5293 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 5294 | { |
| 5295 | nvram_ut_trace("[NVUT] normal_boot_user_lost_reset(): delete test LID fail!\n\r"); |
| 5296 | } |
| 5297 | |
| 5298 | //reset LID and then delete it |
| 5299 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 5300 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 5301 | { |
| 5302 | nvram_ut_trace("[NVUT] normal_boot_user_lost_reset(): reset test LID fail!\n\r"); |
| 5303 | return KAL_FALSE; |
| 5304 | } |
| 5305 | folder_index = nvram_query_folder_index(ldi->category); |
| 5306 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 5307 | nvram_query_file_name(folder_index, nvramname, filename); |
| 5308 | FS_Delete(filename); |
| 5309 | |
| 5310 | //reset SYS LID to default value |
| 5311 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 5312 | { |
| 5313 | nvram_ut_trace("[NVUT] normal_boot_user_lost_reset(): reset SYS LID fail!\n\r"); |
| 5314 | return KAL_FALSE; |
| 5315 | } |
| 5316 | |
| 5317 | //call nvram_init() |
| 5318 | nvram_boot_trace = 0; |
| 5319 | nvram_init(); |
| 5320 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 5321 | { |
| 5322 | nvram_ut_trace("[NVUT] normal_boot_user_lost_reset(): enter version conflict fail!\n\r"); |
| 5323 | return KAL_FALSE; |
| 5324 | } |
| 5325 | |
| 5326 | //lid access |
| 5327 | nvram_ut_assert_flag = 0; |
| 5328 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 5329 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 5330 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 5331 | { |
| 5332 | nvram_ut_trace("[NVUT] normal_boot_user_lost_reset(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 5333 | return KAL_FALSE; |
| 5334 | } |
| 5335 | if(nvram_ut_assert_flag) |
| 5336 | { |
| 5337 | nvram_ut_trace("[NVUT] normal_boot_user_lost_reset(): unexpect assert happen!\n\r"); |
| 5338 | return KAL_FALSE; |
| 5339 | } |
| 5340 | #ifdef __NVRAM_LID_CACHE__ |
| 5341 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 5342 | #endif |
| 5343 | return KAL_TRUE; |
| 5344 | |
| 5345 | } |
| 5346 | |
| 5347 | kal_bool normal_boot_internal_lost_read(kal_uint32 flags, void *param) |
| 5348 | { |
| 5349 | nvram_ltable_entry_struct *ldi = NULL; |
| 5350 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 5351 | nvram_folder_enum folder_index; |
| 5352 | NVRAM_FILE_NAME nvramname; |
| 5353 | |
| 5354 | #ifdef __NVRAM_LID_CACHE__ |
| 5355 | nvram_cache_reset();//Disable NVRAM Cache |
| 5356 | #endif |
| 5357 | |
| 5358 | //reset test LIDs to default settings |
| 5359 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_2_LID) ) |
| 5360 | { |
| 5361 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_read(): reset test LID settings fail!\n\r"); |
| 5362 | } |
| 5363 | |
| 5364 | //this test will use LID verno "000" only |
| 5365 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_2_LID, 0, 0) ) |
| 5366 | { |
| 5367 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_read(): delete test LID fail!\n\r"); |
| 5368 | } |
| 5369 | |
| 5370 | //reset LID and then delete it |
| 5371 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_2_LID); |
| 5372 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 5373 | { |
| 5374 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_read(): reset test LID fail!\n\r"); |
| 5375 | return KAL_FALSE; |
| 5376 | } |
| 5377 | folder_index = nvram_query_folder_index(ldi->category); |
| 5378 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 5379 | nvram_query_file_name(folder_index, nvramname, filename); |
| 5380 | FS_Delete(filename); |
| 5381 | |
| 5382 | //reset SYS LID to default value |
| 5383 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 5384 | { |
| 5385 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_read(): reset SYS LID fail!\n\r"); |
| 5386 | return KAL_FALSE; |
| 5387 | } |
| 5388 | |
| 5389 | //call nvram_init() |
| 5390 | nvram_boot_trace = 0; |
| 5391 | nvram_init(); |
| 5392 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 5393 | { |
| 5394 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_read(): enter version conflict fail!\n\r"); |
| 5395 | return KAL_FALSE; |
| 5396 | } |
| 5397 | |
| 5398 | //lid access |
| 5399 | nvram_ut_assert_flag = 0; |
| 5400 | //internal LID size change expect read fail, internal will not run reset flow in nvram_read_data_item() |
| 5401 | if(0 == nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_2_LID, |
| 5402 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READ, 0, 0, 0), |
| 5403 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 5404 | { |
| 5405 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_read(): expect read fail not happen!\n\r"); |
| 5406 | return KAL_FALSE; |
| 5407 | } |
| 5408 | if(nvram_ut_assert_flag) |
| 5409 | { |
| 5410 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_read(): unexpect assert happen!\n\r"); |
| 5411 | return KAL_FALSE; |
| 5412 | } |
| 5413 | #ifdef __NVRAM_LID_CACHE__ |
| 5414 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 5415 | #endif |
| 5416 | return KAL_TRUE; |
| 5417 | |
| 5418 | } |
| 5419 | |
| 5420 | kal_bool normal_boot_internal_lost_write(kal_uint32 flags, void *param) |
| 5421 | { |
| 5422 | nvram_ltable_entry_struct *ldi = NULL; |
| 5423 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 5424 | nvram_folder_enum folder_index; |
| 5425 | NVRAM_FILE_NAME nvramname; |
| 5426 | |
| 5427 | #ifdef __NVRAM_LID_CACHE__ |
| 5428 | nvram_cache_reset();//Disable NVRAM Cache |
| 5429 | #endif |
| 5430 | |
| 5431 | //reset test LIDs to default settings |
| 5432 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_2_LID) ) |
| 5433 | { |
| 5434 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_write(): reset test LID settings fail!\n\r"); |
| 5435 | } |
| 5436 | |
| 5437 | //this test will use LID verno "000" only |
| 5438 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_2_LID, 0, 0) ) |
| 5439 | { |
| 5440 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_write(): delete test LID fail!\n\r"); |
| 5441 | } |
| 5442 | |
| 5443 | //reset LID and then delete it |
| 5444 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_2_LID); |
| 5445 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 5446 | { |
| 5447 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_write(): reset test LID fail!\n\r"); |
| 5448 | return KAL_FALSE; |
| 5449 | } |
| 5450 | folder_index = nvram_query_folder_index(ldi->category); |
| 5451 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 5452 | nvram_query_file_name(folder_index, nvramname, filename); |
| 5453 | FS_Delete(filename); |
| 5454 | |
| 5455 | //reset SYS LID to default value |
| 5456 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 5457 | { |
| 5458 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_write(): reset SYS LID fail!\n\r"); |
| 5459 | return KAL_FALSE; |
| 5460 | } |
| 5461 | |
| 5462 | //call nvram_init() |
| 5463 | nvram_boot_trace = 0; |
| 5464 | nvram_init(); |
| 5465 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 5466 | { |
| 5467 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_write(): enter version conflict fail!\n\r"); |
| 5468 | return KAL_FALSE; |
| 5469 | } |
| 5470 | |
| 5471 | //lid access |
| 5472 | nvram_ut_assert_flag = 0; |
| 5473 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_2_LID, |
| 5474 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 5475 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 5476 | { |
| 5477 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_write(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 5478 | return KAL_FALSE; |
| 5479 | } |
| 5480 | if(nvram_ut_assert_flag) |
| 5481 | { |
| 5482 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_write(): unexpect assert happen!\n\r"); |
| 5483 | return KAL_FALSE; |
| 5484 | } |
| 5485 | #ifdef __NVRAM_LID_CACHE__ |
| 5486 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 5487 | #endif |
| 5488 | return KAL_TRUE; |
| 5489 | |
| 5490 | } |
| 5491 | |
| 5492 | kal_bool normal_boot_internal_lost_reset(kal_uint32 flags, void *param) |
| 5493 | { |
| 5494 | nvram_ltable_entry_struct *ldi = NULL; |
| 5495 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 5496 | nvram_folder_enum folder_index; |
| 5497 | NVRAM_FILE_NAME nvramname; |
| 5498 | |
| 5499 | #ifdef __NVRAM_LID_CACHE__ |
| 5500 | nvram_cache_reset();//Disable NVRAM Cache |
| 5501 | #endif |
| 5502 | |
| 5503 | //reset test LIDs to default settings |
| 5504 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_2_LID) ) |
| 5505 | { |
| 5506 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_reset(): reset test LID settings fail!\n\r"); |
| 5507 | } |
| 5508 | |
| 5509 | //this test will use LID verno "000" only |
| 5510 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_2_LID, 0, 0) ) |
| 5511 | { |
| 5512 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_reset(): delete test LID fail!\n\r"); |
| 5513 | } |
| 5514 | |
| 5515 | //reset LID and then delete it |
| 5516 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_2_LID); |
| 5517 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 5518 | { |
| 5519 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_reset(): reset test LID fail!\n\r"); |
| 5520 | return KAL_FALSE; |
| 5521 | } |
| 5522 | folder_index = nvram_query_folder_index(ldi->category); |
| 5523 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 5524 | nvram_query_file_name(folder_index, nvramname, filename); |
| 5525 | FS_Delete(filename); |
| 5526 | |
| 5527 | //reset SYS LID to default value |
| 5528 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 5529 | { |
| 5530 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_reset(): reset SYS LID fail!\n\r"); |
| 5531 | return KAL_FALSE; |
| 5532 | } |
| 5533 | |
| 5534 | //call nvram_init() |
| 5535 | nvram_boot_trace = 0; |
| 5536 | nvram_init(); |
| 5537 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 5538 | { |
| 5539 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_reset(): enter version conflict fail!\n\r"); |
| 5540 | return KAL_FALSE; |
| 5541 | } |
| 5542 | |
| 5543 | //lid access |
| 5544 | nvram_ut_assert_flag = 0; |
| 5545 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_2_LID, |
| 5546 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 5547 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 5548 | { |
| 5549 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_reset(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 5550 | return KAL_FALSE; |
| 5551 | } |
| 5552 | if(nvram_ut_assert_flag) |
| 5553 | { |
| 5554 | nvram_ut_trace("[NVUT] normal_boot_internal_lost_reset(): unexpect assert happen!\n\r"); |
| 5555 | return KAL_FALSE; |
| 5556 | } |
| 5557 | #ifdef __NVRAM_LID_CACHE__ |
| 5558 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 5559 | #endif |
| 5560 | return KAL_TRUE; |
| 5561 | |
| 5562 | } |
| 5563 | |
| 5564 | kal_bool normal_boot_calibrat_lost_read(kal_uint32 flags, void *param) |
| 5565 | { |
| 5566 | nvram_ltable_entry_struct *ldi = NULL; |
| 5567 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 5568 | nvram_folder_enum folder_index; |
| 5569 | NVRAM_FILE_NAME nvramname; |
| 5570 | kal_uint8 i; |
| 5571 | |
| 5572 | #ifdef __NVRAM_LID_CACHE__ |
| 5573 | nvram_cache_reset();//Disable NVRAM Cache |
| 5574 | #endif |
| 5575 | |
| 5576 | //reset test LIDs to default settings |
| 5577 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_3_LID) ) |
| 5578 | { |
| 5579 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_read(): reset test LID settings fail!\n\r"); |
| 5580 | } |
| 5581 | |
| 5582 | //this test will use LID verno "000" only |
| 5583 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_3_LID, 0, 0) ) |
| 5584 | { |
| 5585 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_read(): delete test LID fail!\n\r"); |
| 5586 | } |
| 5587 | |
| 5588 | //reset LID and then delete it |
| 5589 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_3_LID); |
| 5590 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 5591 | { |
| 5592 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_read(): reset test LID fail!\n\r"); |
| 5593 | return KAL_FALSE; |
| 5594 | } |
| 5595 | folder_index = nvram_query_folder_index(ldi->category); |
| 5596 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 5597 | nvram_query_file_name(folder_index, nvramname, filename); |
| 5598 | FS_Delete(filename); |
| 5599 | |
| 5600 | //reset SYS LID to default value |
| 5601 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 5602 | { |
| 5603 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_read(): reset SYS LID fail!\n\r"); |
| 5604 | return KAL_FALSE; |
| 5605 | } |
| 5606 | |
| 5607 | //call nvram_init() |
| 5608 | nvram_boot_trace = 0; |
| 5609 | nvram_init(); |
| 5610 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 5611 | { |
| 5612 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_read(): enter version conflict fail!\n\r"); |
| 5613 | return KAL_FALSE; |
| 5614 | } |
| 5615 | |
| 5616 | //lid access |
| 5617 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_3_LID); |
| 5618 | kal_mem_set(data_buffer, 0, ldi->size); |
| 5619 | data_buffer[0] = 0x1; //modify to the value before binregion backup |
| 5620 | for(i = 1; i <= ldi->total_records; i++) |
| 5621 | { |
| 5622 | if(!nvram_external_read_data(ldi->LID, i, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 5623 | { |
| 5624 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_read(): read LID fail!\n\r"); |
| 5625 | return KAL_FALSE; |
| 5626 | } |
| 5627 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 5628 | { |
| 5629 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_read(): read back value not expect!\n\r"); |
| 5630 | return KAL_FALSE; |
| 5631 | } |
| 5632 | } |
| 5633 | #ifdef __NVRAM_LID_CACHE__ |
| 5634 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 5635 | #endif |
| 5636 | return KAL_TRUE; |
| 5637 | |
| 5638 | } |
| 5639 | |
| 5640 | kal_bool normal_boot_calibrat_lost_write(kal_uint32 flags, void *param) |
| 5641 | { |
| 5642 | nvram_ltable_entry_struct *ldi = NULL; |
| 5643 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 5644 | nvram_folder_enum folder_index; |
| 5645 | NVRAM_FILE_NAME nvramname; |
| 5646 | |
| 5647 | #ifdef __NVRAM_LID_CACHE__ |
| 5648 | nvram_cache_reset();//Disable NVRAM Cache |
| 5649 | #endif |
| 5650 | |
| 5651 | //reset test LIDs to default settings |
| 5652 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_3_LID) ) |
| 5653 | { |
| 5654 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_write(): reset test LID settings fail!\n\r"); |
| 5655 | } |
| 5656 | |
| 5657 | //this test will use LID verno "000" only |
| 5658 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_3_LID, 0, 0) ) |
| 5659 | { |
| 5660 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_write(): delete test LID fail!\n\r"); |
| 5661 | } |
| 5662 | |
| 5663 | //reset LID and then delete it |
| 5664 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_3_LID); |
| 5665 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 5666 | { |
| 5667 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_write(): reset test LID fail!\n\r"); |
| 5668 | return KAL_FALSE; |
| 5669 | } |
| 5670 | folder_index = nvram_query_folder_index(ldi->category); |
| 5671 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 5672 | nvram_query_file_name(folder_index, nvramname, filename); |
| 5673 | FS_Delete(filename); |
| 5674 | |
| 5675 | //reset SYS LID to default value |
| 5676 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 5677 | { |
| 5678 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_write(): reset SYS LID fail!\n\r"); |
| 5679 | return KAL_FALSE; |
| 5680 | } |
| 5681 | |
| 5682 | //call nvram_init() |
| 5683 | nvram_boot_trace = 0; |
| 5684 | nvram_init(); |
| 5685 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 5686 | { |
| 5687 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_write(): enter version conflict fail!\n\r"); |
| 5688 | return KAL_FALSE; |
| 5689 | } |
| 5690 | |
| 5691 | //lid access |
| 5692 | nvram_ut_assert_flag = 0; |
| 5693 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_3_LID, |
| 5694 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 5695 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 5696 | { |
| 5697 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_write(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 5698 | return KAL_FALSE; |
| 5699 | } |
| 5700 | if(nvram_ut_assert_flag) |
| 5701 | { |
| 5702 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_write(): unexpect assert happen!\n\r"); |
| 5703 | return KAL_FALSE; |
| 5704 | } |
| 5705 | #ifdef __NVRAM_LID_CACHE__ |
| 5706 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 5707 | #endif |
| 5708 | return KAL_TRUE; |
| 5709 | |
| 5710 | } |
| 5711 | |
| 5712 | kal_bool normal_boot_calibrat_lost_reset(kal_uint32 flags, void *param) |
| 5713 | { |
| 5714 | nvram_ltable_entry_struct *ldi = NULL; |
| 5715 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 5716 | nvram_folder_enum folder_index; |
| 5717 | NVRAM_FILE_NAME nvramname; |
| 5718 | |
| 5719 | #ifdef __NVRAM_LID_CACHE__ |
| 5720 | nvram_cache_reset();//Disable NVRAM Cache |
| 5721 | #endif |
| 5722 | |
| 5723 | //reset test LIDs to default settings |
| 5724 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_3_LID) ) |
| 5725 | { |
| 5726 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_reset(): reset test LID settings fail!\n\r"); |
| 5727 | } |
| 5728 | |
| 5729 | //this test will use LID verno "000" only |
| 5730 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_3_LID, 0, 0) ) |
| 5731 | { |
| 5732 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_reset(): delete test LID fail!\n\r"); |
| 5733 | } |
| 5734 | |
| 5735 | //reset LID and then delete it |
| 5736 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_3_LID); |
| 5737 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 5738 | { |
| 5739 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_reset(): reset test LID fail!\n\r"); |
| 5740 | return KAL_FALSE; |
| 5741 | } |
| 5742 | folder_index = nvram_query_folder_index(ldi->category); |
| 5743 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 5744 | nvram_query_file_name(folder_index, nvramname, filename); |
| 5745 | FS_Delete(filename); |
| 5746 | |
| 5747 | //reset SYS LID to default value |
| 5748 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 5749 | { |
| 5750 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_reset(): reset SYS LID fail!\n\r"); |
| 5751 | return KAL_FALSE; |
| 5752 | } |
| 5753 | |
| 5754 | //call nvram_init() |
| 5755 | nvram_boot_trace = 0; |
| 5756 | nvram_init(); |
| 5757 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 5758 | { |
| 5759 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_reset(): enter version conflict fail!\n\r"); |
| 5760 | return KAL_FALSE; |
| 5761 | } |
| 5762 | |
| 5763 | //lid access |
| 5764 | nvram_ut_assert_flag = 0; |
| 5765 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_3_LID, |
| 5766 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 5767 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 5768 | { |
| 5769 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_reset(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 5770 | return KAL_FALSE; |
| 5771 | } |
| 5772 | if(nvram_ut_assert_flag) |
| 5773 | { |
| 5774 | nvram_ut_trace("[NVUT] normal_boot_calibrat_lost_reset(): unexpect assert happen!\n\r"); |
| 5775 | return KAL_FALSE; |
| 5776 | } |
| 5777 | #ifdef __NVRAM_LID_CACHE__ |
| 5778 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 5779 | #endif |
| 5780 | return KAL_TRUE; |
| 5781 | |
| 5782 | } |
| 5783 | |
| 5784 | kal_bool normal_boot_important_lost_read(kal_uint32 flags, void *param) |
| 5785 | { |
| 5786 | nvram_ltable_entry_struct *ldi = NULL; |
| 5787 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 5788 | nvram_folder_enum folder_index; |
| 5789 | NVRAM_FILE_NAME nvramname; |
| 5790 | kal_uint8 i; |
| 5791 | |
| 5792 | #ifdef __NVRAM_LID_CACHE__ |
| 5793 | nvram_cache_reset();//Disable NVRAM Cache |
| 5794 | #endif |
| 5795 | |
| 5796 | //reset test LIDs to default settings |
| 5797 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_4_LID) ) |
| 5798 | { |
| 5799 | nvram_ut_trace("[NVUT] normal_boot_important_lost_read(): reset test LID settings fail!\n\r"); |
| 5800 | } |
| 5801 | |
| 5802 | //this test will use LID verno "000" only |
| 5803 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_4_LID, 0, 0) ) |
| 5804 | { |
| 5805 | nvram_ut_trace("[NVUT] normal_boot_important_lost_read(): delete test LID fail!\n\r"); |
| 5806 | } |
| 5807 | |
| 5808 | //reset LID and then delete it |
| 5809 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_4_LID); |
| 5810 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 5811 | { |
| 5812 | nvram_ut_trace("[NVUT] normal_boot_important_lost_read(): reset test LID fail!\n\r"); |
| 5813 | return KAL_FALSE; |
| 5814 | } |
| 5815 | folder_index = nvram_query_folder_index(ldi->category); |
| 5816 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 5817 | nvram_query_file_name(folder_index, nvramname, filename); |
| 5818 | FS_Delete(filename); |
| 5819 | |
| 5820 | |
| 5821 | //reset SYS LID to default value |
| 5822 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 5823 | { |
| 5824 | nvram_ut_trace("[NVUT] normal_boot_important_lost_read(): reset SYS LID fail!\n\r"); |
| 5825 | return KAL_FALSE; |
| 5826 | } |
| 5827 | |
| 5828 | //call nvram_init() |
| 5829 | nvram_boot_trace = 0; |
| 5830 | nvram_init(); |
| 5831 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 5832 | { |
| 5833 | nvram_ut_trace("[NVUT] normal_boot_important_lost_read(): enter version conflict fail!\n\r"); |
| 5834 | return KAL_FALSE; |
| 5835 | } |
| 5836 | |
| 5837 | //lid access |
| 5838 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_4_LID); |
| 5839 | kal_mem_set(data_buffer, 0, ldi->size); |
| 5840 | data_buffer[0] = 0x1; //modify to the value before binregion backup |
| 5841 | for(i = 1; i <= ldi->total_records; i++) |
| 5842 | { |
| 5843 | if(!nvram_external_read_data(ldi->LID, i, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 5844 | { |
| 5845 | nvram_ut_trace("[NVUT] normal_boot_important_lost_read(): read LID fail!\n\r"); |
| 5846 | return KAL_FALSE; |
| 5847 | } |
| 5848 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 5849 | { |
| 5850 | nvram_ut_trace("[NVUT] normal_boot_important_lost_read(): read back value not expect!\n\r"); |
| 5851 | return KAL_FALSE; |
| 5852 | } |
| 5853 | } |
| 5854 | #ifdef __NVRAM_LID_CACHE__ |
| 5855 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 5856 | #endif |
| 5857 | return KAL_TRUE; |
| 5858 | |
| 5859 | } |
| 5860 | |
| 5861 | kal_bool normal_boot_important_lost_write(kal_uint32 flags, void *param) |
| 5862 | { |
| 5863 | nvram_ltable_entry_struct *ldi = NULL; |
| 5864 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 5865 | nvram_folder_enum folder_index; |
| 5866 | NVRAM_FILE_NAME nvramname; |
| 5867 | |
| 5868 | #ifdef __NVRAM_LID_CACHE__ |
| 5869 | nvram_cache_reset();//Disable NVRAM Cache |
| 5870 | #endif |
| 5871 | |
| 5872 | //reset test LIDs to default settings |
| 5873 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_4_LID) ) |
| 5874 | { |
| 5875 | nvram_ut_trace("[NVUT] normal_boot_important_lost_write(): reset test LID settings fail!\n\r"); |
| 5876 | } |
| 5877 | |
| 5878 | //this test will use LID verno "000" only |
| 5879 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_4_LID, 0, 0) ) |
| 5880 | { |
| 5881 | nvram_ut_trace("[NVUT] normal_boot_important_lost_write(): delete test LID fail!\n\r"); |
| 5882 | } |
| 5883 | |
| 5884 | //reset LID and then delete it |
| 5885 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_4_LID); |
| 5886 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 5887 | { |
| 5888 | nvram_ut_trace("[NVUT] normal_boot_important_lost_write(): reset test LID fail!\n\r"); |
| 5889 | return KAL_FALSE; |
| 5890 | } |
| 5891 | folder_index = nvram_query_folder_index(ldi->category); |
| 5892 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 5893 | nvram_query_file_name(folder_index, nvramname, filename); |
| 5894 | FS_Delete(filename); |
| 5895 | |
| 5896 | //reset SYS LID to default value |
| 5897 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 5898 | { |
| 5899 | nvram_ut_trace("[NVUT] normal_boot_important_lost_write(): reset SYS LID fail!\n\r"); |
| 5900 | return KAL_FALSE; |
| 5901 | } |
| 5902 | |
| 5903 | //call nvram_init() |
| 5904 | nvram_boot_trace = 0; |
| 5905 | nvram_init(); |
| 5906 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 5907 | { |
| 5908 | nvram_ut_trace("[NVUT] normal_boot_important_lost_write(): enter version conflict fail!\n\r"); |
| 5909 | return KAL_FALSE; |
| 5910 | } |
| 5911 | |
| 5912 | //lid access |
| 5913 | nvram_ut_assert_flag = 0; |
| 5914 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_4_LID, |
| 5915 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 5916 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 5917 | { |
| 5918 | nvram_ut_trace("[NVUT] normal_boot_important_lost_write(): write fail do not happen!\n\r"); |
| 5919 | return KAL_FALSE; |
| 5920 | } |
| 5921 | if(0 != nvram_ut_assert_flag) |
| 5922 | { |
| 5923 | nvram_ut_trace("[NVUT] normal_boot_important_lost_write(): expect assert not happen!\n\r"); |
| 5924 | return KAL_FALSE; |
| 5925 | } |
| 5926 | #ifdef __NVRAM_LID_CACHE__ |
| 5927 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 5928 | #endif |
| 5929 | return KAL_TRUE; |
| 5930 | |
| 5931 | } |
| 5932 | |
| 5933 | kal_bool normal_boot_important_lost_reset(kal_uint32 flags, void *param) |
| 5934 | { |
| 5935 | nvram_ltable_entry_struct *ldi = NULL; |
| 5936 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 5937 | nvram_folder_enum folder_index; |
| 5938 | NVRAM_FILE_NAME nvramname; |
| 5939 | |
| 5940 | #ifdef __NVRAM_LID_CACHE__ |
| 5941 | nvram_cache_reset();//Disable NVRAM Cache |
| 5942 | #endif |
| 5943 | |
| 5944 | //reset test LIDs to default settings |
| 5945 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_4_LID) ) |
| 5946 | { |
| 5947 | nvram_ut_trace("[NVUT] normal_boot_important_lost_reset(): reset test LID settings fail!\n\r"); |
| 5948 | } |
| 5949 | |
| 5950 | //this test will use LID verno "000" only |
| 5951 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_4_LID, 0, 0) ) |
| 5952 | { |
| 5953 | nvram_ut_trace("[NVUT] normal_boot_important_lost_reset(): delete test LID fail!\n\r"); |
| 5954 | } |
| 5955 | |
| 5956 | //reset LID and then delete it |
| 5957 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_4_LID); |
| 5958 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 5959 | { |
| 5960 | nvram_ut_trace("[NVUT] normal_boot_important_lost_reset(): reset test LID fail!\n\r"); |
| 5961 | return KAL_FALSE; |
| 5962 | } |
| 5963 | folder_index = nvram_query_folder_index(ldi->category); |
| 5964 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 5965 | nvram_query_file_name(folder_index, nvramname, filename); |
| 5966 | FS_Delete(filename); |
| 5967 | |
| 5968 | //reset SYS LID to default value |
| 5969 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 5970 | { |
| 5971 | nvram_ut_trace("[NVUT] normal_boot_important_lost_reset(): reset SYS LID fail!\n\r"); |
| 5972 | return KAL_FALSE; |
| 5973 | } |
| 5974 | |
| 5975 | //call nvram_init() |
| 5976 | nvram_boot_trace = 0; |
| 5977 | nvram_init(); |
| 5978 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 5979 | { |
| 5980 | nvram_ut_trace("[NVUT] normal_boot_important_lost_reset(): enter version conflict fail!\n\r"); |
| 5981 | return KAL_FALSE; |
| 5982 | } |
| 5983 | |
| 5984 | //lid access |
| 5985 | nvram_ut_assert_flag = 0; |
| 5986 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_4_LID, |
| 5987 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 5988 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 5989 | { |
| 5990 | nvram_ut_trace("[NVUT] normal_boot_important_lost_reset(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 5991 | return KAL_FALSE; |
| 5992 | } |
| 5993 | if(nvram_ut_assert_flag) |
| 5994 | { |
| 5995 | nvram_ut_trace("[NVUT] normal_boot_important_lost_reset(): unexpect asser happen!\n\r"); |
| 5996 | return KAL_FALSE; |
| 5997 | } |
| 5998 | #ifdef __NVRAM_LID_CACHE__ |
| 5999 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 6000 | #endif |
| 6001 | return KAL_TRUE; |
| 6002 | |
| 6003 | } |
| 6004 | |
| 6005 | kal_bool normal_boot_importantl1_lost_read(kal_uint32 flags, void *param) |
| 6006 | { |
| 6007 | nvram_ltable_entry_struct *ldi = NULL; |
| 6008 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 6009 | nvram_folder_enum folder_index; |
| 6010 | NVRAM_FILE_NAME nvramname; |
| 6011 | |
| 6012 | #ifdef __NVRAM_LID_CACHE__ |
| 6013 | nvram_cache_reset();//Disable NVRAM Cache |
| 6014 | #endif |
| 6015 | |
| 6016 | //reset test LIDs to default settings |
| 6017 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_5_LID) ) |
| 6018 | { |
| 6019 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_read(): reset test LID settings fail!\n\r"); |
| 6020 | } |
| 6021 | |
| 6022 | //this test will use LID verno "000" only |
| 6023 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_5_LID, 0, 0) ) |
| 6024 | { |
| 6025 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_read(): delete test LID fail!\n\r"); |
| 6026 | } |
| 6027 | |
| 6028 | //reset LID and then delete it |
| 6029 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_5_LID); |
| 6030 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 6031 | { |
| 6032 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_read(): reset test LID fail!\n\r"); |
| 6033 | return KAL_FALSE; |
| 6034 | } |
| 6035 | folder_index = nvram_query_folder_index(ldi->category); |
| 6036 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 6037 | nvram_query_file_name(folder_index, nvramname, filename); |
| 6038 | FS_Delete(filename); |
| 6039 | |
| 6040 | //reset SYS LID to default value |
| 6041 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 6042 | { |
| 6043 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_read(): reset SYS LID fail!\n\r"); |
| 6044 | return KAL_FALSE; |
| 6045 | } |
| 6046 | |
| 6047 | //call nvram_init() |
| 6048 | nvram_boot_trace = 0; |
| 6049 | nvram_init(); |
| 6050 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 6051 | { |
| 6052 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_read(): enter version conflict fail!\n\r"); |
| 6053 | return KAL_FALSE; |
| 6054 | } |
| 6055 | |
| 6056 | //lid access |
| 6057 | nvram_ut_assert_flag = 0; |
| 6058 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_5_LID, |
| 6059 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READ, 0, 0, 0), |
| 6060 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 6061 | { |
| 6062 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_read(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 6063 | return KAL_FALSE; |
| 6064 | } |
| 6065 | if(nvram_ut_assert_flag) |
| 6066 | { |
| 6067 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_read(): unexpect assert happen!\n\r"); |
| 6068 | return KAL_FALSE; |
| 6069 | } |
| 6070 | #ifdef __NVRAM_LID_CACHE__ |
| 6071 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 6072 | #endif |
| 6073 | return KAL_TRUE; |
| 6074 | |
| 6075 | } |
| 6076 | |
| 6077 | kal_bool normal_boot_importantl1_lost_write(kal_uint32 flags, void *param) |
| 6078 | { |
| 6079 | nvram_ltable_entry_struct *ldi = NULL; |
| 6080 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 6081 | nvram_folder_enum folder_index; |
| 6082 | NVRAM_FILE_NAME nvramname; |
| 6083 | |
| 6084 | #ifdef __NVRAM_LID_CACHE__ |
| 6085 | nvram_cache_reset();//Disable NVRAM Cache |
| 6086 | #endif |
| 6087 | |
| 6088 | //reset test LIDs to default settings |
| 6089 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_5_LID) ) |
| 6090 | { |
| 6091 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_write(): reset test LID settings fail!\n\r"); |
| 6092 | } |
| 6093 | |
| 6094 | //this test will use LID verno "000" only |
| 6095 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_5_LID, 0, 0) ) |
| 6096 | { |
| 6097 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_write(): delete test LID fail!\n\r"); |
| 6098 | } |
| 6099 | |
| 6100 | //reset LID and then delete it |
| 6101 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_5_LID); |
| 6102 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 6103 | { |
| 6104 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_write(): reset test LID fail!\n\r"); |
| 6105 | return KAL_FALSE; |
| 6106 | } |
| 6107 | folder_index = nvram_query_folder_index(ldi->category); |
| 6108 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 6109 | nvram_query_file_name(folder_index, nvramname, filename); |
| 6110 | FS_Delete(filename); |
| 6111 | |
| 6112 | //reset SYS LID to default value |
| 6113 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 6114 | { |
| 6115 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_write(): reset SYS LID fail!\n\r"); |
| 6116 | return KAL_FALSE; |
| 6117 | } |
| 6118 | |
| 6119 | //call nvram_init() |
| 6120 | nvram_boot_trace = 0; |
| 6121 | nvram_init(); |
| 6122 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 6123 | { |
| 6124 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_write(): enter version conflict fail!\n\r"); |
| 6125 | return KAL_FALSE; |
| 6126 | } |
| 6127 | |
| 6128 | //lid access |
| 6129 | nvram_ut_assert_flag = 0; |
| 6130 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_5_LID, |
| 6131 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 6132 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 6133 | { |
| 6134 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_write(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 6135 | return KAL_FALSE; |
| 6136 | } |
| 6137 | if(nvram_ut_assert_flag) |
| 6138 | { |
| 6139 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_write(): unexpect assert happen!\n\r"); |
| 6140 | return KAL_FALSE; |
| 6141 | } |
| 6142 | #ifdef __NVRAM_LID_CACHE__ |
| 6143 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 6144 | #endif |
| 6145 | return KAL_TRUE; |
| 6146 | |
| 6147 | } |
| 6148 | |
| 6149 | kal_bool normal_boot_importantl1_lost_reset(kal_uint32 flags, void *param) |
| 6150 | { |
| 6151 | nvram_ltable_entry_struct *ldi = NULL; |
| 6152 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 6153 | nvram_folder_enum folder_index; |
| 6154 | NVRAM_FILE_NAME nvramname; |
| 6155 | |
| 6156 | #ifdef __NVRAM_LID_CACHE__ |
| 6157 | nvram_cache_reset();//Disable NVRAM Cache |
| 6158 | #endif |
| 6159 | |
| 6160 | //reset test LIDs to default settings |
| 6161 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_5_LID) ) |
| 6162 | { |
| 6163 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_reset(): reset test LID settings fail!\n\r"); |
| 6164 | } |
| 6165 | |
| 6166 | //this test will use LID verno "000" only |
| 6167 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_5_LID, 0, 0) ) |
| 6168 | { |
| 6169 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_reset(): delete test LID fail!\n\r"); |
| 6170 | } |
| 6171 | |
| 6172 | //reset LID and then delete it |
| 6173 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_5_LID); |
| 6174 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 6175 | { |
| 6176 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_reset(): reset test LID fail!\n\r"); |
| 6177 | return KAL_FALSE; |
| 6178 | } |
| 6179 | folder_index = nvram_query_folder_index(ldi->category); |
| 6180 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 6181 | nvram_query_file_name(folder_index, nvramname, filename); |
| 6182 | FS_Delete(filename); |
| 6183 | |
| 6184 | //reset SYS LID to default value |
| 6185 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 6186 | { |
| 6187 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_reset(): reset SYS LID fail!\n\r"); |
| 6188 | return KAL_FALSE; |
| 6189 | } |
| 6190 | |
| 6191 | //call nvram_init() |
| 6192 | nvram_boot_trace = 0; |
| 6193 | nvram_init(); |
| 6194 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 6195 | { |
| 6196 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_reset(): enter version conflict fail!\n\r"); |
| 6197 | return KAL_FALSE; |
| 6198 | } |
| 6199 | |
| 6200 | //lid access |
| 6201 | nvram_ut_assert_flag = 0; |
| 6202 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_5_LID, |
| 6203 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 6204 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 6205 | { |
| 6206 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_reset(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 6207 | return KAL_FALSE; |
| 6208 | } |
| 6209 | if(nvram_ut_assert_flag) |
| 6210 | { |
| 6211 | nvram_ut_trace("[NVUT] normal_boot_importantl1_lost_reset(): unexpect assert happen!\n\r"); |
| 6212 | return KAL_FALSE; |
| 6213 | } |
| 6214 | #ifdef __NVRAM_LID_CACHE__ |
| 6215 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 6216 | #endif |
| 6217 | return KAL_TRUE; |
| 6218 | |
| 6219 | } |
| 6220 | |
| 6221 | kal_bool normal_boot_importantl4_lost_read(kal_uint32 flags, void *param) |
| 6222 | { |
| 6223 | nvram_ltable_entry_struct *ldi = NULL; |
| 6224 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 6225 | nvram_folder_enum folder_index; |
| 6226 | NVRAM_FILE_NAME nvramname; |
| 6227 | |
| 6228 | #ifdef __NVRAM_LID_CACHE__ |
| 6229 | nvram_cache_reset();//Disable NVRAM Cache |
| 6230 | #endif |
| 6231 | |
| 6232 | //reset test LIDs to default settings |
| 6233 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_6_LID) ) |
| 6234 | { |
| 6235 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_read(): reset test LID settings fail!\n\r"); |
| 6236 | } |
| 6237 | |
| 6238 | //this test will use LID verno "000" only |
| 6239 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_6_LID, 0, 0) ) |
| 6240 | { |
| 6241 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_read(): delete test LID fail!\n\r"); |
| 6242 | } |
| 6243 | |
| 6244 | //reset LID and then delete it |
| 6245 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_6_LID); |
| 6246 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 6247 | { |
| 6248 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_read(): reset test LID fail!\n\r"); |
| 6249 | return KAL_FALSE; |
| 6250 | } |
| 6251 | folder_index = nvram_query_folder_index(ldi->category); |
| 6252 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 6253 | nvram_query_file_name(folder_index, nvramname, filename); |
| 6254 | FS_Delete(filename); |
| 6255 | |
| 6256 | //reset SYS LID to default value |
| 6257 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 6258 | { |
| 6259 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_read(): reset SYS LID fail!\n\r"); |
| 6260 | return KAL_FALSE; |
| 6261 | } |
| 6262 | |
| 6263 | //call nvram_init() |
| 6264 | nvram_boot_trace = 0; |
| 6265 | nvram_init(); |
| 6266 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 6267 | { |
| 6268 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_read(): enter version conflict fail!\n\r"); |
| 6269 | return KAL_FALSE; |
| 6270 | } |
| 6271 | |
| 6272 | //lid access, without FATAL_ASSET will run reset flow |
| 6273 | nvram_ut_assert_flag = 0; |
| 6274 | if(0 |
| 6275 | != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_6_LID, |
| 6276 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READ, 0, 0, 0), |
| 6277 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 6278 | { |
| 6279 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_read(): read fail happen!\n\r"); |
| 6280 | return KAL_FALSE; |
| 6281 | } |
| 6282 | if(0 != nvram_ut_assert_flag) |
| 6283 | { |
| 6284 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_read(): unexpect assert happen!\n\r"); |
| 6285 | return KAL_FALSE; |
| 6286 | } |
| 6287 | #ifdef __NVRAM_LID_CACHE__ |
| 6288 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 6289 | #endif |
| 6290 | return KAL_TRUE; |
| 6291 | |
| 6292 | } |
| 6293 | |
| 6294 | kal_bool normal_boot_importantl4_lost_write(kal_uint32 flags, void *param) |
| 6295 | { |
| 6296 | nvram_ltable_entry_struct *ldi = NULL; |
| 6297 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 6298 | nvram_folder_enum folder_index; |
| 6299 | NVRAM_FILE_NAME nvramname; |
| 6300 | |
| 6301 | #ifdef __NVRAM_LID_CACHE__ |
| 6302 | nvram_cache_reset();//Disable NVRAM Cache |
| 6303 | #endif |
| 6304 | |
| 6305 | //reset test LIDs to default settings |
| 6306 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_6_LID) ) |
| 6307 | { |
| 6308 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_write(): reset test LID settings fail!\n\r"); |
| 6309 | } |
| 6310 | |
| 6311 | //this test will use LID verno "000" only |
| 6312 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_6_LID, 0, 0) ) |
| 6313 | { |
| 6314 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_write(): delete test LID fail!\n\r"); |
| 6315 | } |
| 6316 | |
| 6317 | //reset LID and then delete it |
| 6318 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_6_LID); |
| 6319 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 6320 | { |
| 6321 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_write(): reset test LID fail!\n\r"); |
| 6322 | return KAL_FALSE; |
| 6323 | } |
| 6324 | folder_index = nvram_query_folder_index(ldi->category); |
| 6325 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 6326 | nvram_query_file_name(folder_index, nvramname, filename); |
| 6327 | FS_Delete(filename); |
| 6328 | |
| 6329 | //reset SYS LID to default value |
| 6330 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 6331 | { |
| 6332 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_write(): reset SYS LID fail!\n\r"); |
| 6333 | return KAL_FALSE; |
| 6334 | } |
| 6335 | |
| 6336 | //call nvram_init() |
| 6337 | nvram_boot_trace = 0; |
| 6338 | nvram_init(); |
| 6339 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 6340 | { |
| 6341 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_write(): enter version conflict fail!\n\r"); |
| 6342 | return KAL_FALSE; |
| 6343 | } |
| 6344 | |
| 6345 | //lid access, without FATAL_ASSET will run reset flow |
| 6346 | nvram_ut_assert_flag = 0; |
| 6347 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_6_LID, |
| 6348 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 6349 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 6350 | { |
| 6351 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_write(): write fail happen!\n\r"); |
| 6352 | return KAL_FALSE; |
| 6353 | } |
| 6354 | if(0 != nvram_ut_assert_flag) |
| 6355 | { |
| 6356 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_write(): unexpect assert happen!\n\r"); |
| 6357 | return KAL_FALSE; |
| 6358 | } |
| 6359 | #ifdef __NVRAM_LID_CACHE__ |
| 6360 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 6361 | #endif |
| 6362 | return KAL_TRUE; |
| 6363 | |
| 6364 | } |
| 6365 | |
| 6366 | kal_bool normal_boot_importantl4_lost_reset(kal_uint32 flags, void *param) |
| 6367 | { |
| 6368 | nvram_ltable_entry_struct *ldi = NULL; |
| 6369 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 6370 | nvram_folder_enum folder_index; |
| 6371 | NVRAM_FILE_NAME nvramname; |
| 6372 | |
| 6373 | #ifdef __NVRAM_LID_CACHE__ |
| 6374 | nvram_cache_reset();//Disable NVRAM Cache |
| 6375 | #endif |
| 6376 | |
| 6377 | //reset test LIDs to default settings |
| 6378 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_6_LID) ) |
| 6379 | { |
| 6380 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_reset(): reset test LID settings fail!\n\r"); |
| 6381 | } |
| 6382 | |
| 6383 | //this test will use LID verno "000" only |
| 6384 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_6_LID, 0, 0) ) |
| 6385 | { |
| 6386 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_reset(): delete test LID fail!\n\r"); |
| 6387 | } |
| 6388 | |
| 6389 | //reset LID and then delete it |
| 6390 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_6_LID); |
| 6391 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 6392 | { |
| 6393 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_reset(): reset test LID fail!\n\r"); |
| 6394 | return KAL_FALSE; |
| 6395 | } |
| 6396 | folder_index = nvram_query_folder_index(ldi->category); |
| 6397 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 6398 | nvram_query_file_name(folder_index, nvramname, filename); |
| 6399 | FS_Delete(filename); |
| 6400 | |
| 6401 | //reset SYS LID to default value |
| 6402 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 6403 | { |
| 6404 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_reset(): reset SYS LID fail!\n\r"); |
| 6405 | return KAL_FALSE; |
| 6406 | } |
| 6407 | |
| 6408 | //call nvram_init() |
| 6409 | nvram_boot_trace = 0; |
| 6410 | nvram_init(); |
| 6411 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 6412 | { |
| 6413 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_reset(): enter version conflict fail!\n\r"); |
| 6414 | return KAL_FALSE; |
| 6415 | } |
| 6416 | |
| 6417 | //lid access |
| 6418 | nvram_ut_assert_flag = 0; |
| 6419 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_6_LID, |
| 6420 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 6421 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 6422 | { |
| 6423 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_reset(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 6424 | return KAL_FALSE; |
| 6425 | } |
| 6426 | if(nvram_ut_assert_flag) |
| 6427 | { |
| 6428 | nvram_ut_trace("[NVUT] normal_boot_importantl4_lost_reset(): unexpect asser happen!\n\r"); |
| 6429 | return KAL_FALSE; |
| 6430 | } |
| 6431 | #ifdef __NVRAM_LID_CACHE__ |
| 6432 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 6433 | #endif |
| 6434 | return KAL_TRUE; |
| 6435 | |
| 6436 | } |
| 6437 | |
| 6438 | kal_bool normal_boot_user_altered_read(kal_uint32 flags, void *param) |
| 6439 | { |
| 6440 | nvram_ltable_entry_struct *ldi = NULL; |
| 6441 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 6442 | nvram_folder_enum folder_index; |
| 6443 | NVRAM_FILE_NAME nvramname; |
| 6444 | FS_HANDLE hFile = 0; |
| 6445 | kal_uint32 len; |
| 6446 | |
| 6447 | #ifdef __NVRAM_LID_CACHE__ |
| 6448 | nvram_cache_reset();//Disable NVRAM Cache |
| 6449 | #endif |
| 6450 | |
| 6451 | //reset test LIDs to default settings |
| 6452 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 6453 | { |
| 6454 | nvram_ut_trace("[NVUT] normal_boot_user_altered_read(): reset test LID settings fail!\n\r"); |
| 6455 | } |
| 6456 | |
| 6457 | //this test will use LID verno "000" only |
| 6458 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 6459 | { |
| 6460 | nvram_ut_trace("[NVUT] normal_boot_user_altered_read(): delete test LID fail!\n\r"); |
| 6461 | } |
| 6462 | |
| 6463 | //reset(create) test LID |
| 6464 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 6465 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 6466 | { |
| 6467 | nvram_ut_trace("[NVUT] normal_boot_user_altered_read(): reset test LID fail!\n\r"); |
| 6468 | return KAL_FALSE; |
| 6469 | } |
| 6470 | |
| 6471 | //alter test LID |
| 6472 | folder_index = nvram_query_folder_index(ldi->category); |
| 6473 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 6474 | nvram_query_file_name(folder_index, nvramname, filename); |
| 6475 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 6476 | if (hFile == FS_FILE_NOT_FOUND) |
| 6477 | { |
| 6478 | nvram_ut_trace("[NVUT] normal_boot_user_altered_read(): can not find test LID!\n\r"); |
| 6479 | return KAL_FALSE; |
| 6480 | } |
| 6481 | else if (hFile <= FS_NO_ERROR) |
| 6482 | { |
| 6483 | nvram_ut_trace("[NVUT] normal_boot_user_altered_read(): open test LID fail!\n\r"); |
| 6484 | return KAL_FALSE; |
| 6485 | } |
| 6486 | |
| 6487 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 6488 | { |
| 6489 | nvram_ut_trace("[NVUT] normal_boot_user_altered_read(): first FS_Seek test LID fail!\n\r"); |
| 6490 | return KAL_FALSE; |
| 6491 | } |
| 6492 | |
| 6493 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 6494 | { |
| 6495 | nvram_ut_trace("[NVUT] normal_boot_user_altered_read(): read test LID fail!\n\r"); |
| 6496 | return KAL_FALSE; |
| 6497 | } |
| 6498 | |
| 6499 | data_buffer[0] += 1; |
| 6500 | data_buffer[1] += 1; |
| 6501 | data_buffer[2] += 1; |
| 6502 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 6503 | { |
| 6504 | nvram_ut_trace("[NVUT] normal_boot_user_altered_read(): FS_Seek test LID fail!\n\r"); |
| 6505 | return KAL_FALSE; |
| 6506 | } |
| 6507 | |
| 6508 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 6509 | { |
| 6510 | nvram_ut_trace("[NVUT] normal_boot_user_altered_read(): write back test LID fail!\n\r"); |
| 6511 | return KAL_FALSE; |
| 6512 | } |
| 6513 | |
| 6514 | if(hFile > FS_NO_ERROR) |
| 6515 | { |
| 6516 | FS_Close(hFile); |
| 6517 | } |
| 6518 | |
| 6519 | //reset SYS LID to default value |
| 6520 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 6521 | { |
| 6522 | nvram_ut_trace("[NVUT] normal_boot_user_altered_read(): reset SYS LID fail!\n\r"); |
| 6523 | return KAL_FALSE; |
| 6524 | } |
| 6525 | |
| 6526 | //call nvram_init() |
| 6527 | nvram_boot_trace = 0; |
| 6528 | nvram_init(); |
| 6529 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 6530 | { |
| 6531 | nvram_ut_trace("[NVUT] normal_boot_user_altered_read(): enter version conflict fail!\n\r"); |
| 6532 | return KAL_FALSE; |
| 6533 | } |
| 6534 | |
| 6535 | //lid access |
| 6536 | nvram_ut_assert_flag = 0; |
| 6537 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 6538 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, 0, 0, 0), |
| 6539 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 6540 | { |
| 6541 | nvram_ut_trace("[NVUT] normal_boot_user_altered_read(): unexpect read fail happen!\n\r"); |
| 6542 | return KAL_FALSE; |
| 6543 | } |
| 6544 | if(nvram_ut_assert_flag) |
| 6545 | { |
| 6546 | nvram_ut_trace("[NVUT] normal_boot_user_altered_read(): unexpect assert happen!\n\r"); |
| 6547 | return KAL_FALSE; |
| 6548 | } |
| 6549 | #ifdef __NVRAM_LID_CACHE__ |
| 6550 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 6551 | #endif |
| 6552 | return KAL_TRUE; |
| 6553 | |
| 6554 | } |
| 6555 | |
| 6556 | kal_bool normal_boot_user_altered_write(kal_uint32 flags, void *param) |
| 6557 | { |
| 6558 | nvram_ltable_entry_struct *ldi = NULL; |
| 6559 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 6560 | nvram_folder_enum folder_index; |
| 6561 | NVRAM_FILE_NAME nvramname; |
| 6562 | FS_HANDLE hFile = 0; |
| 6563 | kal_uint32 len; |
| 6564 | |
| 6565 | #ifdef __NVRAM_LID_CACHE__ |
| 6566 | nvram_cache_reset();//Disable NVRAM Cache |
| 6567 | #endif |
| 6568 | |
| 6569 | //reset test LIDs to default settings |
| 6570 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 6571 | { |
| 6572 | nvram_ut_trace("[NVUT] normal_boot_user_altered_write(): reset test LID settings fail!\n\r"); |
| 6573 | } |
| 6574 | |
| 6575 | //this test will use LID verno "000" only |
| 6576 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 6577 | { |
| 6578 | nvram_ut_trace("[NVUT] normal_boot_user_altered_write(): delete test LID fail!\n\r"); |
| 6579 | } |
| 6580 | |
| 6581 | //reset(create) test LID |
| 6582 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 6583 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 6584 | { |
| 6585 | nvram_ut_trace("[NVUT] normal_boot_user_altered_write(): reset test LID fail!\n\r"); |
| 6586 | return KAL_FALSE; |
| 6587 | } |
| 6588 | |
| 6589 | //alter test LID |
| 6590 | folder_index = nvram_query_folder_index(ldi->category); |
| 6591 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 6592 | nvram_query_file_name(folder_index, nvramname, filename); |
| 6593 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 6594 | if (hFile == FS_FILE_NOT_FOUND) |
| 6595 | { |
| 6596 | nvram_ut_trace("[NVUT] normal_boot_user_altered_write(): can not find test LID!\n\r"); |
| 6597 | return KAL_FALSE; |
| 6598 | } |
| 6599 | else if (hFile <= FS_NO_ERROR) |
| 6600 | { |
| 6601 | nvram_ut_trace("[NVUT] normal_boot_user_altered_write(): open test LID fail!\n\r"); |
| 6602 | return KAL_FALSE; |
| 6603 | } |
| 6604 | |
| 6605 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 6606 | { |
| 6607 | nvram_ut_trace("[NVUT] normal_boot_user_altered_write(): first FS_Seek test LID fail!\n\r"); |
| 6608 | return KAL_FALSE; |
| 6609 | } |
| 6610 | |
| 6611 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 6612 | { |
| 6613 | nvram_ut_trace("[NVUT] normal_boot_user_altered_write(): read test LID fail!\n\r"); |
| 6614 | return KAL_FALSE; |
| 6615 | } |
| 6616 | |
| 6617 | data_buffer[0] += 1; |
| 6618 | data_buffer[1] += 1; |
| 6619 | data_buffer[2] += 1; |
| 6620 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 6621 | { |
| 6622 | nvram_ut_trace("[NVUT] normal_boot_user_altered_write(): FS_Seek test LID fail!\n\r"); |
| 6623 | return KAL_FALSE; |
| 6624 | } |
| 6625 | |
| 6626 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 6627 | { |
| 6628 | nvram_ut_trace("[NVUT] normal_boot_user_altered_write(): write back test LID fail!\n\r"); |
| 6629 | return KAL_FALSE; |
| 6630 | } |
| 6631 | if(hFile > FS_NO_ERROR) |
| 6632 | { |
| 6633 | FS_Close(hFile); |
| 6634 | } |
| 6635 | |
| 6636 | //reset SYS LID to default value |
| 6637 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 6638 | { |
| 6639 | nvram_ut_trace("[NVUT] normal_boot_user_altered_write(): reset SYS LID fail!\n\r"); |
| 6640 | return KAL_FALSE; |
| 6641 | } |
| 6642 | |
| 6643 | //call nvram_init() |
| 6644 | nvram_boot_trace = 0; |
| 6645 | nvram_init(); |
| 6646 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 6647 | { |
| 6648 | nvram_ut_trace("[NVUT] normal_boot_user_altered_write(): enter version conflict fail!\n\r"); |
| 6649 | return KAL_FALSE; |
| 6650 | } |
| 6651 | |
| 6652 | //lid access |
| 6653 | nvram_ut_assert_flag = 0; |
| 6654 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 6655 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 6656 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 6657 | { |
| 6658 | nvram_ut_trace("[NVUT] normal_boot_user_altered_write(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 6659 | return KAL_FALSE; |
| 6660 | } |
| 6661 | if(nvram_ut_assert_flag) |
| 6662 | { |
| 6663 | nvram_ut_trace("[NVUT] normal_boot_user_altered_write(): unexpect assert happen!\n\r"); |
| 6664 | return KAL_FALSE; |
| 6665 | } |
| 6666 | #ifdef __NVRAM_LID_CACHE__ |
| 6667 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 6668 | #endif |
| 6669 | return KAL_TRUE; |
| 6670 | |
| 6671 | } |
| 6672 | |
| 6673 | kal_bool normal_boot_user_altered_reset(kal_uint32 flags, void *param) |
| 6674 | { |
| 6675 | nvram_ltable_entry_struct *ldi = NULL; |
| 6676 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 6677 | nvram_folder_enum folder_index; |
| 6678 | NVRAM_FILE_NAME nvramname; |
| 6679 | FS_HANDLE hFile = 0; |
| 6680 | kal_uint32 len; |
| 6681 | #ifdef __NVRAM_LID_CACHE__ |
| 6682 | nvram_cache_reset();//Disable NVRAM Cache |
| 6683 | #endif |
| 6684 | //reset test LIDs to default settings |
| 6685 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 6686 | { |
| 6687 | nvram_ut_trace("[NVUT] normal_boot_user_altered_reset(): reset test LID settings fail!\n\r"); |
| 6688 | } |
| 6689 | |
| 6690 | //this test will use LID verno "000" only |
| 6691 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 6692 | { |
| 6693 | nvram_ut_trace("[NVUT] normal_boot_user_altered_reset(): delete test LID fail!\n\r"); |
| 6694 | } |
| 6695 | |
| 6696 | //reset(create) test LID |
| 6697 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 6698 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 6699 | { |
| 6700 | nvram_ut_trace("[NVUT] normal_boot_user_altered_reset(): reset test LID fail!\n\r"); |
| 6701 | return KAL_FALSE; |
| 6702 | } |
| 6703 | |
| 6704 | //alter test LID |
| 6705 | folder_index = nvram_query_folder_index(ldi->category); |
| 6706 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 6707 | nvram_query_file_name(folder_index, nvramname, filename); |
| 6708 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 6709 | if (hFile == FS_FILE_NOT_FOUND) |
| 6710 | { |
| 6711 | nvram_ut_trace("[NVUT] normal_boot_user_altered_reset(): can not find test LID!\n\r"); |
| 6712 | return KAL_FALSE; |
| 6713 | } |
| 6714 | else if (hFile <= FS_NO_ERROR) |
| 6715 | { |
| 6716 | nvram_ut_trace("[NVUT] normal_boot_user_altered_reset(): open test LID fail!\n\r"); |
| 6717 | return KAL_FALSE; |
| 6718 | } |
| 6719 | |
| 6720 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 6721 | { |
| 6722 | nvram_ut_trace("[NVUT] normal_boot_user_altered_reset(): first FS_Seek test LID fail!\n\r"); |
| 6723 | return KAL_FALSE; |
| 6724 | } |
| 6725 | |
| 6726 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 6727 | { |
| 6728 | nvram_ut_trace("[NVUT] normal_boot_user_altered_reset(): read test LID fail!\n\r"); |
| 6729 | return KAL_FALSE; |
| 6730 | } |
| 6731 | |
| 6732 | data_buffer[0] += 1; |
| 6733 | data_buffer[1] += 1; |
| 6734 | data_buffer[2] += 1; |
| 6735 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 6736 | { |
| 6737 | nvram_ut_trace("[NVUT] normal_boot_user_altered_reset(): FS_Seek test LID fail!\n\r"); |
| 6738 | return KAL_FALSE; |
| 6739 | } |
| 6740 | |
| 6741 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 6742 | { |
| 6743 | nvram_ut_trace("[NVUT] normal_boot_user_altered_reset(): write back test LID fail!\n\r"); |
| 6744 | return KAL_FALSE; |
| 6745 | } |
| 6746 | |
| 6747 | if(hFile > FS_NO_ERROR) |
| 6748 | { |
| 6749 | FS_Close(hFile); |
| 6750 | } |
| 6751 | |
| 6752 | //reset SYS LID to default value |
| 6753 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 6754 | { |
| 6755 | nvram_ut_trace("[NVUT] normal_boot_user_altered_reset(): reset SYS LID fail!\n\r"); |
| 6756 | return KAL_FALSE; |
| 6757 | } |
| 6758 | |
| 6759 | //call nvram_init() |
| 6760 | nvram_boot_trace = 0; |
| 6761 | nvram_init(); |
| 6762 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 6763 | { |
| 6764 | nvram_ut_trace("[NVUT] normal_boot_user_altered_reset(): enter version conflict fail!\n\r"); |
| 6765 | return KAL_FALSE; |
| 6766 | } |
| 6767 | |
| 6768 | //lid access |
| 6769 | nvram_ut_assert_flag = 0; |
| 6770 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 6771 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 6772 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 6773 | { |
| 6774 | nvram_ut_trace("[NVUT] normal_boot_user_altered_reset(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 6775 | return KAL_FALSE; |
| 6776 | } |
| 6777 | if(nvram_ut_assert_flag) |
| 6778 | { |
| 6779 | nvram_ut_trace("[NVUT] normal_boot_user_altered_reset(): unexpect assert happen!\n\r"); |
| 6780 | return KAL_FALSE; |
| 6781 | } |
| 6782 | #ifdef __NVRAM_LID_CACHE__ |
| 6783 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 6784 | #endif |
| 6785 | return KAL_TRUE; |
| 6786 | |
| 6787 | } |
| 6788 | |
| 6789 | kal_bool normal_boot_internal_altered_read(kal_uint32 flags, void *param) |
| 6790 | { |
| 6791 | nvram_ltable_entry_struct *ldi = NULL; |
| 6792 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 6793 | nvram_folder_enum folder_index; |
| 6794 | NVRAM_FILE_NAME nvramname; |
| 6795 | FS_HANDLE hFile = 0; |
| 6796 | kal_uint32 len; |
| 6797 | #ifdef __NVRAM_LID_CACHE__ |
| 6798 | nvram_cache_reset();//Disable NVRAM Cache |
| 6799 | #endif |
| 6800 | //reset test LIDs to default settings |
| 6801 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_2_LID) ) |
| 6802 | { |
| 6803 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_read(): reset test LID settings fail!\n\r"); |
| 6804 | } |
| 6805 | |
| 6806 | //this test will use LID verno "000" only |
| 6807 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_2_LID, 0, 0) ) |
| 6808 | { |
| 6809 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_read(): delete test LID fail!\n\r"); |
| 6810 | } |
| 6811 | |
| 6812 | //reset(create) test LID |
| 6813 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_2_LID); |
| 6814 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 6815 | { |
| 6816 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_read(): reset test LID fail!\n\r"); |
| 6817 | return KAL_FALSE; |
| 6818 | } |
| 6819 | |
| 6820 | //alter test LID |
| 6821 | folder_index = nvram_query_folder_index(ldi->category); |
| 6822 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 6823 | nvram_query_file_name(folder_index, nvramname, filename); |
| 6824 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 6825 | if (hFile == FS_FILE_NOT_FOUND) |
| 6826 | { |
| 6827 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_read(): can not find test LID!\n\r"); |
| 6828 | return KAL_FALSE; |
| 6829 | } |
| 6830 | else if (hFile <= FS_NO_ERROR) |
| 6831 | { |
| 6832 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_read(): open test LID fail!\n\r"); |
| 6833 | return KAL_FALSE; |
| 6834 | } |
| 6835 | |
| 6836 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 6837 | { |
| 6838 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_read(): first FS_Seek test LID fail!\n\r"); |
| 6839 | return KAL_FALSE; |
| 6840 | } |
| 6841 | |
| 6842 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 6843 | { |
| 6844 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_read(): read test LID fail!\n\r"); |
| 6845 | return KAL_FALSE; |
| 6846 | } |
| 6847 | |
| 6848 | data_buffer[0] += 1; |
| 6849 | data_buffer[1] += 1; |
| 6850 | data_buffer[2] += 1; |
| 6851 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 6852 | { |
| 6853 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_read(): FS_Seek test LID fail!\n\r"); |
| 6854 | return KAL_FALSE; |
| 6855 | } |
| 6856 | |
| 6857 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 6858 | { |
| 6859 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_read(): write back test LID fail!\n\r"); |
| 6860 | return KAL_FALSE; |
| 6861 | } |
| 6862 | |
| 6863 | if(hFile > FS_NO_ERROR) |
| 6864 | { |
| 6865 | FS_Close(hFile); |
| 6866 | } |
| 6867 | |
| 6868 | //reset SYS LID to default value |
| 6869 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 6870 | { |
| 6871 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_read(): reset SYS LID fail!\n\r"); |
| 6872 | return KAL_FALSE; |
| 6873 | } |
| 6874 | |
| 6875 | //call nvram_init() |
| 6876 | nvram_boot_trace = 0; |
| 6877 | nvram_init(); |
| 6878 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 6879 | { |
| 6880 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_read(): enter version conflict fail!\n\r"); |
| 6881 | return KAL_FALSE; |
| 6882 | } |
| 6883 | |
| 6884 | //lid access |
| 6885 | nvram_ut_assert_flag = 0; |
| 6886 | //internal LID size change expect read fail, internal will not run reset flow in nvram_read_data_item() |
| 6887 | if(0 == nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_2_LID, |
| 6888 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READ, 0, 0, 0), |
| 6889 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 6890 | { |
| 6891 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_read(): expect read fail not happen!\n\r"); |
| 6892 | return KAL_FALSE; |
| 6893 | } |
| 6894 | if(nvram_ut_assert_flag) |
| 6895 | { |
| 6896 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_read(): unexpect assert happen!\n\r"); |
| 6897 | return KAL_FALSE; |
| 6898 | } |
| 6899 | #ifdef __NVRAM_LID_CACHE__ |
| 6900 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 6901 | #endif |
| 6902 | return KAL_TRUE; |
| 6903 | |
| 6904 | } |
| 6905 | |
| 6906 | kal_bool normal_boot_internal_altered_write(kal_uint32 flags, void *param) |
| 6907 | { |
| 6908 | nvram_ltable_entry_struct *ldi = NULL; |
| 6909 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 6910 | nvram_folder_enum folder_index; |
| 6911 | NVRAM_FILE_NAME nvramname; |
| 6912 | FS_HANDLE hFile = 0; |
| 6913 | kal_uint32 len; |
| 6914 | #ifdef __NVRAM_LID_CACHE__ |
| 6915 | nvram_cache_reset();//Disable NVRAM Cache |
| 6916 | #endif |
| 6917 | //reset test LIDs to default settings |
| 6918 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_2_LID) ) |
| 6919 | { |
| 6920 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_write(): reset test LID settings fail!\n\r"); |
| 6921 | } |
| 6922 | |
| 6923 | //this test will use LID verno "000" only |
| 6924 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_2_LID, 0, 0) ) |
| 6925 | { |
| 6926 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_write(): delete test LID fail!\n\r"); |
| 6927 | } |
| 6928 | |
| 6929 | //reset(create) test LID |
| 6930 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_2_LID); |
| 6931 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 6932 | { |
| 6933 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_write(): reset test LID fail!\n\r"); |
| 6934 | return KAL_FALSE; |
| 6935 | } |
| 6936 | |
| 6937 | //alter test LID |
| 6938 | folder_index = nvram_query_folder_index(ldi->category); |
| 6939 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 6940 | nvram_query_file_name(folder_index, nvramname, filename); |
| 6941 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 6942 | if (hFile == FS_FILE_NOT_FOUND) |
| 6943 | { |
| 6944 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_write(): can not find test LID!\n\r"); |
| 6945 | return KAL_FALSE; |
| 6946 | } |
| 6947 | else if (hFile <= FS_NO_ERROR) |
| 6948 | { |
| 6949 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_write(): open test LID fail!\n\r"); |
| 6950 | return KAL_FALSE; |
| 6951 | } |
| 6952 | |
| 6953 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 6954 | { |
| 6955 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_write(): first FS_Seek test LID fail!\n\r"); |
| 6956 | return KAL_FALSE; |
| 6957 | } |
| 6958 | |
| 6959 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 6960 | { |
| 6961 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_write(): read test LID fail!\n\r"); |
| 6962 | return KAL_FALSE; |
| 6963 | } |
| 6964 | |
| 6965 | data_buffer[0] += 1; |
| 6966 | data_buffer[1] += 1; |
| 6967 | data_buffer[2] += 1; |
| 6968 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 6969 | { |
| 6970 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_write(): FS_Seek test LID fail!\n\r"); |
| 6971 | return KAL_FALSE; |
| 6972 | } |
| 6973 | |
| 6974 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 6975 | { |
| 6976 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_write(): write back test LID fail!\n\r"); |
| 6977 | return KAL_FALSE; |
| 6978 | } |
| 6979 | |
| 6980 | if(hFile > FS_NO_ERROR) |
| 6981 | { |
| 6982 | FS_Close(hFile); |
| 6983 | } |
| 6984 | |
| 6985 | //reset SYS LID to default value |
| 6986 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 6987 | { |
| 6988 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_write(): reset SYS LID fail!\n\r"); |
| 6989 | return KAL_FALSE; |
| 6990 | } |
| 6991 | |
| 6992 | //call nvram_init() |
| 6993 | nvram_boot_trace = 0; |
| 6994 | nvram_init(); |
| 6995 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 6996 | { |
| 6997 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_write(): enter version conflict fail!\n\r"); |
| 6998 | return KAL_FALSE; |
| 6999 | } |
| 7000 | |
| 7001 | //lid access |
| 7002 | nvram_ut_assert_flag = 0; |
| 7003 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_2_LID, |
| 7004 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 7005 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 7006 | { |
| 7007 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_write(): write test LID fail!\n\r"); |
| 7008 | return KAL_FALSE; |
| 7009 | } |
| 7010 | if(nvram_ut_assert_flag) |
| 7011 | { |
| 7012 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_write(): unexpect assert happen!\n\r"); |
| 7013 | return KAL_FALSE; |
| 7014 | } |
| 7015 | #ifdef __NVRAM_LID_CACHE__ |
| 7016 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 7017 | #endif |
| 7018 | return KAL_TRUE; |
| 7019 | |
| 7020 | } |
| 7021 | |
| 7022 | kal_bool normal_boot_internal_altered_reset(kal_uint32 flags, void *param) |
| 7023 | { |
| 7024 | nvram_ltable_entry_struct *ldi = NULL; |
| 7025 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 7026 | nvram_folder_enum folder_index; |
| 7027 | NVRAM_FILE_NAME nvramname; |
| 7028 | FS_HANDLE hFile = 0; |
| 7029 | kal_uint32 len; |
| 7030 | #ifdef __NVRAM_LID_CACHE__ |
| 7031 | nvram_cache_reset();//Disable NVRAM Cache |
| 7032 | #endif |
| 7033 | //reset test LIDs to default settings |
| 7034 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_2_LID) ) |
| 7035 | { |
| 7036 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_reset(): reset test LID settings fail!\n\r"); |
| 7037 | } |
| 7038 | |
| 7039 | //this test will use LID verno "000" only |
| 7040 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_2_LID, 0, 0) ) |
| 7041 | { |
| 7042 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_reset(): delete test LID fail!\n\r"); |
| 7043 | } |
| 7044 | |
| 7045 | //reset(create) test LID |
| 7046 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_2_LID); |
| 7047 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 7048 | { |
| 7049 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_reset(): reset test LID fail!\n\r"); |
| 7050 | return KAL_FALSE; |
| 7051 | } |
| 7052 | |
| 7053 | //alter test LID |
| 7054 | folder_index = nvram_query_folder_index(ldi->category); |
| 7055 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 7056 | nvram_query_file_name(folder_index, nvramname, filename); |
| 7057 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 7058 | if (hFile == FS_FILE_NOT_FOUND) |
| 7059 | { |
| 7060 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_reset(): can not find test LID!\n\r"); |
| 7061 | return KAL_FALSE; |
| 7062 | } |
| 7063 | else if (hFile <= FS_NO_ERROR) |
| 7064 | { |
| 7065 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_reset(): open test LID fail!\n\r"); |
| 7066 | return KAL_FALSE; |
| 7067 | } |
| 7068 | |
| 7069 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 7070 | { |
| 7071 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_reset(): first FS_Seek test LID fail!\n\r"); |
| 7072 | return KAL_FALSE; |
| 7073 | } |
| 7074 | |
| 7075 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 7076 | { |
| 7077 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_reset(): read test LID fail!\n\r"); |
| 7078 | return KAL_FALSE; |
| 7079 | } |
| 7080 | |
| 7081 | data_buffer[0] += 1; |
| 7082 | data_buffer[1] += 1; |
| 7083 | data_buffer[2] += 1; |
| 7084 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 7085 | { |
| 7086 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_reset(): FS_Seek test LID fail!\n\r"); |
| 7087 | return KAL_FALSE; |
| 7088 | } |
| 7089 | |
| 7090 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 7091 | { |
| 7092 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_reset(): write back test LID fail!\n\r"); |
| 7093 | return KAL_FALSE; |
| 7094 | } |
| 7095 | |
| 7096 | if(hFile > FS_NO_ERROR) |
| 7097 | { |
| 7098 | FS_Close(hFile); |
| 7099 | } |
| 7100 | |
| 7101 | //reset SYS LID to default value |
| 7102 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 7103 | { |
| 7104 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_reset(): reset SYS LID fail!\n\r"); |
| 7105 | return KAL_FALSE; |
| 7106 | } |
| 7107 | |
| 7108 | //call nvram_init() |
| 7109 | nvram_boot_trace = 0; |
| 7110 | nvram_init(); |
| 7111 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 7112 | { |
| 7113 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_reset(): enter version conflict fail!\n\r"); |
| 7114 | return KAL_FALSE; |
| 7115 | } |
| 7116 | |
| 7117 | //lid access |
| 7118 | nvram_ut_assert_flag = 0; |
| 7119 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_2_LID, |
| 7120 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 7121 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 7122 | { |
| 7123 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_reset(): reset test LID fail!\n\r"); |
| 7124 | return KAL_FALSE; |
| 7125 | } |
| 7126 | if(nvram_ut_assert_flag) |
| 7127 | { |
| 7128 | nvram_ut_trace("[NVUT] normal_boot_internal_altered_reset(): unexpect assert happen!\n\r"); |
| 7129 | return KAL_FALSE; |
| 7130 | } |
| 7131 | #ifdef __NVRAM_LID_CACHE__ |
| 7132 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 7133 | #endif |
| 7134 | return KAL_TRUE; |
| 7135 | |
| 7136 | } |
| 7137 | |
| 7138 | kal_bool normal_boot_calibrat_altered_read(kal_uint32 flags, void *param) |
| 7139 | { |
| 7140 | nvram_ltable_entry_struct *ldi = NULL; |
| 7141 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 7142 | nvram_folder_enum folder_index; |
| 7143 | NVRAM_FILE_NAME nvramname; |
| 7144 | FS_HANDLE hFile = 0; |
| 7145 | kal_uint32 len; |
| 7146 | kal_uint8 i; |
| 7147 | #ifdef __NVRAM_LID_CACHE__ |
| 7148 | nvram_cache_reset();//Disable NVRAM Cache |
| 7149 | #endif |
| 7150 | //reset test LIDs to default settings |
| 7151 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_3_LID) ) |
| 7152 | { |
| 7153 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_read(): reset test LID settings fail!\n\r"); |
| 7154 | } |
| 7155 | |
| 7156 | //this test will use LID verno "000" only |
| 7157 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_3_LID, 0, 0) ) |
| 7158 | { |
| 7159 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_read(): delete test LID fail!\n\r"); |
| 7160 | } |
| 7161 | |
| 7162 | //reset(create) test LID |
| 7163 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_3_LID); |
| 7164 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 7165 | { |
| 7166 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_read(): reset test LID fail!\n\r"); |
| 7167 | return KAL_FALSE; |
| 7168 | } |
| 7169 | |
| 7170 | //alter test LID |
| 7171 | folder_index = nvram_query_folder_index(ldi->category); |
| 7172 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 7173 | nvram_query_file_name(folder_index, nvramname, filename); |
| 7174 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 7175 | if (hFile == FS_FILE_NOT_FOUND) |
| 7176 | { |
| 7177 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_read(): can not find test LID!\n\r"); |
| 7178 | return KAL_FALSE; |
| 7179 | } |
| 7180 | else if (hFile <= FS_NO_ERROR) |
| 7181 | { |
| 7182 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_read(): open test LID fail!\n\r"); |
| 7183 | return KAL_FALSE; |
| 7184 | } |
| 7185 | |
| 7186 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 7187 | { |
| 7188 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_read(): first FS_Seek test LID fail!\n\r"); |
| 7189 | return KAL_FALSE; |
| 7190 | } |
| 7191 | |
| 7192 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 7193 | { |
| 7194 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_read(): read test LID fail!\n\r"); |
| 7195 | return KAL_FALSE; |
| 7196 | } |
| 7197 | |
| 7198 | data_buffer[0] += 1; |
| 7199 | data_buffer[1] += 1; |
| 7200 | data_buffer[2] += 1; |
| 7201 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 7202 | { |
| 7203 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_read(): FS_Seek test LID fail!\n\r"); |
| 7204 | return KAL_FALSE; |
| 7205 | } |
| 7206 | |
| 7207 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 7208 | { |
| 7209 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_read(): write back test LID fail!\n\r"); |
| 7210 | return KAL_FALSE; |
| 7211 | } |
| 7212 | |
| 7213 | if(hFile > FS_NO_ERROR) |
| 7214 | { |
| 7215 | FS_Close(hFile); |
| 7216 | } |
| 7217 | |
| 7218 | //reset SYS LID to default value |
| 7219 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 7220 | { |
| 7221 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_read(): reset SYS LID fail!\n\r"); |
| 7222 | return KAL_FALSE; |
| 7223 | } |
| 7224 | |
| 7225 | //call nvram_init() |
| 7226 | nvram_boot_trace = 0; |
| 7227 | nvram_init(); |
| 7228 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 7229 | { |
| 7230 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_read(): enter version conflict fail!\n\r"); |
| 7231 | return KAL_FALSE; |
| 7232 | } |
| 7233 | |
| 7234 | //lid access |
| 7235 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_3_LID); |
| 7236 | kal_mem_set(data_buffer, 0, ldi->size); |
| 7237 | data_buffer[0] = 0x1; //modify to the value before binregion backup |
| 7238 | for(i = 1; i <= ldi->total_records; i++) |
| 7239 | { |
| 7240 | if(!nvram_external_read_data(ldi->LID, i, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 7241 | { |
| 7242 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_read(): read LID fail!\n\r"); |
| 7243 | return KAL_FALSE; |
| 7244 | } |
| 7245 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 7246 | { |
| 7247 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_read(): read back value not expect!\n\r"); |
| 7248 | return KAL_FALSE; |
| 7249 | } |
| 7250 | } |
| 7251 | #ifdef __NVRAM_LID_CACHE__ |
| 7252 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 7253 | #endif |
| 7254 | return KAL_TRUE; |
| 7255 | |
| 7256 | } |
| 7257 | |
| 7258 | kal_bool normal_boot_calibrat_altered_write(kal_uint32 flags, void *param) |
| 7259 | { |
| 7260 | nvram_ltable_entry_struct *ldi = NULL; |
| 7261 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 7262 | nvram_folder_enum folder_index; |
| 7263 | NVRAM_FILE_NAME nvramname; |
| 7264 | FS_HANDLE hFile = 0; |
| 7265 | kal_uint32 len; |
| 7266 | #ifdef __NVRAM_LID_CACHE__ |
| 7267 | nvram_cache_reset();//Disable NVRAM Cache |
| 7268 | #endif |
| 7269 | //reset test LIDs to default settings |
| 7270 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_3_LID) ) |
| 7271 | { |
| 7272 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_write(): reset test LID settings fail!\n\r"); |
| 7273 | } |
| 7274 | |
| 7275 | //this test will use LID verno "000" only |
| 7276 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_3_LID, 0, 0) ) |
| 7277 | { |
| 7278 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_write(): delete test LID fail!\n\r"); |
| 7279 | } |
| 7280 | |
| 7281 | //reset(create) test LID |
| 7282 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_3_LID); |
| 7283 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 7284 | { |
| 7285 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_write(): reset test LID fail!\n\r"); |
| 7286 | return KAL_FALSE; |
| 7287 | } |
| 7288 | |
| 7289 | //alter test LID |
| 7290 | folder_index = nvram_query_folder_index(ldi->category); |
| 7291 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 7292 | nvram_query_file_name(folder_index, nvramname, filename); |
| 7293 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 7294 | if (hFile == FS_FILE_NOT_FOUND) |
| 7295 | { |
| 7296 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_write(): can not find test LID!\n\r"); |
| 7297 | return KAL_FALSE; |
| 7298 | } |
| 7299 | else if (hFile <= FS_NO_ERROR) |
| 7300 | { |
| 7301 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_write(): open test LID fail!\n\r"); |
| 7302 | return KAL_FALSE; |
| 7303 | } |
| 7304 | |
| 7305 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 7306 | { |
| 7307 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_write(): first FS_Seek test LID fail!\n\r"); |
| 7308 | return KAL_FALSE; |
| 7309 | } |
| 7310 | |
| 7311 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 7312 | { |
| 7313 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_write(): read test LID fail!\n\r"); |
| 7314 | return KAL_FALSE; |
| 7315 | } |
| 7316 | |
| 7317 | data_buffer[0] += 1; |
| 7318 | data_buffer[1] += 1; |
| 7319 | data_buffer[2] += 1; |
| 7320 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 7321 | { |
| 7322 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_write(): FS_Seek test LID fail!\n\r"); |
| 7323 | return KAL_FALSE; |
| 7324 | } |
| 7325 | |
| 7326 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 7327 | { |
| 7328 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_write(): write back test LID fail!\n\r"); |
| 7329 | return KAL_FALSE; |
| 7330 | } |
| 7331 | |
| 7332 | if(hFile > FS_NO_ERROR) |
| 7333 | { |
| 7334 | FS_Close(hFile); |
| 7335 | } |
| 7336 | |
| 7337 | //reset SYS LID to default value |
| 7338 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 7339 | { |
| 7340 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_write(): reset SYS LID fail!\n\r"); |
| 7341 | return KAL_FALSE; |
| 7342 | } |
| 7343 | |
| 7344 | //call nvram_init() |
| 7345 | nvram_boot_trace = 0; |
| 7346 | nvram_init(); |
| 7347 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 7348 | { |
| 7349 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_write(): enter version conflict fail!\n\r"); |
| 7350 | return KAL_FALSE; |
| 7351 | } |
| 7352 | |
| 7353 | //lid access |
| 7354 | nvram_ut_assert_flag = 0; |
| 7355 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_3_LID, |
| 7356 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 7357 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 7358 | { |
| 7359 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_write(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 7360 | return KAL_FALSE; |
| 7361 | } |
| 7362 | if(nvram_ut_assert_flag) |
| 7363 | { |
| 7364 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_write(): unexpect assert happen!\n\r"); |
| 7365 | return KAL_FALSE; |
| 7366 | } |
| 7367 | #ifdef __NVRAM_LID_CACHE__ |
| 7368 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 7369 | #endif |
| 7370 | return KAL_TRUE; |
| 7371 | |
| 7372 | } |
| 7373 | |
| 7374 | kal_bool normal_boot_calibrat_altered_reset(kal_uint32 flags, void *param) |
| 7375 | { |
| 7376 | nvram_ltable_entry_struct *ldi = NULL; |
| 7377 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 7378 | nvram_folder_enum folder_index; |
| 7379 | NVRAM_FILE_NAME nvramname; |
| 7380 | FS_HANDLE hFile = 0; |
| 7381 | kal_uint32 len; |
| 7382 | #ifdef __NVRAM_LID_CACHE__ |
| 7383 | nvram_cache_reset();//Disable NVRAM Cache |
| 7384 | #endif |
| 7385 | //reset test LIDs to default settings |
| 7386 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_3_LID) ) |
| 7387 | { |
| 7388 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_reset(): reset test LID settings fail!\n\r"); |
| 7389 | } |
| 7390 | |
| 7391 | //this test will use LID verno "000" only |
| 7392 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_3_LID, 0, 0) ) |
| 7393 | { |
| 7394 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_reset(): delete test LID fail!\n\r"); |
| 7395 | } |
| 7396 | |
| 7397 | //reset(create) test LID |
| 7398 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_3_LID); |
| 7399 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 7400 | { |
| 7401 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_reset(): reset test LID fail!\n\r"); |
| 7402 | return KAL_FALSE; |
| 7403 | } |
| 7404 | |
| 7405 | //alter test LID |
| 7406 | folder_index = nvram_query_folder_index(ldi->category); |
| 7407 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 7408 | nvram_query_file_name(folder_index, nvramname, filename); |
| 7409 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 7410 | if (hFile == FS_FILE_NOT_FOUND) |
| 7411 | { |
| 7412 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_reset(): can not find test LID!\n\r"); |
| 7413 | return KAL_FALSE; |
| 7414 | } |
| 7415 | else if (hFile <= FS_NO_ERROR) |
| 7416 | { |
| 7417 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_reset(): open test LID fail!\n\r"); |
| 7418 | return KAL_FALSE; |
| 7419 | } |
| 7420 | |
| 7421 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 7422 | { |
| 7423 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_reset(): first FS_Seek test LID fail!\n\r"); |
| 7424 | return KAL_FALSE; |
| 7425 | } |
| 7426 | |
| 7427 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 7428 | { |
| 7429 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_reset(): read test LID fail!\n\r"); |
| 7430 | return KAL_FALSE; |
| 7431 | } |
| 7432 | |
| 7433 | data_buffer[0] += 1; |
| 7434 | data_buffer[1] += 1; |
| 7435 | data_buffer[2] += 1; |
| 7436 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 7437 | { |
| 7438 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_reset(): FS_Seek test LID fail!\n\r"); |
| 7439 | return KAL_FALSE; |
| 7440 | } |
| 7441 | |
| 7442 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 7443 | { |
| 7444 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_reset(): write back test LID fail!\n\r"); |
| 7445 | return KAL_FALSE; |
| 7446 | } |
| 7447 | |
| 7448 | if(hFile > FS_NO_ERROR) |
| 7449 | { |
| 7450 | FS_Close(hFile); |
| 7451 | } |
| 7452 | |
| 7453 | //reset SYS LID to default value |
| 7454 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 7455 | { |
| 7456 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_reset(): reset SYS LID fail!\n\r"); |
| 7457 | return KAL_FALSE; |
| 7458 | } |
| 7459 | |
| 7460 | //call nvram_init() |
| 7461 | nvram_boot_trace = 0; |
| 7462 | nvram_init(); |
| 7463 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 7464 | { |
| 7465 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_reset(): enter version conflict fail!\n\r"); |
| 7466 | return KAL_FALSE; |
| 7467 | } |
| 7468 | |
| 7469 | //lid access |
| 7470 | nvram_ut_assert_flag = 0; |
| 7471 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_3_LID, |
| 7472 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 7473 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 7474 | { |
| 7475 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_reset(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 7476 | return KAL_FALSE; |
| 7477 | } |
| 7478 | if(nvram_ut_assert_flag) |
| 7479 | { |
| 7480 | nvram_ut_trace("[NVUT] normal_boot_calibrat_altered_reset(): unexpect assert happen!\n\r"); |
| 7481 | return KAL_FALSE; |
| 7482 | } |
| 7483 | #ifdef __NVRAM_LID_CACHE__ |
| 7484 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 7485 | #endif |
| 7486 | return KAL_TRUE; |
| 7487 | |
| 7488 | } |
| 7489 | |
| 7490 | kal_bool normal_boot_important_altered_read(kal_uint32 flags, void *param) |
| 7491 | { |
| 7492 | nvram_ltable_entry_struct *ldi = NULL; |
| 7493 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 7494 | nvram_folder_enum folder_index; |
| 7495 | NVRAM_FILE_NAME nvramname; |
| 7496 | FS_HANDLE hFile = 0; |
| 7497 | kal_uint32 len; |
| 7498 | kal_uint8 i; |
| 7499 | #ifdef __NVRAM_LID_CACHE__ |
| 7500 | nvram_cache_reset();//Disable NVRAM Cache |
| 7501 | #endif |
| 7502 | //reset test LIDs to default settings |
| 7503 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_4_LID) ) |
| 7504 | { |
| 7505 | nvram_ut_trace("[NVUT] normal_boot_important_altered_read(): reset test LID settings fail!\n\r"); |
| 7506 | } |
| 7507 | |
| 7508 | //this test will use LID verno "000" only |
| 7509 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_4_LID, 0, 0) ) |
| 7510 | { |
| 7511 | nvram_ut_trace("[NVUT] normal_boot_important_altered_read(): delete test LID fail!\n\r"); |
| 7512 | } |
| 7513 | |
| 7514 | //reset(create) test LID |
| 7515 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_4_LID); |
| 7516 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 7517 | { |
| 7518 | nvram_ut_trace("[NVUT] normal_boot_important_altered_read(): reset test LID fail!\n\r"); |
| 7519 | return KAL_FALSE; |
| 7520 | } |
| 7521 | |
| 7522 | //alter test LID |
| 7523 | folder_index = nvram_query_folder_index(ldi->category); |
| 7524 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 7525 | nvram_query_file_name(folder_index, nvramname, filename); |
| 7526 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 7527 | if (hFile == FS_FILE_NOT_FOUND) |
| 7528 | { |
| 7529 | nvram_ut_trace("[NVUT] normal_boot_important_altered_read(): can not find test LID!\n\r"); |
| 7530 | return KAL_FALSE; |
| 7531 | } |
| 7532 | else if (hFile <= FS_NO_ERROR) |
| 7533 | { |
| 7534 | nvram_ut_trace("[NVUT] normal_boot_important_altered_read(): open test LID fail!\n\r"); |
| 7535 | return KAL_FALSE; |
| 7536 | } |
| 7537 | |
| 7538 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 7539 | { |
| 7540 | nvram_ut_trace("[NVUT] normal_boot_important_altered_read(): first FS_Seek test LID fail!\n\r"); |
| 7541 | return KAL_FALSE; |
| 7542 | } |
| 7543 | |
| 7544 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 7545 | { |
| 7546 | nvram_ut_trace("[NVUT] normal_boot_important_altered_read(): read test LID fail!\n\r"); |
| 7547 | return KAL_FALSE; |
| 7548 | } |
| 7549 | |
| 7550 | data_buffer[0] += 1; |
| 7551 | data_buffer[1] += 1; |
| 7552 | data_buffer[2] += 1; |
| 7553 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 7554 | { |
| 7555 | nvram_ut_trace("[NVUT] normal_boot_important_altered_read(): FS_Seek test LID fail!\n\r"); |
| 7556 | return KAL_FALSE; |
| 7557 | } |
| 7558 | |
| 7559 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 7560 | { |
| 7561 | nvram_ut_trace("[NVUT] normal_boot_important_altered_read(): write back test LID fail!\n\r"); |
| 7562 | return KAL_FALSE; |
| 7563 | } |
| 7564 | |
| 7565 | if(hFile > FS_NO_ERROR) |
| 7566 | { |
| 7567 | FS_Close(hFile); |
| 7568 | } |
| 7569 | |
| 7570 | //reset SYS LID to default value |
| 7571 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 7572 | { |
| 7573 | nvram_ut_trace("[NVUT] normal_boot_important_altered_read(): reset SYS LID fail!\n\r"); |
| 7574 | return KAL_FALSE; |
| 7575 | } |
| 7576 | |
| 7577 | //call nvram_init() |
| 7578 | nvram_boot_trace = 0; |
| 7579 | nvram_init(); |
| 7580 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 7581 | { |
| 7582 | nvram_ut_trace("[NVUT] normal_boot_important_altered_read(): enter version conflict fail!\n\r"); |
| 7583 | return KAL_FALSE; |
| 7584 | } |
| 7585 | |
| 7586 | //lid access |
| 7587 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_4_LID); |
| 7588 | kal_mem_set(data_buffer, 0, ldi->size); |
| 7589 | data_buffer[0] = 0x1; //modify to the value before binregion backup |
| 7590 | for(i = 1; i <= ldi->total_records; i++) |
| 7591 | { |
| 7592 | if(!nvram_external_read_data(ldi->LID, i, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 7593 | { |
| 7594 | nvram_ut_trace("[NVUT] normal_boot_important_altered_read(): read LID fail!\n\r"); |
| 7595 | return KAL_FALSE; |
| 7596 | } |
| 7597 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 7598 | { |
| 7599 | nvram_ut_trace("[NVUT] normal_boot_important_altered_read(): read back value not expect!\n\r"); |
| 7600 | return KAL_FALSE; |
| 7601 | } |
| 7602 | } |
| 7603 | #ifdef __NVRAM_LID_CACHE__ |
| 7604 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 7605 | #endif |
| 7606 | return KAL_TRUE; |
| 7607 | |
| 7608 | } |
| 7609 | |
| 7610 | kal_bool normal_boot_important_altered_write(kal_uint32 flags, void *param) |
| 7611 | { |
| 7612 | nvram_ltable_entry_struct *ldi = NULL; |
| 7613 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 7614 | nvram_folder_enum folder_index; |
| 7615 | NVRAM_FILE_NAME nvramname; |
| 7616 | FS_HANDLE hFile = 0; |
| 7617 | kal_uint32 len; |
| 7618 | #ifdef __NVRAM_LID_CACHE__ |
| 7619 | nvram_cache_reset();//Disable NVRAM Cache |
| 7620 | #endif |
| 7621 | //reset test LIDs to default settings |
| 7622 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_4_LID) ) |
| 7623 | { |
| 7624 | nvram_ut_trace("[NVUT] normal_boot_important_altered_write(): reset test LID settings fail!\n\r"); |
| 7625 | } |
| 7626 | |
| 7627 | //this test will use LID verno "000" only |
| 7628 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_4_LID, 0, 0) ) |
| 7629 | { |
| 7630 | nvram_ut_trace("[NVUT] normal_boot_important_altered_write(): delete test LID fail!\n\r"); |
| 7631 | } |
| 7632 | |
| 7633 | //reset(create) test LID |
| 7634 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_4_LID); |
| 7635 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 7636 | { |
| 7637 | nvram_ut_trace("[NVUT] normal_boot_important_altered_write(): reset test LID fail!\n\r"); |
| 7638 | return KAL_FALSE; |
| 7639 | } |
| 7640 | |
| 7641 | //alter test LID |
| 7642 | folder_index = nvram_query_folder_index(ldi->category); |
| 7643 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 7644 | nvram_query_file_name(folder_index, nvramname, filename); |
| 7645 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 7646 | if (hFile == FS_FILE_NOT_FOUND) |
| 7647 | { |
| 7648 | nvram_ut_trace("[NVUT] normal_boot_important_altered_write(): can not find test LID!\n\r"); |
| 7649 | return KAL_FALSE; |
| 7650 | } |
| 7651 | else if (hFile <= FS_NO_ERROR) |
| 7652 | { |
| 7653 | nvram_ut_trace("[NVUT] normal_boot_important_altered_write(): open test LID fail!\n\r"); |
| 7654 | return KAL_FALSE; |
| 7655 | } |
| 7656 | |
| 7657 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 7658 | { |
| 7659 | nvram_ut_trace("[NVUT] normal_boot_important_altered_write(): first FS_Seek test LID fail!\n\r"); |
| 7660 | return KAL_FALSE; |
| 7661 | } |
| 7662 | |
| 7663 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 7664 | { |
| 7665 | nvram_ut_trace("[NVUT] normal_boot_important_altered_write(): read test LID fail!\n\r"); |
| 7666 | return KAL_FALSE; |
| 7667 | } |
| 7668 | |
| 7669 | data_buffer[0] += 1; |
| 7670 | data_buffer[1] += 1; |
| 7671 | data_buffer[2] += 1; |
| 7672 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 7673 | { |
| 7674 | nvram_ut_trace("[NVUT] normal_boot_important_altered_write(): FS_Seek test LID fail!\n\r"); |
| 7675 | return KAL_FALSE; |
| 7676 | } |
| 7677 | |
| 7678 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 7679 | { |
| 7680 | nvram_ut_trace("[NVUT] normal_boot_important_altered_write(): write back test LID fail!\n\r"); |
| 7681 | return KAL_FALSE; |
| 7682 | } |
| 7683 | |
| 7684 | if(hFile > FS_NO_ERROR) |
| 7685 | { |
| 7686 | FS_Close(hFile); |
| 7687 | } |
| 7688 | |
| 7689 | //reset SYS LID to default value |
| 7690 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 7691 | { |
| 7692 | nvram_ut_trace("[NVUT] normal_boot_important_altered_write(): reset SYS LID fail!\n\r"); |
| 7693 | return KAL_FALSE; |
| 7694 | } |
| 7695 | |
| 7696 | //call nvram_init() |
| 7697 | nvram_boot_trace = 0; |
| 7698 | nvram_init(); |
| 7699 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 7700 | { |
| 7701 | nvram_ut_trace("[NVUT] normal_boot_important_altered_write(): enter version conflict fail!\n\r"); |
| 7702 | return KAL_FALSE; |
| 7703 | } |
| 7704 | |
| 7705 | //lid access |
| 7706 | nvram_ut_assert_flag = 0; |
| 7707 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_4_LID, |
| 7708 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 7709 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 7710 | { |
| 7711 | nvram_ut_trace("[NVUT] normal_boot_important_altered_write(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 7712 | return KAL_FALSE; |
| 7713 | } |
| 7714 | if(nvram_ut_assert_flag) |
| 7715 | { |
| 7716 | nvram_ut_trace("[NVUT] normal_boot_important_altered_write(): unexpect assert happen!\n\r"); |
| 7717 | return KAL_FALSE; |
| 7718 | } |
| 7719 | #ifdef __NVRAM_LID_CACHE__ |
| 7720 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 7721 | #endif |
| 7722 | return KAL_TRUE; |
| 7723 | |
| 7724 | } |
| 7725 | |
| 7726 | kal_bool normal_boot_important_altered_reset(kal_uint32 flags, void *param) |
| 7727 | { |
| 7728 | nvram_ltable_entry_struct *ldi = NULL; |
| 7729 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 7730 | nvram_folder_enum folder_index; |
| 7731 | NVRAM_FILE_NAME nvramname; |
| 7732 | FS_HANDLE hFile = 0; |
| 7733 | kal_uint32 len; |
| 7734 | #ifdef __NVRAM_LID_CACHE__ |
| 7735 | nvram_cache_reset();//Disable NVRAM Cache |
| 7736 | #endif |
| 7737 | //reset test LIDs to default settings |
| 7738 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_4_LID) ) |
| 7739 | { |
| 7740 | nvram_ut_trace("[NVUT] normal_boot_important_altered_reset(): reset test LID settings fail!\n\r"); |
| 7741 | } |
| 7742 | |
| 7743 | //this test will use LID verno "000" only |
| 7744 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_4_LID, 0, 0) ) |
| 7745 | { |
| 7746 | nvram_ut_trace("[NVUT] normal_boot_important_altered_reset(): delete test LID fail!\n\r"); |
| 7747 | } |
| 7748 | |
| 7749 | //reset(create) test LID |
| 7750 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_4_LID); |
| 7751 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 7752 | { |
| 7753 | nvram_ut_trace("[NVUT] normal_boot_important_altered_reset(): reset test LID fail!\n\r"); |
| 7754 | return KAL_FALSE; |
| 7755 | } |
| 7756 | |
| 7757 | //alter test LID |
| 7758 | folder_index = nvram_query_folder_index(ldi->category); |
| 7759 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 7760 | nvram_query_file_name(folder_index, nvramname, filename); |
| 7761 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 7762 | if (hFile == FS_FILE_NOT_FOUND) |
| 7763 | { |
| 7764 | nvram_ut_trace("[NVUT] normal_boot_important_altered_reset(): can not find test LID!\n\r"); |
| 7765 | return KAL_FALSE; |
| 7766 | } |
| 7767 | else if (hFile <= FS_NO_ERROR) |
| 7768 | { |
| 7769 | nvram_ut_trace("[NVUT] normal_boot_important_altered_reset(): open test LID fail!\n\r"); |
| 7770 | return KAL_FALSE; |
| 7771 | } |
| 7772 | |
| 7773 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 7774 | { |
| 7775 | nvram_ut_trace("[NVUT] normal_boot_important_altered_reset(): first FS_Seek test LID fail!\n\r"); |
| 7776 | return KAL_FALSE; |
| 7777 | } |
| 7778 | |
| 7779 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 7780 | { |
| 7781 | nvram_ut_trace("[NVUT] normal_boot_important_altered_reset(): read test LID fail!\n\r"); |
| 7782 | return KAL_FALSE; |
| 7783 | } |
| 7784 | |
| 7785 | data_buffer[0] += 1; |
| 7786 | data_buffer[1] += 1; |
| 7787 | data_buffer[2] += 1; |
| 7788 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 7789 | { |
| 7790 | nvram_ut_trace("[NVUT] normal_boot_important_altered_reset(): FS_Seek test LID fail!\n\r"); |
| 7791 | return KAL_FALSE; |
| 7792 | } |
| 7793 | |
| 7794 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 7795 | { |
| 7796 | nvram_ut_trace("[NVUT] normal_boot_important_altered_reset(): write back test LID fail!\n\r"); |
| 7797 | return KAL_FALSE; |
| 7798 | } |
| 7799 | |
| 7800 | if(hFile > FS_NO_ERROR) |
| 7801 | { |
| 7802 | FS_Close(hFile); |
| 7803 | } |
| 7804 | |
| 7805 | //reset SYS LID to default value |
| 7806 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 7807 | { |
| 7808 | nvram_ut_trace("[NVUT] normal_boot_important_altered_reset(): reset SYS LID fail!\n\r"); |
| 7809 | return KAL_FALSE; |
| 7810 | } |
| 7811 | |
| 7812 | //call nvram_init() |
| 7813 | nvram_boot_trace = 0; |
| 7814 | nvram_init(); |
| 7815 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 7816 | { |
| 7817 | nvram_ut_trace("[NVUT] normal_boot_important_altered_reset(): enter version conflict fail!\n\r"); |
| 7818 | return KAL_FALSE; |
| 7819 | } |
| 7820 | |
| 7821 | //lid access |
| 7822 | nvram_ut_assert_flag = 0; |
| 7823 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_4_LID, |
| 7824 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 7825 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 7826 | { |
| 7827 | nvram_ut_trace("[NVUT] normal_boot_important_altered_reset(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 7828 | return KAL_FALSE; |
| 7829 | } |
| 7830 | if(nvram_ut_assert_flag) |
| 7831 | { |
| 7832 | nvram_ut_trace("[NVUT] normal_boot_important_altered_reset(): unexpect assert happen!\n\r"); |
| 7833 | return KAL_FALSE; |
| 7834 | } |
| 7835 | #ifdef __NVRAM_LID_CACHE__ |
| 7836 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 7837 | #endif |
| 7838 | return KAL_TRUE; |
| 7839 | |
| 7840 | } |
| 7841 | |
| 7842 | kal_bool normal_boot_importantl1_altered_read(kal_uint32 flags, void *param) |
| 7843 | { |
| 7844 | nvram_ltable_entry_struct *ldi = NULL; |
| 7845 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 7846 | nvram_folder_enum folder_index; |
| 7847 | NVRAM_FILE_NAME nvramname; |
| 7848 | FS_HANDLE hFile = 0; |
| 7849 | kal_uint32 len; |
| 7850 | #ifdef __NVRAM_LID_CACHE__ |
| 7851 | nvram_cache_reset();//Disable NVRAM Cache |
| 7852 | #endif |
| 7853 | //reset test LIDs to default settings |
| 7854 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_5_LID) ) |
| 7855 | { |
| 7856 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_read(): reset test LID settings fail!\n\r"); |
| 7857 | } |
| 7858 | |
| 7859 | //this test will use LID verno "000" only |
| 7860 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_5_LID, 0, 0) ) |
| 7861 | { |
| 7862 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_read(): delete test LID fail!\n\r"); |
| 7863 | } |
| 7864 | |
| 7865 | //reset(create) test LID |
| 7866 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_5_LID); |
| 7867 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 7868 | { |
| 7869 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_read(): reset test LID fail!\n\r"); |
| 7870 | return KAL_FALSE; |
| 7871 | } |
| 7872 | |
| 7873 | //alter test LID |
| 7874 | folder_index = nvram_query_folder_index(ldi->category); |
| 7875 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 7876 | nvram_query_file_name(folder_index, nvramname, filename); |
| 7877 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 7878 | if (hFile == FS_FILE_NOT_FOUND) |
| 7879 | { |
| 7880 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_read(): can not find test LID!\n\r"); |
| 7881 | return KAL_FALSE; |
| 7882 | } |
| 7883 | else if (hFile <= FS_NO_ERROR) |
| 7884 | { |
| 7885 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_read(): open test LID fail!\n\r"); |
| 7886 | return KAL_FALSE; |
| 7887 | } |
| 7888 | |
| 7889 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 7890 | { |
| 7891 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_read(): first FS_Seek test LID fail!\n\r"); |
| 7892 | return KAL_FALSE; |
| 7893 | } |
| 7894 | |
| 7895 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 7896 | { |
| 7897 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_read(): read test LID fail!\n\r"); |
| 7898 | return KAL_FALSE; |
| 7899 | } |
| 7900 | |
| 7901 | data_buffer[0] += 1; |
| 7902 | data_buffer[1] += 1; |
| 7903 | data_buffer[2] += 1; |
| 7904 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 7905 | { |
| 7906 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_read(): FS_Seek test LID fail!\n\r"); |
| 7907 | return KAL_FALSE; |
| 7908 | } |
| 7909 | |
| 7910 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 7911 | { |
| 7912 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_read(): write back test LID fail!\n\r"); |
| 7913 | return KAL_FALSE; |
| 7914 | } |
| 7915 | |
| 7916 | if(hFile > FS_NO_ERROR) |
| 7917 | { |
| 7918 | FS_Close(hFile); |
| 7919 | } |
| 7920 | |
| 7921 | //reset SYS LID to default value |
| 7922 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 7923 | { |
| 7924 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_read(): reset SYS LID fail!\n\r"); |
| 7925 | return KAL_FALSE; |
| 7926 | } |
| 7927 | |
| 7928 | //call nvram_init() |
| 7929 | nvram_boot_trace = 0; |
| 7930 | nvram_init(); |
| 7931 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 7932 | { |
| 7933 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_read(): enter version conflict fail!\n\r"); |
| 7934 | return KAL_FALSE; |
| 7935 | } |
| 7936 | |
| 7937 | //lid access |
| 7938 | nvram_ut_assert_flag = 0; |
| 7939 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_5_LID, |
| 7940 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, 0, 0, 0), |
| 7941 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 7942 | { |
| 7943 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_read(): unexpect read fail happen!\n\r"); |
| 7944 | return KAL_FALSE; |
| 7945 | } |
| 7946 | if(nvram_ut_assert_flag) |
| 7947 | { |
| 7948 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_read(): unexpect assert happen!\n\r"); |
| 7949 | return KAL_FALSE; |
| 7950 | } |
| 7951 | #ifdef __NVRAM_LID_CACHE__ |
| 7952 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 7953 | #endif |
| 7954 | return KAL_TRUE; |
| 7955 | |
| 7956 | } |
| 7957 | |
| 7958 | kal_bool normal_boot_importantl1_altered_write(kal_uint32 flags, void *param) |
| 7959 | { |
| 7960 | nvram_ltable_entry_struct *ldi = NULL; |
| 7961 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 7962 | nvram_folder_enum folder_index; |
| 7963 | NVRAM_FILE_NAME nvramname; |
| 7964 | FS_HANDLE hFile = 0; |
| 7965 | kal_uint32 len; |
| 7966 | #ifdef __NVRAM_LID_CACHE__ |
| 7967 | nvram_cache_reset();//Disable NVRAM Cache |
| 7968 | #endif |
| 7969 | //reset test LIDs to default settings |
| 7970 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_5_LID) ) |
| 7971 | { |
| 7972 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_write(): reset test LID settings fail!\n\r"); |
| 7973 | } |
| 7974 | |
| 7975 | //this test will use LID verno "000" only |
| 7976 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_5_LID, 0, 0) ) |
| 7977 | { |
| 7978 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_write(): delete test LID fail!\n\r"); |
| 7979 | } |
| 7980 | |
| 7981 | //reset(create) test LID |
| 7982 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_5_LID); |
| 7983 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 7984 | { |
| 7985 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_write(): reset test LID fail!\n\r"); |
| 7986 | return KAL_FALSE; |
| 7987 | } |
| 7988 | |
| 7989 | //alter test LID |
| 7990 | folder_index = nvram_query_folder_index(ldi->category); |
| 7991 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 7992 | nvram_query_file_name(folder_index, nvramname, filename); |
| 7993 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 7994 | if (hFile == FS_FILE_NOT_FOUND) |
| 7995 | { |
| 7996 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_write(): can not find test LID!\n\r"); |
| 7997 | return KAL_FALSE; |
| 7998 | } |
| 7999 | else if (hFile <= FS_NO_ERROR) |
| 8000 | { |
| 8001 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_write(): open test LID fail!\n\r"); |
| 8002 | return KAL_FALSE; |
| 8003 | } |
| 8004 | |
| 8005 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 8006 | { |
| 8007 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_write(): first FS_Seek test LID fail!\n\r"); |
| 8008 | return KAL_FALSE; |
| 8009 | } |
| 8010 | |
| 8011 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 8012 | { |
| 8013 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_write(): read test LID fail!\n\r"); |
| 8014 | return KAL_FALSE; |
| 8015 | } |
| 8016 | |
| 8017 | data_buffer[0] += 1; |
| 8018 | data_buffer[1] += 1; |
| 8019 | data_buffer[2] += 1; |
| 8020 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 8021 | { |
| 8022 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_write(): FS_Seek test LID fail!\n\r"); |
| 8023 | return KAL_FALSE; |
| 8024 | } |
| 8025 | |
| 8026 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 8027 | { |
| 8028 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_write(): write back test LID fail!\n\r"); |
| 8029 | return KAL_FALSE; |
| 8030 | } |
| 8031 | |
| 8032 | if(hFile > FS_NO_ERROR) |
| 8033 | { |
| 8034 | FS_Close(hFile); |
| 8035 | } |
| 8036 | |
| 8037 | //reset SYS LID to default value |
| 8038 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 8039 | { |
| 8040 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_write(): reset SYS LID fail!\n\r"); |
| 8041 | return KAL_FALSE; |
| 8042 | } |
| 8043 | |
| 8044 | //call nvram_init() |
| 8045 | nvram_boot_trace = 0; |
| 8046 | nvram_init(); |
| 8047 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 8048 | { |
| 8049 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_write(): enter version conflict fail!\n\r"); |
| 8050 | return KAL_FALSE; |
| 8051 | } |
| 8052 | |
| 8053 | //lid access |
| 8054 | nvram_ut_assert_flag = 0; |
| 8055 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_5_LID, |
| 8056 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 8057 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 8058 | { |
| 8059 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_write(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 8060 | return KAL_FALSE; |
| 8061 | } |
| 8062 | if(nvram_ut_assert_flag) |
| 8063 | { |
| 8064 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_write(): unexpect assert happen!\n\r"); |
| 8065 | return KAL_FALSE; |
| 8066 | } |
| 8067 | #ifdef __NVRAM_LID_CACHE__ |
| 8068 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 8069 | #endif |
| 8070 | return KAL_TRUE; |
| 8071 | |
| 8072 | } |
| 8073 | |
| 8074 | kal_bool normal_boot_importantl1_altered_reset(kal_uint32 flags, void *param) |
| 8075 | { |
| 8076 | nvram_ltable_entry_struct *ldi = NULL; |
| 8077 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 8078 | nvram_folder_enum folder_index; |
| 8079 | NVRAM_FILE_NAME nvramname; |
| 8080 | FS_HANDLE hFile = 0; |
| 8081 | kal_uint32 len; |
| 8082 | #ifdef __NVRAM_LID_CACHE__ |
| 8083 | nvram_cache_reset();//Disable NVRAM Cache |
| 8084 | #endif |
| 8085 | //reset test LIDs to default settings |
| 8086 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_5_LID) ) |
| 8087 | { |
| 8088 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_reset(): reset test LID settings fail!\n\r"); |
| 8089 | } |
| 8090 | |
| 8091 | //this test will use LID verno "000" only |
| 8092 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_5_LID, 0, 0) ) |
| 8093 | { |
| 8094 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_reset(): delete test LID fail!\n\r"); |
| 8095 | } |
| 8096 | |
| 8097 | //reset(create) test LID |
| 8098 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_5_LID); |
| 8099 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 8100 | { |
| 8101 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_reset(): reset test LID fail!\n\r"); |
| 8102 | return KAL_FALSE; |
| 8103 | } |
| 8104 | |
| 8105 | //alter test LID |
| 8106 | folder_index = nvram_query_folder_index(ldi->category); |
| 8107 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 8108 | nvram_query_file_name(folder_index, nvramname, filename); |
| 8109 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 8110 | if (hFile == FS_FILE_NOT_FOUND) |
| 8111 | { |
| 8112 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_reset(): can not find test LID!\n\r"); |
| 8113 | return KAL_FALSE; |
| 8114 | } |
| 8115 | else if (hFile <= FS_NO_ERROR) |
| 8116 | { |
| 8117 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_reset(): open test LID fail!\n\r"); |
| 8118 | return KAL_FALSE; |
| 8119 | } |
| 8120 | |
| 8121 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 8122 | { |
| 8123 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_reset(): first FS_Seek test LID fail!\n\r"); |
| 8124 | return KAL_FALSE; |
| 8125 | } |
| 8126 | |
| 8127 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 8128 | { |
| 8129 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_reset(): read test LID fail!\n\r"); |
| 8130 | return KAL_FALSE; |
| 8131 | } |
| 8132 | |
| 8133 | data_buffer[0] += 1; |
| 8134 | data_buffer[1] += 1; |
| 8135 | data_buffer[2] += 1; |
| 8136 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 8137 | { |
| 8138 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_reset(): FS_Seek test LID fail!\n\r"); |
| 8139 | return KAL_FALSE; |
| 8140 | } |
| 8141 | |
| 8142 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 8143 | { |
| 8144 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_reset(): write back test LID fail!\n\r"); |
| 8145 | return KAL_FALSE; |
| 8146 | } |
| 8147 | |
| 8148 | if(hFile > FS_NO_ERROR) |
| 8149 | { |
| 8150 | FS_Close(hFile); |
| 8151 | } |
| 8152 | |
| 8153 | //reset SYS LID to default value |
| 8154 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 8155 | { |
| 8156 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_reset(): reset SYS LID fail!\n\r"); |
| 8157 | return KAL_FALSE; |
| 8158 | } |
| 8159 | |
| 8160 | //call nvram_init() |
| 8161 | nvram_boot_trace = 0; |
| 8162 | nvram_init(); |
| 8163 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 8164 | { |
| 8165 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_reset(): enter version conflict fail!\n\r"); |
| 8166 | return KAL_FALSE; |
| 8167 | } |
| 8168 | |
| 8169 | //lid access |
| 8170 | nvram_ut_assert_flag = 0; |
| 8171 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_5_LID, |
| 8172 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 8173 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 8174 | { |
| 8175 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_reset(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 8176 | return KAL_FALSE; |
| 8177 | } |
| 8178 | if(nvram_ut_assert_flag) |
| 8179 | { |
| 8180 | nvram_ut_trace("[NVUT] normal_boot_importantl1_altered_reset(): unexpect assert happen!\n\r"); |
| 8181 | return KAL_FALSE; |
| 8182 | } |
| 8183 | #ifdef __NVRAM_LID_CACHE__ |
| 8184 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 8185 | #endif |
| 8186 | return KAL_TRUE; |
| 8187 | |
| 8188 | } |
| 8189 | |
| 8190 | kal_bool normal_boot_importantl4_altered_read(kal_uint32 flags, void *param) |
| 8191 | { |
| 8192 | nvram_ltable_entry_struct *ldi = NULL; |
| 8193 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 8194 | nvram_folder_enum folder_index; |
| 8195 | NVRAM_FILE_NAME nvramname; |
| 8196 | FS_HANDLE hFile = 0; |
| 8197 | kal_uint32 len; |
| 8198 | #ifdef __NVRAM_LID_CACHE__ |
| 8199 | nvram_cache_reset();//Disable NVRAM Cache |
| 8200 | #endif |
| 8201 | //reset test LIDs to default settings |
| 8202 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_6_LID) ) |
| 8203 | { |
| 8204 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_read(): reset test LID settings fail!\n\r"); |
| 8205 | } |
| 8206 | |
| 8207 | //this test will use LID verno "000" only |
| 8208 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_6_LID, 0, 0) ) |
| 8209 | { |
| 8210 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_read(): delete test LID fail!\n\r"); |
| 8211 | } |
| 8212 | |
| 8213 | //reset(create) test LID |
| 8214 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_6_LID); |
| 8215 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 8216 | { |
| 8217 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_read(): reset test LID fail!\n\r"); |
| 8218 | return KAL_FALSE; |
| 8219 | } |
| 8220 | |
| 8221 | //alter test LID |
| 8222 | folder_index = nvram_query_folder_index(ldi->category); |
| 8223 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 8224 | nvram_query_file_name(folder_index, nvramname, filename); |
| 8225 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 8226 | if (hFile == FS_FILE_NOT_FOUND) |
| 8227 | { |
| 8228 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_read(): can not find test LID!\n\r"); |
| 8229 | return KAL_FALSE; |
| 8230 | } |
| 8231 | else if (hFile <= FS_NO_ERROR) |
| 8232 | { |
| 8233 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_read(): open test LID fail!\n\r"); |
| 8234 | return KAL_FALSE; |
| 8235 | } |
| 8236 | |
| 8237 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 8238 | { |
| 8239 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_read(): first FS_Seek test LID fail!\n\r"); |
| 8240 | return KAL_FALSE; |
| 8241 | } |
| 8242 | |
| 8243 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 8244 | { |
| 8245 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_read(): read test LID fail!\n\r"); |
| 8246 | return KAL_FALSE; |
| 8247 | } |
| 8248 | |
| 8249 | data_buffer[0] += 1; |
| 8250 | data_buffer[1] += 1; |
| 8251 | data_buffer[2] += 1; |
| 8252 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 8253 | { |
| 8254 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_read(): FS_Seek test LID fail!\n\r"); |
| 8255 | return KAL_FALSE; |
| 8256 | } |
| 8257 | |
| 8258 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 8259 | { |
| 8260 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_read(): write back test LID fail!\n\r"); |
| 8261 | return KAL_FALSE; |
| 8262 | } |
| 8263 | |
| 8264 | if(hFile > FS_NO_ERROR) |
| 8265 | { |
| 8266 | FS_Close(hFile); |
| 8267 | } |
| 8268 | |
| 8269 | //reset SYS LID to default value |
| 8270 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 8271 | { |
| 8272 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_read(): reset SYS LID fail!\n\r"); |
| 8273 | return KAL_FALSE; |
| 8274 | } |
| 8275 | |
| 8276 | //call nvram_init() |
| 8277 | nvram_boot_trace = 0; |
| 8278 | nvram_init(); |
| 8279 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 8280 | { |
| 8281 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_read(): enter version conflict fail!\n\r"); |
| 8282 | return KAL_FALSE; |
| 8283 | } |
| 8284 | |
| 8285 | //lid access, without FATAL_ASSET will run reset flow |
| 8286 | nvram_ut_assert_flag = 0; |
| 8287 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_6_LID, |
| 8288 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READ, 0, 0, 0), |
| 8289 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 8290 | { |
| 8291 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_read(): read fail happen!\n\r"); |
| 8292 | return KAL_FALSE; |
| 8293 | } |
| 8294 | if(0 != nvram_ut_assert_flag) |
| 8295 | { |
| 8296 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_read(): unexpect assert happen!\n\r"); |
| 8297 | return KAL_FALSE; |
| 8298 | } |
| 8299 | #ifdef __NVRAM_LID_CACHE__ |
| 8300 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 8301 | #endif |
| 8302 | return KAL_TRUE; |
| 8303 | |
| 8304 | } |
| 8305 | |
| 8306 | kal_bool normal_boot_importantl4_altered_write(kal_uint32 flags, void *param) |
| 8307 | { |
| 8308 | nvram_ltable_entry_struct *ldi = NULL; |
| 8309 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 8310 | nvram_folder_enum folder_index; |
| 8311 | NVRAM_FILE_NAME nvramname; |
| 8312 | FS_HANDLE hFile = 0; |
| 8313 | kal_uint32 len; |
| 8314 | #ifdef __NVRAM_LID_CACHE__ |
| 8315 | nvram_cache_reset();//Disable NVRAM Cache |
| 8316 | #endif |
| 8317 | //reset test LIDs to default settings |
| 8318 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_6_LID) ) |
| 8319 | { |
| 8320 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_write(): reset test LID settings fail!\n\r"); |
| 8321 | } |
| 8322 | |
| 8323 | //this test will use LID verno "000" only |
| 8324 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_6_LID, 0, 0) ) |
| 8325 | { |
| 8326 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_write(): delete test LID fail!\n\r"); |
| 8327 | } |
| 8328 | |
| 8329 | //reset(create) test LID |
| 8330 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_6_LID); |
| 8331 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 8332 | { |
| 8333 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_write(): reset test LID fail!\n\r"); |
| 8334 | return KAL_FALSE; |
| 8335 | } |
| 8336 | |
| 8337 | //alter test LID |
| 8338 | folder_index = nvram_query_folder_index(ldi->category); |
| 8339 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 8340 | nvram_query_file_name(folder_index, nvramname, filename); |
| 8341 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 8342 | if (hFile == FS_FILE_NOT_FOUND) |
| 8343 | { |
| 8344 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_write(): can not find test LID!\n\r"); |
| 8345 | return KAL_FALSE; |
| 8346 | } |
| 8347 | else if (hFile <= FS_NO_ERROR) |
| 8348 | { |
| 8349 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_write(): open test LID fail!\n\r"); |
| 8350 | return KAL_FALSE; |
| 8351 | } |
| 8352 | |
| 8353 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 8354 | { |
| 8355 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_write(): first FS_Seek test LID fail!\n\r"); |
| 8356 | return KAL_FALSE; |
| 8357 | } |
| 8358 | |
| 8359 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 8360 | { |
| 8361 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_write(): read test LID fail!\n\r"); |
| 8362 | return KAL_FALSE; |
| 8363 | } |
| 8364 | |
| 8365 | data_buffer[0] += 1; |
| 8366 | data_buffer[1] += 1; |
| 8367 | data_buffer[2] += 1; |
| 8368 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 8369 | { |
| 8370 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_write(): FS_Seek test LID fail!\n\r"); |
| 8371 | return KAL_FALSE; |
| 8372 | } |
| 8373 | |
| 8374 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 8375 | { |
| 8376 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_write(): write back test LID fail!\n\r"); |
| 8377 | return KAL_FALSE; |
| 8378 | } |
| 8379 | |
| 8380 | if(hFile > FS_NO_ERROR) |
| 8381 | { |
| 8382 | FS_Close(hFile); |
| 8383 | } |
| 8384 | |
| 8385 | //reset SYS LID to default value |
| 8386 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 8387 | { |
| 8388 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_write(): reset SYS LID fail!\n\r"); |
| 8389 | return KAL_FALSE; |
| 8390 | } |
| 8391 | |
| 8392 | //call nvram_init() |
| 8393 | nvram_boot_trace = 0; |
| 8394 | nvram_init(); |
| 8395 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 8396 | { |
| 8397 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_write(): enter version conflict fail!\n\r"); |
| 8398 | return KAL_FALSE; |
| 8399 | } |
| 8400 | |
| 8401 | //lid access |
| 8402 | nvram_ut_assert_flag = 0; |
| 8403 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_6_LID, |
| 8404 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, 0, 0, 0), |
| 8405 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 8406 | { |
| 8407 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_write(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 8408 | return KAL_FALSE; |
| 8409 | } |
| 8410 | if(nvram_ut_assert_flag) |
| 8411 | { |
| 8412 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_write(): unexpect assert happen!\n\r"); |
| 8413 | return KAL_FALSE; |
| 8414 | } |
| 8415 | #ifdef __NVRAM_LID_CACHE__ |
| 8416 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 8417 | #endif |
| 8418 | return KAL_TRUE; |
| 8419 | |
| 8420 | } |
| 8421 | |
| 8422 | kal_bool normal_boot_importantl4_altered_reset(kal_uint32 flags, void *param) |
| 8423 | { |
| 8424 | nvram_ltable_entry_struct *ldi = NULL; |
| 8425 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 8426 | nvram_folder_enum folder_index; |
| 8427 | NVRAM_FILE_NAME nvramname; |
| 8428 | FS_HANDLE hFile = 0; |
| 8429 | kal_uint32 len; |
| 8430 | #ifdef __NVRAM_LID_CACHE__ |
| 8431 | nvram_cache_reset();//Disable NVRAM Cache |
| 8432 | #endif |
| 8433 | //reset test LIDs to default settings |
| 8434 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_6_LID) ) |
| 8435 | { |
| 8436 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_reset(): reset test LID settings fail!\n\r"); |
| 8437 | } |
| 8438 | |
| 8439 | //this test will use LID verno "000" only |
| 8440 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_6_LID, 0, 0) ) |
| 8441 | { |
| 8442 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_reset(): delete test LID fail!\n\r"); |
| 8443 | } |
| 8444 | |
| 8445 | //reset(create) test LID |
| 8446 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_6_LID); |
| 8447 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 8448 | { |
| 8449 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_reset(): reset test LID fail!\n\r"); |
| 8450 | return KAL_FALSE; |
| 8451 | } |
| 8452 | |
| 8453 | //alter test LID |
| 8454 | folder_index = nvram_query_folder_index(ldi->category); |
| 8455 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 8456 | nvram_query_file_name(folder_index, nvramname, filename); |
| 8457 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 8458 | if (hFile == FS_FILE_NOT_FOUND) |
| 8459 | { |
| 8460 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_reset(): can not find test LID!\n\r"); |
| 8461 | return KAL_FALSE; |
| 8462 | } |
| 8463 | else if (hFile <= FS_NO_ERROR) |
| 8464 | { |
| 8465 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_reset(): open test LID fail!\n\r"); |
| 8466 | return KAL_FALSE; |
| 8467 | } |
| 8468 | |
| 8469 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 8470 | { |
| 8471 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_reset(): first FS_Seek test LID fail!\n\r"); |
| 8472 | return KAL_FALSE; |
| 8473 | } |
| 8474 | |
| 8475 | if(FS_NO_ERROR > FS_Read(hFile, data_buffer, ldi->size, &len)) |
| 8476 | { |
| 8477 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_reset(): read test LID fail!\n\r"); |
| 8478 | return KAL_FALSE; |
| 8479 | } |
| 8480 | |
| 8481 | data_buffer[0] += 1; |
| 8482 | data_buffer[1] += 1; |
| 8483 | data_buffer[2] += 1; |
| 8484 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 8485 | { |
| 8486 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_reset(): FS_Seek test LID fail!\n\r"); |
| 8487 | return KAL_FALSE; |
| 8488 | } |
| 8489 | |
| 8490 | if(FS_NO_ERROR > FS_Write(hFile, data_buffer, ldi->size, &len)) |
| 8491 | { |
| 8492 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_reset(): write back test LID fail!\n\r"); |
| 8493 | return KAL_FALSE; |
| 8494 | } |
| 8495 | |
| 8496 | if(hFile > FS_NO_ERROR) |
| 8497 | { |
| 8498 | FS_Close(hFile); |
| 8499 | } |
| 8500 | |
| 8501 | //reset SYS LID to default value |
| 8502 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 8503 | { |
| 8504 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_reset(): reset SYS LID fail!\n\r"); |
| 8505 | return KAL_FALSE; |
| 8506 | } |
| 8507 | |
| 8508 | //call nvram_init() |
| 8509 | nvram_boot_trace = 0; |
| 8510 | nvram_init(); |
| 8511 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_COMPATIBLE)) |
| 8512 | { |
| 8513 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_reset(): enter version conflict fail!\n\r"); |
| 8514 | return KAL_FALSE; |
| 8515 | } |
| 8516 | |
| 8517 | //lid access |
| 8518 | nvram_ut_assert_flag = 0; |
| 8519 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_6_LID, |
| 8520 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 8521 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 8522 | { |
| 8523 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_reset(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 8524 | return KAL_FALSE; |
| 8525 | } |
| 8526 | if(nvram_ut_assert_flag) |
| 8527 | { |
| 8528 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_reset(): unexpect assert happen!\n\r"); |
| 8529 | return KAL_FALSE; |
| 8530 | } |
| 8531 | #ifdef __NVRAM_LID_CACHE__ |
| 8532 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 8533 | #endif |
| 8534 | return KAL_TRUE; |
| 8535 | |
| 8536 | } |
| 8537 | |
| 8538 | kal_bool normal_boot_read_syslid_fail(kal_uint32 flags, void *param) |
| 8539 | { |
| 8540 | nvram_ltable_entry_struct *ldi = NULL; |
| 8541 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 8542 | kal_uint8 *default_value; |
| 8543 | nvram_folder_enum folder_index; |
| 8544 | NVRAM_FILE_NAME nvramname; |
| 8545 | kal_uint8 i, temp_result; |
| 8546 | #ifdef __NVRAM_LID_CACHE__ |
| 8547 | nvram_cache_reset();//Disable NVRAM Cache |
| 8548 | #endif |
| 8549 | //reset test LIDs to default settings |
| 8550 | for(i = 0; i < test_lid_number; i++) |
| 8551 | { |
| 8552 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 8553 | { |
| 8554 | nvram_ut_trace("[NVUT] normal_boot_read_syslid_fail(): reset LIDs to default setting fail!\n\r"); |
| 8555 | return KAL_FALSE; |
| 8556 | } |
| 8557 | } |
| 8558 | |
| 8559 | //this test will use LID verno "000" only |
| 8560 | for(i = 0; i < test_lid_number; i++) |
| 8561 | { |
| 8562 | if(!delete_special_version_lid(test_lid_enum[i], 0, 0)) |
| 8563 | { |
| 8564 | nvram_ut_trace("[NVUT] normal_boot_read_syslid_fail(): delete old version LID fail!\n\r"); |
| 8565 | return KAL_FALSE; |
| 8566 | } |
| 8567 | } |
| 8568 | |
| 8569 | //reset(create) test LIDs |
| 8570 | for(i = 0; i < test_lid_number; i++) |
| 8571 | { |
| 8572 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 8573 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 8574 | { |
| 8575 | nvram_ut_trace("[NVUT] normal_boot_read_syslid_fail(): reset test LID fail!\n\r"); |
| 8576 | return KAL_FALSE; |
| 8577 | } |
| 8578 | } |
| 8579 | |
| 8580 | //write test LID with non-default value |
| 8581 | data_buffer[0] = 0x01; |
| 8582 | data_buffer[1] = 0x02; |
| 8583 | data_buffer[2] = 0x03; |
| 8584 | for(i = 0; i < test_lid_number; i++) |
| 8585 | { |
| 8586 | if(!nvram_external_write_data(test_lid_enum[i], 1, (kal_uint8 *)data_buffer, NVRAM_EF_TEST_LID_SIZE)) |
| 8587 | { |
| 8588 | nvram_ut_trace("[NVUT] normal_boot_read_syslid_fail(): write test LID fail!\n\r"); |
| 8589 | return KAL_FALSE; |
| 8590 | } |
| 8591 | } |
| 8592 | |
| 8593 | //delete SYS LID |
| 8594 | nvram_util_get_data_item(&ldi, NVRAM_EF_SW_VERNO_LID); |
| 8595 | folder_index = nvram_query_folder_index(ldi->category); |
| 8596 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 8597 | nvram_query_file_name(folder_index, nvramname, filename); |
| 8598 | FS_Delete(filename); //here do not update bitmap |
| 8599 | if(ldi->attr & NVRAM_ATTR_MULTIPLE) |
| 8600 | { |
| 8601 | nvram_util_make_lid_filename(ldi, nvramname, KAL_FALSE); //B file |
| 8602 | nvram_query_file_name(folder_index, nvramname, filename); |
| 8603 | FS_Delete(filename); |
| 8604 | } |
| 8605 | |
| 8606 | //call nvram_init() |
| 8607 | nvram_boot_trace = 0; |
| 8608 | nvram_init(); |
| 8609 | if(!(nvram_boot_trace & BOOT_TRACE_READ_SYS_LID_FAIL)) |
| 8610 | { |
| 8611 | nvram_ut_trace("[NVUT] normal_boot_read_syslid_fail(): read SYS LID fail not happen!\n\r"); |
| 8612 | return KAL_FALSE; |
| 8613 | } |
| 8614 | |
| 8615 | //lid access |
| 8616 | default_value = (kal_uint8*)get_ctrl_buffer(NVRAM_EF_TEST_LID_SIZE); |
| 8617 | for(i = 0; i < test_lid_number; i++) |
| 8618 | { |
| 8619 | temp_result = nvram_external_read_data(test_lid_enum[i], 1, (kal_uint8 *)cmp_buffer, NVRAM_EF_TEST_LID_SIZE); |
| 8620 | if(!temp_result) |
| 8621 | { |
| 8622 | nvram_ut_trace("[NVUT] normal_boot_read_syslid_fail(): read test LID fail!\n\r"); |
| 8623 | break; |
| 8624 | } |
| 8625 | |
| 8626 | if((NVRAM_EF_NVRAM_TEST_1_LID == test_lid_enum[i]) || |
| 8627 | (NVRAM_EF_NVRAM_TEST_2_LID == test_lid_enum[i]) ) |
| 8628 | { |
| 8629 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 8630 | nvram_get_default_value_to_write(ldi, i, default_value, NVRAM_EF_TEST_LID_SIZE); |
| 8631 | temp_result = !(kal_mem_cmp((kal_char*)default_value, (kal_char*)cmp_buffer, NVRAM_EF_TEST_LID_SIZE)); |
| 8632 | } |
| 8633 | else |
| 8634 | { |
| 8635 | temp_result = !(kal_mem_cmp((kal_char*)data_buffer, (kal_char*)cmp_buffer, NVRAM_EF_TEST_LID_SIZE)); |
| 8636 | } |
| 8637 | |
| 8638 | if(!temp_result) |
| 8639 | { |
| 8640 | nvram_ut_trace("[NVUT] normal_boot_read_syslid_fail(): read back value is not expect!\n\r"); |
| 8641 | break; |
| 8642 | } |
| 8643 | } |
| 8644 | free_ctrl_buffer(default_value); |
| 8645 | |
| 8646 | if(i < test_lid_number) |
| 8647 | { |
| 8648 | nvram_ut_trace("[NVUT] normal_boot_read_syslid_fail(): read back value not as expect!\n\r"); |
| 8649 | return KAL_FALSE; |
| 8650 | } |
| 8651 | #ifdef __NVRAM_LID_CACHE__ |
| 8652 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 8653 | #endif |
| 8654 | return KAL_TRUE; |
| 8655 | |
| 8656 | } |
| 8657 | |
| 8658 | kal_bool normal_boot_file_corrupted_test(nvram_lid_enum LID) |
| 8659 | { |
| 8660 | nvram_ltable_entry_struct *ldi = NULL; |
| 8661 | kal_uint8 *p_buffer = NULL; |
| 8662 | kal_uint8 *p_buffer2 = NULL; |
| 8663 | kal_uint8 i = 0; |
| 8664 | NVRAM_FILE_NAME nvramname; |
| 8665 | WCHAR filename[NVRAM_MAX_PATH_LEN]; |
| 8666 | nvram_folder_enum folder_index; |
| 8667 | FS_HANDLE hFile = 0; |
| 8668 | kal_uint32 len = 0; |
| 8669 | kal_uint32 temp_result = 0; |
| 8670 | |
| 8671 | #ifdef __NVRAM_LID_CACHE__ |
| 8672 | nvram_cache_reset();//Disable NVRAM Cache |
| 8673 | #endif |
| 8674 | |
| 8675 | //reset test LIDs to default settings |
| 8676 | if(!reset_test_lid_default_setting(LID)) |
| 8677 | { |
| 8678 | nvram_ut_trace("[NVUT] ota_boot_user_size_change_read(): reset LIDs to default setting fail!\n\r"); |
| 8679 | return KAL_FALSE; |
| 8680 | } |
| 8681 | nvram_util_get_data_item(&ldi, LID); |
| 8682 | //Get the LID file name |
| 8683 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 8684 | folder_index = nvram_query_folder_index_ex(ldi->category, KAL_TRUE); |
| 8685 | nvram_query_file_name(folder_index, nvramname, filename); |
| 8686 | |
| 8687 | if(ldi->category == NVRAM_CATEGORY_USER) |
| 8688 | { |
| 8689 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 8690 | { |
| 8691 | nvram_ut_trace("[NVUT] normal_boot_importantl4_altered_reset(): reset test LID fail!\n\r"); |
| 8692 | return KAL_FALSE; |
| 8693 | } |
| 8694 | } |
| 8695 | else if((ldi->category & NVRAM_CATEGORY_CALIBRAT)|| (ldi->category & NVRAM_CATEGORY_IMPORTANT)) |
| 8696 | { |
| 8697 | FS_Delete(filename); |
| 8698 | } |
| 8699 | |
| 8700 | p_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 8701 | if(!nvram_external_read_data(LID,1,p_buffer,ldi->size)) |
| 8702 | { |
| 8703 | nvram_ut_trace("[NVUT] %s() %d: LID record[%d] cmpt operations fail @line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 8704 | free_ctrl_buffer(p_buffer); |
| 8705 | return KAL_FALSE; |
| 8706 | } |
| 8707 | // Corrupt the LID file data extendly |
| 8708 | |
| 8709 | hFile = FS_Open(filename,FS_READ_WRITE | FS_CREATE_ALWAYS); |
| 8710 | if (hFile == FS_FILE_NOT_FOUND) |
| 8711 | { |
| 8712 | nvram_ut_trace("[NVUT] normal_boot_file_corrupted_test(): can not find test LID file!\n\r"); |
| 8713 | free_ctrl_buffer(p_buffer); |
| 8714 | return KAL_FALSE; |
| 8715 | } |
| 8716 | else if (hFile <= FS_NO_ERROR) |
| 8717 | { |
| 8718 | nvram_ut_trace("[NVUT] normal_boot_file_corrupted_test(): open test LID file fail!\n\r"); |
| 8719 | free_ctrl_buffer(p_buffer); |
| 8720 | return KAL_FALSE; |
| 8721 | } |
| 8722 | |
| 8723 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 8724 | { |
| 8725 | nvram_ut_trace("[NVUT] normal_boot_file_corrupted_test(): FS_Seek test LID file fail!\n\r"); |
| 8726 | free_ctrl_buffer(p_buffer); |
| 8727 | return KAL_FALSE; |
| 8728 | } |
| 8729 | data_buffer[0]=0xAA; |
| 8730 | data_buffer[1]=0xAA; |
| 8731 | data_buffer[2]=0xAA; |
| 8732 | if(FS_NO_ERROR >FS_Write(hFile,data_buffer,3,&len)) |
| 8733 | { |
| 8734 | nvram_ut_trace("[NVUT] normal_boot_file_corrupted_test(): write test LID file fail!\n\r"); |
| 8735 | free_ctrl_buffer(p_buffer); |
| 8736 | return KAL_FALSE; |
| 8737 | } |
| 8738 | if(hFile > FS_NO_ERROR) |
| 8739 | { |
| 8740 | FS_Close(hFile); |
| 8741 | } |
| 8742 | //Readback the LID file |
| 8743 | #ifdef __NVRAM_LID_CACHE__ |
| 8744 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 8745 | #endif |
| 8746 | p_buffer2 = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 8747 | if(!nvram_external_read_data(LID,1,p_buffer2,ldi->size)) |
| 8748 | { |
| 8749 | nvram_ut_trace("[NVUT] %s() %d: LID record[1] read operations fail @line %d!\n\r",__FUNCTION__,__LINE__); |
| 8750 | free_ctrl_buffer(p_buffer); |
| 8751 | free_ctrl_buffer(p_buffer2); |
| 8752 | return KAL_FALSE; |
| 8753 | } |
| 8754 | temp_result = kal_mem_cmp((kal_char*)p_buffer, (kal_char*)p_buffer2, ldi->size); |
| 8755 | free_ctrl_buffer(p_buffer); |
| 8756 | free_ctrl_buffer(p_buffer2); |
| 8757 | if(temp_result!= 0) |
| 8758 | { |
| 8759 | nvram_ut_trace("[NVUT] %s() %d: LID record[1] compare data fail @line %d!\n\r",__FUNCTION__,__LINE__); |
| 8760 | return KAL_FALSE; |
| 8761 | } |
| 8762 | return KAL_TRUE; |
| 8763 | } |
| 8764 | |
| 8765 | kal_bool normal_boot_user_corrupted_test(kal_uint32 flags, void *param) |
| 8766 | { |
| 8767 | return normal_boot_file_corrupted_test(NVRAM_EF_NVRAM_TEST_1_LID); |
| 8768 | } |
| 8769 | |
| 8770 | kal_bool normal_boot_calibrate_corrupted_test(kal_uint32 flags, void *param) |
| 8771 | { |
| 8772 | return normal_boot_file_corrupted_test(NVRAM_EF_NVRAM_TEST_3_LID); |
| 8773 | } |
| 8774 | |
| 8775 | kal_bool normal_boot_important_corrupted_test(kal_uint32 flags, void *param) |
| 8776 | { |
| 8777 | return normal_boot_file_corrupted_test(NVRAM_EF_NVRAM_TEST_4_LID); |
| 8778 | } |
| 8779 | |
| 8780 | kal_bool normal_boot_important_l4_corrupted_test(kal_uint32 flags, void *param) |
| 8781 | { |
| 8782 | return normal_boot_file_corrupted_test(NVRAM_EF_NVRAM_TEST_6_LID); |
| 8783 | } |
| 8784 | |
| 8785 | kal_bool attr_average_basic_access(kal_uint32 flags, void *param) |
| 8786 | { |
| 8787 | nvram_ltable_entry_struct *ldi = NULL; |
| 8788 | |
| 8789 | //reset test LIDs to default settings |
| 8790 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 8791 | { |
| 8792 | nvram_ut_trace("[NVUT] attr_average_basic_access(): reset test LID settings fail!\n\r"); |
| 8793 | } |
| 8794 | |
| 8795 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 8796 | ldi->attr = NVRAM_ATTR_AVERAGE; |
| 8797 | |
| 8798 | //this test will use LID verno "000" only |
| 8799 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 8800 | { |
| 8801 | nvram_ut_trace("[NVUT] attr_average_basic_access(): delete test LID fail!\n\r"); |
| 8802 | } |
| 8803 | |
| 8804 | //reset test LID to default value |
| 8805 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 8806 | { |
| 8807 | nvram_ut_trace("[NVUT] attr_average_basic_access(): reset test LID fail!\n\r"); |
| 8808 | return KAL_FALSE; |
| 8809 | } |
| 8810 | |
| 8811 | //lid access |
| 8812 | nvram_ut_assert_flag = 0; |
| 8813 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 8814 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 8815 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 8816 | { |
| 8817 | nvram_ut_trace("[NVUT] attr_average_basic_access(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 8818 | return KAL_FALSE; |
| 8819 | } |
| 8820 | if(nvram_ut_assert_flag) |
| 8821 | { |
| 8822 | nvram_ut_trace("[NVUT] attr_average_basic_access(): unexpect assert happen!\n\r"); |
| 8823 | return KAL_FALSE; |
| 8824 | } |
| 8825 | |
| 8826 | return KAL_TRUE; |
| 8827 | |
| 8828 | } |
| 8829 | |
| 8830 | kal_bool attr_multi_default_read_basic_access(kal_uint32 flags, void *param) |
| 8831 | { |
| 8832 | nvram_ltable_entry_struct *ldi = NULL; |
| 8833 | kal_uint8 *p_buffer; |
| 8834 | nvram_read_req_struct *read_req; |
| 8835 | //nvram_read_cnf_struct *nvram_read_cnf; |
| 8836 | ilm_struct current_ilm; |
| 8837 | kal_uint8 i; |
| 8838 | kal_uint8 temp_result; |
| 8839 | |
| 8840 | //reset test LIDs to default settings |
| 8841 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 8842 | { |
| 8843 | nvram_ut_trace("[NVUT] attr_multi_default_read_basic_access(): reset test LID settings fail!\n\r"); |
| 8844 | } |
| 8845 | |
| 8846 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 8847 | //this test will use LID verno "000" only |
| 8848 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 8849 | { |
| 8850 | nvram_ut_trace("[NVUT] attr_multi_default_read_basic_access(): delete test LID fail!\n\r"); |
| 8851 | } |
| 8852 | |
| 8853 | for(i = 0; i < ldi->total_records; i++) |
| 8854 | { |
| 8855 | data_buffer[ldi->size * i] = i+1; //modify data_buffer to special value |
| 8856 | } |
| 8857 | ldi->default_value = (kal_uint8 const*)data_buffer; |
| 8858 | ldi->attr = NVRAM_ATTR_MULTI_DEFAULT | NVRAM_ATTR_MULTIREC_READ; |
| 8859 | |
| 8860 | //reset test LID to default value |
| 8861 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 8862 | { |
| 8863 | nvram_ut_trace("[NVUT] attr_multi_default_read_basic_access(): reset test LID fail!\n\r"); |
| 8864 | return KAL_FALSE; |
| 8865 | } |
| 8866 | |
| 8867 | //lid access |
| 8868 | read_req = (nvram_read_req_struct *)construct_local_para(sizeof(nvram_read_req_struct), TD_CTRL); |
| 8869 | read_req->ref_count = 1; |
| 8870 | read_req->file_idx = ldi->LID; |
| 8871 | read_req->para = 1; |
| 8872 | read_req->rec_amount = ldi->total_records; |
| 8873 | msg_send6(kal_get_active_module_id(), MOD_NVRAM, PS_NVRAM_SAP, MSG_ID_NVRAM_READ_REQ, |
| 8874 | (local_para_struct*)read_req, NULL); |
| 8875 | msg_receive_extq(¤t_ilm); |
| 8876 | p_buffer = (kal_uint8 *)get_peer_buff_pdu(current_ilm.peer_buff_ptr, 0); |
| 8877 | temp_result = kal_mem_cmp(data_buffer, p_buffer, ldi->size * ldi->total_records); |
| 8878 | destroy_ilm(¤t_ilm); |
| 8879 | |
| 8880 | if(0 != temp_result) |
| 8881 | { |
| 8882 | nvram_ut_trace("[NVUT] attr_multi_default_read_basic_access(): read back value not as expect!\n\r"); |
| 8883 | return KAL_FALSE; |
| 8884 | } |
| 8885 | |
| 8886 | nvram_ut_assert_flag = 0; |
| 8887 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 8888 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0, 0), |
| 8889 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 8890 | { |
| 8891 | nvram_ut_trace("[NVUT] attr_multi_default_read_basic_access(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 8892 | return KAL_FALSE; |
| 8893 | } |
| 8894 | if(nvram_ut_assert_flag) |
| 8895 | { |
| 8896 | nvram_ut_trace("[NVUT] attr_multi_default_read_basic_access(): unexpect assert happen!\n\r"); |
| 8897 | return KAL_FALSE; |
| 8898 | } |
| 8899 | |
| 8900 | return KAL_TRUE; |
| 8901 | |
| 8902 | } |
| 8903 | |
| 8904 | kal_bool attr_write_protect_basic_access(kal_uint32 flags, void *param) |
| 8905 | { |
| 8906 | nvram_ltable_entry_struct *ldi = NULL; |
| 8907 | kal_uint8 lock_status; |
| 8908 | |
| 8909 | //reset test LIDs to default settings |
| 8910 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 8911 | { |
| 8912 | nvram_ut_trace("[NVUT] attr_write_protect_basic_access(): reset test LID settings fail!\n\r"); |
| 8913 | } |
| 8914 | |
| 8915 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 8916 | //this test will use LID verno "000" only |
| 8917 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 8918 | { |
| 8919 | nvram_ut_trace("[NVUT] attr_write_protect_basic_access(): delete test LID fail!\n\r"); |
| 8920 | } |
| 8921 | |
| 8922 | //reset test LID to default value |
| 8923 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 8924 | { |
| 8925 | nvram_ut_trace("[NVUT] attr_write_protect_basic_access(): reset test LID fail!\n\r"); |
| 8926 | return KAL_FALSE; |
| 8927 | } |
| 8928 | nvram_get_default_value_to_write(ldi, 1, (kal_uint8 *)data_buffer, ldi->size); |
| 8929 | |
| 8930 | ldi->attr |= NVRAM_ATTR_WRITEPROTECT; |
| 8931 | ldi->default_value = NVRAM_EF_FF_DEFAULT; //modify test LID's default value |
| 8932 | |
| 8933 | //lid read |
| 8934 | if( !nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) ) |
| 8935 | { |
| 8936 | nvram_ut_trace("[NVUT] attr_write_protect_basic_access(): first read test LID fail!\n\r"); |
| 8937 | return KAL_FALSE; |
| 8938 | } |
| 8939 | |
| 8940 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 8941 | { |
| 8942 | nvram_ut_trace("[NVUT] attr_write_protect_basic_access(): first read not as expect!\n\r"); |
| 8943 | return KAL_FALSE; |
| 8944 | } |
| 8945 | //lid write |
| 8946 | lock_status = nvram_ptr->lock; |
| 8947 | nvram_ptr->lock = KAL_TRUE; |
| 8948 | cmp_buffer[0] = 0x30; |
| 8949 | if( KAL_TRUE == nvram_external_write_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) ) |
| 8950 | { |
| 8951 | nvram_ut_trace("[NVUT] attr_write_protect_basic_access(): write fail not happen!\n\r"); |
| 8952 | return KAL_FALSE; |
| 8953 | } |
| 8954 | |
| 8955 | if( !nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) ) |
| 8956 | { |
| 8957 | nvram_ut_trace("[NVUT] attr_write_protect_basic_access(): second read test LID fail!\n\r"); |
| 8958 | return KAL_FALSE; |
| 8959 | } |
| 8960 | |
| 8961 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 8962 | { |
| 8963 | nvram_ut_trace("[NVUT] attr_write_protect_basic_access(): second read not as expect!\n\r"); |
| 8964 | return KAL_FALSE; |
| 8965 | } |
| 8966 | //lid reset |
| 8967 | nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records); |
| 8968 | nvram_get_default_value_to_write(ldi, 1, (kal_uint8 *)data_buffer, ldi->size); //get new default value |
| 8969 | if( !nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) ) |
| 8970 | { |
| 8971 | nvram_ut_trace("[NVUT] attr_write_protect_basic_access(): third read test LID fail!\n\r"); |
| 8972 | return KAL_FALSE; |
| 8973 | } |
| 8974 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 8975 | { |
| 8976 | nvram_ut_trace("[NVUT] attr_write_protect_basic_access(): third read not as expect!\n\r"); |
| 8977 | return KAL_FALSE; |
| 8978 | } |
| 8979 | |
| 8980 | nvram_ptr->lock = lock_status; |
| 8981 | |
| 8982 | return KAL_TRUE; |
| 8983 | |
| 8984 | } |
| 8985 | |
| 8986 | kal_bool attr_multiple_basic_access(kal_uint32 flags, void *param) |
| 8987 | { |
| 8988 | nvram_ltable_entry_struct *ldi = NULL; |
| 8989 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 8990 | nvram_folder_enum folder_index; |
| 8991 | NVRAM_FILE_NAME nvramname; |
| 8992 | |
| 8993 | //reset test LIDs to default settings |
| 8994 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 8995 | { |
| 8996 | nvram_ut_trace("[NVUT] attr_multiple_basic_access(): reset test LID settings fail!\n\r"); |
| 8997 | } |
| 8998 | |
| 8999 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 9000 | ldi->attr = NVRAM_ATTR_MULTIPLE; |
| 9001 | |
| 9002 | //this test will use LID verno "000" only |
| 9003 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 9004 | { |
| 9005 | nvram_ut_trace("[NVUT] attr_multiple_basic_access(): delete test LID fail!\n\r"); |
| 9006 | } |
| 9007 | |
| 9008 | //reset test LID to default value |
| 9009 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 9010 | { |
| 9011 | nvram_ut_trace("[NVUT] attr_multiple_basic_access(): reset test LID fail!\n\r"); |
| 9012 | return KAL_FALSE; |
| 9013 | } |
| 9014 | |
| 9015 | //lid read |
| 9016 | nvram_ut_assert_flag = 0; |
| 9017 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 9018 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, 0, 0, 0), |
| 9019 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 9020 | { |
| 9021 | nvram_ut_trace("[NVUT] attr_multiple_basic_access(): nvram_lid_cmpt_operation() read fail!\n\r"); |
| 9022 | return KAL_FALSE; |
| 9023 | } |
| 9024 | if(nvram_ut_assert_flag) |
| 9025 | { |
| 9026 | nvram_ut_trace("[NVUT] attr_multiple_basic_access(): unexpect read assert happen!\n\r"); |
| 9027 | return KAL_FALSE; |
| 9028 | } |
| 9029 | |
| 9030 | //lid write |
| 9031 | data_buffer[0] = 0x01; |
| 9032 | data_buffer[1] = 0x02; |
| 9033 | data_buffer[2] = 0x03; |
| 9034 | if( !nvram_external_write_data(ldi->LID, 1, (kal_uint8 *)data_buffer, ldi->size) ) |
| 9035 | { |
| 9036 | nvram_ut_trace("[NVUT] attr_multiple_basic_access(): write test LID fail!\n\r"); |
| 9037 | return KAL_FALSE; |
| 9038 | } |
| 9039 | folder_index = nvram_query_folder_index(ldi->category); |
| 9040 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); //A file |
| 9041 | nvram_query_file_name(folder_index, nvramname, filename); |
| 9042 | #ifdef __NVRAM_LID_CACHE__ |
| 9043 | nvram_util_take_mutex(g_nvram_fs_mutex); |
| 9044 | #endif |
| 9045 | FS_Delete(filename); |
| 9046 | #ifdef __NVRAM_LID_CACHE__ |
| 9047 | nvram_util_give_mutex(g_nvram_fs_mutex); |
| 9048 | #endif |
| 9049 | if( !nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) ) |
| 9050 | { |
| 9051 | nvram_ut_trace("[NVUT] attr_multiple_basic_access(): read test LID fail!\n\r"); |
| 9052 | return KAL_FALSE; |
| 9053 | } |
| 9054 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 9055 | { |
| 9056 | nvram_ut_trace("[NVUT] attr_multiple_basic_access(): read back value not as expect!\n\r"); |
| 9057 | return KAL_FALSE; |
| 9058 | } |
| 9059 | |
| 9060 | folder_index = nvram_query_folder_index(ldi->category); |
| 9061 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); //B file |
| 9062 | nvram_query_file_name(folder_index, nvramname, filename); |
| 9063 | #ifdef __NVRAM_LID_CACHE__ |
| 9064 | nvram_util_take_mutex(g_nvram_fs_mutex); |
| 9065 | #endif |
| 9066 | FS_Delete(filename); |
| 9067 | #ifdef __NVRAM_LID_CACHE__ |
| 9068 | nvram_util_give_mutex(g_nvram_fs_mutex); |
| 9069 | #endif |
| 9070 | if( !nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) ) |
| 9071 | { |
| 9072 | nvram_ut_trace("[NVUT] attr_multiple_basic_access(): second read test LID fail!\n\r"); |
| 9073 | return KAL_FALSE; |
| 9074 | } |
| 9075 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 9076 | { |
| 9077 | nvram_ut_trace("[NVUT] attr_multiple_basic_access(): second read back value not as expect!\n\r"); |
| 9078 | return KAL_FALSE; |
| 9079 | } |
| 9080 | |
| 9081 | //lid reset |
| 9082 | nvram_ut_assert_flag = 0; |
| 9083 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 9084 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_RESET, 0, 0, 0), |
| 9085 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 9086 | { |
| 9087 | nvram_ut_trace("[NVUT] attr_multiple_basic_access(): nvram_lid_cmpt_operation() reset fail!\n\r"); |
| 9088 | return KAL_FALSE; |
| 9089 | } |
| 9090 | if(nvram_ut_assert_flag) |
| 9091 | { |
| 9092 | nvram_ut_trace("[NVUT] attr_multiple_basic_access(): unexpect reset assert happen!\n\r"); |
| 9093 | return KAL_FALSE; |
| 9094 | } |
| 9095 | |
| 9096 | return KAL_TRUE; |
| 9097 | |
| 9098 | } |
| 9099 | |
| 9100 | kal_bool attr_confidential_basic_access(kal_uint32 flags, void *param) |
| 9101 | { |
| 9102 | nvram_ltable_entry_struct *ldi = NULL; |
| 9103 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 9104 | nvram_folder_enum folder_index; |
| 9105 | NVRAM_FILE_NAME nvramname; |
| 9106 | FS_HANDLE hFile = 0; |
| 9107 | kal_uint32 len = 0, remainLen = 0; |
| 9108 | #ifdef __NVRAM_LID_CACHE__ |
| 9109 | nvram_cache_reset();//Disable NVRAM Cache as change the LID file size as add the NVRAM_ATTR_CONFIDENTIAL |
| 9110 | #endif |
| 9111 | //reset test LIDs to default settings |
| 9112 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 9113 | { |
| 9114 | nvram_ut_trace("[NVUT] attr_confidential_basic_access(): reset test LID settings fail!\n\r"); |
| 9115 | } |
| 9116 | |
| 9117 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 9118 | ldi->attr |= NVRAM_ATTR_CONFIDENTIAL; |
| 9119 | |
| 9120 | //this test will use LID verno "000" only |
| 9121 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 9122 | { |
| 9123 | nvram_ut_trace("[NVUT] attr_confidential_basic_access(): delete test LID fail!\n\r"); |
| 9124 | } |
| 9125 | |
| 9126 | //reset test LID to default value |
| 9127 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 9128 | { |
| 9129 | nvram_ut_trace("[NVUT] attr_confidential_basic_access(): reset test LID fail!\n\r"); |
| 9130 | return KAL_FALSE; |
| 9131 | } |
| 9132 | |
| 9133 | data_buffer[0] = 0x01; |
| 9134 | data_buffer[1] = 0x02; |
| 9135 | data_buffer[2] = 0x03; |
| 9136 | if( !nvram_external_write_data(ldi->LID, 1, (kal_uint8 *)data_buffer, ldi->size) ) |
| 9137 | { |
| 9138 | nvram_ut_trace("[NVUT] attr_confidential_basic_access(): first write test LID fail!\n\r"); |
| 9139 | return KAL_FALSE; |
| 9140 | } |
| 9141 | |
| 9142 | if( !nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) ) |
| 9143 | { |
| 9144 | nvram_ut_trace("[NVUT] attr_confidential_basic_access(): first read test LID fail!\n\r"); |
| 9145 | return KAL_FALSE; |
| 9146 | } |
| 9147 | |
| 9148 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 9149 | { |
| 9150 | nvram_ut_trace("[NVUT] attr_confidential_basic_access(): read back value not as expect!\n\r"); |
| 9151 | return KAL_FALSE; |
| 9152 | } |
| 9153 | |
| 9154 | folder_index = nvram_query_folder_index(ldi->category); |
| 9155 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 9156 | nvram_query_file_name(folder_index, nvramname, filename); |
| 9157 | |
| 9158 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 9159 | if (hFile == FS_FILE_NOT_FOUND) |
| 9160 | { |
| 9161 | nvram_ut_trace("[NVUT] attr_confidential_basic_access(): can not find test LID!\n\r"); |
| 9162 | return KAL_FALSE; |
| 9163 | } |
| 9164 | else if (hFile <= FS_NO_ERROR) |
| 9165 | { |
| 9166 | nvram_ut_trace("[NVUT] attr_confidential_basic_access(): open test LID fail!\n\r"); |
| 9167 | return KAL_FALSE; |
| 9168 | } |
| 9169 | |
| 9170 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 9171 | { |
| 9172 | nvram_ut_trace("[NVUT] attr_confidential_basic_access(): FS_Seek test LID fail!\n\r"); |
| 9173 | return KAL_FALSE; |
| 9174 | } |
| 9175 | |
| 9176 | remainLen = NVRAM_MSP_ALIGNMENT_REMAINDER(ldi->size + NVRAM_CHKSUM_SIZE); //SW or HW encrpyt need align data |
| 9177 | if(FS_NO_ERROR > FS_Read(hFile, cmp_buffer, ldi->size + NVRAM_CHKSUM_SIZE + remainLen, &len)) |
| 9178 | { |
| 9179 | nvram_ut_trace("[NVUT] attr_confidential_basic_access(): read test LID fail!\n\r"); |
| 9180 | return KAL_FALSE; |
| 9181 | } |
| 9182 | |
| 9183 | if(hFile > FS_NO_ERROR) |
| 9184 | { |
| 9185 | FS_Close(hFile); |
| 9186 | } |
| 9187 | //expect data is changed |
| 9188 | if(0 == kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 9189 | { |
| 9190 | nvram_ut_trace("[NVUT] attr_confidential_basic_access(): after encrypt data not change!\n\r"); |
| 9191 | return KAL_FALSE; |
| 9192 | } |
| 9193 | |
| 9194 | //decrypt |
| 9195 | nvram_AES_decrypt((kal_uint8 *)cmp_buffer, ldi->size + NVRAM_CHKSUM_SIZE + remainLen); |
| 9196 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) //only check data part, ignore cheksum |
| 9197 | { |
| 9198 | nvram_ut_trace("[NVUT] attr_confidential_basic_access(): second read back value not as expect!\n\r"); |
| 9199 | return KAL_FALSE; |
| 9200 | } |
| 9201 | #ifdef __NVRAM_LID_CACHE__ |
| 9202 | mark_nvram_cache_ready(); |
| 9203 | #endif |
| 9204 | return KAL_TRUE; |
| 9205 | |
| 9206 | } |
| 9207 | |
| 9208 | kal_bool attr_msp_basic_access(kal_uint32 flags, void *param) |
| 9209 | { |
| 9210 | #ifdef __NVRAM_BIND_TO_CHIP_CIPHER__ |
| 9211 | nvram_ltable_entry_struct *ldi = NULL; |
| 9212 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 9213 | nvram_folder_enum folder_index; |
| 9214 | NVRAM_FILE_NAME nvramname; |
| 9215 | FS_HANDLE hFile = 0; |
| 9216 | kal_uint32 len = 0, remainLen = 0, section_size = 0; |
| 9217 | |
| 9218 | #ifdef __NVRAM_LID_CACHE__ |
| 9219 | nvram_cache_reset();//Disable NVRAM Cache as change the LID file size as add the NVRAM_ATTR_MSP |
| 9220 | #endif |
| 9221 | |
| 9222 | //reset test LIDs to default settings |
| 9223 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 9224 | { |
| 9225 | nvram_ut_trace("[NVUT] attr_msp_basic_access(): reset test LID settings fail!\n\r"); |
| 9226 | } |
| 9227 | |
| 9228 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 9229 | ldi->attr = NVRAM_ATTR_MSP; |
| 9230 | |
| 9231 | //this test will use LID verno "000" only |
| 9232 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 9233 | { |
| 9234 | nvram_ut_trace("[NVUT] attr_msp_basic_access(): delete test LID fail!\n\r"); |
| 9235 | } |
| 9236 | |
| 9237 | //reset test LID to default value |
| 9238 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 9239 | { |
| 9240 | nvram_ut_trace("[NVUT] attr_msp_basic_access(): reset test LID fail!\n\r"); |
| 9241 | return KAL_FALSE; |
| 9242 | } |
| 9243 | |
| 9244 | data_buffer[0] = 0x01; |
| 9245 | data_buffer[1] = 0x02; |
| 9246 | data_buffer[2] = 0x03; |
| 9247 | if( !nvram_external_write_data(ldi->LID, 1, (kal_uint8 *)data_buffer, ldi->size) ) |
| 9248 | { |
| 9249 | nvram_ut_trace("[NVUT] attr_msp_basic_access(): write test LID fail!\n\r"); |
| 9250 | return KAL_FALSE; |
| 9251 | } |
| 9252 | |
| 9253 | if( !nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) ) |
| 9254 | { |
| 9255 | nvram_ut_trace("[NVUT] attr_msp_basic_access(): read test LID fail!\n\r"); |
| 9256 | return KAL_FALSE; |
| 9257 | } |
| 9258 | |
| 9259 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 9260 | { |
| 9261 | nvram_ut_trace("[NVUT] attr_msp_basic_access(): first read not as expect!\n\r"); |
| 9262 | return KAL_FALSE; |
| 9263 | } |
| 9264 | |
| 9265 | folder_index = nvram_query_folder_index(ldi->category); |
| 9266 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 9267 | nvram_query_file_name(folder_index, nvramname, filename); |
| 9268 | |
| 9269 | hFile = FS_Open((const kal_wchar*)filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_OPEN_SHARED); |
| 9270 | if (hFile == FS_FILE_NOT_FOUND) |
| 9271 | { |
| 9272 | nvram_ut_trace("[NVUT] attr_msp_basic_access(): can not find test LID!\n\r"); |
| 9273 | return KAL_FALSE; |
| 9274 | } |
| 9275 | else if (hFile <= FS_NO_ERROR) |
| 9276 | { |
| 9277 | nvram_ut_trace("[NVUT] attr_msp_basic_access(): open test LID fail!\n\r"); |
| 9278 | return KAL_FALSE; |
| 9279 | } |
| 9280 | |
| 9281 | if(FS_NO_ERROR > FS_Seek(hFile, NVRAM_LDI_HEADER_SIZE, FS_FILE_BEGIN)) //skip LID header |
| 9282 | { |
| 9283 | nvram_ut_trace("[NVUT] attr_msp_basic_access(): FS_Seek test LID fail!\n\r"); |
| 9284 | return KAL_FALSE; |
| 9285 | } |
| 9286 | |
| 9287 | remainLen = NVRAM_MSP_ALIGNMENT_REMAINDER(ldi->size + NVRAM_CHKSUM_SIZE); //SW or HW encrpyt need align data |
| 9288 | section_size = ldi->size + NVRAM_CHKSUM_SIZE + remainLen; |
| 9289 | if(FS_NO_ERROR > FS_Read(hFile, cmp_buffer, section_size, &len)) |
| 9290 | { |
| 9291 | nvram_ut_trace("[NVUT] attr_msp_basic_access(): FS_Read test LID fail!\n\r"); |
| 9292 | return KAL_FALSE; |
| 9293 | } |
| 9294 | |
| 9295 | if(hFile > FS_NO_ERROR) |
| 9296 | { |
| 9297 | FS_Close(hFile); |
| 9298 | } |
| 9299 | //expect after HW encrypt data is changed |
| 9300 | if(0 == kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 9301 | { |
| 9302 | nvram_ut_trace("[NVUT] attr_msp_basic_access(): after encrypt data not change!\n\r"); |
| 9303 | return KAL_FALSE; |
| 9304 | } |
| 9305 | |
| 9306 | //decrypt |
| 9307 | { |
| 9308 | kal_uint8 *working_buffer2 = (kal_uint8*) get_ctrl_buffer(section_size); |
| 9309 | kal_uint8 *working_buffer3 = (kal_uint8*) get_ctrl_buffer(section_size); |
| 9310 | memcpy(working_buffer2, cmp_buffer, section_size); |
| 9311 | do |
| 9312 | { |
| 9313 | //decrypt the cmp_buffer |
| 9314 | SST_Secure_Algo(NVRAM_MSP_DECRYPT, (kal_uint32) (cmp_buffer), section_size, nvram_ptr->secret_key, (kal_uint8 *)cmp_buffer); |
| 9315 | //copy decrypted data from working_buffer to working_buffer3 |
| 9316 | memcpy(working_buffer3, cmp_buffer, section_size); |
| 9317 | //encrypt the working_buffer3 |
| 9318 | SST_Secure_Algo(NVRAM_MSP_ENCRYPT, (kal_uint32)working_buffer3, section_size, nvram_ptr->secret_key, working_buffer3); |
| 9319 | |
| 9320 | //compare the working_buffer2 & working_buffer3 |
| 9321 | if (memcmp(working_buffer2, working_buffer3, section_size) == 0) |
| 9322 | { |
| 9323 | //decrypt PASS |
| 9324 | break; |
| 9325 | } |
| 9326 | else |
| 9327 | { |
| 9328 | //decrypt FAIL, try again |
| 9329 | memcpy(cmp_buffer, working_buffer2, section_size); |
| 9330 | } |
| 9331 | }while(1); |
| 9332 | free_ctrl_buffer(working_buffer2); |
| 9333 | free_ctrl_buffer(working_buffer3); |
| 9334 | } |
| 9335 | |
| 9336 | //after decrypt expect data is same |
| 9337 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 9338 | { |
| 9339 | nvram_ut_trace("[NVUT] attr_msp_basic_access(): second read not as expect!\n\r"); |
| 9340 | return KAL_FALSE; |
| 9341 | } |
| 9342 | #ifdef __NVRAM_LID_CACHE__ |
| 9343 | mark_nvram_cache_ready(); |
| 9344 | #endif |
| 9345 | return KAL_TRUE; |
| 9346 | #else |
| 9347 | |
| 9348 | nvram_ut_trace("[NVUT] attr_msp_basic_access(): HW encrypt is not enable!\n\r"); |
| 9349 | return KAL_TRUE; |
| 9350 | |
| 9351 | #endif |
| 9352 | |
| 9353 | } |
| 9354 | |
| 9355 | kal_bool attr_committed_basic_access(kal_uint32 flags, void *param) |
| 9356 | { |
| 9357 | nvram_ltable_entry_struct *ldi = NULL; |
| 9358 | |
| 9359 | //reset test LIDs to default settings |
| 9360 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 9361 | { |
| 9362 | nvram_ut_trace("[NVUT] attr_committed_basic_access(): reset test LID settings fail!\n\r"); |
| 9363 | } |
| 9364 | |
| 9365 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 9366 | ldi->attr = NVRAM_ATTR_COMMITTED; |
| 9367 | |
| 9368 | //this test will use LID verno "000" only |
| 9369 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 9370 | { |
| 9371 | nvram_ut_trace("[NVUT] attr_committed_basic_access(): delete test LID fail!\n\r"); |
| 9372 | } |
| 9373 | |
| 9374 | //reset test LID to default value |
| 9375 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 9376 | { |
| 9377 | nvram_ut_trace("[NVUT] attr_committed_basic_access(): reset test LID fail!\n\r"); |
| 9378 | return KAL_FALSE; |
| 9379 | } |
| 9380 | |
| 9381 | //lid access |
| 9382 | nvram_ut_assert_flag = 0; |
| 9383 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 9384 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 9385 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 9386 | { |
| 9387 | nvram_ut_trace("[NVUT] attr_committed_basic_access(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 9388 | return KAL_FALSE; |
| 9389 | } |
| 9390 | if(nvram_ut_assert_flag) |
| 9391 | { |
| 9392 | nvram_ut_trace("[NVUT] attr_committed_basic_access(): unexpect assert happen!\n\r"); |
| 9393 | return KAL_FALSE; |
| 9394 | } |
| 9395 | |
| 9396 | return KAL_TRUE; |
| 9397 | |
| 9398 | } |
| 9399 | |
| 9400 | kal_bool attr_ring_basic_access(kal_uint32 flags, void *param) |
| 9401 | { |
| 9402 | nvram_ltable_entry_struct *ldi = NULL; |
| 9403 | nvram_write_req_struct *write_req; |
| 9404 | nvram_write_cnf_struct *nvram_write_cnf; |
| 9405 | kal_uint8 *pdu_write_buffer; |
| 9406 | ilm_struct current_ilm; |
| 9407 | kal_uint8 i; |
| 9408 | kal_uint8 temp_result; |
| 9409 | |
| 9410 | //reset test LIDs to default settings |
| 9411 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 9412 | { |
| 9413 | nvram_ut_trace("[NVUT] attr_ring_basic_access(): reset test LID settings fail!\n\r"); |
| 9414 | } |
| 9415 | |
| 9416 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 9417 | ldi->attr = NVRAM_ATTR_RING; |
| 9418 | ldi->total_records = 3; |
| 9419 | |
| 9420 | //this test will use LID verno "000" only |
| 9421 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 9422 | { |
| 9423 | nvram_ut_trace("[NVUT] attr_ring_basic_access(): delete test LID fail!\n\r"); |
| 9424 | } |
| 9425 | |
| 9426 | //reset test LID to default value |
| 9427 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 9428 | { |
| 9429 | nvram_ut_trace("[NVUT] attr_ring_basic_access(): reset test LID fail!\n\r"); |
| 9430 | return KAL_FALSE; |
| 9431 | } |
| 9432 | |
| 9433 | //write LID |
| 9434 | data_buffer[0] = 0x31; |
| 9435 | data_buffer[1] = 0x32; |
| 9436 | data_buffer[2] = 0x33; |
| 9437 | for(i = 1; i <= ldi->total_records; i++) |
| 9438 | { |
| 9439 | write_req = (nvram_write_req_struct *)construct_local_para(sizeof(nvram_write_req_struct), TD_CTRL); |
| 9440 | pdu_write_buffer = (kal_uint8 *)construct_peer_buff(ldi->size, 0, 0, TD_CTRL); |
| 9441 | kal_mem_cpy(get_peer_buff_pdu((peer_buff_struct*)pdu_write_buffer, 0), data_buffer, ldi->size); |
| 9442 | write_req->ref_count = 1; |
| 9443 | write_req->file_idx = ldi->LID; |
| 9444 | write_req->para = i; |
| 9445 | msg_send6(kal_get_active_module_id(), MOD_NVRAM, PS_NVRAM_SAP, MSG_ID_NVRAM_WRITE_REQ, |
| 9446 | (local_para_struct*)write_req, (peer_buff_struct*)pdu_write_buffer); |
| 9447 | msg_receive_extq(¤t_ilm); |
| 9448 | nvram_write_cnf = (nvram_write_cnf_struct*)current_ilm.local_para_ptr; |
| 9449 | temp_result = nvram_write_cnf->result; |
| 9450 | destroy_ilm(¤t_ilm); |
| 9451 | if(NVRAM_ERRNO_SUCCESS != temp_result) |
| 9452 | { |
| 9453 | break; |
| 9454 | } |
| 9455 | } |
| 9456 | |
| 9457 | if(i <= ldi->total_records) |
| 9458 | { |
| 9459 | nvram_ut_trace("[NVUT] attr_ring_basic_access(): ring write test LID fail!\n\r"); |
| 9460 | return KAL_FALSE; |
| 9461 | } |
| 9462 | |
| 9463 | //check LID value |
| 9464 | for(i = 1; i <= ldi->total_records; i++) |
| 9465 | { |
| 9466 | if( !nvram_external_read_data(ldi->LID, i, (kal_uint8 *)cmp_buffer, ldi->size) ) |
| 9467 | { |
| 9468 | nvram_ut_trace("[NVUT] attr_ring_basic_access(): read test LID fail!\n\r"); |
| 9469 | return KAL_FALSE; |
| 9470 | } |
| 9471 | |
| 9472 | if(1 == i) |
| 9473 | { |
| 9474 | if(cmp_buffer[0] != 0x2) //last write record is stored in cmp_buffer[0] |
| 9475 | { |
| 9476 | nvram_ut_trace("[NVUT] attr_ring_basic_access(): record 1 read back value is not expect!\n\r"); |
| 9477 | return KAL_FALSE; |
| 9478 | } |
| 9479 | } |
| 9480 | else |
| 9481 | { |
| 9482 | if(0 != kal_mem_cmp(cmp_buffer, data_buffer, ldi->size)) //expect same |
| 9483 | { |
| 9484 | nvram_ut_trace("[NVUT] attr_ring_basic_access(): read back value is not expect!\n\r"); |
| 9485 | return KAL_FALSE; |
| 9486 | } |
| 9487 | } |
| 9488 | } |
| 9489 | |
| 9490 | return KAL_TRUE; |
| 9491 | |
| 9492 | } |
| 9493 | |
| 9494 | /* |
| 9495 | Because IMPORTANT/IMPORTANT_L4 access error will cause assert defaultly, so NVRAM_ATTR_FAULT_ASSERT |
| 9496 | is mainly used for some LIDs without IMPORTANT/IMPORTANT_L4 category. So in this case we just test other |
| 9497 | categories with this attribute. |
| 9498 | */ |
| 9499 | kal_bool attr_fault_assert_test(kal_uint32 flags, void *param) |
| 9500 | { |
| 9501 | nvram_ltable_entry_struct *ldi = NULL; |
| 9502 | kal_uint32 category_list[] = { |
| 9503 | NVRAM_CATEGORY_USER, NVRAM_CATEGORY_INTERNAL, |
| 9504 | NVRAM_CATEGORY_CALIBRAT,NVRAM_CATEGORY_IMPORTANT, |
| 9505 | NVRAM_CATEGORY_IMPORTANT_L1,NVRAM_CATEGORY_IMPORTANT_L4, |
| 9506 | }; |
| 9507 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 9508 | nvram_folder_enum folder_index; |
| 9509 | NVRAM_FILE_NAME nvramname; |
| 9510 | kal_uint8 i; |
| 9511 | kal_bool multiple = KAL_FALSE; |
| 9512 | kal_uint32 multiple_ID = 0; |
| 9513 | |
| 9514 | for(i = 0; i < sizeof(category_list)/sizeof(kal_uint32); i++) |
| 9515 | { |
| 9516 | //reset test LIDs to default settings |
| 9517 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 9518 | { |
| 9519 | nvram_ut_trace("[NVUT] attr_fault_assert_test(): reset test LID settings fail!\n\r"); |
| 9520 | } |
| 9521 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 9522 | ldi->category = (nvram_category_enum)(category_list[i]); |
| 9523 | ldi->attr |= NVRAM_ATTR_FAULT_ASSERT; |
| 9524 | ldi->attr &= ~NVRAM_ATTR_MULTIPLE; |
| 9525 | |
| 9526 | if(NVRAM_IS_CATEGORY_IN_BIN_REGION(ldi->category)) |
| 9527 | { |
| 9528 | ldi->fileverno[0]++; //change filename not same with binregion backup file |
| 9529 | } |
| 9530 | |
| 9531 | if (NVRAM_IS_ATTR_MULTIPLE(ldi->attr) || NVRAM_IS_CATEGORY_IMPORTANT_L4(ldi->category)) |
| 9532 | { |
| 9533 | multiple = KAL_TRUE; |
| 9534 | } |
| 9535 | //reset test LID to default value, LID default has GEN_DEFAULT attribute |
| 9536 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 9537 | { |
| 9538 | nvram_ut_trace("[NVUT] attr_fault_assert_test(): reset test LID fail!\n\r"); |
| 9539 | return KAL_FALSE; |
| 9540 | } |
| 9541 | |
| 9542 | #ifdef __NVRAM_LID_CACHE__ |
| 9543 | while((check_lid_all_record_is_undirty_bit(ldi)!= KAL_TRUE)); |
| 9544 | #endif |
| 9545 | |
| 9546 | //delete LID |
| 9547 | #ifdef __NVRAM_LID_CACHE__ |
| 9548 | nvram_util_take_mutex(g_nvram_fs_mutex); |
| 9549 | #endif |
| 9550 | for (multiple_ID = 0; multiple_ID < 2; multiple_ID++) |
| 9551 | { |
| 9552 | folder_index = nvram_query_folder_index(ldi->category); |
| 9553 | |
| 9554 | #if defined(__MTK_TARGET__) && defined(__NVRAM_IMPORTANT_PARTITIONS__) && defined(__CCCIFS_SUPPORT__) |
| 9555 | if (multiple_ID == 1) |
| 9556 | { |
| 9557 | folder_index = nvram_query_folder_index_ex(ldi->category, KAL_FALSE); |
| 9558 | } |
| 9559 | #endif |
| 9560 | |
| 9561 | if (multiple_ID == 0) |
| 9562 | { |
| 9563 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 9564 | }else |
| 9565 | { |
| 9566 | nvram_util_make_lid_filename(ldi, nvramname, KAL_FALSE); |
| 9567 | } |
| 9568 | nvram_query_file_name(folder_index, nvramname, filename); |
| 9569 | FS_Delete(filename); |
| 9570 | if(!multiple) |
| 9571 | { |
| 9572 | break; |
| 9573 | } |
| 9574 | } |
| 9575 | #ifdef __NVRAM_LID_CACHE__ |
| 9576 | nvram_util_give_mutex(g_nvram_fs_mutex); |
| 9577 | #endif |
| 9578 | #ifdef __NVRAM_LID_CACHE__ |
| 9579 | //clean the valid and dirty bit of LID |
| 9580 | if((unmask_lid_all_record_valid_bit(ldi)!= KAL_TRUE) || (unmask_lid_all_record_dirty_bit(ldi)!= KAL_TRUE)) |
| 9581 | { |
| 9582 | nvram_ut_trace("[NVRAM UT] %s() %d: test_lid_enum[%d] valid(%d) and dirty(%d) bit check fail.\n\r",__FUNCTION__,__LINE__,ldi->LID,unmask_lid_all_record_valid_bit(ldi),unmask_lid_all_record_dirty_bit(ldi)); |
| 9583 | return KAL_FALSE; |
| 9584 | } |
| 9585 | #endif |
| 9586 | |
| 9587 | //read access |
| 9588 | nvram_ut_assert_flag = 0; |
| 9589 | if(KAL_TRUE == nvram_external_read_data(ldi->LID, 1, (kal_uint8*)data_buffer, ldi->size)) |
| 9590 | { |
| 9591 | nvram_ut_trace("[NVUT] attr_fault_assert_test(): read fail do not happen!\n\r"); |
| 9592 | return KAL_FALSE; |
| 9593 | } |
| 9594 | if((0 == nvram_ut_assert_flag) && (!NVRAM_IS_CATEGORY_INTERNAL(ldi->category))) //internal category read fail only return fail status |
| 9595 | { |
| 9596 | nvram_ut_trace("[NVUT] attr_fault_assert_test(): read assert do not happen!\n\r"); |
| 9597 | return KAL_FALSE; |
| 9598 | } |
| 9599 | #ifndef __NVRAM_LID_CACHE__ |
| 9600 | //delete LID |
| 9601 | nvram_util_take_mutex(g_nvram_fs_mutex); |
| 9602 | for (multiple_ID = 0; multiple_ID < 2; multiple_ID++) |
| 9603 | { |
| 9604 | folder_index = nvram_query_folder_index(ldi->category); |
| 9605 | |
| 9606 | #if defined(__MTK_TARGET__) && defined(__NVRAM_IMPORTANT_PARTITIONS__) && defined(__CCCIFS_SUPPORT__) |
| 9607 | if (multiple_ID == 1) |
| 9608 | { |
| 9609 | folder_index = nvram_query_folder_index_ex(ldi->category, KAL_FALSE); |
| 9610 | } |
| 9611 | #endif |
| 9612 | |
| 9613 | if (multiple_ID == 0) |
| 9614 | { |
| 9615 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 9616 | }else |
| 9617 | { |
| 9618 | nvram_util_make_lid_filename(ldi, nvramname, KAL_FALSE); |
| 9619 | } |
| 9620 | nvram_query_file_name(folder_index, nvramname, filename); |
| 9621 | FS_Delete(filename); |
| 9622 | if(!multiple) |
| 9623 | { |
| 9624 | break; |
| 9625 | } |
| 9626 | } |
| 9627 | nvram_util_give_mutex(g_nvram_fs_mutex); |
| 9628 | //write access |
| 9629 | nvram_ut_assert_flag = 0; |
| 9630 | if(KAL_TRUE == nvram_external_write_data(ldi->LID, 1, (kal_uint8*)data_buffer, ldi->size)) |
| 9631 | { |
| 9632 | nvram_ut_trace("[NVUT] attr_fault_assert_test(): write fail do not happen!\n\r"); |
| 9633 | return KAL_FALSE; |
| 9634 | } |
| 9635 | if(0 == nvram_ut_assert_flag) |
| 9636 | { |
| 9637 | nvram_ut_trace("[NVUT] attr_fault_assert_test(): write assert do not happen!\n\r"); |
| 9638 | return KAL_FALSE; |
| 9639 | } |
| 9640 | #endif |
| 9641 | |
| 9642 | } |
| 9643 | |
| 9644 | return KAL_TRUE; |
| 9645 | } |
| 9646 | |
| 9647 | |
| 9648 | kal_bool category_user_basic_access(kal_uint32 flags, void *param) |
| 9649 | { |
| 9650 | nvram_ltable_entry_struct *ldi = NULL; |
| 9651 | |
| 9652 | //reset test LIDs to default settings |
| 9653 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 9654 | { |
| 9655 | nvram_ut_trace("[NVUT] category_user_basic_access(): reset test LID settings fail!\n\r"); |
| 9656 | } |
| 9657 | |
| 9658 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 9659 | ldi->category = NVRAM_CATEGORY_USER; |
| 9660 | |
| 9661 | //this test will use LID verno "000" only |
| 9662 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 9663 | { |
| 9664 | nvram_ut_trace("[NVUT] category_user_basic_access(): delete test LID fail!\n\r"); |
| 9665 | } |
| 9666 | |
| 9667 | //reset test LID to default value |
| 9668 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 9669 | { |
| 9670 | nvram_ut_trace("[NVUT] category_user_basic_access(): reset test LID fail!\n\r"); |
| 9671 | return KAL_FALSE; |
| 9672 | } |
| 9673 | |
| 9674 | #ifdef __NVRAM_LID_CACHE__ |
| 9675 | while((check_lid_all_record_is_undirty_bit(ldi)!= KAL_TRUE)); |
| 9676 | #endif |
| 9677 | |
| 9678 | //lid access |
| 9679 | nvram_ut_assert_flag = 0; |
| 9680 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 9681 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 9682 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 9683 | { |
| 9684 | nvram_ut_trace("[NVUT] category_user_basic_access(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 9685 | return KAL_FALSE; |
| 9686 | } |
| 9687 | if(nvram_ut_assert_flag) |
| 9688 | { |
| 9689 | nvram_ut_trace("[NVUT] category_user_basic_access(): unexpect assert happen!\n\r"); |
| 9690 | return KAL_FALSE; |
| 9691 | } |
| 9692 | |
| 9693 | return KAL_TRUE; |
| 9694 | |
| 9695 | } |
| 9696 | |
| 9697 | kal_bool category_internal_basic_access(kal_uint32 flags, void *param) |
| 9698 | { |
| 9699 | nvram_ltable_entry_struct *ldi = NULL; |
| 9700 | |
| 9701 | //reset test LIDs to default settings |
| 9702 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 9703 | { |
| 9704 | nvram_ut_trace("[NVUT] category_internal_basic_access(): reset test LID settings fail!\n\r"); |
| 9705 | } |
| 9706 | |
| 9707 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 9708 | ldi->category = NVRAM_CATEGORY_INTERNAL; |
| 9709 | |
| 9710 | //this test will use LID verno "000" only |
| 9711 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 9712 | { |
| 9713 | nvram_ut_trace("[NVUT] category_internal_basic_access(): delete test LID fail!\n\r"); |
| 9714 | } |
| 9715 | |
| 9716 | //reset test LID to default value |
| 9717 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 9718 | { |
| 9719 | nvram_ut_trace("[NVUT] category_internal_basic_access(): reset test LID fail!\n\r"); |
| 9720 | return KAL_FALSE; |
| 9721 | } |
| 9722 | |
| 9723 | //lid access |
| 9724 | nvram_ut_assert_flag = 0; |
| 9725 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 9726 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 9727 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 9728 | { |
| 9729 | nvram_ut_trace("[NVUT] category_internal_basic_access(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 9730 | return KAL_FALSE; |
| 9731 | } |
| 9732 | if(nvram_ut_assert_flag) |
| 9733 | { |
| 9734 | nvram_ut_trace("[NVUT] category_internal_basic_access(): unexpect assert happen!\n\r"); |
| 9735 | return KAL_FALSE; |
| 9736 | } |
| 9737 | |
| 9738 | return KAL_TRUE; |
| 9739 | |
| 9740 | } |
| 9741 | |
| 9742 | kal_bool category_calibrat_basic_access(kal_uint32 flags, void *param) |
| 9743 | { |
| 9744 | nvram_ltable_entry_struct *ldi = NULL; |
| 9745 | |
| 9746 | //reset test LIDs to default settings |
| 9747 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 9748 | { |
| 9749 | nvram_ut_trace("[NVUT] category_calibrat_basic_access(): reset test LID settings fail!\n\r"); |
| 9750 | } |
| 9751 | |
| 9752 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 9753 | ldi->category = NVRAM_CATEGORY_CALIBRAT; |
| 9754 | |
| 9755 | //this test will use LID verno "000" only |
| 9756 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 9757 | { |
| 9758 | nvram_ut_trace("[NVUT] category_calibrat_basic_access(): delete test LID fail!\n\r"); |
| 9759 | } |
| 9760 | |
| 9761 | //reset test LID to default value |
| 9762 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 9763 | { |
| 9764 | nvram_ut_trace("[NVUT] category_calibrat_basic_access(): reset test LID fail!\n\r"); |
| 9765 | return KAL_FALSE; |
| 9766 | } |
| 9767 | |
| 9768 | //lid access |
| 9769 | nvram_ut_assert_flag = 0; |
| 9770 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 9771 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 9772 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 9773 | { |
| 9774 | nvram_ut_trace("[NVUT] category_calibrat_basic_access(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 9775 | return KAL_FALSE; |
| 9776 | } |
| 9777 | if(nvram_ut_assert_flag) |
| 9778 | { |
| 9779 | nvram_ut_trace("[NVUT] category_calibrat_basic_access(): unexpect assert happen!\n\r"); |
| 9780 | return KAL_FALSE; |
| 9781 | } |
| 9782 | |
| 9783 | return KAL_TRUE; |
| 9784 | |
| 9785 | } |
| 9786 | |
| 9787 | kal_bool category_important_basic_access(kal_uint32 flags, void *param) |
| 9788 | { |
| 9789 | nvram_ltable_entry_struct *ldi = NULL; |
| 9790 | |
| 9791 | //reset test LIDs to default settings |
| 9792 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 9793 | { |
| 9794 | nvram_ut_trace("[NVUT] category_important_basic_access(): reset test LID settings fail!\n\r"); |
| 9795 | } |
| 9796 | |
| 9797 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 9798 | ldi->category = NVRAM_CATEGORY_IMPORTANT; |
| 9799 | |
| 9800 | //this test will use LID verno "000" only |
| 9801 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 9802 | { |
| 9803 | nvram_ut_trace("[NVUT] category_important_basic_access(): delete test LID fail!\n\r"); |
| 9804 | } |
| 9805 | |
| 9806 | //reset test LID to default value |
| 9807 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 9808 | { |
| 9809 | nvram_ut_trace("[NVUT] category_important_basic_access(): reset test LID fail!\n\r"); |
| 9810 | return KAL_FALSE; |
| 9811 | } |
| 9812 | |
| 9813 | //lid access |
| 9814 | nvram_ut_assert_flag = 0; |
| 9815 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 9816 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 9817 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 9818 | { |
| 9819 | nvram_ut_trace("[NVUT] category_important_basic_access(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 9820 | return KAL_FALSE; |
| 9821 | } |
| 9822 | if(nvram_ut_assert_flag) |
| 9823 | { |
| 9824 | nvram_ut_trace("[NVUT] category_important_basic_access(): unexpect assert happen!\n\r"); |
| 9825 | return KAL_FALSE; |
| 9826 | } |
| 9827 | |
| 9828 | return KAL_TRUE; |
| 9829 | |
| 9830 | } |
| 9831 | |
| 9832 | kal_bool category_importantl1_basic_access(kal_uint32 flags, void *param) |
| 9833 | { |
| 9834 | nvram_ltable_entry_struct *ldi = NULL; |
| 9835 | |
| 9836 | //reset test LIDs to default settings |
| 9837 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 9838 | { |
| 9839 | nvram_ut_trace("[NVUT] category_importantl1_basic_access(): reset test LID settings fail!\n\r"); |
| 9840 | } |
| 9841 | |
| 9842 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 9843 | ldi->category = NVRAM_CATEGORY_IMPORTANT_L1; |
| 9844 | |
| 9845 | //this test will use LID verno "000" only |
| 9846 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 9847 | { |
| 9848 | nvram_ut_trace("[NVUT] category_importantl1_basic_access(): delete test LID fail!\n\r"); |
| 9849 | } |
| 9850 | |
| 9851 | //reset test LID to default value |
| 9852 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 9853 | { |
| 9854 | nvram_ut_trace("[NVUT] category_importantl1_basic_access(): reset test LID fail!\n\r"); |
| 9855 | return KAL_FALSE; |
| 9856 | } |
| 9857 | |
| 9858 | //lid access |
| 9859 | nvram_ut_assert_flag = 0; |
| 9860 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 9861 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 9862 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 9863 | { |
| 9864 | nvram_ut_trace("[NVUT] category_importantl1_basic_access(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 9865 | return KAL_FALSE; |
| 9866 | } |
| 9867 | if(nvram_ut_assert_flag) |
| 9868 | { |
| 9869 | nvram_ut_trace("[NVUT] category_importantl1_basic_access(): unexpect assert happen!\n\r"); |
| 9870 | return KAL_FALSE; |
| 9871 | } |
| 9872 | |
| 9873 | return KAL_TRUE; |
| 9874 | |
| 9875 | } |
| 9876 | |
| 9877 | kal_bool category_importantl4_basic_access(kal_uint32 flags, void *param) |
| 9878 | { |
| 9879 | nvram_ltable_entry_struct *ldi = NULL; |
| 9880 | |
| 9881 | //reset test LIDs to default settings |
| 9882 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 9883 | { |
| 9884 | nvram_ut_trace("[NVUT] category_importantl4_basic_access(): reset test LID settings fail!\n\r"); |
| 9885 | } |
| 9886 | |
| 9887 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 9888 | ldi->category = NVRAM_CATEGORY_IMPORTANT_L4; |
| 9889 | |
| 9890 | //this test will use LID verno "000" only |
| 9891 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 9892 | { |
| 9893 | nvram_ut_trace("[NVUT] category_importantl4_basic_access(): delete test LID fail!\n\r"); |
| 9894 | } |
| 9895 | |
| 9896 | //reset test LID to default value |
| 9897 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 9898 | { |
| 9899 | nvram_ut_trace("[NVUT] category_importantl4_basic_access(): reset test LID fail!\n\r"); |
| 9900 | return KAL_FALSE; |
| 9901 | } |
| 9902 | |
| 9903 | //lid access |
| 9904 | nvram_ut_assert_flag = 0; |
| 9905 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 9906 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 9907 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 9908 | { |
| 9909 | nvram_ut_trace("[NVUT] category_importantl4_basic_access(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 9910 | return KAL_FALSE; |
| 9911 | } |
| 9912 | if(nvram_ut_assert_flag) |
| 9913 | { |
| 9914 | nvram_ut_trace("[NVUT] category_importantl4_basic_access(): unexpect assert happen!\n\r"); |
| 9915 | return KAL_FALSE; |
| 9916 | } |
| 9917 | |
| 9918 | return KAL_TRUE; |
| 9919 | |
| 9920 | } |
| 9921 | |
| 9922 | kal_bool func_default_basic_access(kal_uint32 flags, void *param) |
| 9923 | { |
| 9924 | nvram_ltable_entry_struct *ldi = NULL; |
| 9925 | kal_uint8 i; |
| 9926 | |
| 9927 | //reset test LIDs to default settings |
| 9928 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 9929 | { |
| 9930 | nvram_ut_trace("[NVUT] func_default_basic_access(): reset test LID settings fail!\n\r"); |
| 9931 | } |
| 9932 | |
| 9933 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 9934 | ldi->category |= NVRAM_CATEGORY_FUNC_DEFAULT; |
| 9935 | ldi->default_value= (kal_uint8 const*)nvram_ut_get_default_value; |
| 9936 | |
| 9937 | //this test will use LID verno "000" only |
| 9938 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 9939 | { |
| 9940 | nvram_ut_trace("[NVUT] func_default_basic_access(): delete test LID fail!\n\r"); |
| 9941 | } |
| 9942 | |
| 9943 | //reset test LID to default value |
| 9944 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 9945 | { |
| 9946 | nvram_ut_trace("[NVUT] func_default_basic_access(): reset test LID fail!\n\r"); |
| 9947 | return KAL_FALSE; |
| 9948 | } |
| 9949 | |
| 9950 | //check LID value |
| 9951 | nvram_ut_get_default_value(ldi->LID, (kal_uint8 *)data_buffer, ldi->size); |
| 9952 | for(i = 1; i <= ldi->total_records; i++) |
| 9953 | { |
| 9954 | if(!nvram_external_read_data(ldi->LID, i, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 9955 | { |
| 9956 | nvram_ut_trace("[NVUT] func_default_basic_access(): read test LID fail!\n\r"); |
| 9957 | return KAL_FALSE; |
| 9958 | } |
| 9959 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 9960 | { |
| 9961 | nvram_ut_trace("[NVUT] func_default_basic_access(): read back value not expect!\n\r"); |
| 9962 | return KAL_FALSE; |
| 9963 | } |
| 9964 | } |
| 9965 | |
| 9966 | return KAL_TRUE; |
| 9967 | |
| 9968 | } |
| 9969 | |
| 9970 | kal_bool zero_default_basic_access(kal_uint32 flags, void *param) |
| 9971 | { |
| 9972 | nvram_ltable_entry_struct *ldi = NULL; |
| 9973 | kal_uint8 i; |
| 9974 | |
| 9975 | //reset test LIDs to default settings |
| 9976 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 9977 | { |
| 9978 | nvram_ut_trace("[NVUT] zero_default_basic_access(): reset test LID settings fail!\n\r"); |
| 9979 | } |
| 9980 | |
| 9981 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 9982 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 9983 | |
| 9984 | //this test will use LID verno "000" only |
| 9985 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 9986 | { |
| 9987 | nvram_ut_trace("[NVUT] zero_default_basic_access(): delete test LID fail!\n\r"); |
| 9988 | } |
| 9989 | |
| 9990 | //reset test LID to default value |
| 9991 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 9992 | { |
| 9993 | nvram_ut_trace("[NVUT] zero_default_basic_access(): reset test LID fail!\n\r"); |
| 9994 | return KAL_FALSE; |
| 9995 | } |
| 9996 | |
| 9997 | //check LID value |
| 9998 | kal_mem_set(data_buffer, 0x0, ldi->size); |
| 9999 | for(i = 1; i <= ldi->total_records; i++) |
| 10000 | { |
| 10001 | if(!nvram_external_read_data(ldi->LID, i, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 10002 | { |
| 10003 | nvram_ut_trace("[NVUT] zero_default_basic_access(): read test LID fail!\n\r"); |
| 10004 | return KAL_FALSE; |
| 10005 | } |
| 10006 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 10007 | { |
| 10008 | nvram_ut_trace("[NVUT] zero_default_basic_access(): read back value not expect!\n\r"); |
| 10009 | return KAL_FALSE; |
| 10010 | } |
| 10011 | } |
| 10012 | |
| 10013 | return KAL_TRUE; |
| 10014 | |
| 10015 | } |
| 10016 | |
| 10017 | kal_bool ff_default_basic_access(kal_uint32 flags, void *param) |
| 10018 | { |
| 10019 | nvram_ltable_entry_struct *ldi = NULL; |
| 10020 | kal_uint8 i; |
| 10021 | |
| 10022 | //reset test LIDs to default settings |
| 10023 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 10024 | { |
| 10025 | nvram_ut_trace("[NVUT] ff_default_basic_access(): reset test LID settings fail!\n\r"); |
| 10026 | } |
| 10027 | |
| 10028 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 10029 | ldi->default_value = NVRAM_EF_FF_DEFAULT; |
| 10030 | |
| 10031 | //this test will use LID verno "000" only |
| 10032 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 10033 | { |
| 10034 | nvram_ut_trace("[NVUT] ff_default_basic_access(): delete test LID fail!\n\r"); |
| 10035 | } |
| 10036 | |
| 10037 | //reset test LID to default value |
| 10038 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 10039 | { |
| 10040 | nvram_ut_trace("[NVUT] ff_default_basic_access(): reset test LID fail!\n\r"); |
| 10041 | return KAL_FALSE; |
| 10042 | } |
| 10043 | |
| 10044 | //check LID value |
| 10045 | kal_mem_set(data_buffer, 0xFF, ldi->size); |
| 10046 | for(i = 1; i <= ldi->total_records; i++) |
| 10047 | { |
| 10048 | if(!nvram_external_read_data(ldi->LID, i, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 10049 | { |
| 10050 | nvram_ut_trace("[NVUT] ff_default_basic_access(): read test LID fail!\n\r"); |
| 10051 | return KAL_FALSE; |
| 10052 | } |
| 10053 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 10054 | { |
| 10055 | nvram_ut_trace("[NVUT] ff_default_basic_access(): read back value not expect!\n\r"); |
| 10056 | return KAL_FALSE; |
| 10057 | } |
| 10058 | } |
| 10059 | |
| 10060 | return KAL_TRUE; |
| 10061 | |
| 10062 | } |
| 10063 | |
| 10064 | kal_bool table_default_basic_access(kal_uint32 flags, void *param) |
| 10065 | { |
| 10066 | nvram_ltable_entry_struct *ldi = NULL; |
| 10067 | kal_uint8 i; |
| 10068 | |
| 10069 | //reset test LIDs to default settings |
| 10070 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 10071 | { |
| 10072 | nvram_ut_trace("[NVUT] table_default_basic_access(): reset test LID settings fail!\n\r"); |
| 10073 | } |
| 10074 | |
| 10075 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 10076 | kal_mem_set(data_buffer, 0x01, ldi->size); |
| 10077 | ldi->default_value = (kal_uint8 const*)data_buffer; |
| 10078 | |
| 10079 | //this test will use LID verno "000" only |
| 10080 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 10081 | { |
| 10082 | nvram_ut_trace("[NVUT] table_default_basic_access(): delete test LID fail!\n\r"); |
| 10083 | } |
| 10084 | |
| 10085 | //reset test LID to default value |
| 10086 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 10087 | { |
| 10088 | nvram_ut_trace("[NVUT] table_default_basic_access(): reset test LID fail!\n\r"); |
| 10089 | return KAL_FALSE; |
| 10090 | } |
| 10091 | |
| 10092 | //check LID value |
| 10093 | for(i = 1; i <= ldi->total_records; i++) |
| 10094 | { |
| 10095 | if(!nvram_external_read_data(ldi->LID, i, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 10096 | { |
| 10097 | nvram_ut_trace("[NVUT] table_default_basic_access(): read test LID fail!\n\r"); |
| 10098 | return KAL_FALSE; |
| 10099 | } |
| 10100 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 10101 | { |
| 10102 | nvram_ut_trace("[NVUT] table_default_basic_access(): read back value not expcet!\n\r"); |
| 10103 | return KAL_FALSE; |
| 10104 | } |
| 10105 | } |
| 10106 | |
| 10107 | return KAL_TRUE; |
| 10108 | |
| 10109 | } |
| 10110 | |
| 10111 | kal_bool attribute_category_defaultvalue_combine(kal_uint32 flags, void *param) |
| 10112 | { |
| 10113 | nvram_ltable_entry_struct *ldi = NULL; |
| 10114 | nvram_attr_enum attr_bak; |
| 10115 | kal_uint8 i, j, k; |
| 10116 | kal_uint8 lock_status = KAL_FALSE; |
| 10117 | kal_uint32 attribute_list[] = { |
| 10118 | NVRAM_ATTR_AVERAGE, NVRAM_ATTR_COMMITTED, NVRAM_ATTR_CONFIDENTIAL, |
| 10119 | #ifdef __NVRAM_BIND_TO_CHIP_CIPHER__ |
| 10120 | NVRAM_ATTR_MSP, |
| 10121 | #endif |
| 10122 | NVRAM_ATTR_MULTIPLE, NVRAM_ATTR_MULTIREC_READ, |
| 10123 | NVRAM_ATTR_MULTI_DEFAULT, NVRAM_ATTR_OTA_RESET, NVRAM_ATTR_WRITEPROTECT, |
| 10124 | NVRAM_ATTR_GEN_DEFAULT, |
| 10125 | }; |
| 10126 | kal_uint32 category_list[] = { |
| 10127 | NVRAM_CATEGORY_USER, NVRAM_CATEGORY_INTERNAL, NVRAM_CATEGORY_CALIBRAT, |
| 10128 | NVRAM_CATEGORY_IMPORTANT, NVRAM_CATEGORY_IMPORTANT_L1, NVRAM_CATEGORY_IMPORTANT_L4, |
| 10129 | }; |
| 10130 | |
| 10131 | kal_uint8 const* default_value_list[] = { |
| 10132 | (kal_uint8 const*)NVRAM_EF_ZERO_DEFAULT, (kal_uint8 const*)NVRAM_EF_FF_DEFAULT, (kal_uint8 const*)table_default, (kal_uint8 const*)nvram_ut_get_default_value, |
| 10133 | }; |
| 10134 | #ifdef __NVRAM_LID_CACHE__ |
| 10135 | nvram_cache_reset();//Disable NVRAM Cache as change the LID file size as add the NVRAM_ATTR_MSP/NVRAM_ATTR_CONFIDENTIAL |
| 10136 | #endif |
| 10137 | //reset test LIDs to default settings |
| 10138 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 10139 | { |
| 10140 | nvram_ut_trace("[NVUT] attribute_category_defaultvalue_combine(): reset test LID settings fail!\n\r"); |
| 10141 | } |
| 10142 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 10143 | ldi->attr = 0; |
| 10144 | ldi->category = 0; |
| 10145 | ldi->default_value = 0; |
| 10146 | for(i = 0; i < (sizeof(default_value_list)/sizeof(kal_uint8 const*)); i++) //default value loop |
| 10147 | { |
| 10148 | for(j = 0; j < (sizeof(category_list)/sizeof(kal_uint32)); j++) //category loop |
| 10149 | { |
| 10150 | for(k = 0; k < (sizeof(attribute_list)/sizeof(kal_uint32)); k++) //attribute loop |
| 10151 | { |
| 10152 | ldi->default_value = default_value_list[i]; |
| 10153 | ldi->category = category_list[j]; |
| 10154 | ldi->attr |= attribute_list[k]; |
| 10155 | if((kal_uint8 const*)nvram_ut_get_default_value == default_value_list[i]) |
| 10156 | { |
| 10157 | ldi->category |= NVRAM_CATEGORY_FUNC_DEFAULT; |
| 10158 | } |
| 10159 | else |
| 10160 | { |
| 10161 | ldi->category &= ~NVRAM_CATEGORY_FUNC_DEFAULT; |
| 10162 | } |
| 10163 | |
| 10164 | if((kal_uint8 const*)table_default != default_value_list[i]) |
| 10165 | { |
| 10166 | ldi->attr &= ~NVRAM_ATTR_MULTI_DEFAULT; |
| 10167 | } |
| 10168 | |
| 10169 | if(ldi->attr & NVRAM_ATTR_WRITEPROTECT) |
| 10170 | { |
| 10171 | lock_status = nvram_ptr->lock; |
| 10172 | nvram_ptr->lock = KAL_FALSE; |
| 10173 | } |
| 10174 | |
| 10175 | //this test will use LID verno "000" only |
| 10176 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 10177 | { |
| 10178 | nvram_ut_trace("[NVUT] attribute_category_defaultvalue_combine(): delete test LID fail!\n\r"); |
| 10179 | return KAL_FALSE; |
| 10180 | } |
| 10181 | |
| 10182 | attr_bak = ldi->attr; |
| 10183 | |
| 10184 | //reset test LID to default value |
| 10185 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 10186 | { |
| 10187 | nvram_ut_trace("[NVUT] attribute_category_defaultvalue_combine(): reset test LID fail!\n\r"); |
| 10188 | return KAL_FALSE; |
| 10189 | } |
| 10190 | |
| 10191 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 10192 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 10193 | CMPT_OP_WAY_API, 1, NVRAM_EF_TEST_LID_RECORD_TOTAL)) |
| 10194 | { |
| 10195 | nvram_ut_trace("[NVUT] attribute_category_defaultvalue_combine(): nvram_lid_cmpt_operation() fail!\n\r"); |
| 10196 | return KAL_FALSE; |
| 10197 | } |
| 10198 | |
| 10199 | if(attr_bak != ldi->attr) |
| 10200 | { |
| 10201 | nvram_ut_trace("[NVUT] attribute_category_defaultvalue_combine(): attr changed unexpect!\n\r"); |
| 10202 | } |
| 10203 | |
| 10204 | if(ldi->attr & NVRAM_ATTR_WRITEPROTECT) |
| 10205 | { |
| 10206 | nvram_ptr->lock = lock_status; |
| 10207 | } |
| 10208 | } |
| 10209 | ldi->attr = 0; //attr is |= add, so need clear |
| 10210 | kal_sleep_task(kal_milli_secs_to_ticks(10)); |
| 10211 | } |
| 10212 | } |
| 10213 | #ifdef __NVRAM_LID_CACHE__ |
| 10214 | mark_nvram_cache_ready(); |
| 10215 | #endif |
| 10216 | return KAL_TRUE; |
| 10217 | |
| 10218 | } |
| 10219 | |
| 10220 | kal_bool chksum_read_function_basic_test(kal_uint32 flags, void *param) |
| 10221 | { |
| 10222 | nvram_ltable_entry_struct *ldi = NULL; |
| 10223 | kal_uint32 remainLen = 0, file_size; |
| 10224 | NVRAM_FILE_NAME nvramname; |
| 10225 | FS_FileOpenHint Hint; |
| 10226 | nvram_folder_enum folder_index; |
| 10227 | kal_uint8 *chksum_buf = NULL; |
| 10228 | kal_uint16 chksum_2b_buf = 0; |
| 10229 | kal_uint8 chksum_size, chksum_2b_size; |
| 10230 | kal_uint64 const EmptyChksum = 0xCDEF; |
| 10231 | kal_uint8 i; |
| 10232 | nvram_lid_chksum_info lid_chksum_info = {0}; |
| 10233 | kal_bool result = KAL_TRUE; |
| 10234 | |
| 10235 | #ifdef __NVRAM_LID_CACHE__ |
| 10236 | nvram_cache_reset();//Disable NVRAM Cache as change the LID file size as add the NVRAM_ATTR_MSP/NVRAM_ATTR_CONFIDENTIAL |
| 10237 | #endif |
| 10238 | |
| 10239 | //reset test LIDs to default settings |
| 10240 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 10241 | { |
| 10242 | nvram_ut_trace("[NVUT] chksum_read_function_test(): reset test LID settings fail!\n\r"); |
| 10243 | } |
| 10244 | |
| 10245 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 10246 | ldi->total_records = 1; |
| 10247 | ldi->attr |= NVRAM_ATTR_CONFIDENTIAL; |
| 10248 | #ifdef __NVRAM_BIND_TO_CHIP_CIPHER__ |
| 10249 | ldi->attr |= NVRAM_ATTR_MSP; |
| 10250 | #endif |
| 10251 | |
| 10252 | //check 2B checksum API |
| 10253 | //zero default-with not NVRAM_ATTR_GEN_DEFAULT |
| 10254 | //clear test environment |
| 10255 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 10256 | { |
| 10257 | nvram_ut_trace("[NVUT] chksum_read_function_test(): delete test LID fail!\n\r"); |
| 10258 | } |
| 10259 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 10260 | ldi->attr &= (~NVRAM_ATTR_GEN_DEFAULT); //remove GEN_DEFAULT attr |
| 10261 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 10262 | { |
| 10263 | nvram_ut_trace("[NVUT] chksum_read_function_test(): reset test LID fail(ZERO default)!\n\r"); |
| 10264 | return KAL_FALSE; |
| 10265 | } |
| 10266 | kal_mem_set(data_buffer,0,NVRAM_UT_BUFFER_SIZE); |
| 10267 | nvram_get_lid_chksum_algo_info(ldi,&lid_chksum_info,KAL_FALSE,KAL_FALSE); |
| 10268 | chksum_size = lid_chksum_info.algo_info.chksum_algo_length; |
| 10269 | nvram_get_lid_chksum_algo_info(ldi,&lid_chksum_info,KAL_TRUE,KAL_TRUE); |
| 10270 | chksum_2b_size = lid_chksum_info.algo_info.chksum_algo_length; |
| 10271 | |
| 10272 | |
| 10273 | nvram_external_read_chksum(ldi->LID, 1, 1, (kal_uint8 *)data_buffer, chksum_2b_size); |
| 10274 | nvram_external_read_chksum_only(ldi->LID, 1, 1, (kal_uint8 *)cmp_buffer, chksum_2b_size); |
| 10275 | |
| 10276 | if(0!=kal_mem_cmp(data_buffer, &EmptyChksum, sizeof(EmptyChksum)) || 0!=kal_mem_cmp(cmp_buffer, &EmptyChksum, sizeof(EmptyChksum))) |
| 10277 | { |
| 10278 | nvram_ut_trace("[NVUT] chksum_read_function_test(): ZERO default without GEN_DEFAULT checksum mismatch!\n\r"); |
| 10279 | // nvram_ut_trace("[NVUT] chksum2: %x, chksum3: %x.\n\r", chksum2, chksum3); |
| 10280 | return KAL_FALSE; |
| 10281 | } |
| 10282 | |
| 10283 | //zero default-with NVRAM_ATTR_GEN_DEFAULT |
| 10284 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 10285 | { |
| 10286 | nvram_ut_trace("[NVUT] chksum_read_function_test(): delete test LID fail!\n\r"); |
| 10287 | } |
| 10288 | ldi->attr |= NVRAM_ATTR_GEN_DEFAULT; //add GEN_DEFAULT attr |
| 10289 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 10290 | { |
| 10291 | nvram_ut_trace("[NVUT] chksum_read_function_test(): reset test LID fail(ZERO default)!\n\r"); |
| 10292 | return KAL_FALSE; |
| 10293 | } |
| 10294 | nvram_external_read_chksum(ldi->LID, 1, 1, (kal_uint8 *)data_buffer, chksum_2b_size); |
| 10295 | nvram_external_read_chksum_only(ldi->LID, 1, 1, (kal_uint8 *)cmp_buffer, chksum_2b_size); |
| 10296 | |
| 10297 | if(0!=kal_mem_cmp(data_buffer, &EmptyChksum, sizeof(EmptyChksum)) || 0!=kal_mem_cmp(cmp_buffer, &EmptyChksum, sizeof(EmptyChksum))) |
| 10298 | { |
| 10299 | nvram_ut_trace("[NVUT] chksum_read_function_test(): ZERO default without GEN_DEFAULT checksum mismatch!\n\r"); |
| 10300 | // nvram_ut_trace("[NVUT] chksum2: %x, chksum3: %x.\n\r", chksum2, chksum3); |
| 10301 | return KAL_FALSE; |
| 10302 | } |
| 10303 | //non-zero default |
| 10304 | kal_mem_set(data_buffer,0,NVRAM_UT_BUFFER_SIZE); |
| 10305 | data_buffer[0] = 0x12; //modify one data |
| 10306 | ldi->default_value = (const kal_uint8 *)data_buffer; |
| 10307 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 10308 | chksum_buf = (kal_uint8 *)get_ctrl_buffer(chksum_size); |
| 10309 | kal_mem_set(chksum_buf,0,chksum_size); |
| 10310 | for(i = 0; i < 16; i++) //change LID to different size to test(SW/HW encrypt need 16B align) |
| 10311 | { |
| 10312 | if(i%2) //only 0dd time add SW/HW encrypt |
| 10313 | { |
| 10314 | ldi->attr |= NVRAM_ATTR_CONFIDENTIAL; |
| 10315 | #ifdef __NVRAM_BIND_TO_CHIP_CIPHER__ |
| 10316 | ldi->attr |= NVRAM_ATTR_MSP; |
| 10317 | #endif |
| 10318 | } |
| 10319 | else |
| 10320 | { |
| 10321 | ldi->attr &= ~NVRAM_ATTR_CONFIDENTIAL; |
| 10322 | #ifdef __NVRAM_BIND_TO_CHIP_CIPHER__ |
| 10323 | ldi->attr &= ~NVRAM_ATTR_MSP; |
| 10324 | #endif |
| 10325 | } |
| 10326 | kal_mem_set(data_buffer, i, ldi->size); |
| 10327 | kal_mem_set(chksum_buf, 0, chksum_size); |
| 10328 | chksum_2b_buf = nvram_util_caculate_checksum(ldi, (kal_uint8*)data_buffer, ldi->size, chksum_buf); //record size is about 1K, so can generate chksum at one time |
| 10329 | |
| 10330 | //clear test environment |
| 10331 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 10332 | { |
| 10333 | nvram_ut_trace("[NVUT] chksum_read_function_test(): delete test LID fail!\n\r"); |
| 10334 | } |
| 10335 | |
| 10336 | //reset test LID to default value |
| 10337 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 10338 | { |
| 10339 | nvram_ut_trace("[NVUT] chksum_read_function_test(): reset test LID fail!\n\r"); |
| 10340 | result = KAL_FALSE; |
| 10341 | break; |
| 10342 | } |
| 10343 | |
| 10344 | //check LID file size |
| 10345 | if((ldi->attr & NVRAM_ATTR_CONFIDENTIAL) || (ldi->attr & NVRAM_ATTR_MSP)) |
| 10346 | remainLen = NVRAM_MSP_ALIGNMENT_REMAINDER(ldi->size+NVRAM_CHKSUM_SIZE); //SW or HW encrypt align after add checksum |
| 10347 | else |
| 10348 | remainLen = 0; |
| 10349 | |
| 10350 | folder_index = nvram_query_folder_index(ldi->category); |
| 10351 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 10352 | file_size = nvram_drv_fat_get_record_size(nvramname, &Hint, folder_index); |
| 10353 | if(file_size != ((ldi->size+NVRAM_CHKSUM_SIZE+remainLen) * ldi->total_records)) |
| 10354 | { |
| 10355 | nvram_ut_trace("[NVUT] chksum_read_function_test(): file size not match!\n\r"); |
| 10356 | nvram_ut_trace("[NVUT] file size: %d, expect size: %d\n\r", file_size, (ldi->size+NVRAM_CHKSUM_SIZE+remainLen) * ldi->total_records); |
| 10357 | result = KAL_FALSE; |
| 10358 | break; |
| 10359 | } |
| 10360 | |
| 10361 | //check checksum value |
| 10362 | if(!nvram_external_read_chksum(ldi->LID, 1, 1, (kal_uint8 *)cmp_buffer, chksum_2b_size)) |
| 10363 | { |
| 10364 | nvram_ut_trace("[NVUT] chksum_read_function_test(): nvram_external_read_chksum() fail!\n\r"); |
| 10365 | result = KAL_FALSE; |
| 10366 | break; |
| 10367 | } |
| 10368 | if(0!=kal_mem_cmp(&chksum_2b_buf,cmp_buffer,chksum_2b_size)) |
| 10369 | { |
| 10370 | nvram_ut_trace("[NVUT] i: %d.\n\r", i); |
| 10371 | nvram_ut_trace("[NVUT] chksum_read_function_test(): chksum compare fail!\n\r"); |
| 10372 | //nvram_ut_trace("[NVUT] chksum1: %x, chksum2: %x, chksum3: %x.\n\r", chksum1, chksum2, chksum3); |
| 10373 | result = KAL_FALSE; |
| 10374 | break; |
| 10375 | } |
| 10376 | if(!nvram_external_read_chksum_only(ldi->LID, 1, 1, (kal_uint8 *)cmp_buffer, chksum_2b_size)) |
| 10377 | { |
| 10378 | nvram_ut_trace("[NVUT] chksum_read_function_test(): nvram_external_read_chksum_only() fail!\n\r"); |
| 10379 | result = KAL_FALSE; |
| 10380 | break; |
| 10381 | } |
| 10382 | |
| 10383 | if(0!=kal_mem_cmp(&chksum_2b_buf,cmp_buffer,chksum_2b_size)) |
| 10384 | { |
| 10385 | nvram_ut_trace("[NVUT] i: %d.\n\r", i); |
| 10386 | nvram_ut_trace("[NVUT] chksum_read_function_test(): chksum compare fail!\n\r"); |
| 10387 | // nvram_ut_trace("[NVUT] chksum1: %x, chksum2: %x, chksum3: %x.\n\r", chksum1, chksum2, chksum3); |
| 10388 | result = KAL_FALSE; |
| 10389 | break; |
| 10390 | } |
| 10391 | |
| 10392 | //chcek 8B checksum API |
| 10393 | kal_mem_set(chksum_buf,0,chksum_size); |
| 10394 | nvram_util_caculate_checksum(ldi, (kal_uint8 *)data_buffer, ldi->size, chksum_buf); |
| 10395 | if(!nvram_external_read_chksum_8b(ldi->LID, 1, 1, (kal_uint8 *)cmp_buffer, chksum_size)) |
| 10396 | { |
| 10397 | nvram_ut_trace("[NVUT] chksum_read_function_test(): 8B checksum read fail!\n\r"); |
| 10398 | result = KAL_FALSE; |
| 10399 | break; |
| 10400 | } |
| 10401 | if(0 != kal_mem_cmp(chksum_buf, cmp_buffer, chksum_size)) |
| 10402 | { |
| 10403 | nvram_ut_trace("[NVUT] i: %d.\n\r", i); |
| 10404 | nvram_ut_trace("[NVUT] chksum_read_function_test(): 8B checksum not match!\n\r"); |
| 10405 | result = KAL_FALSE; |
| 10406 | break; |
| 10407 | } |
| 10408 | |
| 10409 | ldi->size ++; //modify lid size |
| 10410 | } |
| 10411 | |
| 10412 | free_ctrl_buffer(chksum_buf); |
| 10413 | #ifdef __NVRAM_LID_CACHE__ |
| 10414 | mark_nvram_cache_ready(); |
| 10415 | #endif |
| 10416 | |
| 10417 | return result; |
| 10418 | |
| 10419 | } |
| 10420 | |
| 10421 | kal_bool chksum_multi_read_function_test(kal_uint32 flags, void *param) |
| 10422 | { |
| 10423 | nvram_ltable_entry_struct *ldi = NULL; |
| 10424 | kal_uint8 md5_chksum_comput[NVRAM_CHKSUM_SIZE_2B* NVRAM_EF_TEST_LID_RECORD_TOTAL]; //chksum compute by API |
| 10425 | kal_uint8 md5_chksum_read_2B[NVRAM_CHKSUM_SIZE_2B* NVRAM_EF_TEST_LID_RECORD_TOTAL]; //chksum read by nvram_external_chksum_read() |
| 10426 | kal_uint8 md5_chksum_read_only_2B[NVRAM_CHKSUM_SIZE_2B* NVRAM_EF_TEST_LID_RECORD_TOTAL]; //chksum read by nvram_external_chksum_read_only() |
| 10427 | // kal_uint8 md5_chksum_8B[NVRAM_CHKSUM_SIZE]; |
| 10428 | |
| 10429 | kal_uint8 *chksum_data_buffer=NULL; //md5 chksum 8b |
| 10430 | kal_uint16 *ptr = NULL; |
| 10431 | kal_uint16 md5_chksum_2B = 0; |
| 10432 | kal_uint8 i, chksum_size, chksum_2b_size; |
| 10433 | nvram_lid_chksum_info lid_chksum_info = {0}; |
| 10434 | |
| 10435 | #define CHKSUM_TEST_RECORD_NUM NVRAM_EF_TEST_LID_RECORD_TOTAL/2 //read start_record ~ total_record total CHKSUM_TEST_RECORD_NUM records |
| 10436 | |
| 10437 | #ifdef __NVRAM_LID_CACHE__ |
| 10438 | nvram_cache_reset();//Disable NVRAM Cache as change the LID file size as add the NVRAM_ATTR_MSP/NVRAM_ATTR_CONFIDENTIAL |
| 10439 | #endif |
| 10440 | //NVRAM_EF_ZERO_DEFAULT check (chksum should be 0xCDEF) |
| 10441 | //reset test LIDs to default settings |
| 10442 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 10443 | { |
| 10444 | nvram_ut_trace("[NVUT] chksum_multi_read_function_test(): reset test LID settings fail!\n\r"); |
| 10445 | } |
| 10446 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 10447 | ldi->attr &= ~NVRAM_ATTR_GEN_DEFAULT; //remove GEN_DEFAULT attribute |
| 10448 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 10449 | nvram_get_lid_chksum_algo_info(ldi,&lid_chksum_info,KAL_FALSE,KAL_FALSE); |
| 10450 | chksum_size = lid_chksum_info.algo_info.chksum_algo_length; |
| 10451 | // chksum 2b info |
| 10452 | nvram_get_lid_chksum_algo_info(ldi,&lid_chksum_info,KAL_TRUE,KAL_TRUE); |
| 10453 | chksum_2b_size = lid_chksum_info.algo_info.chksum_algo_length; |
| 10454 | |
| 10455 | //delete related version LID |
| 10456 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 10457 | { |
| 10458 | nvram_ut_trace("[NVUT] chksum_multi_read_function_test(): delete test LID fail!\n\r"); |
| 10459 | } |
| 10460 | |
| 10461 | ptr = (kal_uint16 *)md5_chksum_comput; //fill buffer with 0xCDEF |
| 10462 | for(i = 0; i < CHKSUM_TEST_RECORD_NUM; i++) |
| 10463 | ptr[i] = 0xCDEF; |
| 10464 | |
| 10465 | kal_mem_set(md5_chksum_read_2B, 0, sizeof(md5_chksum_read_2B)); |
| 10466 | kal_mem_set(md5_chksum_read_only_2B, 0, sizeof(md5_chksum_read_only_2B)); |
| 10467 | nvram_external_read_chksum(ldi->LID, ldi->total_records-CHKSUM_TEST_RECORD_NUM+1, CHKSUM_TEST_RECORD_NUM, (kal_uint8 *)(md5_chksum_read_2B), sizeof(md5_chksum_read_2B)); |
| 10468 | nvram_external_read_chksum_only(ldi->LID, ldi->total_records-CHKSUM_TEST_RECORD_NUM+1, CHKSUM_TEST_RECORD_NUM, (kal_uint8 *)(md5_chksum_read_only_2B), sizeof(md5_chksum_read_only_2B)); |
| 10469 | |
| 10470 | if(0 != kal_mem_cmp(md5_chksum_comput, md5_chksum_read_2B, NVRAM_CHKSUM_SIZE_2B*CHKSUM_TEST_RECORD_NUM) || |
| 10471 | 0 != kal_mem_cmp(md5_chksum_comput, md5_chksum_read_only_2B, NVRAM_CHKSUM_SIZE_2B*CHKSUM_TEST_RECORD_NUM)) |
| 10472 | { |
| 10473 | nvram_ut_trace("[NVUT] chksum_multi_read_function_test(): zero default chksum check fail!\n\r"); |
| 10474 | for(i = 0; i < NVRAM_CHKSUM_SIZE_2B* CHKSUM_TEST_RECORD_NUM; i++) |
| 10475 | { |
| 10476 | nvram_ut_trace("[NVUT] cksum_compute[%d]: %x, chksum_read[%d]: %x, chksum_read_only[%d]: %x.\n\r", |
| 10477 | i, md5_chksum_comput[i], i, md5_chksum_read_2B[i], i, md5_chksum_read_only_2B[i]); |
| 10478 | } |
| 10479 | return KAL_FALSE; |
| 10480 | } |
| 10481 | |
| 10482 | //non-zero(with encrypt) chksum check |
| 10483 | ldi->attr |= NVRAM_ATTR_CONFIDENTIAL; |
| 10484 | #ifdef __NVRAM_BIND_TO_CHIP_CIPHER__ |
| 10485 | ldi->attr |= NVRAM_ATTR_MSP; |
| 10486 | #endif |
| 10487 | //delete related version LID |
| 10488 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 10489 | { |
| 10490 | nvram_ut_trace("[NVUT] chksum_multi_read_function_test(): delete test LID fail!\n\r"); |
| 10491 | } |
| 10492 | ptr = (kal_uint16 *)md5_chksum_comput; |
| 10493 | |
| 10494 | chksum_data_buffer = (kal_uint8 *)get_ctrl_buffer(chksum_size); |
| 10495 | kal_mem_set(chksum_data_buffer, 0, sizeof(chksum_size)); |
| 10496 | |
| 10497 | for(i = NVRAM_EF_TEST_LID_RECORD_TOTAL-CHKSUM_TEST_RECORD_NUM+1; i <= NVRAM_EF_TEST_LID_RECORD_TOTAL; i++) |
| 10498 | { |
| 10499 | data_buffer[i] = i; |
| 10500 | kal_mem_set(chksum_data_buffer, 0, chksum_size); |
| 10501 | md5_chksum_2B = nvram_util_caculate_checksum(ldi, (kal_uint8*)data_buffer, ldi->size, chksum_data_buffer); |
| 10502 | ptr[i-(NVRAM_EF_TEST_LID_RECORD_TOTAL-CHKSUM_TEST_RECORD_NUM+1)] = md5_chksum_2B; |
| 10503 | if(!nvram_external_write_data(ldi->LID, i, (kal_uint8 *)data_buffer, ldi->size)) |
| 10504 | { |
| 10505 | nvram_ut_trace("[NVUT] chksum_multi_read_function_test(): write test LID fail!\n\r"); |
| 10506 | free_ctrl_buffer(chksum_data_buffer); |
| 10507 | return KAL_FALSE; |
| 10508 | } |
| 10509 | } |
| 10510 | |
| 10511 | kal_mem_set(md5_chksum_read_2B, 0, sizeof(md5_chksum_read_2B)); |
| 10512 | kal_mem_set(md5_chksum_read_only_2B, 0, sizeof(md5_chksum_read_only_2B)); |
| 10513 | nvram_external_read_chksum(ldi->LID, NVRAM_EF_TEST_LID_RECORD_TOTAL-CHKSUM_TEST_RECORD_NUM+1, CHKSUM_TEST_RECORD_NUM, (kal_uint8 *)(md5_chksum_read_2B), sizeof(md5_chksum_read_2B)); |
| 10514 | nvram_external_read_chksum_only(ldi->LID, NVRAM_EF_TEST_LID_RECORD_TOTAL-CHKSUM_TEST_RECORD_NUM+1, CHKSUM_TEST_RECORD_NUM, (kal_uint8 *)(md5_chksum_read_only_2B), sizeof(md5_chksum_read_only_2B)); |
| 10515 | |
| 10516 | if(0 != kal_mem_cmp(md5_chksum_comput, md5_chksum_read_2B, NVRAM_CHKSUM_SIZE_2B*CHKSUM_TEST_RECORD_NUM) || |
| 10517 | 0 != kal_mem_cmp(md5_chksum_comput, md5_chksum_read_only_2B, NVRAM_CHKSUM_SIZE_2B*CHKSUM_TEST_RECORD_NUM)) |
| 10518 | { |
| 10519 | nvram_ut_trace("[NVUT] chksum_multi_read_function_test(): non-zero with encrypt chksum check fail!\n\r"); |
| 10520 | for(i = 0; i < NVRAM_CHKSUM_SIZE_2B*CHKSUM_TEST_RECORD_NUM; i++) |
| 10521 | { |
| 10522 | nvram_ut_trace("[NVUT] cksum_compute[%d]: %x, chksum_read[%d]: %x, chksum_read_only[%d]: %x.\n\r", |
| 10523 | i, md5_chksum_comput[i], i, md5_chksum_read_2B[i], i, md5_chksum_read_only_2B[i]); |
| 10524 | } |
| 10525 | free_ctrl_buffer(chksum_data_buffer); |
| 10526 | return KAL_FALSE; |
| 10527 | } |
| 10528 | |
| 10529 | //non-zero(without encrypt) chksum check |
| 10530 | ldi->attr &= ~NVRAM_ATTR_CONFIDENTIAL; |
| 10531 | #ifdef __NVRAM_BIND_TO_CHIP_CIPHER__ |
| 10532 | ldi->attr &= ~NVRAM_ATTR_MSP; |
| 10533 | #endif |
| 10534 | //delete related version LID |
| 10535 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 10536 | { |
| 10537 | nvram_ut_trace("[NVUT] chksum_multi_read_function_test(): delete test LID fail!\n\r"); |
| 10538 | } |
| 10539 | ptr = (kal_uint16 *)md5_chksum_comput; |
| 10540 | for(i = NVRAM_EF_TEST_LID_RECORD_TOTAL-CHKSUM_TEST_RECORD_NUM+1; i <= NVRAM_EF_TEST_LID_RECORD_TOTAL; i++) |
| 10541 | { |
| 10542 | data_buffer[i] = i; |
| 10543 | kal_mem_set(chksum_data_buffer, 0, chksum_size); |
| 10544 | md5_chksum_2B = nvram_util_caculate_checksum(ldi, (const kal_uint8*)data_buffer, ldi->size, chksum_data_buffer); |
| 10545 | ptr[i-(NVRAM_EF_TEST_LID_RECORD_TOTAL-CHKSUM_TEST_RECORD_NUM+1)] = md5_chksum_2B; |
| 10546 | if(!nvram_external_write_data(ldi->LID, i, (kal_uint8 *)data_buffer, ldi->size)) |
| 10547 | { |
| 10548 | nvram_ut_trace("[NVUT] chksum_multi_read_function_test(): write test LID fail!\n\r"); |
| 10549 | free_ctrl_buffer(chksum_data_buffer); |
| 10550 | return KAL_FALSE; |
| 10551 | } |
| 10552 | } |
| 10553 | |
| 10554 | nvram_external_read_chksum(ldi->LID, NVRAM_EF_TEST_LID_RECORD_TOTAL-CHKSUM_TEST_RECORD_NUM+1, CHKSUM_TEST_RECORD_NUM, (kal_uint8 *)(md5_chksum_read_2B), sizeof(md5_chksum_read_2B)); |
| 10555 | nvram_external_read_chksum_only(ldi->LID, NVRAM_EF_TEST_LID_RECORD_TOTAL-CHKSUM_TEST_RECORD_NUM+1, CHKSUM_TEST_RECORD_NUM, (kal_uint8 *)(md5_chksum_read_only_2B), sizeof(md5_chksum_read_only_2B)); |
| 10556 | |
| 10557 | if(0 != kal_mem_cmp(md5_chksum_comput, md5_chksum_read_2B, NVRAM_CHKSUM_SIZE_2B*CHKSUM_TEST_RECORD_NUM) || |
| 10558 | 0 != kal_mem_cmp(md5_chksum_comput, md5_chksum_read_only_2B, NVRAM_CHKSUM_SIZE_2B*CHKSUM_TEST_RECORD_NUM)) |
| 10559 | { |
| 10560 | nvram_ut_trace("[NVUT] chksum_multi_read_function_test(): non-zero chksum check fail!\n\r"); |
| 10561 | for(i = 0; i < NVRAM_CHKSUM_SIZE_2B*CHKSUM_TEST_RECORD_NUM; i++) |
| 10562 | { |
| 10563 | nvram_ut_trace("[NVUT] cksum_compute[%d]: %x, chksum_read[%d]: %x, chksum_read_only[%d]: %x.\n\r", |
| 10564 | i, md5_chksum_comput[i], i, md5_chksum_read_2B[i], i, md5_chksum_read_only_2B[i]); |
| 10565 | } |
| 10566 | free_ctrl_buffer(chksum_data_buffer); |
| 10567 | return KAL_FALSE; |
| 10568 | } |
| 10569 | |
| 10570 | free_ctrl_buffer(chksum_data_buffer); |
| 10571 | chksum_data_buffer = NULL; |
| 10572 | //integrated checksum check |
| 10573 | //reset test LIDs to default settings |
| 10574 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_8_LID) ) |
| 10575 | { |
| 10576 | nvram_ut_trace("[NVUT] chksum_multi_read_function_test(): reset test 8_LID settings fail!\n\r"); |
| 10577 | } |
| 10578 | nvram_external_reset_data(NVRAM_EF_NVRAM_TEST_8_LID, 1, NVRAM_EF_TEST_8_LID_RECORD_TOTAL); |
| 10579 | //read checksum check |
| 10580 | kal_mem_set(data_buffer, 0x55, NVRAM_EF_TEST_8_LID_SIZE); |
| 10581 | nvram_external_write_data(NVRAM_EF_NVRAM_TEST_8_LID, 2, (kal_uint8 *)data_buffer, NVRAM_EF_TEST_8_LID_SIZE); |
| 10582 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_8_LID); |
| 10583 | nvram_external_read_chksum(ldi->LID, 1, NVRAM_EF_TEST_8_LID_RECORD_TOTAL, (kal_uint8 *)(md5_chksum_read_2B), sizeof(md5_chksum_read_2B)); |
| 10584 | nvram_external_read_chksum_only(ldi->LID, 1, NVRAM_EF_TEST_8_LID_RECORD_TOTAL, (kal_uint8 *)(md5_chksum_read_only_2B), sizeof(md5_chksum_read_only_2B)); |
| 10585 | if(0 != kal_mem_cmp(md5_chksum_read_2B, md5_chksum_read_only_2B, NVRAM_CHKSUM_SIZE_2B*NVRAM_EF_TEST_8_LID_RECORD_TOTAL)) |
| 10586 | { |
| 10587 | nvram_ut_trace("[NVUT] chksum_multi_read_function_test(): integrated chksum check fail!\n\r"); |
| 10588 | for(i = 0; i < NVRAM_CHKSUM_SIZE_2B*NVRAM_EF_TEST_8_LID_RECORD_TOTAL; i++) |
| 10589 | { |
| 10590 | nvram_ut_trace("[NVUT] cksum_compute[%d]: %x, chksum_read[%d]: %x, chksum_read_only[%d]: %x.\n\r", |
| 10591 | i, md5_chksum_comput[i], i, md5_chksum_read_2B[i], i, md5_chksum_read_only_2B[i]); |
| 10592 | } |
| 10593 | return KAL_FALSE; |
| 10594 | } |
| 10595 | //read checksum 8B check |
| 10596 | do{ |
| 10597 | |
| 10598 | nvram_get_lid_chksum_algo_info(ldi, &lid_chksum_info,KAL_FALSE,KAL_FALSE); |
| 10599 | chksum_size = lid_chksum_info.algo_info.chksum_algo_length; |
| 10600 | |
| 10601 | chksum_data_buffer = (kal_uint8*)get_ctrl_buffer(chksum_size* NVRAM_EF_TEST_8_LID_RECORD_TOTAL); |
| 10602 | kal_mem_set(chksum_data_buffer, 0, chksum_size* NVRAM_EF_TEST_8_LID_RECORD_TOTAL); |
| 10603 | kal_mem_set(cmp_buffer,0,chksum_size * NVRAM_EF_TEST_8_LID_RECORD_TOTAL); |
| 10604 | // kal_uint8 md5_chksum_8b_read[chksum_size * NVRAM_EF_TEST_8_LID_RECORD_TOTAL]; |
| 10605 | kal_mem_set(data_buffer, 0xAA, NVRAM_EF_TEST_8_LID_SIZE); |
| 10606 | nvram_external_write_data(NVRAM_EF_NVRAM_TEST_8_LID, 3, (kal_uint8 *)data_buffer, NVRAM_EF_TEST_8_LID_SIZE); |
| 10607 | |
| 10608 | nvram_external_read_chksum_8b(ldi->LID, 1, NVRAM_EF_TEST_8_LID_RECORD_TOTAL, (kal_uint8 *)(chksum_data_buffer), chksum_size* NVRAM_EF_TEST_8_LID_RECORD_TOTAL); |
| 10609 | nvram_external_read_chksum_only_8b(ldi->LID, 2, (NVRAM_EF_TEST_8_LID_RECORD_TOTAL - 1), (kal_uint8 *)(cmp_buffer), chksum_size*(NVRAM_EF_TEST_8_LID_RECORD_TOTAL-1)); |
| 10610 | if(0 != kal_mem_cmp((chksum_data_buffer+ chksum_size), cmp_buffer, chksum_size*(NVRAM_EF_TEST_8_LID_RECORD_TOTAL-1))) |
| 10611 | { |
| 10612 | nvram_ut_trace("[NVUT] chksum_multi_read_function_test(): integrated 8b chksum check fail!\n\r"); |
| 10613 | for(i = 0; i < chksum_size*(NVRAM_EF_TEST_8_LID_RECORD_TOTAL - 1); i++) |
| 10614 | { |
| 10615 | nvram_ut_trace("[NVUT] chksum_read_8b[%d]: %x, chksum_read_only_8b[%d]: %x.\n\r", |
| 10616 | i, chksum_data_buffer[i+chksum_size], i, cmp_buffer[i+chksum_size]); |
| 10617 | } |
| 10618 | free_ctrl_buffer(chksum_data_buffer); |
| 10619 | return KAL_FALSE; |
| 10620 | } |
| 10621 | }while(0); |
| 10622 | //check appendix data |
| 10623 | ldi->attr &= ~NVRAM_ATTR_CHKSUM_INTEGRATE; |
| 10624 | kal_mem_set(data_buffer, 0xFF, NVRAM_EF_TEST_8_LID_SIZE); |
| 10625 | kal_mem_set(chksum_data_buffer, 0, chksum_size* NVRAM_EF_TEST_8_LID_RECORD_TOTAL); |
| 10626 | nvram_external_write_data(NVRAM_EF_NVRAM_TEST_8_LID, 3, (kal_uint8 *)data_buffer, NVRAM_EF_TEST_8_LID_SIZE); |
| 10627 | ldi->attr |= NVRAM_ATTR_CHKSUM_INTEGRATE; |
| 10628 | nvram_external_read_chksum_8b(ldi->LID, 2, (NVRAM_EF_TEST_8_LID_RECORD_TOTAL - 1), (kal_uint8 *)(chksum_data_buffer), chksum_size*(NVRAM_EF_TEST_8_LID_RECORD_TOTAL - 1)); |
| 10629 | nvram_external_read_chksum_only_8b(ldi->LID, 2, (NVRAM_EF_TEST_8_LID_RECORD_TOTAL - 1), (kal_uint8 *)(cmp_buffer), chksum_size*(NVRAM_EF_TEST_8_LID_RECORD_TOTAL - 1)); |
| 10630 | if(0 != kal_mem_cmp(chksum_data_buffer, cmp_buffer, chksum_size)) |
| 10631 | { |
| 10632 | nvram_ut_trace("[NVUT] chksum_multi_read_function_test(): integrated 8b appendix check fail!\n\r"); |
| 10633 | for(i = 0; i < chksum_size; i++) |
| 10634 | { |
| 10635 | nvram_ut_trace("[NVUT] chksum_read_8b[%d]: %x, chksum_read_only_8b[%d]: %x.\n\r", |
| 10636 | i, chksum_data_buffer[i], i, cmp_buffer[i]); |
| 10637 | } |
| 10638 | free_ctrl_buffer(chksum_data_buffer); |
| 10639 | return KAL_FALSE; |
| 10640 | } |
| 10641 | if(0 == kal_mem_cmp((chksum_data_buffer+chksum_size), (cmp_buffer+chksum_size), chksum_size)) |
| 10642 | { |
| 10643 | nvram_ut_trace("[NVUT] chksum_multi_read_function_test(): integrated 8b appendix check2 fail!\n\r"); |
| 10644 | for(i = 0; i < chksum_size; i++) |
| 10645 | { |
| 10646 | nvram_ut_trace("[NVUT] chksum_read_8b[%d]: %x, chksum_read_only_8b[%d]: %x.\n\r", |
| 10647 | i, chksum_data_buffer[i+chksum_size], i, cmp_buffer[i+chksum_size]); |
| 10648 | } |
| 10649 | free_ctrl_buffer(chksum_data_buffer); |
| 10650 | return KAL_FALSE; |
| 10651 | } |
| 10652 | free_ctrl_buffer(chksum_data_buffer); |
| 10653 | |
| 10654 | #ifdef __NVRAM_LID_CACHE__ |
| 10655 | mark_nvram_cache_ready(); |
| 10656 | #endif |
| 10657 | return KAL_TRUE; |
| 10658 | |
| 10659 | } |
| 10660 | |
| 10661 | |
| 10662 | kal_bool raw_data_access_function_test(kal_uint32 flags, void *param) |
| 10663 | { |
| 10664 | nvram_ltable_entry_struct *ldi = NULL; |
| 10665 | kal_uint32 *large_buffer_ptr = (kal_uint32*)large_buffer; |
| 10666 | kal_uint32 i, j, addr; |
| 10667 | |
| 10668 | //reset test LIDs to default settings |
| 10669 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_7_LID) ) |
| 10670 | { |
| 10671 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): reset test LID settings fail!\n\r"); |
| 10672 | } |
| 10673 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_7_LID); |
| 10674 | if(!nvram_external_reset_data(ldi->LID, 1, ldi->total_records)) { |
| 10675 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): LID reset fail!\n\r"); |
| 10676 | } |
| 10677 | |
| 10678 | //empty file read test |
| 10679 | nvram_memset(large_buffer, 0xFF, NVRAM_UT_BUFFER_SIZE); |
| 10680 | if(!nvram_external_read_raw_data(NVRAM_EF_NVRAM_TEST_7_LID, 0x100000, large_buffer, NVRAM_UT_BUFFER_SIZE)) { |
| 10681 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): read empty file fail!\n\r"); |
| 10682 | return KAL_FALSE; |
| 10683 | } |
| 10684 | for(i = 0; i < (NVRAM_UT_BUFFER_SIZE / sizeof(kal_uint32)); i++) { |
| 10685 | if(large_buffer_ptr[i] != 0) { |
| 10686 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): read empty file not as expect!\n\r"); |
| 10687 | return KAL_FALSE; |
| 10688 | } |
| 10689 | } |
| 10690 | |
| 10691 | //write extern |
| 10692 | for(i = 0; i < (NVRAM_UT_BUFFER_SIZE / sizeof(kal_uint32)); i++) { |
| 10693 | large_buffer_ptr[i] = ((i * sizeof(kal_uint32)) + 0xAA100000); |
| 10694 | } |
| 10695 | if(!nvram_external_write_raw_data(NVRAM_EF_NVRAM_TEST_7_LID, 0x100000, large_buffer, NVRAM_UT_BUFFER_SIZE)) { |
| 10696 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): write extern file fail!\n\r"); |
| 10697 | return KAL_FALSE; |
| 10698 | } |
| 10699 | |
| 10700 | //write exist |
| 10701 | for(i = 0; i < (NVRAM_UT_BUFFER_SIZE / sizeof(kal_uint32)); i++) { |
| 10702 | large_buffer_ptr[i] = ((i * sizeof(kal_uint32)) + 0xBB0F0000); |
| 10703 | } |
| 10704 | if(!nvram_external_write_raw_data(NVRAM_EF_NVRAM_TEST_7_LID, 0xF0000, large_buffer, NVRAM_UT_BUFFER_SIZE)) { |
| 10705 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): write exist file fail!\n\r"); |
| 10706 | return KAL_FALSE; |
| 10707 | } |
| 10708 | |
| 10709 | //read back check |
| 10710 | for(i = 0; i < (0x100000 + 2*NVRAM_UT_BUFFER_SIZE); i+= NVRAM_UT_BUFFER_SIZE) { |
| 10711 | nvram_memset(large_buffer, 0xFF, NVRAM_UT_BUFFER_SIZE); |
| 10712 | if(!nvram_external_read_raw_data(NVRAM_EF_NVRAM_TEST_7_LID, i, large_buffer, NVRAM_UT_BUFFER_SIZE) && |
| 10713 | i < (0x100000 + NVRAM_UT_BUFFER_SIZE)) |
| 10714 | { |
| 10715 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): read back fail!\n\r"); |
| 10716 | return KAL_FALSE; |
| 10717 | } |
| 10718 | for(j = 0; j < (NVRAM_UT_BUFFER_SIZE / sizeof(kal_uint32)); j++) { |
| 10719 | addr = (i + (j * sizeof(kal_uint32))); |
| 10720 | if(addr < 0xF0000) { |
| 10721 | if(large_buffer_ptr[j] != 0) { |
| 10722 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): read back check_a fail!\n\r"); |
| 10723 | return KAL_FALSE; |
| 10724 | } |
| 10725 | } |
| 10726 | else if(addr < (0x100000 + NVRAM_UT_BUFFER_SIZE - 0x10000)) { |
| 10727 | if((large_buffer_ptr[j] >> 24) != 0xBB || (large_buffer_ptr[j] & 0x00FFFFFF) != addr) { |
| 10728 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): read back check_b fail!\n\r"); |
| 10729 | return KAL_FALSE; |
| 10730 | } |
| 10731 | } |
| 10732 | else if(addr < (0x100000 + NVRAM_UT_BUFFER_SIZE)) { |
| 10733 | if((large_buffer_ptr[j] >> 24) != 0xAA || (large_buffer_ptr[j] & 0x00FFFFFF) != addr) { |
| 10734 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): read back check_c fail!\n\r"); |
| 10735 | return KAL_FALSE; |
| 10736 | } |
| 10737 | } |
| 10738 | else { |
| 10739 | if(large_buffer_ptr[j] != 0xFFFFFFFF) { |
| 10740 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): read back check_d fail!\n\r"); |
| 10741 | return KAL_FALSE; |
| 10742 | } |
| 10743 | } |
| 10744 | } |
| 10745 | } |
| 10746 | |
| 10747 | //check normal r/w API |
| 10748 | if(nvram_external_read_data(NVRAM_EF_NVRAM_TEST_7_LID, 1, large_buffer, MAX_NVRAM_RECORD_SIZE)) { |
| 10749 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): nvram_external_read_data() test fail.\n\r"); |
| 10750 | return KAL_FALSE; |
| 10751 | } |
| 10752 | if(nvram_external_secure_read_data(NVRAM_EF_NVRAM_TEST_7_LID, 1, large_buffer, MAX_NVRAM_RECORD_SIZE, NULL)) { |
| 10753 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): nvram_external_secure_read_data() test fail.\n\r"); |
| 10754 | return KAL_FALSE; |
| 10755 | } |
| 10756 | if(nvram_external_write_data(NVRAM_EF_NVRAM_TEST_7_LID, 1, large_buffer, 2)) { |
| 10757 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): nvram_external_write_data() test fail.\n\r"); |
| 10758 | return KAL_FALSE; |
| 10759 | } |
| 10760 | if(nvram_external_secure_write_data(NVRAM_EF_NVRAM_TEST_7_LID, 1, large_buffer, 2, NULL)) { |
| 10761 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): nvram_external_secure_write_data() test fail.\n\r"); |
| 10762 | return KAL_FALSE; |
| 10763 | } |
| 10764 | |
| 10765 | return KAL_TRUE; |
| 10766 | |
| 10767 | } |
| 10768 | |
| 10769 | kal_bool record_size_boundary_test(kal_uint32 flags, void *param) |
| 10770 | { |
| 10771 | record_size_boundary_struct record_size_loop[] = { |
| 10772 | {1, 32}, {1024-16, 1024+16}, {2*1024-16, 2*1024+16}, |
| 10773 | {4*1024-16, 4*1024+16}, {8*1024-16, 8*1024+16}, {16*1024-16, 16*1024+16}, |
| 10774 | {32*1024-16, 32*1024+16}, {NVRAM_MAX_OP_BUFFER_SIZE-32, NVRAM_MAX_OP_BUFFER_SIZE}, |
| 10775 | }; |
| 10776 | nvram_ltable_entry_struct *ldi = NULL; |
| 10777 | kal_uint32 i, j, result; |
| 10778 | #ifdef __NVRAM_LID_CACHE__ |
| 10779 | nvram_cache_reset();//Disable NVRAM Cache |
| 10780 | #endif |
| 10781 | for(i = 0; i < sizeof(record_size_loop)/sizeof(record_size_boundary_struct); i++) |
| 10782 | { |
| 10783 | for(j = record_size_loop[i].start_record_size ; j <= record_size_loop[i].end_record_size; j++) |
| 10784 | { |
| 10785 | //reset test LIDs to default settings |
| 10786 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 10787 | { |
| 10788 | nvram_ut_trace("[NVUT] record_size_boundary_test(): reset test LID settings fail!\n\r"); |
| 10789 | } |
| 10790 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 10791 | ldi->total_records = 2; // to save time we just set record number to 2 |
| 10792 | ldi->size = j; |
| 10793 | |
| 10794 | //this test will use LID verno "000" only |
| 10795 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 10796 | { |
| 10797 | nvram_ut_trace("[NVUT] record_size_boundary_test(): delete test LID fail!\n\r"); |
| 10798 | return KAL_FALSE; |
| 10799 | } |
| 10800 | |
| 10801 | result = nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 10802 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 10803 | CMPT_OP_WAY_API, |
| 10804 | 1, ldi->total_records); |
| 10805 | if(0 != result) |
| 10806 | { |
| 10807 | nvram_ut_trace("[NVUT] record_size_boundary_test(): lid API access fail! i=%d, j=%d.\n\r", i, j); |
| 10808 | return KAL_FALSE; |
| 10809 | } |
| 10810 | |
| 10811 | result = nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 10812 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 10813 | CMPT_OP_WAY_MSG, |
| 10814 | 1, ldi->total_records); |
| 10815 | if(0 != result) |
| 10816 | { |
| 10817 | nvram_ut_trace("[NVUT] record_size_boundary_test(): lid MSG access fail! i=%d, j=%d.\n\r", i, j); |
| 10818 | return KAL_FALSE; |
| 10819 | } |
| 10820 | |
| 10821 | nvram_ut_trace("[NVUT] record_size_boundary_test(): loop i=%d j=%d\n\r", i, j); |
| 10822 | kal_sleep_task(kal_milli_secs_to_ticks(10)); //do not always take CPU |
| 10823 | } |
| 10824 | } |
| 10825 | #ifdef __NVRAM_LID_CACHE__ |
| 10826 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 10827 | #endif |
| 10828 | return KAL_TRUE; |
| 10829 | } |
| 10830 | |
| 10831 | kal_bool record_number_boundary_test(kal_uint32 flags, void *param) |
| 10832 | { |
| 10833 | record_number_boundary_struct record_number_loop[] = { |
| 10834 | {1, 16}, {32-8, 32+8}, {64-8, 64+8}, |
| 10835 | {128-8, 128+8}, {256-8, 256+8}, {512-8, 512+8}, |
| 10836 | {1024-8, 1024+8}, {2048-8, 2048+8}, {4096-8, 2048+8}, |
| 10837 | {8192-8, 8192+8}, {16384-8, 16384+8}, {32768-8, 32768+8}, |
| 10838 | {65535-16, 65535}, |
| 10839 | }; |
| 10840 | nvram_ltable_entry_struct *ldi = NULL; |
| 10841 | kal_uint32 i, j, result; |
| 10842 | #ifdef __NVRAM_LID_CACHE__ |
| 10843 | nvram_cache_reset();//Disable NVRAM Cache |
| 10844 | #endif |
| 10845 | for(i = 0; i < sizeof(record_number_loop)/sizeof(record_number_boundary_struct); i++) |
| 10846 | { |
| 10847 | for(j = record_number_loop[i].start_record_number ; j <= record_number_loop[i].end_record_number; j++) |
| 10848 | { |
| 10849 | //reset test LIDs to default settings |
| 10850 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 10851 | { |
| 10852 | nvram_ut_trace("[NVUT] record_number_boundary_test(): reset test LID settings fail!\n\r"); |
| 10853 | } |
| 10854 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 10855 | ldi->total_records = j; |
| 10856 | ldi->size = 20; //we just set record size to 10 for test |
| 10857 | |
| 10858 | //this test will use LID verno "000" only |
| 10859 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 10860 | { |
| 10861 | nvram_ut_trace("[NVUT] record_number_boundary_test(): delete test LID fail!\n\r"); |
| 10862 | return KAL_FALSE; |
| 10863 | } |
| 10864 | |
| 10865 | if(j > 30) //if record number large than 30, only access 30 records to test(begin, middle, end) |
| 10866 | { |
| 10867 | //through API |
| 10868 | result = nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 10869 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 10870 | CMPT_OP_WAY_API, 1, 10); |
| 10871 | if(0 != result) |
| 10872 | { |
| 10873 | nvram_ut_trace("[NVUT] record_number_boundary_test(): lid API1 access fail! i=%d, j=%d.\n\r", i, j); |
| 10874 | return KAL_FALSE; |
| 10875 | } |
| 10876 | result = nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 10877 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 10878 | CMPT_OP_WAY_API, ldi->total_records/2 - 4, ldi->total_records/2 + 5); |
| 10879 | if(0 != result) |
| 10880 | { |
| 10881 | nvram_ut_trace("[NVUT] record_number_boundary_test(): lid API2 access fail! i=%d, j=%d.\n\r", i, j); |
| 10882 | return KAL_FALSE; |
| 10883 | } |
| 10884 | result = nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 10885 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 10886 | CMPT_OP_WAY_API, ldi->total_records-9, ldi->total_records); |
| 10887 | if(0 != result) |
| 10888 | { |
| 10889 | nvram_ut_trace("[NVUT] record_number_boundary_test(): lid API3 access fail! i=%d, j=%d.\n\r", i, j); |
| 10890 | return KAL_FALSE; |
| 10891 | } |
| 10892 | //through MSG |
| 10893 | result = nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 10894 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 10895 | CMPT_OP_WAY_MSG, 1, 10); |
| 10896 | if(0 != result) |
| 10897 | { |
| 10898 | nvram_ut_trace("[NVUT] record_number_boundary_test(): lid MSG1 access fail! i=%d, j=%d.\n\r", i, j); |
| 10899 | return KAL_FALSE; |
| 10900 | } |
| 10901 | result = nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 10902 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 10903 | CMPT_OP_WAY_MSG, ldi->total_records/2 - 4, ldi->total_records/2 + 5); |
| 10904 | if(0 != result) |
| 10905 | { |
| 10906 | nvram_ut_trace("[NVUT] record_number_boundary_test(): lid MSG2 access fail! i=%d, j=%d.\n\r", i, j); |
| 10907 | return KAL_FALSE; |
| 10908 | } |
| 10909 | result = nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 10910 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 10911 | CMPT_OP_WAY_MSG, ldi->total_records-9, ldi->total_records); |
| 10912 | if(0 != result) |
| 10913 | { |
| 10914 | nvram_ut_trace("[NVUT] record_number_boundary_test(): lid MSG3 access fail! i=%d, j=%d.\n\r", i, j); |
| 10915 | return KAL_FALSE; |
| 10916 | } |
| 10917 | } |
| 10918 | else //full record cover |
| 10919 | { |
| 10920 | result = nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 10921 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 10922 | CMPT_OP_WAY_API, 1, ldi->total_records); |
| 10923 | if(0 != result) |
| 10924 | { |
| 10925 | nvram_ut_trace("[NVUT] record_number_boundary_test(): lid API access fail! i=%d, j=%d.\n\r", i, j); |
| 10926 | return KAL_FALSE; |
| 10927 | } |
| 10928 | |
| 10929 | result = nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 10930 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 10931 | CMPT_OP_WAY_MSG, 1, ldi->total_records); |
| 10932 | if(0 != result) |
| 10933 | { |
| 10934 | nvram_ut_trace("[NVUT] record_number_boundary_test(): lid MSG access fail! i=%d, j=%d.\n\r", i, j); |
| 10935 | return KAL_FALSE; |
| 10936 | } |
| 10937 | } |
| 10938 | nvram_ut_trace("[NVUT] record_number_boundary_test(): loop i=%d j=%d\n\r", i, j); |
| 10939 | kal_sleep_task(kal_milli_secs_to_ticks(10)); //do not always take CPU |
| 10940 | } |
| 10941 | } |
| 10942 | #ifdef __NVRAM_LID_CACHE__ |
| 10943 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 10944 | #endif |
| 10945 | return KAL_TRUE; |
| 10946 | } |
| 10947 | |
| 10948 | kal_bool nvram_stress_test(kal_uint32 flags, void *param) |
| 10949 | { |
| 10950 | #define NVRAM_STRESS_TEST_LOOP 1000 |
| 10951 | #define NVRAM_MAX_RAND_RECORD_NUM 512 //normally user's LID record number will not exceed 512 |
| 10952 | #define NVRAM_MAX_FILE_SIZE 1024*1024 //there we assue max test LID file size is 1MB, if exceed, ajust record number |
| 10953 | nvram_ltable_entry_struct *ldi = NULL; |
| 10954 | nvram_attr_enum attr_bak; |
| 10955 | nvram_write_req_struct *write_req; |
| 10956 | nvram_write_cnf_struct *nvram_write_cnf; |
| 10957 | kal_uint8 *pdu_write_buffer; |
| 10958 | ilm_struct current_ilm; |
| 10959 | kal_uint32 attribute_list[] = { |
| 10960 | NVRAM_ATTR_AVERAGE, NVRAM_ATTR_COMMITTED, NVRAM_ATTR_CONFIDENTIAL, |
| 10961 | #ifdef __NVRAM_BIND_TO_CHIP_CIPHER__ |
| 10962 | NVRAM_ATTR_MSP, |
| 10963 | #endif |
| 10964 | NVRAM_ATTR_MULTIPLE, NVRAM_ATTR_MULTIREC_READ, |
| 10965 | NVRAM_ATTR_MULTI_DEFAULT, NVRAM_ATTR_OTA_RESET, NVRAM_ATTR_WRITEPROTECT, |
| 10966 | NVRAM_ATTR_GEN_DEFAULT, NVRAM_ATTR_FAULT_ASSERT, |
| 10967 | //because NVRAM_ATTR_RING is not often used, there do not test, if test ctrl buffer is not enough |
| 10968 | //NVRAM_ATTR_RING, |
| 10969 | }; |
| 10970 | kal_uint32 category_list[] = { |
| 10971 | NVRAM_CATEGORY_USER, NVRAM_CATEGORY_INTERNAL, NVRAM_CATEGORY_CALIBRAT, |
| 10972 | NVRAM_CATEGORY_IMPORTANT, NVRAM_CATEGORY_IMPORTANT_L1, NVRAM_CATEGORY_IMPORTANT_L4, |
| 10973 | }; |
| 10974 | |
| 10975 | kal_uint8 const* default_value_list[] = { |
| 10976 | (kal_uint8 const*)NVRAM_EF_ZERO_DEFAULT, (kal_uint8 const*)NVRAM_EF_FF_DEFAULT, (kal_uint8 const*)table_default, (kal_uint8 const*)nvram_ut_get_default_value, |
| 10977 | }; |
| 10978 | kal_uint32 attr_rand_range, category_rand_range, default_rand_range; //insteand random value range |
| 10979 | kal_uint32 attr_rand_value, category_rand_value, default_rand_value; |
| 10980 | kal_uint32 attr_number, category_number, default_number; |
| 10981 | kal_uint32 i, j; |
| 10982 | kal_uint16 ring_write_record; |
| 10983 | kal_uint8 lock_status = KAL_FALSE; |
| 10984 | kal_uint8 *d_buffer, *c_buffer, result; |
| 10985 | |
| 10986 | #ifdef __NVRAM_LID_CACHE__ |
| 10987 | nvram_cache_reset();//Disable NVRAM Cache as change LID file size via adding the NVRAM_ATTR_CONFIDENTIAL or NVRAM_ATTR_MSP |
| 10988 | #endif |
| 10989 | attr_number = sizeof(attribute_list)/sizeof(kal_uint32); |
| 10990 | category_number = sizeof(category_list)/sizeof(kal_uint32); |
| 10991 | default_number = sizeof(default_value_list)/sizeof(kal_uint8 const *); |
| 10992 | |
| 10993 | attr_rand_range = (kal_uint32)pow(2, attr_number); //each bit stands a attribute should have or not have |
| 10994 | category_rand_range = category_number; //each LID only have one kind category |
| 10995 | default_rand_range = default_number; //each LID only have one kind default value |
| 10996 | |
| 10997 | //set random seed |
| 10998 | srand(ust_get_current_time()); |
| 10999 | |
| 11000 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 11001 | //reset test LID to default settings |
| 11002 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 11003 | { |
| 11004 | nvram_ut_trace("[NVUT] nvram_stress_test(): reset test LID settings fail!\n\r"); |
| 11005 | } |
| 11006 | |
| 11007 | for(i = 0; i < NVRAM_STRESS_TEST_LOOP; i++) |
| 11008 | { |
| 11009 | attr_rand_value = rand()%attr_rand_range; |
| 11010 | category_rand_value = rand()%category_rand_range; |
| 11011 | default_rand_value = rand()%default_rand_range; |
| 11012 | //set attr, category, default value, record_size, record_number |
| 11013 | for(ldi->attr = 0, j = 0; j < attr_number; j++) |
| 11014 | { |
| 11015 | if((attr_rand_value>>j)&0x1) //shoud add this attribute |
| 11016 | { |
| 11017 | ldi->attr |= attribute_list[j]; |
| 11018 | } |
| 11019 | } |
| 11020 | |
| 11021 | ldi->category = category_list[category_rand_value]; |
| 11022 | ldi->default_value = default_value_list[default_rand_value]; |
| 11023 | #ifndef __NVRAM_LID_CACHE__ |
| 11024 | ldi->total_records = rand()%NVRAM_MAX_RAND_RECORD_NUM + 1; |
| 11025 | ldi->size = rand()%NVRAM_MAX_OP_BUFFER_SIZE + 1; |
| 11026 | if((ldi->size+NVRAM_CHKSUM_SIZE)*ldi->total_records > NVRAM_MAX_FILE_SIZE) //do not allow LID size too large |
| 11027 | { |
| 11028 | ldi->total_records = NVRAM_MAX_FILE_SIZE / ldi->size; |
| 11029 | } |
| 11030 | |
| 11031 | if(ldi->attr & NVRAM_ATTR_RING) |
| 11032 | { |
| 11033 | if(ldi->size < 2) |
| 11034 | ldi->size = 2; |
| 11035 | if(ldi->total_records < 2) |
| 11036 | ldi->total_records = 2; |
| 11037 | } |
| 11038 | #endif |
| 11039 | nvram_ut_trace("[NVDBG] nvram_stress_test(): category= %8x,attr= %8x,ldi->size=%d,lid->total_records=%d!\n\r", |
| 11040 | ldi->category,ldi->attr,ldi->size,ldi->total_records); |
| 11041 | |
| 11042 | if((ldi->size+NVRAM_CHKSUM_SIZE)*ldi->total_records > NVRAM_MAX_OP_BUFFER_SIZE) //large LID can only set default value as 0x00 or 0xFF otherwise buffer is not enough |
| 11043 | { |
| 11044 | ldi->default_value = NVRAM_EF_ZERO_DEFAULT; |
| 11045 | nvram_ut_trace("[NVDBG] nvram_stress_test(): default_value is NVRAM_EF_ZERO_DEFAULT!\n\r"); |
| 11046 | } |
| 11047 | |
| 11048 | if((kal_uint8 const*)nvram_ut_get_default_value == ldi->default_value) |
| 11049 | { |
| 11050 | ldi->category |= NVRAM_CATEGORY_FUNC_DEFAULT; |
| 11051 | nvram_ut_trace("[NVDBG] nvram_stress_test(): mask the NVRAM_CATEGORY_FUNC_DEFAULT!\n\r"); |
| 11052 | } |
| 11053 | else |
| 11054 | { |
| 11055 | ldi->category &= ~NVRAM_CATEGORY_FUNC_DEFAULT; |
| 11056 | nvram_ut_trace("[NVDBG] nvram_stress_test(): unmask the NVRAM_CATEGORY_FUNC_DEFAULT!\n\r"); |
| 11057 | } |
| 11058 | |
| 11059 | if((kal_uint8 const*)table_default != ldi->default_value) |
| 11060 | { |
| 11061 | ldi->attr &= ~NVRAM_ATTR_MULTI_DEFAULT; |
| 11062 | nvram_ut_trace("[NVDBG] nvram_stress_test(): unmask the NVRAM_ATTR_MULTI_DEFAULT!\n\r"); |
| 11063 | } |
| 11064 | if(ldi->attr & NVRAM_ATTR_WRITEPROTECT) //temp close NVRAM system lock status |
| 11065 | { |
| 11066 | lock_status = nvram_ptr->lock; |
| 11067 | nvram_ptr->lock = KAL_FALSE; |
| 11068 | } |
| 11069 | nvram_ut_trace("[NVDBG] nvram_stress_test() 2: category= %8x,attr= %8x,ldi->size=%d,lid->total_records=%d!\n\r", |
| 11070 | ldi->category,ldi->attr,ldi->size,ldi->total_records); |
| 11071 | //this test will use LID verno "000" only |
| 11072 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 11073 | { |
| 11074 | nvram_ut_trace("[NVUT] nvram_stress_test(): delete test LID fail before test!\n\r"); |
| 11075 | //return KAL_FALSE; |
| 11076 | } |
| 11077 | |
| 11078 | attr_bak = ldi->attr; |
| 11079 | |
| 11080 | //reset test LID to default value |
| 11081 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 11082 | { |
| 11083 | nvram_ut_trace("[NVUT] nvram_stress_test(): reset test LID fail!\n\r"); |
| 11084 | return KAL_FALSE; |
| 11085 | } |
| 11086 | nvram_ut_trace("[NVDBG] nvram_stress_test(): reset test LID Success!\n\r"); |
| 11087 | |
| 11088 | if(ldi->attr & NVRAM_ATTR_RING) //ring attribute should use msg to test only |
| 11089 | { |
| 11090 | //write LID |
| 11091 | d_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 11092 | d_buffer[0] = 0xEF; |
| 11093 | write_req = (nvram_write_req_struct *)construct_local_para(sizeof(nvram_write_req_struct), TD_CTRL); |
| 11094 | pdu_write_buffer = (kal_uint8 *)construct_peer_buff(ldi->size, 0, 0, TD_CTRL); |
| 11095 | kal_mem_cpy(get_peer_buff_pdu((peer_buff_struct*)pdu_write_buffer, 0), d_buffer, ldi->size); |
| 11096 | write_req->ref_count = 1; |
| 11097 | write_req->file_idx = ldi->LID; |
| 11098 | write_req->para = 1; //for ring, this para have no meaning |
| 11099 | |
| 11100 | msg_send6(kal_get_active_module_id(), MOD_NVRAM, 0, MSG_ID_NVRAM_WRITE_REQ, |
| 11101 | (local_para_struct*)write_req, (peer_buff_struct*)pdu_write_buffer); |
| 11102 | msg_receive_extq(¤t_ilm); |
| 11103 | nvram_write_cnf = (nvram_write_cnf_struct*)current_ilm.local_para_ptr; |
| 11104 | result = nvram_write_cnf->result; |
| 11105 | destroy_ilm(¤t_ilm); |
| 11106 | if(NVRAM_ERRNO_SUCCESS != result) |
| 11107 | { |
| 11108 | free_ctrl_buffer(d_buffer); |
| 11109 | nvram_ut_trace("[NVUT] nvram_stress_test(): ring write fail!\n\r"); |
| 11110 | break; |
| 11111 | } |
| 11112 | c_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 11113 | //for ring LID, record 1's first two bytes stores the last written record |
| 11114 | if( !nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)c_buffer, ldi->size) ) |
| 11115 | { |
| 11116 | free_ctrl_buffer(d_buffer); |
| 11117 | free_ctrl_buffer(c_buffer); |
| 11118 | nvram_ut_trace("[NVUT] nvram_stress_test(): ring read record 1 fail!\n\r"); |
| 11119 | return KAL_FALSE; |
| 11120 | } |
| 11121 | ring_write_record = (kal_uint16)c_buffer[0]; |
| 11122 | if( !nvram_external_read_data(ldi->LID, ring_write_record, (kal_uint8 *)c_buffer, ldi->size) ) |
| 11123 | { |
| 11124 | free_ctrl_buffer(d_buffer); |
| 11125 | free_ctrl_buffer(c_buffer); |
| 11126 | nvram_ut_trace("[NVUT] nvram_stress_test(): ring read write record fail!\n\r"); |
| 11127 | return KAL_FALSE; |
| 11128 | } |
| 11129 | if(0 != kal_mem_cmp(c_buffer, d_buffer, ldi->size)) |
| 11130 | { |
| 11131 | free_ctrl_buffer(d_buffer); |
| 11132 | free_ctrl_buffer(c_buffer); |
| 11133 | nvram_ut_trace("[NVUT] nvram_stress_test(): ring read back value change.\n\r"); |
| 11134 | return KAL_FALSE; |
| 11135 | } |
| 11136 | free_ctrl_buffer(d_buffer); |
| 11137 | free_ctrl_buffer(c_buffer); |
| 11138 | } |
| 11139 | else |
| 11140 | { |
| 11141 | if(ldi->total_records <= 5) //full record cover |
| 11142 | { |
| 11143 | //API access |
| 11144 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 11145 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 11146 | CMPT_OP_WAY_API, 1, ldi->total_records)) |
| 11147 | { |
| 11148 | nvram_ut_trace("[NVUT] nvram_stress_test(): nvram_lid_cmpt_operation() API fail!\n\r"); |
| 11149 | nvram_ut_trace("[NVUT] nvram_stress_test(): attr_rand_value=%d, category_rand_value=%d, default_rand_value=%d.\n\r", attr_rand_value, category_rand_value, default_rand_value); |
| 11150 | nvram_ut_trace("[NVUT] nvram_stress_test(): attr_number=%d, category_number=%d, default_number=%d.\n\r", attr_number, category_number, default_number); |
| 11151 | return KAL_FALSE; |
| 11152 | } |
| 11153 | //MSG access |
| 11154 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 11155 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 11156 | CMPT_OP_WAY_MSG, 1, ldi->total_records)) |
| 11157 | { |
| 11158 | nvram_ut_trace("[NVUT] nvram_stress_test(): nvram_lid_cmpt_operation() MSG fail!\n\r"); |
| 11159 | nvram_ut_trace("[NVUT] nvram_stress_test(): attr_rand_value=%d, category_rand_value=%d, default_rand_value=%d.\n\r", attr_rand_value, category_rand_value, default_rand_value); |
| 11160 | nvram_ut_trace("[NVUT] nvram_stress_test(): attr_number=%d, category_number=%d, default_number=%d.\n\r", attr_number, category_number, default_number); |
| 11161 | return KAL_FALSE; |
| 11162 | } |
| 11163 | } |
| 11164 | else //only access begin and end part ecah 2 records |
| 11165 | { |
| 11166 | //API access |
| 11167 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 11168 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 11169 | CMPT_OP_WAY_API, 1, 2)) |
| 11170 | { |
| 11171 | nvram_ut_trace("[NVUT] nvram_stress_test(): nvram_lid_cmpt_operation() API fail!\n\r"); |
| 11172 | nvram_ut_trace("[NVUT] nvram_stress_test(): attr_rand_value=%d, category_rand_value=%d, default_rand_value=%d.\n\r", attr_rand_value, category_rand_value, default_rand_value); |
| 11173 | nvram_ut_trace("[NVUT] nvram_stress_test(): attr_number=%d, category_number=%d, default_number=%d.\n\r", attr_number, category_number, default_number); |
| 11174 | return KAL_FALSE; |
| 11175 | } |
| 11176 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 11177 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 11178 | CMPT_OP_WAY_API, ldi->total_records-1, ldi->total_records)) |
| 11179 | { |
| 11180 | nvram_ut_trace("[NVUT] nvram_stress_test(): nvram_lid_cmpt_operation() API fail!\n\r"); |
| 11181 | nvram_ut_trace("[NVUT] nvram_stress_test(): attr_rand_value=%d, category_rand_value=%d, default_rand_value=%d.\n\r", attr_rand_value, category_rand_value, default_rand_value); |
| 11182 | nvram_ut_trace("[NVUT] nvram_stress_test(): attr_number=%d, category_number=%d, default_number=%d.\n\r", attr_number, category_number, default_number); |
| 11183 | return KAL_FALSE; |
| 11184 | } |
| 11185 | //MSG access |
| 11186 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 11187 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 11188 | CMPT_OP_WAY_MSG, 1, 2)) |
| 11189 | { |
| 11190 | nvram_ut_trace("[NVUT] nvram_stress_test(): nvram_lid_cmpt_operation() MSG fail!\n\r"); |
| 11191 | nvram_ut_trace("[NVUT] nvram_stress_test(): attr_rand_value=%d, category_rand_value=%d, default_rand_value=%d.\n\r", attr_rand_value, category_rand_value, default_rand_value); |
| 11192 | nvram_ut_trace("[NVUT] nvram_stress_test(): attr_number=%d, category_number=%d, default_number=%d.\n\r", attr_number, category_number, default_number); |
| 11193 | return KAL_FALSE; |
| 11194 | } |
| 11195 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 11196 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK, CMPT_OP_FLAG_WRITE, CMPT_OP_FLAG_RESET, 0), |
| 11197 | CMPT_OP_WAY_MSG, ldi->total_records-1, ldi->total_records)) |
| 11198 | { |
| 11199 | nvram_ut_trace("[NVUT] nvram_stress_test(): nvram_lid_cmpt_operation() MSG fail!\n\r"); |
| 11200 | nvram_ut_trace("[NVUT] nvram_stress_test(): attr_rand_value=%d, category_rand_value=%d, default_rand_value=%d.\n\r", attr_rand_value, category_rand_value, default_rand_value); |
| 11201 | nvram_ut_trace("[NVUT] nvram_stress_test(): attr_number=%d, category_number=%d, default_number=%d.\n\r", attr_number, category_number, default_number); |
| 11202 | return KAL_FALSE; |
| 11203 | } |
| 11204 | } |
| 11205 | } |
| 11206 | |
| 11207 | if(attr_bak != ldi->attr) |
| 11208 | { |
| 11209 | nvram_ut_trace("[NVUT] nvram_stress_test(): attr changed unexpect!\n\r"); |
| 11210 | } |
| 11211 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 11212 | { |
| 11213 | nvram_ut_trace("[NVUT] nvram_stress_test(): delete test LID fail after test!\n\r"); |
| 11214 | } |
| 11215 | if(ldi->attr & NVRAM_ATTR_WRITEPROTECT) |
| 11216 | { |
| 11217 | nvram_ptr->lock = lock_status; |
| 11218 | } |
| 11219 | |
| 11220 | if(0 == i%10) //suspend a while |
| 11221 | { |
| 11222 | kal_sleep_task(kal_milli_secs_to_ticks(10)); |
| 11223 | } |
| 11224 | nvram_ut_trace("[NVUT] nvram_stress_test(): loop i=%d\n\r", i); |
| 11225 | } |
| 11226 | #ifdef __NVRAM_LID_CACHE__ |
| 11227 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 11228 | #endif |
| 11229 | return KAL_TRUE; |
| 11230 | |
| 11231 | } |
| 11232 | |
| 11233 | kal_bool nvram_exception_test(kal_uint32 flags, void *param) |
| 11234 | { |
| 11235 | nvram_ltable_entry_struct *ldi = NULL; |
| 11236 | kal_uint32 exception_test_lid[]= |
| 11237 | { |
| 11238 | NVRAM_EF_SYS_EXCEPTION_LID_DUMMY, NVRAM_EF_SYS_STATISTICS_LID |
| 11239 | }; //nvram_write_exception_data_item and nvram_read_exception_data_item only allow this two LID's operation |
| 11240 | kal_uint32 i, j; |
| 11241 | #ifdef __NVRAM_LID_CACHE__ |
| 11242 | nvram_cache_reset();//Disable NVRAM Cache |
| 11243 | #endif |
| 11244 | for(i = 0; i < sizeof(exception_test_lid)/sizeof(kal_uint32); i++) |
| 11245 | { |
| 11246 | nvram_util_get_data_item(&ldi, exception_test_lid[i]); |
| 11247 | |
| 11248 | data_buffer[0] = i; |
| 11249 | for(j = 1; j <= ldi->total_records; j++) |
| 11250 | { |
| 11251 | //nvram_write_exception_data_item() test |
| 11252 | if(NVRAM_DRV_OK != nvram_write_exception_data_item(ldi, j, (kal_uint8 *)data_buffer)) |
| 11253 | { |
| 11254 | nvram_ut_trace("[NVUT] nvram_exception_test(): nvram_write_exception_data_item() fail.\n\r"); |
| 11255 | return KAL_FALSE; |
| 11256 | } |
| 11257 | if(NVRAM_DRV_OK != nvram_read_exception_data_item(ldi, j, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 11258 | { |
| 11259 | nvram_ut_trace("[NVUT] nvram_exception_test(): 1st nvram_read_exception_data_item() fail.\n\r"); |
| 11260 | return KAL_FALSE; |
| 11261 | } |
| 11262 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 11263 | { |
| 11264 | nvram_ut_trace("[NVUT] nvram_exception_test(): nvram_read_exception_data_item() 1st readback not as except.\n\r"); |
| 11265 | return KAL_FALSE; |
| 11266 | } |
| 11267 | if(! nvram_external_read_data(ldi->LID, j, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 11268 | { |
| 11269 | nvram_ut_trace("[NVUT] nvram_exception_test(): 1st nvram_external_read_data() fail.\n\r"); |
| 11270 | return KAL_FALSE; |
| 11271 | } |
| 11272 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 11273 | { |
| 11274 | nvram_ut_trace("[NVUT] nvram_exception_test(): 1st nvram_external_read_data() readback not as except.\n\r"); |
| 11275 | return KAL_FALSE; |
| 11276 | } |
| 11277 | |
| 11278 | //nvram_read_exception_data_item() test |
| 11279 | if(! nvram_external_write_data(ldi->LID, j, (kal_uint8 *)data_buffer, ldi->size)) |
| 11280 | { |
| 11281 | nvram_ut_trace("[NVUT] nvram_exception_test(): nvram_external_write_data() fail.\n\r"); |
| 11282 | return KAL_FALSE; |
| 11283 | } |
| 11284 | if(NVRAM_DRV_OK != nvram_read_exception_data_item(ldi, j, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 11285 | { |
| 11286 | nvram_ut_trace("[NVUT] nvram_exception_test(): 2nd nvram_read_exception_data_item() fail.\n\r"); |
| 11287 | return KAL_FALSE; |
| 11288 | } |
| 11289 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 11290 | { |
| 11291 | nvram_ut_trace("[NVUT] nvram_exception_test(): nvram_read_exception_data_item() 2nd readback not as except.\n\r"); |
| 11292 | return KAL_FALSE; |
| 11293 | } |
| 11294 | |
| 11295 | } |
| 11296 | } |
| 11297 | #ifdef __NVRAM_LID_CACHE__ |
| 11298 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 11299 | #endif |
| 11300 | return KAL_TRUE; |
| 11301 | |
| 11302 | } |
| 11303 | |
| 11304 | kal_bool nvram_security_test(kal_uint32 flags, void *param) |
| 11305 | { |
| 11306 | nvram_ltable_entry_struct *ldi = NULL; |
| 11307 | |
| 11308 | //reset test LIDs to default settings |
| 11309 | if( !reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID) ) |
| 11310 | { |
| 11311 | nvram_ut_trace("[NVUT] nvram_security_test(): reset test LID settings fail!\n\r"); |
| 11312 | } |
| 11313 | |
| 11314 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 11315 | //this test will use LID verno "000" only |
| 11316 | if( !delete_special_version_lid(NVRAM_EF_NVRAM_TEST_1_LID, 0, 0) ) |
| 11317 | { |
| 11318 | nvram_ut_trace("[NVUT] nvram_security_test(): delete test LID fail!\n\r"); |
| 11319 | } |
| 11320 | |
| 11321 | //reset test LID to default value |
| 11322 | if( !nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records) ) |
| 11323 | { |
| 11324 | nvram_ut_trace("[NVUT] nvram_security_test(): reset test LID fail!\n\r"); |
| 11325 | return KAL_FALSE; |
| 11326 | } |
| 11327 | nvram_ut_trace("[NVUT] nvram_security_test(): reset test LID Success!\n\r"); |
| 11328 | |
| 11329 | nvram_get_default_value_to_write(ldi, 1, (kal_uint8 *)data_buffer, ldi->size); |
| 11330 | |
| 11331 | ldi->attr |= NVRAM_ATTR_WRITEPROTECT; |
| 11332 | ldi->default_value = NVRAM_EF_FF_DEFAULT; //modify test LID's default value |
| 11333 | //lid read |
| 11334 | if( !nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) ) |
| 11335 | { |
| 11336 | nvram_ut_trace("[NVUT] nvram_security_test(): first read test LID fail!\n\r"); |
| 11337 | return KAL_FALSE; |
| 11338 | } |
| 11339 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 11340 | { |
| 11341 | nvram_ut_trace("[NVUT] nvram_security_test(): first read not as expect!\n\r"); |
| 11342 | return KAL_FALSE; |
| 11343 | } |
| 11344 | nvram_ut_trace("[NVUT] nvram_security_test(): first read as expect!\n\r"); |
| 11345 | |
| 11346 | //lid access |
| 11347 | nvram_ut_assert_flag = 0; |
| 11348 | |
| 11349 | if(0 != nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 11350 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_SET_LOCK, 0, 0, 0), |
| 11351 | CMPT_OP_WAY_MSG, 1, 1)) |
| 11352 | { |
| 11353 | nvram_ut_trace("[NVUT] nvram_security_test(): nvram_lid_cmpt_operation()Lock fail!\n\r"); |
| 11354 | return KAL_FALSE; |
| 11355 | } |
| 11356 | nvram_ut_trace("[NVUT] nvram_security_test(): nvram_lid_cmpt_operation()Lock Success!\n\r"); |
| 11357 | |
| 11358 | cmp_buffer[0] = 0x30; |
| 11359 | if( KAL_TRUE == nvram_external_write_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) ) |
| 11360 | { |
| 11361 | nvram_ut_trace("[NVUT] nvram_security_test(): write fail not happen!\n\r"); |
| 11362 | return KAL_FALSE; |
| 11363 | } |
| 11364 | else |
| 11365 | { |
| 11366 | nvram_ut_trace("[NVUT] nvram_security_test(): can't write when locked!\n\r"); |
| 11367 | } |
| 11368 | |
| 11369 | if( !nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) ) |
| 11370 | { |
| 11371 | nvram_ut_trace("[NVUT] nvram_security_test(): second read test LID fail!\n\r"); |
| 11372 | return KAL_FALSE; |
| 11373 | } |
| 11374 | |
| 11375 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 11376 | { |
| 11377 | nvram_ut_trace("[NVUT] nvram_security_test(): second read not as expect!\n\r"); |
| 11378 | return KAL_FALSE; |
| 11379 | } |
| 11380 | nvram_ut_trace("[NVUT] nvram_security_test(): second read as expect!\n\r"); |
| 11381 | |
| 11382 | if(0 == nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, |
| 11383 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_SET_UNLOCK, 0, 0, 0), |
| 11384 | CMPT_OP_WAY_MSG, 1, 1)) |
| 11385 | { |
| 11386 | #ifdef __NVRAM_IMEI_UNLOCK_DISABLE__ |
| 11387 | nvram_ut_trace("[NVUT] nvram_security_test(): nvram_lid_cmpt_operation() UNLOCK fail not happen!\n\r"); |
| 11388 | return KAL_FALSE; |
| 11389 | #else |
| 11390 | nvram_ut_trace("[NVUT] nvram_security_test(): nvram_lid_cmpt_operation() UNLOCK Success !\n\r"); |
| 11391 | #endif |
| 11392 | |
| 11393 | } |
| 11394 | #ifdef __NVRAM_IMEI_UNLOCK_DISABLE__ |
| 11395 | nvram_ut_trace("[NVUT] nvram_security_test(): nvram_lid_cmpt_operation() UNLOCK fail happen!\n\r"); |
| 11396 | #endif |
| 11397 | |
| 11398 | if(nvram_ut_assert_flag) |
| 11399 | { |
| 11400 | nvram_ut_trace("[NVUT] nvram_security_test(): unexpect assert happen!\n\r"); |
| 11401 | return KAL_FALSE; |
| 11402 | } |
| 11403 | |
| 11404 | cmp_buffer[0] = 0x32; |
| 11405 | if( KAL_TRUE == nvram_external_write_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) ) |
| 11406 | { |
| 11407 | #ifdef __NVRAM_IMEI_UNLOCK_DISABLE__ |
| 11408 | nvram_ut_trace("[NVUT] nvram_security_test(): write fail not happen!\n\r"); |
| 11409 | return KAL_FALSE; |
| 11410 | #else |
| 11411 | nvram_ut_trace("[NVUT] nvram_security_test(): write success after unlock!\n\r"); |
| 11412 | #endif |
| 11413 | } |
| 11414 | #ifdef __NVRAM_IMEI_UNLOCK_DISABLE__ |
| 11415 | nvram_ut_trace("[NVUT] nvram_security_test(): write fail happen when unlock fail!\n\r"); |
| 11416 | #endif |
| 11417 | |
| 11418 | if( !nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) ) |
| 11419 | { |
| 11420 | nvram_ut_trace("[NVUT] nvram_security_test(): third read test LID fail!\n\r"); |
| 11421 | return KAL_FALSE; |
| 11422 | } |
| 11423 | |
| 11424 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 11425 | { |
| 11426 | #ifdef __NVRAM_IMEI_UNLOCK_DISABLE__ |
| 11427 | nvram_ut_trace("[NVUT] nvram_security_test(): third read not as expect!\n\r"); |
| 11428 | return KAL_FALSE; |
| 11429 | #endif |
| 11430 | } |
| 11431 | nvram_ut_trace("[NVUT] nvram_security_test(): third read as expect!\n\r"); |
| 11432 | |
| 11433 | //lid reset |
| 11434 | nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records); |
| 11435 | nvram_get_default_value_to_write(ldi, 1, (kal_uint8 *)data_buffer, ldi->size); //get new default value |
| 11436 | if( !nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) ) |
| 11437 | { |
| 11438 | nvram_ut_trace("[NVUT] nvram_security_test(): third read test LID fail!\n\r"); |
| 11439 | return KAL_FALSE; |
| 11440 | } |
| 11441 | nvram_ut_trace("[NVUT] nvram_security_test(): third read test LID Success!\n\r"); |
| 11442 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 11443 | { |
| 11444 | nvram_ut_trace("[NVUT] nvram_security_test(): third read not as expect!\n\r"); |
| 11445 | return KAL_FALSE; |
| 11446 | } |
| 11447 | nvram_ut_trace("[NVUT] nvram_security_test(): third read as expect!\n\r"); |
| 11448 | return KAL_TRUE; |
| 11449 | } |
| 11450 | |
| 11451 | |
| 11452 | #if defined(__NVRAM_STRUCTURE_CHANGE_RESET__) || defined(__NVRAM_DEFVAL_CHANGE_RESET__) |
| 11453 | extern const checksum_reset_struct lid_structure_chksum[]; |
| 11454 | extern const checksum_reset_struct lid_default_value_chksum[]; |
| 11455 | |
| 11456 | |
| 11457 | extern kal_uint32 lid_structure_chksum_num; |
| 11458 | extern kal_uint32 lid_default_value_chksum_num; |
| 11459 | |
| 11460 | kal_bool nvram_modify_structure_checksum(nvram_lid_enum LID) |
| 11461 | { |
| 11462 | NVRAM_FILE_NAME nvramname; |
| 11463 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 11464 | nvram_folder_enum nvram_folder; |
| 11465 | FS_HANDLE file_handle = FS_INVALID_FILE_HANDLE; |
| 11466 | nvram_ldi_header nv_header; |
| 11467 | nvram_ltable_entry_struct *ldi; |
| 11468 | kal_bool mulpiple = KAL_FALSE, ret_val = KAL_TRUE; |
| 11469 | kal_int32 backup_file_num = 1, result; |
| 11470 | kal_uint32 len; |
| 11471 | |
| 11472 | nvram_util_get_data_item(&ldi, LID); |
| 11473 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 11474 | nvram_folder = nvram_query_folder_index(ldi->category); |
| 11475 | nvram_query_file_name(nvram_folder, nvramname, filename); |
| 11476 | nvram_read_data_header(filename, LDI_HEADER_ALL_SECTION, &nv_header, NVRAM_LDI_HEADER_SIZE); |
| 11477 | nv_header.nv_dbg_header.struct_chkrst[0]++; |
| 11478 | |
| 11479 | //write header nvram_write_data_header() |
| 11480 | if(NVRAM_IS_ATTR_MULTIPLE(ldi->attr)) |
| 11481 | { |
| 11482 | mulpiple = KAL_TRUE; |
| 11483 | backup_file_num = 2; |
| 11484 | } |
| 11485 | |
| 11486 | nvram_util_take_mutex(g_nvram_fs_mutex); |
| 11487 | do { |
| 11488 | file_handle = FS_Open(filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_CREATE); |
| 11489 | if (file_handle < FS_NO_ERROR) { |
| 11490 | if(NVRAM_IS_ATTR_FAULT_ASSERT(ldi->attr)) { |
| 11491 | NVRAM_EXT_ASSERT(KAL_FALSE, (kal_uint32)file_handle, NVRAM_LOC_OPEN_NV_FOLDER_FAIL_4, ldi->LID); |
| 11492 | } |
| 11493 | ret_val = KAL_FALSE; |
| 11494 | } |
| 11495 | if ((result = FS_Write(file_handle, (void *)(&nv_header), sizeof(nv_header), &len)) < FS_NO_ERROR) { |
| 11496 | if(NVRAM_IS_ATTR_FAULT_ASSERT(ldi->attr)) { |
| 11497 | NVRAM_EXT_ASSERT(KAL_FALSE, (kal_uint32)file_handle, NVRAM_LOC_OPEN_NV_FOLDER_FAIL_5, ldi->LID); |
| 11498 | } |
| 11499 | ret_val = KAL_FALSE; |
| 11500 | } |
| 11501 | if(file_handle > FS_NO_ERROR) { |
| 11502 | FS_Close(file_handle); |
| 11503 | } |
| 11504 | if(!mulpiple) |
| 11505 | { |
| 11506 | break; |
| 11507 | } |
| 11508 | nvram_folder = nvram_query_folder_index_ex(ldi->category,KAL_FALSE); |
| 11509 | nvram_util_make_lid_filename(ldi, nvramname, KAL_FALSE); |
| 11510 | nvram_query_file_name(nvram_folder, nvramname, filename); |
| 11511 | }while(backup_file_num > 0); |
| 11512 | nvram_util_give_mutex(g_nvram_fs_mutex); |
| 11513 | |
| 11514 | return ret_val; |
| 11515 | } |
| 11516 | |
| 11517 | kal_bool nvram_modify_default_value_checksum(nvram_lid_enum LID) |
| 11518 | { |
| 11519 | NVRAM_FILE_NAME nvramname; |
| 11520 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 11521 | nvram_folder_enum nvram_folder; |
| 11522 | FS_HANDLE file_handle = FS_INVALID_FILE_HANDLE; |
| 11523 | nvram_ldi_header nv_header; |
| 11524 | nvram_ltable_entry_struct *ldi; |
| 11525 | kal_bool mulpiple = KAL_FALSE, ret_val = KAL_TRUE; |
| 11526 | kal_int32 backup_file_num = 1, result; |
| 11527 | kal_uint32 len; |
| 11528 | |
| 11529 | nvram_util_get_data_item(&ldi, LID); |
| 11530 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 11531 | nvram_folder = nvram_query_folder_index(ldi->category); |
| 11532 | nvram_query_file_name(nvram_folder, nvramname, filename); |
| 11533 | nvram_read_data_header(filename, LDI_HEADER_ALL_SECTION, &nv_header, NVRAM_LDI_HEADER_SIZE); |
| 11534 | nv_header.nv_dbg_header.defval_chkrst_l[0]++; |
| 11535 | |
| 11536 | //write header nvram_write_data_header() |
| 11537 | if(NVRAM_IS_ATTR_MULTIPLE(ldi->attr)) |
| 11538 | { |
| 11539 | mulpiple = KAL_TRUE; |
| 11540 | backup_file_num = 2; |
| 11541 | } |
| 11542 | |
| 11543 | nvram_util_take_mutex(g_nvram_fs_mutex); |
| 11544 | do { |
| 11545 | file_handle = FS_Open(filename, FS_READ_WRITE | FS_OPEN_NO_DIR | FS_CREATE); |
| 11546 | if (file_handle < FS_NO_ERROR) { |
| 11547 | if(NVRAM_IS_ATTR_FAULT_ASSERT(ldi->attr)) { |
| 11548 | NVRAM_EXT_ASSERT(KAL_FALSE, (kal_uint32)file_handle, NVRAM_LOC_OPEN_NV_FOLDER_FAIL_4, ldi->LID); |
| 11549 | } |
| 11550 | ret_val = KAL_FALSE; |
| 11551 | } |
| 11552 | if ((result = FS_Write(file_handle, (void *)(&nv_header), sizeof(nv_header), &len)) < FS_NO_ERROR) { |
| 11553 | if(NVRAM_IS_ATTR_FAULT_ASSERT(ldi->attr)) { |
| 11554 | NVRAM_EXT_ASSERT(KAL_FALSE, (kal_uint32)file_handle, NVRAM_LOC_OPEN_NV_FOLDER_FAIL_5, ldi->LID); |
| 11555 | } |
| 11556 | ret_val = KAL_FALSE; |
| 11557 | } |
| 11558 | if(file_handle > FS_NO_ERROR) { |
| 11559 | FS_Close(file_handle); |
| 11560 | } |
| 11561 | if(!mulpiple) |
| 11562 | { |
| 11563 | break; |
| 11564 | } |
| 11565 | nvram_folder = nvram_query_folder_index_ex(ldi->category,KAL_FALSE); |
| 11566 | nvram_util_make_lid_filename(ldi, nvramname, KAL_FALSE); |
| 11567 | nvram_query_file_name(nvram_folder, nvramname, filename); |
| 11568 | }while(backup_file_num > 0); |
| 11569 | nvram_util_give_mutex(g_nvram_fs_mutex); |
| 11570 | |
| 11571 | return ret_val; |
| 11572 | } |
| 11573 | |
| 11574 | kal_bool nvram_verify_checksum(nvram_lid_enum LID) |
| 11575 | { |
| 11576 | NVRAM_FILE_NAME nvramname; |
| 11577 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 11578 | nvram_folder_enum nvram_folder; |
| 11579 | nvram_ldi_header nv_header; |
| 11580 | nvram_ltable_entry_struct *ldi; |
| 11581 | kal_int32 index = 0; |
| 11582 | |
| 11583 | nvram_util_get_data_item(&ldi, LID); |
| 11584 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 11585 | nvram_folder = nvram_query_folder_index(ldi->category); |
| 11586 | nvram_query_file_name(nvram_folder, nvramname, filename); |
| 11587 | nvram_read_data_header(filename, LDI_HEADER_ALL_SECTION, &nv_header, NVRAM_LDI_HEADER_SIZE); |
| 11588 | |
| 11589 | #if defined(__NVRAM_STRUCTURE_CHANGE_RESET__) |
| 11590 | for(index = 0; index < lid_structure_chksum_num && LID != lid_structure_chksum[index].LID; index ++) |
| 11591 | {} |
| 11592 | if(index >= lid_structure_chksum_num) |
| 11593 | { |
| 11594 | nvram_ut_trace("[NVUT] nvram_verify_checksum(): LID not in structure checksum table!\n\r"); |
| 11595 | nvram_ut_trace("[NVUT] LID: %d!\n\r", LID); |
| 11596 | return KAL_FALSE; |
| 11597 | } |
| 11598 | if(strncmp((const char *)(lid_structure_chksum[index].chksum), (const char *)(nv_header.nv_dbg_header.struct_chkrst), RST_CHKSUM_SIZE)) |
| 11599 | { |
| 11600 | nvram_ut_trace("[NVUT] nvram_verify_checksum(): structure checksum not match LID header!\n\r"); |
| 11601 | nvram_ut_trace("[NVUT] LID: %d!\n\r", LID); |
| 11602 | return KAL_FALSE; |
| 11603 | } |
| 11604 | #endif |
| 11605 | |
| 11606 | #if defined(__NVRAM_DEFVAL_CHANGE_RESET__) |
| 11607 | for(index = 0; index < lid_default_value_chksum_num && LID != lid_default_value_chksum[index].LID; index ++) |
| 11608 | {} |
| 11609 | if(index >= lid_default_value_chksum_num) |
| 11610 | { |
| 11611 | nvram_ut_trace("[NVUT] nvram_verify_checksum(): LID not in default value checksum table!\n\r"); |
| 11612 | nvram_ut_trace("[NVUT] LID: %d!\n\r", LID); |
| 11613 | return KAL_FALSE; |
| 11614 | } |
| 11615 | if(strncmp((const char *)(nv_header.nv_ota_header.defval_chkrst_h), (const char *)(lid_default_value_chksum[index].chksum), RST_CHKSUM_SIZE-6) || |
| 11616 | strncmp((const char *)(nv_header.nv_dbg_header.defval_chkrst_l), (const char*)(&(lid_default_value_chksum[index].chksum[RST_CHKSUM_SIZE-6])), 6)) |
| 11617 | { |
| 11618 | nvram_ut_trace("[NVUT] nvram_verify_checksum(): default value checksum not match LID header!\n\r"); |
| 11619 | nvram_ut_trace("[NVUT] LID: %d!\n\r", LID); |
| 11620 | return KAL_FALSE; |
| 11621 | } |
| 11622 | #endif |
| 11623 | |
| 11624 | return KAL_TRUE; |
| 11625 | } |
| 11626 | |
| 11627 | |
| 11628 | |
| 11629 | kal_bool nvram_smart_reset_entry_test(kal_uint32 flags, void *param) |
| 11630 | { |
| 11631 | nvram_ltable_entry_struct *ldi = &logical_data_item_table[0]; |
| 11632 | kal_int32 index = 0; |
| 11633 | kal_bool case_fail = KAL_FALSE; |
| 11634 | |
| 11635 | //first round check: every reset LID should in checksum table |
| 11636 | do |
| 11637 | { |
| 11638 | #if defined(__NVRAM_STRUCTURE_CHANGE_RESET__) |
| 11639 | if(NVRAM_STRUCTURE_CHKSUM_CHANGE_RESETABLE(ldi)) |
| 11640 | { |
| 11641 | for(index = 0; index < lid_structure_chksum_num && lid_structure_chksum[index].LID != ldi->LID; index ++) |
| 11642 | {} |
| 11643 | if(index >= lid_structure_chksum_num) |
| 11644 | { |
| 11645 | nvram_ut_trace("[NVUT] nvram_smart_reset_entry_test(): LID not in structure checksum table!\n\r"); |
| 11646 | nvram_ut_trace("[NVUT] LID: %d!\n\r", ldi->LID); |
| 11647 | case_fail = KAL_TRUE; |
| 11648 | } |
| 11649 | } |
| 11650 | #endif |
| 11651 | |
| 11652 | #if defined(__NVRAM_DEFVAL_CHANGE_RESET__) |
| 11653 | if(NVRAM_DEFVAL_CHKSUM_CHANGE_RESETABLE(ldi)) |
| 11654 | { |
| 11655 | for(index = 0; index < lid_default_value_chksum_num && lid_default_value_chksum[index].LID != ldi->LID; index ++) |
| 11656 | {} |
| 11657 | if(index >= lid_default_value_chksum_num) |
| 11658 | { |
| 11659 | nvram_ut_trace("[NVUT] nvram_smart_reset_entry_test(): LID not in default value checksum table!\n\r"); |
| 11660 | nvram_ut_trace("[NVUT] LID: %d!\n\r", ldi->LID); |
| 11661 | case_fail = KAL_TRUE; |
| 11662 | } |
| 11663 | } |
| 11664 | #endif |
| 11665 | }while(nvram_util_next_data_item(&ldi)); |
| 11666 | |
| 11667 | //second round check: every LID in checksum table should be reset LID |
| 11668 | #if defined(__NVRAM_STRUCTURE_CHANGE_RESET__) |
| 11669 | for(index = 0; index < lid_structure_chksum_num; index++) |
| 11670 | { |
| 11671 | ldi = NULL; |
| 11672 | nvram_util_get_data_item(&ldi, lid_structure_chksum[index].LID); |
| 11673 | if(! ldi) |
| 11674 | { |
| 11675 | nvram_ut_trace("[NVUT] nvram_smart_reset_entry_test(): structure checksum LID not in LID table!\n\r"); |
| 11676 | nvram_ut_trace("[NVUT] LID: %d!\n\r", lid_structure_chksum[index].LID); |
| 11677 | case_fail = KAL_TRUE; |
| 11678 | } |
| 11679 | if(! NVRAM_STRUCTURE_CHKSUM_CHANGE_RESETABLE(ldi)) |
| 11680 | { |
| 11681 | nvram_ut_trace("[NVUT] nvram_smart_reset_entry_test(): structure checksum LID can not be reset!\n\r"); |
| 11682 | nvram_ut_trace("[NVUT] LID: %d!\n\r", lid_structure_chksum[index].LID); |
| 11683 | case_fail = KAL_TRUE; |
| 11684 | } |
| 11685 | |
| 11686 | } |
| 11687 | #endif |
| 11688 | |
| 11689 | #if defined(__NVRAM_DEFVAL_CHANGE_RESET__) |
| 11690 | for(index = 0; index < lid_default_value_chksum_num; index++) |
| 11691 | { |
| 11692 | ldi = NULL; |
| 11693 | nvram_util_get_data_item(&ldi, lid_default_value_chksum[index].LID); |
| 11694 | if(! ldi) |
| 11695 | { |
| 11696 | nvram_ut_trace("[NVUT] nvram_smart_reset_entry_test(): structure checksum LID not in LID table!\n\r"); |
| 11697 | nvram_ut_trace("[NVUT] LID: %d!\n\r", lid_default_value_chksum[index].LID); |
| 11698 | case_fail = KAL_TRUE; |
| 11699 | } |
| 11700 | if(! NVRAM_DEFVAL_CHKSUM_CHANGE_RESETABLE(ldi)) |
| 11701 | { |
| 11702 | nvram_ut_trace("[NVUT] nvram_smart_reset_entry_test(): default value checksum LID can not be reset!\n\r"); |
| 11703 | nvram_ut_trace("[NVUT] LID: %d!\n\r", lid_default_value_chksum[index].LID); |
| 11704 | case_fail = KAL_TRUE; |
| 11705 | } |
| 11706 | } |
| 11707 | #endif |
| 11708 | |
| 11709 | if(case_fail) |
| 11710 | return KAL_FALSE; |
| 11711 | else |
| 11712 | return KAL_TRUE; |
| 11713 | } |
| 11714 | |
| 11715 | kal_bool nvram_structure_change_reset_test(kal_uint32 flags, void *param) |
| 11716 | { |
| 11717 | nvram_ltable_entry_struct *ldi = NULL; |
| 11718 | kal_uint8 *d_buffer, *c_buffer; |
| 11719 | kal_uint8 i, j; |
| 11720 | #ifdef __NVRAM_LID_CACHE__ |
| 11721 | nvram_cache_reset();//Disable NVRAM Cache |
| 11722 | #endif |
| 11723 | //reset test LIDs to default settings |
| 11724 | for(i = 0; i < test_lid_number; i++) |
| 11725 | { |
| 11726 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 11727 | { |
| 11728 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): reset LIDs to default setting fail!\n\r"); |
| 11729 | return KAL_FALSE; |
| 11730 | } |
| 11731 | } |
| 11732 | |
| 11733 | //reset test LIDs |
| 11734 | for(i = 0; i < test_lid_number; i++) |
| 11735 | { |
| 11736 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 11737 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 11738 | { |
| 11739 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): reset test LIDs fail!\n\r"); |
| 11740 | return KAL_FALSE; |
| 11741 | } |
| 11742 | } |
| 11743 | |
| 11744 | //write test LIDs to non-default |
| 11745 | nvram_write_test_lids(); |
| 11746 | |
| 11747 | //modify structure checksum |
| 11748 | for(i = 0; i < test_lid_number; i++) |
| 11749 | { |
| 11750 | nvram_modify_structure_checksum(test_lid_enum[i]); |
| 11751 | } |
| 11752 | |
| 11753 | //reset SYS LID |
| 11754 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 11755 | { |
| 11756 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): reset SYS LID fail!\n\r"); |
| 11757 | return KAL_FALSE; |
| 11758 | } |
| 11759 | |
| 11760 | //modify MD SW version |
| 11761 | if(!modify_md_sw_version()) |
| 11762 | { |
| 11763 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): modify MD SW version fail!\n\r"); |
| 11764 | return KAL_FALSE; |
| 11765 | } |
| 11766 | |
| 11767 | //call nvram_init() |
| 11768 | nvram_boot_trace = 0; |
| 11769 | nvram_init(); |
| 11770 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 11771 | { |
| 11772 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): enter version conflict fail!\n\r"); |
| 11773 | return KAL_FALSE; |
| 11774 | } |
| 11775 | |
| 11776 | //check new checksum is right |
| 11777 | if(! nvram_verify_checksum(NVRAM_EF_NVRAM_TEST_1_LID)) //USER category |
| 11778 | { |
| 11779 | return KAL_FALSE; |
| 11780 | } |
| 11781 | if(! nvram_verify_checksum(NVRAM_EF_NVRAM_TEST_5_LID)) //L1 category |
| 11782 | { |
| 11783 | return KAL_FALSE; |
| 11784 | } |
| 11785 | |
| 11786 | //check LID is reset |
| 11787 | for(j = 0; j < test_lid_number; j++) |
| 11788 | { |
| 11789 | nvram_util_get_data_item(&ldi, test_lid_enum[j]); |
| 11790 | d_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 11791 | c_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 11792 | kal_mem_set(c_buffer, 0x33, ldi->size); |
| 11793 | kal_mem_set(d_buffer, 0x66, ldi->size); |
| 11794 | for(i = 1; i <= ldi->total_records; i++) |
| 11795 | { |
| 11796 | nvram_get_default_value_to_write(ldi, i, c_buffer, ldi->size); |
| 11797 | nvram_external_read_data(ldi->LID, i, d_buffer, ldi->size); |
| 11798 | if(ldi->LID == NVRAM_EF_NVRAM_TEST_1_LID || ldi->LID == NVRAM_EF_NVRAM_TEST_5_LID) |
| 11799 | { |
| 11800 | if(kal_mem_cmp((kal_char*)d_buffer, (kal_char*)c_buffer, ldi->size)) |
| 11801 | { |
| 11802 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): LID do not reset!\n\r"); |
| 11803 | nvram_ut_trace("[NVUT] LID: %d!\n\r", ldi->LID); |
| 11804 | free_ctrl_buffer(d_buffer); |
| 11805 | free_ctrl_buffer(c_buffer); |
| 11806 | return KAL_FALSE; |
| 11807 | } |
| 11808 | } |
| 11809 | else |
| 11810 | { |
| 11811 | if(! kal_mem_cmp((kal_char*)d_buffer, (kal_char*)c_buffer, ldi->size)) |
| 11812 | { |
| 11813 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): un-expect LID reset!\n\r"); |
| 11814 | nvram_ut_trace("[NVUT] LID: %d!\n\r", ldi->LID); |
| 11815 | free_ctrl_buffer(d_buffer); |
| 11816 | free_ctrl_buffer(c_buffer); |
| 11817 | return KAL_FALSE; |
| 11818 | } |
| 11819 | } |
| 11820 | } |
| 11821 | free_ctrl_buffer(d_buffer); |
| 11822 | free_ctrl_buffer(c_buffer); |
| 11823 | } |
| 11824 | #ifdef __NVRAM_LID_CACHE__ |
| 11825 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 11826 | #endif |
| 11827 | return KAL_TRUE; |
| 11828 | } |
| 11829 | |
| 11830 | kal_bool nvram_default_value_change_reset_test(kal_uint32 flags, void *param) |
| 11831 | { |
| 11832 | nvram_ltable_entry_struct *ldi = NULL; |
| 11833 | kal_uint8 *d_buffer, *c_buffer; |
| 11834 | kal_uint8 i, j; |
| 11835 | #ifdef __NVRAM_LID_CACHE__ |
| 11836 | nvram_cache_reset();//Disable NVRAM Cache |
| 11837 | #endif |
| 11838 | //reset test LIDs to default settings |
| 11839 | for(i = 0; i < test_lid_number; i++) |
| 11840 | { |
| 11841 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 11842 | { |
| 11843 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): reset LIDs to default setting fail!\n\r"); |
| 11844 | return KAL_FALSE; |
| 11845 | } |
| 11846 | } |
| 11847 | |
| 11848 | //reset test LIDs |
| 11849 | for(i = 0; i < test_lid_number; i++) |
| 11850 | { |
| 11851 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 11852 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 11853 | { |
| 11854 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): reset test LIDs fail!\n\r"); |
| 11855 | return KAL_FALSE; |
| 11856 | } |
| 11857 | } |
| 11858 | |
| 11859 | //write test LIDs to non-default |
| 11860 | nvram_write_test_lids(); |
| 11861 | |
| 11862 | //modify structure checksum |
| 11863 | for(i = 0; i < test_lid_number; i++) |
| 11864 | { |
| 11865 | nvram_modify_default_value_checksum(test_lid_enum[i]); |
| 11866 | } |
| 11867 | |
| 11868 | //reset SYS LID |
| 11869 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 11870 | { |
| 11871 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): reset SYS LID fail!\n\r"); |
| 11872 | return KAL_FALSE; |
| 11873 | } |
| 11874 | |
| 11875 | //modify MD SW version |
| 11876 | if(!modify_md_sw_version()) |
| 11877 | { |
| 11878 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): modify MD SW version fail!\n\r"); |
| 11879 | return KAL_FALSE; |
| 11880 | } |
| 11881 | |
| 11882 | //call nvram_init() |
| 11883 | nvram_boot_trace = 0; |
| 11884 | nvram_init(); |
| 11885 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 11886 | { |
| 11887 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): enter version conflict fail!\n\r"); |
| 11888 | return KAL_FALSE; |
| 11889 | } |
| 11890 | |
| 11891 | //check new checksum is right |
| 11892 | if(! nvram_verify_checksum(NVRAM_EF_NVRAM_TEST_1_LID)) //USER category |
| 11893 | { |
| 11894 | return KAL_FALSE; |
| 11895 | } |
| 11896 | if(! nvram_verify_checksum(NVRAM_EF_NVRAM_TEST_5_LID)) //L1 category |
| 11897 | { |
| 11898 | return KAL_FALSE; |
| 11899 | } |
| 11900 | |
| 11901 | //check LID is reset |
| 11902 | for(j = 0; j < test_lid_number; j++) |
| 11903 | { |
| 11904 | nvram_util_get_data_item(&ldi, test_lid_enum[j]); |
| 11905 | d_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 11906 | c_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 11907 | kal_mem_set(c_buffer, 0x33, ldi->size); |
| 11908 | kal_mem_set(d_buffer, 0x66, ldi->size); |
| 11909 | for(i = 1; i <= ldi->total_records; i++) |
| 11910 | { |
| 11911 | nvram_get_default_value_to_write(ldi, i, c_buffer, ldi->size); |
| 11912 | nvram_external_read_data(ldi->LID, i, d_buffer, ldi->size); |
| 11913 | if(ldi->LID == NVRAM_EF_NVRAM_TEST_1_LID || ldi->LID == NVRAM_EF_NVRAM_TEST_5_LID) |
| 11914 | { |
| 11915 | if(kal_mem_cmp((kal_char*)d_buffer, (kal_char*)c_buffer, ldi->size)) |
| 11916 | { |
| 11917 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): LID do not reset!\n\r"); |
| 11918 | nvram_ut_trace("[NVUT] LID: %d!\n\r", ldi->LID); |
| 11919 | free_ctrl_buffer(d_buffer); |
| 11920 | free_ctrl_buffer(c_buffer); |
| 11921 | return KAL_FALSE; |
| 11922 | } |
| 11923 | } |
| 11924 | else |
| 11925 | { |
| 11926 | if(! kal_mem_cmp((kal_char*)d_buffer, (kal_char*)c_buffer, ldi->size)) |
| 11927 | { |
| 11928 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): un-expect LID reset!\n\r"); |
| 11929 | nvram_ut_trace("[NVUT] LID: %d!\n\r", ldi->LID); |
| 11930 | free_ctrl_buffer(d_buffer); |
| 11931 | free_ctrl_buffer(c_buffer); |
| 11932 | return KAL_FALSE; |
| 11933 | } |
| 11934 | } |
| 11935 | } |
| 11936 | free_ctrl_buffer(d_buffer); |
| 11937 | free_ctrl_buffer(c_buffer); |
| 11938 | } |
| 11939 | #ifdef __NVRAM_LID_CACHE__ |
| 11940 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 11941 | #endif |
| 11942 | return KAL_TRUE; |
| 11943 | } |
| 11944 | |
| 11945 | kal_bool nvram_func_default_checksum_change_test(kal_uint32 flags, void *param) |
| 11946 | { |
| 11947 | nvram_ltable_entry_struct *ldi = NULL; |
| 11948 | kal_uint8 *d_buffer, *c_buffer; |
| 11949 | kal_uint8 i, j; |
| 11950 | #ifdef __NVRAM_LID_CACHE__ |
| 11951 | nvram_cache_reset();//Disable NVRAM Cache |
| 11952 | #endif |
| 11953 | //reset test LIDs to default settings |
| 11954 | for(i = 0; i < test_lid_number; i++) |
| 11955 | { |
| 11956 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 11957 | { |
| 11958 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): reset LIDs to default setting fail!\n\r"); |
| 11959 | return KAL_FALSE; |
| 11960 | } |
| 11961 | if(test_lid_enum[i] == NVRAM_EF_NVRAM_TEST_1_LID || test_lid_enum[i] == NVRAM_EF_NVRAM_TEST_5_LID) |
| 11962 | { |
| 11963 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 11964 | ldi->category |= NVRAM_CATEGORY_FUNC_DEFAULT; |
| 11965 | ldi->default_value= (kal_uint8 const*)nvram_ut_get_default_value; |
| 11966 | } |
| 11967 | } |
| 11968 | |
| 11969 | //reset test LIDs |
| 11970 | for(i = 0; i < test_lid_number; i++) |
| 11971 | { |
| 11972 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 11973 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 11974 | { |
| 11975 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): reset test LIDs fail!\n\r"); |
| 11976 | return KAL_FALSE; |
| 11977 | } |
| 11978 | } |
| 11979 | |
| 11980 | //write test LIDs to non-default |
| 11981 | nvram_write_test_lids(); |
| 11982 | |
| 11983 | //modify structure checksum |
| 11984 | for(i = 0; i < test_lid_number; i++) |
| 11985 | { |
| 11986 | nvram_modify_default_value_checksum(test_lid_enum[i]); |
| 11987 | } |
| 11988 | |
| 11989 | //reset SYS LID |
| 11990 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 11991 | { |
| 11992 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): reset SYS LID fail!\n\r"); |
| 11993 | return KAL_FALSE; |
| 11994 | } |
| 11995 | |
| 11996 | //modify MD SW version |
| 11997 | if(!modify_md_sw_version()) |
| 11998 | { |
| 11999 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): modify MD SW version fail!\n\r"); |
| 12000 | return KAL_FALSE; |
| 12001 | } |
| 12002 | |
| 12003 | //call nvram_init() |
| 12004 | nvram_boot_trace = 0; |
| 12005 | nvram_init(); |
| 12006 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 12007 | { |
| 12008 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): enter version conflict fail!\n\r"); |
| 12009 | return KAL_FALSE; |
| 12010 | } |
| 12011 | |
| 12012 | //check LID is reset |
| 12013 | for(j = 0; j < test_lid_number; j++) |
| 12014 | { |
| 12015 | nvram_util_get_data_item(&ldi, test_lid_enum[j]); |
| 12016 | d_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 12017 | c_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 12018 | kal_mem_set(c_buffer, 0x33, ldi->size); |
| 12019 | kal_mem_set(d_buffer, 0x66, ldi->size); |
| 12020 | for(i = 1; i <= ldi->total_records; i++) |
| 12021 | { |
| 12022 | nvram_get_default_value_to_write(ldi, i, c_buffer, ldi->size); |
| 12023 | nvram_external_read_data(ldi->LID, i, d_buffer, ldi->size); |
| 12024 | if(! kal_mem_cmp((kal_char*)d_buffer, (kal_char*)c_buffer, ldi->size)) |
| 12025 | { |
| 12026 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): un-expect LID reset!\n\r"); |
| 12027 | nvram_ut_trace("[NVUT] LID: %d!\n\r", ldi->LID); |
| 12028 | free_ctrl_buffer(d_buffer); |
| 12029 | free_ctrl_buffer(c_buffer); |
| 12030 | return KAL_FALSE; |
| 12031 | } |
| 12032 | } |
| 12033 | free_ctrl_buffer(d_buffer); |
| 12034 | free_ctrl_buffer(c_buffer); |
| 12035 | } |
| 12036 | #ifdef __NVRAM_LID_CACHE__ |
| 12037 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 12038 | #endif |
| 12039 | return KAL_TRUE; |
| 12040 | } |
| 12041 | |
| 12042 | kal_bool nvram_smart_reset_checksum_test(kal_uint32 flags, void *param) |
| 12043 | { |
| 12044 | nvram_ltable_entry_struct *ldi = NULL; |
| 12045 | kal_uint8 i; |
| 12046 | |
| 12047 | //reset test LIDs to default settings |
| 12048 | for(i = 0; i < test_lid_number; i++) |
| 12049 | { |
| 12050 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 12051 | { |
| 12052 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): reset LIDs to default setting fail!\n\r"); |
| 12053 | return KAL_FALSE; |
| 12054 | } |
| 12055 | } |
| 12056 | |
| 12057 | //reset test LIDs |
| 12058 | for(i = 0; i < test_lid_number; i++) |
| 12059 | { |
| 12060 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 12061 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 12062 | { |
| 12063 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): reset test LIDs fail!\n\r"); |
| 12064 | return KAL_FALSE; |
| 12065 | } |
| 12066 | } |
| 12067 | |
| 12068 | //check new checksum is right |
| 12069 | if(! nvram_verify_checksum(NVRAM_EF_NVRAM_TEST_1_LID)) //USER category |
| 12070 | { |
| 12071 | return KAL_FALSE; |
| 12072 | } |
| 12073 | if(! nvram_verify_checksum(NVRAM_EF_NVRAM_TEST_5_LID)) //L1 category |
| 12074 | { |
| 12075 | return KAL_FALSE; |
| 12076 | } |
| 12077 | |
| 12078 | //write test LIDs to non-default |
| 12079 | nvram_write_test_lids(); |
| 12080 | |
| 12081 | //check new checksum is right |
| 12082 | if(! nvram_verify_checksum(NVRAM_EF_NVRAM_TEST_1_LID)) //USER category |
| 12083 | { |
| 12084 | return KAL_FALSE; |
| 12085 | } |
| 12086 | if(! nvram_verify_checksum(NVRAM_EF_NVRAM_TEST_5_LID)) //L1 category |
| 12087 | { |
| 12088 | return KAL_FALSE; |
| 12089 | } |
| 12090 | |
| 12091 | return KAL_TRUE; |
| 12092 | } |
| 12093 | |
| 12094 | kal_bool nvram_no_checksum_change_test(kal_uint32 flags, void *param) |
| 12095 | { |
| 12096 | nvram_ltable_entry_struct *ldi = NULL; |
| 12097 | kal_uint8 *d_buffer, *c_buffer; |
| 12098 | kal_uint8 i, j; |
| 12099 | #ifdef __NVRAM_LID_CACHE__ |
| 12100 | nvram_cache_reset();//Disable NVRAM Cache |
| 12101 | #endif |
| 12102 | //reset test LIDs to default settings |
| 12103 | for(i = 0; i < test_lid_number; i++) |
| 12104 | { |
| 12105 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 12106 | { |
| 12107 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): reset LIDs to default setting fail!\n\r"); |
| 12108 | return KAL_FALSE; |
| 12109 | } |
| 12110 | } |
| 12111 | |
| 12112 | //reset test LIDs |
| 12113 | for(i = 0; i < test_lid_number; i++) |
| 12114 | { |
| 12115 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 12116 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 12117 | { |
| 12118 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): reset test LIDs fail!\n\r"); |
| 12119 | return KAL_FALSE; |
| 12120 | } |
| 12121 | } |
| 12122 | |
| 12123 | //write test LIDs to non-default |
| 12124 | nvram_write_test_lids(); |
| 12125 | |
| 12126 | //reset SYS LID |
| 12127 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 12128 | { |
| 12129 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): reset SYS LID fail!\n\r"); |
| 12130 | return KAL_FALSE; |
| 12131 | } |
| 12132 | |
| 12133 | //modify MD SW version |
| 12134 | if(!modify_md_sw_version()) |
| 12135 | { |
| 12136 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): modify MD SW version fail!\n\r"); |
| 12137 | return KAL_FALSE; |
| 12138 | } |
| 12139 | |
| 12140 | //call nvram_init() |
| 12141 | nvram_boot_trace = 0; |
| 12142 | nvram_init(); |
| 12143 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 12144 | { |
| 12145 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): enter version conflict fail!\n\r"); |
| 12146 | return KAL_FALSE; |
| 12147 | } |
| 12148 | |
| 12149 | //check new checksum is right |
| 12150 | if(! nvram_verify_checksum(NVRAM_EF_NVRAM_TEST_1_LID)) //USER category |
| 12151 | { |
| 12152 | return KAL_FALSE; |
| 12153 | } |
| 12154 | if(! nvram_verify_checksum(NVRAM_EF_NVRAM_TEST_5_LID)) //L1 category |
| 12155 | { |
| 12156 | return KAL_FALSE; |
| 12157 | } |
| 12158 | |
| 12159 | //check LID is reset |
| 12160 | for(j = 0; j < test_lid_number; j++) |
| 12161 | { |
| 12162 | nvram_util_get_data_item(&ldi, test_lid_enum[j]); |
| 12163 | d_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 12164 | c_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 12165 | kal_mem_set(c_buffer, 0x33, ldi->size); |
| 12166 | kal_mem_set(d_buffer, 0x66, ldi->size); |
| 12167 | for(i = 1; i <= ldi->total_records; i++) |
| 12168 | { |
| 12169 | nvram_get_default_value_to_write(ldi, i, c_buffer, ldi->size); |
| 12170 | nvram_external_read_data(ldi->LID, i, d_buffer, ldi->size); |
| 12171 | if(! kal_mem_cmp((kal_char*)d_buffer, (kal_char*)c_buffer, ldi->size)) |
| 12172 | { |
| 12173 | nvram_ut_trace("[NVUT] nvram_structure_change_reset_test(): un-expect LID reset!\n\r"); |
| 12174 | nvram_ut_trace("[NVUT] LID: %d!\n\r", ldi->LID); |
| 12175 | free_ctrl_buffer(d_buffer); |
| 12176 | free_ctrl_buffer(c_buffer); |
| 12177 | return KAL_FALSE; |
| 12178 | } |
| 12179 | } |
| 12180 | free_ctrl_buffer(d_buffer); |
| 12181 | free_ctrl_buffer(c_buffer); |
| 12182 | } |
| 12183 | #ifdef __NVRAM_LID_CACHE__ |
| 12184 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 12185 | #endif |
| 12186 | return KAL_TRUE; |
| 12187 | } |
| 12188 | |
| 12189 | kal_bool nvram_write_header_test(kal_uint32 flags, void *param) |
| 12190 | { |
| 12191 | NVRAM_FILE_NAME nvramname; |
| 12192 | kal_wchar filename[NVRAM_MAX_PATH_LEN]; |
| 12193 | nvram_folder_enum nvram_folder; |
| 12194 | nvram_ldi_header nv_header, nv_header_cmp; |
| 12195 | nvram_ltable_entry_struct *ldi; |
| 12196 | kal_uint8 i; |
| 12197 | #ifdef __NVRAM_LID_CACHE__ |
| 12198 | nvram_cache_reset();//Disable NVRAM Cache |
| 12199 | #endif |
| 12200 | //reset test LIDs to default settings |
| 12201 | for(i = 0; i < test_lid_number; i++) |
| 12202 | { |
| 12203 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 12204 | { |
| 12205 | nvram_ut_trace("[NVUT] nvram_write_header_test(): reset LIDs to default setting fail!\n\r"); |
| 12206 | return KAL_FALSE; |
| 12207 | } |
| 12208 | } |
| 12209 | |
| 12210 | //reset test LIDs |
| 12211 | for(i = 0; i < test_lid_number; i++) |
| 12212 | { |
| 12213 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 12214 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 12215 | { |
| 12216 | nvram_ut_trace("[NVUT] nvram_write_header_test(): reset test LIDs fail!\n\r"); |
| 12217 | return KAL_FALSE; |
| 12218 | } |
| 12219 | } |
| 12220 | |
| 12221 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); //only use NVRAM_EF_NVRAM_TEST_1_LID to test |
| 12222 | nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE); |
| 12223 | nvram_folder = nvram_query_folder_index(ldi->category); |
| 12224 | nvram_query_file_name(nvram_folder, nvramname, filename); |
| 12225 | nvram_read_data_header(filename, LDI_HEADER_ALL_SECTION, &nv_header, NVRAM_LDI_HEADER_SIZE); |
| 12226 | |
| 12227 | //write ota header by API |
| 12228 | nvram_write_data_header(ldi, LDI_HEADER_OTA_SECTION); |
| 12229 | nvram_read_data_header(filename, LDI_HEADER_ALL_SECTION, &nv_header_cmp, NVRAM_LDI_HEADER_SIZE); |
| 12230 | if(strncmp((const char *)(nv_header.nv_dbg_header.defval_chkrst_l), (const char *)(nv_header_cmp.nv_dbg_header.defval_chkrst_l), 6) || |
| 12231 | strncmp((const char *)(nv_header.nv_dbg_header.struct_chkrst), (const char *)(nv_header_cmp.nv_dbg_header.struct_chkrst), RST_CHKSUM_SIZE) || |
| 12232 | strncmp((const char *)(nv_header.nv_ota_header.defval_chkrst_h), (const char *)(nv_header_cmp.nv_ota_header.defval_chkrst_h), RST_CHKSUM_SIZE-6)) |
| 12233 | { |
| 12234 | nvram_ut_trace("[NVUT] nvram_write_header_test(): write ota header checksum change!\n\r"); |
| 12235 | return KAL_FALSE; |
| 12236 | } |
| 12237 | |
| 12238 | //write dbg header by API |
| 12239 | nvram_write_data_header(ldi, LDI_HEADER_DBG_SECTION); |
| 12240 | nvram_read_data_header(filename, LDI_HEADER_ALL_SECTION, &nv_header_cmp, NVRAM_LDI_HEADER_SIZE); |
| 12241 | if(strncmp((const char *)(nv_header.nv_dbg_header.defval_chkrst_l), (const char *)(nv_header_cmp.nv_dbg_header.defval_chkrst_l), 6) || |
| 12242 | strncmp((const char *)(nv_header.nv_dbg_header.struct_chkrst), (const char *)(nv_header_cmp.nv_dbg_header.struct_chkrst), RST_CHKSUM_SIZE) || |
| 12243 | strncmp((const char *)(nv_header.nv_ota_header.defval_chkrst_h), (const char *)(nv_header_cmp.nv_ota_header.defval_chkrst_h), RST_CHKSUM_SIZE-6)) |
| 12244 | { |
| 12245 | nvram_ut_trace("[NVUT] nvram_write_header_test(): write dbg header checksum change!\n\r"); |
| 12246 | return KAL_FALSE; |
| 12247 | } |
| 12248 | |
| 12249 | //write all header by API |
| 12250 | nvram_write_data_header(ldi, LDI_HEADER_ALL_SECTION); |
| 12251 | nvram_read_data_header(filename, LDI_HEADER_ALL_SECTION, &nv_header_cmp, NVRAM_LDI_HEADER_SIZE); |
| 12252 | if(strncmp((const char *)(nv_header.nv_dbg_header.defval_chkrst_l), (const char *)(nv_header_cmp.nv_dbg_header.defval_chkrst_l), 6) || |
| 12253 | strncmp((const char *)(nv_header.nv_dbg_header.struct_chkrst), (const char *)(nv_header_cmp.nv_dbg_header.struct_chkrst), RST_CHKSUM_SIZE) || |
| 12254 | strncmp((const char *)(nv_header.nv_ota_header.defval_chkrst_h), (const char *)(nv_header_cmp.nv_ota_header.defval_chkrst_h), RST_CHKSUM_SIZE-6)) |
| 12255 | { |
| 12256 | nvram_ut_trace("[NVUT] nvram_write_header_test(): write all header checksum change!\n\r"); |
| 12257 | return KAL_FALSE; |
| 12258 | } |
| 12259 | #ifdef __NVRAM_LID_CACHE__ |
| 12260 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 12261 | #endif |
| 12262 | return KAL_TRUE; |
| 12263 | } |
| 12264 | |
| 12265 | kal_bool nvram_attribute_change_reset_test(kal_uint32 flags, void *param) |
| 12266 | { |
| 12267 | nvram_ltable_entry_struct *ldi = NULL; |
| 12268 | kal_uint8 *d_buffer, *c_buffer; |
| 12269 | kal_uint8 i, j; |
| 12270 | #ifdef __NVRAM_LID_CACHE__ |
| 12271 | nvram_cache_reset();//Disable NVRAM Cache |
| 12272 | #endif |
| 12273 | //reset test LIDs to default settings |
| 12274 | for(i = 0; i < test_lid_number; i++) |
| 12275 | { |
| 12276 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 12277 | { |
| 12278 | nvram_ut_trace("[NVUT] nvram_attribute_change_reset_test(): reset LIDs to default setting fail!\n\r"); |
| 12279 | return KAL_FALSE; |
| 12280 | } |
| 12281 | } |
| 12282 | |
| 12283 | //reset test LIDs |
| 12284 | for(i = 0; i < test_lid_number; i++) |
| 12285 | { |
| 12286 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 12287 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 12288 | { |
| 12289 | nvram_ut_trace("[NVUT] nvram_attribute_change_reset_test(): reset test LIDs fail!\n\r"); |
| 12290 | return KAL_FALSE; |
| 12291 | } |
| 12292 | } |
| 12293 | |
| 12294 | //write test LIDs to non-default |
| 12295 | nvram_write_test_lids(); |
| 12296 | |
| 12297 | //modify attribute |
| 12298 | for(i = 0; i < test_lid_number; i++) |
| 12299 | { |
| 12300 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 12301 | ldi->attr &= (~NVRAM_ATTR_GEN_DEFAULT); //remove GEN_DEFAULT |
| 12302 | } |
| 12303 | |
| 12304 | //reset SYS LID |
| 12305 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 12306 | { |
| 12307 | nvram_ut_trace("[NVUT] nvram_attribute_change_reset_test(): reset SYS LID fail!\n\r"); |
| 12308 | return KAL_FALSE; |
| 12309 | } |
| 12310 | |
| 12311 | //modify MD SW version |
| 12312 | if(!modify_md_sw_version()) |
| 12313 | { |
| 12314 | nvram_ut_trace("[NVUT] nvram_attribute_change_reset_test(): modify MD SW version fail!\n\r"); |
| 12315 | return KAL_FALSE; |
| 12316 | } |
| 12317 | |
| 12318 | //call nvram_init() |
| 12319 | nvram_boot_trace = 0; |
| 12320 | nvram_init(); |
| 12321 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 12322 | { |
| 12323 | nvram_ut_trace("[NVUT] nvram_attribute_change_reset_test(): enter version conflict fail!\n\r"); |
| 12324 | return KAL_FALSE; |
| 12325 | } |
| 12326 | |
| 12327 | //check LID is reset |
| 12328 | for(j = 0; j < test_lid_number; j++) |
| 12329 | { |
| 12330 | nvram_util_get_data_item(&ldi, test_lid_enum[j]); |
| 12331 | d_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 12332 | c_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 12333 | kal_mem_set(c_buffer, 0x33, ldi->size); |
| 12334 | kal_mem_set(d_buffer, 0x66, ldi->size); |
| 12335 | for(i = 1; i <= ldi->total_records; i++) |
| 12336 | { |
| 12337 | nvram_get_default_value_to_write(ldi, i, c_buffer, ldi->size); |
| 12338 | nvram_external_read_data(ldi->LID, i, d_buffer, ldi->size); |
| 12339 | if(ldi->LID == NVRAM_EF_NVRAM_TEST_1_LID || ldi->LID == NVRAM_EF_NVRAM_TEST_5_LID) |
| 12340 | { |
| 12341 | if(kal_mem_cmp((kal_char*)d_buffer, (kal_char*)c_buffer, ldi->size)) |
| 12342 | { |
| 12343 | nvram_ut_trace("[NVUT] nvram_attribute_change_reset_test(): LID do not reset!\n\r"); |
| 12344 | nvram_ut_trace("[NVUT] LID: %d!\n\r", ldi->LID); |
| 12345 | free_ctrl_buffer(d_buffer); |
| 12346 | free_ctrl_buffer(c_buffer); |
| 12347 | return KAL_FALSE; |
| 12348 | } |
| 12349 | } |
| 12350 | else |
| 12351 | { |
| 12352 | if(! kal_mem_cmp((kal_char*)d_buffer, (kal_char*)c_buffer, ldi->size)) |
| 12353 | { |
| 12354 | nvram_ut_trace("[NVUT] nvram_attribute_change_reset_test(): un-expect LID reset!\n\r"); |
| 12355 | nvram_ut_trace("[NVUT] LID: %d!\n\r", ldi->LID); |
| 12356 | free_ctrl_buffer(d_buffer); |
| 12357 | free_ctrl_buffer(c_buffer); |
| 12358 | return KAL_FALSE; |
| 12359 | } |
| 12360 | } |
| 12361 | } |
| 12362 | free_ctrl_buffer(d_buffer); |
| 12363 | free_ctrl_buffer(c_buffer); |
| 12364 | } |
| 12365 | #ifdef __NVRAM_LID_CACHE__ |
| 12366 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 12367 | #endif |
| 12368 | return KAL_TRUE; |
| 12369 | } |
| 12370 | |
| 12371 | kal_bool nvram_attribute_no_change_test(kal_uint32 flags, void *param) |
| 12372 | { |
| 12373 | nvram_ltable_entry_struct *ldi = NULL; |
| 12374 | kal_uint8 *d_buffer, *c_buffer; |
| 12375 | kal_uint8 i, j; |
| 12376 | #ifdef __NVRAM_LID_CACHE__ |
| 12377 | nvram_cache_reset();//Disable NVRAM Cache |
| 12378 | #endif |
| 12379 | //reset test LIDs to default settings |
| 12380 | for(i = 0; i < test_lid_number; i++) |
| 12381 | { |
| 12382 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 12383 | { |
| 12384 | nvram_ut_trace("[NVUT] nvram_attribute_no_change_test(): reset LIDs to default setting fail!\n\r"); |
| 12385 | return KAL_FALSE; |
| 12386 | } |
| 12387 | } |
| 12388 | |
| 12389 | //reset test LIDs |
| 12390 | for(i = 0; i < test_lid_number; i++) |
| 12391 | { |
| 12392 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 12393 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 12394 | { |
| 12395 | nvram_ut_trace("[NVUT] nvram_attribute_no_change_test(): reset test LIDs fail!\n\r"); |
| 12396 | return KAL_FALSE; |
| 12397 | } |
| 12398 | } |
| 12399 | |
| 12400 | //write test LIDs to non-default |
| 12401 | nvram_write_test_lids(); |
| 12402 | |
| 12403 | //modify attribute |
| 12404 | for(i = 0; i < test_lid_number; i++) |
| 12405 | { |
| 12406 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 12407 | ldi->attr |= NVRAM_ATTR_WRITEPROTECT; //add a now reset attribute to test |
| 12408 | } |
| 12409 | |
| 12410 | //reset SYS LID |
| 12411 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 12412 | { |
| 12413 | nvram_ut_trace("[NVUT] nvram_attribute_no_change_test(): reset SYS LID fail!\n\r"); |
| 12414 | return KAL_FALSE; |
| 12415 | } |
| 12416 | |
| 12417 | //modify MD SW version |
| 12418 | if(!modify_md_sw_version()) |
| 12419 | { |
| 12420 | nvram_ut_trace("[NVUT] nvram_attribute_no_change_test(): modify MD SW version fail!\n\r"); |
| 12421 | return KAL_FALSE; |
| 12422 | } |
| 12423 | |
| 12424 | //call nvram_init() |
| 12425 | nvram_boot_trace = 0; |
| 12426 | nvram_init(); |
| 12427 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 12428 | { |
| 12429 | nvram_ut_trace("[NVUT] nvram_attribute_no_change_test(): enter version conflict fail!\n\r"); |
| 12430 | return KAL_FALSE; |
| 12431 | } |
| 12432 | |
| 12433 | //check LID is reset |
| 12434 | for(j = 0; j < test_lid_number; j++) |
| 12435 | { |
| 12436 | nvram_util_get_data_item(&ldi, test_lid_enum[j]); |
| 12437 | d_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 12438 | c_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 12439 | kal_mem_set(c_buffer, 0x33, ldi->size); |
| 12440 | kal_mem_set(d_buffer, 0x66, ldi->size); |
| 12441 | for(i = 1; i <= ldi->total_records; i++) |
| 12442 | { |
| 12443 | nvram_get_default_value_to_write(ldi, i, c_buffer, ldi->size); |
| 12444 | nvram_external_read_data(ldi->LID, i, d_buffer, ldi->size); |
| 12445 | if(! kal_mem_cmp((kal_char*)d_buffer, (kal_char*)c_buffer, ldi->size)) |
| 12446 | { |
| 12447 | nvram_ut_trace("[NVUT] nvram_attribute_no_change_test(): un-expect LID reset!\n\r"); |
| 12448 | nvram_ut_trace("[NVUT] LID: %d!\n\r", ldi->LID); |
| 12449 | free_ctrl_buffer(d_buffer); |
| 12450 | free_ctrl_buffer(c_buffer); |
| 12451 | return KAL_FALSE; |
| 12452 | } |
| 12453 | } |
| 12454 | free_ctrl_buffer(d_buffer); |
| 12455 | free_ctrl_buffer(c_buffer); |
| 12456 | } |
| 12457 | #ifdef __NVRAM_LID_CACHE__ |
| 12458 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 12459 | #endif |
| 12460 | return KAL_TRUE; |
| 12461 | } |
| 12462 | #endif |
| 12463 | |
| 12464 | kal_bool nvram_smart_reset_new_ota_old_test(kal_uint32 flags, void *param) |
| 12465 | { |
| 12466 | nvram_ltable_entry_struct *ldi = NULL; |
| 12467 | kal_uint8 *d_buffer, *c_buffer; |
| 12468 | kal_uint8 i, j; |
| 12469 | #ifdef __NVRAM_LID_CACHE__ |
| 12470 | nvram_cache_reset();//Disable NVRAM Cache |
| 12471 | #endif |
| 12472 | if(!manual_ota_reboot_finish) |
| 12473 | { |
| 12474 | #if defined(__NVRAM_STRUCTURE_CHANGE_RESET__) || defined(__NVRAM_DEFVAL_CHANGE_RESET__) |
| 12475 | #else |
| 12476 | nvram_ut_trace("[NVUT] nvram_smart_reset_new_ota_old_test(): First version is not smart reset enable!\n\r"); |
| 12477 | return KAL_FALSE; |
| 12478 | #endif |
| 12479 | //reset test LIDs to default settings |
| 12480 | for(i = 0; i < test_lid_number; i++) |
| 12481 | { |
| 12482 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 12483 | { |
| 12484 | nvram_ut_trace("[NVUT] nvram_smart_reset_new_ota_old_test(): reset LIDs to default setting fail!\n\r"); |
| 12485 | return KAL_FALSE; |
| 12486 | } |
| 12487 | } |
| 12488 | |
| 12489 | //reset test LIDs |
| 12490 | for(i = 0; i < test_lid_number; i++) |
| 12491 | { |
| 12492 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 12493 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 12494 | { |
| 12495 | nvram_ut_trace("[NVUT] nvram_smart_reset_new_ota_old_test(): reset test LIDs fail!\n\r"); |
| 12496 | return KAL_FALSE; |
| 12497 | } |
| 12498 | } |
| 12499 | |
| 12500 | //write test LIDs to non-default |
| 12501 | nvram_write_test_lids(); |
| 12502 | ota_save_context(); |
| 12503 | ota_notify_tester("Please mannual do OTA: NEW(smart reset) -> OLD(no smart reset)"); |
| 12504 | } |
| 12505 | else |
| 12506 | { |
| 12507 | manual_ota_reboot_finish = KAL_FALSE; |
| 12508 | } |
| 12509 | |
| 12510 | //check LID is reset |
| 12511 | for(j = 0; j < test_lid_number; j++) |
| 12512 | { |
| 12513 | nvram_util_get_data_item(&ldi, test_lid_enum[j]); |
| 12514 | d_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 12515 | c_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 12516 | kal_mem_set(c_buffer, 0x33, ldi->size); |
| 12517 | kal_mem_set(d_buffer, 0x66, ldi->size); |
| 12518 | for(i = 1; i <= ldi->total_records; i++) |
| 12519 | { |
| 12520 | nvram_get_default_value_to_write(ldi, i, c_buffer, ldi->size); |
| 12521 | nvram_external_read_data(ldi->LID, i, d_buffer, ldi->size); |
| 12522 | if(ldi->LID == NVRAM_EF_NVRAM_TEST_1_LID || ldi->LID == NVRAM_EF_NVRAM_TEST_5_LID) |
| 12523 | { |
| 12524 | if(kal_mem_cmp((kal_char*)d_buffer, (kal_char*)c_buffer, ldi->size)) |
| 12525 | { |
| 12526 | nvram_ut_trace("[NVUT] nvram_smart_reset_new_ota_old_test(): LID do not reset!\n\r"); |
| 12527 | nvram_ut_trace("[NVUT] LID: %d!\n\r", ldi->LID); |
| 12528 | free_ctrl_buffer(d_buffer); |
| 12529 | free_ctrl_buffer(c_buffer); |
| 12530 | return KAL_FALSE; |
| 12531 | } |
| 12532 | } |
| 12533 | else |
| 12534 | { |
| 12535 | if(! kal_mem_cmp((kal_char*)d_buffer, (kal_char*)c_buffer, ldi->size)) |
| 12536 | { |
| 12537 | nvram_ut_trace("[NVUT] nvram_smart_reset_new_ota_old_test(): un-expect LID reset!\n\r"); |
| 12538 | nvram_ut_trace("[NVUT] LID: %d!\n\r", ldi->LID); |
| 12539 | free_ctrl_buffer(d_buffer); |
| 12540 | free_ctrl_buffer(c_buffer); |
| 12541 | return KAL_FALSE; |
| 12542 | } |
| 12543 | } |
| 12544 | |
| 12545 | } |
| 12546 | free_ctrl_buffer(d_buffer); |
| 12547 | free_ctrl_buffer(c_buffer); |
| 12548 | } |
| 12549 | #ifdef __NVRAM_LID_CACHE__ |
| 12550 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 12551 | #endif |
| 12552 | return KAL_TRUE; |
| 12553 | } |
| 12554 | |
| 12555 | kal_bool nvram_smart_reset_old_ota_new_test(kal_uint32 flags, void *param) |
| 12556 | { |
| 12557 | nvram_ltable_entry_struct *ldi = NULL; |
| 12558 | kal_uint8 *d_buffer, *c_buffer; |
| 12559 | kal_uint8 i, j; |
| 12560 | #ifdef __NVRAM_LID_CACHE__ |
| 12561 | nvram_cache_reset();//Disable NVRAM Cache |
| 12562 | #endif |
| 12563 | if(!manual_ota_reboot_finish) |
| 12564 | { |
| 12565 | #if defined(__NVRAM_STRUCTURE_CHANGE_RESET__) || defined(__NVRAM_DEFVAL_CHANGE_RESET__) |
| 12566 | nvram_ut_trace("[NVUT] nvram_smart_reset_old_ota_new_test(): Second version is not no smart reset!\n\r"); |
| 12567 | return KAL_FALSE; |
| 12568 | #else |
| 12569 | #endif |
| 12570 | //reset test LIDs to default settings |
| 12571 | for(i = 0; i < test_lid_number; i++) |
| 12572 | { |
| 12573 | if(!reset_test_lid_default_setting(test_lid_enum[i])) |
| 12574 | { |
| 12575 | nvram_ut_trace("[NVUT] nvram_smart_reset_old_ota_new_test(): reset LIDs to default setting fail!\n\r"); |
| 12576 | return KAL_FALSE; |
| 12577 | } |
| 12578 | } |
| 12579 | |
| 12580 | //reset test LIDs |
| 12581 | for(i = 0; i < test_lid_number; i++) |
| 12582 | { |
| 12583 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 12584 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 12585 | { |
| 12586 | nvram_ut_trace("[NVUT] nvram_smart_reset_old_ota_new_test(): reset test LIDs fail!\n\r"); |
| 12587 | return KAL_FALSE; |
| 12588 | } |
| 12589 | } |
| 12590 | |
| 12591 | //write test LIDs to non-default |
| 12592 | nvram_write_test_lids(); |
| 12593 | ota_save_context(); |
| 12594 | ota_notify_tester("Please mannual do OTA: OLD(no smart reset) -> NEW(smart reset)"); |
| 12595 | } |
| 12596 | else |
| 12597 | { |
| 12598 | manual_ota_reboot_finish = KAL_FALSE; |
| 12599 | } |
| 12600 | |
| 12601 | //check LID is reset |
| 12602 | for(j = 0; j < test_lid_number; j++) |
| 12603 | { |
| 12604 | nvram_util_get_data_item(&ldi, test_lid_enum[j]); |
| 12605 | d_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 12606 | c_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 12607 | kal_mem_set(c_buffer, 0x33, ldi->size); |
| 12608 | kal_mem_set(d_buffer, 0x66, ldi->size); |
| 12609 | for(i = 1; i <= ldi->total_records; i++) |
| 12610 | { |
| 12611 | nvram_get_default_value_to_write(ldi, i, c_buffer, ldi->size); |
| 12612 | nvram_external_read_data(ldi->LID, i, d_buffer, ldi->size); |
| 12613 | if(ldi->LID == NVRAM_EF_NVRAM_TEST_1_LID || ldi->LID == NVRAM_EF_NVRAM_TEST_5_LID) |
| 12614 | { |
| 12615 | if(kal_mem_cmp((kal_char*)d_buffer, (kal_char*)c_buffer, ldi->size)) |
| 12616 | { |
| 12617 | nvram_ut_trace("[NVUT] nvram_smart_reset_old_ota_new_test(): LID do not reset!\n\r"); |
| 12618 | nvram_ut_trace("[NVUT] LID: %d!\n\r", ldi->LID); |
| 12619 | free_ctrl_buffer(d_buffer); |
| 12620 | free_ctrl_buffer(c_buffer); |
| 12621 | return KAL_FALSE; |
| 12622 | } |
| 12623 | } |
| 12624 | else |
| 12625 | { |
| 12626 | if(! kal_mem_cmp((kal_char*)d_buffer, (kal_char*)c_buffer, ldi->size)) |
| 12627 | { |
| 12628 | nvram_ut_trace("[NVUT] nvram_smart_reset_old_ota_new_test(): un-expect LID reset!\n\r"); |
| 12629 | nvram_ut_trace("[NVUT] LID: %d!\n\r", ldi->LID); |
| 12630 | free_ctrl_buffer(d_buffer); |
| 12631 | free_ctrl_buffer(c_buffer); |
| 12632 | return KAL_FALSE; |
| 12633 | } |
| 12634 | } |
| 12635 | |
| 12636 | } |
| 12637 | free_ctrl_buffer(d_buffer); |
| 12638 | free_ctrl_buffer(c_buffer); |
| 12639 | } |
| 12640 | #ifdef __NVRAM_LID_CACHE__ |
| 12641 | mark_nvram_cache_ready();//Enable NVRAM Cache |
| 12642 | #endif |
| 12643 | return KAL_TRUE; |
| 12644 | } |
| 12645 | |
| 12646 | kal_bool nvram_external_get_lid_info_test(kal_uint32 flags, void *param) |
| 12647 | { |
| 12648 | nvram_ltable_entry_struct ltable_entry={0}; |
| 12649 | kal_uint8 i; |
| 12650 | |
| 12651 | |
| 12652 | for(i = 0; i < test_lid_number; i++) |
| 12653 | { |
| 12654 | if(NVRAM_ERRNO_SUCCESS != nvram_external_get_lid_info(test_lid_enum[i],<able_entry)) |
| 12655 | { |
| 12656 | nvram_ut_trace("[NVUT] nvram_external_get_lid_info():get LID info fail!\n\r"); |
| 12657 | return KAL_FALSE; |
| 12658 | } |
| 12659 | nvram_ut_trace("LID info:\r\n"); |
| 12660 | nvram_ut_trace("attr:0x%x,category:0x%x\r\n",ltable_entry.attr,ltable_entry.category); |
| 12661 | nvram_ut_trace("filname:%s,verno:%s\r\n",ltable_entry.fileprefix,ltable_entry.fileverno); |
| 12662 | } |
| 12663 | return KAL_TRUE; |
| 12664 | } |
| 12665 | |
| 12666 | |
| 12667 | kal_bool nvram_ut_test1(kal_uint32 flags, void *param) |
| 12668 | { |
| 12669 | nvram_ut_trace("[NVUT] This is in nvram_ut_test1().\n\r"); |
| 12670 | return KAL_FALSE; |
| 12671 | } |
| 12672 | kal_bool nvram_ut_test2(kal_uint32 flags, void *param) |
| 12673 | { |
| 12674 | nvram_ut_trace("[NVUT] This is in nvram_ut_test2().\n\r"); |
| 12675 | return KAL_FALSE; |
| 12676 | } |
| 12677 | kal_bool nvram_ut_test3(kal_uint32 flags, void *param) |
| 12678 | { |
| 12679 | nvram_ut_trace("[NVUT] This is in nvram_ut_test3().\n\r"); |
| 12680 | return KAL_TRUE; |
| 12681 | } |
| 12682 | kal_bool nvram_ut_test4(kal_uint32 flags, void *param) |
| 12683 | { |
| 12684 | nvram_ut_trace("[NVUT] This is in nvram_ut_test4().\n\r"); |
| 12685 | return KAL_TRUE; |
| 12686 | } |
| 12687 | |
| 12688 | #ifdef __NVRAM_LID_CACHE__ |
| 12689 | |
| 12690 | kal_bool unmask_lid_all_record_valid_bit(nvram_ltable_entry_struct* ldi) |
| 12691 | { |
| 12692 | return unmask_valid_bit_by_ltable_entry(ldi,1,ldi->total_records); |
| 12693 | } |
| 12694 | |
| 12695 | kal_bool unmask_lid_all_record_dirty_bit(nvram_ltable_entry_struct* ldi) |
| 12696 | { |
| 12697 | return unmask_dirty_bit_by_ltable_entry(ldi,1,ldi->total_records); |
| 12698 | } |
| 12699 | |
| 12700 | kal_bool check_lid_all_record_is_valid_bit(nvram_ltable_entry_struct* ldi) |
| 12701 | { |
| 12702 | kal_uint8 i; |
| 12703 | for(i = 1; i <= ldi->total_records; i++) |
| 12704 | { |
| 12705 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 12706 | { |
| 12707 | return KAL_FALSE; |
| 12708 | } |
| 12709 | } |
| 12710 | return KAL_TRUE; |
| 12711 | } |
| 12712 | |
| 12713 | kal_bool check_lid_all_record_is_dirty_bit(nvram_ltable_entry_struct* ldi) |
| 12714 | { |
| 12715 | kal_uint8 i; |
| 12716 | for(i = 1; i <= ldi->total_records; i++) |
| 12717 | { |
| 12718 | if(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 12719 | { |
| 12720 | return KAL_FALSE; |
| 12721 | } |
| 12722 | } |
| 12723 | return KAL_TRUE; |
| 12724 | } |
| 12725 | |
| 12726 | kal_bool check_lid_all_record_is_invalid_bit(nvram_ltable_entry_struct* ldi) |
| 12727 | { |
| 12728 | kal_uint8 i; |
| 12729 | for(i = 1; i <= ldi->total_records; i++) |
| 12730 | { |
| 12731 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 12732 | { |
| 12733 | return KAL_FALSE; |
| 12734 | } |
| 12735 | } |
| 12736 | return KAL_TRUE; |
| 12737 | } |
| 12738 | |
| 12739 | kal_bool check_lid_all_record_is_undirty_bit(nvram_ltable_entry_struct* ldi) |
| 12740 | { |
| 12741 | kal_uint8 i; |
| 12742 | for(i = 1; i <= ldi->total_records; i++) |
| 12743 | { |
| 12744 | if(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 12745 | { |
| 12746 | return KAL_FALSE; |
| 12747 | } |
| 12748 | } |
| 12749 | return KAL_TRUE; |
| 12750 | } |
| 12751 | |
| 12752 | |
| 12753 | kal_bool first_boot_cache_access() |
| 12754 | { |
| 12755 | nvram_ltable_entry_struct *ldi = NULL; |
| 12756 | kal_uint8 *p_buffer = NULL; |
| 12757 | kal_uint8 i = 0,j = 0,count = 0; |
| 12758 | |
| 12759 | for(j = 0; j < test_lid_number; j++) |
| 12760 | { |
| 12761 | if(!NVRAM_IS_LID_VALID(test_lid_enum[j])) |
| 12762 | { |
| 12763 | return KAL_FALSE; |
| 12764 | } |
| 12765 | //reset test LIDs to default settings |
| 12766 | if( !reset_test_lid_default_setting(test_lid_enum[j]) ) |
| 12767 | { |
| 12768 | nvram_ut_trace("[NVUT] %s(): reset test LID settings fail!\n\r",__FUNCTION__); |
| 12769 | } |
| 12770 | nvram_util_get_data_item(&ldi, test_lid_enum[j]); |
| 12771 | |
| 12772 | //clean the valid and dirty bit of LID |
| 12773 | if((unmask_lid_all_record_valid_bit(ldi)!= KAL_TRUE) || (unmask_lid_all_record_dirty_bit(ldi)!= KAL_TRUE)) |
| 12774 | { |
| 12775 | nvram_ut_trace("[NVRAM UT] %s() %d: test_lid_enum[%d] valid(%d) and dirty(%d) bit check fail.\n\r",__FUNCTION__,__LINE__,j,unmask_lid_all_record_valid_bit(ldi),unmask_lid_all_record_dirty_bit(ldi)); |
| 12776 | return KAL_FALSE; |
| 12777 | } |
| 12778 | //check the defalut value of valid bit and dirty bit of the LID |
| 12779 | if((check_lid_all_record_is_invalid_bit(ldi)!= KAL_TRUE) || (check_lid_all_record_is_undirty_bit(ldi)!= KAL_TRUE)) |
| 12780 | { |
| 12781 | nvram_ut_trace("[NVRAM UT] %s() %d: test_lid_enum[%d] valid(%d) and dirty(%d) bit check fail.\n\r",__FUNCTION__,__LINE__,j,check_lid_all_record_is_invalid_bit(ldi),check_lid_all_record_is_undirty_bit(ldi)); |
| 12782 | return KAL_FALSE; |
| 12783 | } |
| 12784 | p_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 12785 | |
| 12786 | for(i = 1; i <= ldi->total_records; i++) |
| 12787 | { |
| 12788 | memset(p_buffer,0,ldi->size); |
| 12789 | if(!nvram_external_read_data(test_lid_enum[j],i,p_buffer,ldi->size)) |
| 12790 | { |
| 12791 | nvram_ut_trace("[NVUT] %s(): nvram_external_read_data fail @line %d!\n\r",__FUNCTION__,__LINE__); |
| 12792 | free_ctrl_buffer(p_buffer); |
| 12793 | return KAL_FALSE; |
| 12794 | } |
| 12795 | //check the defalut value of valid bit and dirty bit of the LID |
| 12796 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 12797 | { |
| 12798 | nvram_ut_trace("[NVUT] %s() %d: record[%d] check valid bit fail!\n\r",__FUNCTION__,__LINE__,i); |
| 12799 | free_ctrl_buffer(p_buffer); |
| 12800 | return KAL_FALSE; |
| 12801 | } |
| 12802 | if(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 12803 | { |
| 12804 | nvram_ut_trace("[NVUT] %s() %d: record[%d] check dirty bit fail!\n\r",__FUNCTION__,__LINE__,i); |
| 12805 | free_ctrl_buffer(p_buffer); |
| 12806 | return KAL_FALSE; |
| 12807 | } |
| 12808 | } |
| 12809 | |
| 12810 | for(i = 1; i <= ldi->total_records; i++) |
| 12811 | { |
| 12812 | memset(p_buffer,0,ldi->size); |
| 12813 | p_buffer[0] = 0x1; //modify some data |
| 12814 | if(ldi->size >= 3) |
| 12815 | { |
| 12816 | p_buffer[1] = 0x2; |
| 12817 | p_buffer[2] = 0x3; |
| 12818 | } |
| 12819 | if(!nvram_external_write_data(test_lid_enum[j],i,p_buffer,ldi->size)) |
| 12820 | { |
| 12821 | nvram_ut_trace("[NVUT] %s(): nvram_external_write_data fail @%d!\n\r",__FUNCTION__,__LINE__); |
| 12822 | free_ctrl_buffer(p_buffer); |
| 12823 | return KAL_FALSE; |
| 12824 | } |
| 12825 | count = 0; |
| 12826 | //check the defalut value of valid bit and dirty bit of the LID |
| 12827 | while(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) //may be optional |
| 12828 | { |
| 12829 | count ++; |
| 12830 | nvram_ut_trace("[NVUT] %s() %d: record[%d] wait(%d) data to be flushed!\n\r",__FUNCTION__,__LINE__,i,count); |
| 12831 | } |
| 12832 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 12833 | { |
| 12834 | nvram_ut_trace("[NVUT] %s() %d: record[%d] valid bit check error!\n\r",__FUNCTION__,__LINE__,i); |
| 12835 | free_ctrl_buffer(p_buffer); |
| 12836 | return KAL_FALSE; |
| 12837 | } |
| 12838 | |
| 12839 | } |
| 12840 | for(i = 1; i <= ldi->total_records; i++) |
| 12841 | { |
| 12842 | memset(p_buffer,0,ldi->size); |
| 12843 | |
| 12844 | if(!nvram_external_read_data(test_lid_enum[j],i,p_buffer,ldi->size)) |
| 12845 | { |
| 12846 | nvram_ut_trace("[NVUT] %s(): record[%d] nvram_external_read_data fail @line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 12847 | free_ctrl_buffer(p_buffer); |
| 12848 | return KAL_FALSE; |
| 12849 | } |
| 12850 | |
| 12851 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 12852 | { |
| 12853 | nvram_ut_trace("[NVUT] %s() %d: record[%d] valid bit check error!\n\r",__FUNCTION__,__LINE__,i); |
| 12854 | free_ctrl_buffer(p_buffer); |
| 12855 | return KAL_FALSE; |
| 12856 | } |
| 12857 | |
| 12858 | //check the defalut value of valid bit and dirty bit of the LID |
| 12859 | if(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) //may be optional |
| 12860 | { |
| 12861 | nvram_ut_trace("[NVUT] %s() %d: record[%d] dirty bit check error!\n\r",__FUNCTION__,__LINE__,i); |
| 12862 | } |
| 12863 | |
| 12864 | if(p_buffer[0] != 0x1) |
| 12865 | { |
| 12866 | nvram_ut_trace("[NVUT] %s() %d: record[%d] data[0]:%d error!\n\r",__FUNCTION__,__LINE__,i,p_buffer[0]); |
| 12867 | free_ctrl_buffer(p_buffer); |
| 12868 | return KAL_FALSE; |
| 12869 | } |
| 12870 | if(ldi->size >= 3) |
| 12871 | { |
| 12872 | if((p_buffer[1] != 0x2) ||(p_buffer[2] != 0x3)) |
| 12873 | { |
| 12874 | nvram_ut_trace("[NVUT] %s() %d: record[%d] data[1]:%d data[2]:%d error!\n\r",__FUNCTION__,__LINE__,i,p_buffer[1],p_buffer[2]); |
| 12875 | free_ctrl_buffer(p_buffer); |
| 12876 | return KAL_FALSE; |
| 12877 | } |
| 12878 | } |
| 12879 | |
| 12880 | } |
| 12881 | free_ctrl_buffer(p_buffer); |
| 12882 | } |
| 12883 | return KAL_TRUE; |
| 12884 | } |
| 12885 | |
| 12886 | kal_bool normal_boot_cache_access() |
| 12887 | { |
| 12888 | return first_boot_cache_access(); |
| 12889 | } |
| 12890 | |
| 12891 | kal_bool ota_boot_cache_access() |
| 12892 | { |
| 12893 | return first_boot_cache_access(); |
| 12894 | } |
| 12895 | |
| 12896 | kal_bool normal_boot_file_lost_cache_read(nvram_lid_enum LID) |
| 12897 | { |
| 12898 | nvram_ltable_entry_struct *ldi = NULL; |
| 12899 | kal_uint8 *p_buffer = NULL; |
| 12900 | kal_uint8 i; |
| 12901 | NVRAM_FILE_NAME nvramname; |
| 12902 | WCHAR filename[NVRAM_MAX_PATH_LEN]; |
| 12903 | nvram_folder_enum folder_index; |
| 12904 | kal_uint32 idx; |
| 12905 | |
| 12906 | |
| 12907 | //reset test LIDs to default settings |
| 12908 | if( !reset_test_lid_default_setting(LID) ) |
| 12909 | { |
| 12910 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): reset test LID settings fail!\n\r"); |
| 12911 | } |
| 12912 | nvram_util_get_data_item(&ldi, LID); |
| 12913 | |
| 12914 | //clean the valid and dirty bit of LID |
| 12915 | if((unmask_lid_all_record_valid_bit(ldi)!= KAL_TRUE) || (unmask_lid_all_record_dirty_bit(ldi)!= KAL_TRUE)) |
| 12916 | { |
| 12917 | nvram_ut_trace("[NVUT] %s() %d: unmask valid/dirty bit fail!\n\r",__FUNCTION__,__LINE__); |
| 12918 | return KAL_FALSE; |
| 12919 | } |
| 12920 | |
| 12921 | //check the defalut value of valid bit and dirty bit of the LID |
| 12922 | if((check_lid_all_record_is_invalid_bit(ldi)!= KAL_TRUE) || (check_lid_all_record_is_undirty_bit(ldi)!= KAL_TRUE)) |
| 12923 | { |
| 12924 | nvram_ut_trace("[NVUT] %s() %d: check valid/dirty bit fail!\n\r",__FUNCTION__,__LINE__); |
| 12925 | return KAL_FALSE; |
| 12926 | } |
| 12927 | |
| 12928 | p_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 12929 | |
| 12930 | //read all the record data of a LID |
| 12931 | for(i = 1; i <= ldi->total_records; i++) |
| 12932 | { |
| 12933 | memset(p_buffer,0,ldi->size); |
| 12934 | if(!nvram_external_read_data(LID,i,p_buffer,ldi->size)) |
| 12935 | { |
| 12936 | nvram_ut_trace("[NVUT] %s() %d: LID record[%d] cmpt operations fail @line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 12937 | free_ctrl_buffer(p_buffer); |
| 12938 | return KAL_FALSE; |
| 12939 | } |
| 12940 | //check the defalut value of valid bit and dirty bit of the LID |
| 12941 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 12942 | { |
| 12943 | nvram_ut_trace("[NVUT] %s() %d: check record[%d] valid bit fail @line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 12944 | free_ctrl_buffer(p_buffer); |
| 12945 | return KAL_FALSE; |
| 12946 | } |
| 12947 | if(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 12948 | { |
| 12949 | nvram_ut_trace("[NVUT] %s() %d: check record[%d] dirty bit fail @line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 12950 | free_ctrl_buffer(p_buffer); |
| 12951 | return KAL_FALSE; |
| 12952 | } |
| 12953 | } |
| 12954 | |
| 12955 | for (idx = 0; idx < 2; idx++) |
| 12956 | { |
| 12957 | nvram_util_make_lid_filename(ldi, nvramname, (idx==0)); |
| 12958 | folder_index = nvram_query_folder_index_ex(ldi->category, (idx==0)); |
| 12959 | nvram_query_file_name(folder_index, nvramname, filename); |
| 12960 | FS_Delete(filename); |
| 12961 | } |
| 12962 | |
| 12963 | for(i = 1; i <= ldi->total_records; i++) |
| 12964 | { |
| 12965 | memset(p_buffer,0,ldi->size); |
| 12966 | if(!nvram_external_read_data(LID,i,p_buffer,ldi->size)) |
| 12967 | { |
| 12968 | nvram_ut_trace("[NVUT] %s(): LID cmpt operations fail!\n\r",__FUNCTION__); |
| 12969 | free_ctrl_buffer(p_buffer); |
| 12970 | return KAL_FALSE; |
| 12971 | } |
| 12972 | //check the defalut value of valid bit and dirty bit of the LID |
| 12973 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 12974 | { |
| 12975 | nvram_ut_trace("[NVUT] %s(): check record[%d] valid bit fail@line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 12976 | free_ctrl_buffer(p_buffer); |
| 12977 | return KAL_FALSE; |
| 12978 | } |
| 12979 | if(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 12980 | { |
| 12981 | nvram_ut_trace("[NVUT] %s(): check record[%d]dirty bit fail @line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 12982 | free_ctrl_buffer(p_buffer); |
| 12983 | return KAL_FALSE; |
| 12984 | } |
| 12985 | } |
| 12986 | |
| 12987 | //re-create file |
| 12988 | if(nvram_cache_reset_one_data_item(ldi,1,ldi->total_records) == NVRAM_IO_ERRNO_OK) |
| 12989 | { |
| 12990 | //check the defalut value of valid bit of the LID |
| 12991 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 12992 | { |
| 12993 | nvram_ut_trace("[NVUT] %s(): check record[%d] valid bit fail @line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 12994 | free_ctrl_buffer(p_buffer); |
| 12995 | return KAL_FALSE; |
| 12996 | } |
| 12997 | } |
| 12998 | |
| 12999 | free_ctrl_buffer(p_buffer); |
| 13000 | return KAL_TRUE; |
| 13001 | } |
| 13002 | |
| 13003 | kal_bool normal_boot_file_lost_cache_read_with_recover(nvram_lid_enum LID) |
| 13004 | { |
| 13005 | nvram_ltable_entry_struct *ldi = NULL; |
| 13006 | kal_uint8 *p_buffer = NULL; |
| 13007 | kal_uint8 i; |
| 13008 | NVRAM_FILE_NAME nvramname; |
| 13009 | WCHAR filename[NVRAM_MAX_PATH_LEN]; |
| 13010 | nvram_folder_enum folder_index; |
| 13011 | kal_uint32 idx = 0,count = 0; |
| 13012 | |
| 13013 | |
| 13014 | //reset test LIDs to default settings |
| 13015 | if( !reset_test_lid_default_setting(LID) ) |
| 13016 | { |
| 13017 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): reset test LID settings fail!\n\r"); |
| 13018 | } |
| 13019 | nvram_util_get_data_item(&ldi, LID); |
| 13020 | |
| 13021 | //clean the valid and dirty bit of LID |
| 13022 | if((unmask_lid_all_record_valid_bit(ldi)!= KAL_TRUE) || (unmask_lid_all_record_dirty_bit(ldi)!= KAL_TRUE)) |
| 13023 | { |
| 13024 | nvram_ut_trace("[NVUT] %s() %d: unmask valid/dirty bit fail!\n\r",__FUNCTION__,__LINE__); |
| 13025 | return KAL_FALSE; |
| 13026 | } |
| 13027 | |
| 13028 | //check the defalut value of valid bit and dirty bit of the LID |
| 13029 | if((check_lid_all_record_is_invalid_bit(ldi)!= KAL_TRUE) || (check_lid_all_record_is_undirty_bit(ldi)!= KAL_TRUE)) |
| 13030 | { |
| 13031 | nvram_ut_trace("[NVUT] %s() %d: check valid/dirty bit fail!\n\r",__FUNCTION__,__LINE__); |
| 13032 | return KAL_FALSE; |
| 13033 | } |
| 13034 | |
| 13035 | p_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 13036 | |
| 13037 | //read all the record data of a LID |
| 13038 | for(i = 1; i <= ldi->total_records; i++) |
| 13039 | { |
| 13040 | memset(p_buffer,0,ldi->size); |
| 13041 | if(!nvram_external_read_data(LID,i,p_buffer,ldi->size)) |
| 13042 | { |
| 13043 | nvram_ut_trace("[NVUT] %s(): LID record[%d] cmpt operations fail @line%d!\n\r",__FUNCTION__,i,__LINE__); |
| 13044 | free_ctrl_buffer(p_buffer); |
| 13045 | return KAL_FALSE; |
| 13046 | } |
| 13047 | //check the defalut value of valid bit and dirty bit of the LID |
| 13048 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 13049 | { |
| 13050 | nvram_ut_trace("[NVUT] %s(): check record[%d] valid bit fail @line%d!\n\r",__FUNCTION__,i,__LINE__); |
| 13051 | free_ctrl_buffer(p_buffer); |
| 13052 | return KAL_FALSE; |
| 13053 | } |
| 13054 | if(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 13055 | { |
| 13056 | nvram_ut_trace("[NVUT] %s(): check record[%d] dirty bit fail @line%d!\n\r",__FUNCTION__,i,__LINE__); |
| 13057 | free_ctrl_buffer(p_buffer); |
| 13058 | return KAL_FALSE; |
| 13059 | } |
| 13060 | } |
| 13061 | |
| 13062 | for (idx = 0; idx < 2; idx++) |
| 13063 | { |
| 13064 | nvram_util_make_lid_filename(ldi, nvramname, (idx==0)); |
| 13065 | folder_index = nvram_query_folder_index_ex(ldi->category, (idx==0)); |
| 13066 | nvram_query_file_name(folder_index, nvramname, filename); |
| 13067 | FS_Delete(filename); |
| 13068 | } |
| 13069 | |
| 13070 | if((unmask_lid_all_record_valid_bit(ldi)!= KAL_TRUE) || (unmask_lid_all_record_dirty_bit(ldi)!= KAL_TRUE)) |
| 13071 | { |
| 13072 | nvram_ut_trace("[NVUT] %s() %d: unmask valid/dirty bit fail!\n\r",__FUNCTION__,__LINE__); |
| 13073 | free_ctrl_buffer(p_buffer); |
| 13074 | return KAL_FALSE; |
| 13075 | } |
| 13076 | |
| 13077 | for(i = 1; i <= ldi->total_records; i++) |
| 13078 | { |
| 13079 | memset(p_buffer,0,ldi->size); |
| 13080 | if(!nvram_external_read_data(LID,i,p_buffer,ldi->size)) |
| 13081 | { |
| 13082 | nvram_ut_trace("[NVUT] %s(): LID record[%d] cmpt operations fail@ line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 13083 | free_ctrl_buffer(p_buffer); |
| 13084 | return KAL_FALSE; |
| 13085 | } |
| 13086 | count = 0; |
| 13087 | //check the defalut value of valid bit and dirty bit of the LID |
| 13088 | while(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 13089 | { |
| 13090 | nvram_ut_trace("[NVUT] %s():record[%d] wait(%d) valid bit become true@line %d !\n\r",__FUNCTION__,i,count,__LINE__); |
| 13091 | count++; |
| 13092 | } |
| 13093 | if(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 13094 | { |
| 13095 | nvram_ut_trace("[NVUT] %s():check record[%d] dirty bit fail at line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 13096 | free_ctrl_buffer(p_buffer); |
| 13097 | return KAL_FALSE; |
| 13098 | } |
| 13099 | } |
| 13100 | free_ctrl_buffer(p_buffer); |
| 13101 | return KAL_TRUE; |
| 13102 | } |
| 13103 | |
| 13104 | |
| 13105 | kal_bool normal_boot_user_lost_cache_read() |
| 13106 | { |
| 13107 | return normal_boot_file_lost_cache_read(NVRAM_EF_NVRAM_TEST_1_LID); |
| 13108 | } |
| 13109 | |
| 13110 | kal_bool nvram_boot_calibrate_lost_cache_read() |
| 13111 | { |
| 13112 | return normal_boot_file_lost_cache_read(NVRAM_EF_NVRAM_TEST_3_LID); |
| 13113 | } |
| 13114 | |
| 13115 | kal_bool nvram_boot_important_lost_cache_read() |
| 13116 | { |
| 13117 | return normal_boot_file_lost_cache_read(NVRAM_EF_NVRAM_TEST_4_LID); |
| 13118 | } |
| 13119 | |
| 13120 | kal_bool nvram_boot_important_l4_lost_cache_read() |
| 13121 | { |
| 13122 | return normal_boot_file_lost_cache_read(NVRAM_EF_NVRAM_TEST_6_LID); |
| 13123 | } |
| 13124 | |
| 13125 | kal_bool normal_boot_user_lost_cache_read_with_recover() |
| 13126 | { |
| 13127 | return normal_boot_file_lost_cache_read_with_recover(NVRAM_EF_NVRAM_TEST_1_LID); |
| 13128 | } |
| 13129 | |
| 13130 | kal_bool nvram_boot_calibrate_lost_cache_read_with_recover() |
| 13131 | { |
| 13132 | return normal_boot_file_lost_cache_read_with_recover(NVRAM_EF_NVRAM_TEST_3_LID); |
| 13133 | } |
| 13134 | |
| 13135 | kal_bool nvram_boot_important_lost_cache_read_with_recover() |
| 13136 | { |
| 13137 | return normal_boot_file_lost_cache_read_with_recover(NVRAM_EF_NVRAM_TEST_4_LID); |
| 13138 | } |
| 13139 | |
| 13140 | kal_bool nvram_boot_important_l4_lost_cache_read_with_recover() |
| 13141 | { |
| 13142 | return normal_boot_file_lost_cache_read_with_recover(NVRAM_EF_NVRAM_TEST_6_LID); |
| 13143 | } |
| 13144 | |
| 13145 | |
| 13146 | extern kal_int32 nvram_recover_data_item(nvram_ltable_entry_struct *ldi); |
| 13147 | |
| 13148 | kal_bool nvram_cache_valid_bit_after_recover() |
| 13149 | { |
| 13150 | nvram_ltable_entry_struct *ldi = NULL; |
| 13151 | kal_uint8 *p_buffer = NULL; |
| 13152 | kal_uint8 i,j; |
| 13153 | NVRAM_FILE_NAME nvramname; |
| 13154 | WCHAR filename[NVRAM_MAX_PATH_LEN]; |
| 13155 | nvram_folder_enum folder_index; |
| 13156 | kal_uint32 idx; |
| 13157 | for(j = 0; j < test_lid_number; j++) |
| 13158 | { |
| 13159 | if(!NVRAM_IS_LID_VALID(test_lid_enum[j])) |
| 13160 | { |
| 13161 | return KAL_FALSE; |
| 13162 | } |
| 13163 | |
| 13164 | //read all the record data of a LID |
| 13165 | nvram_util_get_data_item(&ldi, test_lid_enum[j]); |
| 13166 | |
| 13167 | //clean the valid and dirty bit of LID |
| 13168 | if((unmask_lid_all_record_valid_bit(ldi)!= KAL_TRUE) || (unmask_lid_all_record_dirty_bit(ldi)!= KAL_TRUE)) |
| 13169 | { |
| 13170 | nvram_ut_trace("[NVUT] %s() %d: unmask valid/dirty bit fail!\n\r",__FUNCTION__,__LINE__); |
| 13171 | return KAL_FALSE; |
| 13172 | } |
| 13173 | |
| 13174 | //check the defalut value of valid bit and dirty bit of the LID |
| 13175 | if((check_lid_all_record_is_invalid_bit(ldi)!= KAL_TRUE) || (check_lid_all_record_is_undirty_bit(ldi)!= KAL_TRUE)) |
| 13176 | { |
| 13177 | nvram_ut_trace("[NVUT] %s() %d: check invalid/undirty bit fail!\n\r",__FUNCTION__,__LINE__); |
| 13178 | return KAL_FALSE; |
| 13179 | } |
| 13180 | p_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 13181 | |
| 13182 | for(i = 1; i <= ldi->total_records; i++) |
| 13183 | { |
| 13184 | memset(p_buffer,0,ldi->size); |
| 13185 | if(!nvram_external_read_data(test_lid_enum[j],i,p_buffer,ldi->size)) |
| 13186 | { |
| 13187 | nvram_ut_trace("[NVUT] %s() : nvram_external_read_data record[%d] fail at line%d!\n\r",__FUNCTION__,i,__LINE__); |
| 13188 | free_ctrl_buffer(p_buffer); |
| 13189 | return KAL_FALSE; |
| 13190 | } |
| 13191 | //check the defalut value of valid bit and dirty bit of the LID |
| 13192 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 13193 | { |
| 13194 | nvram_ut_trace("[NVUT] %s(): check record[%d] dirty bit fail@line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 13195 | free_ctrl_buffer(p_buffer); |
| 13196 | return KAL_FALSE; |
| 13197 | } |
| 13198 | if(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 13199 | { |
| 13200 | nvram_ut_trace("[NVUT] %s(): check record[%d] dirty bit fail@line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 13201 | free_ctrl_buffer(p_buffer); |
| 13202 | return KAL_FALSE; |
| 13203 | } |
| 13204 | } |
| 13205 | |
| 13206 | for (idx = 0; idx < 2; idx++) |
| 13207 | { |
| 13208 | nvram_util_make_lid_filename(ldi, nvramname, (idx==0)); |
| 13209 | folder_index = nvram_query_folder_index_ex(ldi->category, (idx==0)); |
| 13210 | nvram_query_file_name(folder_index, nvramname, filename); |
| 13211 | |
| 13212 | FS_Delete(filename); |
| 13213 | } |
| 13214 | if(NVRAM_IS_CATEGORY_IN_BIN_REGION(ldi->category)) |
| 13215 | { |
| 13216 | if(nvram_recover_data_item(ldi) == NVRAM_IO_ERRNO_OK) |
| 13217 | { |
| 13218 | //check the defalut value of valid bit of the LID |
| 13219 | if(check_lid_all_record_is_valid_bit(ldi)!= KAL_FALSE) |
| 13220 | { |
| 13221 | nvram_ut_trace("[NVUT] %s() %d: check all valid bit fail!\n\r",__FUNCTION__,__LINE__); |
| 13222 | free_ctrl_buffer(p_buffer); |
| 13223 | return KAL_FALSE; |
| 13224 | } |
| 13225 | } |
| 13226 | else |
| 13227 | { |
| 13228 | nvram_ut_trace("[NVUT] %s() %d: recover data fail!\n\r",__FUNCTION__,__LINE__); |
| 13229 | free_ctrl_buffer(p_buffer); |
| 13230 | return KAL_FALSE; |
| 13231 | } |
| 13232 | } |
| 13233 | else |
| 13234 | { |
| 13235 | //reset LID to default |
| 13236 | if(nvram_cache_reset_one_data_item(ldi,1,ldi->total_records) == NVRAM_IO_ERRNO_OK) |
| 13237 | { |
| 13238 | //check the defalut value of valid bit of the LID |
| 13239 | if(check_lid_all_record_is_valid_bit(ldi)!= KAL_FALSE) |
| 13240 | { |
| 13241 | nvram_ut_trace("[NVUT] %s(): check valid bit fail@line %d!\n\r",__FUNCTION__,__LINE__); |
| 13242 | free_ctrl_buffer(p_buffer); |
| 13243 | return KAL_FALSE; |
| 13244 | } |
| 13245 | } |
| 13246 | else |
| 13247 | { |
| 13248 | nvram_ut_trace("[NVUT] %s(): cache reset LID (%d)fail @line %d!\n\r",__FUNCTION__,ldi->LID,__LINE__); |
| 13249 | free_ctrl_buffer(p_buffer); |
| 13250 | return KAL_FALSE; |
| 13251 | } |
| 13252 | } |
| 13253 | |
| 13254 | free_ctrl_buffer(p_buffer); |
| 13255 | } |
| 13256 | return KAL_TRUE; |
| 13257 | } |
| 13258 | |
| 13259 | |
| 13260 | kal_bool normal_boot_file_lost_cache_write(nvram_lid_enum LID) |
| 13261 | { |
| 13262 | nvram_ltable_entry_struct *ldi = NULL; |
| 13263 | kal_uint8 *p_buffer = NULL; |
| 13264 | kal_uint8 i; |
| 13265 | NVRAM_FILE_NAME nvramname; |
| 13266 | WCHAR filename[NVRAM_MAX_PATH_LEN]; |
| 13267 | nvram_folder_enum folder_index; |
| 13268 | kal_uint32 idx =0,count=0; |
| 13269 | |
| 13270 | //reset test LIDs to default settings |
| 13271 | if( !reset_test_lid_default_setting(LID) ) |
| 13272 | { |
| 13273 | nvram_ut_trace("[NVUT] raw_data_access_function_test(): reset test LID settings fail!\n\r"); |
| 13274 | } |
| 13275 | |
| 13276 | nvram_util_get_data_item(&ldi, LID); |
| 13277 | //clean the valid and dirty bit of LID |
| 13278 | if((unmask_lid_all_record_valid_bit(ldi)!= KAL_TRUE) || (unmask_lid_all_record_dirty_bit(ldi)!= KAL_TRUE)) |
| 13279 | { |
| 13280 | nvram_ut_trace("[NVUT] %s() %d: unmask all record valid/dirty bit fail!\n\r",__FUNCTION__,__LINE__); |
| 13281 | return KAL_FALSE; |
| 13282 | } |
| 13283 | |
| 13284 | //check the defalut value of valid bit and dirty bit of the LID |
| 13285 | if((check_lid_all_record_is_invalid_bit(ldi)!= KAL_TRUE) || (check_lid_all_record_is_undirty_bit(ldi)!= KAL_TRUE)) |
| 13286 | { |
| 13287 | nvram_ut_trace("[NVUT] %s() %d: check all record invalid/undirty bit fail!\n\r",__FUNCTION__,__LINE__); |
| 13288 | return KAL_FALSE; |
| 13289 | } |
| 13290 | |
| 13291 | p_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 13292 | |
| 13293 | for(i = 1; i <= ldi->total_records; i++) |
| 13294 | { |
| 13295 | memset(p_buffer,0,ldi->size); |
| 13296 | if(!nvram_external_read_data(LID,i,p_buffer,ldi->size)) |
| 13297 | { |
| 13298 | nvram_ut_trace("[NVUT] %s(): LID cmpt operations fail!\n\r",__FUNCTION__); |
| 13299 | free_ctrl_buffer(p_buffer); |
| 13300 | return KAL_FALSE; |
| 13301 | } |
| 13302 | //check the defalut value of valid bit and dirty bit of the LID |
| 13303 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 13304 | { |
| 13305 | free_ctrl_buffer(p_buffer); |
| 13306 | return KAL_FALSE; |
| 13307 | } |
| 13308 | count = 0; |
| 13309 | while(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 13310 | { |
| 13311 | count ++; |
| 13312 | nvram_ut_trace("[NVUT] %s() %d: wait(%d) data to be flushed!\n\r",__FUNCTION__,__LINE__,count); |
| 13313 | } |
| 13314 | } |
| 13315 | |
| 13316 | for (idx = 0; idx < 2; idx++) |
| 13317 | { |
| 13318 | nvram_util_make_lid_filename(ldi, nvramname, (idx==0)); |
| 13319 | folder_index = nvram_query_folder_index_ex(ldi->category, (idx==0)); |
| 13320 | nvram_query_file_name(folder_index, nvramname, filename); |
| 13321 | |
| 13322 | FS_Delete(filename); |
| 13323 | } |
| 13324 | |
| 13325 | //set flag to disable cache flush |
| 13326 | |
| 13327 | |
| 13328 | for(i = 1; i <= ldi->total_records; ) |
| 13329 | { |
| 13330 | memset(p_buffer,0,ldi->size); |
| 13331 | p_buffer[0] = 0x1; //modify some data |
| 13332 | if(ldi->size >= 3) |
| 13333 | { |
| 13334 | p_buffer[1] = 0x2; |
| 13335 | p_buffer[2] = 0x3; |
| 13336 | } |
| 13337 | |
| 13338 | unmask_valid_bit_by_ltable_entry(ldi,i,1); |
| 13339 | if(!nvram_external_write_data(LID,i,p_buffer,ldi->size)) |
| 13340 | { |
| 13341 | nvram_ut_trace("[NVUT] %s(): LID cmpt operations fail!\n\r",__FUNCTION__); |
| 13342 | free_ctrl_buffer(p_buffer); |
| 13343 | return KAL_FALSE; |
| 13344 | } |
| 13345 | count = 0; |
| 13346 | //check the defalut value of valid bit and dirty bit of the LID |
| 13347 | while(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 13348 | { |
| 13349 | count++; |
| 13350 | nvram_ut_trace("[NVUT] %s(): wait(%d) the data has to be flushed!\n\r",__FUNCTION__,count); |
| 13351 | } |
| 13352 | while(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 13353 | { |
| 13354 | nvram_ut_trace("[NVUT] %s(): check_dirty_bit_by_ltable_entry fail at line %d!\n\r",__FUNCTION__,__LINE__); |
| 13355 | } |
| 13356 | i = i +2; |
| 13357 | } |
| 13358 | |
| 13359 | for(i = 1; i <= ldi->total_records; i+=2) |
| 13360 | { |
| 13361 | memset(p_buffer,0,ldi->size); |
| 13362 | if(!nvram_external_read_data(LID,i,p_buffer,ldi->size)) |
| 13363 | { |
| 13364 | nvram_ut_trace("[NVUT] %s(): nvram_external_read_data fail at line %d!\n\r",__FUNCTION__,__LINE__); |
| 13365 | free_ctrl_buffer(p_buffer); |
| 13366 | return KAL_FALSE; |
| 13367 | } |
| 13368 | if(p_buffer[0] != 0x1) |
| 13369 | { |
| 13370 | free_ctrl_buffer(p_buffer); |
| 13371 | return KAL_FALSE; |
| 13372 | } |
| 13373 | if(ldi->size >= 3) |
| 13374 | { |
| 13375 | if((p_buffer[1] != 0x2) ||(p_buffer[2] != 0x3)) |
| 13376 | { |
| 13377 | free_ctrl_buffer(p_buffer); |
| 13378 | return KAL_FALSE; |
| 13379 | } |
| 13380 | } |
| 13381 | //check the defalut value of valid bit and dirty bit of the LID |
| 13382 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 13383 | { |
| 13384 | free_ctrl_buffer(p_buffer); |
| 13385 | return KAL_FALSE; |
| 13386 | } |
| 13387 | //Maybe optional |
| 13388 | if(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 13389 | { |
| 13390 | free_ctrl_buffer(p_buffer); |
| 13391 | return KAL_FALSE; |
| 13392 | } |
| 13393 | } |
| 13394 | free_ctrl_buffer(p_buffer); |
| 13395 | return KAL_TRUE; |
| 13396 | } |
| 13397 | |
| 13398 | kal_bool normal_boot_user_lost_cache_write() |
| 13399 | { |
| 13400 | return normal_boot_file_lost_cache_write(NVRAM_EF_NVRAM_TEST_1_LID); |
| 13401 | } |
| 13402 | |
| 13403 | kal_bool normal_boot_calibrate_lost_cache_write() |
| 13404 | { |
| 13405 | return normal_boot_file_lost_cache_write(NVRAM_EF_NVRAM_TEST_3_LID); |
| 13406 | } |
| 13407 | |
| 13408 | kal_bool normal_boot_important_lost_cache_write() |
| 13409 | { |
| 13410 | return normal_boot_file_lost_cache_write(NVRAM_EF_NVRAM_TEST_4_LID); |
| 13411 | } |
| 13412 | |
| 13413 | kal_bool normal_boot_important_l4_lost_cache_write() |
| 13414 | { |
| 13415 | return normal_boot_file_lost_cache_write(NVRAM_EF_NVRAM_TEST_6_LID); |
| 13416 | } |
| 13417 | |
| 13418 | #define CACHE_READ_COUNT (100) |
| 13419 | kal_bool nvram_cache_read_performance_chek() |
| 13420 | { |
| 13421 | nvram_ltable_entry_struct *ldi = NULL; |
| 13422 | kal_uint8 *p_buffer = NULL; |
| 13423 | kal_uint8 i; |
| 13424 | kal_uint32 start_time; |
| 13425 | kal_uint32 end_time; |
| 13426 | kal_uint32 during_time; |
| 13427 | kal_uint32 consum_time[2]={0,0}; |
| 13428 | |
| 13429 | // reset and backup data into data_buffer |
| 13430 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID)) |
| 13431 | { |
| 13432 | nvram_ut_trace("[NVUT] %s():rest test lid fail!\n\r", __FUNCTION__); |
| 13433 | return KAL_FALSE; |
| 13434 | } |
| 13435 | |
| 13436 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 13437 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 13438 | { |
| 13439 | nvram_ut_trace("[NVUT] %s(): reset test LIDs fail!\n\r", __FUNCTION__); |
| 13440 | return KAL_FALSE; |
| 13441 | } |
| 13442 | |
| 13443 | //clean and check the valid and dirty bit of LID |
| 13444 | if((unmask_lid_all_record_valid_bit(ldi)!= KAL_TRUE) || (unmask_lid_all_record_dirty_bit(ldi)!= KAL_TRUE)) |
| 13445 | { |
| 13446 | nvram_ut_trace("[NVUT] %s() %d: unmask valid/dirty bit fail!\n\r",__FUNCTION__,__LINE__); |
| 13447 | return KAL_FALSE; |
| 13448 | } |
| 13449 | |
| 13450 | p_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size*ldi->total_records); |
| 13451 | |
| 13452 | //read all the record data of a LID |
| 13453 | start_time = ust_get_current_time(); |
| 13454 | if(!nvram_external_read_multi_record(NVRAM_EF_NVRAM_TEST_1_LID,1,ldi->total_records,p_buffer,ldi->size*ldi->total_records)) |
| 13455 | { |
| 13456 | nvram_ut_trace("[NVUT] %s(): LID cmpt operations fail!\n\r",__FUNCTION__); |
| 13457 | free_ctrl_buffer(p_buffer); |
| 13458 | return KAL_FALSE; |
| 13459 | } |
| 13460 | end_time = ust_get_current_time(); |
| 13461 | consum_time[0] = end_time - start_time; |
| 13462 | |
| 13463 | for(i = 0; i < CACHE_READ_COUNT ; i++) |
| 13464 | { |
| 13465 | memset(p_buffer,0,ldi->size); |
| 13466 | start_time = ust_get_current_time(); |
| 13467 | if(!nvram_external_read_multi_record(NVRAM_EF_NVRAM_TEST_1_LID,1,ldi->total_records,p_buffer,ldi->size*ldi->total_records)) |
| 13468 | { |
| 13469 | nvram_ut_trace("[NVUT] %s(): LID cmpt operations fail!\n\r",__FUNCTION__); |
| 13470 | free_ctrl_buffer(p_buffer); |
| 13471 | return KAL_FALSE; |
| 13472 | } |
| 13473 | end_time = ust_get_current_time(); |
| 13474 | during_time = end_time - start_time; |
| 13475 | if(consum_time[0] <= during_time ) |
| 13476 | { |
| 13477 | free_ctrl_buffer(p_buffer); |
| 13478 | return KAL_FALSE; |
| 13479 | } |
| 13480 | consum_time[1] += during_time; |
| 13481 | } |
| 13482 | nvram_ut_trace("[NVUT] %s(): LID non-cache read average time:%u \n\r", __FUNCTION__, consum_time[0]); |
| 13483 | nvram_ut_trace("[NVUT] %s(): LID cache read total time:%u \n\r",__FUNCTION__, consum_time[1]); |
| 13484 | //compare the read time |
| 13485 | consum_time[1] = consum_time[1]/CACHE_READ_COUNT; |
| 13486 | nvram_ut_trace("[NVUT] %s(): LID cache read average time:%u \n\r",__FUNCTION__, consum_time[1]); |
| 13487 | if(consum_time[0] < consum_time[1]) |
| 13488 | { |
| 13489 | free_ctrl_buffer(p_buffer); |
| 13490 | return KAL_FALSE; |
| 13491 | } |
| 13492 | free_ctrl_buffer(p_buffer); |
| 13493 | return KAL_TRUE; |
| 13494 | } |
| 13495 | |
| 13496 | kal_bool nvram_cache_write_performance_chek() |
| 13497 | { |
| 13498 | nvram_ltable_entry_struct *ldi = NULL; |
| 13499 | kal_uint8 *p_buffer = NULL; |
| 13500 | kal_uint8 i; |
| 13501 | kal_uint32 start_time; |
| 13502 | kal_uint32 end_time; |
| 13503 | kal_uint32 during_time; |
| 13504 | kal_uint32 consum_time[2]={0,0}; |
| 13505 | |
| 13506 | // reset and backup data into data_buffer |
| 13507 | if(!reset_test_lid_default_setting(NVRAM_EF_NVRAM_TEST_1_LID)) |
| 13508 | { |
| 13509 | nvram_ut_trace("[NVUT] %s():rest test lid fail!\n\r", __FUNCTION__); |
| 13510 | return KAL_FALSE; |
| 13511 | } |
| 13512 | |
| 13513 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_1_LID); |
| 13514 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 13515 | { |
| 13516 | nvram_ut_trace("[NVUT] %s(): reset test LIDs fail!\n\r", __FUNCTION__); |
| 13517 | return KAL_FALSE; |
| 13518 | } |
| 13519 | |
| 13520 | //clean and check the valid and dirty bit of LID |
| 13521 | if((unmask_lid_all_record_valid_bit(ldi)!= KAL_TRUE) || (unmask_lid_all_record_dirty_bit(ldi)!= KAL_TRUE)) |
| 13522 | { |
| 13523 | nvram_ut_trace("[NVUT] %s() %d: unmask valid/dirty bit fail!\n\r",__FUNCTION__,__LINE__); |
| 13524 | return KAL_FALSE; |
| 13525 | } |
| 13526 | |
| 13527 | //disable the cache funtion |
| 13528 | unmark_nvram_cache_ready(); |
| 13529 | p_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size*ldi->total_records); |
| 13530 | |
| 13531 | //write all the record data of a LID |
| 13532 | for(i= 1; i <= ldi->total_records; i++) |
| 13533 | { |
| 13534 | start_time = ust_get_current_time(); |
| 13535 | if(!nvram_external_write_data(NVRAM_EF_NVRAM_TEST_1_LID,i,p_buffer,ldi->size)) |
| 13536 | { |
| 13537 | nvram_ut_trace("[NVUT] %s(): LID cmpt operations fail!\n\r",__FUNCTION__); |
| 13538 | free_ctrl_buffer(p_buffer); |
| 13539 | return KAL_FALSE; |
| 13540 | } |
| 13541 | end_time = ust_get_current_time(); |
| 13542 | nvram_ut_trace("[NVUT] %s(): LID non-cache write time:%u \n\r", __FUNCTION__, (end_time - start_time)); |
| 13543 | consum_time[0] += (end_time - start_time); |
| 13544 | } |
| 13545 | nvram_ut_trace("[NVUT] %s(): LID non-cache write total time:%u \n\r",__FUNCTION__, consum_time[0]); |
| 13546 | |
| 13547 | consum_time[0] = consum_time[0]/ldi->total_records; |
| 13548 | nvram_ut_trace("[NVUT] %s(): LID non-cache write average time:%u \n\r", __FUNCTION__, consum_time[0]); |
| 13549 | //Enable the cache funtion |
| 13550 | mark_nvram_cache_ready(); |
| 13551 | for(i= 0; i < ldi->total_records; i++) |
| 13552 | { |
| 13553 | start_time = ust_get_current_time(); |
| 13554 | nvram_external_write_data(NVRAM_EF_NVRAM_TEST_1_LID,i+1,p_buffer,ldi->size); |
| 13555 | end_time = ust_get_current_time(); |
| 13556 | during_time = end_time - start_time; |
| 13557 | if(consum_time[0] <= during_time) |
| 13558 | { |
| 13559 | //free_ctrl_buffer(p_buffer); |
| 13560 | //return KAL_FALSE; |
| 13561 | nvram_ut_trace("[NVUT] %s(): LID cache write During time:%u \n\r", __FUNCTION__, during_time); |
| 13562 | } |
| 13563 | consum_time[1] += during_time; |
| 13564 | } |
| 13565 | nvram_ut_trace("[NVUT] %s(): LID cache write total time:%u \n\r",__FUNCTION__, consum_time[1]); |
| 13566 | |
| 13567 | consum_time[1] = consum_time[1]/ldi->total_records; |
| 13568 | nvram_ut_trace("[NVUT] %s(): LID cache write average time:%u \n\r", __FUNCTION__, consum_time[1]); |
| 13569 | |
| 13570 | if(consum_time[0] < consum_time[1]) |
| 13571 | { |
| 13572 | free_ctrl_buffer(p_buffer); |
| 13573 | return KAL_FALSE; |
| 13574 | } |
| 13575 | |
| 13576 | free_ctrl_buffer(p_buffer); |
| 13577 | return KAL_TRUE; |
| 13578 | } |
| 13579 | |
| 13580 | kal_bool nvram_cache_read_data_less_than_16K() |
| 13581 | { |
| 13582 | nvram_ltable_entry_struct *ldi = NULL; |
| 13583 | kal_uint8 *p_buffer = NULL; |
| 13584 | kal_uint32 i = 0,j = 0,count = 0; |
| 13585 | |
| 13586 | if(!NVRAM_IS_LID_VALID(NVRAM_EF_INTERNAL_TEST_14_LID)) |
| 13587 | { |
| 13588 | return KAL_FALSE; |
| 13589 | } |
| 13590 | //reset test LIDs to default settings |
| 13591 | if( !reset_test_lid_default_setting(NVRAM_EF_INTERNAL_TEST_14_LID) ) |
| 13592 | { |
| 13593 | nvram_ut_trace("[NVUT] %s(): reset test LID settings fail!\n\r",__FUNCTION__); |
| 13594 | } |
| 13595 | nvram_util_get_data_item(&ldi, NVRAM_EF_INTERNAL_TEST_14_LID); |
| 13596 | nvram_ut_trace("[NVUT] %s(): LID->attr=(%x) \n\r", __FUNCTION__, ldi->attr); |
| 13597 | |
| 13598 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 13599 | { |
| 13600 | nvram_ut_trace("[NVUT] %s(): reset test LIDs fail!\n\r", __FUNCTION__); |
| 13601 | return KAL_FALSE; |
| 13602 | } |
| 13603 | |
| 13604 | //clean the valid and dirty bit of LID |
| 13605 | if((unmask_lid_all_record_valid_bit(ldi)!= KAL_TRUE) || (unmask_lid_all_record_dirty_bit(ldi)!= KAL_TRUE)) |
| 13606 | { |
| 13607 | nvram_ut_trace("[NVRAM UT] %s() %d: test_lid_enum[%d] valid(%d) and dirty(%d) bit check fail.\n\r",__FUNCTION__,__LINE__,j,unmask_lid_all_record_valid_bit(ldi),unmask_lid_all_record_dirty_bit(ldi)); |
| 13608 | return KAL_FALSE; |
| 13609 | } |
| 13610 | //check the defalut value of valid bit and dirty bit of the LID |
| 13611 | if((check_lid_all_record_is_invalid_bit(ldi)!= KAL_TRUE) || (check_lid_all_record_is_undirty_bit(ldi)!= KAL_TRUE)) |
| 13612 | { |
| 13613 | nvram_ut_trace("[NVRAM UT] %s() %d: test_lid_enum[%d] valid(%d) and dirty(%d) bit check fail.\n\r",__FUNCTION__,__LINE__,j,check_lid_all_record_is_invalid_bit(ldi),check_lid_all_record_is_undirty_bit(ldi)); |
| 13614 | return KAL_FALSE; |
| 13615 | } |
| 13616 | p_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 13617 | |
| 13618 | memset(p_buffer,0,ldi->size); |
| 13619 | if(!nvram_external_read_data(NVRAM_EF_INTERNAL_TEST_14_LID,1,p_buffer,ldi->size)) |
| 13620 | { |
| 13621 | nvram_ut_trace("[NVUT] %s(): nvram_external_read_data fail @line %d!\n\r",__FUNCTION__,__LINE__); |
| 13622 | free_ctrl_buffer(p_buffer); |
| 13623 | return KAL_FALSE; |
| 13624 | } |
| 13625 | |
| 13626 | if(p_buffer[0] != 1) |
| 13627 | { |
| 13628 | nvram_ut_trace("[NVUT] %s() %d: record[1] check data fail(data[0]!=1) p_buffer=%d !\n\r",__FUNCTION__,__LINE__, *((kal_uint32 *)p_buffer)); |
| 13629 | free_ctrl_buffer(p_buffer); |
| 13630 | return KAL_FALSE; |
| 13631 | } |
| 13632 | |
| 13633 | for(j = 1; j < ldi->size; j++) |
| 13634 | { |
| 13635 | if(p_buffer[j] != 0) |
| 13636 | { |
| 13637 | nvram_ut_trace("[NVUT] %s() %d: record[1] check data fail(data[%d]!=0)!\n\r",__FUNCTION__,__LINE__,j); |
| 13638 | free_ctrl_buffer(p_buffer); |
| 13639 | return KAL_FALSE; |
| 13640 | } |
| 13641 | } |
| 13642 | |
| 13643 | for(i = 1; i <= ldi->total_records; i++) |
| 13644 | { |
| 13645 | //check the defalut value of valid bit and dirty bit of the LID |
| 13646 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 13647 | { |
| 13648 | nvram_ut_trace("[NVUT] %s() %d: record[%d] check valid bit fail!\n\r",__FUNCTION__,__LINE__,i); |
| 13649 | free_ctrl_buffer(p_buffer); |
| 13650 | return KAL_FALSE; |
| 13651 | } |
| 13652 | if(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 13653 | { |
| 13654 | nvram_ut_trace("[NVUT] %s() %d: record[%d] check dirty bit fail!\n\r",__FUNCTION__,__LINE__,i); |
| 13655 | free_ctrl_buffer(p_buffer); |
| 13656 | return KAL_FALSE; |
| 13657 | } |
| 13658 | } |
| 13659 | |
| 13660 | for(i = 1; i <= ldi->total_records; i++) |
| 13661 | { |
| 13662 | memset(p_buffer,0,ldi->size); |
| 13663 | p_buffer[0] = 0x1; //modify some data |
| 13664 | if(ldi->size >= 3) |
| 13665 | { |
| 13666 | p_buffer[1] = 0x2; |
| 13667 | p_buffer[2] = 0x3; |
| 13668 | } |
| 13669 | if(!nvram_external_write_data(NVRAM_EF_INTERNAL_TEST_14_LID,i,p_buffer,ldi->size)) |
| 13670 | { |
| 13671 | nvram_ut_trace("[NVUT] %s(): nvram_external_write_data fail @%d!\n\r",__FUNCTION__,__LINE__); |
| 13672 | free_ctrl_buffer(p_buffer); |
| 13673 | return KAL_FALSE; |
| 13674 | } |
| 13675 | count = 0; |
| 13676 | //check the defalut value of valid bit and dirty bit of the LID |
| 13677 | while(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) //may be optional |
| 13678 | { |
| 13679 | count ++; |
| 13680 | nvram_ut_trace("[NVUT] %s() %d: record[%d] wait(%d) data to be flushed!\n\r",__FUNCTION__,__LINE__,i,count); |
| 13681 | } |
| 13682 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 13683 | { |
| 13684 | nvram_ut_trace("[NVUT] %s() %d: record[%d] valid bit check error!\n\r",__FUNCTION__,__LINE__,i); |
| 13685 | free_ctrl_buffer(p_buffer); |
| 13686 | return KAL_FALSE; |
| 13687 | } |
| 13688 | |
| 13689 | } |
| 13690 | for(i = 1; i <= ldi->total_records; i++) |
| 13691 | { |
| 13692 | memset(p_buffer,0,ldi->size); |
| 13693 | |
| 13694 | if(!nvram_external_read_data(NVRAM_EF_INTERNAL_TEST_14_LID,i,p_buffer,ldi->size)) |
| 13695 | { |
| 13696 | nvram_ut_trace("[NVUT] %s(): record[%d] nvram_external_read_data fail @line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 13697 | free_ctrl_buffer(p_buffer); |
| 13698 | return KAL_FALSE; |
| 13699 | } |
| 13700 | if( i == 1 ){ |
| 13701 | for(j = 1; j <= ldi->total_records; j++){ |
| 13702 | if(check_valid_bit_by_ltable_entry(ldi,j)!= KAL_TRUE) |
| 13703 | { |
| 13704 | nvram_ut_trace("[NVUT] %s() %d: record[%d] valid bit check error!\n\r",__FUNCTION__,__LINE__,j); |
| 13705 | free_ctrl_buffer(p_buffer); |
| 13706 | return KAL_FALSE; |
| 13707 | } |
| 13708 | |
| 13709 | //check the defalut value of valid bit and dirty bit of the LID |
| 13710 | if(check_dirty_bit_by_ltable_entry(ldi,j)!= KAL_FALSE) //may be optional |
| 13711 | { |
| 13712 | nvram_ut_trace("[NVUT] %s() %d: record[%d] dirty bit check error!\n\r",__FUNCTION__,__LINE__,j); |
| 13713 | } |
| 13714 | } |
| 13715 | } |
| 13716 | if(p_buffer[0] != 0x1) |
| 13717 | { |
| 13718 | nvram_ut_trace("[NVUT] %s() %d: record[%d] data[0]:%d error!\n\r",__FUNCTION__,__LINE__,i,p_buffer[0]); |
| 13719 | free_ctrl_buffer(p_buffer); |
| 13720 | return KAL_FALSE; |
| 13721 | } |
| 13722 | if(ldi->size >= 3) |
| 13723 | { |
| 13724 | if((p_buffer[1] != 0x2) ||(p_buffer[2] != 0x3)) |
| 13725 | { |
| 13726 | nvram_ut_trace("[NVUT] %s() %d: record[%d] data[1]:%d data[2]:%d error!\n\r",__FUNCTION__,__LINE__,i,p_buffer[1],p_buffer[2]); |
| 13727 | free_ctrl_buffer(p_buffer); |
| 13728 | return KAL_FALSE; |
| 13729 | } |
| 13730 | } |
| 13731 | |
| 13732 | } |
| 13733 | //re-create file |
| 13734 | if(nvram_cache_reset_one_data_item(ldi,1,ldi->total_records) == NVRAM_IO_ERRNO_OK) |
| 13735 | { |
| 13736 | for(i = 1; i <= ldi->total_records; i++){ |
| 13737 | //check the defalut value of valid bit of the LID |
| 13738 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 13739 | { |
| 13740 | nvram_ut_trace("[NVUT] %s(): check record[%d] valid bit fail @line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 13741 | free_ctrl_buffer(p_buffer); |
| 13742 | return KAL_FALSE; |
| 13743 | } |
| 13744 | } |
| 13745 | } |
| 13746 | nvram_util_get_data_item(&ldi, NVRAM_EF_INTERNAL_TEST_14_LID); |
| 13747 | for(j = 1; j <= ldi->total_records; j++) |
| 13748 | { |
| 13749 | kal_mem_set(data_buffer, 0, ldi->size); |
| 13750 | data_buffer[0] = j; |
| 13751 | if(!nvram_external_write_data(ldi->LID, j, (kal_uint8 *)data_buffer, ldi->size)) |
| 13752 | { |
| 13753 | free_ctrl_buffer(p_buffer); |
| 13754 | return KAL_FALSE; |
| 13755 | } |
| 13756 | } |
| 13757 | |
| 13758 | free_ctrl_buffer(p_buffer); |
| 13759 | |
| 13760 | return KAL_TRUE; |
| 13761 | } |
| 13762 | |
| 13763 | kal_uint8 temp_cache_buffer[65*1024]; |
| 13764 | #define RECORD_CNT_FOR_16K_MORE_CACHE_READ (2) |
| 13765 | #define RECORD_CNT_FOR_64K_MORE_CACHE_READ (59) |
| 13766 | |
| 13767 | kal_bool nvram_cache_read_data_more_than_16K() |
| 13768 | { |
| 13769 | nvram_ltable_entry_struct *ldi = NULL; |
| 13770 | kal_uint8 *p_buffer = NULL; |
| 13771 | kal_uint32 i = 0,j = 0,count = 0; |
| 13772 | |
| 13773 | if(!NVRAM_IS_LID_VALID(NVRAM_EF_INTERNAL_13_LID)) |
| 13774 | { |
| 13775 | return KAL_FALSE; |
| 13776 | } |
| 13777 | //reset test LIDs to default settings |
| 13778 | if( !reset_test_lid_default_setting(NVRAM_EF_INTERNAL_13_LID) ) |
| 13779 | { |
| 13780 | nvram_ut_trace("[NVUT] %s(): reset test LID settings fail!\n\r",__FUNCTION__); |
| 13781 | } |
| 13782 | nvram_util_get_data_item(&ldi, NVRAM_EF_INTERNAL_13_LID); |
| 13783 | |
| 13784 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 13785 | { |
| 13786 | nvram_ut_trace("[NVUT] %s(): reset test LIDs fail!\n\r", __FUNCTION__); |
| 13787 | return KAL_FALSE; |
| 13788 | } |
| 13789 | |
| 13790 | for(j = 1; j <= ldi->total_records; j++) |
| 13791 | { |
| 13792 | kal_mem_set(data_buffer, 0, ldi->size); |
| 13793 | data_buffer[0] = j; |
| 13794 | if(!nvram_external_write_data(ldi->LID, j, (kal_uint8 *)data_buffer, ldi->size)) |
| 13795 | { |
| 13796 | return KAL_FALSE; |
| 13797 | } |
| 13798 | } |
| 13799 | //clean the valid and dirty bit of LID |
| 13800 | if((unmask_lid_all_record_valid_bit(ldi)!= KAL_TRUE) || (unmask_lid_all_record_dirty_bit(ldi)!= KAL_TRUE)) |
| 13801 | { |
| 13802 | nvram_ut_trace("[NVRAM UT] %s() %d: test_lid_enum[%d] valid(%d) and dirty(%d) bit check fail.\n\r",__FUNCTION__,__LINE__,j,unmask_lid_all_record_valid_bit(ldi),unmask_lid_all_record_dirty_bit(ldi)); |
| 13803 | return KAL_FALSE; |
| 13804 | } |
| 13805 | //check the defalut value of valid bit and dirty bit of the LID |
| 13806 | if((check_lid_all_record_is_invalid_bit(ldi)!= KAL_TRUE) || (check_lid_all_record_is_undirty_bit(ldi)!= KAL_TRUE)) |
| 13807 | { |
| 13808 | nvram_ut_trace("[NVRAM UT] %s() %d: test_lid_enum[%d] valid(%d) and dirty(%d) bit check fail.\n\r",__FUNCTION__,__LINE__,j,check_lid_all_record_is_invalid_bit(ldi),check_lid_all_record_is_undirty_bit(ldi)); |
| 13809 | return KAL_FALSE; |
| 13810 | } |
| 13811 | p_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 13812 | memset(temp_cache_buffer,0,ldi->size * RECORD_CNT_FOR_16K_MORE_CACHE_READ); |
| 13813 | if(!nvram_external_read_multi_record(NVRAM_EF_INTERNAL_13_LID,1,RECORD_CNT_FOR_16K_MORE_CACHE_READ,temp_cache_buffer,ldi->size * RECORD_CNT_FOR_16K_MORE_CACHE_READ)) |
| 13814 | { |
| 13815 | nvram_ut_trace("[NVUT] %s(): nvram_external_read_data fail @line %d!\n\r",__FUNCTION__,__LINE__); |
| 13816 | free_ctrl_buffer(p_buffer); |
| 13817 | return KAL_FALSE; |
| 13818 | } |
| 13819 | |
| 13820 | for(i = 1; i <= (RECORD_CNT_FOR_16K_MORE_CACHE_READ); i++) |
| 13821 | { |
| 13822 | //check the defalut value of valid bit and dirty bit of the LID |
| 13823 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 13824 | { |
| 13825 | nvram_ut_trace("[NVUT] %s() %d: record[%d] check valid bit fail!\n\r",__FUNCTION__,__LINE__,i); |
| 13826 | free_ctrl_buffer(p_buffer); |
| 13827 | return KAL_FALSE; |
| 13828 | } |
| 13829 | if(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 13830 | { |
| 13831 | nvram_ut_trace("[NVUT] %s() %d: record[%d] check dirty bit fail!\n\r",__FUNCTION__,__LINE__,i); |
| 13832 | free_ctrl_buffer(p_buffer); |
| 13833 | return KAL_FALSE; |
| 13834 | } |
| 13835 | if(temp_cache_buffer[((i-1)*ldi->size)] != i) |
| 13836 | { |
| 13837 | nvram_ut_trace("[NVUT] %s() %d: record[%d] check data fail(data[%d]!=%d)!\n\r",__FUNCTION__,__LINE__,i,((i-1)*ldi->size),i); |
| 13838 | return KAL_FALSE; |
| 13839 | } |
| 13840 | |
| 13841 | for(j = 1; j < ldi->size; j++) |
| 13842 | { |
| 13843 | if(temp_cache_buffer[((i-1)*ldi->size + j)] != 0) |
| 13844 | { |
| 13845 | nvram_ut_trace("[NVUT] %s() %d: record[%d] check data fail(data[%d]!=0)!\n\r",__FUNCTION__,__LINE__,i,j); |
| 13846 | return KAL_FALSE; |
| 13847 | } |
| 13848 | } |
| 13849 | } |
| 13850 | |
| 13851 | for(i = 1; i <= ldi->total_records; i++) |
| 13852 | { |
| 13853 | memset(p_buffer,0,ldi->size); |
| 13854 | p_buffer[0] = 0x1; //modify some data |
| 13855 | if(ldi->size >= 3) |
| 13856 | { |
| 13857 | p_buffer[1] = 0x2; |
| 13858 | p_buffer[2] = 0x3; |
| 13859 | } |
| 13860 | if(!nvram_external_write_data(NVRAM_EF_INTERNAL_13_LID,i,p_buffer,ldi->size)) |
| 13861 | { |
| 13862 | nvram_ut_trace("[NVUT] %s(): nvram_external_write_data fail @%d!\n\r",__FUNCTION__,__LINE__); |
| 13863 | free_ctrl_buffer(p_buffer); |
| 13864 | return KAL_FALSE; |
| 13865 | } |
| 13866 | count = 0; |
| 13867 | //check the defalut value of valid bit and dirty bit of the LID |
| 13868 | while(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) //may be optional |
| 13869 | { |
| 13870 | count ++; |
| 13871 | nvram_ut_trace("[NVUT] %s() %d: record[%d] wait(%d) data to be flushed!\n\r",__FUNCTION__,__LINE__,i,count); |
| 13872 | } |
| 13873 | |
| 13874 | } |
| 13875 | for(i = 1; i <= ldi->total_records; i++) |
| 13876 | { |
| 13877 | memset(p_buffer,0,ldi->size); |
| 13878 | |
| 13879 | if(!nvram_external_read_data(NVRAM_EF_INTERNAL_13_LID,i,p_buffer,ldi->size)) |
| 13880 | { |
| 13881 | nvram_ut_trace("[NVUT] %s(): record[%d] nvram_external_read_data fail @line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 13882 | free_ctrl_buffer(p_buffer); |
| 13883 | return KAL_FALSE; |
| 13884 | } |
| 13885 | if(p_buffer[0] != 0x1) |
| 13886 | { |
| 13887 | nvram_ut_trace("[NVUT] %s() %d: record[%d] data[0]:%d error!\n\r",__FUNCTION__,__LINE__,i,p_buffer[0]); |
| 13888 | free_ctrl_buffer(p_buffer); |
| 13889 | return KAL_FALSE; |
| 13890 | } |
| 13891 | if(ldi->size >= 3) |
| 13892 | { |
| 13893 | if((p_buffer[1] != 0x2) ||(p_buffer[2] != 0x3)) |
| 13894 | { |
| 13895 | nvram_ut_trace("[NVUT] %s() %d: record[%d] data[1]:%d data[2]:%d error!\n\r",__FUNCTION__,__LINE__,i,p_buffer[1],p_buffer[2]); |
| 13896 | free_ctrl_buffer(p_buffer); |
| 13897 | return KAL_FALSE; |
| 13898 | } |
| 13899 | } |
| 13900 | |
| 13901 | } |
| 13902 | |
| 13903 | //re-create file |
| 13904 | if(nvram_cache_reset_one_data_item(ldi,1,ldi->total_records) == NVRAM_IO_ERRNO_OK) |
| 13905 | { |
| 13906 | for(i = 1; i <= ldi->total_records; i++){ |
| 13907 | //check the defalut value of valid bit of the LID |
| 13908 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 13909 | { |
| 13910 | nvram_ut_trace("[NVUT] %s(): check record[%d] valid bit fail @line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 13911 | free_ctrl_buffer(p_buffer); |
| 13912 | return KAL_FALSE; |
| 13913 | } |
| 13914 | } |
| 13915 | } |
| 13916 | |
| 13917 | for(j = 1; j <= ldi->total_records; j++) |
| 13918 | { |
| 13919 | kal_mem_set(data_buffer, 0, ldi->size); |
| 13920 | data_buffer[0] = j; |
| 13921 | if(!nvram_external_write_data(ldi->LID, j, (kal_uint8 *)data_buffer, ldi->size)) |
| 13922 | { |
| 13923 | free_ctrl_buffer(p_buffer); |
| 13924 | return KAL_FALSE; |
| 13925 | } |
| 13926 | } |
| 13927 | free_ctrl_buffer(p_buffer); |
| 13928 | |
| 13929 | return KAL_TRUE; |
| 13930 | } |
| 13931 | |
| 13932 | kal_bool nvram_cache_read_data_more_than_64K() |
| 13933 | { |
| 13934 | nvram_ltable_entry_struct *ldi = NULL; |
| 13935 | kal_uint8 *p_buffer = NULL; |
| 13936 | kal_uint32 i = 0,j = 0,count = 0; |
| 13937 | |
| 13938 | if(!NVRAM_IS_LID_VALID(NVRAM_EF_INTERNAL_TEST_16_LID)) |
| 13939 | { |
| 13940 | return KAL_FALSE; |
| 13941 | } |
| 13942 | nvram_util_get_data_item(&ldi, NVRAM_EF_INTERNAL_TEST_16_LID); |
| 13943 | |
| 13944 | //clean the valid and dirty bit of LID |
| 13945 | if((unmask_lid_all_record_valid_bit(ldi)!= KAL_TRUE) || (unmask_lid_all_record_dirty_bit(ldi)!= KAL_TRUE)) |
| 13946 | { |
| 13947 | nvram_ut_trace("[NVRAM UT] %s() %d: test_lid_enum[%d] valid(%d) and dirty(%d) bit check fail.\n\r",__FUNCTION__,__LINE__,j,unmask_lid_all_record_valid_bit(ldi),unmask_lid_all_record_dirty_bit(ldi)); |
| 13948 | return KAL_FALSE; |
| 13949 | } |
| 13950 | //check the defalut value of valid bit and dirty bit of the LID |
| 13951 | if((check_lid_all_record_is_invalid_bit(ldi)!= KAL_TRUE) || (check_lid_all_record_is_undirty_bit(ldi)!= KAL_TRUE)) |
| 13952 | { |
| 13953 | nvram_ut_trace("[NVRAM UT] %s() %d: test_lid_enum[%d] valid(%d) and dirty(%d) bit check fail.\n\r",__FUNCTION__,__LINE__,j,check_lid_all_record_is_invalid_bit(ldi),check_lid_all_record_is_undirty_bit(ldi)); |
| 13954 | return KAL_FALSE; |
| 13955 | } |
| 13956 | memset(temp_cache_buffer,0,ldi->size * RECORD_CNT_FOR_64K_MORE_CACHE_READ); |
| 13957 | if(!nvram_external_read_multi_record(NVRAM_EF_INTERNAL_TEST_16_LID,1,RECORD_CNT_FOR_64K_MORE_CACHE_READ,temp_cache_buffer,ldi->size * RECORD_CNT_FOR_64K_MORE_CACHE_READ)) |
| 13958 | { |
| 13959 | nvram_ut_trace("[NVUT] %s(): nvram_external_read_data fail @line %d!\n\r",__FUNCTION__,__LINE__); |
| 13960 | return KAL_FALSE; |
| 13961 | } |
| 13962 | |
| 13963 | //read more than 64KB per one time |
| 13964 | for(i = 1; i <= RECORD_CNT_FOR_64K_MORE_CACHE_READ; i++) |
| 13965 | { |
| 13966 | //check the defalut value of valid bit and dirty bit of the LID |
| 13967 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_TRUE) |
| 13968 | { |
| 13969 | nvram_ut_trace("[NVUT] %s() %d: record[%d] check valid bit fail!\n\r",__FUNCTION__,__LINE__,i); |
| 13970 | return KAL_FALSE; |
| 13971 | } |
| 13972 | if(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 13973 | { |
| 13974 | nvram_ut_trace("[NVUT] %s() %d: record[%d] check dirty bit fail!\n\r",__FUNCTION__,__LINE__,i); |
| 13975 | return KAL_FALSE; |
| 13976 | } |
| 13977 | |
| 13978 | if(temp_cache_buffer[((i-1)*ldi->size)] != i) |
| 13979 | { |
| 13980 | nvram_ut_trace("[NVUT] %s() %d: record[%d] check data fail(data[%d]!=%d)!\n\r",__FUNCTION__,__LINE__,i,((i-1)*ldi->size),i); |
| 13981 | return KAL_FALSE; |
| 13982 | } |
| 13983 | |
| 13984 | for(j = 1; j < ldi->size;j++) |
| 13985 | { |
| 13986 | if(temp_cache_buffer[((i-1)*ldi->size) + j] != 0) |
| 13987 | { |
| 13988 | nvram_ut_trace("[NVUT] %s() %d: record[%d] check data fail(data[%d]!=0)!\n\r",__FUNCTION__,__LINE__,i,j); |
| 13989 | return KAL_FALSE; |
| 13990 | } |
| 13991 | } |
| 13992 | } |
| 13993 | |
| 13994 | p_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 13995 | memset(p_buffer,0,ldi->size); |
| 13996 | |
| 13997 | for(i = 1; i <= ldi->total_records; i++) |
| 13998 | { |
| 13999 | memset(p_buffer,0,ldi->size); |
| 14000 | p_buffer[0] = 0x1; //modify some data |
| 14001 | if(ldi->size >= 3) |
| 14002 | { |
| 14003 | p_buffer[1] = 0x2; |
| 14004 | p_buffer[2] = 0x3; |
| 14005 | } |
| 14006 | if(!nvram_external_write_data(NVRAM_EF_INTERNAL_TEST_16_LID,i,p_buffer,ldi->size)) |
| 14007 | { |
| 14008 | nvram_ut_trace("[NVUT] %s(): nvram_external_write_data fail @%d!\n\r",__FUNCTION__,__LINE__); |
| 14009 | free_ctrl_buffer(p_buffer); |
| 14010 | return KAL_FALSE; |
| 14011 | } |
| 14012 | count = 0; |
| 14013 | //check the defalut value of valid bit and dirty bit of the LID |
| 14014 | while(check_dirty_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) //may be optional |
| 14015 | { |
| 14016 | count ++; |
| 14017 | nvram_ut_trace("[NVUT] %s() %d: record[%d] wait(%d) data to be flushed!\n\r",__FUNCTION__,__LINE__,i,count); |
| 14018 | } |
| 14019 | |
| 14020 | } |
| 14021 | for(i = 1; i <= ldi->total_records; i++) |
| 14022 | { |
| 14023 | memset(p_buffer,0,ldi->size); |
| 14024 | |
| 14025 | if(!nvram_external_read_data(NVRAM_EF_INTERNAL_TEST_16_LID,i,p_buffer,ldi->size)) |
| 14026 | { |
| 14027 | nvram_ut_trace("[NVUT] %s(): record[%d] nvram_external_read_data fail @line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 14028 | free_ctrl_buffer(p_buffer); |
| 14029 | return KAL_FALSE; |
| 14030 | } |
| 14031 | if(p_buffer[0] != 0x1) |
| 14032 | { |
| 14033 | nvram_ut_trace("[NVUT] %s() %d: record[%d] data[0]:%d error!\n\r",__FUNCTION__,__LINE__,i,p_buffer[0]); |
| 14034 | free_ctrl_buffer(p_buffer); |
| 14035 | return KAL_FALSE; |
| 14036 | } |
| 14037 | if(ldi->size >= 3) |
| 14038 | { |
| 14039 | if((p_buffer[1] != 0x2) ||(p_buffer[2] != 0x3)) |
| 14040 | { |
| 14041 | nvram_ut_trace("[NVUT] %s() %d: record[%d] data[1]:%d data[2]:%d error!\n\r",__FUNCTION__,__LINE__,i,p_buffer[1],p_buffer[2]); |
| 14042 | free_ctrl_buffer(p_buffer); |
| 14043 | return KAL_FALSE; |
| 14044 | } |
| 14045 | } |
| 14046 | |
| 14047 | } |
| 14048 | |
| 14049 | //re-create file |
| 14050 | if(nvram_cache_reset_one_data_item(ldi,1,ldi->total_records) == NVRAM_IO_ERRNO_OK) |
| 14051 | { |
| 14052 | for(i = 1; i <= ldi->total_records; i++){ |
| 14053 | //check the defalut value of valid bit of the LID |
| 14054 | if(check_valid_bit_by_ltable_entry(ldi,i)!= KAL_FALSE) |
| 14055 | { |
| 14056 | nvram_ut_trace("[NVUT] %s(): check record[%d] valid bit fail @line %d!\n\r",__FUNCTION__,i,__LINE__); |
| 14057 | free_ctrl_buffer(p_buffer); |
| 14058 | return KAL_FALSE; |
| 14059 | } |
| 14060 | } |
| 14061 | } |
| 14062 | |
| 14063 | for(j = 1; j <= ldi->total_records; j++) |
| 14064 | { |
| 14065 | kal_mem_set(data_buffer, 0, ldi->size); |
| 14066 | data_buffer[0] = j; |
| 14067 | if(!nvram_external_write_data(NVRAM_EF_INTERNAL_TEST_16_LID, j, (kal_uint8 *)data_buffer, ldi->size)) |
| 14068 | { |
| 14069 | free_ctrl_buffer(p_buffer); |
| 14070 | return KAL_FALSE; |
| 14071 | } |
| 14072 | } |
| 14073 | free_ctrl_buffer(p_buffer); |
| 14074 | |
| 14075 | return KAL_TRUE; |
| 14076 | } |
| 14077 | |
| 14078 | |
| 14079 | #ifdef __NVRAM_LID_PREREAD__ |
| 14080 | kal_bool nvram_cache_preread_chk() |
| 14081 | { |
| 14082 | nvram_ltable_entry_struct *ldi = NULL; |
| 14083 | kal_uint8 idx; |
| 14084 | |
| 14085 | for(idx = 0; idx < preread_white_list_amount; idx++) |
| 14086 | { |
| 14087 | nvram_util_get_data_item(&ldi, pre_read_white_list[idx]); |
| 14088 | //check the valid and dirty bit of LID |
| 14089 | if(ldi->attr & NVRAM_ATTR_GEN_DEFAULT) |
| 14090 | { |
| 14091 | if(check_lid_all_record_is_valid_bit(ldi)!= KAL_TRUE) |
| 14092 | { |
| 14093 | nvram_ut_trace("[NVUT] %s() %d: the valid bit !\n\r",__FUNCTION__,__LINE__); |
| 14094 | return KAL_FALSE; |
| 14095 | }else |
| 14096 | { |
| 14097 | nvram_ut_trace("[NVUT] %s() %d: have pre-read !\n\r",__FUNCTION__, ldi->LID); |
| 14098 | } |
| 14099 | } |
| 14100 | } |
| 14101 | |
| 14102 | return KAL_TRUE; |
| 14103 | } |
| 14104 | #endif |
| 14105 | |
| 14106 | kal_bool nvram_cache_bypass_white_list_test() |
| 14107 | { |
| 14108 | nvram_ltable_entry_struct *ldi = NULL; |
| 14109 | kal_uint8 *p_buffer = NULL; |
| 14110 | kal_uint8 i; |
| 14111 | |
| 14112 | nvram_util_get_data_item(&ldi, NVRAM_EF_INTERNAL_TEST_17_LID); |
| 14113 | |
| 14114 | //check the defalut value of valid bit and dirty bit of the LID |
| 14115 | if((check_lid_all_record_is_invalid_bit(ldi)!= KAL_TRUE) || (check_lid_all_record_is_undirty_bit(ldi)!= KAL_TRUE)) |
| 14116 | { |
| 14117 | nvram_ut_trace("[NVRAM UT] %s() %d: test_lid_enum[%d] valid or dirty bit check fail.\n\r", __FUNCTION__, __LINE__, NVRAM_EF_INTERNAL_TEST_17_LID); |
| 14118 | return KAL_FALSE; |
| 14119 | } |
| 14120 | |
| 14121 | p_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size*ldi->total_records); |
| 14122 | memset(p_buffer,0,ldi->size*ldi->total_records); |
| 14123 | |
| 14124 | //write all the record data of a LID |
| 14125 | for(i= 1; i <= ldi->total_records; i++) |
| 14126 | { |
| 14127 | p_buffer[0] = i; |
| 14128 | if(!nvram_external_write_data(NVRAM_EF_INTERNAL_TEST_17_LID, i, p_buffer, ldi->size)) |
| 14129 | { |
| 14130 | nvram_ut_trace("[NVUT] %s() %d: LID write operations fail!\n\r",__FUNCTION__, __LINE__); |
| 14131 | free_ctrl_buffer(p_buffer); |
| 14132 | return KAL_FALSE; |
| 14133 | } |
| 14134 | } |
| 14135 | |
| 14136 | //check the defalut value of valid bit and dirty bit of the LID |
| 14137 | if(check_lid_all_record_is_valid_bit(ldi)!= KAL_TRUE) |
| 14138 | { |
| 14139 | nvram_ut_trace("[NVRAM UT] %s() %d: test_lid_enum[%d] valid bit check fail.\n\r",__FUNCTION__, __LINE__, NVRAM_EF_INTERNAL_TEST_17_LID); |
| 14140 | free_ctrl_buffer(p_buffer); |
| 14141 | return KAL_FALSE; |
| 14142 | } |
| 14143 | |
| 14144 | nvram_ut_trace("[NVUT] %s(): LID write done.\n\r",__FUNCTION__); |
| 14145 | |
| 14146 | //clean and check the valid bit of LID |
| 14147 | if((unmask_lid_all_record_valid_bit(ldi)!= KAL_TRUE) && (check_lid_all_record_is_invalid_bit(ldi)!= KAL_TRUE)) |
| 14148 | { |
| 14149 | nvram_ut_trace("[NVUT] %s() %d: unmask valid bit fail!\n\r",__FUNCTION__,__LINE__); |
| 14150 | free_ctrl_buffer(p_buffer); |
| 14151 | return KAL_FALSE; |
| 14152 | } |
| 14153 | |
| 14154 | //read all the record data of a LID |
| 14155 | memset(p_buffer,0,ldi->size*ldi->total_records); |
| 14156 | |
| 14157 | if(!nvram_external_read_multi_record(NVRAM_EF_INTERNAL_TEST_17_LID,1,ldi->total_records,p_buffer,ldi->size*ldi->total_records)) |
| 14158 | { |
| 14159 | nvram_ut_trace("[NVUT] %s() %d: LID cmpt operations fail!\n\r",__FUNCTION__, __LINE__); |
| 14160 | free_ctrl_buffer(p_buffer); |
| 14161 | return KAL_FALSE; |
| 14162 | } |
| 14163 | |
| 14164 | //check the record data of a LID |
| 14165 | for(i= 0; i < ldi->total_records; i++) |
| 14166 | { |
| 14167 | if(p_buffer[i*1024] != (i+1)) |
| 14168 | { |
| 14169 | nvram_ut_trace("[NVUT] %s() %d: check the LID data fail!\n\r",__FUNCTION__, __LINE__); |
| 14170 | free_ctrl_buffer(p_buffer); |
| 14171 | return KAL_FALSE; |
| 14172 | } |
| 14173 | } |
| 14174 | |
| 14175 | //check the value of valid bit of the LID |
| 14176 | if(check_lid_all_record_is_valid_bit(ldi)!= KAL_TRUE) |
| 14177 | { |
| 14178 | nvram_ut_trace("[NVRAM UT] %s() %d: test_lid_enum[%d] valid bit check fail.\n\r",__FUNCTION__, __LINE__, NVRAM_EF_INTERNAL_TEST_17_LID); |
| 14179 | free_ctrl_buffer(p_buffer); |
| 14180 | return KAL_FALSE; |
| 14181 | } |
| 14182 | nvram_ut_trace("[NVUT] %s(): LID read multi record done.\n\r",__FUNCTION__); |
| 14183 | |
| 14184 | //clean and check the valid bit of LID |
| 14185 | if((unmask_lid_all_record_valid_bit(ldi)!= KAL_TRUE) && (check_lid_all_record_is_invalid_bit(ldi)!= KAL_TRUE)) |
| 14186 | { |
| 14187 | nvram_ut_trace("[NVUT] %s() %d: unmask valid bit fail!\n\r",__FUNCTION__,__LINE__); |
| 14188 | free_ctrl_buffer(p_buffer); |
| 14189 | return KAL_FALSE; |
| 14190 | } |
| 14191 | |
| 14192 | //read all the record data of a LID |
| 14193 | memset(p_buffer,0,ldi->size*ldi->total_records); |
| 14194 | for(i= 1; i <= ldi->total_records; i++) |
| 14195 | { |
| 14196 | if(!nvram_external_read_data(NVRAM_EF_INTERNAL_TEST_17_LID, i,(p_buffer + ((i-1)*1024)),ldi->size)) |
| 14197 | { |
| 14198 | nvram_ut_trace("[NVUT] %s() %d: LID cmpt operations fail!\n\r",__FUNCTION__, __LINE__); |
| 14199 | free_ctrl_buffer(p_buffer); |
| 14200 | return KAL_FALSE; |
| 14201 | } |
| 14202 | |
| 14203 | //check the record data of a LID |
| 14204 | if(p_buffer[(i-1)*1024] != i) |
| 14205 | { |
| 14206 | nvram_ut_trace("[NVUT] %s() %d: check the LID data fail!\n\r",__FUNCTION__, __LINE__); |
| 14207 | free_ctrl_buffer(p_buffer); |
| 14208 | return KAL_FALSE; |
| 14209 | } |
| 14210 | } |
| 14211 | |
| 14212 | //check the value of valid bit of the LID |
| 14213 | if(check_lid_all_record_is_valid_bit(ldi)!= KAL_TRUE) |
| 14214 | { |
| 14215 | nvram_ut_trace("[NVRAM UT] %s() %d: test_lid_enum[%d] valid bit check fail.\n\r",__FUNCTION__, __LINE__, NVRAM_EF_INTERNAL_TEST_17_LID); |
| 14216 | free_ctrl_buffer(p_buffer); |
| 14217 | return KAL_FALSE; |
| 14218 | } |
| 14219 | free_ctrl_buffer(p_buffer); |
| 14220 | return KAL_TRUE; |
| 14221 | } |
| 14222 | |
| 14223 | #endif |
| 14224 | |
| 14225 | // __NVRAM_ENHANCE_CHKSUM_ALGORITHM__ |
| 14226 | #ifdef __NV_CHKSUM_ENHANCE__ |
| 14227 | kal_bool reset_test_lids(kal_uint32 *lid_list, kal_uint8 length) |
| 14228 | { |
| 14229 | kal_uint8 i=0; |
| 14230 | nvram_ltable_entry_struct *ldi = NULL; |
| 14231 | |
| 14232 | for(i=0; i< length; i++) |
| 14233 | { |
| 14234 | //reset test LID to default settings |
| 14235 | nvram_util_get_data_item(&ldi,lid_list[i]); |
| 14236 | if( !reset_test_lid_default_setting(lid_list[i]) ) |
| 14237 | { |
| 14238 | nvram_ut_trace("[NVUT] %s(): reset test LID to default settings fail!\n\r",__FUNCTION__); |
| 14239 | return KAL_FALSE; |
| 14240 | } |
| 14241 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 14242 | { |
| 14243 | nvram_ut_trace("[NVUT] %s(): reset test LIDs fail!\n\r", __FUNCTION__); |
| 14244 | return KAL_FALSE; |
| 14245 | } |
| 14246 | } |
| 14247 | return KAL_TRUE; |
| 14248 | |
| 14249 | } |
| 14250 | |
| 14251 | kal_bool access_chksum_test_lid() |
| 14252 | { |
| 14253 | kal_uint8 i; |
| 14254 | nvram_ltable_entry_struct *ldi=NULL; |
| 14255 | |
| 14256 | for(i=0; i<chksum_algo_test_lid_number; i++) |
| 14257 | { |
| 14258 | nvram_util_get_data_item(&ldi,chksum_algo_test_lid_list[i]); |
| 14259 | if(0!= nvram_lid_cmpt_operation(ldi->LID,\ |
| 14260 | CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK,CMPT_OP_FLAG_WRITE,CMPT_OP_FLAG_RESET,0),CMPT_OP_WAY_API,1,ldi->total_records)) |
| 14261 | { |
| 14262 | nvram_ut_trace("[NVUT] %s(): CMPT access lid(%x) fail access way CMPT_OP_WAY_API\n\r", __FUNCTION__, ldi->LID); |
| 14263 | return KAL_FALSE; |
| 14264 | } |
| 14265 | if(0!= nvram_lid_cmpt_operation(ldi->LID,CMPT_OP_FLAG_GEN(CMPT_OP_FLAG_READBACK,CMPT_OP_FLAG_WRITE,CMPT_OP_FLAG_RESET,0), |
| 14266 | CMPT_OP_WAY_MSG,1,ldi->total_records)) |
| 14267 | { |
| 14268 | nvram_ut_trace("[NVUT] %s(): CMPT access lid(%x) fail access way CMPT_OP_WAY_MSG\n\r", __FUNCTION__, ldi->LID); |
| 14269 | return KAL_FALSE; |
| 14270 | } |
| 14271 | } |
| 14272 | |
| 14273 | return KAL_TRUE; |
| 14274 | } |
| 14275 | |
| 14276 | kal_bool reset_chksum_info_lid() |
| 14277 | { |
| 14278 | nvram_ltable_entry_struct *ldi=NULL; |
| 14279 | kal_bool result = KAL_TRUE; |
| 14280 | |
| 14281 | nvram_cfg_crrnt_chksum_algo(); |
| 14282 | nvram_util_get_data_item(&ldi,NVRAM_EF_CORE_CHKSUM_INFO_LID); |
| 14283 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN,NVRAM_APP_RESERVED,ldi,1,ldi->total_records)) |
| 14284 | { |
| 14285 | result = KAL_FALSE; |
| 14286 | } |
| 14287 | nvram_ut_trace("[NVUT]%s():CHK_1_CONFIG def_size(%d),def_type(%d)\n\r", __FUNCTION__, NVRAM_CHK_CONFIG.default_algo_size, NVRAM_CHK_CONFIG.default_algo_type); |
| 14288 | nvram_ut_trace("[NVUT]%s():CHK_1_CONFIG enh_size(%d),enh_type(%d)\n\r", __FUNCTION__, NVRAM_CHK_CONFIG.enhance_algo_size, NVRAM_CHK_CONFIG.enhance_algo_type); |
| 14289 | return result; |
| 14290 | } |
| 14291 | |
| 14292 | /* |
| 14293 | This function is used to change LID chksum algo type, verno . |
| 14294 | Input: |
| 14295 | chksum_chg_type: the type chksum alog change |
| 14296 | inc_verno: true, verno+1 else keep verno |
| 14297 | Output: |
| 14298 | KAL_TRUE: success |
| 14299 | KAL_FALSE: fail |
| 14300 | */ |
| 14301 | |
| 14302 | kal_bool nvram_chg_chksum_test_lid_info(nvram_chksum_change_enum chksum_chg_type, kal_bool inc_verno, kal_uint32 *lid_list, kal_uint8 length) |
| 14303 | { |
| 14304 | kal_uint8 i; |
| 14305 | nvram_ltable_entry_struct *ldi= NULL; |
| 14306 | nvram_checksum_config *nv_chk_cf_bk = NULL; |
| 14307 | |
| 14308 | if(chksum_chg_type == FROM_ENHANCE_A_TO_B) |
| 14309 | { |
| 14310 | // backup NVRAM_CHK_CONFIG |
| 14311 | nvram_ut_trace("[NVUT]%s(): def_size(%d),def_type(%d)\n\r", __FUNCTION__, chksum_config_backup.default_algo_size, chksum_config_backup.default_algo_type); |
| 14312 | nvram_ut_trace("[NVUT]%s(): enh_size(%d),enh_type(%d)\n\r", __FUNCTION__, chksum_config_backup.enhance_algo_size, chksum_config_backup.enhance_algo_type); |
| 14313 | nv_chk_cf_bk = (nvram_checksum_config *)(&NVRAM_CHK_CONFIG); |
| 14314 | nv_chk_cf_bk->enhance_algo_size = nv_chk_cf_bk->default_algo_size; |
| 14315 | nv_chk_cf_bk->enhance_algo_type = nv_chk_cf_bk->default_algo_type; |
| 14316 | if(inc_verno) |
| 14317 | { |
| 14318 | for(i=0; i<length; i++) |
| 14319 | { |
| 14320 | if(!lid_verno_increase_one(lid_list[i])) |
| 14321 | { |
| 14322 | nvram_ut_trace("[NVUT]%s(): lid verno increase fail\n\r", __FUNCTION__); |
| 14323 | return KAL_FALSE; |
| 14324 | } |
| 14325 | } |
| 14326 | } |
| 14327 | } |
| 14328 | else |
| 14329 | { |
| 14330 | for(i=0; i<length; i++) |
| 14331 | { |
| 14332 | nvram_util_get_data_item(&ldi,lid_list[i]); |
| 14333 | switch(chksum_chg_type) |
| 14334 | { |
| 14335 | case FROM_DEF_TO_ENHANCE: |
| 14336 | { |
| 14337 | ldi->attr |= NVRAM_ATTR_CHKSUM_ENHNC_ALGRTHM; |
| 14338 | break; |
| 14339 | } |
| 14340 | case FROM_ENHANCE_TO_DEF: |
| 14341 | { |
| 14342 | ldi->attr &= (~NVRAM_ATTR_CHKSUM_ENHNC_ALGRTHM); |
| 14343 | break; |
| 14344 | } |
| 14345 | default: |
| 14346 | { |
| 14347 | nvram_ut_trace("[NVUT] %s(): Error chksum change type %d\r\n", __FUNCTION__, chksum_chg_type); |
| 14348 | return KAL_FALSE; |
| 14349 | } |
| 14350 | } |
| 14351 | |
| 14352 | if(inc_verno) |
| 14353 | { |
| 14354 | if(!lid_verno_increase_one(ldi->LID)) |
| 14355 | { |
| 14356 | nvram_ut_trace("[NVUT]%s(): lid verno increase fail\n\r", __FUNCTION__); |
| 14357 | return KAL_FALSE; |
| 14358 | } |
| 14359 | } |
| 14360 | } |
| 14361 | } |
| 14362 | return KAL_TRUE; |
| 14363 | } |
| 14364 | |
| 14365 | |
| 14366 | kal_bool test_chksum_algo_ota_boot_init(kal_uint32 *lid_list, const kal_uint8 count) |
| 14367 | { |
| 14368 | kal_bool result=KAL_TRUE; |
| 14369 | |
| 14370 | // reset chksum algo test lid |
| 14371 | // result = reset_test_lids(chksum_algo_test_lid_list,chksum_algo_test_lid_number); |
| 14372 | result = reset_test_lids(lid_list,count); |
| 14373 | |
| 14374 | //reset SYS LID |
| 14375 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 14376 | { |
| 14377 | nvram_ut_trace("[NVUT] ota_boot_calibrat_size_change_read(): reset SYS LID fail!\n\r"); |
| 14378 | return KAL_FALSE; |
| 14379 | } |
| 14380 | |
| 14381 | // Modify sw version |
| 14382 | if(!modify_md_sw_version()) |
| 14383 | { |
| 14384 | nvram_ut_trace("[NVUT] %s(): modify MD SW version fail!\n\r", __FUNCTION__); |
| 14385 | result = KAL_FALSE; |
| 14386 | } |
| 14387 | return result; |
| 14388 | } |
| 14389 | |
| 14390 | kal_bool ota_boot_change_chksum_default_algorithm_config() |
| 14391 | { |
| 14392 | kal_bool result = KAL_TRUE; |
| 14393 | |
| 14394 | #ifdef __NVRAM_LID_CACHE__ |
| 14395 | nvram_cache_reset(); |
| 14396 | #endif |
| 14397 | |
| 14398 | if(KAL_TRUE != test_chksum_algo_ota_boot_init(chksum_algo_test_lid_list, chksum_algo_test_lid_number)) |
| 14399 | { |
| 14400 | nvram_ut_trace("[NVUT] %s(): ota boot init fail!\n\r", __FUNCTION__); |
| 14401 | result = KAL_FALSE; |
| 14402 | goto final; |
| 14403 | } |
| 14404 | // Modify default chksum algo |
| 14405 | kal_mem_cpy(&chksum_config_backup,&NVRAM_CHK_CONFIG,sizeof(NVRAM_CHK_CONFIG)); |
| 14406 | nvram_ut_trace("[NVUT]%s():CHK_0_CONFIG def_size(%d),def_type(%d)\n\r", __FUNCTION__, NVRAM_CHK_CONFIG.default_algo_size, NVRAM_CHK_CONFIG.default_algo_type); |
| 14407 | nvram_ut_trace("[NVUT]%s():CHK_0_CONFIG enh_size(%d),enh_type(%d)\n\r", __FUNCTION__, NVRAM_CHK_CONFIG.enhance_algo_size, NVRAM_CHK_CONFIG.enhance_algo_type); |
| 14408 | nvram_ut_trace("[NVUT]%s():back def_size(%d),def_type(%d)\n\r", __FUNCTION__, chksum_config_backup.default_algo_size, chksum_config_backup.default_algo_type); |
| 14409 | nvram_ut_trace("[NVUT]%s():back enh_size(%d),enh_type(%d)\n\r", __FUNCTION__, chksum_config_backup.enhance_algo_size, chksum_config_backup.enhance_algo_type); |
| 14410 | NVRAM_CHK_CONFIG.default_algo_size = NVRAM_CHK_CONFIG.enhance_algo_size; |
| 14411 | NVRAM_CHK_CONFIG.default_algo_type = NVRAM_CHK_CONFIG.enhance_algo_type; |
| 14412 | |
| 14413 | //call nvram_init() |
| 14414 | nvram_ut_assert_flag = 0; |
| 14415 | nvram_boot_trace = 0; |
| 14416 | nvram_init(); |
| 14417 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 14418 | { |
| 14419 | nvram_ut_trace("[NVUT] %s(): enter version conflict fail!\n\r", __FUNCTION__); |
| 14420 | result = KAL_FALSE; |
| 14421 | } |
| 14422 | |
| 14423 | nvram_ut_trace("[NVUT] %s(): nvram_ut_assert_flag(%d) nvram ota state.\n\r", __FUNCTION__, nvram_ut_assert_flag); |
| 14424 | if(0 == nvram_ut_assert_flag) |
| 14425 | { |
| 14426 | nvram_ut_trace("[NVUT] %s(): Default chksum algo change ota not assert.\n\r", __FUNCTION__); |
| 14427 | result = KAL_FALSE; |
| 14428 | } |
| 14429 | |
| 14430 | // recover customer chksum setting |
| 14431 | kal_mem_cpy(&NVRAM_CHK_CONFIG,&chksum_config_backup, sizeof(NVRAM_CHK_CONFIG)); |
| 14432 | if(KAL_TRUE != reset_chksum_info_lid()) |
| 14433 | { |
| 14434 | nvram_ut_trace("[NVUT] %s(): reset chksum info lid error!\n\r", __FUNCTION__); |
| 14435 | result = KAL_FALSE; |
| 14436 | } |
| 14437 | |
| 14438 | final: |
| 14439 | |
| 14440 | #ifdef __NVRAM_LID_CACHE__ |
| 14441 | mark_nvram_cache_ready(); |
| 14442 | #endif |
| 14443 | |
| 14444 | return result; |
| 14445 | |
| 14446 | } |
| 14447 | |
| 14448 | kal_bool ota_boot_lid_algo_def_to_en_incr_verno() |
| 14449 | { |
| 14450 | kal_bool result=KAL_TRUE; |
| 14451 | |
| 14452 | #ifdef __NVRAM_LID_CACHE__ |
| 14453 | nvram_cache_reset(); |
| 14454 | #endif |
| 14455 | |
| 14456 | if(KAL_TRUE != test_chksum_algo_ota_boot_init(chksum_algo_test_lid_list, chksum_algo_test_lid_number)) |
| 14457 | { |
| 14458 | nvram_ut_trace("[NVUT] %s(): ota boot init fail!\n\r", __FUNCTION__); |
| 14459 | result = KAL_FALSE; |
| 14460 | goto final; |
| 14461 | } |
| 14462 | |
| 14463 | if(KAL_TRUE != nvram_chg_chksum_test_lid_info(FROM_DEF_TO_ENHANCE,KAL_TRUE, chksum_algo_test_lid_list, chksum_algo_test_lid_number)) |
| 14464 | { |
| 14465 | nvram_ut_trace("[NVUT] %s():chksum change fail!\n\r", __FUNCTION__); |
| 14466 | result = KAL_FALSE; |
| 14467 | goto reset_default; |
| 14468 | } |
| 14469 | // Call nvram_init |
| 14470 | nvram_ut_assert_flag = 0; |
| 14471 | nvram_boot_trace = 0; |
| 14472 | nvram_init(); |
| 14473 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 14474 | { |
| 14475 | nvram_ut_trace("[NVUT] %s(): enter version conflict fail!\n\r", __FUNCTION__); |
| 14476 | result = KAL_FALSE; |
| 14477 | goto reset_default; |
| 14478 | } |
| 14479 | |
| 14480 | nvram_ut_trace("[NVUT] %s(): nvram_ut_assert_flag(%d) nvram ota state.\n\r", __FUNCTION__, nvram_ut_assert_flag); |
| 14481 | if(KAL_TRUE != access_chksum_test_lid()) |
| 14482 | { |
| 14483 | nvram_ut_trace("[NVUT] %s(): access chksum test lid fail!\n\r", __FUNCTION__); |
| 14484 | result = KAL_FALSE; |
| 14485 | } |
| 14486 | |
| 14487 | reset_default: |
| 14488 | |
| 14489 | // reset chksum algo test lid to default |
| 14490 | if(KAL_TRUE != reset_test_lids(chksum_algo_test_lid_list,chksum_algo_test_lid_number)) |
| 14491 | { |
| 14492 | nvram_ut_trace("[NVUT] %s(): %d reset to default fail!\n\r", __FUNCTION__, __LINE__); |
| 14493 | result = KAL_FALSE; |
| 14494 | } |
| 14495 | |
| 14496 | final: |
| 14497 | |
| 14498 | #ifdef __NVRAM_LID_CACHE__ |
| 14499 | mark_nvram_cache_ready(); |
| 14500 | #endif |
| 14501 | |
| 14502 | return result; |
| 14503 | |
| 14504 | } |
| 14505 | |
| 14506 | /* |
| 14507 | LID chksum algo from def to enhance with out verno+1 |
| 14508 | Normal LIDs: except calibrate & important |
| 14509 | */ |
| 14510 | kal_bool ota_boot_lid_algo_def_to_en_normal() |
| 14511 | { |
| 14512 | kal_bool result = KAL_TRUE; |
| 14513 | kal_uint8 i,j; |
| 14514 | nvram_ltable_entry_struct *ldi = NULL;; |
| 14515 | |
| 14516 | #ifdef __NVRAM_LID_CACHE__ |
| 14517 | nvram_cache_reset(); |
| 14518 | #endif |
| 14519 | |
| 14520 | if(KAL_TRUE != test_chksum_algo_ota_boot_init(chksum_algo_normal_list, chksum_algo_normal_len)) |
| 14521 | { |
| 14522 | nvram_ut_trace("[NVUT] %s(): modify MD SW version fail!\n\r", __FUNCTION__); |
| 14523 | result = KAL_FALSE; |
| 14524 | goto final; |
| 14525 | } |
| 14526 | |
| 14527 | // write LID record(1) and backup data for data check after OTA |
| 14528 | |
| 14529 | for(i=0; i< chksum_algo_normal_len; i++) |
| 14530 | { |
| 14531 | nvram_util_get_data_item(&ldi, chksum_algo_normal_list[i]); |
| 14532 | kal_mem_set(data_buffer, 0, ldi->size); |
| 14533 | data_buffer[0] = 0x1; |
| 14534 | data_buffer[1] = 0x2; |
| 14535 | data_buffer[2] = 0x3; |
| 14536 | for(j = 1; j <= ldi->total_records; j++) |
| 14537 | { |
| 14538 | if(!nvram_external_write_data(ldi->LID, j, (kal_uint8 *)data_buffer, ldi->size)) |
| 14539 | { |
| 14540 | nvram_ut_trace("[NVUT] %s():%d write test LIDs(0x%x) fail!\n\r", __FUNCTION__, __LINE__, ldi->LID); |
| 14541 | result = KAL_FALSE; |
| 14542 | goto reset_default; |
| 14543 | } |
| 14544 | } |
| 14545 | } |
| 14546 | |
| 14547 | if(KAL_TRUE != nvram_chg_chksum_test_lid_info(FROM_DEF_TO_ENHANCE,KAL_FALSE, chksum_algo_normal_list, chksum_algo_normal_len)) |
| 14548 | { |
| 14549 | nvram_ut_trace("[NVUT] %s():chksum change fail!\n\r", __FUNCTION__); |
| 14550 | result = KAL_FALSE; |
| 14551 | goto reset_default; |
| 14552 | } |
| 14553 | |
| 14554 | // Call nvram_init |
| 14555 | nvram_ut_assert_flag = 0; |
| 14556 | nvram_boot_trace = 0; |
| 14557 | nvram_init(); |
| 14558 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 14559 | { |
| 14560 | nvram_ut_trace("[NVUT] %s(): enter version conflict fail!\n\r", __FUNCTION__); |
| 14561 | result = KAL_FALSE; |
| 14562 | goto reset_default; |
| 14563 | } |
| 14564 | nvram_ut_trace("[NVUT] %s(): nvram_ut_assert_flag(%d) nvram ota state.\n\r", __FUNCTION__, nvram_ut_assert_flag); |
| 14565 | |
| 14566 | //Read and check record data |
| 14567 | for(i=0; i<chksum_algo_normal_len; i++) |
| 14568 | { |
| 14569 | nvram_util_get_data_item(&ldi, chksum_algo_normal_list[i]); |
| 14570 | kal_mem_set(cmp_buffer, 0, ldi->size); |
| 14571 | kal_mem_set(data_buffer, 0, ldi->size); |
| 14572 | data_buffer[0] = 0x1; |
| 14573 | data_buffer[1] = 0x2; |
| 14574 | data_buffer[2] = 0x3; |
| 14575 | for(j = 1; j <= ldi->total_records; j++) |
| 14576 | { |
| 14577 | if(!nvram_external_read_data(ldi->LID,j,(kal_uint8 *)cmp_buffer, ldi->size)) |
| 14578 | { |
| 14579 | nvram_ut_trace("[NVUT] %s():read lid(%x) fail!\n\r", __FUNCTION__, chksum_algo_normal_list[i]); |
| 14580 | result = KAL_FALSE; |
| 14581 | goto reset_default; |
| 14582 | } |
| 14583 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 14584 | { |
| 14585 | nvram_ut_trace("[NVUT] %s():lid(%x) data check error after OTA.\n\r", __FUNCTION__, chksum_algo_normal_list[i]); |
| 14586 | result = KAL_FALSE; |
| 14587 | goto reset_default; |
| 14588 | } |
| 14589 | } |
| 14590 | } |
| 14591 | |
| 14592 | reset_default: |
| 14593 | |
| 14594 | // reset chksum algo test lid to default |
| 14595 | if(KAL_TRUE != reset_test_lids(chksum_algo_normal_list,chksum_algo_normal_len)) |
| 14596 | { |
| 14597 | nvram_ut_trace("[NVUT] %s(): %d reset test lid to default setting fail!\n\r", __FUNCTION__, __LINE__); |
| 14598 | result = KAL_FALSE; |
| 14599 | } |
| 14600 | |
| 14601 | final: |
| 14602 | |
| 14603 | #ifdef __NVRAM_LID_CACHE__ |
| 14604 | mark_nvram_cache_ready(); |
| 14605 | #endif |
| 14606 | |
| 14607 | return result; |
| 14608 | |
| 14609 | } |
| 14610 | |
| 14611 | kal_bool ota_boot_lid_algo_def_to_en_special() |
| 14612 | { |
| 14613 | kal_bool result = KAL_TRUE; |
| 14614 | |
| 14615 | #ifdef __NVRAM_LID_CACHE__ |
| 14616 | nvram_cache_reset(); |
| 14617 | #endif |
| 14618 | |
| 14619 | if(KAL_TRUE != test_chksum_algo_ota_boot_init(chksum_algo_special_list, chksum_algo_special_len)) |
| 14620 | { |
| 14621 | nvram_ut_trace("[NVUT] %s(): modify MD SW version fail!\n\r", __FUNCTION__); |
| 14622 | result = KAL_FALSE; |
| 14623 | goto final; |
| 14624 | } |
| 14625 | |
| 14626 | if(KAL_TRUE != nvram_chg_chksum_test_lid_info(FROM_DEF_TO_ENHANCE,KAL_FALSE, chksum_algo_special_list, chksum_algo_special_len)) |
| 14627 | { |
| 14628 | nvram_ut_trace("[NVUT] %s():chksum change fail!\n\r", __FUNCTION__); |
| 14629 | result = KAL_FALSE; |
| 14630 | goto reset_default; |
| 14631 | } |
| 14632 | // Call nvram_init |
| 14633 | nvram_ut_assert_flag = 0; |
| 14634 | nvram_boot_trace = 0; |
| 14635 | nvram_init(); |
| 14636 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 14637 | { |
| 14638 | nvram_ut_trace("[NVUT] %s(): enter version conflict fail!\n\r", __FUNCTION__); |
| 14639 | result = KAL_FALSE; |
| 14640 | } |
| 14641 | |
| 14642 | nvram_ut_trace("[NVUT] %s(): nvram_ut_assert_flag(%d) nvram ota state.\n\r", __FUNCTION__, nvram_ut_assert_flag); |
| 14643 | if(0 == nvram_ut_assert_flag) |
| 14644 | { |
| 14645 | nvram_ut_trace("[NVUT] %s(): line: %d nvram ota not assert.\n\r", __FUNCTION__, __LINE__); |
| 14646 | result = KAL_FALSE; |
| 14647 | } |
| 14648 | |
| 14649 | reset_default: |
| 14650 | |
| 14651 | // reset chksum algo test lid to default |
| 14652 | if(KAL_TRUE != reset_test_lids(chksum_algo_special_list,chksum_algo_special_len)) |
| 14653 | { |
| 14654 | nvram_ut_trace("[NVUT] %s(): %d reset test lid to default setting fail!\n\r", __FUNCTION__, __LINE__); |
| 14655 | result = KAL_FALSE; |
| 14656 | } |
| 14657 | |
| 14658 | final: |
| 14659 | |
| 14660 | #ifdef __NVRAM_LID_CACHE__ |
| 14661 | mark_nvram_cache_ready(); |
| 14662 | #endif |
| 14663 | |
| 14664 | return result; |
| 14665 | |
| 14666 | } |
| 14667 | |
| 14668 | /**/ |
| 14669 | kal_bool ota_boot_lid_algo_en_A_to_B_inc_verno() |
| 14670 | { |
| 14671 | kal_uint8 i; |
| 14672 | nvram_ltable_entry_struct * ldi=NULL; |
| 14673 | kal_bool result = KAL_TRUE; |
| 14674 | |
| 14675 | |
| 14676 | #ifdef __NVRAM_LID_CACHE__ |
| 14677 | nvram_cache_reset(); |
| 14678 | #endif |
| 14679 | |
| 14680 | kal_mem_cpy(&chksum_config_backup,&NVRAM_CHK_CONFIG,sizeof(NVRAM_CHK_CONFIG)); |
| 14681 | for(i=0; i< chksum_algo_test_lid_number; i++) |
| 14682 | { |
| 14683 | // Add ATTR_ENHANCE for test lid |
| 14684 | reset_test_lid_default_setting(chksum_algo_test_lid_list[i]); |
| 14685 | nvram_util_get_data_item(&ldi,chksum_algo_test_lid_list[i]); |
| 14686 | ldi->attr |= NVRAM_ATTR_CHKSUM_ENHNC_ALGRTHM; |
| 14687 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN,NVRAM_APP_RESERVED,ldi,1,ldi->total_records)) |
| 14688 | { |
| 14689 | nvram_ut_trace("[NVUT] %s(): nvram reset lid fail!\n\r", __FUNCTION__); |
| 14690 | result = KAL_FALSE; |
| 14691 | goto reset_default; |
| 14692 | } |
| 14693 | } |
| 14694 | // CHKSUM A_TO_B |
| 14695 | if(KAL_TRUE != nvram_chg_chksum_test_lid_info(FROM_ENHANCE_A_TO_B,KAL_TRUE, chksum_algo_test_lid_list, chksum_algo_test_lid_number)) |
| 14696 | { |
| 14697 | nvram_ut_trace("[NVUT] %s():chksum change fail!\n\r", __FUNCTION__); |
| 14698 | result = KAL_FALSE; |
| 14699 | goto reset_default; |
| 14700 | } |
| 14701 | //reset SYS LID |
| 14702 | if(KAL_TRUE != nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 14703 | { |
| 14704 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_read(): reset SYS LID fail!\n\r"); |
| 14705 | result = KAL_FALSE; |
| 14706 | goto reset_default; |
| 14707 | } |
| 14708 | // Modify sw version |
| 14709 | if(KAL_TRUE != modify_md_sw_version()) |
| 14710 | { |
| 14711 | nvram_ut_trace("[NVUT]%s(): modify_md_sw_version(): fail!\n\r", __FUNCTION__); |
| 14712 | result = KAL_FALSE; |
| 14713 | goto reset_default; |
| 14714 | } |
| 14715 | // Call nvram_init |
| 14716 | nvram_ut_assert_flag = 0; |
| 14717 | nvram_boot_trace = 0; |
| 14718 | nvram_init(); |
| 14719 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 14720 | { |
| 14721 | nvram_ut_trace("[NVUT] %s(): enter version conflict fail!\n\r", __FUNCTION__); |
| 14722 | result = KAL_FALSE; |
| 14723 | goto reset_default; |
| 14724 | } |
| 14725 | |
| 14726 | nvram_ut_trace("[NVUT] %s(): nvram_ut_assert_flag(%d) nvram ota state.\n\r", __FUNCTION__, nvram_ut_assert_flag); |
| 14727 | if(!access_chksum_test_lid()) |
| 14728 | { |
| 14729 | nvram_ut_trace("[NVUT] %s(): access chksum test lid fail!\n\r", __FUNCTION__); |
| 14730 | result = KAL_FALSE; |
| 14731 | } |
| 14732 | |
| 14733 | reset_default: |
| 14734 | |
| 14735 | // Recover customer config chksum algo |
| 14736 | kal_mem_cpy(&NVRAM_CHK_CONFIG,&chksum_config_backup, sizeof(NVRAM_CHK_CONFIG)); |
| 14737 | if(!reset_chksum_info_lid()) |
| 14738 | { |
| 14739 | nvram_ut_trace("[NVUT] %s(): reset chksum info lid error!\n\r", __FUNCTION__); |
| 14740 | result = KAL_FALSE; |
| 14741 | } |
| 14742 | // reset chksum algo test lid to default |
| 14743 | if(!reset_test_lids(chksum_algo_test_lid_list,chksum_algo_test_lid_number)) |
| 14744 | { |
| 14745 | nvram_ut_trace("[NVUT] %s(): %d reset to default setting fail!\n\r", __FUNCTION__, __LINE__); |
| 14746 | result = KAL_FALSE; |
| 14747 | } |
| 14748 | #ifdef __NVRAM_LID_CACHE__ |
| 14749 | mark_nvram_cache_ready(); |
| 14750 | #endif |
| 14751 | |
| 14752 | return result; |
| 14753 | |
| 14754 | } |
| 14755 | |
| 14756 | |
| 14757 | kal_bool ota_boot_lid_algo_en_A_to_B_normal() |
| 14758 | { |
| 14759 | kal_uint8 i, j; |
| 14760 | nvram_ltable_entry_struct * ldi=NULL; |
| 14761 | kal_bool result = KAL_TRUE; |
| 14762 | |
| 14763 | |
| 14764 | #ifdef __NVRAM_LID_CACHE__ |
| 14765 | nvram_cache_reset(); |
| 14766 | #endif |
| 14767 | |
| 14768 | kal_mem_cpy(&chksum_config_backup,&NVRAM_CHK_CONFIG,sizeof(NVRAM_CHK_CONFIG)); |
| 14769 | |
| 14770 | for(i=0; i< chksum_algo_normal_len; i++) |
| 14771 | { |
| 14772 | // Add ATTR_ENHANCE for test lid |
| 14773 | nvram_util_get_data_item(&ldi, chksum_algo_normal_list[i]); |
| 14774 | reset_test_lid_default_setting(ldi->LID); |
| 14775 | |
| 14776 | ldi->attr |= NVRAM_ATTR_CHKSUM_ENHNC_ALGRTHM; |
| 14777 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN,NVRAM_APP_RESERVED,ldi,1,ldi->total_records)) |
| 14778 | { |
| 14779 | nvram_ut_trace("[NVUT] %s(): nvram reset lid fail!\n\r", __FUNCTION__); |
| 14780 | result = KAL_FALSE; |
| 14781 | goto reset_default; |
| 14782 | } |
| 14783 | |
| 14784 | kal_mem_set(data_buffer, 0, ldi->size); |
| 14785 | data_buffer[0] = 0x1; |
| 14786 | data_buffer[1] = 0x2; |
| 14787 | data_buffer[2] = 0x3; |
| 14788 | |
| 14789 | for(j = 1; j <= ldi->total_records; j++) |
| 14790 | { |
| 14791 | if(NVRAM_IO_ERRNO_OK != nvram_write_data_item(ldi,j,(kal_uint8 *)data_buffer,KAL_FALSE)) |
| 14792 | { |
| 14793 | nvram_ut_trace("[NVUT] %s(): write test LIDs fail!\n\r", __FUNCTION__); |
| 14794 | result = KAL_FALSE; |
| 14795 | goto reset_default; |
| 14796 | } |
| 14797 | } |
| 14798 | } |
| 14799 | // CHKSUM A_TO_B |
| 14800 | if(!nvram_chg_chksum_test_lid_info(FROM_ENHANCE_A_TO_B,KAL_FALSE, chksum_algo_normal_list, chksum_algo_normal_len)) |
| 14801 | { |
| 14802 | nvram_ut_trace("[NVUT] %s():chksum change fail!\n\r", __FUNCTION__); |
| 14803 | result = KAL_FALSE; |
| 14804 | goto reset_default; |
| 14805 | } |
| 14806 | //reset SYS LID |
| 14807 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 14808 | { |
| 14809 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_read(): reset SYS LID fail!\n\r"); |
| 14810 | result = KAL_FALSE; |
| 14811 | goto reset_default; |
| 14812 | } |
| 14813 | // Modify sw version |
| 14814 | if(!modify_md_sw_version()) |
| 14815 | { |
| 14816 | nvram_ut_trace("[NVUT]%s(): modify_md_sw_version(): fail!\n\r", __FUNCTION__); |
| 14817 | result = KAL_FALSE; |
| 14818 | goto reset_default; |
| 14819 | } |
| 14820 | // Call nvram_init |
| 14821 | nvram_ut_assert_flag = 0; |
| 14822 | nvram_boot_trace = 0; |
| 14823 | nvram_init(); |
| 14824 | |
| 14825 | nvram_ut_trace("[NVUT] %s():nvram_ut_assert_flag(0x%x) enter version conflict fail!\n\r", __FUNCTION__, nvram_ut_assert_flag); |
| 14826 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 14827 | { |
| 14828 | nvram_ut_trace("[NVUT] %s(): enter version conflict fail!\n\r", __FUNCTION__); |
| 14829 | result = KAL_FALSE; |
| 14830 | goto reset_default; |
| 14831 | } |
| 14832 | |
| 14833 | nvram_ut_trace("[NVUT] %s(): nvram_ut_assert_flag(%d) nvram ota state.\n\r", __FUNCTION__, nvram_ut_assert_flag); |
| 14834 | for(i=0; i<chksum_algo_normal_len; i++) |
| 14835 | { |
| 14836 | nvram_util_get_data_item(&ldi, chksum_algo_normal_list[i]); |
| 14837 | kal_mem_set(data_buffer, 0, ldi->size); |
| 14838 | data_buffer[0] = 0x1; |
| 14839 | data_buffer[1] = 0x2; |
| 14840 | data_buffer[2] = 0x3; |
| 14841 | for(j = 1; j <= ldi->total_records; j++) |
| 14842 | { |
| 14843 | kal_mem_set(cmp_buffer, 0, ldi->size); |
| 14844 | if(!nvram_external_read_data(ldi->LID,j,(kal_uint8 *)cmp_buffer, ldi->size)) |
| 14845 | { |
| 14846 | nvram_ut_trace("[NVUT] %s():read lid(%x) fail!\n\r", __FUNCTION__, chksum_algo_normal_list[i]); |
| 14847 | result = KAL_FALSE; |
| 14848 | goto reset_default; |
| 14849 | } |
| 14850 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 14851 | { |
| 14852 | nvram_ut_trace("[NVUT] %s():lid(%x) data check error after OTA.\n\r", __FUNCTION__, chksum_algo_normal_list[i]); |
| 14853 | result = KAL_FALSE; |
| 14854 | goto reset_default; |
| 14855 | } |
| 14856 | } |
| 14857 | } |
| 14858 | |
| 14859 | reset_default: |
| 14860 | // Recover customer config chksum algo |
| 14861 | kal_mem_cpy(&NVRAM_CHK_CONFIG,&chksum_config_backup, sizeof(NVRAM_CHK_CONFIG)); |
| 14862 | if(!reset_chksum_info_lid()) |
| 14863 | { |
| 14864 | nvram_ut_trace("[NVUT] %s(): reset chksum info lid error!\n\r", __FUNCTION__); |
| 14865 | result = KAL_FALSE; |
| 14866 | } |
| 14867 | // reset chksum algo test lid to default |
| 14868 | if(!reset_test_lids(chksum_algo_normal_list,chksum_algo_normal_len)) |
| 14869 | { |
| 14870 | nvram_ut_trace("[NVUT] %s(): %d reset to default fail!\n\r", __FUNCTION__, __LINE__); |
| 14871 | result = KAL_FALSE; |
| 14872 | } |
| 14873 | |
| 14874 | final: |
| 14875 | |
| 14876 | #ifdef __NVRAM_LID_CACHE__ |
| 14877 | mark_nvram_cache_ready(); |
| 14878 | #endif |
| 14879 | |
| 14880 | return result; |
| 14881 | |
| 14882 | } |
| 14883 | |
| 14884 | |
| 14885 | kal_bool ota_boot_lid_algo_en_A_to_B_special() |
| 14886 | { |
| 14887 | kal_uint8 i; |
| 14888 | nvram_ltable_entry_struct * ldi=NULL; |
| 14889 | kal_bool result = KAL_TRUE; |
| 14890 | |
| 14891 | |
| 14892 | #ifdef __NVRAM_LID_CACHE__ |
| 14893 | nvram_cache_reset(); |
| 14894 | #endif |
| 14895 | |
| 14896 | kal_mem_cpy(&chksum_config_backup,&NVRAM_CHK_CONFIG,sizeof(NVRAM_CHK_CONFIG)); |
| 14897 | for(i=0; i< chksum_algo_special_len; i++) |
| 14898 | { |
| 14899 | // Add ATTR_ENHANCE for test lid |
| 14900 | reset_test_lid_default_setting(chksum_algo_special_list[i]); |
| 14901 | nvram_util_get_data_item(&ldi,chksum_algo_special_list[i]); |
| 14902 | ldi->attr |= NVRAM_ATTR_CHKSUM_ENHNC_ALGRTHM; |
| 14903 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN,NVRAM_APP_RESERVED,ldi,1,ldi->total_records)) |
| 14904 | { |
| 14905 | nvram_ut_trace("[NVUT] %s(): nvram reset lid fail!\n\r", __FUNCTION__); |
| 14906 | result = KAL_FALSE; |
| 14907 | goto reset_default; |
| 14908 | } |
| 14909 | } |
| 14910 | // CHKSUM A_TO_B |
| 14911 | if(!nvram_chg_chksum_test_lid_info(FROM_ENHANCE_A_TO_B,KAL_FALSE, chksum_algo_special_list, chksum_algo_special_len)) |
| 14912 | { |
| 14913 | nvram_ut_trace("[NVUT] %s():chksum change fail!\n\r", __FUNCTION__); |
| 14914 | result = KAL_FALSE; |
| 14915 | goto reset_default; |
| 14916 | } |
| 14917 | //reset SYS LID |
| 14918 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 14919 | { |
| 14920 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_read(): reset SYS LID fail!\n\r"); |
| 14921 | result = KAL_FALSE; |
| 14922 | goto reset_default; |
| 14923 | } |
| 14924 | // Modify sw version |
| 14925 | if(!modify_md_sw_version()) |
| 14926 | { |
| 14927 | nvram_ut_trace("[NVUT]%s(): modify_md_sw_version(): fail!\n\r", __FUNCTION__); |
| 14928 | result = KAL_FALSE; |
| 14929 | goto reset_default; |
| 14930 | } |
| 14931 | // Call nvram_init |
| 14932 | nvram_ut_assert_flag = 0; |
| 14933 | nvram_boot_trace = 0; |
| 14934 | nvram_init(); |
| 14935 | |
| 14936 | nvram_ut_trace("[NVUT] %s():nvram_ut_assert_flag(0x%x) enter version conflict fail!\n\r", __FUNCTION__, nvram_ut_assert_flag); |
| 14937 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 14938 | { |
| 14939 | nvram_ut_trace("[NVUT] %s(): enter version conflict fail!\n\r", __FUNCTION__); |
| 14940 | result = KAL_FALSE; |
| 14941 | } |
| 14942 | |
| 14943 | nvram_ut_trace("[NVUT] %s(): nvram_ut_assert_flag(%d) nvram ota state.\n\r", __FUNCTION__, nvram_ut_assert_flag); |
| 14944 | if(0 == nvram_ut_assert_flag) |
| 14945 | { |
| 14946 | nvram_ut_trace("[NVUT] %s(): ota not assert.\n\r", __FUNCTION__); |
| 14947 | result = KAL_FALSE; |
| 14948 | } |
| 14949 | |
| 14950 | reset_default: |
| 14951 | |
| 14952 | // Recover customer config chksum algo |
| 14953 | kal_mem_cpy(&NVRAM_CHK_CONFIG,&chksum_config_backup, sizeof(NVRAM_CHK_CONFIG)); |
| 14954 | if(!reset_chksum_info_lid()) |
| 14955 | { |
| 14956 | nvram_ut_trace("[NVUT] %s(): reset chksum info lid error!\n\r", __FUNCTION__); |
| 14957 | result = KAL_FALSE; |
| 14958 | } |
| 14959 | // reset chksum algo test lid to default |
| 14960 | if(!reset_test_lids(chksum_algo_special_list,chksum_algo_special_len)) |
| 14961 | { |
| 14962 | nvram_ut_trace("[NVUT] %s(): %d reset to default fail!\n\r", __FUNCTION__, __LINE__); |
| 14963 | result = KAL_FALSE; |
| 14964 | } |
| 14965 | #ifdef __NVRAM_LID_CACHE__ |
| 14966 | mark_nvram_cache_ready(); |
| 14967 | #endif |
| 14968 | |
| 14969 | return result; |
| 14970 | |
| 14971 | } |
| 14972 | |
| 14973 | kal_bool ota_boot_lid_algo_en_to_def_incr_verno() |
| 14974 | { |
| 14975 | kal_bool result=KAL_TRUE; |
| 14976 | kal_uint8 i; |
| 14977 | nvram_ltable_entry_struct *ldi=NULL; |
| 14978 | |
| 14979 | #ifdef __NVRAM_LID_CACHE__ |
| 14980 | nvram_cache_reset(); |
| 14981 | #endif |
| 14982 | |
| 14983 | for(i=0; i< chksum_algo_test_lid_number; i++) |
| 14984 | { |
| 14985 | // Add ATTR_ENHANCE for test lid |
| 14986 | reset_test_lid_default_setting(chksum_algo_test_lid_list[i]); |
| 14987 | nvram_util_get_data_item(&ldi,chksum_algo_test_lid_list[i]); |
| 14988 | ldi->attr |= NVRAM_ATTR_CHKSUM_ENHNC_ALGRTHM; |
| 14989 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN,NVRAM_APP_RESERVED,ldi,1,ldi->total_records)) |
| 14990 | { |
| 14991 | nvram_ut_trace("[NVUT] %s(): nvram reset lid fail!\n\r", __FUNCTION__); |
| 14992 | result = KAL_FALSE; |
| 14993 | goto reset_default; |
| 14994 | } |
| 14995 | } |
| 14996 | if(!nvram_chg_chksum_test_lid_info(FROM_ENHANCE_TO_DEF,KAL_TRUE, chksum_algo_test_lid_list, chksum_algo_test_lid_number)) |
| 14997 | { |
| 14998 | nvram_ut_trace("[NVUT] %s():chksum change fail!\n\r", __FUNCTION__); |
| 14999 | result = KAL_FALSE; |
| 15000 | goto reset_default; |
| 15001 | } |
| 15002 | //reset SYS LID |
| 15003 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 15004 | { |
| 15005 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_read(): reset SYS LID fail!\n\r"); |
| 15006 | result = KAL_FALSE; |
| 15007 | goto reset_default; |
| 15008 | } |
| 15009 | // Modify sw version |
| 15010 | if(!modify_md_sw_version()) |
| 15011 | { |
| 15012 | nvram_ut_trace("[NVUT]%s(): modify_md_sw_version(): fail!\n\r", __FUNCTION__); |
| 15013 | result = KAL_FALSE; |
| 15014 | goto reset_default; |
| 15015 | } |
| 15016 | // Call nvram_init |
| 15017 | nvram_ut_assert_flag = 0; |
| 15018 | nvram_boot_trace = 0; |
| 15019 | nvram_init(); |
| 15020 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 15021 | { |
| 15022 | nvram_ut_trace("[NVUT] %s(): enter version conflict fail!\n\r", __FUNCTION__); |
| 15023 | result = KAL_FALSE; |
| 15024 | goto reset_default; |
| 15025 | } |
| 15026 | |
| 15027 | nvram_ut_trace("[NVUT] %s(): nvram_ut_assert_flag(%d) nvram ota state.\n\r", __FUNCTION__, nvram_ut_assert_flag); |
| 15028 | if(!access_chksum_test_lid()) |
| 15029 | { |
| 15030 | nvram_ut_trace("[NVUT] %s(): access chksum test lid fail!\n\r", __FUNCTION__); |
| 15031 | result = KAL_FALSE; |
| 15032 | } |
| 15033 | |
| 15034 | reset_default: |
| 15035 | |
| 15036 | // reset chksum algo test lid to default |
| 15037 | if(!reset_test_lids(chksum_algo_test_lid_list,chksum_algo_test_lid_number)) |
| 15038 | { |
| 15039 | nvram_ut_trace("[NVUT] %s(): %d reset to default fail!\n\r", __FUNCTION__, __LINE__); |
| 15040 | result = KAL_FALSE; |
| 15041 | } |
| 15042 | |
| 15043 | #ifdef __NVRAM_LID_CACHE__ |
| 15044 | mark_nvram_cache_ready(); |
| 15045 | #endif |
| 15046 | |
| 15047 | return result; |
| 15048 | } |
| 15049 | |
| 15050 | kal_bool ota_boot_lid_algo_en_to_def_normal() |
| 15051 | { |
| 15052 | kal_bool result = KAL_TRUE; |
| 15053 | kal_uint8 i, j; |
| 15054 | nvram_ltable_entry_struct *ldi=NULL; |
| 15055 | |
| 15056 | #ifdef __NVRAM_LID_CACHE__ |
| 15057 | nvram_cache_reset(); |
| 15058 | #endif |
| 15059 | |
| 15060 | for(i=0; i< chksum_algo_normal_len; i++) |
| 15061 | { |
| 15062 | // Add ATTR_ENHANCE for test lid |
| 15063 | nvram_util_get_data_item(&ldi,chksum_algo_normal_list[i]); |
| 15064 | reset_test_lid_default_setting(ldi->LID); |
| 15065 | |
| 15066 | ldi->attr |= NVRAM_ATTR_CHKSUM_ENHNC_ALGRTHM; |
| 15067 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN,NVRAM_APP_RESERVED,ldi,1,ldi->total_records)) |
| 15068 | { |
| 15069 | nvram_ut_trace("[NVUT] %s(): nvram reset lid fail!\n\r", __FUNCTION__); |
| 15070 | result = KAL_FALSE; |
| 15071 | goto reset_default; |
| 15072 | } |
| 15073 | |
| 15074 | kal_mem_set(data_buffer, 0, ldi->size); |
| 15075 | data_buffer[0] = 0x1; |
| 15076 | data_buffer[1] = 0x2; |
| 15077 | data_buffer[2] = 0x3; |
| 15078 | |
| 15079 | for(j = 1; j <= ldi->total_records; j++) |
| 15080 | { |
| 15081 | if(NVRAM_IO_ERRNO_OK != nvram_write_data_item(ldi,j,(kal_uint8 *)data_buffer,KAL_FALSE)) |
| 15082 | { |
| 15083 | nvram_ut_trace("[NVUT] %s(): write test LIDs fail!\n\r", __FUNCTION__); |
| 15084 | result = KAL_FALSE; |
| 15085 | goto reset_default; |
| 15086 | } |
| 15087 | } |
| 15088 | } |
| 15089 | // CHKSUM A_TO_B |
| 15090 | if(!nvram_chg_chksum_test_lid_info(FROM_ENHANCE_TO_DEF,KAL_FALSE, chksum_algo_normal_list, chksum_algo_normal_len)) |
| 15091 | { |
| 15092 | nvram_ut_trace("[NVUT] %s():chksum change fail!\n\r", __FUNCTION__); |
| 15093 | result = KAL_FALSE; |
| 15094 | goto reset_default; |
| 15095 | } |
| 15096 | //reset SYS LID |
| 15097 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 15098 | { |
| 15099 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_read(): reset SYS LID fail!\n\r"); |
| 15100 | result = KAL_FALSE; |
| 15101 | goto reset_default; |
| 15102 | } |
| 15103 | // Modify sw version |
| 15104 | if(!modify_md_sw_version()) |
| 15105 | { |
| 15106 | nvram_ut_trace("[NVUT]%s(): modify_md_sw_version(): fail!\n\r", __FUNCTION__); |
| 15107 | result = KAL_FALSE; |
| 15108 | goto reset_default; |
| 15109 | } |
| 15110 | |
| 15111 | // Call nvram_init |
| 15112 | nvram_ut_assert_flag = 0; |
| 15113 | nvram_boot_trace = 0; |
| 15114 | nvram_init(); |
| 15115 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 15116 | { |
| 15117 | nvram_ut_trace("[NVUT] %s(): enter version conflict fail!\n\r", __FUNCTION__); |
| 15118 | result = KAL_FALSE; |
| 15119 | goto reset_default; |
| 15120 | } |
| 15121 | |
| 15122 | nvram_ut_trace("[NVUT] %s(): nvram_ut_assert_flag(%d) nvram ota state.\n\r", __FUNCTION__, nvram_ut_assert_flag); |
| 15123 | //Read and check record data |
| 15124 | for(i=0; i<chksum_algo_normal_len; i++) |
| 15125 | { |
| 15126 | nvram_util_get_data_item(&ldi, chksum_algo_normal_list[i]); |
| 15127 | kal_mem_set(cmp_buffer, 0, ldi->size); |
| 15128 | kal_mem_set(data_buffer, 0, ldi->size); |
| 15129 | data_buffer[0] = 0x1; |
| 15130 | data_buffer[1] = 0x2; |
| 15131 | data_buffer[2] = 0x3; |
| 15132 | for(j = 1; j <= ldi->total_records; j++) |
| 15133 | { |
| 15134 | if(!nvram_external_read_data(ldi->LID,j,(kal_uint8 *)cmp_buffer, ldi->size)) |
| 15135 | { |
| 15136 | nvram_ut_trace("[NVUT] %s():read lid(%x) fail!\n\r", __FUNCTION__, chksum_algo_normal_list[i]); |
| 15137 | result = KAL_FALSE; |
| 15138 | goto reset_default; |
| 15139 | } |
| 15140 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 15141 | { |
| 15142 | nvram_ut_trace("[NVUT] %s():lid(%x) data check error after OTA.\n\r", __FUNCTION__, chksum_algo_normal_list[i]); |
| 15143 | result = KAL_FALSE; |
| 15144 | goto reset_default; |
| 15145 | } |
| 15146 | } |
| 15147 | } |
| 15148 | |
| 15149 | reset_default: |
| 15150 | |
| 15151 | // reset chksum algo test lid to default |
| 15152 | if(!reset_test_lids(chksum_algo_normal_list,chksum_algo_normal_len)) |
| 15153 | { |
| 15154 | nvram_ut_trace("[NVUT] %s(): %d reset to default fail!\n\r", __FUNCTION__, __LINE__); |
| 15155 | result = KAL_FALSE; |
| 15156 | } |
| 15157 | #ifdef __NVRAM_LID_CACHE__ |
| 15158 | mark_nvram_cache_ready(); |
| 15159 | #endif |
| 15160 | return result; |
| 15161 | } |
| 15162 | |
| 15163 | kal_bool ota_boot_lid_algo_en_to_def_special() |
| 15164 | { |
| 15165 | kal_bool result = KAL_TRUE; |
| 15166 | kal_uint8 i; |
| 15167 | nvram_ltable_entry_struct *ldi=NULL; |
| 15168 | |
| 15169 | #ifdef __NVRAM_LID_CACHE__ |
| 15170 | nvram_cache_reset(); |
| 15171 | #endif |
| 15172 | |
| 15173 | for(i=0; i< chksum_algo_special_len; i++) |
| 15174 | { |
| 15175 | // Add ATTR_ENHANCE for test lid |
| 15176 | reset_test_lid_default_setting(chksum_algo_special_list[i]); |
| 15177 | nvram_util_get_data_item(&ldi,chksum_algo_special_list[i]); |
| 15178 | ldi->attr |= NVRAM_ATTR_CHKSUM_ENHNC_ALGRTHM; |
| 15179 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN,NVRAM_APP_RESERVED,ldi,1,ldi->total_records)) |
| 15180 | { |
| 15181 | nvram_ut_trace("[NVUT] %s(): nvram reset lid fail!\n\r", __FUNCTION__); |
| 15182 | result = KAL_FALSE; |
| 15183 | goto reset_default; |
| 15184 | } |
| 15185 | } |
| 15186 | |
| 15187 | if(!nvram_chg_chksum_test_lid_info(FROM_ENHANCE_TO_DEF,KAL_FALSE, chksum_algo_special_list, chksum_algo_special_len)) |
| 15188 | { |
| 15189 | nvram_ut_trace("[NVUT] %s():chksum change fail!\n\r", __FUNCTION__); |
| 15190 | result = KAL_FALSE; |
| 15191 | goto reset_default; |
| 15192 | } |
| 15193 | //reset SYS LID |
| 15194 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 15195 | { |
| 15196 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_read(): reset SYS LID fail!\n\r"); |
| 15197 | result = KAL_FALSE; |
| 15198 | goto reset_default; |
| 15199 | } |
| 15200 | // Modify sw version |
| 15201 | if(!modify_md_sw_version()) |
| 15202 | { |
| 15203 | nvram_ut_trace("[NVUT]%s(): modify_md_sw_version(): fail!\n\r", __FUNCTION__); |
| 15204 | result = KAL_FALSE; |
| 15205 | goto reset_default; |
| 15206 | } |
| 15207 | // Call nvram_init |
| 15208 | nvram_ut_assert_flag = 0; |
| 15209 | nvram_boot_trace = 0; |
| 15210 | nvram_init(); |
| 15211 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 15212 | { |
| 15213 | nvram_ut_trace("[NVUT] %s(): enter version conflict fail!\n\r", __FUNCTION__); |
| 15214 | result = KAL_FALSE; |
| 15215 | } |
| 15216 | |
| 15217 | nvram_ut_trace("[NVUT] %s(): nvram_ut_assert_flag(%d) nvram ota state.\n\r", __FUNCTION__, nvram_ut_assert_flag); |
| 15218 | if(0 == nvram_ut_assert_flag) |
| 15219 | { |
| 15220 | nvram_ut_trace("[NVUT] %s(): ota not assert.\n\r", __FUNCTION__); |
| 15221 | result = KAL_FALSE; |
| 15222 | } |
| 15223 | |
| 15224 | reset_default: |
| 15225 | |
| 15226 | // reset chksum algo test lid to default |
| 15227 | if(!reset_test_lids(chksum_algo_special_list,chksum_algo_special_len)) |
| 15228 | { |
| 15229 | nvram_ut_trace("[NVUT] %s(): %d reset to default fail!\n\r", __FUNCTION__, __LINE__); |
| 15230 | result = KAL_FALSE; |
| 15231 | } |
| 15232 | #ifdef __NVRAM_LID_CACHE__ |
| 15233 | mark_nvram_cache_ready(); |
| 15234 | #endif |
| 15235 | return result; |
| 15236 | } |
| 15237 | |
| 15238 | |
| 15239 | kal_bool data_double_check(nvram_chksum_change_enum chksum_chg_type) |
| 15240 | { |
| 15241 | kal_uint32 buffer_size; |
| 15242 | kal_uint8 i, j, chksum_size; |
| 15243 | kal_uint8 *chksum_buf = NULL; |
| 15244 | kal_uint16 chksum_buf_2b = 0; |
| 15245 | kal_bool result=KAL_TRUE; |
| 15246 | nvram_lid_chksum_info lid_algo_info = {0}; |
| 15247 | nvram_errno_enum state = NVRAM_IO_ERRNO_OK; |
| 15248 | kal_bool algo_chksum_only[2]= {KAL_TRUE, KAL_FALSE}; |
| 15249 | kal_bool algo_read_2b[2] = {KAL_FALSE, KAL_FALSE}; |
| 15250 | kal_int32 algo_chksum_only_length = sizeof(algo_chksum_only)/sizeof(kal_bool); |
| 15251 | kal_int32 algo_read_2b_length = sizeof(algo_read_2b)/sizeof(kal_bool); |
| 15252 | kal_int32 chk_indx =0; |
| 15253 | kal_int32 rd2b_indx =0; |
| 15254 | kal_uint32 tmp_indx =0; |
| 15255 | nvram_ltable_entry_struct *ldi = NULL; |
| 15256 | |
| 15257 | for(j=0; j< chksum_algo_normal_len; j++) |
| 15258 | { |
| 15259 | nvram_util_get_data_item(&ldi, chksum_algo_normal_list[j]); |
| 15260 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 15261 | { |
| 15262 | nvram_ut_trace("[NVUT] %s(): reset test LIDs fail!\n\r", __FUNCTION__); |
| 15263 | return KAL_FALSE; |
| 15264 | } |
| 15265 | |
| 15266 | kal_mem_set(data_buffer, 0, ldi->size); |
| 15267 | |
| 15268 | data_buffer[0] = 0x1; |
| 15269 | data_buffer[1] = 0x2; |
| 15270 | data_buffer[2] = 0x3; |
| 15271 | buffer_size = ldi->size; |
| 15272 | for(i=1; i<=ldi->total_records; i++) |
| 15273 | { |
| 15274 | if(!nvram_external_write_data(ldi->LID , i, (kal_uint8 *)data_buffer, ldi->size)) |
| 15275 | { |
| 15276 | nvram_ut_trace("[NVUT] %s():%d write lid fail!\n\r", __FUNCTION__, __LINE__); |
| 15277 | return KAL_FALSE; |
| 15278 | } |
| 15279 | } |
| 15280 | |
| 15281 | for(i = 1; i <= ldi->total_records; i++) |
| 15282 | { |
| 15283 | kal_mem_set(cmp_buffer, 0, ldi->size); |
| 15284 | if(!nvram_external_read_data(ldi->LID,i,(kal_uint8 *)cmp_buffer, ldi->size)) |
| 15285 | { |
| 15286 | nvram_ut_trace("[NVUT] %s():%d read lid(%x) fail!\n\r", __FUNCTION__, __LINE__, ldi->LID); |
| 15287 | return KAL_FALSE; |
| 15288 | } |
| 15289 | } |
| 15290 | |
| 15291 | // lid chksum algo from def to enhance |
| 15292 | switch(chksum_chg_type) |
| 15293 | { |
| 15294 | case FROM_DEF_TO_ENHANCE: |
| 15295 | { |
| 15296 | ldi->attr |= NVRAM_ATTR_CHKSUM_ENHNC_ALGRTHM; |
| 15297 | break; |
| 15298 | } |
| 15299 | case FROM_ENHANCE_TO_DEF: |
| 15300 | { |
| 15301 | ldi->attr &= (~NVRAM_ATTR_CHKSUM_ENHNC_ALGRTHM); |
| 15302 | break; |
| 15303 | } |
| 15304 | default: |
| 15305 | { |
| 15306 | nvram_ut_trace("[NVUT] %s(): Error chksum change type %d\r\n", __FUNCTION__, chksum_chg_type); |
| 15307 | return KAL_FALSE; |
| 15308 | } |
| 15309 | } |
| 15310 | } |
| 15311 | //reset SYS LID |
| 15312 | if(!nvram_external_reset_data(NVRAM_EF_SW_VERNO_LID, SW_VERNO_RECORD_NUMBER, 1)) |
| 15313 | { |
| 15314 | nvram_ut_trace("[NVUT] ota_boot_importantl4_size_change_read(): reset SYS LID fail!\n\r"); |
| 15315 | return KAL_FALSE; |
| 15316 | } |
| 15317 | // Modify sw version |
| 15318 | if(!modify_md_sw_version()) |
| 15319 | { |
| 15320 | nvram_ut_trace("[NVUT]%s(): modify_md_sw_version(): fail!\n\r", __FUNCTION__); |
| 15321 | return KAL_FALSE; |
| 15322 | } |
| 15323 | |
| 15324 | // Call nvram_init |
| 15325 | nvram_boot_trace = 0; |
| 15326 | nvram_init(); |
| 15327 | if(!(nvram_boot_trace & BOOT_TRACE_SW_VERNO_CONFLICT)) |
| 15328 | { |
| 15329 | nvram_ut_trace("[NVUT] %s(): enter version conflict fail!\n\r", __FUNCTION__); |
| 15330 | return KAL_FALSE; |
| 15331 | } |
| 15332 | |
| 15333 | for(j=0; j< chksum_algo_normal_len; j++) |
| 15334 | { |
| 15335 | nvram_util_get_data_item(&ldi, chksum_algo_normal_list[j]); |
| 15336 | // read lid data info cmp_buffer |
| 15337 | kal_mem_set(data_buffer, 0, ldi->size); |
| 15338 | data_buffer[0] = 0x1; |
| 15339 | data_buffer[1] = 0x2; |
| 15340 | data_buffer[2] = 0x3; |
| 15341 | for(i = 1; i <= ldi->total_records; i++) |
| 15342 | { |
| 15343 | kal_mem_set(cmp_buffer, 0, ldi->size); |
| 15344 | if(!nvram_external_read_data(ldi->LID, i, (kal_uint8 *)cmp_buffer, ldi->size)) |
| 15345 | { |
| 15346 | nvram_ut_trace("[NVUT] %s():%d read lid(%x) fail!\n\r", __FUNCTION__, __LINE__, ldi->LID); |
| 15347 | return KAL_FALSE; |
| 15348 | } |
| 15349 | if(0 != kal_mem_cmp(data_buffer, cmp_buffer, ldi->size)) |
| 15350 | { |
| 15351 | nvram_ut_trace("[NVUT] %s():%d lid(%x) data check error after OTA.\n\r", __FUNCTION__, __LINE__, ldi->LID); |
| 15352 | return KAL_FALSE; |
| 15353 | } |
| 15354 | } |
| 15355 | |
| 15356 | // CHKSUM cmp |
| 15357 | for(chk_indx = 0 ; chk_indx < algo_chksum_only_length; chk_indx++) |
| 15358 | { |
| 15359 | nvram_get_lid_chksum_algo_info(ldi,&lid_algo_info, algo_chksum_only[chk_indx], KAL_FALSE); |
| 15360 | chksum_size = lid_algo_info.algo_info.chksum_algo_length; |
| 15361 | nvram_ut_trace("[NVUT] %s(): chksum_size(%d).\n\r", __FUNCTION__, chksum_size); |
| 15362 | |
| 15363 | for(rd2b_indx = 0 ; rd2b_indx < algo_read_2b_length; rd2b_indx++) |
| 15364 | { |
| 15365 | nvram_get_lid_chksum_algo_info(ldi,&lid_algo_info, algo_chksum_only[chk_indx], algo_read_2b[rd2b_indx]); |
| 15366 | buffer_size = lid_algo_info.algo_info.chksum_algo_length * ldi->total_records; |
| 15367 | |
| 15368 | nvram_ut_trace("[NVUT] %s():buffer_size(%d), chksum_algo_length(%d).\n\r", __FUNCTION__, buffer_size, lid_algo_info.algo_info.chksum_algo_length); |
| 15369 | nvram_ut_trace("[NVUT] %s():algo_chksum_only[%d](%d), algo_read_2b[%d](%d).\n\r", __FUNCTION__, chk_indx, algo_chksum_only[chk_indx], rd2b_indx, algo_read_2b[rd2b_indx]); |
| 15370 | // Reuse for checksum compare |
| 15371 | kal_mem_set(cmp_buffer,0,buffer_size); |
| 15372 | chksum_buf = (kal_uint8*)get_ctrl_buffer(chksum_size); |
| 15373 | |
| 15374 | for(i=1; i<=ldi->total_records; i++) |
| 15375 | { |
| 15376 | kal_mem_set(chksum_buf, 0, chksum_size); |
| 15377 | if((lid_algo_info.algo_info.chksum_algo_type == NVRAM_MD5) && (algo_read_2b[rd2b_indx] == KAL_TRUE)) |
| 15378 | { |
| 15379 | chksum_buf_2b = nvram_util_caculate_checksum(ldi, (kal_uint8*)data_buffer, ldi->size, chksum_buf); |
| 15380 | nvram_ut_trace("[NVUT] %s(): chksum_buf_2b = %hd.\n\r", __FUNCTION__, chksum_buf_2b); |
| 15381 | } |
| 15382 | else |
| 15383 | { |
| 15384 | nvram_util_caculate_checksum(ldi, (kal_uint8*)data_buffer, ldi->size, chksum_buf); |
| 15385 | } |
| 15386 | |
| 15387 | nvram_ut_trace("[NVUT_cmp] %s(): caculate chksum show start.\n\r", __FUNCTION__); |
| 15388 | for(tmp_indx = 0; tmp_indx < chksum_size; tmp_indx += 4) |
| 15389 | { |
| 15390 | nvram_ut_trace("[NVUT] (0x%x)\n\r", *((kal_uint32 *)(chksum_buf + tmp_indx))); |
| 15391 | } |
| 15392 | nvram_ut_trace("[NVUT] %s(): caculate chksum show done(%d).\n\r", __FUNCTION__, i); |
| 15393 | |
| 15394 | state = nvram_external_read_chksum_value(ldi->LID,i,1,(kal_uint8 *)cmp_buffer,lid_algo_info.algo_info.chksum_algo_length, lid_algo_info.read_chksum_type); |
| 15395 | if(state != NVRAM_IO_ERRNO_OK) |
| 15396 | { |
| 15397 | nvram_ut_trace("[NVUT_cmp] %s(): read chksum value fail.\n\r", __FUNCTION__); |
| 15398 | result = KAL_FALSE; |
| 15399 | free_ctrl_buffer(chksum_buf); |
| 15400 | goto TEST_END; |
| 15401 | } |
| 15402 | nvram_ut_trace("[NVUT_cmp] %s(): read chksum show start.\n\r", __FUNCTION__); |
| 15403 | for(tmp_indx = 0; tmp_indx < lid_algo_info.algo_info.chksum_algo_length; tmp_indx += 4) |
| 15404 | { |
| 15405 | nvram_ut_trace("[NVUT_cmp] (0x%x)\n\r", *((kal_uint32 *)(((kal_uint8 *)cmp_buffer) + tmp_indx))); |
| 15406 | } |
| 15407 | nvram_ut_trace("[NVUT_cmp] %s(): read chksum show done(%d).\n\r", __FUNCTION__, i); |
| 15408 | |
| 15409 | if((lid_algo_info.algo_info.chksum_algo_type == NVRAM_MD5) && (algo_read_2b[rd2b_indx] == KAL_TRUE)) |
| 15410 | { |
| 15411 | result = kal_mem_cmp(&chksum_buf_2b, cmp_buffer, lid_algo_info.algo_info.chksum_algo_length); |
| 15412 | } |
| 15413 | else |
| 15414 | { |
| 15415 | result = kal_mem_cmp(chksum_buf, cmp_buffer, lid_algo_info.algo_info.chksum_algo_length); |
| 15416 | } |
| 15417 | |
| 15418 | if(0 != result) |
| 15419 | { |
| 15420 | nvram_ut_trace("[NVUT] %s(): chksum double check fail!\n\r", __FUNCTION__); |
| 15421 | result = KAL_FALSE; |
| 15422 | free_ctrl_buffer(chksum_buf); |
| 15423 | goto TEST_END; |
| 15424 | } |
| 15425 | else |
| 15426 | { |
| 15427 | result = KAL_TRUE; |
| 15428 | } |
| 15429 | } |
| 15430 | |
| 15431 | free_ctrl_buffer(chksum_buf); |
| 15432 | } |
| 15433 | } |
| 15434 | } |
| 15435 | |
| 15436 | |
| 15437 | TEST_END: |
| 15438 | |
| 15439 | return result; |
| 15440 | } |
| 15441 | |
| 15442 | /* |
| 15443 | double check data & chksum after algo change ota boot |
| 15444 | */ |
| 15445 | kal_bool ota_boot_lid_algo_change_with_double_chkdata() |
| 15446 | { |
| 15447 | kal_uint8 i, j, length; |
| 15448 | nvram_chksum_change_enum chksum_chg_lists[] = {FROM_DEF_TO_ENHANCE, FROM_ENHANCE_TO_DEF}; |
| 15449 | kal_bool result = KAL_TRUE; |
| 15450 | nvram_ltable_entry_struct *ldi = NULL; |
| 15451 | |
| 15452 | length = sizeof(chksum_chg_lists)/sizeof(nvram_chksum_change_enum); |
| 15453 | #ifdef __NVRAM_LID_CACHE__ |
| 15454 | nvram_cache_reset(); |
| 15455 | #endif |
| 15456 | |
| 15457 | for(i=0; i< chksum_algo_normal_len; i++) |
| 15458 | { |
| 15459 | nvram_util_get_data_item(&ldi, chksum_algo_normal_list[i]); |
| 15460 | |
| 15461 | // reset and backup data into data_buffer |
| 15462 | if(!reset_test_lid_default_setting(ldi->LID)) |
| 15463 | { |
| 15464 | nvram_ut_trace("[NVUT] %s():rest test lid fail!\n\r", __FUNCTION__); |
| 15465 | result = KAL_FALSE; |
| 15466 | goto reset_default; |
| 15467 | } |
| 15468 | } |
| 15469 | |
| 15470 | for(j=0; j<length; j++) |
| 15471 | { |
| 15472 | if(!data_double_check(chksum_chg_lists[j])) |
| 15473 | { |
| 15474 | nvram_ut_trace("[NVUT] %s():double check error! chksum change type: %d!\n\r", __FUNCTION__, chksum_chg_lists[j]); |
| 15475 | result = KAL_FALSE; |
| 15476 | break; |
| 15477 | } |
| 15478 | } |
| 15479 | |
| 15480 | reset_default: |
| 15481 | |
| 15482 | for(i=0; i< chksum_algo_normal_len; i++) |
| 15483 | { |
| 15484 | nvram_util_get_data_item(&ldi, chksum_algo_normal_list[i]); |
| 15485 | |
| 15486 | // reset and backup data into data_buffer |
| 15487 | if(!reset_test_lid_default_setting(ldi->LID)) |
| 15488 | { |
| 15489 | nvram_ut_trace("[NVUT] %s():rest test lid fail!\n\r", __FUNCTION__); |
| 15490 | result = KAL_FALSE; |
| 15491 | } |
| 15492 | |
| 15493 | if(!nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records)) |
| 15494 | { |
| 15495 | nvram_ut_trace("[NVUT] %s(): reset test LIDs fail!\n\r", __FUNCTION__); |
| 15496 | result = KAL_FALSE; |
| 15497 | } |
| 15498 | |
| 15499 | if(result == KAL_FALSE) |
| 15500 | { |
| 15501 | break; |
| 15502 | } |
| 15503 | } |
| 15504 | |
| 15505 | |
| 15506 | #ifdef __NVRAM_LID_CACHE__ |
| 15507 | mark_nvram_cache_ready(); |
| 15508 | #endif |
| 15509 | |
| 15510 | return result; |
| 15511 | } |
| 15512 | |
| 15513 | #endif |
| 15514 | |
| 15515 | /*__NVRAM_ENHANCE_CHKSUM_ALGORITHM__*/ |
| 15516 | |
| 15517 | |
| 15518 | /* |
| 15519 | Test case return value: 0: success, others: fail |
| 15520 | */ |
| 15521 | ut_testcase_struct ut_nvram_full_test[] = |
| 15522 | { |
| 15523 | //factory test cases |
| 15524 | {factory_reset_user_access, 0, NULL, "Factory Reset USER LID Access Test", "2.1.1.1"}, |
| 15525 | {factory_reset_internal_access, 0, NULL, "Factory Reset INTERNAL LID Access Test", "2.1.1.2"}, |
| 15526 | {factory_reset_calibrat_access, 0, NULL, "Factory Reset CALIBRAT LID Access Test", "2.1.1.3"}, |
| 15527 | {factory_reset_important_access, 0, NULL, "Factory Reset IMPORTANT LID Access Test", "2.1.1.4"}, |
| 15528 | {factory_reset_importantl1_access, 0, NULL, "Factory Reset IMPORTANT_L1 LID Access Test", "2.1.1.5"}, |
| 15529 | {factory_reset_importantl4_access, 0, NULL, "Factory Reset IMPORTANT_L4 LID Access Test", "2.1.1.6"}, |
| 15530 | //first boot test cases |
| 15531 | {first_boot_basic_access, 0, NULL, "First Boot Basic Access Test", "2.1.2.1"}, |
| 15532 | //OTA boot test cases |
| 15533 | {ota_boot_basic_access, 0, NULL, "OTA Boot Basic Access Test", "2.1.3.1"}, |
| 15534 | {ota_boot_lid_verno_change_access, 0, NULL, "OTA Boot LID Verno Change Access", "2.1.3.2"}, |
| 15535 | //{ota_boot_add_lid_access, 0, NULL, "OTA Boot Basic Add LID Access Test", "2.1.3.3"},//cancel, this is the same with 2.1.3.1 |
| 15536 | /* bellow 6 cases feature currently not support |
| 15537 | {ota_boot_add_record_read, 0, NULL, "OTA Boot Add Record Read Test", "2.1.3.4"}, |
| 15538 | {ota_boot_add_record_write, 0, NULL, "OTA Boot Add Record Write Test", "2.1.3.5"}, |
| 15539 | {ota_boot_add_record_reset, 0, NULL, "OTA Boot Add Record Reset Test", "2.1.3.6"}, |
| 15540 | {ota_boot_delete_record_read, 0, NULL, "OTA Boot Delete Record Read Test", "2.1.3.7"}, |
| 15541 | {ota_boot_delete_record_write, 0, NULL, "OTA Boot Delete Record Write Test", "2.1.3.8"}, |
| 15542 | {ota_boot_delete_record_reset, 0, NULL, "OTA Boot Delete Record Reset Test", "2.1.3.9"}, |
| 15543 | */ |
| 15544 | {ota_boot_verno_change_previous_lid_access, 0, NULL, "OTA Boot Verno Change Previous Version LID Access Test", "2.1.3.10"}, |
| 15545 | {ota_boot_size_change_previous_lid_access, 0, NULL, "OTA Boot Record Size Change Previous Version LID Access Test", "2.1.3.11"}, |
| 15546 | {ota_boot_record_change_previous_lid_access, 0, NULL, "OTA Boot Record Number Change Previous Version LID Access Test", "2.1.3.12"}, |
| 15547 | /* bellow 6 cases feature currently not support |
| 15548 | {ota_boot_extend_record_read, 0, NULL, "OTA Boot Extend Record Read Test", "2.1.3.13"}, |
| 15549 | {ota_boot_extend_record_write, 0, NULL, "OTA Boot Extend Record Write Test", "2.1.3.14"}, |
| 15550 | {ota_boot_extend_record_reset, 0, NULL, "OTA Boot Extend Record Reset Test", "2.1.3.15"}, |
| 15551 | {ota_boot_minish_record_read, 0, NULL, "OTA Boot Minish Record Read Test", "2.1.3.16"}, |
| 15552 | {ota_boot_minish_record_write, 0, NULL, "OTA Boot Minish Record Write Test", "2.1.3.17"}, |
| 15553 | {ota_boot_minish_record_reset, 0, NULL, "OTA Boot Minish Record Reset Test", "2.1.3.18"}, |
| 15554 | */ |
| 15555 | {ota_boot_user_size_change_read, 0, NULL, "OTA Boot USER LID Size Change Read Test", "2.1.3.19"}, |
| 15556 | {ota_boot_user_size_change_write, 0, NULL, "OTA Boot USER LID Size Change Write Test", "2.1.3.20"}, |
| 15557 | {ota_boot_user_size_change_reset, 0, NULL, "OTA Boot USER LID Size Change Reset Test", "2.1.3.21"}, |
| 15558 | {ota_boot_internal_size_change_read, 0, NULL, "OTA Boot INTERNAL LID Size Change Read Test", "2.1.3.22"}, |
| 15559 | {ota_boot_internal_size_change_write, 0, NULL, "OTA Boot INTERNAL LID Size Change Write Test", "2.1.3.23"}, |
| 15560 | {ota_boot_internal_size_change_reset, 0, NULL, "OTA Boot INTERNAL LID Size Change Reset Test", "2.1.3.24"}, |
| 15561 | {ota_boot_calibrat_size_change, 0, NULL, "OTA Boot CALIBRAT LID Size Change Test", "2.1.3.25"}, |
| 15562 | {ota_boot_important_size_change, 0, NULL, "OTA Boot IMPORTANT LID Size Change Test", "2.1.3.26"}, |
| 15563 | {ota_boot_calibrat_lost_access, 0, NULL, "OTA Boot CALIBRAT LID Lost Test", "2.1.3.27"}, |
| 15564 | {ota_boot_important_lost_access, 0, NULL, "OTA Boot IMPORTANT LID Lost Test", "2.1.3.28"}, |
| 15565 | #if 0 //change test cases, because NVRAM design flow change |
| 15566 | /* under construction !*/ |
| 15567 | /* under construction !*/ |
| 15568 | /* under construction !*/ |
| 15569 | /* under construction !*/ |
| 15570 | /* under construction !*/ |
| 15571 | /* under construction !*/ |
| 15572 | #endif |
| 15573 | {ota_boot_importantl1_size_change_read, 0, NULL, "OTA Boot IMPORTANT_L1 LID Size Change Read Test", "2.1.3.31"}, |
| 15574 | {ota_boot_importantl1_size_change_write, 0, NULL, "OTA Boot IMPORTANT_L1 LID Size Change Write Test", "2.1.3.32"}, |
| 15575 | {ota_boot_importantl1_size_change_reset, 0, NULL, "OTA Boot IMPORTANT_L1 LID Size Change Reset Test", "2.1.3.33"}, |
| 15576 | {ota_boot_importantl4_size_change_read, 0, NULL, "OTA Boot IMPORTANT_L4 LID Size Change Read Test", "2.1.3.34"}, |
| 15577 | {ota_boot_importantl4_size_change_write, 0, NULL, "OTA Boot IMPORTANT_L4 LID Size Change Write Test", "2.1.3.35"}, |
| 15578 | {ota_boot_importantl4_size_change_reset, 0, NULL, "OTA Boot IMPORTANT_L4 LID Size Change Reset Test", "2.1.3.36"}, |
| 15579 | {ota_boot_ota_reset_attr, 0, NULL, "OTA Boot OTA_RESET Attribute Test", "2.1.3.37"}, |
| 15580 | {ota_boot_reserve_backward_verno_change, 0, NULL, "OTA Boot RESERVE_BACKWARD VERNO Change Test", "2.1.3.38"}, |
| 15581 | {ota_boot_reserve_backward_size_change, 0, NULL, "OTA Boot RESERVE_BACKWARD Size Change Test", "2.1.3.39"}, |
| 15582 | //normal boot test |
| 15583 | {normal_boot_basic_access, 0, NULL, "Normal Boot Basic Access Test", "2.1.4.1"}, |
| 15584 | {normal_boot_user_lost_read, 0, NULL, "Normal Boot USER LID Lost Read Test", "2.1.4.2"}, |
| 15585 | {normal_boot_user_lost_write, 0, NULL, "Normal Boot USER LID Lost Write Test", "2.1.4.3"}, |
| 15586 | {normal_boot_user_lost_reset, 0, NULL, "Normal Boot USER LID Lost Reset Test", "2.1.4.4"}, |
| 15587 | {normal_boot_internal_lost_read, 0, NULL, "Normal Boot INTERNAL LID Lost Read Test", "2.1.4.5"}, |
| 15588 | {normal_boot_internal_lost_write, 0, NULL, "Normal Boot INTERNAL LID Lost Write Test", "2.1.4.6"}, |
| 15589 | {normal_boot_internal_lost_reset, 0, NULL, "Normal Boot INTERNAL LID Lost Reset Test", "2.1.4.7"}, |
| 15590 | {normal_boot_calibrat_lost_read, 0, NULL, "Normal Boot CALIBRAT LID Lost Read Test", "2.1.4.8"}, |
| 15591 | {normal_boot_calibrat_lost_write, 0, NULL, "Normal Boot CALIBRAT LID Lost Write Test", "2.1.4.9"}, |
| 15592 | {normal_boot_calibrat_lost_reset, 0, NULL, "Normal Boot CALIBRAT LID Lost Reset Test", "2.1.4.10"}, |
| 15593 | {normal_boot_important_lost_read, 0, NULL, "Normal Boot IMPORTANT LID Lost Read Test", "2.1.4.11"}, |
| 15594 | {normal_boot_important_lost_write, 0, NULL, "Normal Boot IMPORTANT LID Lost Write Test", "2.1.4.12"}, |
| 15595 | {normal_boot_important_lost_reset, 0, NULL, "Normal Boot IMPORTANT LID Lost Reset Test", "2.1.4.13"}, |
| 15596 | {normal_boot_importantl1_lost_read, 0, NULL, "Normal Boot IMPORTANT_L1 LID Lost Read Test", "2.1.4.14"}, |
| 15597 | {normal_boot_importantl1_lost_write, 0, NULL, "Normal Boot IMPORTANT_L1 LID Lost Write Test", "2.1.4.15"}, |
| 15598 | {normal_boot_importantl1_lost_reset, 0, NULL, "Normal Boot IMPORTANT_L1 LID Lost Reset Test", "2.1.4.16"}, |
| 15599 | {normal_boot_importantl4_lost_read, 0, NULL, "Normal Boot IMPORTANT_L4 LID Lost Read Test", "2.1.4.17"}, |
| 15600 | {normal_boot_importantl4_lost_write, 0, NULL, "Normal Boot IMPORTANT_L4 LID Lost Write Test", "2.1.4.18"}, |
| 15601 | {normal_boot_importantl4_lost_reset, 0, NULL, "Normal Boot IMPORTANT_L4 LID Lost Reset Test", "2.1.4.19"}, |
| 15602 | {normal_boot_user_altered_read, 0, NULL, "Normal Boot USER LID Altered Read Test", "2.1.4.20"}, |
| 15603 | {normal_boot_user_altered_write, 0, NULL, "Normal Boot USER LID Altered Write Test", "2.1.4.21"}, |
| 15604 | {normal_boot_user_altered_reset, 0, NULL, "Normal Boot USER LID Altered Reset Test", "2.1.4.22"}, |
| 15605 | {normal_boot_internal_altered_read, 0, NULL, "Normal Boot INTERNAL LID Altered Read Test", "2.1.4.23"}, |
| 15606 | {normal_boot_internal_altered_write, 0, NULL, "Normal Boot INTERNAL LID Altered Write Test", "2.1.4.24"}, |
| 15607 | {normal_boot_internal_altered_reset, 0, NULL, "Normal Boot INTERNAL LID Altered Reset Test", "2.1.4.25"}, |
| 15608 | {normal_boot_calibrat_altered_read, 0, NULL, "Normal Boot CALIBRAT LID Altered Read Test", "2.1.4.26"}, |
| 15609 | {normal_boot_calibrat_altered_write, 0, NULL, "Normal Boot CALIBRAT LID Altered Write Test", "2.1.4.27"}, |
| 15610 | {normal_boot_calibrat_altered_reset, 0, NULL, "Normal Boot CALIBRAT LID Altered Reset Test", "2.1.4.28"}, |
| 15611 | {normal_boot_important_altered_read, 0, NULL, "Normal Boot IMPORTANT LID Altered Read Test", "2.1.4.29"}, |
| 15612 | {normal_boot_important_altered_write, 0, NULL, "Normal Boot IMPORTANT Altered Write Test", "2.1.4.30"}, |
| 15613 | {normal_boot_important_altered_reset, 0, NULL, "Normal Boot IMPORTANT Altered Reset Test", "2.1.4.31"}, |
| 15614 | {normal_boot_importantl1_altered_read, 0, NULL, "Normal Boot IMPORTANT_L1 LID Altered Read Test", "2.1.4.32"}, |
| 15615 | {normal_boot_importantl1_altered_write, 0, NULL, "Normal Boot IMPORTANT_L1 LID Altered Write Test", "2.1.4.33"}, |
| 15616 | {normal_boot_importantl1_altered_reset, 0, NULL, "Normal Boot IMPORTANT_L1 LID Altered Reset Test", "2.1.4.34"}, |
| 15617 | {normal_boot_importantl4_altered_read, 0, NULL, "Normal Boot IMPORTANT_L4 LID Altered Read Test", "2.1.4.35"}, |
| 15618 | {normal_boot_importantl4_altered_write, 0, NULL, "Normal Boot IMPORTANT_L4 LID Altered Write Test", "2.1.4.36"}, |
| 15619 | {normal_boot_importantl4_altered_reset, 0, NULL, "Normal Boot IMPORTANT_L4 LID Altered Reset Test", "2.1.4.37"}, |
| 15620 | {normal_boot_read_syslid_fail, 0, NULL, "Normal Boot Read SYS LID Fail Test", "2.1.4.38"}, |
| 15621 | |
| 15622 | {normal_boot_user_corrupted_test, 0, NULL, "Normal Boot User Category LID Corrupted Data Test", "2.1.5.1"}, |
| 15623 | {normal_boot_calibrate_corrupted_test, 0, NULL, "Normal Boot Calibrate Category LID Corrupted Data Test", "2.1.5.2"}, |
| 15624 | {normal_boot_important_corrupted_test, 0, NULL, "Normal Boot Important Category LID Corrupted Data Test", "2.1.5.3"}, |
| 15625 | {normal_boot_important_l4_corrupted_test, 0, NULL, "Normal Boot Important_L4 Category LID Corrupted Data Test", "2.1.5.4"}, |
| 15626 | //attribute & category test |
| 15627 | {attr_average_basic_access, 0, NULL, "NVRAM_ATTR_AVERAGE Attribute Basic Test", "2.2.1.1"}, |
| 15628 | {attr_multi_default_read_basic_access, 0, NULL, "MULTI_DEFAULT and MULTI_READ Attribute Basic Test", "2.2.1.2"}, |
| 15629 | {attr_write_protect_basic_access, 0, NULL, "NVRAM_ATTR_WRITE_PROTECT Attribute Basic Test", "2.2.1.3"}, |
| 15630 | {attr_multiple_basic_access, 0, NULL, "NVRAM_ATTR_MULTIPLE Attribute Basic Test", "2.2.1.4"}, |
| 15631 | {attr_confidential_basic_access, 0, NULL, "NVRAM_ATTR_CONFIDENTIAL Attribute Basic Test", "2.2.1.5"}, |
| 15632 | {attr_msp_basic_access, 0, NULL, "NVRAM_ATTR_MSP Attribute Basic Test", "2.2.1.6"}, |
| 15633 | {attr_committed_basic_access, 0, NULL, "NVRAM_ATTR_COMMITTED Attribute Basic Test", "2.2.1.7"}, |
| 15634 | {attr_ring_basic_access, 0, NULL, "NVRAM_ATTR_RING Attribute Basic Test", "2.2.1.8"}, |
| 15635 | {attr_fault_assert_test, 0, NULL, "NVRAM_ATTR_FAULT_ASSERT Attribute Test", "2.2.1.9"}, |
| 15636 | {category_user_basic_access, 0, NULL, "NVRAM_CATEGORY_USER Basic Test", "2.2.2.1"}, |
| 15637 | {category_internal_basic_access, 0, NULL, "NVRAM_CATEGORY_INTERNAL Basic Test", "2.2.2.2"}, |
| 15638 | {category_calibrat_basic_access, 0, NULL, "NVRAM_CATEGORY_CALIBRAT Basic Test", "2.2.2.3"}, |
| 15639 | {category_important_basic_access, 0, NULL, "NVRAM_CATEGORY_IMPORTANT Basic Test", "2.2.2.4"}, |
| 15640 | {category_importantl1_basic_access, 0, NULL, "NVRAM_CATEGORY_IMPORTANT_L1 Basic Test", "2.2.2.5"}, |
| 15641 | {category_importantl4_basic_access, 0, NULL, "NVRAM_CATEGORY_IMPORTANT_L4 Basic Test", "2.2.2.6"}, |
| 15642 | {func_default_basic_access, 0, NULL, "NVRAM_CATEGORY_FUNC_DEFAULT Basic Test", "2.2.2.7"}, |
| 15643 | {zero_default_basic_access, 0, NULL, "NVRAM_EF_ZERO_DEFAULT Basic Test", "2.2.2.8"}, |
| 15644 | {ff_default_basic_access, 0, NULL, "NVRAM_EF_FF_DEFAULT Basic Test", "2.2.2.9"}, |
| 15645 | {table_default_basic_access, 0, NULL, "TABLE_DEFAULT Basic Test", "2.2.2.10"}, |
| 15646 | {attribute_category_defaultvalue_combine, 0, NULL, "Attribute/Category/Default Value Combine Basic Test", "2.2.2.11"}, |
| 15647 | {chksum_read_function_basic_test, 0, NULL, "NVRAM Checksum Read Function Basic Test", "2.2.2.12"}, |
| 15648 | {chksum_multi_read_function_test, 0, NULL, "NVRAM Checksum Multi Read Function Test", "2.2.2.13"}, |
| 15649 | {raw_data_access_function_test, 0, NULL, "NVRAM RAW_DATA Access Function Test", "2.2.2.14"}, |
| 15650 | //boundary & stress test |
| 15651 | {record_size_boundary_test, 0, NULL, "NVRAM Record Size Boundary Test", "2.3.1.1"}, |
| 15652 | {record_number_boundary_test, 0, NULL, "NVRAM Record Number Boundary Test", "2.3.2.1"}, |
| 15653 | {nvram_stress_test, 0, NULL, "NVRAM Stress Test", "2.3.3.1"}, |
| 15654 | |
| 15655 | //nvram special feature test |
| 15656 | //{nvram_write_exception_test, 0, NULL, "NVRAM Write Exception Test", "2.4.4.1"}, //cancel, this API is exception owner own |
| 15657 | {nvram_exception_test, 0, NULL, "NVRAM Exception Test", "2.4.4.2"}, |
| 15658 | {nvram_security_test, 0, NULL, "NVRAM Security Test", "2.4.1.3"}, |
| 15659 | #if defined(__NVRAM_STRUCTURE_CHANGE_RESET__) || defined(__NVRAM_DEFVAL_CHANGE_RESET__) |
| 15660 | {nvram_smart_reset_entry_test, 0, NULL, "NVRAM Smart Reset Entry Number Test", "2.4.1.4"}, //build checksum enties need match code |
| 15661 | {nvram_structure_change_reset_test, 0, NULL, "NVRAM Structure Change Reset Test", "2.4.1.5"}, |
| 15662 | {nvram_default_value_change_reset_test, 0, NULL, "NVRAM Default Value Change Reset Test", "2.4.1.6"}, |
| 15663 | {nvram_func_default_checksum_change_test, 0, NULL, "NVRAM FUN_DEF Checksum Change Test", "2.4.1.7"}, |
| 15664 | {nvram_smart_reset_checksum_test, 0, NULL, "NVRAM Smart Reset Checksum Test", "2.4.1.8"}, |
| 15665 | {nvram_no_checksum_change_test, 0, NULL, "NVRAM No Checksum Change Test", "2.4.1.9"}, |
| 15666 | {nvram_write_header_test, 0, NULL, "NVRAM Write Header Test", "2.4.1.10"}, |
| 15667 | {nvram_attribute_change_reset_test, 0, NULL, "NVRAM Attribute Change Reset Test", "2.4.1.11"}, |
| 15668 | {nvram_attribute_no_change_test, 0, NULL, "NVRAM Attribute No Change Test", "2.4.1.12"}, |
| 15669 | #endif |
| 15670 | /*Bellow two cases should not be put into __NVRAM_STRUCTURE_CHANGE_RESET__ and __NVRAM_DEFVAL_CHANGE_RESET__ option |
| 15671 | these two test need prepare two versions modem load |
| 15672 | 1st version: NVRAM_UT enable, NVRAM_OTA_SMART_RESET enable |
| 15673 | 2nd version: NVRAM_UT enable, NVRAM_OTA_SMART_RESET disable |
| 15674 | these two cases need manual build load to test |
| 15675 | Tips: |
| 15676 | disable dbg header write then build load. |
| 15677 | old OTA to new or new OTA to old, CALIBRAT/IMPORTANT/IMPORTANT_L4 category LID should not change. |
| 15678 | LIDs in USER and IMPORTANT_1 should all reset. |
| 15679 | */ |
| 15680 | {nvram_smart_reset_new_ota_old_test, 0, NULL, "NVRAM Smart Reset OTA to No Smart Reset Test", "2.4.1.20"}, |
| 15681 | {nvram_smart_reset_old_ota_new_test, 0, NULL, "NVRAM No Smart Reset OTA to Smart Reset Test", "2.4.1.21"}, |
| 15682 | {nvram_external_get_lid_info_test, 0, NULL, "NVRAM Get LID Info Test", "2.5.1.1"}, |
| 15683 | //These case is used for LID cache feature |
| 15684 | #ifdef __NVRAM_LID_CACHE__ |
| 15685 | {first_boot_cache_access, 0, NULL, "First Boot Cache Access Test", "2.6.1"}, |
| 15686 | {normal_boot_cache_access, 0, NULL, "Normal Boot Cache Access Test", "2.6.2"}, |
| 15687 | {ota_boot_cache_access, 0, NULL, "OTA Boot Cache Access Test", "2.6.3"}, |
| 15688 | {normal_boot_user_lost_cache_read, 0, NULL, "Normal Boot User File Lost Cache Read Test", "2.6.4"}, |
| 15689 | {nvram_boot_calibrate_lost_cache_read, 0, NULL, "Normal Boot Calibrate File Lost Cache Read Test", "2.6.5"}, |
| 15690 | {nvram_boot_important_lost_cache_read, 0, NULL, "Normal Boot Important File Lost Cache Read Test", "2.6.6"}, |
| 15691 | {nvram_boot_important_l4_lost_cache_read, 0, NULL, "Normal Boot Important L4 File Lost Cache Read Test", "2.6.7"}, |
| 15692 | {nvram_cache_valid_bit_after_recover, 0, NULL, "Nvram Cache Valid Bit After Recover Test", "2.6.8"}, |
| 15693 | {normal_boot_user_lost_cache_read_with_recover, 0, NULL, "Normal Boot User File Lost Cache Read With Recover Test", "2.6.9"}, |
| 15694 | {nvram_boot_calibrate_lost_cache_read_with_recover, 0, NULL, "Normal Boot Calibrate File Lost Cache Read With Recover Test", "2.6.10"}, |
| 15695 | {nvram_boot_important_lost_cache_read_with_recover, 0, NULL, "Normal Boot Important File Lost Cache Read With Recover Test", "2.6.11"}, |
| 15696 | {nvram_boot_important_l4_lost_cache_read_with_recover, 0, NULL, "Normal Boot Important L4 File Lost Cache With Recover Read Test", "2.6.12"}, |
| 15697 | {normal_boot_user_lost_cache_write, 0, NULL, "Normal Boot User File Lost Cache Write Test", "2.6.13"}, |
| 15698 | {normal_boot_calibrate_lost_cache_write, 0, NULL, "Normal Boot Calibrate File Lost Cache Write Test", "2.6.14"}, |
| 15699 | {normal_boot_important_lost_cache_write, 0, NULL, "Normal Boot Important File Lost Cache Write Test", "2.6.15"}, |
| 15700 | {normal_boot_important_l4_lost_cache_write, 0, NULL, "Normal Boot Important_L4 File Lost Cache Write Test", "2.6.16"}, |
| 15701 | {nvram_cache_read_performance_chek, 0, NULL, "Normal Boot Cache Read Performance Test", "2.6.17"}, |
| 15702 | {nvram_cache_write_performance_chek, 0, NULL, "Normal Boot Cache Write Performance Test", "2.6.18"}, |
| 15703 | {nvram_cache_read_data_less_than_16K, 0, NULL, "Normal Boot Cache Read Less Than 16K Data Test", "2.6.19"}, |
| 15704 | {nvram_cache_read_data_more_than_16K, 0, NULL, "Normal Boot Cache Read More Than 16K Data Test", "2.6.20"}, |
| 15705 | {nvram_cache_read_data_more_than_64K, 0, NULL, "Normal Boot Cache Read More Than 64K Data Test", "2.6.21"}, |
| 15706 | {nvram_cache_bypass_white_list_test, 0, NULL, "Normal Boot Cache Bypass White List Test", "2.6.22"}, |
| 15707 | #ifdef __NVRAM_LID_PREREAD__ |
| 15708 | {nvram_cache_preread_chk, 0, NULL, "Normal Boot Cache pre-read Test", "2.8.1"}, |
| 15709 | #endif |
| 15710 | #endif |
| 15711 | |
| 15712 | #ifdef __NV_CHKSUM_ENHANCE__ |
| 15713 | {ota_boot_change_chksum_default_algorithm_config, 0, NULL, "OTA Boot Default chksum algo change Test", "2.9.1"}, |
| 15714 | {ota_boot_lid_algo_def_to_en_incr_verno, 0, NULL, "OTA Boot Chksum algo add enhance ATTR Test", "2.9.2"}, |
| 15715 | {ota_boot_lid_algo_def_to_en_normal, 0, NULL, "OTA Boot Chksum algo add enhance ATTR (normal lids)without verno+1 Test", "2.9.3"}, |
| 15716 | {ota_boot_lid_algo_def_to_en_special, 0, NULL, "OTA Boot Chksum algo add enhance ATTR(CALI&IMEI) without verno+1 Test", "2.9.4"}, |
| 15717 | {ota_boot_lid_algo_en_A_to_B_inc_verno, 0, NULL, "OTA Boot Chksum algo from Enhance A TO B Test", "2.9.5"}, |
| 15718 | {ota_boot_lid_algo_en_A_to_B_normal, 0, NULL, "OTA Boot Chksum algo from Enhance A TO B(normal lids) without verno+1 Test", "2.9.6"}, |
| 15719 | {ota_boot_lid_algo_en_A_to_B_special, 0, NULL, "OTA Boot Chksum algo from Enhance A TO B (CALI&IMEI)without verno+1 Test", "2.9.7"}, |
| 15720 | {ota_boot_lid_algo_en_to_def_incr_verno, 0, NULL, "OTA Boot Chksum algo remove ATTR enhance Test", "2.9.8"}, |
| 15721 | {ota_boot_lid_algo_en_to_def_normal, 0, NULL, "OTA Boot Chksum algo remove ATTR enhance (normal lids) without verno+1 Test", "2.9.9"}, |
| 15722 | {ota_boot_lid_algo_en_to_def_special, 0, NULL, "OTA Boot Chksum algo remove ATTR enhance (CALI&IMEI) without verno+1 Test", "2.9.10"}, |
| 15723 | {ota_boot_lid_algo_change_with_double_chkdata, 0, NULL, "OTA Boot Chksum algo cahnge data check Test", "2.9.11"}, |
| 15724 | #endif |
| 15725 | |
| 15726 | //pleaes add test case before these cases |
| 15727 | /* These 4 cases just use for test structure |
| 15728 | {nvram_ut_test1, 0, NULL, "NVRAM UT Test Case 1", "9.1"}, |
| 15729 | {nvram_ut_test2, 0, NULL, "NVRAM UT Test Case 2", "9.11"}, |
| 15730 | {nvram_ut_test3, 0, NULL, "NVRAM UT Test Case 3", "9.1.1"}, |
| 15731 | {nvram_ut_test4, 0, NULL, "NVRAM UT Test Case 4", "9.1.2"}, |
| 15732 | */ |
| 15733 | }; |
| 15734 | kal_uint16 full_test_num = sizeof(ut_nvram_full_test)/sizeof(ut_testcase_struct); |
| 15735 | |
| 15736 | |
| 15737 | #if 0 |
| 15738 | /* under construction !*/ |
| 15739 | /* under construction !*/ |
| 15740 | /* under construction !*/ |
| 15741 | /* under construction !*/ |
| 15742 | /* under construction !*/ |
| 15743 | /* under construction !*/ |
| 15744 | /* under construction !*/ |
| 15745 | /* under construction !*/ |
| 15746 | /* under construction !*/ |
| 15747 | /* under construction !*/ |
| 15748 | /* under construction !*/ |
| 15749 | /* under construction !*/ |
| 15750 | /* under construction !*/ |
| 15751 | /* under construction !*/ |
| 15752 | /* under construction !*/ |
| 15753 | /* under construction !*/ |
| 15754 | /* under construction !*/ |
| 15755 | /* under construction !*/ |
| 15756 | /* under construction !*/ |
| 15757 | /* under construction !*/ |
| 15758 | /* under construction !*/ |
| 15759 | /* under construction !*/ |
| 15760 | /* under construction !*/ |
| 15761 | /* under construction !*/ |
| 15762 | /* under construction !*/ |
| 15763 | /* under construction !*/ |
| 15764 | /* under construction !*/ |
| 15765 | /* under construction !*/ |
| 15766 | /* under construction !*/ |
| 15767 | /* under construction !*/ |
| 15768 | /* under construction !*/ |
| 15769 | /* under construction !*/ |
| 15770 | /* under construction !*/ |
| 15771 | /* under construction !*/ |
| 15772 | /* under construction !*/ |
| 15773 | /* under construction !*/ |
| 15774 | /* under construction !*/ |
| 15775 | /* under construction !*/ |
| 15776 | /* under construction !*/ |
| 15777 | /* under construction !*/ |
| 15778 | /* under construction !*/ |
| 15779 | /* under construction !*/ |
| 15780 | /* under construction !*/ |
| 15781 | /* under construction !*/ |
| 15782 | /* under construction !*/ |
| 15783 | /* under construction !*/ |
| 15784 | /* under construction !*/ |
| 15785 | /* under construction !*/ |
| 15786 | /* under construction !*/ |
| 15787 | /* under construction !*/ |
| 15788 | /* under construction !*/ |
| 15789 | /* under construction !*/ |
| 15790 | /* under construction !*/ |
| 15791 | /* under construction !*/ |
| 15792 | /* under construction !*/ |
| 15793 | /* under construction !*/ |
| 15794 | /* under construction !*/ |
| 15795 | /* under construction !*/ |
| 15796 | /* under construction !*/ |
| 15797 | /* under construction !*/ |
| 15798 | /* under construction !*/ |
| 15799 | /* under construction !*/ |
| 15800 | /* under construction !*/ |
| 15801 | /* under construction !*/ |
| 15802 | /* under construction !*/ |
| 15803 | /* under construction !*/ |
| 15804 | /* under construction !*/ |
| 15805 | /* under construction !*/ |
| 15806 | /* under construction !*/ |
| 15807 | /* under construction !*/ |
| 15808 | /* under construction !*/ |
| 15809 | /* under construction !*/ |
| 15810 | /* under construction !*/ |
| 15811 | /* under construction !*/ |
| 15812 | /* under construction !*/ |
| 15813 | /* under construction !*/ |
| 15814 | /* under construction !*/ |
| 15815 | /* under construction !*/ |
| 15816 | /* under construction !*/ |
| 15817 | /* under construction !*/ |
| 15818 | /* under construction !*/ |
| 15819 | #endif |
| 15820 | |
| 15821 | |
| 15822 | kal_uint32 nvram_ut_test() //return value insted fail case num, 0 stands all pass |
| 15823 | { |
| 15824 | kal_uint32 result; |
| 15825 | kal_uint8 next_char; |
| 15826 | |
| 15827 | start_test_time = ust_get_current_time(); |
| 15828 | for(; test_number < valid_test_case_num; test_number++) |
| 15829 | { |
| 15830 | for(; sub_test_number < full_test_num; sub_test_number++) |
| 15831 | { |
| 15832 | //if(case_is_need_run(test_case_list[test_number], (kal_uint8*)ut_nvram_full_test[sub_test_number].testplan_section)) |
| 15833 | if(strlen((char *)test_case_list[test_number]) > strlen((char *)ut_nvram_full_test[sub_test_number].testplan_section)) |
| 15834 | { |
| 15835 | continue; |
| 15836 | } |
| 15837 | |
| 15838 | //test case is "2.1", case "2.11" should not run. next_char is used to this case |
| 15839 | next_char = ut_nvram_full_test[sub_test_number].testplan_section[strlen((char *)test_case_list[test_number])]; |
| 15840 | if(0 == kal_mem_cmp(test_case_list[test_number], ut_nvram_full_test[sub_test_number].testplan_section, strlen((char *)test_case_list[test_number])) |
| 15841 | && ('\0' == next_char || '.' == next_char)) |
| 15842 | { |
| 15843 | result = ut_nvram_full_test[sub_test_number]._main_fn(ut_nvram_full_test[sub_test_number].flags, ut_nvram_full_test[sub_test_number].para); |
| 15844 | total_case_num++; |
| 15845 | if(KAL_TRUE == result) //success |
| 15846 | { |
| 15847 | nvram_ut_trace("[NVRAM UT] %s : %s -- test result: PASS!\n\r", |
| 15848 | ut_nvram_full_test[sub_test_number].testplan_section, ut_nvram_full_test[sub_test_number].description); |
| 15849 | } |
| 15850 | else |
| 15851 | { |
| 15852 | nvram_ut_trace("[NVRAM UT] %s : %s -- test result: FAIL!\n\r", |
| 15853 | ut_nvram_full_test[sub_test_number].testplan_section, ut_nvram_full_test[sub_test_number].description); |
| 15854 | fail_case_num++; |
| 15855 | } |
| 15856 | } |
| 15857 | kal_sleep_task(kal_milli_secs_to_ticks(10)); |
| 15858 | } |
| 15859 | |
| 15860 | sub_test_number = 0; |
| 15861 | } |
| 15862 | end_test_time = ust_get_current_time(); |
| 15863 | test_time_consume += end_test_time - start_test_time; |
| 15864 | |
| 15865 | return fail_case_num; |
| 15866 | } |
| 15867 | |
| 15868 | //kal_uint32 read_write_buffer[NVRAM_EF_TEST_LID_SIZE/4]; //1K glbal buffer |
| 15869 | void nvram_Ttask1_main(task_entry_struct *task_entry_ptr) |
| 15870 | { |
| 15871 | /*local parameters*/ |
| 15872 | ilm_struct current_ilm; |
| 15873 | tst_module_string_inject_struct *nvram_tst_req; |
| 15874 | //nvram_stress_test1_req_struct *stress_test1_req1,*stress_test1_req2,*stress_test1_req3; |
| 15875 | //nvram_stress_test1_cnf_struct *stress_test1_cnf; |
| 15876 | nvram_ltable_entry_struct *ldi = NULL; |
| 15877 | factory_test_context_struct *test_context; |
| 15878 | kal_wchar filename[NVRAM_MAX_PATH_LEN] = L"Z:\\W_TST_LID.log"; |
| 15879 | kal_uint8 *d_buffer; |
| 15880 | kal_uint32 i; |
| 15881 | kal_uint8 test_result; |
| 15882 | kal_uint8 begin_test = 0; |
| 15883 | |
| 15884 | #ifdef __NVRAM_LID_CACHE__ |
| 15885 | if(check_nvram_cache_ready()) |
| 15886 | { |
| 15887 | for(i = 0; i < test_lid_number; i++) |
| 15888 | { |
| 15889 | nvram_util_get_data_item(&ldi, test_lid_enum[i]); |
| 15890 | if((check_lid_all_record_is_invalid_bit(ldi) != KAL_TRUE) || (check_lid_all_record_is_undirty_bit(ldi)!= KAL_TRUE)) |
| 15891 | { |
| 15892 | nvram_ut_trace("[NVRAM UT] %s() %d: test_lid_enum[%d] valid(%d) and dirty(%d) bit check fail.\n\r",__FUNCTION__,__LINE__,i,check_lid_all_record_is_invalid_bit(ldi),check_lid_all_record_is_undirty_bit(ldi)); |
| 15893 | return; |
| 15894 | } |
| 15895 | } |
| 15896 | }else |
| 15897 | { |
| 15898 | nvram_ut_trace("[NVRAM UT] %s() %d: NVRAM cache not ready!!!\n\r", __FUNCTION__, __LINE__); |
| 15899 | return; |
| 15900 | } |
| 15901 | #endif |
| 15902 | nvram_util_get_data_item(&ldi, NVRAM_EF_NVRAM_TEST_6_LID); |
| 15903 | d_buffer = (kal_uint8*)get_ctrl_buffer(ldi->size); |
| 15904 | nvram_external_read_data(ldi->LID, 1, d_buffer, ldi->size); |
| 15905 | test_context = (factory_test_context_struct*)d_buffer; |
| 15906 | if(0xAB == test_context->context_is_valid) //0xAB is a special value we write |
| 15907 | { |
| 15908 | factory_test_reboot_finish = KAL_TRUE; |
| 15909 | test_number = test_context->break_test_case_num; |
| 15910 | sub_test_number = test_context->sub_test_case_num; |
| 15911 | valid_test_case_num = test_context->valid_test_case_num_total; |
| 15912 | total_case_num = test_context->total_case_number; |
| 15913 | fail_case_num = test_context->fail_case_number; |
| 15914 | test_time_consume = test_context->tst_time_consume; |
| 15915 | kal_mem_cpy(test_case_list, test_context->test_case_lst, sizeof(test_case_list)); |
| 15916 | nvram_external_reset_data(NVRAM_EF_NVRAM_TEST_6_LID, 1, 1); |
| 15917 | |
| 15918 | msg_receive_extq(¤t_ilm); //wait start msg |
| 15919 | destroy_ilm(¤t_ilm); |
| 15920 | } |
| 15921 | else if(0xCD == test_context->context_is_valid) |
| 15922 | { |
| 15923 | manual_ota_reboot_finish = KAL_TRUE; |
| 15924 | test_number = test_context->break_test_case_num; |
| 15925 | sub_test_number = test_context->sub_test_case_num; |
| 15926 | valid_test_case_num = test_context->valid_test_case_num_total; |
| 15927 | total_case_num = test_context->total_case_number; |
| 15928 | fail_case_num = test_context->fail_case_number; |
| 15929 | test_time_consume = test_context->tst_time_consume; |
| 15930 | kal_mem_cpy(test_case_list, test_context->test_case_lst, sizeof(test_case_list)); |
| 15931 | nvram_external_reset_data(NVRAM_EF_NVRAM_TEST_6_LID, 1, 1); |
| 15932 | |
| 15933 | msg_receive_extq(¤t_ilm); //wait start msg |
| 15934 | destroy_ilm(¤t_ilm); |
| 15935 | |
| 15936 | } |
| 15937 | else |
| 15938 | { |
| 15939 | #ifdef __NVRAM_LID_CACHE__ |
| 15940 | nvram_util_take_mutex(g_nvram_fs_mutex); |
| 15941 | #endif |
| 15942 | if(FS_GetAttributes(filename) < FS_NO_ERROR) //before binregion backup write TEST LIDs to special value |
| 15943 | { |
| 15944 | #ifdef __NVRAM_LID_CACHE__ |
| 15945 | nvram_util_give_mutex(g_nvram_fs_mutex); |
| 15946 | #endif |
| 15947 | nvram_write_test_lids(); |
| 15948 | #ifdef __NVRAM_LID_CACHE__ |
| 15949 | nvram_util_take_mutex(g_nvram_fs_mutex); |
| 15950 | #endif |
| 15951 | FS_Close(FS_Open(filename, FS_READ_WRITE | FS_CREATE_ALWAYS)); |
| 15952 | nvram_ap_bin_region_backup(); |
| 15953 | #ifdef __NVRAM_LID_CACHE__ |
| 15954 | nvram_util_give_mutex(g_nvram_fs_mutex); |
| 15955 | #endif |
| 15956 | }else |
| 15957 | { |
| 15958 | #ifdef __NVRAM_LID_CACHE__ |
| 15959 | nvram_util_give_mutex(g_nvram_fs_mutex); |
| 15960 | #endif |
| 15961 | } |
| 15962 | } |
| 15963 | free_ctrl_buffer(d_buffer); |
| 15964 | |
| 15965 | nvram_test_task1_id = kal_get_current_task(); |
| 15966 | |
| 15967 | while(1) |
| 15968 | { |
| 15969 | if(!factory_test_reboot_finish && !manual_ota_reboot_finish) |
| 15970 | { |
| 15971 | msg_receive_extq(¤t_ilm); |
| 15972 | kal_set_active_module_id(current_ilm.dest_mod_id); |
| 15973 | |
| 15974 | if(current_ilm.msg_id == MSG_ID_TST_INJECT_STRING) |
| 15975 | { |
| 15976 | nvram_tst_req = (tst_module_string_inject_struct*) current_ilm.local_para_ptr; |
| 15977 | nvram_ut_trace("[NVRAM UT] test_case_num:%s\n\r", nvram_tst_req->string); |
| 15978 | nvram_ut_trace("[NVRAM UT] test_start:%d\n\r", nvram_tst_req->index); |
| 15979 | |
| 15980 | if(0 == kal_mem_cmp("p", nvram_tst_req->string, 1)) //print all test_case_list |
| 15981 | { |
| 15982 | if(0 == valid_test_case_num) |
| 15983 | { |
| 15984 | nvram_ut_trace("[NVRAM UT] test_case_list is NULL.\n\r"); |
| 15985 | } |
| 15986 | |
| 15987 | for(i = 0; i < valid_test_case_num; i++) |
| 15988 | { |
| 15989 | nvram_ut_trace("[NVRAM UT] test_case_list[%d]: %s.\n\r", i, test_case_list[i]); |
| 15990 | } |
| 15991 | |
| 15992 | if((valid_test_case_num > 0) && (0 != nvram_tst_req->index)) |
| 15993 | { |
| 15994 | begin_test = 1; |
| 15995 | } |
| 15996 | } |
| 15997 | else if(0 == kal_mem_cmp("c", nvram_tst_req->string, 1)) //clear all test_case_list |
| 15998 | { |
| 15999 | kal_mem_set(test_case_list, 0 , sizeof(test_case_list)); |
| 16000 | valid_test_case_num = 0; |
| 16001 | nvram_ut_trace("[NVRAM UT] test_case_list has been cleared.\n\r"); |
| 16002 | |
| 16003 | } |
| 16004 | else //normal test case parse |
| 16005 | { |
| 16006 | for(i = 0; i < full_test_num && |
| 16007 | 0 != (kal_mem_cmp(nvram_tst_req->string, (kal_uint8*)ut_nvram_full_test[i].testplan_section, strlen((char *)nvram_tst_req->string))) |
| 16008 | ; i++) |
| 16009 | {} //to find whether there is one test case need to run |
| 16010 | |
| 16011 | if(i >= full_test_num) |
| 16012 | { |
| 16013 | nvram_ut_trace("[NVRAM UT] Invalid test_case_num, please try again!\n\r"); |
| 16014 | } |
| 16015 | else |
| 16016 | { |
| 16017 | if(valid_test_case_num < 10) |
| 16018 | { |
| 16019 | kal_mem_cpy(test_case_list[valid_test_case_num++], nvram_tst_req->string, strlen((char *)nvram_tst_req->string)); |
| 16020 | } |
| 16021 | else |
| 16022 | { |
| 16023 | nvram_ut_trace("[NVRAM UT] test_case_num list is full, max is 10!\n\r"); |
| 16024 | } |
| 16025 | |
| 16026 | if(nvram_tst_req->index) |
| 16027 | { |
| 16028 | begin_test = 1; |
| 16029 | } |
| 16030 | } |
| 16031 | } |
| 16032 | } |
| 16033 | destroy_ilm(¤t_ilm); |
| 16034 | } |
| 16035 | else //go on factory test |
| 16036 | { |
| 16037 | kal_set_active_module_id(MOD_NV_TEST1); |
| 16038 | begin_test = 1; |
| 16039 | } |
| 16040 | |
| 16041 | if(begin_test) |
| 16042 | { |
| 16043 | nvram_ut_trace("[NVRAM UT] Start: nvram_ut_test()!\n\r"); |
| 16044 | test_result = nvram_ut_test(); |
| 16045 | nvram_ut_trace("[NVRAM UT] End: nvram_ut_test()!\n\r"); |
| 16046 | |
| 16047 | //print test results |
| 16048 | nvram_ut_trace("[NVRAM UT] Total Test Cases: %d.\n\r", total_case_num); |
| 16049 | if(!test_result) |
| 16050 | { |
| 16051 | nvram_ut_trace("[NVRAM UT] NVRAM UT Test Result: PASS!\n\r"); |
| 16052 | } |
| 16053 | else |
| 16054 | { |
| 16055 | nvram_ut_trace("[NVRAM UT] NVRAM UT Test Result: FAIL!\n\r"); |
| 16056 | nvram_ut_trace("[NVRAM UT] Total Fail Cases: %d!\n\r", fail_case_num); |
| 16057 | } |
| 16058 | nvram_ut_trace("[NVRAM UT] Test Time Consume: %d ticks.\n\r", test_time_consume); |
| 16059 | |
| 16060 | //clear environment, you can do another test again(except factory reset test) |
| 16061 | kal_mem_set(test_case_list, 0 , sizeof(test_case_list)); |
| 16062 | begin_test = 0; |
| 16063 | valid_test_case_num = 0; |
| 16064 | factory_test_reboot_finish = KAL_FALSE; |
| 16065 | manual_ota_reboot_finish = KAL_FALSE; |
| 16066 | test_number = 0; |
| 16067 | sub_test_number = 0; |
| 16068 | total_case_num = 0; |
| 16069 | fail_case_num = 0; |
| 16070 | test_time_consume = 0; |
| 16071 | } |
| 16072 | |
| 16073 | /*send msg to Ttask2~Ttask4*/ |
| 16074 | /* |
| 16075 | stress_test1_req1 = (nvram_stress_test1_req_struct*) construct_local_para(sizeof(nvram_stress_test1_req_struct), TD_CTRL); |
| 16076 | stress_test1_req1->access_id = 0x0; |
| 16077 | stress_test1_req1->ref_count = 1; |
| 16078 | stress_test1_req1->start_stress_test1 = 1; |
| 16079 | msg_send6(MOD_NV_TEST1, MOD_NV_TEST2, 0x0, MSG_ID_NVRAM_STRESS_TEST1_REQ, |
| 16080 | (local_para_struct*)stress_test1_req1, NULL); |
| 16081 | |
| 16082 | stress_test1_req2 = (nvram_stress_test1_req_struct*) construct_local_para(sizeof(nvram_stress_test1_req_struct), TD_CTRL); |
| 16083 | stress_test1_req2->access_id = 0x0; |
| 16084 | stress_test1_req2->ref_count = 1; |
| 16085 | stress_test1_req2->start_stress_test1 = 1; |
| 16086 | msg_send6(MOD_NV_TEST1, MOD_NV_TEST3, 0x0, MSG_ID_NVRAM_STRESS_TEST1_REQ, |
| 16087 | (local_para_struct*)stress_test1_req2, NULL); |
| 16088 | |
| 16089 | stress_test1_req3 = (nvram_stress_test1_req_struct*) construct_local_para(sizeof(nvram_stress_test1_req_struct), TD_CTRL); |
| 16090 | stress_test1_req3->access_id = 0x0; |
| 16091 | stress_test1_req3->ref_count = 1; |
| 16092 | stress_test1_req3->start_stress_test1 = 1; |
| 16093 | msg_send6(MOD_NV_TEST1, MOD_NV_TEST4, 0x0, MSG_ID_NVRAM_STRESS_TEST1_REQ, |
| 16094 | (local_para_struct*)stress_test1_req3, NULL); |
| 16095 | |
| 16096 | kal_prompt_trace(MOD_NVRAM, "Ttask1 send msg to Ttask2~Ttask4 done!\n\r"); |
| 16097 | */ |
| 16098 | /*else if(current_ilm.msg_id == MSG_ID_NVRAM_STRESS_TEST1_CNF) |
| 16099 | { |
| 16100 | stress_test1_cnf = (nvram_stress_test1_cnf_struct*) current_ilm.local_para_ptr; |
| 16101 | kal_prompt_trace(MOD_NVRAM, "current_ilm.src_mod_id = %d!\n\r", current_ilm.src_mod_id); |
| 16102 | kal_prompt_trace(MOD_NVRAM, "test result = %d!\n\r", stress_test1_cnf.stress_test1_result); |
| 16103 | }*/ |
| 16104 | |
| 16105 | //nvram_ut_trace("cmpt_op_result:%d\n\r", nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, 0x01020300, 0x1)); |
| 16106 | //nvram_ut_trace("cmpt_op_result:%d\n\r", nvram_lid_cmpt_operation(NVRAM_EF_NVRAM_TEST_1_LID, 0x00020301, 0x2)); |
| 16107 | } |
| 16108 | |
| 16109 | } |
| 16110 | |
| 16111 | kal_bool nvram_Ttask1_init(void) |
| 16112 | { |
| 16113 | |
| 16114 | return KAL_TRUE; |
| 16115 | |
| 16116 | } |
| 16117 | |
| 16118 | kal_bool nvram_Ttask1_reset(void) |
| 16119 | { |
| 16120 | |
| 16121 | return KAL_TRUE; |
| 16122 | |
| 16123 | } |
| 16124 | |
| 16125 | #if 0 |
| 16126 | /* under construction !*/ |
| 16127 | /* under construction !*/ |
| 16128 | /* under construction !*/ |
| 16129 | /* under construction !*/ |
| 16130 | /* under construction !*/ |
| 16131 | /* under construction !*/ |
| 16132 | /* under construction !*/ |
| 16133 | /* under construction !*/ |
| 16134 | /* under construction !*/ |
| 16135 | /* under construction !*/ |
| 16136 | /* under construction !*/ |
| 16137 | /* under construction !*/ |
| 16138 | /* under construction !*/ |
| 16139 | /* under construction !*/ |
| 16140 | /* under construction !*/ |
| 16141 | /* under construction !*/ |
| 16142 | /* under construction !*/ |
| 16143 | /* under construction !*/ |
| 16144 | /* under construction !*/ |
| 16145 | /* under construction !*/ |
| 16146 | /* under construction !*/ |
| 16147 | /* under construction !*/ |
| 16148 | /* under construction !*/ |
| 16149 | /* under construction !*/ |
| 16150 | /* under construction !*/ |
| 16151 | /* under construction !*/ |
| 16152 | /* under construction !*/ |
| 16153 | /* under construction !*/ |
| 16154 | /* under construction !*/ |
| 16155 | /* under construction !*/ |
| 16156 | /* under construction !*/ |
| 16157 | /* under construction !*/ |
| 16158 | /* under construction !*/ |
| 16159 | /* under construction !*/ |
| 16160 | /* under construction !*/ |
| 16161 | /* under construction !*/ |
| 16162 | /* under construction !*/ |
| 16163 | /* under construction !*/ |
| 16164 | /* under construction !*/ |
| 16165 | /* under construction !*/ |
| 16166 | /* under construction !*/ |
| 16167 | /* under construction !*/ |
| 16168 | /* under construction !*/ |
| 16169 | /* under construction !*/ |
| 16170 | /* under construction !*/ |
| 16171 | /* under construction !*/ |
| 16172 | /* under construction !*/ |
| 16173 | /* under construction !*/ |
| 16174 | /* under construction !*/ |
| 16175 | /* under construction !*/ |
| 16176 | /* under construction !*/ |
| 16177 | /* under construction !*/ |
| 16178 | /* under construction !*/ |
| 16179 | /* under construction !*/ |
| 16180 | /* under construction !*/ |
| 16181 | /* under construction !*/ |
| 16182 | /* under construction !*/ |
| 16183 | /* under construction !*/ |
| 16184 | /* under construction !*/ |
| 16185 | /* under construction !*/ |
| 16186 | /* under construction !*/ |
| 16187 | /* under construction !*/ |
| 16188 | /* under construction !*/ |
| 16189 | /* under construction !*/ |
| 16190 | /* under construction !*/ |
| 16191 | /* under construction !*/ |
| 16192 | /* under construction !*/ |
| 16193 | /* under construction !*/ |
| 16194 | /* under construction !*/ |
| 16195 | /* under construction !*/ |
| 16196 | /* under construction !*/ |
| 16197 | /* under construction !*/ |
| 16198 | /* under construction !*/ |
| 16199 | /* under construction !*/ |
| 16200 | /* under construction !*/ |
| 16201 | /* under construction !*/ |
| 16202 | /* under construction !*/ |
| 16203 | /* under construction !*/ |
| 16204 | /* under construction !*/ |
| 16205 | /* under construction !*/ |
| 16206 | /* under construction !*/ |
| 16207 | /* under construction !*/ |
| 16208 | /* under construction !*/ |
| 16209 | /* under construction !*/ |
| 16210 | /* under construction !*/ |
| 16211 | /* under construction !*/ |
| 16212 | /* under construction !*/ |
| 16213 | /* under construction !*/ |
| 16214 | /* under construction !*/ |
| 16215 | /* under construction !*/ |
| 16216 | /* under construction !*/ |
| 16217 | /* under construction !*/ |
| 16218 | /* under construction !*/ |
| 16219 | /* under construction !*/ |
| 16220 | /* under construction !*/ |
| 16221 | /* under construction !*/ |
| 16222 | /* under construction !*/ |
| 16223 | /* under construction !*/ |
| 16224 | /* under construction !*/ |
| 16225 | /* under construction !*/ |
| 16226 | /* under construction !*/ |
| 16227 | /* under construction !*/ |
| 16228 | /* under construction !*/ |
| 16229 | /* under construction !*/ |
| 16230 | /* under construction !*/ |
| 16231 | /* under construction !*/ |
| 16232 | /* under construction !*/ |
| 16233 | /* under construction !*/ |
| 16234 | /* under construction !*/ |
| 16235 | /* under construction !*/ |
| 16236 | /* under construction !*/ |
| 16237 | /* under construction !*/ |
| 16238 | /* under construction !*/ |
| 16239 | /* under construction !*/ |
| 16240 | /* under construction !*/ |
| 16241 | /* under construction !*/ |
| 16242 | /* under construction !*/ |
| 16243 | /* under construction !*/ |
| 16244 | /* under construction !*/ |
| 16245 | #endif |
| 16246 | kal_bool nvram_Ttask1_create(comptask_handler_struct **handle) |
| 16247 | { |
| 16248 | /*----------------------------------------------------------------*/ |
| 16249 | /* Local Variables */ |
| 16250 | /*----------------------------------------------------------------*/ |
| 16251 | static const comptask_handler_struct nvram_ttask1_handler_info = |
| 16252 | { |
| 16253 | nvram_Ttask1_main, /* task entry function */ |
| 16254 | nvram_Ttask1_init, /* task initialization function */ |
| 16255 | nvram_Ttask1_reset /* task reset handler */ |
| 16256 | }; |
| 16257 | |
| 16258 | /*----------------------------------------------------------------*/ |
| 16259 | /* Code Body */ |
| 16260 | /*----------------------------------------------------------------*/ |
| 16261 | *handle = (comptask_handler_struct*) & nvram_ttask1_handler_info; |
| 16262 | return KAL_TRUE; |
| 16263 | } |
| 16264 | #if 0 |
| 16265 | /* under construction !*/ |
| 16266 | /* under construction !*/ |
| 16267 | /* under construction !*/ |
| 16268 | /* under construction !*/ |
| 16269 | /* under construction !*/ |
| 16270 | /* under construction !*/ |
| 16271 | /* under construction !*/ |
| 16272 | /* under construction !*/ |
| 16273 | /* under construction !*/ |
| 16274 | /* under construction !*/ |
| 16275 | /* under construction !*/ |
| 16276 | /* under construction !*/ |
| 16277 | /* under construction !*/ |
| 16278 | /* under construction !*/ |
| 16279 | /* under construction !*/ |
| 16280 | /* under construction !*/ |
| 16281 | /* under construction !*/ |
| 16282 | /* under construction !*/ |
| 16283 | /* under construction !*/ |
| 16284 | /* under construction !*/ |
| 16285 | /* under construction !*/ |
| 16286 | /* under construction !*/ |
| 16287 | /* under construction !*/ |
| 16288 | /* under construction !*/ |
| 16289 | /* under construction !*/ |
| 16290 | /* under construction !*/ |
| 16291 | /* under construction !*/ |
| 16292 | /* under construction !*/ |
| 16293 | /* under construction !*/ |
| 16294 | /* under construction !*/ |
| 16295 | /* under construction !*/ |
| 16296 | /* under construction !*/ |
| 16297 | /* under construction !*/ |
| 16298 | /* under construction !*/ |
| 16299 | /* under construction !*/ |
| 16300 | /* under construction !*/ |
| 16301 | /* under construction !*/ |
| 16302 | /* under construction !*/ |
| 16303 | /* under construction !*/ |
| 16304 | /* under construction !*/ |
| 16305 | /* under construction !*/ |
| 16306 | /* under construction !*/ |
| 16307 | /* under construction !*/ |
| 16308 | /* under construction !*/ |
| 16309 | /* under construction !*/ |
| 16310 | /* under construction !*/ |
| 16311 | /* under construction !*/ |
| 16312 | /* under construction !*/ |
| 16313 | /* under construction !*/ |
| 16314 | /* under construction !*/ |
| 16315 | /* under construction !*/ |
| 16316 | /* under construction !*/ |
| 16317 | /* under construction !*/ |
| 16318 | /* under construction !*/ |
| 16319 | /* under construction !*/ |
| 16320 | /* under construction !*/ |
| 16321 | #endif |
| 16322 | #endif |