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

📄 phb_handler_write.c

📁 最新MTK手机软件源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/*****************************************************************************
*  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).
*
*****************************************************************************/

/*****************************************************************************
 *
 * Filename:
 * ---------
 * phb_handler_write.c
 *
 * Project:
 * --------
 *   MAUI
 *
 * Description:
 * ------------
 *   This is write handler of PHB module.
 *
 * Author:
 * -------
 * -------
 *
 *============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 *
 * removed!
 * removed!
 *
 *
 * removed!
 * removed!
 *
 *
 * removed!
 * removed!
 *
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/
#include "kal_release.h"        /* Basic data type */

#include "stack_common.h"
#include "stack_msgs.h"
#include "app_ltlcom.h" /* Task message communiction */
#include "app_buff_alloc.h"

#include "kal_trace.h"
#include "phb_trc.h"

// #include "nvram_editor_data_item.h"
#include "custom_nvram_editor_data_item.h"
#include "sim_common_enums.h"
#include "l4c_common_enum.h"
#ifdef __MCD__
#include "mcd_l3_inc_struct.h"
#endif
#include "l4c_utility.h"  /* for l4c_is_src_from_rmmi */

#include "l4_common.h"
#include "ps2sim_struct.h"

#include "l4c2phb_enums.h"
#include "l4c2phb_struct.h"

/* Prerequisite of phb_context.h */
#include "phb_defs.h"
#include "phb_control_block.h"
#include "phb_data_desc.h"
#include "phb_data_entry_table.h"
#include "phb_pindex.h"
#include "phb_name_num_index.h"

#include "phb_context.h"
#include "phb_se.h"
#include "phb_utils.h"

/* ErrorStruct */
#include "asn-error.h"
#include "phb_common.h"
#include "phb_ilm.h"

#include "phb_sap.h"
#include "phb_handler_read.h"
#include "phb_handler_write.h"
#include "phb_nvram_access.h"
#include "phb_sim_access.h"

#include "nvram_enums.h"
#include "nvram_struct.h"
#undef  _FILE_CODE_
#define _FILE_CODE_ _PHB_HANDLER_WRITE_C_

static void phb_write_err_handler(ilm_struct *ilm_ptr, control_block_type *control_block);
static void phb_write_continue(ilm_struct *ilm_ptr, control_block_type *control_block);
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__
static void phb_write_usim_err_handler(ilm_struct *ilm_ptr, control_block_type *control_block);
static void phb_write_usim_confirm(
                phb_errno_enum result,
                kal_uint16 actual_count,
                kal_uint8 src_id,
                control_block_type *control_block);
#endif /* __PHB_USIM_SUPPORT__ */ 

static void phb_sync_confirm(phb_errno_enum result, control_block_type *control_block);
static void phb_write_ln_confirm(phb_errno_enum result, kal_uint8 src_id, control_block_type *control_block);
static kal_bool phb_update_ln(nvram_ef_phb_ln_struct *record, control_block_type *control_block);

static kal_bool phb_edit_ln(control_block_type *control_block);

#ifndef __PHB_LN_SINGLE_COUNT__
static kal_bool phb_compare_bcd(kal_uint8 length1, kal_uint8 length2, kal_uint8 *bcd1, kal_uint8 *bcd2);
#endif 

#if (MAX_PHB_LN_ENTRY <= 20)
static void phb_ln_renew_entry1(kal_uint8 index, phb_ln_entry_struct *entry, nvram_ef_phb_ln_struct *record);
static void phb_ln_renew_entry2(
                kal_uint8 index,
                phb_ln_entry_struct *entry,
                nvram_ef_phb_ln_struct *record,
                nvram_ef_phb_ln_struct *record2);
#endif /* (MAX_PHB_LN_ENTRY <= 20) */ 

static void phb_ln_push_new_entry(
                phb_ln_entry_struct *entry,
                nvram_ef_phb_ln_struct *record,
                nvram_ef_phb_ln_struct *record2);

extern kal_uint8 convert_to_digit(kal_uint8 *source, kal_uint8 *dest);


/*****************************************************************************
 * FUNCTION
 *  phb_write_handler
 * DESCRIPTION
 *  This is phb_write_handler function of PHB module.
 *  Handles write request from L4C.
 *  3 scenerio are allowed:
 *  read / write   index    total storage  record_index   Semantic
 *  WRITE          0xFFFF         valid    valid          Write an entry to user-specified physical location - {`storage', `record_index'}
 *  This operation is `add'.
 *  valid          ignored  0xFFFF         Write an entry to `index'th entry maintained by PHB.
 *  This opeartion is `update'.
 *  0xFFFF         valid    0xFFFF         Write an entry to `storage'. The physical location written is a free record searched by PHB.
 *  This opeartion is `add'.
 * PARAMETERS
 *  ilm_ptr             [IN]        The primitives
 *  control_block       [?]         
 * RETURNS
 *  void
 *****************************************************************************/
void phb_write_handler(ilm_struct *ilm_ptr, control_block_type *control_block)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    if (ilm_ptr != NULL)
    {
        l4cphb_write_req_struct *l4cphb_write_req;

        l4cphb_write_req = (l4cphb_write_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_write_req->src_id, control_block);
            return;
        }

        control_block->src_id = l4cphb_write_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_NONE)
            {
                kal_uint8 *pdu_ptr;
                kal_uint16 pdu_length;

                phb_entry_struct *phb_entry;
                l4cphb_phb_entry_array_struct *l4cphb_phb_entry_array;

                /* Error: ECC and SDN are read only */
                if (!phb_is_type_valid(l4cphb_write_req->type) ||
                    (l4cphb_write_req->type == PHB_ECC) || (l4cphb_write_req->type == PHB_SDN))
                {
                    phb_write_err_handler(NULL, control_block);
                    return;
                }

                /* First we have to unpack user's request */
            /**
             * Number of entries can be wriiten is exactly 1.
             * Hence, number of entries in peer buffer is expected to be 1.
             *
             * Since the entry to write is requested from L4C,
             * here a temporary l4cphb_phb_entry_array is allocated, so that user's
             * parameter can be unpacked to control_block->temp_entry.
             */

                pdu_ptr = (kal_uint8*) get_pdu_ptr(ilm_ptr->peer_buff_ptr, &pdu_length);
                l4cphb_phb_entry_array = (l4cphb_phb_entry_array_struct*) get_32bits_aligned_val(pdu_ptr);
                phb_entry = &l4cphb_phb_entry_array->array[0];

            /**
             * After copying user's parameter from peer buffer, temporary
             * l4cphb_phb_entry_array can be freed.
             *
             * The entry to be written is stored in temp_entry!!
             */
                kal_mem_cpy(&control_block->temp_entry, (void const*)phb_entry, sizeof(phb_entry_struct));

            /**
             * Finally, the data to write is prepared in control_block->temp_entry.
             * Now the prepared data can be written.
             */
                /* This is for fectching necessary parameters from temp_entry */
                phb_entry = (phb_entry_struct*) & control_block->temp_entry;

                phb_control_block_set_param(control_block, WRITE_CONTINUE, NULL, NULL);

                phb_control_block_set(
                    control_block,
                    phb_write_continue,
                    phb_write_handler,
                    phb_write_err_handler,
                    WRITE_CONTINUE);
                phb_control_block_set_IO(control_block, l4cphb_write_req->type, phb_entry->index, 1);

⌨️ 快捷键说明

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