blob: c04e296c7aaa606a92ad71db0e30dcd83b8427d6 [file] [log] [blame]
/*****************************************************************************
* 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).
*
*****************************************************************************/
/*******************************************************************************
* 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) 2001
*
*******************************************************************************/
/*******************************************************************************
* Filename:
* ---------
* sim_public_api.h
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
* API provided by SIM task and outside-PS task uses also
*
* Author:
* -------
* -------
*
*******************************************************************************/
#ifndef SIM_PUBLIC_API_H
#define SIM_PUBLIC_API_H
#include "kal_general_types.h"
#include "sim_public_enum.h"
#include "sim_ps_enum.h"
#ifdef __SIM_MULTI_PIN__
#include "ps_public_struct.h"
#endif
/*******************************************************************************/
/* Merge sim_ps_api.h */
#if defined (__GEMINI__)
kal_bool is_usim_type(sim_interface_enum ps_id);
#else
kal_bool is_usim_type(void);
#endif
kal_bool is_usim_type_by_ps_id(protocol_id_enum ps_id);
kal_uint8 sim_query_mnc_num(sim_interface_enum simInterface);
#if defined (__GEMINI__)
usim_acl_type_enum usim_query_acl_type(sim_interface_enum ps_id);
#else
usim_acl_type_enum usim_query_acl_type(void);
#endif
usim_acl_type_enum usim_query_acl_type_by_ps_id(protocol_id_enum ps_id);
uicc_app_type_enum sim_application_id_query(sim_interface_enum simInterface, usim_logic_channel_enum channel);
sim_dn_enum sim_dn_type_query(sim_interface_enum simInterface);
#if defined (__GEMINI__)
kal_bool is_vsim_on(kal_uint8 simInterface);
#else
kal_bool is_vsim_on(void);
#endif
kal_bool is_vsim_on_by_ps_id(protocol_id_enum ps_id);
kal_uint8 sim_read_vsim_profileid(kal_uint8 simInterface);
kal_uint8 sim_read_vsim_type(kal_uint8 simInterface, kal_uint8 profile_id);
kal_uint8 sim_read_vsim_auth_algo(kal_uint8 simInterface, kal_uint8 profile_id);
void sim_read_vsim_auth_res(kal_uint8 simInterface, kal_uint8 profile_id, kal_uint16 *auth_len, kal_uint8 *auth_res);
vsim_ver_type_enum sim_read_vsim_ver(kal_uint8 simInterface);
#ifdef __GEMINI__
kal_uint8 *get_sim_context_g_sat_event_list(kal_uint8 simInterface);
#else
kal_uint8 *get_sim_context_g_sat_event_list(void);
#endif
void deactivate_fetch(sim_interface_enum simInterface);
void activate_fetch(sim_interface_enum simInterface);
extern void sim_get_full_path(sim_file_index_enum file_index, kal_uint8 *full_path);
/*******************************************************************************/
kal_bool is_sim1_test_sim(void);
#if defined( __GEMINI__)
kal_bool is_test_sim(kal_uint8 simInterface);
#else
kal_bool is_test_sim(void);
#endif
kal_bool is_test_sim_by_ps_id(protocol_id_enum ps_id);
usim_logic_channel_enum l4c_sim_get_app_channel_id(kal_uint8 simInterface, kal_uint8 applicationid);
#if defined(__ECALL_SUPPORT__) || defined(__NG_ECALL_SUPPORT__)
sim_ecall_mode_enum sim_ecall_mode_query(sim_interface_enum simInterface);
kal_bool sim_set_ecall_test_mode(sim_interface_enum simInterface,sim_ecall_mode_enum mode);
#endif
#ifdef __NG_ECALL_SUPPORT__
sim_ecall_mode_enum sim_ecall_mode_ims_query(sim_interface_enum simInterface);
#endif
#if defined( __GEMINI__)
sim_type_query_enum sim_query_type(sim_interface_enum which_sim);
#else
sim_type_query_enum sim_query_type(void);
#endif
sim_type_query_enum sim_query_type_by_ps_id(protocol_id_enum ps_id);
#if defined( __GEMINI__)
sim_service_state_enum sim_service_table_query(sim_service_enum service_id, kal_uint8 ps_id);
#else
sim_service_state_enum sim_service_table_query(sim_service_enum service_id);
#endif
sim_service_state_enum sim_service_table_query_by_ps_id(sim_service_enum service_id, protocol_id_enum ps_id);
#if defined(__GEMINI__)
sim_card_status_enum check_sim_card_status(kal_uint8 simInterface);
#else
sim_card_status_enum check_sim_card_status(void);
#endif
#if defined(__ICUSB_SUPPORT__) && defined(__MTK_TARGET__)
extern void sim_icusb_error_ind_call_back(kal_uint32 which_sim);
#endif
extern kal_bool is_sim_registered(kal_uint8 simInterface);
extern kal_uint8 sim_get_cdma_info(kal_uint8 sim_indx);
extern kal_bool sim_get_3GCT_card_info(kal_uint8 sim_indx);
extern kal_bool is_op20_imei_lock(kal_uint8 sim_indx);
extern kal_uint8 is_isim_exist(kal_uint8 sim_indx);
#ifdef __SAT__
kal_bool sat_set_profile_download_config(sat_profile_download_enum dl_setting, protocol_id_enum sim_ps_id);
sat_profile_download_enum sat_get_profile_download_config(protocol_id_enum sim_ps_id);
kal_bool sat_set_profile_activate_config(sat_profile_activate_enum act_setting, protocol_id_enum sim_ps_id);
sat_profile_activate_enum sat_get_profile_activate_config(protocol_id_enum sim_ps_id);
#endif
extern void usim_get_ust(kal_uint8* ust, kal_uint8 *ust_len, kal_uint8 sim_ps_id);
extern kal_uint8 sim_query_L1_SIM_insert_status(void);
extern kal_uint8 get_uicc_type_from_channel_id(kal_uint8 simInterface, kal_uint8 channel_id);
extern void l4c_usim_get_aid_info_by_channel(kal_uint8 simInterface, kal_uint8 applicationid, kal_uint8 *channel_id, kal_uint8* aid, kal_uint8 *aid_len, kal_uint8 *app_label, kal_uint8 *app_label_len);
extern kal_bool usim_is_uicc_app_exist(kal_uint8 sim_indx, kal_uint8 app_id);
/*******************************************************************************/
/* Add new functions */
/* Check whether SIM slot has card, including CT3G, UIM, recovery */
/* Workaround for CT3G recovery */
extern kal_bool sim_is_card_in_slot(kal_uint8 sim_ps_id);
/*
READ BINARY/RECORD from SIM file cache
Currently only support:
Default channel
Valid file_idx
SFI not used
*/
kal_bool sim_read_file_cache(kal_uint8 sim_ps_id,
sim_file_index_enum file_idx,
kal_uint32 cmd, // smu_common_enums.h - (smu_sim_access_cmd_enum) READ_BINARY or READ_RECORD
kal_uint16 fileid,
kal_uint8 *pathid,
kal_uint8 pathid_length,
kal_uint8 p1,
kal_uint8 p2,
kal_uint8 p3,
kal_uint8 channel_id,
kal_uint8 sfi,
kal_uint8 *res_data);
/* Pass ICCID stored in SIM context */
void sim_get_iccid(kal_uint8 sim_ps_id, kal_uint8 *iccid);
/*******************************************************************************/
#if defined (__GEMINI__)
kal_bool is_apvsim_on(kal_uint8 simInterface);
#else
kal_bool is_apvsim_on(void);
#endif
kal_bool sim_is_any_hotswap_poll_timer_start(void);
/*****************************************************************************
* FUNCTION
* sim_query_atr_info
* DESCRIPTION
* To query ATR info
* PARAMETERS
* length [OUT] ATR length
* atr [OUT] ATR value(Hex)
* ps_id [IN] which SIM
* RETURNS
* KAL_TRUE SIM exist
* KAL_FALSE SIM absent
* GLOBALS AFFECTED
* void
*****************************************************************************/
kal_bool sim_query_atr_info(kal_uint8 *length, kal_uint8 *atr, protocol_id_enum ps_id);
/*****************************************************************************
* FUNCTION
* sim_ps_data_off_exempt_query_by_ps_id
* DESCRIPTION
* Check if the service is 3GPP PS Data Off Exempt
* PARAMETERS
* exempt_id [IN] service to be queried
* this_sim
* RETURNS
* Boolean
* GLOBALS AFFECTED
* None
*****************************************************************************/
sim_ps_data_off_exempt_state_enum sim_ps_data_off_exempt_query_by_ps_id(sim_ps_data_off_exempt_enum exempt_id, protocol_id_enum ps_id);
extern kal_bool sim_get_if_immediate_auth_needed(kal_uint8 sim_ps_id);
extern void sim_set_immediate_auth_flag(kal_uint8 sim_ps_id);
/*****************************************************************************
* FUNCTION
* sim_check_curr_disable_by_ps
* DESCRIPTION
* To query the current ps sim state is disable or enable
* PARAMETERS
* sim_ps_id [IN] protocol id
* RETURNS
* Boolean Disable state
* GLOBALS AFFECTED
* None
*****************************************************************************/
extern kal_bool sim_check_curr_disable_by_ps(kal_uint8 sim_ps_id);
/*****************************************************************************
* FUNCTION
* sim_check_curr_disable_card_exist_by_ps
* DESCRIPTION
* To query the current ps sim state is disable or enable
* PARAMETERS
* sim_ps_id [IN] protocol id
* RETURNS
* Boolean Disable state and the card in slot
*****************************************************************************/
extern kal_bool sim_check_curr_disable_card_exist_by_ps (kal_uint8 sim_ps_id);
/*****************************************************************************
* FUNCTION
* sim_get_file_idx_from_path
* DESCRIPTION
* To get the sim file index from file path.
* PARAMETERS
* path [IN] the array carry the file id path
* path_len [IN] the valid path length
* app_type [IN] the file is belong to which application (ADF)
* RETURNS
* sim file index
* GLOBALS AFFECTED
* None
*****************************************************************************/
kal_uint32 sim_get_file_idx_from_path (const kal_uint8 *path, kal_uint16 path_len, uicc_app_type_enum app_type);
/*****************************************************************************
* FUNCTION
* sim_get_file_meta_cache_by_ps
* DESCRIPTION
* This function is to get the meta info of FCP data in sim context cache
* PARAMETERS
* sim_ps_id [IN] which PS to be check
* file_idx [IN] which file to be check
* file_exist [OUT] the file exist or not
* file_type [OUT] the file type. TRANSPARENT or RECORD type
* file_size [OUT] the file size for TRANSPARNET file/ the record size for RECORD file
* total_rec_num [OUT] total number of records.
* RETURNS
* Boolean FALSE means the file to be checked is not in sim context cache.
* GLOBALS AFFECTED
* void
*****************************************************************************/
kal_bool sim_get_file_meta_cache_by_ps(kal_uint8 sim_ps_id,
sim_file_index_enum file_idx,
kal_bool *file_exist,
sim_file_structure_enum *file_type,
kal_uint16 *file_size,
kal_uint16 *total_rec_num);
/*****************************************************************************
* FUNCTION
* sim_get_cached_file_size_by_ps
* DESCRIPTION
* Query SIM cached data profile by file index
* PARAMETERS
* sim_ps_id [IN] which PS to be check
* file_idx [IN] which file to be check
* cached_rec_num [OUT] the number of record cached
* cached_rec_size [OUT] the cached record size
* RETURNS
* KAL_TRUE The file in cache
* KAL_FALSE The file not in cache
* GLOBALS AFFECTED
* void
*****************************************************************************/
kal_bool sim_get_cached_file_size_by_ps (kal_uint8 sim_ps_id,
sim_file_index_enum file_idx,
kal_uint8 *cached_rec_num,
kal_uint16 *cached_rec_size);
/*****************************************************************************
* FUNCTION
* sim_get_cached_file_data_by_ps
* DESCRIPTION
* Get the SIM cached data by file index
* PARAMETERS
* sim_ps_id [IN] which PS to be check
* file_idx [IN] which file to be check
* cmd [IN] read command, READ_RECORD or READ_BINARY
* rec_id [IN] the 1-based record id to be read.
* res_buffer_size [IN] the size of the respose buffer, res_data
* res_data [OUT] the response buffer
* RETURNS
* The length of data in res_data buffer
* GLOBALS AFFECTED
* void
*****************************************************************************/
kal_uint16 sim_get_cached_file_data_by_ps (kal_uint8 sim_ps_id,
sim_file_index_enum file_idx,
kal_uint8 rec_id,
kal_uint16 res_buffer_size,
kal_uint8 *res_data);
/*****************************************************************************
* FUNCTION
* sim_query_operator_card
* DESCRIPTION
* Query the operator name based on ICCID/EHPLMN/IMSI in SIM context
* PARAMETERS
* ps_id [IN] which PS to be query
* RETURNS
* operator name
*****************************************************************************/
sim_operator_type_enum sim_query_operator_card(protocol_id_enum ps_id);
/*****************************************************************************
* FUNCTION
* is_extended_length_fields_support
* DESCRIPTION
* This function is to check if card supports extended length fields
* PARAMETERS
* ps_id [IN] which PS to be query
* RETURNS
* KAL_TRUE extended length fields supported
* KAL_FALSE extended length fields not supported
* GLOBALS AFFECTED
* void
*****************************************************************************/
kal_bool is_extended_length_fields_support(protocol_id_enum ps_id);
#ifdef __FAKEID_SUPPORT__
/*****************************************************************************
* FUNCTION
* sim_is_fake_imsi_by_ps_id
* DESCRIPTION
* This function is to check if the current protocol is using fake IMSI
* Caller should use this API after SIM ready
* PARAMETERS
* protocol_id_enum ps_id [?]
* RETURNS
* KAL_TRUE fake IMSI used
* KAL_FALSE fake IMSI not used
* GLOBALS AFFECTED
* void
*****************************************************************************/
extern kal_bool sim_is_fake_imsi_by_ps_id(protocol_id_enum ps_id);
/*****************************************************************************
* FUNCTION
* sim_get_fake_imsi
* DESCRIPTION
* This function is to get the fake IMSI set by the tester
* Caller should use this API after SIM ready
* Caller should allocate the MAX_SIM_IMSI_LEN memory for imsi_p
* PARAMETERS
* kal_uint8 sim_ps_id [IN]
* RETURNS
* imsi_p fake IMSI
* mnc_length_p MNC length of fake IMSI
* GLOBALS AFFECTED
* void
*****************************************************************************/
extern void sim_get_fake_imsi(protocol_id_enum sim_ps_id, kal_uint8 *imsi_p, kal_uint8 *mnc_length_p);
/*****************************************************************************
* FUNCTION
* sim_get_fake_gid1
* DESCRIPTION
* This function is to get the fake GID1 set by the tester
* Caller should use this API after SIM ready
* Caller should allocate the NUM_GID1 memory for gid1_p
* PARAMETERS
* kal_uint8 sim_ps_id [IN]
* RETURNS
* gid1_p fake GID1
* gid1_length_p GID1 length of fake GID1
* GLOBALS AFFECTED
* void
*****************************************************************************/
extern kal_bool sim_get_fake_gid1(protocol_id_enum ps_id, kal_uint8 *gid1_p, kal_uint8 *gid1_length_p);
#endif
/*****************************************************************************
* FUNCTION
* sim_is_euicc
* DESCRIPTION
* To check the present card is eUICC.
* PARAMETERS
* ps_id [IN] Protocol ID
* RETURNS
* KAL_TRUE SIM is eUICC
* KAL_FALSE SIM is not eUICC
* GLOBALS AFFECTED
* void
*****************************************************************************/
kal_bool sim_is_euicc(protocol_id_enum ps_id);
/*****************************************************************************
* FUNCTION
* sim_is_empty_euicc
* DESCRIPTION
* To check the present card is empty eUICC.
* PARAMETERS
* ps_id [IN] Protocol ID
* RETURNS
* KAL_TRUE SIM is empty eUICC
* KAL_FALSE SIM is not empty eUICC
* GLOBALS AFFECTED
* void
*****************************************************************************/
kal_bool sim_is_empty_euicc(protocol_id_enum ps_id);
/*****************************************************************************
* FUNCTION
* sim_query_eid
* DESCRIPTION
* To query EID
* PARAMETERS
* eid [OUT] EID value(Hex)
* ps_id [IN] Protocol ID
* RETURNS
* KAL_TRUE SIM exist and EID retrieved
* KAL_FALSE SIM absent or EID not retrieved
* GLOBALS AFFECTED
* void
*****************************************************************************/
kal_bool sim_query_eid(kal_uint8 *eid, protocol_id_enum ps_id);
#ifdef __SIM_MULTI_PIN__
/*****************************************************************************
* FUNCTION
* sim_get_app_pin_remaining_count_by_ps_id
* DESCRIPTION
*
* PARAMETERS
* RETURNS
* KAL_TRUE
* KAL_FALSE
*****************************************************************************/
kal_bool sim_get_app_pin_remaining_count_by_ps_id(uicc_app_type_enum app_type, sim_chv_info_struct *chv_info, protocol_id_enum ps_id);
#endif
/*****************************************************************************
* FUNCTION
* sim_get_imsi_null_suci_by_ps
* DESCRIPTION
* Get the SUCI with Null Scheme by protocol stack.
* PARAMETERS
* sim_ps_id [IN] which PS to be check
* res_len [IN/OUT] the size of suci_ptr buffer and the data length in suci_ptr for return
* suci_ptr [OUT] array buffer to carry response data
* RETURNS
* Result of process the command
*****************************************************************************/
kal_bool sim_get_imsi_null_suci_by_ps (kal_uint8 sim_ps_id, kal_uint16 *res_len, kal_uint8 *suci_ptr);
/*****************************************************************************
* FUNCTION
* usim_get_sfi_from_fcp
* DESCRIPTION
* Get the SFI (short file id) from FCP.
* Support of SFI for a specific file is indicated if the FCP of the file contains a
* TLV DO with tag '88'. If the length is 0 it indicates that the file does not support
* referencing by SFI. If the TLV DO is not present in the FCP it indicates that the
* 5 least significant bits of the FID are used as SFI.
* PARAMETERS
* fcp [IN] fcp data to be checked
* fcp_len [IN] the length of whole fcp data
* RETURNS
* SFI. 0 means no SFI found
*****************************************************************************/
kal_uint8 usim_get_sfi_from_fcp (kal_uint8 *fcp, kal_uint16 fcp_len);
#ifdef __TC10__
extern void sim_get_last_commnad_APDU(kal_uint8 simInterface, kal_uint8 *command_header_p);
extern sim_dss_state_enum sim_get_dss_state(protocol_id_enum ps_id); /*ALPS03779598*/
/*****************************************************************************
* FUNCTION
* sim_check_hplmnwact_3g_only
* DESCRIPTION
* To query E-UTRAN bit available from EF_HPLMNwAcT.
* PARAMETERS
* ps_id [IN] Protocol ID
* RETURNS
* KAL_TRUE VzW 3G USIM not supported condition match, i.e. no E-UTRAN in HPLMNwAcT
*****************************************************************************/
kal_bool sim_check_hplmnwact_3g_only(protocol_id_enum ps_id);
extern kal_bool sim_query_vzpf(kal_uint8 *vzpf, protocol_id_enum ps_id);
#endif
extern kal_bool sim_query_gid1(kal_uint8 *gid1, protocol_id_enum ps_id);
extern kal_bool sim_query_gid2(kal_uint8 *gid2, protocol_id_enum ps_id);
extern kal_uint8 sim_query_voltage_info(protocol_id_enum ps_id);
extern kal_uint8 sim_query_tray_info(protocol_id_enum ps_id);
extern kal_bool sim_check_operator_card(sim_operator_type_enum operator_type, kal_uint8 sim_indx);
extern kal_bool sim_check_operator_card_by_iccid(sim_operator_type_enum operator_type, kal_uint8 sim_indx);
extern sim_op01_enum sim_query_op_mode(kal_uint8 ps_id);
#ifdef __TC10_JPN_FACTORY__
extern void sim_set_factory_mode(kal_bool is_factory);
#endif
#ifdef __SIM_TERMINAL_CAP__
void sim_get_host_terminal_capabilities_by_ps_id(kal_uint16 tc_data_len, kal_uint8 *tc_data_ptr, protocol_id_enum ps_id);
#endif
#ifdef __SIM_PASS_THROUGH__
/*****************************************************************************
* FUNCTION
* sim_get_esimpower_state_by_ps_id
* DESCRIPTION
* To query the current esimpower state ps sim
* PARAMETERS
* sim_ps_id [IN] protocol id
* RETURNS
* ESIMPOWER state
*****************************************************************************/
sim_esimpower_state_enum sim_get_esimpower_state_by_ps_id(protocol_id_enum ps_id);
#endif
#endif