⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 phb_handler_write.c

📁 最新MTK手机软件源码
💻 C
📖 第 1 页 / 共 5 页
字号:
            /* The just written entry is still there! */
            phb_entry = (phb_entry_struct*) & control_block->temp_entry;

            /* control_block->set_IO() need not be invoked, because type, total is already be set. */
            /* Weird error happened. Anyway, the entry is already written successfully. */
        #ifdef __PHB_USIM_SUPPORT__
            if (phb_se_is_in_range(phb_entry->type, phb_entry->index, &control_block->total) == KAL_FALSE)
        #else 
            if (phb_se_is_in_range(control_block->type, phb_entry->index, &control_block->total) == KAL_FALSE)
        #endif 
            {
                control_block->actual_count = 1;
                phb_write_usim_confirm(
                    PHB_ERRNO_SUCCESS,
                    control_block->actual_count,
                    control_block->src_id,
                    control_block);
                return;
            }

            /* If any critial error occured. read_err_handler will handle it. */
            if (phb_read_fake(control_block, phb_entry) == KAL_FALSE)
            {
                return;
            }

            /* Finally, faking complete....Now continue reading */
            phb_read_continue(NULL, control_block);
            return;
        }
    }
    /* error */
    else
    {
        phb_write_err_handler(NULL, control_block);
        return;
    }
}   /* end of phb_write_usim_handler */


/*****************************************************************************
 * FUNCTION
 *  phb_write_usim_err_handler
 * DESCRIPTION
 *  This is phb_write_usim_err_handler function of PHB module.
 * PARAMETERS
 *  ilm_ptr             [IN]        The primitives
 *  control_block       [?]         
 * RETURNS
 *  void
 *****************************************************************************/
static void phb_write_usim_err_handler(ilm_struct *ilm_ptr, control_block_type *control_block)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_PHB_WRITE_ERR);

   /**
    * Shall we try to recover/continue handling,
    * or just reject the request in processing?
    * Currently, the latter is adpoted.
    */
    control_block->actual_count = 0;
    phb_write_usim_confirm(PHB_ERRNO_FAIL, control_block->actual_count, control_block->src_id, control_block);

}   /* end of phb_write_err_handler function */


/*****************************************************************************
 * FUNCTION
 *  phb_write_usim_confirm
 * DESCRIPTION
 *  This is phb_write_usim_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_usim_confirm(
                phb_errno_enum result,
                kal_uint16 actual_count,
                kal_uint8 src_id,
                control_block_type *control_block)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    local_para_struct *local_param_ptr = NULL;
    l4cphb_write_usim_cnf_struct *l4cphb_write_cnf;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_PHB_WRITE_CNF, result, actual_count, src_id);

    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);
}   /* end of phb_write_confirm */


/*****************************************************************************
 * FUNCTION
 *  phb_set_grp_handler
 * DESCRIPTION
 *  This is phb_set_grp_handler function of PHB module.
 *  Handles write request from L4C.
 * PARAMETERS
 *  ilm_ptr             [IN]        The primitives
 *  control_block       [?]         
 * RETURNS
 *  void
 *****************************************************************************/
