📄 nvimw.c
字号:
#ifndef _SAMSUNG_BREW_COMMON //jwlee 2004.11.04 for test to write RF_CAL_DATE
/* rf_cal_date can only be written once */
if (status == NV_DONE_S) {
if (local_rf_cal_date != 0) {
/* The file is now considered read-only */
return NV_READONLY_S;
}
else {
/* The PST may try to write a value of 0 one or more times,
simply return success if the current rf_cal_date value is 0 */
if (cmd_ptr->data_ptr->rf_cal_date == 0) {
return NV_DONE_S;
}
}
}
#endif // !_SAMSUNG_BREW_COMMON
/* Turn off permanent file attribute in order to write */
if ((status = nvim_update_fs_item_file_attrs(efs_params,
FS_FA_UNRESTRICTED)) != NV_DONE_S)
{
return status;
}
status = nvimw_write_fixed(cmd_ptr->item,
cmd_ptr->data_ptr,
nv_op_get_size(cmd_ptr->item));
/* Turn back on permanent file attribute */
if (status == NV_DONE_S) {
status = nvim_update_fs_item_file_attrs(efs_params,
FS_FA_SYS_PERMANENT);
}
return status;
}
#endif
#ifdef FEATURE_RFCAL_VERSION
/*===========================================================================
FUNCTION NVIMW_WRITE_RF_CAL_DAT_FILE
DESCRIPTION
This function processed a write command to the NV_RF_CAL_DAT_FILE_I item.
DEPENDENCIES
None.
RETURN VALUE
NV_DONE_S if it worked error status code if it failed.
SIDE EFFECTS
None
===========================================================================*/
LOCAL nv_stat_enum_type nvimw_write_rf_cal_dat_file
(
nv_cmd_type *cmd_ptr /* Command block */
)
{
int i;
nv_stat_enum_type status;
byte local_rf_cal_dat_file[NV_QC_SERIAL_NUM_LEN]; /* tmp buffer for rf_cal_dat_file */
boolean all_zero_write_value;
boolean empty_value = TRUE;
nvim_efs_params *efs_params = nv_op_get_fparams(cmd_ptr->item);
/* Read the current rf_cal_dat_file. value */
status = nvimr_read_fixed(cmd_ptr->item,
local_rf_cal_dat_file, /* data ptr */
nv_op_get_size(cmd_ptr->item));
if ((status != NV_DONE_S) && (status != NV_NOTACTIVE_S))
{
return status;
}
/* rf_cal_dat_file can only be written once */
if (status == NV_DONE_S) {
for (i=0; i<NV_QC_SERIAL_NUM_LEN; i++) {
if (local_rf_cal_dat_file[i] != 0) {
empty_value = FALSE;
}
}
if (!empty_value)
{
/* The file is now considered read-only */
return NV_READONLY_S;
} else {
/* The PST may try to write a value of 0 one or more times,
simply return success if the current rf_cal_dat_file value is 0 */
all_zero_write_value = TRUE;
for (i=0; i<NV_QC_SERIAL_NUM_LEN; i++) {
if (cmd_ptr->data_ptr->rf_cal_dat_file[i] != 0) {
all_zero_write_value = FALSE;
}
}
if (all_zero_write_value)
{
return NV_DONE_S;
}
}
}
/* Turn off permanent file attribute in order to write */
if ((status = nvim_update_fs_item_file_attrs(efs_params,
FS_FA_UNRESTRICTED)) != NV_DONE_S)
{
return status;
}
status = nvimw_write_fixed(cmd_ptr->item,
cmd_ptr->data_ptr,
nv_op_get_size(cmd_ptr->item));
/* Turn back on permanent file attribute */
if (status == NV_DONE_S) {
status = nvim_update_fs_item_file_attrs(efs_params,
FS_FA_SYS_PERMANENT);
}
return status;
}
#endif
/*===========================================================================
FUNCTION NVIMW_WRITE_IMEI
DESCRIPTION
This function processed a write command to the NV_UE_IMEI_I item.
DEPENDENCIES
None.
RETURN VALUE
NV_DONE_S if it worked error status code if it failed.
SIDE EFFECTS
None
===========================================================================*/
#ifdef _SAMSUNG_MP_CUSTOM_RESET //sec_ui2_kkw_20051031_1
extern ResetMode_Type ResetMode;
extern int Master_Reset;
#endif
LOCAL nv_stat_enum_type nvimw_write_imei
(
nv_cmd_type *cmd_ptr /* Command block */
)
{
int i;
nv_stat_enum_type status;
nv_ue_imei_type local_ue_imei; /* tmp buffer for ue_imei */
boolean all_zero_write_value;
boolean ue_imei_empty = TRUE;
nvim_efs_params *efs_params = nv_op_get_fparams(cmd_ptr->item);
/* Read the current IMEI value */
status = nvimr_read_fixed(cmd_ptr->item,
&local_ue_imei, /* data ptr */
nv_op_get_size(cmd_ptr->item));
if ((status != NV_DONE_S) && (status != NV_NOTACTIVE_S))
{
return status;
}
#ifdef _SAMSUNG_MP_CUSTOM_RESET
if(Master_Reset)
return NV_READONLY_S;
if(ResetMode>0 && ResetMode<MAX_MODE)
{
if(keystr == FALSE)return NV_READONLY_S; //sec_system_selee_051106 : keystring reset 矫 檬扁拳
}
#endif
/* IMEI can only be written once */
if (status == NV_DONE_S) {
for (i=0; i<NV_UE_IMEI_SIZE; i++) {
if (local_ue_imei.ue_imei[i] != 0) {
ue_imei_empty = FALSE;
}
}
#ifdef _SAMSUNG_MP_IMEI_WRITE // sec_ui2_kkw_20051005_1
//jwlee 2004.11.25 for writing IMEI only in Test Mode
if (ftm_mode == FTM_MODE || cm_mp_nv == TRUE)
ue_imei_empty = TRUE;
#endif
if (!ue_imei_empty)
{
/* The file is now considered read-only */
return NV_READONLY_S;
} else {
/* The PST may try to write a value of 0 one or more times,
simply return success if the current IMEI value is 0 */
all_zero_write_value = TRUE;
for (i=0; i<NV_UE_IMEI_SIZE; i++) {
if (cmd_ptr->data_ptr->ue_imei.ue_imei[i] != 0) {
all_zero_write_value = FALSE;
}
}
if (all_zero_write_value)
{
return NV_DONE_S;
}
}
}
/* Turn off permanent file attribute in order to write */
if ((status = nvim_update_fs_item_file_attrs(efs_params,
FS_FA_UNRESTRICTED)) != NV_DONE_S)
{
return status;
}
status = nvimw_write_fixed(cmd_ptr->item,
cmd_ptr->data_ptr,
nv_op_get_size(cmd_ptr->item));
/* Turn back on permanent file attribute */
if (status == NV_DONE_S) {
status = nvim_update_fs_item_file_attrs(efs_params,
FS_FA_SYS_PERMANENT);
}
return status;
}
/*===========================================================================
FUNCTION NVIMW_WRITE_MEID
DESCRIPTION
This function processed a write command to the NV_MEID_I item.
DEPENDENCIES
None.
RETURN VALUE
NV_DONE_S if it worked error status code if it failed.
SIDE EFFECTS
None
===========================================================================*/
LOCAL nv_stat_enum_type nvimw_write_meid
(
nv_cmd_type *cmd_ptr /* Command block */
)
{
nv_stat_enum_type status;
qword local_meid; /* temporary buffer for meid */
local_meid[0] = 0;
local_meid[1] = 0;
/* Read the current MEID value */
status = nvimr_read_fixed(cmd_ptr->item,
local_meid, /* data ptr */
nv_op_get_size(cmd_ptr->item));
if ((status != NV_DONE_S)&&(status != NV_NOTACTIVE_S))
{
MSG_HIGH (" MEID Read was successful. ",0,0,0);
return status;
}
if (!(((local_meid[0] == 0) && (local_meid[1] == 0)) ||
((local_meid[0] == (dword)0xFFFFFFFFUL)
&& (local_meid[1] == (dword)0x00FFFFFFUL))))
{
/* The file is now considered read-only */
MSG_HIGH (" MEID is neither all 0s nor all Fs. ",0,0,0);
return NV_READONLY_S;
}
/* Turn off permanent file attribute in order to write */
if ((status = nvim_update_fs_item_file_attrs(
nv_op_get_fparams(cmd_ptr->item),
FS_FA_UNRESTRICTED)) != NV_DONE_S)
{
return status;
}
status = nvimw_write_fixed(cmd_ptr->item,
cmd_ptr->data_ptr,
nv_op_get_size(cmd_ptr->item));
/* Turn back on permanent file attribute */
if (status == NV_DONE_S)
{
status = nvim_update_fs_item_file_attrs(
nv_op_get_fparams(cmd_ptr->item),
FS_FA_SYS_PERMANENT);
}
return status;
}
/*===========================================================================
FUNCTION NVIMW_WRITE_FIXED_ARRAY
DESCRIPTION
This function writes a fixed array item.
DEPENDENCIES
None
RETURN VALUE
NV_DONE_S if it worked
NV_FAIL_S if it couldn't be writen.
SIDE EFFECTS
None
===========================================================================*/
nv_stat_enum_type nvimw_write_fixed_array
(
nv_items_enum_type item, /* NV index of the item */
byte item_index, /* index into array of array members */
PACKED void *data_ptr, /* Data to write for variable */
word size /* Size of a member of the array */
)
{
boolean true_flag = TRUE; /* Flag used to set active flag to TRUE */
boolean false_flag = FALSE; /* Flag used to set active flag to FALSE */
boolean close_file = FALSE; /* Flag used to indicate if close required */
nv_stat_enum_type status = NV_DONE_S; /* Assume good status */
nvim_efs_params *fparams;
fs_file_position_type fpos;
/* Roaming list requires special processing */
#ifdef NV_FEATURE_IS683A_PRL
if (item == NV_ROAMING_LIST_683_I)
#else
if (item == NV_ROAMING_LIST_I)
#endif
{
/* Setup file info */
fparams = nvim_prl_fs_params(item_index);
fpos = 0;
}
else
{
fparams = nv_op_get_fparams(item);
fpos = nv_op_get_file_pos(item) + (item_index*size);
}
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Open for write access if necessary */
if (fparams->wr_handle == FS_NULL_HANDLE)
{
(void) nvim_open_write(fparams);
close_file = TRUE;
}
/* Reset the watchdog timer */
KICK_WATCHDOG();
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Attempt to write active flag to false, then write the data,
* then write the flag to true. In event of a write failure the
* item ends up "inactive"
*/
memcpy(((byte*)&nvi_item), &true_flag, sizeof(true_flag));
/*lint -save -e{419,420} */
memcpy(((byte*)&nvi_item)+sizeof(true_flag), (byte*)data_ptr, size-sizeof(true_flag));
/*lint -restore */
status = nvim_write_efs(fparams->wr_handle,
fpos,
&false_flag,
sizeof(false_flag));
/* Write the new data into the item */
if(status == NV_DONE_S) {
status = nvim_write_efs(fparams->wr_handle,
fpos + sizeof(true_flag),
data_ptr,
size-sizeof(true_flag));
}
/* Write the active flag to true for this member of the array */
if(status == NV_DONE_S)
{
status = nvim_write_efs(fparams->wr_handle,
fpos,
&true_flag,
sizeof(true_flag));
if (status != NV_DONE_S)
{
ERR("Couldn't update array: pos 0x%x, status %d",
fpos,status,0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -