FreeCalypso > hg > fc-magnetite
comparison src/g23m-gsm/sim/sim_pei.c @ 104:27a4235405c6
src/g23m-gsm: import from LoCosto source
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Tue, 04 Oct 2016 18:24:05 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 103:76d139c7a25e | 104:27a4235405c6 |
|---|---|
| 1 /* | |
| 2 +----------------------------------------------------------------------------- | |
| 3 | Project : GSM-F&D (8411) | |
| 4 | Modul : SIM_PEI | |
| 5 +----------------------------------------------------------------------------- | |
| 6 | Copyright 2004 Texas Instruments | |
| 7 | All rights reserved. | |
| 8 | | |
| 9 | This file is confidential and a trade secret of Texas | |
| 10 | Instruments | |
| 11 | The receipt of or possession of this file does not convey | |
| 12 | any rights to reproduce or disclose its contents or to | |
| 13 | manufacture, use, or sell anything it may describe, in | |
| 14 | whole, or in part, without the specific written consent of | |
| 15 | Texas Instruments. | |
| 16 +----------------------------------------------------------------------------- | |
| 17 | Purpose : This Modul defines the process body interface | |
| 18 | for the component SIM of the mobile station | |
| 19 +----------------------------------------------------------------------------- | |
| 20 */ | |
| 21 | |
| 22 #ifndef SIM_PEI_C | |
| 23 #define SIM_PEI_C | |
| 24 | |
| 25 #define ENTITY_SIM | |
| 26 | |
| 27 /*==== INCLUDES ===================================================*/ | |
| 28 | |
| 29 #include <string.h> | |
| 30 #include "typedefs.h" | |
| 31 #include "pconst.cdg" | |
| 32 #include "mconst.cdg" | |
| 33 #include "message.h" | |
| 34 #include "ccdapi.h" | |
| 35 #include "vsi.h" | |
| 36 #include "custom.h" | |
| 37 #include "gsm.h" | |
| 38 #include "prim.h" | |
| 39 #include "cnf_sim.h" | |
| 40 #include "mon_sim.h" | |
| 41 #include "pei.h" | |
| 42 #include "tok.h" | |
| 43 #include "sim.h" | |
| 44 #include "sim_em.h" | |
| 45 #include "cl_shrd.h" | |
| 46 | |
| 47 #ifdef TI_PS_UICC_CHIPSET_15 | |
| 48 #include "8010_136_SIMDRV_SAP_inline.h" | |
| 49 #endif | |
| 50 | |
| 51 | |
| 52 /*==== EXPORT =====================================================*/ | |
| 53 #ifdef TI_PS_HCOMM_CHANGE | |
| 54 #ifdef FF_SAT_E | |
| 55 T_HANDLE hCommUDP = VSI_ERROR; /* UDP Communication */ | |
| 56 #endif /* FF_SAT_E */ | |
| 57 #if defined (GPRS) | |
| 58 T_HANDLE hCommGMM = VSI_ERROR; /* SMS Communication */ | |
| 59 #endif /* GPRS */ | |
| 60 T_HANDLE sim_handle; | |
| 61 #else | |
| 62 T_HANDLE hCommMMI = VSI_ERROR; /* MMI Communication */ | |
| 63 T_HANDLE hCommMM = VSI_ERROR; /* MM Communication */ | |
| 64 T_HANDLE hCommSMS = VSI_ERROR; /* SMS Communication */ | |
| 65 #ifdef FF_SAT_E | |
| 66 T_HANDLE hCommUDP = VSI_ERROR; /* UDP Communication */ | |
| 67 #endif /* FF_SAT_E */ | |
| 68 #ifdef _SIMULATION_ | |
| 69 T_HANDLE hCommSIM = VSI_ERROR; /* TEST CASES: TAP Communication */ | |
| 70 #endif | |
| 71 #if defined (GPRS) | |
| 72 T_HANDLE hCommGMM = VSI_ERROR; /* SMS Communication */ | |
| 73 #endif /* GPRS */ | |
| 74 T_HANDLE sim_handle; | |
| 75 #endif /* TI_PS_HCOMM_CHANGE */ | |
| 76 | |
| 77 | |
| 78 #ifdef OPTION_RELATIVE | |
| 79 ULONG offset; | |
| 80 #endif | |
| 81 | |
| 82 T_SIM_DATA sim_data; | |
| 83 | |
| 84 /*==== PRIVATE ====================================================*/ | |
| 85 | |
| 86 #ifdef FF_SAT_E | |
| 87 #define pei_dti_getdata_req _ENTITY_PREFIXED(pei_dti_getdata_req) | |
| 88 #define pei_dti_disconnect_ind _ENTITY_PREFIXED(pei_dti_disconnect_ind) | |
| 89 #define pei_dti_ready_ind _ENTITY_PREFIXED(pei_dti_ready_ind) | |
| 90 #define pei_dti_data_req _ENTITY_PREFIXED(pei_dti_data_req) | |
| 91 #define pei_dti_data_ind _ENTITY_PREFIXED(pei_dti_data_ind) | |
| 92 #define pei_dti_callback _ENTITY_PREFIXED(pei_dti_callback) | |
| 93 #define pei_dti_data_test_req _ENTITY_PREFIXED(pei_dti_data_test_req) | |
| 94 #define pei_dti_data_test_ind _ENTITY_PREFIXED(pei_dti_data_test_ind) | |
| 95 #endif /* FF_SAT_E */ | |
| 96 | |
| 97 static void pei_not_supported (void * data); | |
| 98 #ifdef SIM_TOOLKIT | |
| 99 static void sim_timeout (USHORT index); | |
| 100 #ifdef FF_SAT_E | |
| 101 LOCAL void pei_dti_getdata_req(T_DTI2_GETDATA_REQ* dti_getdata_req); | |
| 102 LOCAL void pei_dti_disconnect_ind(T_DTI2_DISCONNECT_IND *dti_disconnect_ind); | |
| 103 LOCAL void pei_dti_ready_ind(T_DTI2_READY_IND* dti_ready_ind); | |
| 104 LOCAL void pei_dti_data_req(T_DTI2_DATA_REQ* dti_data_req); | |
| 105 LOCAL void pei_dti_data_ind(T_DTI2_DATA_IND* dti_data_ind); | |
| 106 LOCAL void pei_dti_callback(UBYTE instance, | |
| 107 UBYTE interfac, | |
| 108 UBYTE channel, | |
| 109 UBYTE reason, | |
| 110 T_DTI2_DATA_IND* dti_data_ind); | |
| 111 #ifdef _SIMULATION_ | |
| 112 LOCAL const void pei_dti_data_test_req(T_DTI2_DATA_TEST_REQ* dti_data_test_req); | |
| 113 LOCAL const void pei_dti_data_test_ind(T_DTI2_DATA_TEST_IND* dti_data_test_ind); | |
| 114 #endif /* _SIMULATION_ */ | |
| 115 #endif /* FF_SAT_E */ | |
| 116 #endif /* else SIM_TOOLKIT */ | |
| 117 | |
| 118 #define SIM_TIMEOUT(_x_) sim_timeout(_x_) | |
| 119 | |
| 120 static void sim_chk_retry_failure (void); | |
| 121 | |
| 122 /*==== VARIABLES ==================================================*/ | |
| 123 #ifdef _SIMULATION_ | |
| 124 static BOOL first_access = TRUE; | |
| 125 #endif /* _SIMULATION_ */ | |
| 126 static T_MONITOR sim_mon; | |
| 127 static BOOL sleepTimerRunning =FALSE; | |
| 128 extern BOOL startTimerPollOff; | |
| 129 | |
| 130 /*==== FUNCTIONS ==================================================*/ | |
| 131 | |
| 132 #ifdef FF_SAT_E | |
| 133 LOCAL void pei_dti_getdata_req(T_DTI2_GETDATA_REQ* dti_getdata_req) | |
| 134 { | |
| 135 dti_dti_getdata_req(sim_data.hDTI, dti_getdata_req); | |
| 136 } /* pei_dti_getdata_req() */ | |
| 137 | |
| 138 LOCAL void pei_dti_disconnect_ind(T_DTI2_DISCONNECT_IND *dti_disconnect_ind) | |
| 139 { | |
| 140 dti_dti_disconnect_ind (sim_data.hDTI, dti_disconnect_ind); | |
| 141 }/* pei_dti_disconnect_ind() */ | |
| 142 | |
| 143 LOCAL void pei_dti_ready_ind(T_DTI2_READY_IND* dti_ready_ind) | |
| 144 { | |
| 145 dti_dti_ready_ind(sim_data.hDTI, dti_ready_ind); | |
| 146 } /* pei_dti_ready_ind() */ | |
| 147 | |
| 148 LOCAL void pei_dti_data_req(T_DTI2_DATA_REQ* dti_data_req) | |
| 149 { | |
| 150 dti_dti_data_req(sim_data.hDTI, dti_data_req); | |
| 151 } /* pei_dti_data_req() */ | |
| 152 | |
| 153 LOCAL void pei_dti_data_ind(T_DTI2_DATA_IND* dti_data_ind) | |
| 154 { | |
| 155 dti_dti_data_ind(sim_data.hDTI, dti_data_ind); | |
| 156 } /* pei_dti_data_ind() */ | |
| 157 | |
| 158 LOCAL void pei_dti_callback(U8 instance, | |
| 159 U8 interfac, | |
| 160 U8 channel, | |
| 161 U8 reason, | |
| 162 T_DTI2_DATA_IND* dti_data_ind) | |
| 163 { | |
| 164 TRACE_FUNCTION ("pei_dti_callback()"); /*###jk:tbd*/ | |
| 165 TRACE_EVENT_P1("pei_dti_callback: reason = %2d", reason); /*###jk:tbd*/ | |
| 166 switch(reason) | |
| 167 { | |
| 168 case DTI_REASON_CONNECTION_OPENED: | |
| 169 stk_dti_connection_opened(); | |
| 170 break; | |
| 171 | |
| 172 case DTI_REASON_CONNECTION_CLOSED: | |
| 173 stk_dti_connection_closed(); | |
| 174 break; | |
| 175 | |
| 176 case DTI_REASON_DATA_RECEIVED: | |
| 177 stk_dti_data_received(dti_data_ind); | |
| 178 break; | |
| 179 | |
| 180 case DTI_REASON_TX_BUFFER_FULL: | |
| 181 stk_dti_tx_buffer_full(); | |
| 182 break; | |
| 183 | |
| 184 case DTI_REASON_TX_BUFFER_READY: | |
| 185 stk_dti_tx_buffer_ready(); | |
| 186 break; | |
| 187 } | |
| 188 } /* pei_dti_callback() */ | |
| 189 | |
| 190 LOCAL void pei_dti_connect_ind ( | |
| 191 T_DTI2_CONNECT_IND *dti_connect_ind | |
| 192 ) | |
| 193 { | |
| 194 dti_dti_connect_ind(sim_data.hDTI, dti_connect_ind); | |
| 195 } | |
| 196 | |
| 197 LOCAL void pei_dti_connect_cnf ( | |
| 198 T_DTI2_CONNECT_CNF *dti_connect_cnf | |
| 199 ) | |
| 200 { | |
| 201 dti_dti_connect_cnf(sim_data.hDTI, dti_connect_cnf); | |
| 202 } | |
| 203 | |
| 204 | |
| 205 #ifdef _SIMULATION_ | |
| 206 LOCAL const void pei_dti_data_test_req(T_DTI2_DATA_TEST_REQ* dti_data_test_req) | |
| 207 { | |
| 208 dti_dti_data_test_req(sim_data.hDTI, dti_data_test_req); | |
| 209 } /* pei_dti_data_test_req() */ | |
| 210 | |
| 211 LOCAL const void pei_dti_data_test_ind(T_DTI2_DATA_TEST_IND* dti_data_test_ind) | |
| 212 { | |
| 213 dti_dti_data_test_ind(sim_data.hDTI, dti_data_test_ind); | |
| 214 } /* pei_dti_data_test_ind() */ | |
| 215 #endif /* _SIMULATION_ */ | |
| 216 #endif /* FF_SAT_E */ | |
| 217 | |
| 218 LOCAL const T_FUNC sim_table[] = { | |
| 219 MAK_FUNC_0 (app_sim_read_req, SIM_READ_REQ ), /* 0x80004005 */ | |
| 220 MAK_FUNC_0 (app_sim_update_req, SIM_UPDATE_REQ ), /* 0x80014005 */ | |
| 221 MAK_FUNC_0 (app_sim_read_record_req, SIM_READ_RECORD_REQ ), /* 0x80024005 */ | |
| 222 MAK_FUNC_N (pei_not_supported, 0 ), /* 0x80034005 */ | |
| 223 MAK_FUNC_0 (app_sim_update_record_req, SIM_UPDATE_RECORD_REQ ), /* 0x80044005 */ | |
| 224 MAK_FUNC_N (pei_not_supported, 0 ), /* 0x80054005 */ | |
| 225 MAK_FUNC_N (pei_not_supported, 0 ), /* 0x80064005 */ | |
| 226 #if defined SIM_TOOLKIT AND defined TI_PS_FF_AT_P_CMD_CUST | |
| 227 MAK_FUNC_0 (stk_sim_refresh_user_res, SIM_REFRESH_USER_RES ), /* */ | |
| 228 #else /* SIM_TOOLKIT */ | |
| 229 MAK_FUNC_N (pei_not_supported, 0 ), /* 0x80074005 */ | |
| 230 #endif /* else SIM_TOOLKIT */ | |
| 231 MAK_FUNC_0 (app_sim_increment_req, SIM_INCREMENT_REQ ), /* 0x80084005 */ | |
| 232 MAK_FUNC_0 (app_sim_verify_pin_req, SIM_VERIFY_PIN_REQ ), /* 0x80094005 */ | |
| 233 MAK_FUNC_0 (app_sim_change_pin_req, SIM_CHANGE_PIN_REQ ), /* 0x800a4005 */ | |
| 234 MAK_FUNC_0 (app_sim_disable_pin_req, SIM_DISABLE_PIN_REQ ), /* 0x800b4005 */ | |
| 235 MAK_FUNC_0 (app_sim_enable_pin_req, SIM_ENABLE_PIN_REQ ), /* 0x800c4005 */ | |
| 236 MAK_FUNC_0 (app_sim_unblock_req, SIM_UNBLOCK_REQ ), /* 0x800d4005 */ | |
| 237 MAK_FUNC_0 (app_sim_auth_req, SIM_AUTHENTICATION_REQ ), /* 0x800e4005 */ | |
| 238 MAK_FUNC_0 (app_sim_mm_update_req, SIM_MM_UPDATE_REQ ), /* 0x800f4005 */ | |
| 239 MAK_FUNC_0 (app_sim_sync_req, SIM_SYNC_REQ ), /* 0x80104005 */ | |
| 240 MAK_FUNC_0 (app_sim_activate_req, SIM_ACTIVATE_REQ ), /* 0x80114005 */ | |
| 241 #if defined SIM_TOOLKIT | |
| 242 MAK_FUNC_0 (stk_sim_toolkit_req, SIM_TOOLKIT_REQ ), /* 0x80124005 */ | |
| 243 MAK_FUNC_0 (stk_sim_toolkit_res, SIM_TOOLKIT_RES ), /* 0x80134005 */ | |
| 244 #else /* SIM_TOOLKIT */ | |
| 245 MAK_FUNC_N (pei_not_supported, 0 ), /* 0x80124005 */ | |
| 246 MAK_FUNC_N (pei_not_supported, 0 ), /* 0x80134005 */ | |
| 247 #endif /* else SIM_TOOLKIT */ | |
| 248 MAK_FUNC_0 (app_sim_access_req, SIM_ACCESS_REQ ), /* 0x80144005 */ | |
| 249 #if defined SIM_TOOLKIT | |
| 250 MAK_FUNC_0 (stk_file_update_res, SIM_FILE_UPDATE_RES ), /* 0x80154005 */ | |
| 251 #else /* SIM_TOOLKIT */ | |
| 252 MAK_FUNC_N (pei_not_supported, 0 ), /* 0x80154005 */ | |
| 253 #endif /* else SIM_TOOLKIT */ | |
| 254 #if defined GPRS | |
| 255 MAK_FUNC_0 (gprs_sim_gmm_update_req, SIM_GMM_UPDATE_REQ ), /* 0x80164005 */ | |
| 256 #else /* GPRS */ | |
| 257 MAK_FUNC_N (pei_not_supported, 0 ), /* 0x80164005 */ | |
| 258 #endif /* else GPRS */ | |
| 259 #if defined FF_SAT_E | |
| 260 MAK_FUNC_0 (stk_sim_dti_req, SIM_DTI_REQ ), /* 0x80174005 */ | |
| 261 MAK_FUNC_0 (stk_sim_bip_req, SIM_BIP_REQ ), /* 0x80184005 */ | |
| 262 MAK_FUNC_0 (stk_sim_bip_config_req, SIM_BIP_CONFIG_REQ ), /* 0x80194005 */ | |
| 263 MAK_FUNC_0 (stk_sim_eventlist_req, SIM_EVENTLIST_REQ ), /* 0x801a4005 */ | |
| 264 #else | |
| 265 MAK_FUNC_N (pei_not_supported, 0 ), /* 0x80174005 */ | |
| 266 MAK_FUNC_N (pei_not_supported, 0 ), /* 0x80184005 */ | |
| 267 MAK_FUNC_N (pei_not_supported, 0 ), /* 0x80194005 */ | |
| 268 MAK_FUNC_N (pei_not_supported, 0 ), /* 0x801a4005 */ | |
| 269 #endif /* FF_SAT_E */ | |
| 270 }; | |
| 271 | |
| 272 #ifdef FF_SAT_E | |
| 273 LOCAL const T_FUNC dti_dl_table[] = | |
| 274 { | |
| 275 MAK_FUNC_0(pei_dti_connect_ind, DTI2_CONNECT_IND), /* 0x7750 */ | |
| 276 MAK_FUNC_0(pei_dti_connect_cnf, DTI2_CONNECT_CNF), /* 0x7751 */ | |
| 277 MAK_FUNC_0(pei_dti_disconnect_ind, DTI2_DISCONNECT_IND), /* 0x7752 */ | |
| 278 MAK_FUNC_0(pei_dti_ready_ind, DTI2_READY_IND), /* 0x7753 */ | |
| 279 MAK_FUNC_0(pei_dti_data_ind, DTI2_DATA_IND), /* 0x7754 */ | |
| 280 #ifdef _SIMULATION_ | |
| 281 MAK_FUNC_S(pei_dti_data_test_ind, DTI2_DATA_TEST_IND) /* 0x7755 */ | |
| 282 #else | |
| 283 MAK_FUNC_S(pei_not_supported, DTI2_DATA_TEST_IND) /* 0x7755 */ | |
| 284 #endif /* _SIMULATION_ */ | |
| 285 }; | |
| 286 | |
| 287 LOCAL const T_FUNC dti_ul_table[] = | |
| 288 { | |
| 289 MAK_FUNC_0(pei_not_supported, DTI2_CONNECT_REQ), /* 0x3750 */ | |
| 290 MAK_FUNC_0(pei_not_supported, DTI2_CONNECT_RES), /* 0x3751 */ | |
| 291 MAK_FUNC_0(pei_not_supported, DTI2_DISCONNECT_REQ ), /* 0x3752 */ | |
| 292 MAK_FUNC_0(pei_dti_getdata_req, DTI2_GETDATA_REQ), /* 0x3753 */ | |
| 293 MAK_FUNC_0(pei_dti_data_req, DTI2_DATA_REQ), /* 0x3754 */ | |
| 294 #ifdef _SIMULATION_ | |
| 295 MAK_FUNC_S(pei_dti_data_test_req, DTI2_DATA_TEST_REQ) /* 0x3755 */ | |
| 296 #else | |
| 297 MAK_FUNC_S(pei_not_supported, DTI2_DATA_TEST_REQ) /* 0x3755 */ | |
| 298 #endif /* _SIMULATION_ */ | |
| 299 }; | |
| 300 | |
| 301 LOCAL const T_FUNC udp_table[] = | |
| 302 { | |
| 303 MAK_FUNC_0(stk_udp_bind_cnf, UDP_BIND_CNF), /* 0x80004046 */ | |
| 304 MAK_FUNC_0(stk_udp_closeport_cnf, UDP_CLOSEPORT_CNF), /* 0x80014046 */ | |
| 305 MAK_FUNC_0(stk_udp_error_ind, UDP_ERROR_IND), /* 0x80024046 */ | |
| 306 MAK_FUNC_0(stk_udp_shutdown_ind, UDP_SHUTDOWN_IND) /* 0x80034046 */ | |
| 307 }; | |
| 308 #endif /* FF_SAT_E */ | |
| 309 | |
| 310 #ifdef FF_EM_MODE | |
| 311 LOCAL const T_FUNC em_table[] = { | |
| 312 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x00 */ | |
| 313 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x01 */ | |
| 314 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x02 */ | |
| 315 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x03 */ | |
| 316 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x04 */ | |
| 317 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x05 */ | |
| 318 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x06 */ | |
| 319 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x07 */ | |
| 320 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x08 */ | |
| 321 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x09 */ | |
| 322 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x0A */ | |
| 323 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x0B */ | |
| 324 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x0C */ | |
| 325 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x0D */ | |
| 326 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x0E */ | |
| 327 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x0F */ | |
| 328 MAK_FUNC_0 (sim_em_sim_event_req , EM_SIM_EVENT_REQ ) /* 0x10 */ | |
| 329 }; | |
| 330 #endif /* FF_EM_MODE */ | |
| 331 | |
| 332 | |
| 333 /* | |
| 334 +--------------------------------------------------------------------+ | |
| 335 | PROJECT : GSM-PS (6302) MODULE : SIM_PEI | | |
| 336 | STATE : code ROUTINE : pei_primitive | | |
| 337 +--------------------------------------------------------------------+ | |
| 338 | |
| 339 PURPOSE : Process protocol specific primitive. | |
| 340 | |
| 341 */ | |
| 342 LOCAL SHORT pei_primitive (void * ptr) | |
| 343 { | |
| 344 T_PRIM *prim = ptr; | |
| 345 | |
| 346 /* | |
| 347 * | | | |
| 348 * DTI2 SIM UPLINK | |
| 349 * | | | |
| 350 * +---------v------v---------+ | |
| 351 * | | | |
| 352 * | SIM | | |
| 353 * | | | |
| 354 * +--------------------------+ | |
| 355 * | |
| 356 */ | |
| 357 | |
| 358 TRACE_FUNCTION ("pei_primitive()"); | |
| 359 | |
| 360 if (prim NEQ NULL) | |
| 361 { | |
| 362 ULONG opc = prim->custom.opc; | |
| 363 USHORT n, loc_sap_nr; | |
| 364 const T_FUNC *table; | |
| 365 | |
| 366 VSI_PPM_REC ((T_PRIM_HEADER*)prim, __FILE__, __LINE__); | |
| 367 | |
| 368 PTRACE_IN (opc); | |
| 369 loc_sap_nr = SAP_NR(opc); | |
| 370 switch (loc_sap_nr) | |
| 371 { | |
| 372 case SAP_NR(SIM_DL): table = sim_table; n = TAB_SIZE (sim_table); break; | |
| 373 #ifdef FF_SAT_E | |
| 374 case SAP_NR(UDP_DL): table = udp_table; n = TAB_SIZE (udp_table); break; | |
| 375 case SAP_NR(DTI2_DL): table = dti_dl_table; n = TAB_SIZE (dti_dl_table); | |
| 376 opc -= 0x50; /* DTI2 opcodes start at 0x50 */ | |
| 377 break; | |
| 378 case SAP_NR(DTI2_UL): table = dti_ul_table; n = TAB_SIZE (dti_ul_table); | |
| 379 opc -= 0x50; /* DTI2 opcodes start at 0x50 */ | |
| 380 break; | |
| 381 #endif /* FF_SAT_E */ | |
| 382 #ifdef FF_EM_MODE | |
| 383 case SAP_NR(EM_Ul): table = em_table; n = TAB_SIZE (em_table); break; | |
| 384 #endif /* FF_EM_MODE */ | |
| 385 default: table = NULL; n = 0; break; | |
| 386 } /* switch (SAP_NR(opc)) */ | |
| 387 | |
| 388 if (table != NULL ) | |
| 389 { | |
| 390 if (PRIM_NR(opc) < n) | |
| 391 { | |
| 392 if(sleepTimerRunning == TRUE) | |
| 393 { | |
| 394 TIMER_STOP(sim_handle,SLEEP_TIMER); | |
| 395 sleepTimerRunning = FALSE; | |
| 396 } | |
| 397 table += PRIM_NR(opc); | |
| 398 JUMP(table->func)(P2D(prim)); | |
| 399 #ifdef SIM_TOOLKIT | |
| 400 if (sim_data.chk_sat_avail) | |
| 401 { | |
| 402 sim_data.chk_sat_avail = FALSE; | |
| 403 stk_proactive_polling(); | |
| 404 } | |
| 405 #endif /* SIM_TOOLKIT */ | |
| 406 | |
| 407 sleepTimerRunning = TRUE; | |
| 408 TIMER_START(sim_handle,SLEEP_TIMER,100); /* no primitives in next 100 m secs go for Sleep*/ | |
| 409 sim_chk_retry_failure (); | |
| 410 } | |
| 411 else | |
| 412 { | |
| 413 pei_not_supported (P2D(prim)); | |
| 414 } | |
| 415 return PEI_OK; | |
| 416 } | |
| 417 /* | |
| 418 * Primitive is no GSM Primitive | |
| 419 * then forward to the environment | |
| 420 */ | |
| 421 #ifdef GSM_ONLY | |
| 422 PFREE (P2D(prim)) | |
| 423 return PEI_ERROR; | |
| 424 #else | |
| 425 if (opc & SYS_MASK) | |
| 426 vsi_c_primitive (VSI_CALLER prim); | |
| 427 else | |
| 428 { | |
| 429 PFREE (P2D(prim)); | |
| 430 } | |
| 431 return PEI_ERROR; | |
| 432 #endif | |
| 433 } | |
| 434 return PEI_OK; | |
| 435 } | |
| 436 | |
| 437 /* | |
| 438 +--------------------------------------------------------------------+ | |
| 439 | PROJECT : GSM-PS (6302) MODULE : SIM_PEI | | |
| 440 | STATE : code ROUTINE : pei_not_supported | | |
| 441 +--------------------------------------------------------------------+ | |
| 442 | |
| 443 PURPOSE : An unsupported primitive is received. | |
| 444 | |
| 445 */ | |
| 446 | |
| 447 static void pei_not_supported (void * data) | |
| 448 { | |
| 449 TRACE_FUNCTION ("pei_not_supported()"); | |
| 450 | |
| 451 PFREE (data); | |
| 452 } | |
| 453 | |
| 454 /* | |
| 455 +--------------------------------------------------------------------+ | |
| 456 | PROJECT : GSM-PS (6302) MODULE : SIM_PEI | | |
| 457 | STATE : code ROUTINE : sim_chk_retry_failure | | |
| 458 +--------------------------------------------------------------------+ | |
| 459 | |
| 460 PURPOSE : check for driver retry failure to start SIM re-initialisation. | |
| 461 | |
| 462 */ | |
| 463 | |
| 464 void sim_chk_retry_failure (void) | |
| 465 { | |
| 466 #ifdef TI_PS_UICC_CHIPSET_15 | |
| 467 U8 readerId = SIMDRV_VAL_READER_ID__RANGE_MIN; | |
| 468 U8 voltageSelect = SIMDRV_REQ_VOLTAGE_SEL; | |
| 469 #else | |
| 470 T_SIM_CARD sim_info; | |
| 471 #endif | |
| 472 if (SIM_IS_FLAG_SET(DRV_FAILED_RETRY)) | |
| 473 { | |
| 474 | |
| 475 TRACE_EVENT("SIM RETRY FAILURE"); | |
| 476 | |
| 477 if (SIM_IS_FLAG_CLEARED(CALL_ACTIVE)) | |
| 478 { | |
| 479 PALLOC (sim_remove_ind_to_mmi, SIM_REMOVE_IND); | |
| 480 sim_remove_ind_to_mmi->cause = SIM_CAUSE_DRV_TEMPFAIL; | |
| 481 PSENDX (MMI, sim_remove_ind_to_mmi); | |
| 482 | |
| 483 #ifndef TI_PS_UICC_CHIPSET_15 | |
| 484 SIM_PowerOff (); | |
| 485 #else | |
| 486 simdrv_poweroff ( readerId ); | |
| 487 #endif | |
| 488 | |
| 489 sim_data.act_directory = NOT_PRESENT_16BIT; | |
| 490 sim_data.act_field = NOT_PRESENT_16BIT; | |
| 491 | |
| 492 TIMER_START (sim_handle, SIM_TIMER, T_DETECT_VALUE); | |
| 493 SIM_CLEAR_FLAG (SIM_INSERT); | |
| 494 | |
| 495 #ifndef TI_PS_UICC_CHIPSET_15 | |
| 496 if (SIM_Reset (&sim_info) NEQ 0) | |
| 497 #else | |
| 498 if (simdrv_reset( readerId, voltageSelect) NEQ 0) | |
| 499 #endif | |
| 500 { | |
| 501 TIMER_STOP (sim_handle, SIM_TIMER); | |
| 502 app_sim_remove(); | |
| 503 } | |
| 504 } | |
| 505 else | |
| 506 { | |
| 507 SIM_CLEAR_FLAG (SIM_INSERT); | |
| 508 app_sim_remove(); | |
| 509 } | |
| 510 SIM_CLEAR_FLAG(DRV_FAILED_RETRY); | |
| 511 } | |
| 512 } | |
| 513 | |
| 514 /* | |
| 515 +--------------------------------------------------------------------+ | |
| 516 | PROJECT : GSM-PS (6302) MODULE : SIM_PEI | | |
| 517 | STATE : code ROUTINE : pei_init | | |
| 518 +--------------------------------------------------------------------+ | |
| 519 | |
| 520 PURPOSE : Initialize Protocol Stack Entity | |
| 521 | |
| 522 */ | |
| 523 LOCAL SHORT pei_init (T_HANDLE handle) | |
| 524 { | |
| 525 sim_handle = handle; | |
| 526 | |
| 527 TRACE_FUNCTION ("pei_init()"); | |
| 528 | |
| 529 #ifdef TI_PS_HCOMM_CHANGE | |
| 530 if (!cl_hcom_all_handles_open()) | |
| 531 { | |
| 532 return PEI_ERROR; | |
| 533 } | |
| 534 #else /* for hCommHandles backward compatibility */ | |
| 535 if (hCommMMI < VSI_OK) | |
| 536 { | |
| 537 /* | |
| 538 * Open MMI (Layer 4) | |
| 539 */ | |
| 540 | |
| 541 if ((hCommMMI = vsi_c_open (VSI_CALLER ACI_NAME)) < VSI_OK) | |
| 542 return PEI_ERROR; | |
| 543 } | |
| 544 | |
| 545 if (hCommMM < VSI_OK) | |
| 546 { | |
| 547 if ((hCommMM = vsi_c_open (VSI_CALLER MM_NAME)) < VSI_OK) | |
| 548 return PEI_ERROR; | |
| 549 } | |
| 550 | |
| 551 if (hCommSMS < VSI_OK) | |
| 552 { | |
| 553 if ((hCommSMS = vsi_c_open (VSI_CALLER SMS_NAME)) < VSI_OK) | |
| 554 return PEI_ERROR; | |
| 555 } | |
| 556 | |
| 557 #ifdef _SIMULATION_ | |
| 558 if (hCommSIM < VSI_OK) /* get comhandle in order to be able to use the */ | |
| 559 { /* Funktion vsi_c_await() in the sim_csf.c module */ | |
| 560 if ((hCommSIM = vsi_c_open (VSI_CALLER SIM_NAME)) < VSI_OK) | |
| 561 return PEI_ERROR; | |
| 562 } | |
| 563 #endif /* _SIMULATION_ */ | |
| 564 #endif /* TI_PS_HCOMM_CHANGE */ | |
| 565 | |
| 566 #if defined (GPRS) | |
| 567 if (hCommGMM < VSI_OK) | |
| 568 { | |
| 569 if ((hCommGMM = vsi_c_open (VSI_CALLER GMM_NAME)) < VSI_OK) | |
| 570 return PEI_ERROR; | |
| 571 } | |
| 572 #endif | |
| 573 | |
| 574 #ifdef SIM_TOOLKIT | |
| 575 #ifdef FF_SAT_E | |
| 576 /* | |
| 577 * DTI initialization | |
| 578 */ | |
| 579 sim_data.hDTI = dti_init(1, handle, DTI_DEFAULT_OPTIONS, pei_dti_callback); | |
| 580 hCommUDP = VSI_ERROR; | |
| 581 #endif /* FF_SAT_E */ | |
| 582 stk_init_sim_data(); | |
| 583 #endif /* SIM_TOOLKIT */ | |
| 584 | |
| 585 app_init_sim_data (); | |
| 586 ccd_init (); | |
| 587 #if defined (_SIMULATION_) | |
| 588 sim_data.mode = 0; | |
| 589 #endif | |
| 590 | |
| 591 #ifdef FF_EM_MODE | |
| 592 em_init_sim_event_trace(); | |
| 593 #endif /* FF_EM_MODE */ | |
| 594 cl_shrd_init(sim_handle); | |
| 595 return PEI_OK; | |
| 596 } | |
| 597 | |
| 598 /* | |
| 599 +--------------------------------------------------------------------+ | |
| 600 | PROJECT : GSM-PS (6302) MODULE : SIM_PEI | | |
| 601 | STATE : code ROUTINE : pei_timeout | | |
| 602 +--------------------------------------------------------------------+ | |
| 603 | |
| 604 PURPOSE : Process timeout | |
| 605 | |
| 606 */ | |
| 607 LOCAL SHORT pei_timeout (USHORT index) | |
| 608 { | |
| 609 U16 sleepResult; | |
| 610 TRACE_EVENT_P1 ("[pei_timeout]: index %d",index); | |
| 611 SIM_TIMEOUT (index); | |
| 612 return PEI_OK; | |
| 613 } | |
| 614 | |
| 615 #ifdef FF_SAT_E | |
| 616 #ifdef _SIMULATION_ | |
| 617 /* | |
| 618 +--------------------------------------------------------------------+ | |
| 619 | PROJECT : GSM-PS (6302) MODULE : SIM_PEI | | |
| 620 | STATE : code ROUTINE : csf_sim_pei_timeout | | |
| 621 +--------------------------------------------------------------------+ | |
| 622 | |
| 623 PURPOSE : Process timeout for the _SIMULATION_ test cases. Purpose is to | |
| 624 gain global access to the local function pei_timeout() | |
| 625 | |
| 626 */ | |
| 627 GLOBAL USHORT csf_sim_pei_timeout (USHORT index) | |
| 628 { | |
| 629 TRACE_FUNCTION ("csf_sim_pei_timeout(index)"); | |
| 630 TRACE_EVENT_P1 ("[csf_sim_pei_timeout]: index %d",index); | |
| 631 return pei_timeout (index); | |
| 632 } | |
| 633 #endif /* _SIMULATION_ */ | |
| 634 #endif /* FF_SAT_E */ | |
| 635 | |
| 636 /* | |
| 637 +--------------------------------------------------------------------+ | |
| 638 | PROJECT : GSM-PS (6302) MODULE : SIM_PEI | | |
| 639 | STATE : code ROUTINE : sim_timeout | | |
| 640 +--------------------------------------------------------------------+ | |
| 641 | |
| 642 PURPOSE : Process timeout | |
| 643 | |
| 644 */ | |
| 645 | |
| 646 static void sim_timeout (USHORT index) | |
| 647 { | |
| 648 if (index EQ SIM_TIMER) | |
| 649 { | |
| 650 if(sleepTimerRunning == TRUE) | |
| 651 { | |
| 652 TIMER_STOP(sim_handle, SLEEP_TIMER); | |
| 653 } | |
| 654 sleepTimerRunning = FALSE; | |
| 655 app_sim_timeout (SIM_TIMER); | |
| 656 } | |
| 657 else if(index EQ SLEEP_TIMER) | |
| 658 { | |
| 659 sleepTimerRunning = FALSE; | |
| 660 app_sim_timeout (SLEEP_TIMER); | |
| 661 } | |
| 662 #ifdef SIM_TOOLKIT | |
| 663 else | |
| 664 { | |
| 665 if(sleepTimerRunning == TRUE) | |
| 666 { | |
| 667 TIMER_STOP(sim_handle, SLEEP_TIMER); | |
| 668 } | |
| 669 sleepTimerRunning = FALSE; | |
| 670 stk_timeout (index); | |
| 671 } | |
| 672 #endif | |
| 673 | |
| 674 if((startTimerPollOff == TRUE)&&(sim_data.idle_polling != TRUE)) | |
| 675 { | |
| 676 startTimerPollOff = FALSE; | |
| 677 sleepTimerRunning = TRUE; | |
| 678 TIMER_START(sim_handle,SLEEP_TIMER,35000); // this will not be effective as the SIM TIMER will expire before this and stop it. Just to takecare of Sleep after the POLLING_OFF STK command | |
| 679 } | |
| 680 | |
| 681 } | |
| 682 | |
| 683 | |
| 684 | |
| 685 #ifdef _SIMULATION_ | |
| 686 /* | |
| 687 +--------------------------------------------------------------------+ | |
| 688 | PROJECT : GSM-PS (6302) MODULE : SIM_PEI | | |
| 689 | STATE : code ROUTINE : pei_exit | | |
| 690 +--------------------------------------------------------------------+ | |
| 691 | |
| 692 PURPOSE : Close Resources and terminate | |
| 693 | |
| 694 */ | |
| 695 | |
| 696 LOCAL SHORT pei_exit (void) | |
| 697 { | |
| 698 TRACE_FUNCTION ("pei_exit()"); | |
| 699 | |
| 700 /* | |
| 701 * clean up communication | |
| 702 */ | |
| 703 #ifdef TI_PS_HCOMM_CHANGE | |
| 704 #if defined (GPRS) | |
| 705 vsi_c_close (VSI_CALLER hCommGMM); | |
| 706 hCommGMM = VSI_ERROR; | |
| 707 #endif | |
| 708 #else /* for hCommHandles backward compatibility */ | |
| 709 vsi_c_close (VSI_CALLER hCommMMI); | |
| 710 hCommMMI = VSI_ERROR; | |
| 711 | |
| 712 vsi_c_close (VSI_CALLER hCommMM); | |
| 713 hCommMM = VSI_ERROR; | |
| 714 | |
| 715 vsi_c_close (VSI_CALLER hCommSMS); | |
| 716 hCommSMS = VSI_ERROR; | |
| 717 | |
| 718 #if defined (GPRS) | |
| 719 vsi_c_close (VSI_CALLER hCommGMM); | |
| 720 hCommGMM = VSI_ERROR; | |
| 721 #endif | |
| 722 | |
| 723 #ifdef _SIMULATION_ | |
| 724 /* | |
| 725 * SIM commhandle deinitialization -> was used for the test cases | |
| 726 */ | |
| 727 if (hCommSIM >= VSI_OK) | |
| 728 { | |
| 729 vsi_c_close (VSI_CALLER hCommSIM); | |
| 730 } | |
| 731 hCommSIM = VSI_ERROR; | |
| 732 #endif /* _SIMULATION_ */ | |
| 733 #endif /* TI_PS_HCOMM_CHANGE */ | |
| 734 | |
| 735 | |
| 736 | |
| 737 #ifdef FF_SAT_E | |
| 738 /* | |
| 739 * DTI deinitialization | |
| 740 */ | |
| 741 dti_deinit(sim_data.hDTI); | |
| 742 if (hCommUDP >= VSI_OK) | |
| 743 { | |
| 744 vsi_c_close (VSI_CALLER hCommUDP); | |
| 745 } | |
| 746 hCommUDP = VSI_ERROR; | |
| 747 #endif /* FF_SAT_E */ | |
| 748 cl_shrd_exit(); | |
| 749 | |
| 750 return PEI_OK; | |
| 751 } | |
| 752 #endif /* _SIMULATION_ */ | |
| 753 | |
| 754 | |
| 755 /* | |
| 756 +--------------------------------------------------------------------+ | |
| 757 | PROJECT : GSM-PS (6302) MODULE : SIM_PEI | | |
| 758 | STATE : code ROUTINE : pei_config | | |
| 759 +--------------------------------------------------------------------+ | |
| 760 | |
| 761 PURPOSE : Dynamic Configuration | |
| 762 | |
| 763 */ | |
| 764 | |
| 765 /* Implements Measure#36 */ | |
| 766 #ifndef NCONFIG | |
| 767 LOCAL const KW_DATA kwtab[] = { | |
| 768 #ifdef _SIMULATION_ | |
| 769 SIM_MODE, CFG_MODE, | |
| 770 #endif | |
| 771 SIM_REMOVE, CFG_REMOVE, | |
| 772 SIM_NORM_POLL, CFG_NORM_POLL, | |
| 773 SIM_TEST_POLL, CFG_TEST_POLL, | |
| 774 "", 0 | |
| 775 }; | |
| 776 | |
| 777 LOCAL SHORT pei_config (T_PEI_CONFIG inString) | |
| 778 { | |
| 779 char * s = inString; | |
| 780 char * keyw; | |
| 781 char * val [10]; | |
| 782 | |
| 783 TRACE_FUNCTION ("pei_config()"); | |
| 784 | |
| 785 TRACE_FUNCTION (s); | |
| 786 | |
| 787 tok_init(s); | |
| 788 | |
| 789 /* | |
| 790 * Parse next keyword and number of variables | |
| 791 */ | |
| 792 while ((tok_next(&keyw,val)) NEQ TOK_EOCS) | |
| 793 { | |
| 794 switch (tok_key((KW_DATA *)kwtab,keyw)) | |
| 795 { | |
| 796 default: | |
| 797 TRACE_ERROR ("[PEI_CONFIG]: not supported"); | |
| 798 break; | |
| 799 case TOK_NOT_FOUND: | |
| 800 TRACE_ERROR ("[PEI_CONFIG]: illegal Keyword"); | |
| 801 break; | |
| 802 #if defined (_SIMULATION_) | |
| 803 case CFG_MODE: | |
| 804 sim_data.mode = atoi (val[0]); | |
| 805 break; | |
| 806 #endif | |
| 807 case CFG_REMOVE: | |
| 808 app_sim_remove (); | |
| 809 break; | |
| 810 case CFG_NORM_POLL: | |
| 811 SIM_CLEAR_FLAG (TEST_SIM_INSERTED); | |
| 812 SIM_CLEAR_FLAG (TEST_MODE_POLLING); | |
| 813 break; | |
| 814 #if defined SIM_TOOLKIT | |
| 815 case CFG_TEST_POLL: | |
| 816 SIM_SET_FLAG (TEST_SIM_INSERTED); | |
| 817 SIM_SET_FLAG (TEST_MODE_POLLING); | |
| 818 break; | |
| 819 #endif | |
| 820 } | |
| 821 } | |
| 822 return PEI_OK; | |
| 823 } | |
| 824 | |
| 825 /* | |
| 826 +--------------------------------------------------------------------+ | |
| 827 | PROJECT : GSM-PS (6147) MODULE : SIM_PEI | | |
| 828 | STATE : code ROUTINE : sim_pei_config | | |
| 829 +--------------------------------------------------------------------+ | |
| 830 | |
| 831 PURPOSE : Dynamic Configuration | |
| 832 | |
| 833 */ | |
| 834 GLOBAL SHORT sim_pei_config ( char * inString, char * dummy ) | |
| 835 { | |
| 836 pei_config ( inString ); | |
| 837 | |
| 838 return PEI_OK; | |
| 839 } | |
| 840 #endif /* not NCONFIG */ | |
| 841 | |
| 842 /* | |
| 843 +--------------------------------------------------------------------+ | |
| 844 | PROJECT : GSM-PS (6302) MODULE : SIM_PEI | | |
| 845 | STATE : code ROUTINE : pei_monitor | | |
| 846 +--------------------------------------------------------------------+ | |
| 847 | |
| 848 PURPOSE : Monitoring of physical Parameters | |
| 849 | |
| 850 */ | |
| 851 LOCAL SHORT pei_monitor (void ** monitor) | |
| 852 { | |
| 853 TRACE_FUNCTION ("pei_monitor()"); | |
| 854 | |
| 855 /* Implements Measure#32: Row 15 */ | |
| 856 | |
| 857 *monitor = &sim_mon; | |
| 858 | |
| 859 return PEI_OK; | |
| 860 } | |
| 861 | |
| 862 /* | |
| 863 +--------------------------------------------------------------------+ | |
| 864 | PROJECT : GSM-PS (6302) MODULE : SIM_PEI | | |
| 865 | STATE : code ROUTINE : pei_create | | |
| 866 +--------------------------------------------------------------------+ | |
| 867 | |
| 868 PURPOSE : Create the Protocol Stack Entity | |
| 869 | |
| 870 */ | |
| 871 | |
| 872 GLOBAL SHORT sim_pei_create (T_PEI_INFO **info) | |
| 873 { | |
| 874 static const T_PEI_INFO pei_info = | |
| 875 { | |
| 876 "SIM", | |
| 877 { | |
| 878 pei_init, | |
| 879 #ifdef _SIMULATION_ | |
| 880 pei_exit, | |
| 881 #else | |
| 882 NULL, | |
| 883 #endif | |
| 884 pei_primitive, | |
| 885 pei_timeout, | |
| 886 NULL, /* no signal function */ | |
| 887 NULL, /* no run function */ | |
| 888 /* Implements Measure#36 */ | |
| 889 #ifdef NCONFIG | |
| 890 NULL, /* no pei_config function */ | |
| 891 #else /* not NCONFIG */ | |
| 892 pei_config, | |
| 893 #endif /* NCONFIG */ | |
| 894 pei_monitor, | |
| 895 }, | |
| 896 0x900, /* Stack Size */ | |
| 897 10, /* Queue Entries */ | |
| 898 176, /* Priority */ | |
| 899 NUM_OF_SIM_TIMERS, /* number of timer */ | |
| 900 PASSIVE_BODY | | |
| 901 COPY_BY_REF | | |
| 902 TRC_NO_SUSPEND | | |
| 903 PRIM_NO_SUSPEND /* flags */ | |
| 904 }; | |
| 905 | |
| 906 TRACE_FUNCTION ("pei_create"); | |
| 907 /* | |
| 908 * Close Resources if open | |
| 909 */ | |
| 910 | |
| 911 #ifdef _SIMULATION_ | |
| 912 if (first_access) | |
| 913 first_access = FALSE; | |
| 914 else | |
| 915 pei_exit (); | |
| 916 #endif | |
| 917 | |
| 918 /* | |
| 919 * export startup configuration data | |
| 920 */ | |
| 921 *info = (T_PEI_INFO *)&pei_info; | |
| 922 | |
| 923 #ifdef _TARGET_ | |
| 924 /* | |
| 925 * bind to SIM Driver supporting ATR provision | |
| 926 */ | |
| 927 #ifndef TI_PS_UICC_CHIPSET_15 | |
| 928 SIM_lock_cr17689(); | |
| 929 #endif | |
| 930 #endif | |
| 931 return PEI_OK; | |
| 932 } | |
| 933 | |
| 934 #endif |