void phb_set_grp_handler(ilm_struct *ilm_ptr, control_block_type *control_block)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (ilm_ptr != NULL)
    {
        l4cphb_set_grp_req_struct *l4cphb_set_req;

        l4cphb_set_req = (l4cphb_set_grp_req_struct*) ilm_ptr->local_para_ptr;

        /* Cannot allocate, means that PHB is still operating. Reject request! */
        control_block = phb_alloc_control_block();
        if (control_block == NULL)
        {
            phb_write_confirm(PHB_ERRNO_BUSY, 0, l4cphb_set_req->src_id, control_block);
            return;
        }

        control_block->src_id = l4cphb_set_req->src_id;

        /* Retain msg_id */
        control_block->cnf_msg_id = ilm_ptr->msg_id;

        if (phb_ptr->state == PHB_STATE_READY)
        {
            if (control_block->proc_stage == WRITE_USIM_NONE)
            {
                control_block->temp_group_id = l4cphb_set_req->group_type;

                //phb_control_block_set_param(control_block,
                //                        WRITE_USIM_ANR,
                //                        NULL,
                //                        NULL);

                phb_control_block_set(control_block, phb_write_continue, phb_set_grp_handler, phb_write_err_handler, 0);
                phb_control_block_set_IO(
                    control_block,
                    PHB_GRP,
                    l4cphb_set_req->record_index,   /* only set index, not including record_index */
                    1);
                /* set storage, record_index, primary_ID, and secondary_ID */
                control_block->primary_ID = FILE_G_GRP_IDX;
                control_block->secondary_ID = FILE_NONE;
                kal_mem_cpy(control_block->path, usim_ef_info[FILE_G_PHONEBOOK_IDX].full_path, 4);
                control_block->path[4] = phb_ptr->path[DATA_DESC_GRP][0];
                control_block->path[5] = phb_ptr->path[DATA_DESC_GRP][1];
                control_block->record_index = l4cphb_set_req->record_index;
                control_block->storage = PHB_SIM;

                /* data stores data to be written, and length is record size of storage */
                /* *control_block->data = control_block->temp_group_id; */
                control_block->length = phb_data_desc_get_record_size(phb_data_desc_get_desc_by_ID(control_block->primary_ID));
                if (phb_sim_write_first_record(control_block, (kal_uint8) PHB_INVALID_VALUE) == KAL_FALSE)
                {
                    /* Possibly because segemented data cannot be written */
                    phb_write_confirm(
                        PHB_ERRNO_FAIL,
                        control_block->actual_count,
                        control_block->src_id,
                        control_block);
                    return;
                }
            }
            /* error */
            else
            {
                phb_write_err_handler(NULL, control_block);
                return;
            }
        }
        /* error */
        else
        {
            kal_trace(TRACE_ERROR, ERROR_PHB_STATE);

            control_block->actual_count = 0;
            phb_free_control_block(control_block);
            control_block = NULL;
            phb_write_confirm(PHB_ERRNO_BUSY, 0, l4cphb_set_req->src_id, control_block);
            return;
        }

    }
    /* Write confirmed */
    else
    {
        phb_write_confirm(PHB_ERRNO_SUCCESS, 1, control_block->src_id, control_block);
        return;
    }
}
#endif /* __PHB_USIM_SUPPORT__ */ 


/*****************************************************************************
 * FUNCTION
 *  phb_write_continue
 * DESCRIPTION
 *  This is phb_write_continue function of PHB module.
 *  
 *  Since only exactly one entry can be written at a time, this function just issues write
 *  request if it's time to begin write prepared data, or give control back to controller.
 * PARAMETERS
 *  ilm_ptr             [IN]        The primitives
 *  control_block       [?]         
 * RETURNS
 *  void
 *****************************************************************************/
static void phb_write_continue(ilm_struct *ilm_ptr, control_block_type *control_block)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_PHB_WRITE_CONT);

    /* It's time to write prepared data */
    if (ilm_ptr == NULL)
    {
        if (phb_issue_IO_write(control_block) == KAL_FALSE)
        {
            /* Possibly because segemented data cannot be written */
            phb_write_confirm(PHB_ERRNO_FAIL, control_block->actual_count, control_block->src_id, control_block);
            return;
        }
    }
#ifdef __PHB_USIM_SUPPORT__
    else if (control_block->cnf_msg_id == MSG_ID_L4CPHB_SET_GRP_REQ)
    {
        /* Then give control back to controller */
        (*control_block->controller) (NULL, control_block);
    }
#endif /* __PHB_USIM_SUPPORT__ */
    /* Write confirmed. Give control back to contoller */
    else
    {
        phb_entry_struct *phb_entry = (phb_entry_struct*) control_block->data;

        /* For 1 to 1 mapping */
        if (control_block->type == PHB_MSISDN)
        {
            phb_entry->index = phb_entry->record_index = control_block->index;
        }
    #ifdef __PHB_USIM_SUPPORT__
        else if (control_block->type == PHB_GAS)
        {
        }
        else if (control_block->type == PHB_GRP || control_block->type == PHB_IAP)
        {
            phb_entry->index = control_block->record_index;
        }
        else if (control_block->type == PHB_EMAIL)
        {
            if (phb_ptr->email_type == 2)
            {
                /* set email_index_table */
                phb_se_iap_index_set(
                    control_block->temp_email_entry.adn_record_index,
                    (kal_uint8)control_block->record_index,
                    DATA_DESC_EMAIL);
                /* Since data is written or become empty, that record must be marked */
                phb_data_desc_mark_free(
                    DATA_DESC_EMAIL,
                    control_block->record_index,
                    ((control_block->temp_email_entry.adn_record_index == 0xFF) ? KAL_TRUE : KAL_FALSE));
            }
        }
    #endif /* __PHB_USIM_SUPPORT__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -