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_util.h |
| 40 | * |
| 41 | * Project: |
| 42 | * -------- |
| 43 | * MAUI |
| 44 | * |
| 45 | * Description: |
| 46 | * ------------ |
| 47 | * Utility header file for NVRAM |
| 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 | * |
| 68 | * removed! |
| 69 | * removed! |
| 70 | * removed! |
| 71 | * removed! |
| 72 | * |
| 73 | * removed! |
| 74 | * removed! |
| 75 | * removed! |
| 76 | * removed! |
| 77 | * removed! |
| 78 | * removed! |
| 79 | * removed! |
| 80 | * removed! |
| 81 | * |
| 82 | * removed! |
| 83 | * removed! |
| 84 | * removed! |
| 85 | * |
| 86 | * removed! |
| 87 | * removed! |
| 88 | * |
| 89 | * removed! |
| 90 | * removed! |
| 91 | * |
| 92 | * removed! |
| 93 | * removed! |
| 94 | * removed! |
| 95 | * removed! |
| 96 | * removed! |
| 97 | * |
| 98 | * removed! |
| 99 | * removed! |
| 100 | * removed! |
| 101 | * removed! |
| 102 | * removed! |
| 103 | * removed! |
| 104 | * |
| 105 | * removed! |
| 106 | * removed! |
| 107 | * removed! |
| 108 | * removed! |
| 109 | * removed! |
| 110 | * removed! |
| 111 | * removed! |
| 112 | * removed! |
| 113 | * removed! |
| 114 | * removed! |
| 115 | * removed! |
| 116 | * removed! |
| 117 | * removed! |
| 118 | * removed! |
| 119 | * |
| 120 | * removed! |
| 121 | * removed! |
| 122 | * removed! |
| 123 | * |
| 124 | * removed! |
| 125 | * removed! |
| 126 | * removed! |
| 127 | * |
| 128 | * removed! |
| 129 | * removed! |
| 130 | * removed! |
| 131 | * |
| 132 | * removed! |
| 133 | * removed! |
| 134 | * removed! |
| 135 | * |
| 136 | * removed! |
| 137 | * removed! |
| 138 | * removed! |
| 139 | * |
| 140 | * removed! |
| 141 | * removed! |
| 142 | * removed! |
| 143 | * |
| 144 | * removed! |
| 145 | * removed! |
| 146 | * removed! |
| 147 | * |
| 148 | * removed! |
| 149 | * removed! |
| 150 | * removed! |
| 151 | * |
| 152 | * removed! |
| 153 | * removed! |
| 154 | * removed! |
| 155 | * |
| 156 | * removed! |
| 157 | * removed! |
| 158 | * removed! |
| 159 | * |
| 160 | * removed! |
| 161 | * removed! |
| 162 | * removed! |
| 163 | * |
| 164 | * removed! |
| 165 | * removed! |
| 166 | * removed! |
| 167 | * |
| 168 | * removed! |
| 169 | * removed! |
| 170 | * removed! |
| 171 | * |
| 172 | * removed! |
| 173 | * removed! |
| 174 | * removed! |
| 175 | * |
| 176 | * removed! |
| 177 | * removed! |
| 178 | * removed! |
| 179 | * |
| 180 | * removed! |
| 181 | * removed! |
| 182 | * removed! |
| 183 | * |
| 184 | * removed! |
| 185 | * removed! |
| 186 | * removed! |
| 187 | * |
| 188 | * removed! |
| 189 | * removed! |
| 190 | * removed! |
| 191 | * |
| 192 | * removed! |
| 193 | * removed! |
| 194 | * removed! |
| 195 | * |
| 196 | * removed! |
| 197 | * removed! |
| 198 | * removed! |
| 199 | * |
| 200 | *------------------------------------------------------------------------------ |
| 201 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 202 | *============================================================================== |
| 203 | *******************************************************************************/ |
| 204 | |
| 205 | #ifndef NVRAM_UTIL_H |
| 206 | #define NVRAM_UTIL_H |
| 207 | /***************************************************************************** |
| 208 | * Include |
| 209 | ****************************************************************************/ |
| 210 | #include "kal_general_types.h" |
| 211 | #include "kal_public_api.h" |
| 212 | #include "kal_trace.h" |
| 213 | #include "nvram_defs.h" |
| 214 | #include "nvram_internal.h" |
| 215 | #include "nvram_interface.h" |
| 216 | #include "nvram_drval_fat.h" |
| 217 | #include "nvram_chksum_algorithm.h" |
| 218 | |
| 219 | #include "fs_type.h" |
| 220 | /***************************************************************************** |
| 221 | * Define |
| 222 | ****************************************************************************/ |
| 223 | /***************************************************************************** |
| 224 | * Typedef |
| 225 | ****************************************************************************/ |
| 226 | typedef enum |
| 227 | { |
| 228 | NVRAM_INIT_READ_VERSION_FAIL = 1, |
| 229 | NVRAM_INIT_CLEAN_BOOT, |
| 230 | NVRAM_INIT_VERSION_CHANGE, |
| 231 | NVRAM_INIT_NORMAL_BOOT, |
| 232 | } nvram_init_flow_trace; |
| 233 | |
| 234 | typedef struct |
| 235 | { |
| 236 | nvram_lid_chksum_algo_info algo_info; |
| 237 | nvram_drv_read_type_enum read_chksum_type; |
| 238 | }nvram_lid_chksum_info; |
| 239 | |
| 240 | |
| 241 | /***************************************************************************** |
| 242 | * Global Function |
| 243 | ****************************************************************************/ |
| 244 | extern void nvram_util_blocking_assert(char* exp, char* f, kal_uint32 line, kal_uint32 e1, kal_uint32 e2, kal_uint32 e3); |
| 245 | |
| 246 | #if 0 |
| 247 | #if 0 |
| 248 | /* under construction !*/ |
| 249 | #else |
| 250 | /* under construction !*/ |
| 251 | #endif |
| 252 | #endif |
| 253 | |
| 254 | #ifdef NVRAM_DEBUG |
| 255 | extern void nvram_trace_to_file(kal_uint32 line, kal_uint32 e1, kal_uint32 e2, kal_uint32 e3, kal_uint32 e4, kal_uint32 e5); |
| 256 | #else |
| 257 | #define nvram_trace_to_file(line, e1, e2, e3, e4, e5) |
| 258 | #endif |
| 259 | |
| 260 | #ifdef __NVRAM_INIT_TIME_UT__ |
| 261 | #define NVRAM_INIT_TIME_UT_STAMP(num) \ |
| 262 | do{ \ |
| 263 | extern kal_uint16 init_time_tick[10]; \ |
| 264 | init_time_tick[num] = kal_get_systicks(); \ |
| 265 | }while(0) |
| 266 | |
| 267 | #define NVRAM_INIT_TIME_UT_FLOW(id) \ |
| 268 | do{ \ |
| 269 | extern nvram_init_flow_trace init_trace; \ |
| 270 | init_trace = id; \ |
| 271 | }while(0) |
| 272 | #define NVRAM_INIT_TIME_UT_SAVE() \ |
| 273 | do{ \ |
| 274 | extern void nvram_init_time_ut_save(void); \ |
| 275 | nvram_init_time_ut_save(); \ |
| 276 | }while(0) |
| 277 | #else |
| 278 | #define NVRAM_INIT_TIME_UT_STAMP(num) |
| 279 | #define NVRAM_INIT_TIME_UT_FLOW(id) |
| 280 | #define NVRAM_INIT_TIME_UT_SAVE() |
| 281 | #endif |
| 282 | |
| 283 | extern void nvram_util_make_lid_filename(nvram_ltable_entry_struct *ldi, NVRAM_FILE_NAME nvramname, kal_bool first_copy); |
| 284 | extern kal_uint16 nvram_util_md5_checksum_convert(const kal_uint8 *checksum_buf_8B, kal_uint8 *checksum_buf_2B, kal_bool bypass_CDEF); |
| 285 | extern kal_uint16 nvram_util_caculate_checksum(nvram_ltable_entry_struct *ldi, const kal_uint8 *buf, kal_uint32 size, kal_uint8* checksum_buf); |
| 286 | extern kal_uint16 nvram_util_cal_checksum_simple(const kal_uint8 *buf, kal_uint32 size); |
| 287 | extern void nvram_util_make_filename(NVRAM_FILE_NAME buf, kal_char* prefix, kal_char M, kal_char* verno); |
| 288 | |
| 289 | //extern void nvram_trace(trace_class_enum trc_class, kal_uint32 msg_index, const char* format, ...); |
| 290 | /* #define nvram_trace(...) kal_brief_trace(__VA_ARGS__)*/ |
| 291 | |
| 292 | #if 0 |
| 293 | /* under construction !*/ |
| 294 | /* under construction !*/ |
| 295 | /* under construction !*/ |
| 296 | /* under construction !*/ |
| 297 | /* under construction !*/ |
| 298 | /* under construction !*/ |
| 299 | /* under construction !*/ |
| 300 | /* under construction !*/ |
| 301 | /* under construction !*/ |
| 302 | /* under construction !*/ |
| 303 | /* under construction !*/ |
| 304 | /* under construction !*/ |
| 305 | /* under construction !*/ |
| 306 | /* under construction !*/ |
| 307 | #endif |
| 308 | |
| 309 | #if 0 |
| 310 | /* under construction !*/ |
| 311 | #endif |
| 312 | extern kal_bool nvram_util_is_usbboot(void); |
| 313 | extern kal_bool nvram_util_poweron(void); |
| 314 | extern void nvram_util_poweroff(void); |
| 315 | |
| 316 | extern nvram_lid_enum nvram_util_get_IMEISV_LID(void); |
| 317 | |
| 318 | extern kal_uint32 nvram_util_get_IMEISV_size(void); |
| 319 | |
| 320 | extern kal_uint32 nvram_util_get_IMEI_size(void); |
| 321 | |
| 322 | extern void nvram_util_take_mutex(kal_mutexid ext_mutex_id_ptr); |
| 323 | extern void nvram_util_give_mutex(kal_mutexid ext_mutex_id_ptr); |
| 324 | void * nvram_memset(void* dest, kal_int32 value, kal_uint32 size); |
| 325 | |
| 326 | extern kal_bool nvram_write_data_header(nvram_ltable_entry_struct *ldi, nvram_header_section_enum section); |
| 327 | extern kal_bool nvram_read_data_header(const kal_wchar *filename, nvram_header_section_enum section, void* buffer, kal_uint32 buffer_size); |
| 328 | extern kal_bool nvram_read_ota_header(FS_HANDLE hFile, void* buffer, kal_uint32 buffer_size); |
| 329 | extern kal_bool nvram_prepare_data_header(nvram_ltable_entry_struct *ldi,kal_uint8 *ldi_hd_buffer); |
| 330 | extern kal_uint32 nvram_prepare_appendix_header(nvram_appendix_type_enum type, nvram_ldi_appendix_header *ldi_append_header, nvram_ltable_entry_struct *ldi, kal_uint32 data_offset); |
| 331 | extern kal_uint32 nvram_appendix_header_offset(nvram_ltable_entry_struct *ldi); |
| 332 | |
| 333 | extern kal_bool nvram_ota_backup_file(const kal_wchar *s_filename, nvram_ldi_ota_header *ldi_ota_header); |
| 334 | extern kal_bool nvram_ota_restore_file(nvram_ltable_entry_struct *ldi); |
| 335 | extern kal_uint32 nvram_ota_buffer_size(); |
| 336 | |
| 337 | extern kal_bool nvram_ota_search_backup_file(const kal_char *s_filename, NVRAM_FULL_PATH *r_filename); |
| 338 | |
| 339 | #ifdef __NVRAM_LID_CACHE__ |
| 340 | extern kal_bool nvram_cache_read_ota_header(const kal_wchar *filename, FS_HANDLE hFile, void* buffer, kal_uint32 buffer_size); |
| 341 | #endif |
| 342 | |
| 343 | #if defined(__NVRAM_CREATE_FILE_ON_WRITE__) |
| 344 | extern kal_mutexid nvram_bitmap_mutex; |
| 345 | extern kal_uint8 *nvram_bitmap_ptr; |
| 346 | |
| 347 | extern kal_bool nvram_util_init_info_file(); |
| 348 | extern kal_bool nvram_util_has_file_created(nvram_ltable_entry_struct *ldi); |
| 349 | extern void nvram_util_pre_write_lid(nvram_ltable_entry_struct *ldi); |
| 350 | extern void nvram_util_post_write_lid(nvram_ltable_entry_struct *ldi); |
| 351 | extern void nvram_util_pre_reset_gen_default_lid(nvram_ltable_entry_struct *ldi); |
| 352 | extern void nvram_util_post_reset_gen_default_lid(nvram_ltable_entry_struct *ldi); |
| 353 | extern void nvram_util_mark_file_uncreated(nvram_ltable_entry_struct *ldi); |
| 354 | extern kal_bool nvram_util_always_gen_default(nvram_ltable_entry_struct *ldi); |
| 355 | extern void nvram_utile_reset_lid_bitmap(); |
| 356 | extern kal_bool nvram_write_bitmap_into_file(); |
| 357 | extern kal_bool nvram_util_lid_bitmap_check(kal_uint8 *bitmap, kal_uint32 lid); |
| 358 | extern void nvram_util_lid_bimtap_set(kal_uint8 *bitmap, kal_uint32 lid); |
| 359 | extern kal_bool nvram_delete_bitmap_file(); |
| 360 | |
| 361 | #endif |
| 362 | #ifdef __NVRAM_INIT_LID_BUFFER__ |
| 363 | extern void nvram_init_lid_buffer_prepare(void); |
| 364 | extern nvram_errno_enum nvram_init_lid_buffer_read(nvram_lid_enum LID, kal_uint32 rec_index, kal_uint16 rec_amount, kal_uint8 *buffer, kal_uint32 buffer_size); |
| 365 | extern nvram_errno_enum nvram_init_lid_buffer_write(nvram_lid_enum LID, kal_uint32 rec_index, kal_uint16 rec_amount, kal_uint8 *buffer, kal_uint32 buffer_size); |
| 366 | extern void nvram_init_lid_buffer_writeback(void); |
| 367 | #endif |
| 368 | |
| 369 | #if defined(__NVRAM_STRUCTURE_CHANGE_RESET__) || defined(__NVRAM_DEFVAL_CHANGE_RESET__) |
| 370 | extern kal_int32 nvram_get_structure_chksum_index(nvram_lid_enum LID); |
| 371 | extern kal_int32 nvram_get_defval_chksum_index(nvram_lid_enum LID); |
| 372 | #endif |
| 373 | |
| 374 | extern void nvram_get_trace_configuration(); |
| 375 | |
| 376 | extern nvram_errno_enum nvram_get_lid_chksum_algo_info(nvram_ltable_entry_struct *ldi, nvram_lid_chksum_info * lid_chksum_info, kal_bool chksum_only, kal_bool read_2B); |
| 377 | |
| 378 | #endif /* NVRAM_UTIL_H */ |
| 379 | |