comparison src/g23m-gsm/mm/mm_pei.c @ 1:fa8dc04885d8

src/g23m-*: import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:25:50 +0000
parents
children
comparison
equal deleted inserted replaced
0:4e78acac3d88 1:fa8dc04885d8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul :
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
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 Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This module implements the process body interface
18 | for the entity MM of the mobile station.
19 +-----------------------------------------------------------------------------
20 */
21
22
23 #ifndef MM_PEI_C
24 #define MM_PEI_C
25
26 #define ENTITY_MM
27
28
29 /*==== INCLUDES ===================================================*/
30 #if defined (NEW_FRAME)
31
32 #include <string.h>
33 #include <stdlib.h>
34 #include <stddef.h>
35 #include "typedefs.h"
36 #include "pcm.h"
37 #include "pconst.cdg"
38 #include "mconst.cdg"
39 #include "message.h"
40 #include "ccdapi.h"
41 #include "vsi.h"
42 #include "custom.h"
43 #include "gsm.h"
44 #include "prim.h"
45 #include "cnf_mm.h"
46 #include "mon_mm.h"
47 #include "pei.h"
48 #include "tok.h"
49 #include "mm.h"
50 #include "mm_em.h"
51
52 #else
53
54 #include <string.h>
55 #include <stdlib.h>
56 #include <stddef.h>
57 #include "stddefs.h"
58 #include "pcm.h"
59 #include "pconst.cdg"
60 #include "mconst.cdg"
61 #include "message.h"
62 #include "ccdapi.h"
63 #include "custom.h"
64 #include "gsm.h"
65 #include "prim.h"
66 #include "cnf_mm.h"
67 #include "mon_mm.h"
68 #include "vsi.h"
69 #include "pei.h"
70 #include "tok.h"
71 #include "mm.h"
72 #include "mm_em.h"
73
74 #endif
75
76 /*==== TEST =====================================================*/
77
78 /*==== EXPORT =====================================================*/
79 #if defined (NEW_FRAME)
80 #ifdef TI_PS_HCOMM_CHANGE
81 #else
82 GLOBAL T_HANDLE hCommMMI = VSI_ERROR; /* MMI Communication */
83 GLOBAL T_HANDLE hCommCC = VSI_ERROR; /* CC Communication */
84 GLOBAL T_HANDLE hCommSS = VSI_ERROR; /* SS Communication */
85 GLOBAL T_HANDLE hCommSMS = VSI_ERROR; /* SMS Communication */
86 GLOBAL T_HANDLE hCommSIM = VSI_ERROR; /* SIM Communication */
87 GLOBAL T_HANDLE hCommDL = VSI_ERROR; /* DL Communication */
88 GLOBAL T_HANDLE hCommRR = VSI_ERROR; /* RR Communication */
89 #endif /* TI_PS_HCOMM_CHANGE */
90 #ifdef GPRS
91 GLOBAL T_HANDLE hCommGMM = VSI_ERROR; /* GMM Communication */
92 #endif
93 GLOBAL T_HANDLE mm_handle;
94 #else
95 #ifdef TI_PS_HCOMM_CHANGE
96 #else
97 GLOBAL T_VSI_CHANDLE hCommMMI = VSI_ERROR; /* MMI Communication */
98 GLOBAL T_VSI_CHANDLE hCommCC = VSI_ERROR; /* CC Communication */
99 GLOBAL T_VSI_CHANDLE hCommSS = VSI_ERROR; /* SS Communication */
100 GLOBAL T_VSI_CHANDLE hCommSMS = VSI_ERROR; /* SMS Communication */
101 GLOBAL T_VSI_CHANDLE hCommSIM = VSI_ERROR; /* SIM Communication */
102 GLOBAL T_VSI_CHANDLE hCommDL = VSI_ERROR; /* DL Communication */
103 GLOBAL T_VSI_CHANDLE hCommRR = VSI_ERROR; /* RR Communication */
104 #endif /* TI_PS_HCOMM_CHANGE */
105 GLOBAL T_VSI_THANDLE mm_act_handle = VSI_ERROR;
106 #endif /* NEW_FRAME */
107 T_MM_DATA mm_data_base;
108
109 /*==== PRIVATE ====================================================*/
110
111 LOCAL void pei_not_supported (void *);
112
113 /*==== VARIABLES ==================================================*/
114
115 #ifdef _SIMULATION_
116 LOCAL BOOL first_access = TRUE;
117 #endif /* _SIMULATION_ */
118 LOCAL T_MONITOR mm_mon;
119
120 /*==== FUNCTIONS ==================================================*/
121
122 #ifdef GPRS
123 LOCAL const T_FUNC mmgmm_table[] = {
124 MAK_FUNC_0 (mm_mmgmm_reg_req , MMGMM_REG_REQ ), /* 0x00 */
125 MAK_FUNC_0 (mm_mmgmm_nreg_req , MMGMM_NREG_REQ ), /* 0x01 */
126 MAK_FUNC_0 (mm_mmgmm_net_req , MMGMM_NET_REQ ), /* 0x02 */
127 MAK_FUNC_0 (mm_mmgmm_plmn_res , MMGMM_PLMN_RES ), /* 0x03 */
128 MAK_FUNC_0 (mm_mmgmm_plmn_mode_req , MMGMM_PLMN_MODE_REQ ), /* 0x04 */
129 MAK_FUNC_0 (mm_mmgmm_auth_rej_req , MMGMM_AUTH_REJ_REQ ), /* 0x05 */
130 MAK_FUNC_0 (mm_mmgmm_cm_establish_res,MMGMM_CM_ESTABLISH_RES), /* 0x06 */
131 MAK_FUNC_0 (mm_mmgmm_attach_started_req, MMGMM_ATTACH_STARTED_REQ),
132 MAK_FUNC_0 (mm_mmgmm_attach_acc_req, MMGMM_ATTACH_ACC_REQ ), /* 0x08 */
133 MAK_FUNC_0 (mm_mmgmm_attach_rej_req, MMGMM_ATTACH_REJ_REQ ), /* 0x09 */
134 MAK_FUNC_0 (mm_mmgmm_detach_started_req, MMGMM_DETACH_STARTED_REQ),
135 MAK_FUNC_0 (mm_mmgmm_start_t3212_req, MMGMM_START_T3212_REQ ), /* 0x0b */
136 MAK_FUNC_0 (mm_mmgmm_cm_emergency_res,MMGMM_CM_EMERGENCY_RES), /* 0x0c */
137 MAK_FUNC_0 (mm_mmgmm_allowed_req , MMGMM_ALLOWED_REQ ), /* 0x0d */
138 MAK_FUNC_0 (pei_not_supported , MMGMM_TRIGGER_REQ ) /* 0x0e */
139 };
140 #else
141 LOCAL const T_FUNC mmreg_table[] = {
142 MAK_FUNC_0 (reg_mmr_reg_req , MMR_REG_REQ ),
143 MAK_FUNC_0 (reg_mmr_nreg_req , MMR_NREG_REQ ),
144 MAK_FUNC_0 (reg_mmr_net_req , MMR_NET_REQ ),
145 MAK_FUNC_0 (reg_mmr_plmn_res , MMR_PLMN_RES ),
146 MAK_FUNC_0 (reg_mmr_plmn_mode_req , MMR_PLMN_MODE_REQ )
147 };
148 #endif
149
150 LOCAL const T_FUNC mmcm_table[] = {
151 MAK_FUNC_0 (mm_mmcm_establish_req , MMCM_ESTABLISH_REQ ), /* 0x00 */
152 MAK_FUNC_S (mm_mmcm_data_req , MMCM_DATA_REQ ), /* 0x01 */
153 MAK_FUNC_0 (mm_mmcm_release_req , MMCM_RELEASE_REQ ), /* 0x02 */
154 MAK_FUNC_0 (mm_mmcm_reestablish_req, MMCM_REESTABLISH_REQ ), /* 0x03 */
155 MAK_FUNC_0 (mm_mmcm_prompt_res , MMCM_PROMPT_RES ), /* 0x04 */
156 MAK_FUNC_0 (mm_mmcm_prompt_rej , MMCM_PROMPT_REJ ) /* 0x05 */
157 };
158
159 LOCAL const T_FUNC mmss_table[] = {
160 MAK_FUNC_0 (mm_mmss_establish_req , MMSS_ESTABLISH_REQ ),
161 MAK_FUNC_0 (mm_mmss_release_req , MMSS_RELEASE_REQ ),
162 MAK_FUNC_S (mm_mmss_data_req , MMSS_DATA_REQ )
163 };
164
165 LOCAL const T_FUNC mmsms_table[] = {
166 MAK_FUNC_0 (mm_mmsms_establish_req , MMSMS_ESTABLISH_REQ ),
167 MAK_FUNC_0 (mm_mmsms_release_req , MMSMS_RELEASE_REQ ),
168 MAK_FUNC_S (mm_mmsms_data_req , MMSMS_DATA_REQ )
169 };
170
171 LOCAL const T_FUNC sim_table[] = {
172 MAK_FUNC_0 (reg_sim_read_cnf , SIM_READ_CNF ), /* 0x00 */
173 MAK_FUNC_0 (pei_not_supported , SIM_UPDATE_CNF ),
174 MAK_FUNC_0 (pei_not_supported , SIM_READ_RECORD_CNF ),
175 MAK_FUNC_N (pei_not_supported , 0 ),
176 MAK_FUNC_0 (pei_not_supported , SIM_UPDATE_RECORD_CNF ),
177 MAK_FUNC_N (pei_not_supported , 0 ),
178 MAK_FUNC_N (pei_not_supported , 0 ),
179 MAK_FUNC_N (pei_not_supported , 0 ),
180 MAK_FUNC_0 (pei_not_supported , SIM_INCREMENT_CNF ),
181 MAK_FUNC_0 (pei_not_supported , SIM_VERIFY_PIN_CNF ),
182 MAK_FUNC_0 (pei_not_supported , SIM_CHANGE_PIN_CNF ),
183 MAK_FUNC_0 (pei_not_supported , SIM_DISABLE_PIN_CNF ),
184 MAK_FUNC_0 (pei_not_supported , SIM_ENABLE_PIN_CNF ),
185 MAK_FUNC_0 (pei_not_supported , SIM_UNBLOCK_CNF ),
186 MAK_FUNC_0 (reg_sim_auth_cnf , SIM_AUTHENTICATION_CNF ),
187 MAK_FUNC_0 (pei_not_supported , SIM_MMI_INSERT_IND ),
188 MAK_FUNC_0 (reg_sim_mm_insert_ind , SIM_MM_INSERT_IND ),
189 MAK_FUNC_0 (reg_sim_remove_ind , SIM_REMOVE_IND ),
190 MAK_FUNC_0 (reg_sim_sync_cnf , SIM_SYNC_CNF ),
191 MAK_FUNC_0 (pei_not_supported , SIM_ACTIVATE_CNF ),
192 MAK_FUNC_0 (pei_not_supported , SIM_SMS_INSERT_IND ), /* 0x14 */
193 MAK_FUNC_0 (pei_not_supported , SIM_TOOLKIT_IND ), /* 0x15 */
194 MAK_FUNC_0 (pei_not_supported , SIM_TOOLKIT_CNF ), /* 0x16 */
195 MAK_FUNC_0 (pei_not_supported , SIM_ACTIVATE_IND ), /* 0x17 */
196 MAK_FUNC_0 (reg_sim_mm_info_ind , SIM_MM_INFO_IND ), /* 0x18 */
197 MAK_FUNC_0 (pei_not_supported , SIM_ACCESS_CNF ), /* 0x19 */
198 MAK_FUNC_0 (reg_sim_file_upd_ind , SIM_FILE_UPDATE_IND ) /* 0x1a */
199 };
200
201 #ifdef FF_EM_MODE
202 LOCAL const T_FUNC em_ul_table[] = {
203 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E00 */
204 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E01 */
205 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E02 */
206 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E03 */
207 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E04 */
208 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E05 */
209 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E06 */
210 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E07 */
211 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E08 */
212 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E09 */
213 MAK_FUNC_0 (mm_em_dl_event_req , EM_DL_EVENT_REQ ), /* 0x3E0A */
214 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E0B */
215 MAK_FUNC_0 (mm_em_mm_event_req , EM_MM_EVENT_REQ ) /* 0x3E0C */
216 };
217
218 LOCAL const T_FUNC em_dl_table[] = {
219 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x7E00 */
220 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x7E01 */
221 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x7E02 */
222 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x7E03 */
223 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x7E04 */
224 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x7E05 */
225 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x7E06 */
226 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x7E07 */
227 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x7E08 */
228 MAK_FUNC_N( pei_not_supported , 0 ), /* 0x7E09 */
229 MAK_FUNC_N( pei_not_supported , 0 ), /* 0x7E0A */
230 MAK_FUNC_0( pei_not_supported , EM_DATA_IND ), /* 0x7E0B */
231 };
232 #endif /* FF_EM_MODE */
233
234 LOCAL const T_FUNC rr_table[] = {
235 MAK_FUNC_0 (mm_rr_abort_ind , RR_ABORT_IND ),
236 MAK_FUNC_0 (mm_rr_activate_cnf , RR_ACTIVATE_CNF ),
237 MAK_FUNC_0 (mm_rr_activate_ind , RR_ACTIVATE_IND ),
238 MAK_FUNC_S (for_rr_data_ind , RR_DATA_IND ),
239 MAK_FUNC_0 (mm_rr_establish_cnf , RR_ESTABLISH_CNF ),
240 MAK_FUNC_0 (mm_rr_establish_ind , RR_ESTABLISH_IND ),
241 MAK_FUNC_N (pei_not_supported , 0 ),
242 MAK_FUNC_0 (mm_rr_release_ind , RR_RELEASE_IND ),
243 MAK_FUNC_0 (mm_rr_sync_ind , RR_SYNC_IND )
244 #if defined (FF_EOTD) AND defined (REL99)
245 ,
246 MAK_FUNC_0 (mm_rr_rrlp_start_ind , RR_RRLP_START_IND ),
247 MAK_FUNC_0 (mm_rr_rrlp_stop_ind , RR_RRLP_STOP_IND )
248 #else
249 ,
250 MAK_FUNC_N (pei_not_supported , 0 ),
251 MAK_FUNC_N (pei_not_supported , 0 )
252 #endif /* (FF_EOTD) AND defined (REL99) */
253 };
254
255 LOCAL const T_FUNC mdl_table[] = {
256 MAK_FUNC_0 (mm_mdl_error_ind , MDL_ERROR_IND )
257 };
258
259
260 /*
261 +--------------------------------------------------------------------+
262 | PROJECT : GSM-PS (6147) MODULE : MM_PEI |
263 | STATE : code ROUTINE : pei_primitive |
264 +--------------------------------------------------------------------+
265
266 PURPOSE : Process protocol specific primitive.
267
268 */
269
270 #if defined (NEW_FRAME)
271 LOCAL SHORT pei_primitive (void * ptr)
272 #else
273 GLOBAL T_PEI_RETURN pei_primitive (T_PRIM * prim)
274 #endif
275 {
276 GET_INSTANCE_DATA;
277 #if defined (NEW_FRAME)
278 T_PRIM *prim = ptr;
279 #endif
280 /*
281 * | | | | |
282 * MMREG MMCM MMSS MMSMS EM UPLINK
283 * | | | | |
284 * +---v-----v-----v-----v-----v---+
285 * | |
286 * | MM |
287 * | |
288 * +---^---------^--------^--------+
289 * | | |
290 * SIM RR MDL DOWNLINK
291 * | | |
292 *
293 */
294
295 TRACE_FUNCTION ("pei_primitive()");
296 if (prim NEQ NULL)
297 {
298 ULONG opc = prim->custom.opc;
299 USHORT n;
300 const T_FUNC *table;
301
302 #if defined (NEW_FRAME)
303 VSI_PPM_REC ((T_PRIM_HEADER*)prim, __FILE__, __LINE__);
304 #endif
305
306 PTRACE_IN (opc);
307
308 switch (SAP_NR(opc))
309 {
310 case SAP_NR(MMCM_UL): table = mmcm_table; n = TAB_SIZE ( mmcm_table); break;
311 case SAP_NR(MMSS_UL): table = mmss_table; n = TAB_SIZE ( mmss_table); break;
312 case SAP_NR(MMSMS_UL): table = mmsms_table; n = TAB_SIZE (mmsms_table); break;
313 case SAP_NR(SIM_UL): table = sim_table; n = TAB_SIZE ( sim_table); break;
314 #ifdef FF_EM_MODE
315 case EM_Ul: table = em_ul_table; n = TAB_SIZE (em_ul_table); break;
316 #endif /* FF_EM_MODE */
317 case SAP_NR(RR_DL): table = rr_table; n = TAB_SIZE ( rr_table); break;
318 case SAP_NR(MDL_UL): table = mdl_table; n = TAB_SIZE ( mdl_table); break;
319 #ifdef GPRS
320 case MMGMM_UL: table = mmgmm_table; n = TAB_SIZE (mmgmm_table); break;
321 #else
322 case SAP_NR(MMREG_UL): table = mmreg_table; n = TAB_SIZE (mmreg_table); break;
323 #endif
324 #ifdef FF_EM_MODE
325 case EM_Dl: table = em_dl_table; n = TAB_SIZE (em_dl_table); break;
326 #endif /* FF_EM_MODE */
327 default : table = NULL; n = 0; break;
328 }
329
330 if (table != NULL )
331 {
332 if (PRIM_NR(opc) < n)
333 {
334 table += PRIM_NR(opc);
335 #ifdef PALLOC_TRANSITION
336 P_SDU(prim) = table->soff ? (T_sdu*) (((char*)&prim->data) + table->soff) : 0;
337 #ifndef NO_COPY_ROUTING
338 P_LEN(prim) = table->size + sizeof (T_PRIM_HEADER);
339 #endif /* NO_COPY_ROUTING */
340 #endif /* PALLOC_TRANSITION */
341 JUMP (table->func) (P2D(prim));
342
343 while (ENTITY_DATA->use_stored_entries)
344 {
345 ENTITY_DATA->use_stored_entries = FALSE;
346 mm_use_entry();
347 }
348
349 }
350 else
351 {
352 pei_not_supported (P2D(prim));
353 }
354 return PEI_OK;
355 }
356
357 #ifdef GSM_ONLY
358 PFREE (P2D(prim))
359 return PEI_ERROR;
360 #else
361 if (opc & SYS_MASK)
362 vsi_c_primitive (VSI_CALLER prim);
363 else
364 {
365 PFREE (P2D(prim))
366 return PEI_ERROR;
367 }
368 #endif
369 }
370 return PEI_OK;
371 }
372
373 #if defined (NEW_FRAME)
374 /*
375 +--------------------------------------------------------------------+
376 | PROJECT : GSM-PS (6147) MODULE : MM_PEI |
377 | STATE : code ROUTINE : mm_pei_primitive |
378 +--------------------------------------------------------------------+
379
380 PURPOSE : used to restart a stored primitive.
381
382 */
383 GLOBAL void mm_pei_primitive (T_PRIM * prim)
384 {
385 pei_primitive (prim);
386 }
387 #endif
388
389 /*
390 +--------------------------------------------------------------------+
391 | PROJECT : GSM-PS (8410) MODULE : SMS_PEI |
392 | STATE : code ROUTINE : pei_not_supported |
393 +--------------------------------------------------------------------+
394
395 PURPOSE : An unsupported primitive is received.
396
397 */
398
399 static void pei_not_supported (void *data)
400 {
401 TRACE_FUNCTION ("pei_not_supported()");
402
403 PFREE (data);
404 }
405
406 /*
407 +--------------------------------------------------------------------+
408 | PROJECT : GSM-PS (6147) MODULE : MM_PEI |
409 | STATE : code ROUTINE : pei_init |
410 +--------------------------------------------------------------------+
411
412 PURPOSE : Initialize Protocol Stack Entity
413
414 */
415
416 #if defined (NEW_FRAME)
417 LOCAL SHORT pei_init (T_HANDLE handle)
418 #else
419 GLOBAL T_PEI_RETURN pei_init (void)
420 #endif
421 {
422 #if defined (NEW_FRAME)
423 mm_handle = handle;
424 #endif
425
426 TRACE_FUNCTION ("pei_init()");
427
428 #ifdef TI_PS_HCOMM_CHANGE
429 if (!cl_hcom_all_handles_open())
430 {
431 return PEI_ERROR;
432 }
433 #else /* for hCommHandles backward compatibility */
434 if (hCommMMI < VSI_OK)
435 {
436 /*
437 * Open MMI (Layer 4)
438 */
439
440 if ((hCommMMI = vsi_c_open (VSI_CALLER ACI_NAME)) < VSI_OK)
441 return PEI_ERROR;
442 }
443
444 if (hCommCC < VSI_OK)
445 {
446 if ((hCommCC = vsi_c_open (VSI_CALLER CC_NAME)) < VSI_OK)
447 return PEI_ERROR;
448 }
449
450 if (hCommSS < VSI_OK)
451 {
452 if ((hCommSS = vsi_c_open (VSI_CALLER SS_NAME)) < VSI_OK)
453 return PEI_ERROR;
454 }
455
456 if (hCommSMS < VSI_OK)
457 {
458 if ((hCommSMS = vsi_c_open (VSI_CALLER SMS_NAME)) < VSI_OK)
459 return PEI_ERROR;
460 }
461
462 if (hCommRR < VSI_OK)
463 {
464 if ((hCommRR = vsi_c_open (VSI_CALLER RR_NAME)) < VSI_OK)
465 return PEI_ERROR;
466 }
467
468 if (hCommDL < VSI_OK)
469 {
470 if ((hCommDL = vsi_c_open (VSI_CALLER DL_NAME)) < VSI_OK)
471 return PEI_ERROR;
472 }
473
474 if (hCommSIM < VSI_OK)
475 {
476 if ((hCommSIM = vsi_c_open (VSI_CALLER SIM_NAME)) < VSI_OK)
477 return PEI_ERROR;
478 }
479 #endif /* TI_PS_HCOMM_CHANGE */
480 #ifdef GPRS
481 if (hCommGMM < VSI_OK)
482 {
483 if ((hCommGMM = vsi_c_open (VSI_CALLER GMM_NAME)) < VSI_OK)
484 return PEI_ERROR;
485 }
486 #endif
487
488 /*
489 * Open Timer Resources
490 */
491
492 mm_init_mm_data ();
493
494 #ifdef FF_EM_MODE
495 em_init_mm_event_trace();
496 #endif /* FF_EM_MODE */
497
498 #if defined (OPTION_TIMER)
499 tim_init_timer ();
500 #endif
501 ccd_init ();
502
503 return PEI_OK;
504 }
505
506 /*
507 +--------------------------------------------------------------------+
508 | PROJECT : GSM-PS (6147) MODULE : MM_PEI |
509 | STATE : code ROUTINE : pei_timeout |
510 +--------------------------------------------------------------------+
511
512 PURPOSE : Process timeout
513
514 */
515 #if defined (NEW_FRAME)
516 LOCAL SHORT pei_timeout (USHORT index)
517 {
518 GET_INSTANCE_DATA;
519
520 tim_exec_timeout (index);
521
522 while (ENTITY_DATA->use_stored_entries)
523 {
524 ENTITY_DATA->use_stored_entries = FALSE;
525 mm_use_entry();
526 }
527
528 return PEI_OK;
529 }
530
531 #else
532
533 GLOBAL T_PEI_RETURN pei_timeout (T_VSI_THANDLE handle)
534 {
535 /*
536 * Set Timeout Flag according
537 * to timer handle
538 */
539 if (mm_act_handle NEQ handle)
540 tim_set_timeout_flag (handle, &t_flag);
541
542 #ifdef OPTION_TIMEOUT_SYNC
543 while (t_flag)
544 {
545 /*
546 * Handle Timeouts
547 */
548 tim_handle_timeout (&t_flag);
549 }
550 #else
551 vsi_c_awake (VSI_CALLER_SINGLE);
552 #endif
553
554 while (ENTITY_DATA->use_stored_entries)
555 {
556 ENTITY_DATA->use_stored_entries = FALSE;
557 mm_use_entry();
558 }
559
560 return PEI_OK;
561 }
562 #endif
563
564 #ifdef _SIMULATION_
565 /*
566 +--------------------------------------------------------------------+
567 | PROJECT : GSM-PS (6147) MODULE : MM_PEI |
568 | STATE : code ROUTINE : pei_exit |
569 +--------------------------------------------------------------------+
570
571 PURPOSE : Close Resources and terminate
572
573 */
574 #if defined (NEW_FRAME)
575 LOCAL SHORT pei_exit (void)
576 #else
577 GLOBAL T_PEI_RETURN pei_exit (void)
578 #endif
579 {
580 TRACE_FUNCTION ("pei_exit()");
581
582 /*
583 * clean up communication
584 */
585 #ifdef TI_PS_HCOMM_CHANGE
586 #else /* for hCommHandles backward compatibility */
587 vsi_c_close (VSI_CALLER hCommMMI);
588 hCommMMI = VSI_ERROR;
589
590 vsi_c_close (VSI_CALLER hCommCC);
591 hCommCC = VSI_ERROR;
592
593 vsi_c_close (VSI_CALLER hCommSS);
594 hCommSS = VSI_ERROR;
595
596 vsi_c_close (VSI_CALLER hCommSMS);
597 hCommSMS = VSI_ERROR;
598
599 vsi_c_close (VSI_CALLER hCommRR);
600 hCommRR = VSI_ERROR;
601
602 vsi_c_close (VSI_CALLER hCommDL);
603 hCommDL = VSI_ERROR;
604
605 vsi_c_close (VSI_CALLER hCommSIM);
606 hCommSIM = VSI_ERROR;
607 #endif /* TI_PS_HCOMM_CHANGE */
608 #ifdef GPRS
609 vsi_c_close (VSI_CALLER hCommGMM);
610 hCommGMM = VSI_ERROR;
611 #endif
612
613 return PEI_OK;
614 }
615 #endif /* _SIMULATION_ */
616
617 /*
618 +--------------------------------------------------------------------+
619 | PROJECT : GSM-PS (6147) MODULE : MM_PEI |
620 | STATE : code ROUTINE : pei_config |
621 +--------------------------------------------------------------------+
622
623 PURPOSE : Dynamic Configuration
624
625 */
626
627 /* Implements Measure#36 */
628 #if !defined (NCONFIG)
629 LOCAL const KW_DATA kwtab[] = {
630 #ifdef OPTION_TIMER
631 MM_TIMER_SET, TIMER_SET,
632 MM_TIMER_RESET, TIMER_RESET,
633 MM_TIMER_SPEED_UP, TIMER_SPEED_UP,
634 MM_TIMER_SLOW_DOWN, TIMER_SLOW_DOWN,
635 MM_TIMER_SUPPRESS, TIMER_SUPPRESS,
636 #endif
637 MM_T3212_CNT, T3212_CNT,
638 MM_USE_STORED_BCCH, USE_STORED_BCCH,
639 MM_FFS_RESET_EPLMN, FFS_RESET_EPLMN,
640 MM_FFS_READ_EPLMN, FFS_READ_EPLMN,
641 MM_FFS_READ_EPLMN_INIT, FFS_READ_EPLMN_INIT,
642 MM_FFS_WRITE_EPLMN, FFS_WRITE_EPLMN,
643 "", 0
644 };
645 #endif /* (NCONFIG) */
646
647 GLOBAL const KW_DATA partab[] = {
648 #ifdef OPTION_TIMER
649 T_REG_NAME, T_REGISTRATION,
650 T3210_NAME, T3210,
651 T3211_NAME, T3211,
652 T3212_NAME, T3212,
653 T3213_NAME, T3213,
654 T3220_NAME, T3220,
655 T3230_NAME, T3230,
656 T3240_NAME, T3240,
657 T_HPLMN_NAME, T_HPLMN,
658 #ifdef REL99
659 T3241_NAME, T3241,
660 #endif
661 #endif
662 "", 0
663 };
664
665 /* Implements Measure#36 */
666 #if !defined (NCONFIG)
667 #if defined (NEW_FRAME)
668 LOCAL SHORT pei_config (T_PEI_CONFIG inString)
669 #else
670 GLOBAL T_PEI_RETURN pei_config (T_PEI_CONFIG inString,
671 T_PEI_CONFIG outString)
672 #endif
673 {
674 GET_INSTANCE_DATA;
675 {
676 char * s = inString;
677 SHORT valno;
678 SHORT keyno;
679 char * keyw;
680 char * val [10];
681 #if defined (OPTION_TIMER)
682 BOOL t_man = FALSE;
683 SHORT t_num;
684 LONG t_val;
685 UBYTE t_mod;
686 #endif /* #if defined (OPTION_TIMER) */
687
688 TRACE_FUNCTION ("pei_config()");
689
690 TRACE_EVENT (s);
691
692 #if defined TM_SPECIAL
693 if (!strcmp (inString, "RESET_2"))
694 {
695 /*
696 * Hardware Reset
697 */
698 csf_hardware_reset_2 ();
699 return PEI_OK;
700 }
701
702 if (!strcmp (inString, "RESET_3"))
703 {
704 /*
705 * Init RF
706 */
707 csf_hardware_reset_3 ();
708 return PEI_OK;
709 }
710 #endif /* #if defined TM_SPECIAL */
711
712 tok_init(s);
713
714 /*
715 * Parse next keyword and number of variables
716 */
717 while ((valno = tok_next(&keyw,val)) != TOK_EOCS)
718 {
719 switch ((keyno = tok_key((KW_DATA *)kwtab,keyw)))
720 {
721 case TOK_NOT_FOUND:
722 TRACE_ERROR ("[PEI_CONFIG]: Illegal Keyword");
723 break;
724
725 #if defined (OPTION_TIMER)
726 case TIMER_SET:
727 if (valno EQ 2)
728 {
729 t_man = TRUE;
730 t_num = tok_key((KW_DATA *)partab,val[0]);
731 t_mod = TIMER_SET;
732 t_val = atoi(val[1]);
733 if (t_val < 0L)
734 t_val = 0L;
735 }
736 else
737 {
738 TRACE_ERROR ("[PEI_CONFIG]: Wrong Number of Parameters");
739 }
740 break;
741 case TIMER_RESET:
742 case TIMER_SUPPRESS:
743 if (valno == 1)
744 {
745 t_man = TRUE; /* Timermanipulation */
746 t_num = tok_key((KW_DATA *)partab,val[0]);
747 t_mod = (UBYTE)keyno;
748 t_val = 0L;
749 }
750 else
751 {
752 TRACE_ERROR ("[PEI_CONFIG]: Wrong Number of Parameters");
753 }
754 break;
755 case TIMER_SPEED_UP:
756 case TIMER_SLOW_DOWN:
757 if (valno == 2)
758 {
759 t_man = TRUE;
760 t_num = tok_key((KW_DATA *)partab,val[0]);
761 t_mod = (UBYTE)keyno;
762 t_val = atoi(val[1]);
763 if (t_val <= 0L)
764 t_val = 1L;
765 }
766 else
767 {
768 TRACE_ERROR ("[PEI_CONFIG]: Wrong Number of Parameters");
769 }
770 break;
771 #endif /* #if defined (OPTION_TIMER) */
772 case T3212_CNT:
773 if (valno == 1)
774 mm_data->t3212_cfg_counter = atoi(val[0]);
775 else
776 {
777 TRACE_ERROR ("[PEI_CONFIG]: Wrong Number of Parameters");
778 }
779 break;
780
781 case USE_STORED_BCCH:
782 mm_data->config_use_stored_bcch = TRUE;
783 TRACE_EVENT ("MS uses stored BCCH lists also with test SIM");
784 break;
785
786 case FFS_RESET_EPLMN:
787 mm_reset_ffs();
788 break;
789
790 case FFS_READ_EPLMN:
791 mm_read_ffs();
792 mm_display_eplmn();
793 break;
794
795 case FFS_READ_EPLMN_INIT:
796 mm_read_ffs_init();
797 break;
798
799 case FFS_WRITE_EPLMN:
800 {
801 UBYTE samplelist[18] ={'S','A','M','P','L','E',' ','L','I','S','T',' ','E','P','L','M','N'};
802 memcpy(mm_data->reg.eqv_plmns.eqv_plmn_list, samplelist, 18);
803 mm_write_eplmn_to_ffs();
804 }
805 break;
806
807 default:
808 break;
809 } /* switch */
810
811 #if defined (OPTION_TIMER)
812 /*
813 * If timer manipulation
814 */
815
816 if (t_man)
817 {
818 t_man = FALSE;
819 /*lint -e644 variable may not have been initialized*/
820 if (t_num >= 0)
821 tim_config_timer ( (UBYTE) t_num, t_mod, t_val);
822 else
823 {
824 TRACE_ERROR ("[PEI_CONFIG]: Parameter out of Range");
825 }
826 /*lint +e644 variable may not have been initialized*/
827 } /* if (t_man) */
828 #endif /* #if defined (OPTION_TIMER) */
829 } /* while */
830 }
831 return PEI_OK;
832 }
833 #endif /* (NCONFIG) */
834
835
836 #if defined (NEW_FRAME)
837 /*
838 +--------------------------------------------------------------------+
839 | PROJECT : GSM-PS (6147) MODULE : MM_PEI |
840 | STATE : code ROUTINE : mm_pei_config |
841 +--------------------------------------------------------------------+
842
843 PURPOSE : Dynamic Configuration
844
845 */
846 /* Implements Measure#36 */
847 #if !defined (NCONFIG)
848 GLOBAL SHORT mm_pei_config ( char * inString, char * dummy )
849 {
850 pei_config ( inString );
851
852 return PEI_OK;
853 }
854 #endif /* (NCONFIG) */
855 #endif
856
857 /*
858 +--------------------------------------------------------------------+
859 | PROJECT : GSM-PS (6147) MODULE : MM_PEI |
860 | STATE : code ROUTINE : pei_monitor |
861 +--------------------------------------------------------------------+
862
863 PURPOSE : Monitoring of physical Parameters
864
865 */
866 #if defined (NEW_FRAME)
867 LOCAL SHORT pei_monitor (void ** monitor)
868 #else
869 GLOBAL T_PEI_RETURN pei_monitor (void ** monitor)
870 #endif
871 {
872 TRACE_FUNCTION ("pei_monitor()");
873
874 /* Implements Measure#32: Row 76 */
875
876 *monitor = &mm_mon;
877
878 return PEI_OK;
879 }
880
881
882 /*
883 +--------------------------------------------------------------------+
884 | PROJECT : GSM-PS (6147) MODULE : MM_PEI |
885 | STATE : code ROUTINE : pei_create |
886 +--------------------------------------------------------------------+
887
888 PURPOSE : Create the Protocol Stack Entity
889
890 */
891
892
893 #if defined (NEW_FRAME)
894
895 GLOBAL SHORT mm_pei_create (T_PEI_INFO **info)
896 {
897 static const T_PEI_INFO pei_info =
898 {
899 "MM",
900 {
901 pei_init,
902 #ifdef _SIMULATION_
903 pei_exit,
904 #else
905 NULL,
906 #endif
907 pei_primitive,
908 pei_timeout,
909 NULL, /* no signal function */
910 NULL, /* no run function */
911 /* Implements Measure#36 */
912 #if defined(NCONFIG)
913 NULL, /* no pei_config function */
914 #else /* not (NCONFIG) */
915 pei_config,
916 #endif /* (NCONFIG) */
917 pei_monitor,
918 },
919 1024, /* Stack Size */
920 10, /* Queue Entries */
921 195, /* Priority */
922 NUM_OF_MM_TIMERS, /* number of timer */
923 PASSIVE_BODY|COPY_BY_REF|PRIM_NO_SUSPEND /* flags */
924 };
925
926 TRACE_FUNCTION ("pei_create()");
927
928 /*
929 * Close Resources if open
930 */
931
932 #ifdef _SIMULATION_
933 if (first_access)
934 first_access = FALSE;
935 else
936 pei_exit ();
937 #endif
938
939 /*
940 * Export startup configuration data
941 */
942
943 *info = (T_PEI_INFO *)&pei_info;
944
945 pcm_Init ();
946
947 return PEI_OK;
948 }
949
950 #else
951
952 T_PEI_RETURN pei_create (T_VSI_CNAME * name)
953 {
954 TRACE_FUNCTION ("pei_create()")
955
956 /*
957 * Close Resources if open
958 */
959
960 #ifdef _SIMULATION_
961 if (first_access)
962 first_access = FALSE;
963 else
964 pei_exit ();
965 #endif
966
967 /*
968 * Initialize entity data
969 */
970
971 *name = MM_NAME;
972
973 pcm_Init ();
974
975 return PEI_OK;
976 }
977
978 #endif
979
980 #endif