blob: a8e59f389a23de6a45f6f129b377bb68d12b9f0e [file] [log] [blame]
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*
* Include
*/
#include <string.h>
#include "kal_general_types.h"
#include "kal_internal_api.h"
#include "kal_public_defs.h"
#include "kal_public_api.h"
#include "kal_trace.h"
#include "fs_type.h" /* FS_HANDLE */
#include "fs_func.h" /* FS_Delete */
#include "fs_errcode.h" /* FS_NO_ERROR */
#include "ex_item.h" /* EX_LOG_T */
#include "tst_msgid.h"
#include "sbp_public_utility.h"
#if defined(__NVRAM_ACCESS_TIMEOUT_ASSERT__)
#include "dcl_gpt.h"
#endif
#include "nvram_cache_interface.h"
#include "nvram_defs.h"
/*******************************************************
* External Function
*******************************************************/
extern kal_uint32 pre_read_white_list[];
extern kal_uint16 preread_white_list_amount;
/*******************************************************
* Define
*******************************************************/
/*******************************************************
* Typedef
*******************************************************/
/*******************************************************
* Global Variable
*******************************************************/
extern nvram_ee_info_type* nvram_ee_info;
extern kal_char nvram_trace_dump_temp_buffer[];
extern kal_char nvram_trace_dump_buffer[];
extern kal_mutexid g_nvram_dump_trace_mutex;
extern kal_wchar nvram_trace_filename[];
extern FS_HANDLE nvram_trace_file_hdl;
extern kal_uint32 nvram_trace_dump_buffer_offset;
/*******************************************************
* Local Function
*******************************************************/
/*******************************************************
* Local Variable
*******************************************************/
nvram_errno_enum nvram_pre_read_white_list_lid(void)
{
#ifdef __NVRAM_LID_PREREAD__
kal_uint16 i,j;
nvram_ltable_entry_struct *ldi = NULL;
kal_uint8 *preread_temp_buffer = NULL;
kal_uint32 preread_temp_buffer_size = 0;
NVRAM_FILE_NAME nvramname;
kal_wchar filename[NVRAM_MAX_PATH_LEN];
nvram_folder_enum nvram_folder;
nvram_ldi_header nv_header;
kal_int32 rec_in_block = 0;
for(i = 0; i < preread_white_list_amount; i++)
{
if(!nvram_util_get_data_item(&ldi, pre_read_white_list[i]))
{
//NVRAM_EXT_ASSERT(pre_read_white_list[i], preread_white_list_amount, NVRAM_LOC_INIT_BUFFER_OVERFLOW, MAX_NVRAM_RECORD_SIZE);
continue;
}
if (!nvram_util_has_file_created(ldi))
{
continue;
}
preread_temp_buffer_size = ldi->size * ldi->total_records;
if (preread_temp_buffer_size > MAX_NVRAM_RECORD_SIZE)
{
preread_temp_buffer_size = MAX_NVRAM_RECORD_SIZE;
}
preread_temp_buffer = (kal_uint8 *)get_ctrl_buffer(preread_temp_buffer_size);
if(preread_temp_buffer == NULL)
{
kal_prompt_trace(MOD_NVRAM, "[NVUT] %s()ldi->LID:%x LID->attr=(%x) preread_temp_buffer is NULL\n\r", __FUNCTION__, ldi->LID, ldi->attr);
NVRAM_DEBUG_DUMP(NVRAM_CRITICAL_DUMP,"[OTA]%s->LINE 0x%04x :lid=0x%x preread_temp_buffer is NULL\r\n", __FUNCTION__, __LINE__, ldi->LID);
continue;
}
nvram_util_make_lid_filename(ldi, nvramname, KAL_TRUE);
nvram_folder = nvram_query_folder_index(ldi->category);
nvram_query_file_name(nvram_folder, nvramname, filename);
nvram_read_data_header(filename, LDI_HEADER_ALL_SECTION, &nv_header, NVRAM_LDI_HEADER_SIZE);
kal_prompt_trace(MOD_NVRAM, "[NVUT] %s()ldi->LID:%x LID->attr=(%x) default_attr\n\r", __FUNCTION__, ldi->LID, ldi->attr);
NVRAM_DEBUG_DUMP(NVRAM_CRITICAL_DUMP,"[OTA]%s->LINE 0x%04x :lid=0x%x \r\n", __FUNCTION__, __LINE__, ldi->LID);
rec_in_block = preread_temp_buffer_size / ldi->size;
for (j = 1 ; j <= ldi->total_records; )
{
kal_mem_set(preread_temp_buffer, 0x00, preread_temp_buffer_size);
if(NVRAM_ERRNO_SUCCESS != nvram_read_data_item(ldi, j, rec_in_block, preread_temp_buffer, preread_temp_buffer_size))
{
kal_prompt_trace(MOD_NVRAM, "[NVUT] %s()ldi->LID:%x LID->attr=(%x) nvram_read_data_item\n\r", __FUNCTION__, ldi->LID, ldi->attr);
NVRAM_DEBUG_DUMP(NVRAM_CRITICAL_DUMP,"[OTA]%s->LINE 0x%04x :lid=0x%x nvram_read_data_item failed\r\n", __FUNCTION__, __LINE__, ldi->LID);
break;
//free_ctrl_buffer(preread_temp_buffer);
//preread_temp_buffer = NULL;
//NVRAM_EXT_ASSERT(pre_read_white_list[i], ldi->size, NVRAM_LOC_INIT_BUFFER_OVERFLOW, ldi->total_records);
}
j += rec_in_block;
rec_in_block = rec_in_block < (ldi->total_records - j + 1)? rec_in_block : (ldi->total_records - j + 1);
}
free_ctrl_buffer(preread_temp_buffer);
preread_temp_buffer = NULL;
}
#endif
return NVRAM_ERRNO_SUCCESS;
}