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

📄 phb_se.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_se.c
 *
 * Project:
 * --------
 *   MAUI
 *
 * Description:
 * ------------
 *   This is the data descriptor. It maintains number of records, record size, free count,
 *   bits of the bitmap, free list implemented in bitmap.
 *
 * 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 <string.h>

#include "kal_release.h"        /* Basic data type */

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

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

/* include the LID */
// #include "nvram_data_items.h"
#include "nvram_user_defs.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 "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"

/* 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 "nvram_data_items.h"
#include "phb_config.h"
#include "phb_utils.h"

#include "phb_handler_read.h"
#include "phb_se.h"

#undef  _FILE_CODE_
#define _FILE_CODE_ _PHB_SE_C_

#define SIG_DIGITS      6
#define SIG_MOD_VAL     10000000
#define SIG_DIV_VAL     10000
#define SIG_WIDTH_VAL   255

#define COUNTRYCODE_ELEMENT_COUNT sizeof(countrycode) / sizeof(countrycode[0])

/* Defines memory allocation of name_num_index for PHB, FDN, and BDN */
#ifdef __PHB_SORT_ENABLE__
/* memory allocation of indexing structure (name_num_index) for PHB */
data_entry_struct data_entry_table_PHB[PHB_INDEX_MAX_ENTRIES_COUNT];
pindex_struct name_index_PHB[PHB_INDEX_MAX_ENTRIES_COUNT];
pindex_struct num_index_PHB[PHB_INDEX_MAX_ENTRIES_COUNT];
#endif /* __PHB_SORT_ENABLE__ */ 

ext_index_struct ext_index_table[EXT1_MAX_ENTRIES_COUNT];

#ifdef __PHB_USIM_SUPPORT__
kal_uint8 anr_index_table[ANR_INDEX_MAX_ENTRIES_COUNT] = {0xFF};
kal_uint8 email_index_table[EMAIL_INDEX_MAX_ENTRIES_COUNT] = {0xFF};
kal_uint8 sne_index_table[SNE_INDEX_MAX_ENTRIES_COUNT] = {0xFF};
#endif /* __PHB_USIM_SUPPORT__ */ 

/* memory allocation of indexing structure (name_num_index) for FDN */
data_entry_struct data_entry_table_FDN[FDN_INDEX_MAX_ENTRIES_COUNT];
pindex_struct name_index_FDN[FDN_INDEX_MAX_ENTRIES_COUNT];
pindex_struct num_index_FDN[FDN_INDEX_MAX_ENTRIES_COUNT];

/* memory allocation of indexing structure (name_num_index) for BDN */
data_entry_struct data_entry_table_BDN[BDN_INDEX_MAX_ENTRIES_COUNT];
pindex_struct name_index_BDN[BDN_INDEX_MAX_ENTRIES_COUNT];

/* NOTE: BDN NEED NOT support num_index */

static kal_uint16 phb_binary_search_country_code(kal_uint8 *bcd_array);
static kal_uint8 phb_se_cal_signature_num(kal_uint8 ton_npi, kal_uint8 *bcd_array, kal_uint8 length, kal_uint8 *num);

extern kal_uint8 convert_to_digit(kal_uint8 *source, kal_uint8 *dest);
#ifdef __PHB_USIM_SUPPORT__
extern kal_bool is_usim_type(void);
#endif

/* Solution for PinYin sorting hang problem */
#if defined(__PINYIN_SORTING_ZI__) || defined(__PINYIN_SORTING_KA__)
alpha_id_type alpha_id_pinyin_PHB[PHB_INDEX_MAX_ENTRIES_COUNT];
#endif 


