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

📄 phb_sim_access.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_sim_access.c
 *
 * Project:
 * --------
 *   MAUI
 *
 * Description:
 * ------------
 *   This is startup 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!
 * 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"     /* Declaration of buffer management API */

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

#include "sim_common_enums.h"
// #include "nvram_editor_data_item.h"
#include "custom_nvram_editor_data_item.h"

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

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

#include "l4_defs.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_handler_startup.h"

#include "phb_context.h"

#include "phb_common.h"
#include "phb_ilm.h"
#include "phb_utils.h"
#include "phb_se.h"

#include "phb_sim_access.h"

#undef  _FILE_CODE_
#define _FILE_CODE_ _PHB_SIM_ACCESS_C_

/* SIM constants */
#define SIM_WRITE_OFFSET   5

/* Offset begun after alpha id, these are for write operation */
#define BCD_LEN_OFFSET     0
#define TON_NPI_OFFSET     1
#define TEL_NUMBER_OFFSET  2
#define CAP_CNF_OFFSET     12
#define SIM_EXT_ID_OFFSET  13

#define EF_EXT_TYPE_ADDITIONAL_DATA    0x02
#define EF_EXT_TYPE_SUBADDRESS         0x01

/* EFext types and constants */
typedef struct
{
    kal_uint8 record_type;
    kal_uint8 ext_data_length;
    kal_uint8 ext_data[EF_TEL_NUMBER_SIZE];
    kal_uint8 identifier;
} ef_ext_type;


static void phb_sim_file_info_cnf(ilm_struct *ilm_ptr, control_block_type *control_block);

static void phb_sim_read_record(kal_uint16 file_idx, kal_uint16 record_index, kal_uint16 length, kal_uint8 access_id);
static kal_uint8 phb_sim_reassemble_tel_num(ef_ext_type *data_ptr, control_block_type *control_block);
static void phb_sim_read_cnf(ilm_struct *ilm_ptr, control_block_type *control_block);

static void phb_sim_write_record(
                kal_uint16 file_idx,
                kal_uint16 record_index,
                kal_uint8 *data,
                kal_uint16 length,
                kal_uint8 access_id);
static kal_bool phb_sim_write_segmented_record(
                    control_block_type *control_block,
                    data_desc_enum type,
                    kal_uint8 chained_id);

static void phb_sim_write_cnf(ilm_struct *ilm_ptr, control_block_type *control_block);
static void phb_sim_delete_cnf(ilm_struct *ilm_ptr, control_block_type *control_block);
static kal_bool phb_sim_prepare_data_to_write(
                    control_block_type *control_block,
                    kal_uint8 *buffer,
                    kal_uint8 chained_id);
static kal_uint16 phb_sync_translate_ln_to_sim(
                    kal_uint8 *data,
                    nvram_ef_phb_ln_struct *record,
                    nvram_ef_phb_ln_struct *record1,
                    control_block_type *control_block);


/*****************************************************************************
 * FUNCTION
 *  phb_sim_file_info
 * DESCRIPTION
 *  This function issues SIM_FILE_INFO_REQ to sim.
 * PARAMETERS
 *  control_block       [?]         
 *  info_type           [IN]        
 *  ilm_ptr(?)          [IN]        The primitives
 * RETURNS
 *  KAL_TRUE if success, KAL_FALSE otherwise.
 *****************************************************************************/
kal_bool phb_sim_file_info(control_block_type *control_block, sim_info_type_enum info_type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_bool result = KAL_FALSE;

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

    ASSERT(control_block != NULL);

    if (control_block->IO_stage == IO_NONE)
    {
        sim_file_info_req_struct *sim_file_info_req;

        sim_file_info_req = (sim_file_info_req_struct*) construct_local_para(
                                                            sizeof(sim_file_info_req_struct),
                                                            TD_CTRL);
        sim_file_info_req->file_idx = control_block->primary_ID;
    #ifdef __USIM_SUPPORT__
        kal_mem_cpy(sim_file_info_req->path, control_block->path, 6);
    #endif 
        sim_file_info_req->info_type = info_type;
        sim_file_info_req->access_id = control_block->ID;

        control_block->IO_stage = IO_WAIT;
        control_block->IO_cnf_receive = phb_sim_file_info_cnf;
        phb_send_ilm(MOD_SIM, MSG_ID_SIM_FILE_INFO_REQ, sim_file_info_req, NULL);

        result = KAL_TRUE;
    }
    /* Abnormal, return false */
    else
    {
        result = KAL_FALSE;
    }

    return result;
}   /* end of module main function */


/*****************************************************************************
 * FUNCTION
 *  phb_sim_file_info_cnf
 * DESCRIPTION
 *  This function issues SIM_FILE_INFO_REQ to sim.
 * PARAMETERS
 *  ilm_ptr             [IN]        The primitives
 *  control_block       [?]         
 * RETURNS
 *  void
 *****************************************************************************/
static void phb_sim_file_info_cnf(ilm_struct *ilm_ptr, control_block_type *control_block)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    sim_file_info_cnf_struct *sim_file_info_cnf;

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

    ASSERT(control_block != NULL);

    sim_file_info_cnf = (sim_file_info_cnf_struct*) ilm_ptr->local_para_ptr;

    if (sim_file_info_cnf->result == SIM_CMD_SUCCESS)
    {
        /* amanda add */
        if (sim_file_info_cnf->num_of_rec > 0)
        {
            if (sim_file_info_cnf->file_idx == FILE_FDN_IDX)
            {
                phb_ptr->fdn_alpha_length = (sim_file_info_cnf->file_size / sim_file_info_cnf->num_of_rec) - 14;
            }
            else if (sim_file_info_cnf->file_idx == FILE_BDN_IDX)
            {
                phb_ptr->bdn_alpha_length = (sim_file_info_cnf->file_size / sim_file_info_cnf->num_of_rec) - 15;
            }
            else if (sim_file_info_cnf->file_idx == FILE_MSISDN_IDX)
            {
                phb_ptr->msisdn_alpha_length = (sim_file_info_cnf->file_size / sim_file_info_cnf->num_of_rec) - 14;
            }
        }

        if (control_block->IO_stage == IO_WAIT)
        {
            /* success */
            phb_IO_return(control_block, ilm_ptr, KAL_TRUE);
            return;
        }
      /** 
       * Wrong state: currently it is not waiting. 
       * Abnormal, consume message.
       */
        else
        {
            kal_trace(TRACE_ERROR, ERROR_PHB_SIM_IO_STATE_FILE_INFO);
            return;
        }
    }
    /* error occured, call error handler */

⌨️ 快捷键说明

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