yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 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 | * Filename: |
| 38 | * --------- |
| 39 | * nvram_defs.h |
| 40 | * |
| 41 | * Project: |
| 42 | * -------- |
| 43 | * MT6208 |
| 44 | * |
| 45 | * Description: |
| 46 | * ------------ |
| 47 | * This file contains definitions used by NVRAM task. |
| 48 | * |
| 49 | * Author: |
| 50 | * ------- |
| 51 | * ------- |
| 52 | * |
| 53 | *============================================================================== |
| 54 | * HISTORY |
| 55 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 56 | *------------------------------------------------------------------------------ |
| 57 | * removed! |
| 58 | * |
| 59 | * removed! |
| 60 | * removed! |
| 61 | * removed! |
| 62 | * removed! |
| 63 | * |
| 64 | * removed! |
| 65 | * removed! |
| 66 | * removed! |
| 67 | * removed! |
| 68 | * |
| 69 | * removed! |
| 70 | * removed! |
| 71 | * removed! |
| 72 | * removed! |
| 73 | * removed! |
| 74 | * |
| 75 | * removed! |
| 76 | * removed! |
| 77 | * removed! |
| 78 | * removed! |
| 79 | * |
| 80 | * removed! |
| 81 | * removed! |
| 82 | * removed! |
| 83 | * |
| 84 | * removed! |
| 85 | * removed! |
| 86 | * removed! |
| 87 | * removed! |
| 88 | * |
| 89 | * removed! |
| 90 | * removed! |
| 91 | * removed! |
| 92 | * removed! |
| 93 | * removed! |
| 94 | * removed! |
| 95 | * removed! |
| 96 | * removed! |
| 97 | * |
| 98 | * removed! |
| 99 | * removed! |
| 100 | * removed! |
| 101 | * |
| 102 | * removed! |
| 103 | * removed! |
| 104 | * |
| 105 | * removed! |
| 106 | * removed! |
| 107 | * |
| 108 | * removed! |
| 109 | * removed! |
| 110 | * removed! |
| 111 | * |
| 112 | * removed! |
| 113 | * removed! |
| 114 | * |
| 115 | * removed! |
| 116 | * removed! |
| 117 | * |
| 118 | * removed! |
| 119 | * removed! |
| 120 | * removed! |
| 121 | * removed! |
| 122 | * |
| 123 | * removed! |
| 124 | * removed! |
| 125 | * removed! |
| 126 | * removed! |
| 127 | * |
| 128 | * removed! |
| 129 | * removed! |
| 130 | * removed! |
| 131 | * |
| 132 | * removed! |
| 133 | * removed! |
| 134 | * removed! |
| 135 | * removed! |
| 136 | * |
| 137 | * removed! |
| 138 | * removed! |
| 139 | * |
| 140 | * removed! |
| 141 | * removed! |
| 142 | * removed! |
| 143 | * |
| 144 | * removed! |
| 145 | * removed! |
| 146 | * removed! |
| 147 | * |
| 148 | * removed! |
| 149 | * removed! |
| 150 | * |
| 151 | * removed! |
| 152 | * removed! |
| 153 | * removed! |
| 154 | * |
| 155 | * removed! |
| 156 | * removed! |
| 157 | * removed! |
| 158 | * |
| 159 | * removed! |
| 160 | * removed! |
| 161 | * removed! |
| 162 | * |
| 163 | * removed! |
| 164 | * removed! |
| 165 | * |
| 166 | * removed! |
| 167 | * removed! |
| 168 | * removed! |
| 169 | * |
| 170 | * removed! |
| 171 | * removed! |
| 172 | * removed! |
| 173 | * |
| 174 | * removed! |
| 175 | * removed! |
| 176 | * removed! |
| 177 | * |
| 178 | * removed! |
| 179 | * removed! |
| 180 | * removed! |
| 181 | * |
| 182 | * removed! |
| 183 | * removed! |
| 184 | * removed! |
| 185 | * |
| 186 | * removed! |
| 187 | * removed! |
| 188 | * removed! |
| 189 | * |
| 190 | * removed! |
| 191 | * removed! |
| 192 | * removed! |
| 193 | * |
| 194 | * removed! |
| 195 | * removed! |
| 196 | * removed! |
| 197 | * |
| 198 | * removed! |
| 199 | * removed! |
| 200 | * removed! |
| 201 | * |
| 202 | * removed! |
| 203 | * removed! |
| 204 | * removed! |
| 205 | * |
| 206 | * removed! |
| 207 | * removed! |
| 208 | * removed! |
| 209 | * |
| 210 | * removed! |
| 211 | * removed! |
| 212 | * removed! |
| 213 | * |
| 214 | * removed! |
| 215 | * removed! |
| 216 | * removed! |
| 217 | * |
| 218 | * removed! |
| 219 | * removed! |
| 220 | * removed! |
| 221 | * |
| 222 | * removed! |
| 223 | * removed! |
| 224 | * removed! |
| 225 | * |
| 226 | * removed! |
| 227 | * removed! |
| 228 | * removed! |
| 229 | * |
| 230 | * removed! |
| 231 | * removed! |
| 232 | * removed! |
| 233 | * |
| 234 | * removed! |
| 235 | * removed! |
| 236 | * removed! |
| 237 | * |
| 238 | * removed! |
| 239 | * removed! |
| 240 | * removed! |
| 241 | * |
| 242 | * removed! |
| 243 | * removed! |
| 244 | * removed! |
| 245 | * |
| 246 | * removed! |
| 247 | * removed! |
| 248 | * removed! |
| 249 | * |
| 250 | * removed! |
| 251 | * removed! |
| 252 | * removed! |
| 253 | * |
| 254 | * removed! |
| 255 | * removed! |
| 256 | * removed! |
| 257 | * |
| 258 | * removed! |
| 259 | * removed! |
| 260 | * removed! |
| 261 | * |
| 262 | *------------------------------------------------------------------------------ |
| 263 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 264 | *============================================================================== |
| 265 | *******************************************************************************/ |
| 266 | |
| 267 | #ifndef NVRAM_DEFS_H |
| 268 | #define NVRAM_DEFS_H |
| 269 | |
| 270 | #ifdef __cplusplus |
| 271 | extern "C" |
| 272 | { |
| 273 | #endif /* __cplusplus */ |
| 274 | |
| 275 | #include "kal_general_types.h" |
| 276 | #include "kal_public_defs.h" |
| 277 | |
| 278 | /*************************************************************** |
| 279 | * Macro and Definition used for lid table |
| 280 | **********************************************************************/ |
| 281 | |
| 282 | /***************************************************************************** |
| 283 | * Include |
| 284 | ****************************************************************************/ |
| 285 | #ifndef NVRAM_NOT_PRESENT |
| 286 | #include "nvram_lid_statistics.h" |
| 287 | #endif |
| 288 | #include "nvram_enums.h" |
| 289 | #include "mmss_def.h" |
| 290 | #include "dhl_trace.h" |
| 291 | //*************************************************************************** |
| 292 | // -- Custpack configuration -- |
| 293 | //*************************************************************************** |
| 294 | #ifdef __MULTIPLE_BINARY_FILES__ |
| 295 | #if !defined(__L1_STANDALONE__) |
| 296 | #define __NVRAM_SUPPORT_CUSTPACK__ |
| 297 | #endif |
| 298 | #endif |
| 299 | |
| 300 | /***************************************************************************** |
| 301 | * Define |
| 302 | ****************************************************************************/ |
| 303 | #if defined (__NVRAM_UT_TEST__) |
| 304 | |
| 305 | extern kal_taskid nvram_test_task1_id; |
| 306 | extern kal_uint32 nvram_ut_assert_flag; |
| 307 | #define NVRAM_EXT_ASSERT(expr, e1, e2, e3, ...) do{\ |
| 308 | if(nvram_test_task1_id == kal_get_current_task() && !(expr)) {\ |
| 309 | nvram_ut_assert_flag = e2;\ |
| 310 | do{__VA_ARGS__;}while(0);\ |
| 311 | return NVRAM_ERRNO_FAIL;\ |
| 312 | }\ |
| 313 | else {\ |
| 314 | EXT_ASSERT(expr, e1, e2, e3);\ |
| 315 | }\ |
| 316 | }while(0) |
| 317 | |
| 318 | /*BOOT_TRACE_XXXX is used for nvram_init() flow trace*/ |
| 319 | #define BOOT_TRACE_DRV_UNFORMATTED 0x01 |
| 320 | #define BOOT_TRACE_FOLDER_NOT_READY 0x02 |
| 321 | #define BOOT_TRACE_DRIVE_BROKEN_VNOERR 0x04 |
| 322 | #define BOOT_TRACE_READ_SYS_LID_FAIL 0x08 |
| 323 | #define BOOT_TRACE_CLEAN_BOOT 0x10 |
| 324 | #define BOOT_TRACE_SW_VERNO_COMPATIBLE 0x20 |
| 325 | #define BOOT_TRACE_SW_VERNO_CONFLICT 0x40 |
| 326 | |
| 327 | #else |
| 328 | #define NVRAM_EXT_ASSERT(expr, e1, e2, e3, ...) EXT_ASSERT(expr, e1, e2, e3) |
| 329 | #endif |
| 330 | |
| 331 | |
| 332 | #define NVRAM_MAX_PATH_LEN 36 |
| 333 | #define FILE_PREFIX_LEN 4 |
| 334 | #define FILE_VERNO_LEN 3 |
| 335 | #define FILE_RESERVED_LEN 9 |
| 336 | #define NVRAM_FILE_LEN (FILE_PREFIX_LEN + 1 + FILE_VERNO_LEN) |
| 337 | #define NVRAM_MAX_DESC_LEN 20 |
| 338 | |
| 339 | #define NVRAM_EF_RESERVED_LID 0xFFFE |
| 340 | |
| 341 | #define VER_LID(lid) lid##_VERNO lid |
| 342 | #ifndef NVRAM_AUTO_GEN |
| 343 | #define VER(lid) lid##_VERNO |
| 344 | #else |
| 345 | #if(defined(__NVRAM_LID_HASH_CHECK__) && defined(__MTK_INTERNAL__)) |
| 346 | #define VER(lid) lid##_VERNO,#lid,NULL,lid##_HASH |
| 347 | #else |
| 348 | #define VER(lid) lid##_VERNO,#lid |
| 349 | #endif |
| 350 | #endif |
| 351 | |
| 352 | #define NVRAM_EF_ZERO_DEFAULT_ZIP NVRAM_EF_ZERO_DEFAULT |
| 353 | #define NVRAM_EF_FF_DEFAULT_ZIP NVRAM_EF_FF_DEFAULT |
| 354 | |
| 355 | |
| 356 | #ifndef NVRAM_AUTO_GEN |
| 357 | #define NVRAM_NORMAL(X) (kal_uint8 const *)X |
| 358 | #define NVRAM_NORMAL_NOT_GEN(X) (kal_uint8 const *)X |
| 359 | |
| 360 | #if !defined(__NVRAM_SUPPORT_CUSTPACK__) && !defined(__L1_STANDALONE__) |
| 361 | #define NVRAM_CUSTPACK(X) NVRAM_NORMAL(X) |
| 362 | #else |
| 363 | #define NVRAM_CUSTPACK(X) NVRAM_EF_ZERO_DEFAULT |
| 364 | #define NVRAM_CUSTPACK_DEFAULT_REPLACED |
| 365 | #endif /* __MMI_FMI__ */ |
| 366 | |
| 367 | #define NVRAM_SECUPACK(X) NVRAM_EF_ZERO_DEFAULT |
| 368 | #define NVRAM_DEFAULT_FUNC(X) (kal_uint8 const*)X |
| 369 | #else |
| 370 | #define NVRAM_NORMAL(X) #X, (kal_uint8 const *)X |
| 371 | #define NVRAM_NORMAL_NOT_GEN(X) #X,NVRAM_EF_ZERO_DEFAULT |
| 372 | #define NVRAM_CUSTPACK(X) #X,NVRAM_EF_SPECIAL_DEFAULT |
| 373 | #define NVRAM_SECUPACK(X) #X,(kal_uint8 const *)X |
| 374 | #define NVRAM_DEFAULT_FUNC(X) #X,NVRAM_EF_SPECIAL_DEFAULT |
| 375 | #endif |
| 376 | |
| 377 | #define NVRAM_LOCK_PATTERN_LOCKED "_NVRAM_LOCK_YES_" //need 16b align |
| 378 | #define NVRAM_LOCK_PATTERN_UNLOCKED "__NVRAM_LOCK_NO_" |
| 379 | |
| 380 | #define NVRAM_CHKSUM_SIZE 8 |
| 381 | #define NVRAM_CHKSUM_SIZE_2B sizeof(kal_uint16) |
| 382 | |
| 383 | /* AES 16 byte alignment, must be power of 2*/ |
| 384 | #define NVRAM_MSP_ALIGNMENT 16 |
| 385 | #define NVRAM_MSP_ALIGNMENT_REMAINDER(x) ((~(x) + 1) & (NVRAM_MSP_ALIGNMENT - 1)) |
| 386 | #define NVRAM_MSP_ALIGNMENT_FLOOR(x) ((x) & (~(NVRAM_MSP_ALIGNMENT-1))) |
| 387 | #define NVRAM_MSP_ALIGNMENT_CEILING(x) (((x) + NVRAM_MSP_ALIGNMENT - 1) & ~(NVRAM_MSP_ALIGNMENT-1)) |
| 388 | |
| 389 | #define NVRAM_MSP_DECRYPT 0 |
| 390 | #define NVRAM_MSP_ENCRYPT 1 |
| 391 | |
| 392 | #define NVRAM_APP_RESERVED 0 |
| 393 | |
| 394 | /* Attributes of a Logical Data Item, predefined. */ |
| 395 | typedef kal_uint32 nvram_attr_enum; |
| 396 | #define NVRAM_ATTR_AVERAGE 0x00000000UL |
| 397 | #define NVRAM_ATTR_MULTI_DEFAULT 0x00000001UL |
| 398 | #define NVRAM_ATTR_WRITEPROTECT 0x00000002UL |
| 399 | #define NVRAM_ATTR_MULTIPLE 0x00000004UL |
| 400 | #define NVRAM_ATTR_CONFIDENTIAL 0x00000008UL |
| 401 | #define NVRAM_ATTR_MULTIREC_READ 0x00000010UL |
| 402 | #define NVRAM_ATTR_MSP 0x00000020UL /* Protected by MTK Secure Platform */ |
| 403 | #define NVRAM_ATTR_OTA_RESET 0x00000040UL |
| 404 | #define NVRAM_ATTR_GEN_DEFAULT 0x00000080UL |
| 405 | #define NVRAM_ATTR_RING 0x00000100UL |
| 406 | #define NVRAM_ATTR_PACKAGE 0x00000200UL /* NVRAM Reserved.LID will package in file */ |
| 407 | #define NVRAM_ATTR_BACKUP_FAT 0x00000400UL /* Put a copy into backup partition, and the format is FAT */ |
| 408 | #define NVRAM_ATTR_BACKUP_RAW 0x00000800UL /* Put a copy into backup partition, and the format is Raw data */ |
| 409 | #define NVRAM_ATTR_RESERVE_BACKWARD 0x00001000UL |
| 410 | #define NVRAM_ATTR_FAULT_ASSERT 0x00002000UL |
| 411 | #if 0 |
| 412 | /* under construction !*/ |
| 413 | /* under construction !*/ |
| 414 | /* under construction !*/ |
| 415 | #endif |
| 416 | #define NVRAM_ATTR_COMMITTED 0x00004000UL /* Add for SP, add FS_COMMITTED while opening file */ |
| 417 | #define NVRAM_ATTR_RAW_DATA 0x00008000UL |
| 418 | #define NVRAM_ATTR_CHKSUM_INTEGRATE 0x00010000UL |
| 419 | #define NVRAM_ATTR_CHKSUM_ENHNC_ALGRTHM 0x00020000UL |
| 420 | |
| 421 | |
| 422 | //Add Attribute only for MCF Used |
| 423 | #define NVRAM_ATTR_MCF_OTA_ADDITIONAL_NOT_CHECK_VERNO 0x10000000UL /* MCF will not check LID version when OTA. User MUST!! make sure structure is backward compatible. MUST set at least one of OTA, OTA_FOR_QUERY, or OTA_BY_OP. */ |
| 424 | #define NVRAM_ATTR_MCF_OTA_FOR_QUERY 0x20000000UL /* Customer can modify your LID when "OTA". MCF will NOT write setting to NVRAM. User need to query setting at run time. Conflict with NVRAM_ATTR_MCF_OTA. */ |
| 425 | #define NVRAM_ATTR_MCF_OTA_BY_OP 0x40000000UL /* Customer can modify your LID when "OTA by operator". MCF will NOT write setting to NVRAM. User need to query setting at run time. */ |
| 426 | #define NVRAM_ATTR_MCF_OTA 0x80000000UL /* Customer can modify your LID when "OTA". MCF will write setting to NVRAM. User does not aware.*/ |
| 427 | |
| 428 | #define NVRAM_ATTR_ALL 0xFFFFFFFFUL |
| 429 | |
| 430 | |
| 431 | typedef kal_uint32 nvram_category_enum; |
| 432 | /* |
| 433 | * byte 0: NVRAM internal or Not |
| 434 | */ |
| 435 | #define NVRAM_CATEGORY_USER 0x0000 |
| 436 | #define NVRAM_CATEGORY_INTERNAL 0x0001 |
| 437 | |
| 438 | /* |
| 439 | * byte 1: storage information |
| 440 | */ |
| 441 | #define NVRAM_CATEGORY_BACKUP_SDS 0x0010 |
| 442 | #define NVRAM_CATEGORY_OTP 0x0020 |
| 443 | #define NVRAM_CATEGORY_CUSTOM_DISK 0x0040 /* Used by custom, it means the data is put into another partition */ |
| 444 | |
| 445 | /* Used by custom, NVRAM will put custom's sensitive data into another folder |
| 446 | if multiple folder feature turn on. Attribute of the data item in this category |
| 447 | must with NVRAM_ATTR_CONFIDENTIAL | NVRAM_ATTR_MULTIPLE */ |
| 448 | #define NVRAM_CATEGORY_CUSTOM_SENSITIVE 0x0080 |
| 449 | |
| 450 | /* |
| 451 | * byte 2: default value information |
| 452 | */ |
| 453 | #define NVRAM_CATEGORY_CUSTPACK 0x0100 |
| 454 | #define NVRAM_CATEGORY_SECUPACK 0x0200 |
| 455 | #define NVRAM_CATEGORY_FUNC_DEFAULT 0x0400 |
| 456 | |
| 457 | /* |
| 458 | * byte 3: factory tool/Smartphone Nvram related information |
| 459 | */ |
| 460 | #if (defined(CURR_MODULE) && (CURR_MODULE == MOD_NVRAM)) || defined(NVRAM_AUTO_GEN) || defined(NVRAM_LID_SPLIT) || defined(__LTE_RAT__) |
| 461 | #define NVRAM_CATEGORY_CALIBRAT 0x1000 |
| 462 | #define NVRAM_CATEGORY_IMPORTANT 0x2000 |
| 463 | #define NVRAM_CATEGORY_IMPORTANT_L4 0x4000 |
| 464 | #define NVRAM_CATEGORY_IMPORTANT_L1 0x8000 |
| 465 | #else |
| 466 | #define NVRAM_CATEGORY_CALIBRAT "NVRAM_CATEGORY_CALIBRAT is not able to use here! Please contact META tool owner for help." |
| 467 | #define NVRAM_CATEGORY_IMPORTANT "NVRAM_CATEGORY_IMPORTANT is not able to use here! Please contact META tool owner for help." |
| 468 | #define NVRAM_CATEGORY_IMPORTANT_L4 "NVRAM_CATEGORY_IMPORTANT_L4 is not able to use here! Please contact META tool owner for help." |
| 469 | #define NVRAM_CATEGORY_IMPORTANT_L1 "NVRAM_CATEGORY_IMPORTANT_L1 is not able to use here! Please contact META tool owner for help." |
| 470 | #endif |
| 471 | |
| 472 | #define NVRAM_CATEGORY_ALL 0xFFFF |
| 473 | #define NVRAM_CATEGORY_RESERVED 0x80000000UL /* for __NVRAM_READ_RESERVED_FILE__ feature*/ |
| 474 | |
| 475 | typedef enum |
| 476 | { |
| 477 | NVRAM_CLEAN_FOLDER_NONE = 0x00, |
| 478 | NVRAM_CLEAN_FOLDER_SYSTEM = 0x01, //custom_nvram_config.c |
| 479 | NVRAM_CLEAN_FOLDER_FACTORY = 0x02, |
| 480 | NVRAM_CLEAN_FOLDER_BRANCH = 0x04, |
| 481 | NVRAM_CLEAN_FOLDER_ALL = 0xFF |
| 482 | } nvram_clean_folder_enum; |
| 483 | /***************************************************************************** |
| 484 | * Typedef |
| 485 | ****************************************************************************/ |
| 486 | |
| 487 | typedef void (*nvram_query_deault_func)(nvram_lid_enum file_id, kal_uint8 *buffer, kal_uint16 buffer_size); |
| 488 | |
| 489 | #ifndef NVRAM_AUTO_GEN |
| 490 | |
| 491 | #if !defined(_MSC_VER) || defined(GEN_FOR_PC) |
| 492 | typedef struct |
| 493 | #else |
| 494 | #ifdef L1_SIM |
| 495 | typedef struct |
| 496 | #else |
| 497 | typedef struct __declspec(align(32)) |
| 498 | #endif |
| 499 | #endif |
| 500 | { |
| 501 | nvram_lid_enum LID; /* Logical Data Item ID, U16 */ |
| 502 | kal_uint16 total_records; /* Number of records */ |
| 503 | kal_uint32 size; /* Size of one record. < sizeof(control buffer) */ |
| 504 | kal_uint8 const* default_value; /* Hardcoded default */ |
| 505 | nvram_category_enum category; /* U32 */ |
| 506 | nvram_attr_enum attr; /* U32 */ |
| 507 | kal_char fileprefix[FILE_PREFIX_LEN + 1]; |
| 508 | kal_char fileverno[FILE_VERNO_LEN + 1]; |
| 509 | //kal_char* description; |
| 510 | kal_int32 append_offset; |
| 511 | kal_char* append_buffer; |
| 512 | } nvram_ltable_entry_struct; |
| 513 | #else |
| 514 | typedef struct |
| 515 | { |
| 516 | nvram_lid_enum LID; |
| 517 | kal_uint16 total_records; |
| 518 | kal_uint32 size; |
| 519 | kal_char* str_default_value; |
| 520 | kal_uint8 * default_value; |
| 521 | nvram_category_enum category; |
| 522 | nvram_attr_enum attr; |
| 523 | kal_char fileprefix[FILE_PREFIX_LEN + 1]; |
| 524 | kal_char fileverno[FILE_VERNO_LEN + 1]; |
| 525 | kal_char* str_LID; |
| 526 | kal_char* description; |
| 527 | #if(defined(__NVRAM_LID_HASH_CHECK__) && defined(__MTK_INTERNAL__)) |
| 528 | kal_uint32 hash_key; |
| 529 | #endif |
| 530 | } nvram_ltable_entry_struct; |
| 531 | |
| 532 | #ifdef NVRAM_AUTO_GEN // For nvram_auto_gen target build |
| 533 | typedef struct |
| 534 | { |
| 535 | nvram_lid_enum LID; |
| 536 | kal_uint16 total_records; |
| 537 | kal_uint32 size; |
| 538 | kal_uint32 str_default_value; //kal_char* |
| 539 | kal_uint32 default_value; //kal_uint8 const* |
| 540 | nvram_category_enum category; |
| 541 | nvram_attr_enum attr; |
| 542 | kal_char fileprefix[FILE_PREFIX_LEN + 1]; |
| 543 | kal_char fileverno[FILE_VERNO_LEN + 1]; |
| 544 | kal_uint32 str_LID; //kal_char* |
| 545 | kal_uint32 description; //kal_char* |
| 546 | } nvram_ltable_entry_struct_target; |
| 547 | #endif |
| 548 | #endif |
| 549 | |
| 550 | typedef struct |
| 551 | { |
| 552 | nvram_ltable_entry_struct *ltable; |
| 553 | kal_uint32 size; |
| 554 | }nvram_ltable_tbl_struct; |
| 555 | |
| 556 | |
| 557 | #ifdef NVRAM_AUTO_GEN |
| 558 | #define SYS_CACHE_ENTRY(ENUM_ID, APP_ID, RESTORE, DESCRIPTION, VALUE1, VALUE2, VALUE3, VALUE4, VALUE5, VALUE6, VALUE7, VALUE8) \ |
| 559 | { \ |
| 560 | ENUM_ID, \ |
| 561 | APP_ID, \ |
| 562 | RESTORE, \ |
| 563 | VALUE1, \ |
| 564 | VALUE2, \ |
| 565 | VALUE3, \ |
| 566 | VALUE4, \ |
| 567 | VALUE5, \ |
| 568 | VALUE6, \ |
| 569 | VALUE7, \ |
| 570 | VALUE8, \ |
| 571 | #ENUM_ID, \ |
| 572 | #APP_ID, \ |
| 573 | #VALUE1, \ |
| 574 | #VALUE2, \ |
| 575 | #VALUE3, \ |
| 576 | #VALUE4, \ |
| 577 | #VALUE5, \ |
| 578 | #VALUE6, \ |
| 579 | #VALUE7, \ |
| 580 | #VALUE8, \ |
| 581 | DESCRIPTION \ |
| 582 | } |
| 583 | |
| 584 | typedef struct |
| 585 | { |
| 586 | kal_uint16 id; /* nvram_sys_cache_enum */ |
| 587 | nvram_app_id_enum app_id; /* nvram_restore_app_id_enum */ |
| 588 | kal_bool restore; |
| 589 | kal_uint8 value1; |
| 590 | kal_uint8 value2; |
| 591 | kal_uint8 value3; |
| 592 | kal_uint8 value4; |
| 593 | kal_uint8 value5; |
| 594 | kal_uint8 value6; |
| 595 | kal_uint8 value7; |
| 596 | kal_uint8 value8; |
| 597 | kal_char *id_str; |
| 598 | kal_char *app_id_str; |
| 599 | kal_char *value1_str; |
| 600 | kal_char *value2_str; |
| 601 | kal_char *value3_str; |
| 602 | kal_char *value4_str; |
| 603 | kal_char *value5_str; |
| 604 | kal_char *value6_str; |
| 605 | kal_char *value7_str; |
| 606 | kal_char *value8_str; |
| 607 | kal_char *description; |
| 608 | }nvram_sys_cache_entry; |
| 609 | #endif |
| 610 | |
| 611 | #if defined(NVRAM_AUTO_GEN) |
| 612 | #define ltable_entry_struct nvram_ltable_entry_struct __attribute__((aligned(4))) __attribute__((__section__("_nvram_ltable"))) |
| 613 | #define NVRAM_LIG_GRP_INIT(X) |
| 614 | |
| 615 | #elif defined(__MTK_TARGET__) |
| 616 | #define ltable_entry_struct nvram_ltable_entry_struct __attribute__((section("_nvram_ltable"))) |
| 617 | #define NVRAM_LIG_GRP_INIT(X) {\ |
| 618 | extern nvram_ltable_entry_struct X##[];\ |
| 619 | void *X##_p = (void *)&X;\ |
| 620 | } |
| 621 | |
| 622 | #else |
| 623 | #if defined(_MSC_VER) && (_MSC_VER >= 1500) |
| 624 | #define ltable_entry_struct __pragma(section("_nvram_ltable_content")) __declspec(align(64))\ |
| 625 | nvram_ltable_entry_struct __declspec(allocate("_nvram_ltable_content")) |
| 626 | #elif defined(__GNUC__) |
| 627 | #define ltable_entry_struct nvram_ltable_entry_struct __attribute__((section("_nvram_ltable_content"))) |
| 628 | #endif |
| 629 | #define NVRAM_LIG_GRP_INIT(X) extern nvram_ltable_entry_struct X##[];\ |
| 630 | static void *X##_p = (void *)&X; |
| 631 | |
| 632 | #endif |
| 633 | |
| 634 | |
| 635 | #ifndef NVRAM_CUSTPACK_TOTAL |
| 636 | #define NVRAM_CUSTPACK_TOTAL 1 |
| 637 | #endif |
| 638 | |
| 639 | typedef struct |
| 640 | { |
| 641 | kal_uint8 const* version; |
| 642 | void const* custpack_default[NVRAM_CUSTPACK_TOTAL]; |
| 643 | }custpack_nvram_header; |
| 644 | |
| 645 | typedef struct |
| 646 | { |
| 647 | nvram_clean_folder_enum category; |
| 648 | kal_wchar *folder_path; |
| 649 | } nvram_clean_folder_entry; |
| 650 | |
| 651 | typedef struct |
| 652 | { |
| 653 | nvram_lid_enum LID; |
| 654 | kal_bool (*get_data)(kal_uint8 *buffer, kal_uint16 buf_size); |
| 655 | }nvram_shutdown_cb_struct; |
| 656 | |
| 657 | typedef struct |
| 658 | { |
| 659 | nvram_lid_enum LID; |
| 660 | kal_uint32 size; /* Size of one record. < sizeof(control buffer) */ |
| 661 | kal_uint16 total_records; /* Number of records */ |
| 662 | kal_uint8 const *default_value; |
| 663 | kal_bool is_multi_default; |
| 664 | } nvram_cat_replace_setting; |
| 665 | |
| 666 | //#endif |
| 667 | #define RST_CHKSUM_SIZE 16 |
| 668 | typedef struct |
| 669 | { |
| 670 | kal_char header[4]; |
| 671 | nvram_lid_enum LID; |
| 672 | kal_uint16 total_records; |
| 673 | kal_uint32 record_size; |
| 674 | kal_uint32 ldi_attr; |
| 675 | kal_uint32 ldi_category; |
| 676 | kal_uint8 defval_chkrst_h[RST_CHKSUM_SIZE-6]; |
| 677 | kal_uint16 checksum; |
| 678 | } nvram_ldi_ota_header; |
| 679 | #define NVRAM_LDI_OTA_HEADER_SIZE 32 |
| 680 | |
| 681 | typedef struct |
| 682 | { |
| 683 | kal_uint32 last_write_taskID; |
| 684 | kal_uint8 defval_chkrst_l[6]; |
| 685 | kal_uint16 last_write_time; |
| 686 | kal_uint32 write_times; |
| 687 | kal_uint8 struct_chkrst[RST_CHKSUM_SIZE]; |
| 688 | } nvram_ldi_debug_header; |
| 689 | #define NVRAM_LDI_DEBUG_HEADER_SIZE 32 |
| 690 | #define NVRAM_LDI_HEADER_SIZE (NVRAM_LDI_OTA_HEADER_SIZE + NVRAM_LDI_DEBUG_HEADER_SIZE) |
| 691 | |
| 692 | typedef struct |
| 693 | { |
| 694 | nvram_ldi_ota_header nv_ota_header; |
| 695 | nvram_ldi_debug_header nv_dbg_header; |
| 696 | } nvram_ldi_header; |
| 697 | |
| 698 | typedef struct |
| 699 | { |
| 700 | nvram_lid_enum LID; |
| 701 | kal_uint8 chksum[16]; |
| 702 | }checksum_reset_struct; |
| 703 | |
| 704 | |
| 705 | typedef enum |
| 706 | { |
| 707 | LDI_HEADER_OTA_SECTION = 0x01, |
| 708 | LDI_HEADER_DBG_SECTION = 0x02, |
| 709 | LDI_HEADER_ALL_SECTION = 0x03 |
| 710 | } nvram_header_section_enum; |
| 711 | |
| 712 | #if defined(__MTK_TARGET__) |
| 713 | #define NVRAM_LTABLE_END |
| 714 | #else |
| 715 | #define NVRAM_LTABLE_END 0 |
| 716 | #endif |
| 717 | |
| 718 | #define NVRAM_READ_GPT_TIMEOUT 2000 //*10ms, 2000 stands 20s |
| 719 | #define NVRAM_WRITE_GPT_TIMEOUT 2000 //20s |
| 720 | #define MAX_TRACE_NUM 10 |
| 721 | |
| 722 | typedef struct |
| 723 | { |
| 724 | kal_uint32 LID; |
| 725 | kal_uint32 access_way; |
| 726 | kal_uint32 start_time; |
| 727 | kal_uint32 end_time; |
| 728 | kal_uint32 ret_value; |
| 729 | }trace_info; |
| 730 | |
| 731 | typedef struct |
| 732 | { |
| 733 | kal_uint32 read_trace_index; //record which index is the last updated |
| 734 | kal_uint32 write_trace_index; |
| 735 | kal_uint32 reset_trace_index; |
| 736 | trace_info read_trace[MAX_TRACE_NUM]; //only record the info of last 10 times access |
| 737 | trace_info write_trace[MAX_TRACE_NUM]; |
| 738 | trace_info reset_trace[MAX_TRACE_NUM]; |
| 739 | |
| 740 | }nvram_access_trace_information; |
| 741 | |
| 742 | #define NWSEL_HISTORY_TABLE_SIZE 16 |
| 743 | #define NVRAM_MAX_IMSI_LEN 9 |
| 744 | #define NVRAM_MAX_LTE_RETRY_COUNT 5 |
| 745 | |
| 746 | #define NVRAM_APPEND_TYPE_CHKSUM 0x0001 |
| 747 | #define NVRAM_APPEND_TYPE_END 0xFFFF |
| 748 | |
| 749 | typedef struct |
| 750 | { |
| 751 | //--- common part ------------- |
| 752 | kal_char header[4]; //"APDX" |
| 753 | kal_uint16 checksum; |
| 754 | nvram_appendix_type_enum type; |
| 755 | kal_uint32 data_offset; |
| 756 | //----------------------------- |
| 757 | kal_uint32 header_info[5]; |
| 758 | } nvram_ldi_appendix_header; |
| 759 | #define NVRAM_LDI_APPENDIX_HEADER_SIZE 32 |
| 760 | |
| 761 | ///////////////////////////////////////// |
| 762 | /* |
| 763 | Used to NVRAM Debug |
| 764 | */ |
| 765 | //////////////////////////////////////// |
| 766 | |
| 767 | typedef struct |
| 768 | { |
| 769 | nvram_access_type_enum access_type; |
| 770 | kal_char filename[NVRAM_MAX_PATH_LEN]; |
| 771 | kal_uint32 start_time; |
| 772 | kal_uint32 end_time; |
| 773 | kal_uint32 consum_time; |
| 774 | kal_int32 access_result; |
| 775 | kal_uint32 access_count; |
| 776 | kal_uint32 max_time; |
| 777 | kal_uint32 min_time; |
| 778 | kal_uint32 total_time; |
| 779 | }nvram_access_info_type; |
| 780 | |
| 781 | typedef struct |
| 782 | { |
| 783 | nvram_access_type_enum access_type; |
| 784 | kal_char filename[NVRAM_MAX_PATH_LEN]; |
| 785 | kal_uint32 start_time; |
| 786 | kal_uint32 end_time; |
| 787 | kal_int32 access_result; |
| 788 | }nvram_access_info_ex_type; |
| 789 | |
| 790 | |
| 791 | typedef struct |
| 792 | { |
| 793 | kal_uint8 info_log:1; |
| 794 | kal_uint8 warning_log:1; |
| 795 | kal_uint8 error_log:1; |
| 796 | kal_uint8 enable_trace:1; |
| 797 | }nvram_trace_setting_type; |
| 798 | |
| 799 | |
| 800 | #define MAX_TIME_COUNT 19 |
| 801 | #define RESERVED_MEMORY_FOR_NVRAM 100 |
| 802 | #define MD_CCCI_INFO_SIZE 4 |
| 803 | #define NVRAM_DUMP_TRACE_TEMP_BUFFER_SIZE 160 |
| 804 | #define NVRAM_DUMP_TRACE_BUFFER_SIZE 4096 |
| 805 | #define NVRAM_MD_VERSION_INFO_SIZE 34 |
| 806 | #define NVRAM_SECRET_SEED_KEY_SIZE 32 |
| 807 | |
| 808 | typedef struct |
| 809 | { |
| 810 | kal_uint8 state; |
| 811 | kal_bool dev_broken; |
| 812 | kal_bool lock; |
| 813 | kal_bool saved_lock; |
| 814 | kal_uint8 secret_key[NVRAM_SECRET_SEED_KEY_SIZE]; |
| 815 | kal_uint8 old_coded_version[NVRAM_MD_VERSION_INFO_SIZE + 1]; |
| 816 | kal_uint8 old_branch_version[NVRAM_MD_VERSION_INFO_SIZE + 1]; |
| 817 | kal_uint8 old_flavor_version[NVRAM_MD_VERSION_INFO_SIZE + 1]; |
| 818 | kal_uint8 old_build_time[NVRAM_MD_VERSION_INFO_SIZE + 1]; |
| 819 | nvram_lid_enum total_LID; |
| 820 | kal_uint32 area_size; |
| 821 | kal_uint32 sw_status; |
| 822 | }nvram_init_context_type; |
| 823 | |
| 824 | typedef struct |
| 825 | { |
| 826 | kal_uint32 cache_memory_addr; |
| 827 | kal_uint32 cache_memory_size; |
| 828 | kal_uint32 cache_init_status; |
| 829 | }nvram_cache_setting_type; |
| 830 | |
| 831 | typedef struct |
| 832 | { |
| 833 | kal_uint32 nvram_init_type; |
| 834 | kal_uint32 nvram_init_step; |
| 835 | kal_uint32 nvram_init_time[MAX_TIME_COUNT]; |
| 836 | nvram_cache_setting_type nvram_cache_setting; |
| 837 | nvram_access_trace_setting_file_result_enum nvram_access_trace_setting_file_val; |
| 838 | //nvram_trace_setting is used to control nvram trace dump |
| 839 | //bit5:always_write;bit4:info_log;bit3:warning_log; |
| 840 | //bit2:critical_log;bit1:write_file_way;bit0:enable_trace |
| 841 | kal_uint32 nvram_trace_setting; |
| 842 | kal_uint8 nvram_trace_fs_access_val; |
| 843 | |
| 844 | nvram_init_context_type nvram_init_context; |
| 845 | nvram_access_info_type nvram_access_info; |
| 846 | nvram_access_info_ex_type nvram_access_info_for_exception; |
| 847 | kal_uint8 reserved[RESERVED_MEMORY_FOR_NVRAM]; |
| 848 | kal_uint32 md_ccci_debug_info[MD_CCCI_INFO_SIZE]; |
| 849 | }nvram_ee_info_type; |
| 850 | |
| 851 | #define NVRAM_INIT_NORMAL_BOOT_UP 0x0 |
| 852 | #define NVRAM_INIT_FIRST_BOOT_UP 0x0001 |
| 853 | #define NVRAM_INIT_OTA_BOOT_UP 0x0002 |
| 854 | #define NVRAM_INIT_FACTORY_BOOT_UP 0x0004 |
| 855 | |
| 856 | #define NVRAM_TRACE_ALWAYS_WRITE 0x20 |
| 857 | #define NVRAM_INFO_DUMP 0x10 |
| 858 | #define NVRAM_WARNING_DUMP 0x8 |
| 859 | #define NVRAM_CRITICAL_DUMP 0x4 |
| 860 | |
| 861 | #define NVRAM_DEBUG_DUMP(log_level,info, ...) \ |
| 862 | do {\ |
| 863 | if(nvram_ee_info != NULL){\ |
| 864 | if((nvram_ee_info->nvram_trace_setting & 0x1) && (nvram_ee_info->nvram_trace_setting & log_level) && ((nvram_ee_info->nvram_trace_setting & NVRAM_TRACE_ALWAYS_WRITE) || !dhl_is_trace_started())) \ |
| 865 | {\ |
| 866 | kal_uint32 str_size = 0;\ |
| 867 | kal_uint32 str_title_size = 0;\ |
| 868 | kal_uint32 trace_len = 0;\ |
| 869 | kal_uint8 trace_count = 0;\ |
| 870 | kal_bool exception_flag = INT_QueryExceptionStatus();\ |
| 871 | if(!exception_flag)\ |
| 872 | {\ |
| 873 | nvram_util_take_mutex(g_nvram_dump_trace_mutex);\ |
| 874 | }\ |
| 875 | kal_mem_set(nvram_trace_dump_temp_buffer,0,NVRAM_DUMP_TRACE_TEMP_BUFFER_SIZE);\ |
| 876 | if(log_level & NVRAM_CRITICAL_DUMP)\ |
| 877 | {\ |
| 878 | str_title_size = sprintf(nvram_trace_dump_temp_buffer,"Time:[0x%08X]Module:[%d][NVM_Critical]",(kal_uint32)ust_get_current_time(),stack_get_active_module_id());\ |
| 879 | }\ |
| 880 | else if(log_level & NVRAM_WARNING_DUMP)\ |
| 881 | {\ |
| 882 | str_title_size = sprintf(nvram_trace_dump_temp_buffer,"Time:[0x%08X]Module:[%d][NVM_Warning]",(kal_uint32)ust_get_current_time(),stack_get_active_module_id());\ |
| 883 | }\ |
| 884 | else if(log_level & NVRAM_INFO_DUMP)\ |
| 885 | {\ |
| 886 | str_title_size = sprintf(nvram_trace_dump_temp_buffer,"Time:[0x%08X]Module:[%d][NVM_Info]",(kal_uint32)ust_get_current_time(),stack_get_active_module_id());\ |
| 887 | }\ |
| 888 | str_size = snprintf((nvram_trace_dump_temp_buffer+str_title_size),(NVRAM_DUMP_TRACE_TEMP_BUFFER_SIZE-str_title_size),info,__VA_ARGS__);\ |
| 889 | str_size = str_size+str_title_size;\ |
| 890 | if(nvram_trace_file_hdl == 0)\ |
| 891 | {\ |
| 892 | nvram_ee_info->nvram_trace_fs_access_val = ++trace_count;\ |
| 893 | nvram_trace_file_hdl = FS_Open((const WCHAR *)nvram_trace_filename, FS_CREATE | FS_READ_WRITE | FS_OPEN_NO_DIR);\ |
| 894 | nvram_ee_info->nvram_trace_fs_access_val = ++trace_count;\ |
| 895 | }\ |
| 896 | if((nvram_ee_info->nvram_trace_setting & 0x2))\ |
| 897 | { \ |
| 898 | nvram_ee_info->nvram_trace_fs_access_val = ++trace_count;\ |
| 899 | FS_Seek(nvram_trace_file_hdl, 0, FS_FILE_END);\ |
| 900 | nvram_ee_info->nvram_trace_fs_access_val = ++trace_count;\ |
| 901 | FS_Write(nvram_trace_file_hdl, nvram_trace_dump_temp_buffer, str_size, &trace_len);\ |
| 902 | nvram_ee_info->nvram_trace_fs_access_val = ++trace_count;\ |
| 903 | if(exception_flag)\ |
| 904 | {\ |
| 905 | FS_Close(nvram_trace_file_hdl);\ |
| 906 | nvram_trace_file_hdl = 0;\ |
| 907 | }\ |
| 908 | }\ |
| 909 | else \ |
| 910 | {\ |
| 911 | if(((nvram_trace_dump_buffer_offset+str_size) >= NVRAM_DUMP_TRACE_BUFFER_SIZE) || exception_flag)\ |
| 912 | {\ |
| 913 | nvram_ee_info->nvram_trace_fs_access_val = ++trace_count;\ |
| 914 | FS_Seek(nvram_trace_file_hdl, 0, FS_FILE_END);\ |
| 915 | nvram_ee_info->nvram_trace_fs_access_val = ++trace_count;\ |
| 916 | FS_Write(nvram_trace_file_hdl, nvram_trace_dump_buffer, nvram_trace_dump_buffer_offset, &trace_len);\ |
| 917 | nvram_ee_info->nvram_trace_fs_access_val = ++trace_count;\ |
| 918 | if(exception_flag)\ |
| 919 | {\ |
| 920 | FS_Close(nvram_trace_file_hdl);\ |
| 921 | nvram_trace_file_hdl = 0;\ |
| 922 | }\ |
| 923 | nvram_ee_info->nvram_trace_fs_access_val = ++trace_count;\ |
| 924 | kal_mem_set(nvram_trace_dump_buffer,0,NVRAM_DUMP_TRACE_BUFFER_SIZE);\ |
| 925 | nvram_trace_dump_buffer_offset = str_size;\ |
| 926 | kal_mem_cpy(nvram_trace_dump_buffer,nvram_trace_dump_temp_buffer,str_size);\ |
| 927 | }\ |
| 928 | else \ |
| 929 | {\ |
| 930 | kal_mem_cpy(nvram_trace_dump_buffer+nvram_trace_dump_buffer_offset,nvram_trace_dump_temp_buffer,str_size);\ |
| 931 | nvram_trace_dump_buffer_offset += str_size;\ |
| 932 | }\ |
| 933 | }\ |
| 934 | if(!exception_flag)\ |
| 935 | {\ |
| 936 | nvram_util_give_mutex(g_nvram_dump_trace_mutex);\ |
| 937 | }\ |
| 938 | }\ |
| 939 | }\ |
| 940 | }while(0) |
| 941 | |
| 942 | #define NVRAM_FS_START(FS_OP)\ |
| 943 | do {\ |
| 944 | kal_bool exception_flag = INT_QueryExceptionStatus();\ |
| 945 | if(nvram_ee_info != NULL){\ |
| 946 | if(!exception_flag)\ |
| 947 | {\ |
| 948 | nvram_ee_info->nvram_access_info.access_type = FS_OP;\ |
| 949 | nvram_ee_info->nvram_access_info.access_count++;\ |
| 950 | nvram_ee_info->nvram_access_info.access_result = 0xFFFFFFFF;\ |
| 951 | nvram_ee_info->nvram_access_info.start_time = ust_get_current_time();\ |
| 952 | nvram_ee_info->nvram_access_info.end_time = 0;\ |
| 953 | nvram_ee_info->nvram_access_info.consum_time = 0;\ |
| 954 | }\ |
| 955 | else \ |
| 956 | {\ |
| 957 | nvram_ee_info->nvram_access_info_for_exception.access_type = FS_OP;\ |
| 958 | nvram_ee_info->nvram_access_info_for_exception.access_result = 0xFFFFFFFF;\ |
| 959 | nvram_ee_info->nvram_access_info_for_exception.start_time = ust_get_current_time();\ |
| 960 | nvram_ee_info->nvram_access_info_for_exception.end_time = 0;\ |
| 961 | }\ |
| 962 | }\ |
| 963 | }while(0) |
| 964 | |
| 965 | #define NVRAM_FS_START_EX(FS_OP,FS_FILE_NAME)\ |
| 966 | do {\ |
| 967 | kal_bool exception_flag = INT_QueryExceptionStatus();\ |
| 968 | if(nvram_ee_info != NULL){\ |
| 969 | if(!exception_flag)\ |
| 970 | {\ |
| 971 | nvram_ee_info->nvram_access_info.access_type = FS_OP;\ |
| 972 | kal_mem_set(nvram_ee_info->nvram_access_info.filename,0,NVRAM_MAX_PATH_LEN);\ |
| 973 | kal_dchar2char((WCHAR *)(FS_FILE_NAME), nvram_ee_info->nvram_access_info.filename);\ |
| 974 | NVRAM_DEBUG_DUMP(NVRAM_CRITICAL_DUMP,#FS_OP":%s\r\n",nvram_ee_info->nvram_access_info.filename);\ |
| 975 | nvram_ee_info->nvram_access_info.access_count++;\ |
| 976 | nvram_ee_info->nvram_access_info.access_result = 0xFFFFFFFF;\ |
| 977 | nvram_ee_info->nvram_access_info.start_time = ust_get_current_time();\ |
| 978 | nvram_ee_info->nvram_access_info.end_time = 0;\ |
| 979 | nvram_ee_info->nvram_access_info.consum_time = 0;\ |
| 980 | }\ |
| 981 | else \ |
| 982 | {\ |
| 983 | nvram_ee_info->nvram_access_info_for_exception.access_type = FS_OP;\ |
| 984 | kal_mem_set(nvram_ee_info->nvram_access_info_for_exception.filename,0,NVRAM_MAX_PATH_LEN);\ |
| 985 | kal_dchar2char((WCHAR *)(FS_FILE_NAME), nvram_ee_info->nvram_access_info_for_exception.filename);\ |
| 986 | nvram_ee_info->nvram_access_info_for_exception.access_result = 0xFFFFFFFF;\ |
| 987 | nvram_ee_info->nvram_access_info_for_exception.start_time = ust_get_current_time();\ |
| 988 | nvram_ee_info->nvram_access_info_for_exception.end_time = 0;\ |
| 989 | }\ |
| 990 | }\ |
| 991 | }while(0) |
| 992 | |
| 993 | #define NVRAM_FS_END(FS_OP,Ret_Val) \ |
| 994 | do {\ |
| 995 | kal_bool exception_flag = INT_QueryExceptionStatus();\ |
| 996 | if(Ret_Val < FS_NO_ERROR)\ |
| 997 | {\ |
| 998 | kal_prompt_trace(MOD_NVRAM,#FS_OP" Return %d\r\n",Ret_Val);\ |
| 999 | }\ |
| 1000 | if(nvram_ee_info != NULL){\ |
| 1001 | if(!exception_flag)\ |
| 1002 | {\ |
| 1003 | nvram_ee_info->nvram_access_info.end_time = ust_get_current_time();\ |
| 1004 | nvram_ee_info->nvram_access_info.access_result = Ret_Val;\ |
| 1005 | nvram_ee_info->nvram_access_info.consum_time = nvram_ee_info->nvram_access_info.end_time - nvram_ee_info->nvram_access_info.start_time;\ |
| 1006 | if(nvram_ee_info->nvram_access_info.consum_time > nvram_ee_info->nvram_access_info.max_time)\ |
| 1007 | {\ |
| 1008 | nvram_ee_info->nvram_access_info.max_time = nvram_ee_info->nvram_access_info.consum_time;\ |
| 1009 | }\ |
| 1010 | if(nvram_ee_info->nvram_access_info.consum_time < nvram_ee_info->nvram_access_info.min_time)\ |
| 1011 | {\ |
| 1012 | nvram_ee_info->nvram_access_info.min_time = nvram_ee_info->nvram_access_info.consum_time;\ |
| 1013 | }\ |
| 1014 | nvram_ee_info->nvram_access_info.total_time += nvram_ee_info->nvram_access_info.consum_time;\ |
| 1015 | }\ |
| 1016 | else \ |
| 1017 | {\ |
| 1018 | nvram_ee_info->nvram_access_info_for_exception.end_time = ust_get_current_time();\ |
| 1019 | nvram_ee_info->nvram_access_info_for_exception.access_result = Ret_Val;\ |
| 1020 | }\ |
| 1021 | if(Ret_Val < FS_NO_ERROR)\ |
| 1022 | {\ |
| 1023 | NVRAM_DEBUG_DUMP(NVRAM_WARNING_DUMP,#FS_OP" Return %d\r\n",Ret_Val);\ |
| 1024 | }\ |
| 1025 | }\ |
| 1026 | }while(0) |
| 1027 | |
| 1028 | |
| 1029 | |
| 1030 | /***************************************************************************** |
| 1031 | * Global Function |
| 1032 | ****************************************************************************/ |
| 1033 | |
| 1034 | extern const kal_uint8 NVRAM_EF_ZERO_DEFAULT[]; |
| 1035 | extern const kal_uint8 NVRAM_EF_FF_DEFAULT[]; |
| 1036 | extern const kal_uint8 NVRAM_EF_SPECIAL_DEFAULT[]; |
| 1037 | |
| 1038 | #ifdef __cplusplus |
| 1039 | } |
| 1040 | #endif |
| 1041 | |
| 1042 | #endif /* NVRAM_DEFS_H */ |
| 1043 | |