/*****************************************************************************
 * FUNCTION
 *  phb_se_new
 * DESCRIPTION
 *  Constructor of the Search Engine
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void phb_se_new()
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    name_num_index_type *name_num_index;

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

#ifdef __PHB_SORT_ENABLE__
    name_num_index = &phb_ptr->indices.phb_index;
    name_num_index->data_entry_table.table = &data_entry_table_PHB[0];
    name_num_index->name_index.table = &name_index_PHB[0];
    name_num_index->num_index.table = &num_index_PHB[0];
    phb_name_num_index_new(name_num_index, PHB_INDEX_MAX_ENTRIES_COUNT);
#endif /* __PHB_SORT_ENABLE__ */ 
    kal_mem_set(&ext_index_table[0], (kal_uint8) PHB_INVALID_VALUE, EXT1_MAX_ENTRIES_COUNT * sizeof(ext_index_struct));

    name_num_index = &phb_ptr->indices.fdn_index;
    phb_ptr->indices.fdn_index.data_entry_table.table = &data_entry_table_FDN[0];
    phb_ptr->indices.fdn_index.name_index.table = &name_index_FDN[0];
    phb_ptr->indices.fdn_index.num_index.table = &num_index_FDN[0];
    phb_name_num_index_new(name_num_index, FDN_INDEX_MAX_ENTRIES_COUNT);

    name_num_index = &phb_ptr->indices.bdn_index;
    name_num_index->data_entry_table.table = &data_entry_table_BDN[0];
    name_num_index->name_index.table = &name_index_BDN[0];
    name_num_index->num_index.table = NULL; /* BDN need NOT num_index */

    phb_name_num_index_new(name_num_index, BDN_INDEX_MAX_ENTRIES_COUNT);
}   /* end of phb_se_new */


/*****************************************************************************
 * FUNCTION
 *  phb_se_reset
 * DESCRIPTION
 *  Reset the Search Engine
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void phb_se_reset()
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

#ifdef __PHB_SORT_ENABLE__
    phb_name_num_index_reset(&phb_ptr->indices.phb_index);
#endif 
    kal_mem_set(&ext_index_table[0], (kal_uint8) PHB_INVALID_VALUE, EXT1_MAX_ENTRIES_COUNT * sizeof(ext_index_struct));
    phb_name_num_index_reset(&phb_ptr->indices.fdn_index);
    phb_name_num_index_reset(&phb_ptr->indices.bdn_index);
}   /* end of phb_se_reset */


/*****************************************************************************
 * FUNCTION
 *  phb_se_ext_index_set
 * DESCRIPTION
 *  Append the ext_index
 * PARAMETERS
 *  record_index        [IN]        
 *  ext_index           [IN]        
 *  phb_type            [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void phb_se_ext_index_set(kal_uint16 record_index, kal_uint8 ext_index, phb_type_enum phb_type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    ASSERT(ext_index >= 1);
    if (ext_index != (kal_uint8) PHB_INVALID_VALUE)
    {
        ext_index_table[ext_index - 1].record_index = record_index;
    #ifdef __PHB_USIM_SUPPORT__
        ext_index_table[ext_index - 1].type = phb_type;
    #endif 
    }
}   /* end of phb_se_ext_index_set */


/*****************************************************************************
 * FUNCTION
 *  phb_se_ext_index_delete
 * DESCRIPTION
 *  Append the ext_index
 * PARAMETERS
 *  record_index        [IN]        
 *  phb_type            [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void phb_se_ext_index_delete(kal_uint16 record_index, phb_type_enum phb_type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    int i;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    for (i = 0; i < EXT1_MAX_ENTRIES_COUNT; i++)
    {
    #ifdef __PHB_USIM_SUPPORT__
        if (ext_index_table[i].record_index == record_index && ext_index_table[i].type == phb_type)
        {
            ext_index_table[i].record_index = (kal_uint16) PHB_INVALID_VALUE;
            ext_index_table[i].type = PHB_NONE;
            return;
        }
    #else /* __PHB_USIM_SUPPORT__ */ 
        if (ext_index_table[i].record_index == record_index)
        {
            ext_index_table[i].record_index = (kal_uint16) PHB_INVALID_VALUE;
            return;
        }
    #endif /* __PHB_USIM_SUPPORT__ */ 
    }
}   /* end of phb_se_ext_index_delete */


/*****************************************************************************
 * FUNCTION

⌨️ 快捷键说明

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