📄 phb_handler_write.c
字号:
/* First we have to sync the written entry into search engine */
else
{
/**
* If this control path is reached, then one of the following
* conditions is true:
* 1. For `add' operation, a free record must be found and
* the requested entry is successfully written.
* 2. For `update' operation, the record addressed by
* record_index must be occupied, and the requested
* entry is successfully updated.
*/
/* This write is a add operation */
control_block->candidate = control_block->index;
if (control_block->index == (kal_uint16) PHB_INVALID_VALUE)
{
kal_uint16 total = 0, available = 0;
if (control_block->seg_record_index == 0)
{
control_block->seg_record_index = (kal_uint8) PHB_INVALID_VALUE;
}
if ((control_block->type == PHB_PHONEBOOK || control_block->type == PHB_ANR)
&& control_block->storage == PHB_SIM &&
control_block->seg_record_index != (kal_uint8) PHB_INVALID_VALUE)
{
/* set ext_index_table */
phb_se_ext_index_set(
control_block->record_index,
control_block->seg_record_index,
control_block->ext1_parent_type);
}
#ifndef __PHB_SORT_ENABLE__
if (control_block->type == PHB_PHONEBOOK)
{
phb_entry->index = control_block->record_index;
}
else
#endif /* __PHB_SORT_ENABLE__ */
phb_entry->index = phb_se_append(
control_block->type,
control_block->record_index,
control_block->seg_record_index,
phb_entry);
/* Mark free-list as used! */
phb_data_desc_mark_free(
phb_data_desc_get_desc_by_ID(control_block->primary_ID),
control_block->record_index,
KAL_FALSE);
/**
* Since it's an add operation, MMI needs to be informed
* whether this newly added entry causes storage full.
*/
if (control_block->type == PHB_PHONEBOOK)
{
l4cphb_phonebook_status_req(control_block->storage, &total, &available);
}
else
{
l4cphb_status_req(control_block->type, &total, &available);
}
/* Storage full! */
if ((total != 0) && (available == 0))
{
control_block->cause = PHB_CAUSE_STORAGE_FULL;
}
}
/* This write is a overwrite/update operation */
else
{
kal_uint8 old_ext_index = (kal_uint8) PHB_INVALID_VALUE;
if (control_block->seg_record_index == 0)
{
control_block->seg_record_index = (kal_uint8) PHB_INVALID_VALUE;
}
/* seg_record_index could be Invalid for update */
if ((control_block->type == PHB_PHONEBOOK || control_block->type == PHB_ANR) &&
control_block->storage == PHB_SIM)
{
if (control_block->seg_record_index != (kal_uint8) PHB_INVALID_VALUE)
{
/* set ext_index_table */
phb_se_ext_index_set(
control_block->record_index,
control_block->seg_record_index,
control_block->ext1_parent_type);
}
else /* new ext index is 0, check the old ext index */
{
old_ext_index = phb_se_ext_index_find(control_block->record_index, control_block->ext1_parent_type);
if (old_ext_index != (kal_uint8) PHB_INVALID_VALUE)
{
phb_se_ext_index_delete(control_block->record_index, control_block->ext1_parent_type);
}
}
}
#ifndef __PHB_SORT_ENABLE__ /* seg_record_index could be Invalid for update */
if (control_block->type == PHB_PHONEBOOK || control_block->type == PHB_ANR)
{
phb_entry->index = control_block->record_index;
}
else
#endif /* __PHB_SORT_ENABLE__ */
{
phb_entry->index = phb_se_update(
control_block->type,
control_block->seg_record_index,
phb_entry,
--phb_entry->index,
&old_ext_index);
}
if (control_block->seg_record_index == (kal_uint8) PHB_INVALID_VALUE &&
old_ext_index > 0 && old_ext_index != (kal_uint8) PHB_INVALID_VALUE)
{
phb_data_desc_mark_free(
phb_data_desc_get_desc_by_ID(control_block->secondary_ID),
(kal_uint16)old_ext_index,
KAL_TRUE);
}
}
/* Weird error occured!! */
if (phb_entry->index == (kal_uint16) PHB_INVALID_VALUE)
{
phb_write_err_handler(NULL, control_block);
return;
}
phb_entry->index++;
phb_entry->record_index = control_block->record_index;
}
/* Then give control back to controller */
(*control_block->controller) (NULL, control_block);
}
} /* end of phb_write_continue */
/*****************************************************************************
* FUNCTION
* phb_write_confirm
* DESCRIPTION
* This is phb_write_confirm function of PHB module.
* PARAMETERS
* result [IN]
* actual_count [IN]
* src_id [IN]
* control_block [?]
* ilm_ptr(?) [IN] The primitives
* RETURNS
* void
*****************************************************************************/
static void phb_write_confirm(
phb_errno_enum result,
kal_uint16 actual_count,
kal_uint8 src_id,
control_block_type *control_block)
{
#ifdef __PHB_USIM_SUPPORT__
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (control_block->cnf_msg_id == MSG_ID_L4CPHB_WRITE_USIM_REQ)
{
local_para_struct *local_param_ptr = NULL;
l4cphb_write_usim_cnf_struct *l4cphb_write_cnf;
l4cphb_write_cnf = (l4cphb_write_usim_cnf_struct*) construct_local_para(
sizeof(l4cphb_write_cnf_struct),
TD_CTRL);
l4cphb_write_cnf->total = actual_count;
l4cphb_write_cnf->src_id = src_id;
local_param_ptr = (local_para_struct*) l4cphb_write_cnf;
/* If result is PHB_ERRNO_BUSY, reject newly received request */
l4cphb_write_cnf->result = result;
/* Confirm to in-processing operation */
if (result != PHB_ERRNO_BUSY)
{
/* Field 'cause' is meaningful when I/O occured by using control blocks */
l4cphb_write_cnf->cause = control_block->cause;
l4cphb_write_cnf->old_index = control_block->candidate;
phb_free_control_block(control_block);
}
phb_send_ilm(MOD_L4C, MSG_ID_L4CPHB_WRITE_USIM_CNF, local_param_ptr, NULL);
}
else if (control_block->cnf_msg_id == MSG_ID_L4CPHB_SET_GRP_REQ)
{
local_para_struct *local_param_ptr = NULL;
l4cphb_set_grp_cnf_struct *l4cphb_write_cnf;
l4cphb_write_cnf = (l4cphb_set_grp_cnf_struct*) construct_local_para(
sizeof(l4cphb_set_grp_cnf_struct),
TD_CTRL);
l4cphb_write_cnf->src_id = src_id;
local_param_ptr = (local_para_struct*) l4cphb_write_cnf;
/* If result is PHB_ERRNO_BUSY, reject newly received request */
l4cphb_write_cnf->result = result;
/* Confirm to in-processing operation */
if (result != PHB_ERRNO_BUSY)
{
/* Field `cause' is meaningful when I/O occured by using control blocks */
/* l4cphb_write_cnf->cause = control_block->cause; */
l4cphb_write_cnf->record_index = control_block->record_index;
l4cphb_write_cnf->group_type = control_block->temp_group_id;
phb_free_control_block(control_block);
}
phb_send_ilm(MOD_L4C, MSG_ID_L4CPHB_SET_GRP_CNF, local_param_ptr, NULL);
}
else
#endif /* __PHB_USIM_SUPPORT__ */
{
local_para_struct *local_param_ptr = NULL;
l4cphb_write_cnf_struct *l4cphb_write_cnf;
kal_trace(TRACE_FUNC, FUNC_PHB_WRITE_CNF, result, actual_count, src_id);
l4cphb_write_cnf = (l4cphb_write_cnf_struct*) construct_local_para(sizeof(l4cphb_write_cnf_struct), TD_CTRL);
l4cphb_write_cnf->total = actual_count;
l4cphb_write_cnf->src_id = src_id;
local_param_ptr = (local_para_struct*) l4cphb_write_cnf;
/* If result is PHB_ERRNO_BUSY, reject newly received request */
l4cphb_write_cnf->result = result;
/* Confirm to in-processing operation */
if (result != PHB_ERRNO_BUSY)
{
/* Field `cause' is meaningful when I/O occured by using control blocks */
l4cphb_write_cnf->cause = control_block->cause;
l4cphb_write_cnf->old_index = control_block->candidate;
phb_free_control_block(control_block);
}
phb_send_ilm(MOD_L4C, MSG_ID_L4CPHB_WRITE_CNF, local_param_ptr, NULL);
}
} /* end of phb_write_confirm */
/*****************************************************************************
* FUNCTION
* phb_sync_handler
* DESCRIPTION
* This is phb_sync_handler function of PHB module.
* Handles sync request from L4C when power off.
* Copyies LND records from NVRAM to SIM, if supported
* PARAMETERS
* ilm_ptr [IN] The primitives
* control_block [?]
* RETURNS
* void
*****************************************************************************/
void phb_sync_handler(ilm_struct *ilm_ptr, control_block_type *control_block)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (ilm_ptr != NULL)
{
#ifdef __PHB_NVRAM_LN_ONLY__
phb_send_ilm(MOD_L4C, MSG_ID_L4CPHB_SYNC_CNF, NULL, NULL);
#else /* __PHB_NVRAM_LN_ONLY__ */
/* Cannot allocate, means that PHB is still operating. Reject request! */
if (control_block == NULL)
{
control_block = phb_alloc_control_block();
if (control_block == NULL)
{
phb_sync_confirm(PHB_ERRNO_BUSY, control_block);
return;
}
/* Retain msg_id */
control_block->cnf_msg_id = ilm_ptr->msg_id;
}
/* if (phb_ptr->state == PHB_STATE_READY) */
{
if (control_block->proc_stage == SYNC_NONE)
{
control_block->proc_stage = SYNC_READ_FILE;
control_block->IO_cnf_receive = phb_sync_handler;
if (sim_service_table_query(SERVICE_LND) == SERVICE_SUPPORT)
{
sim_file_info_req_struct *param_ptr;
/* SIM card supports LND, get file info */
param_ptr = (sim_file_info_req_struct*)
construct_local_para((kal_uint1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -