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