comparison src/g23m-gsm/cc/cc_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 :
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 CC of the mobile station.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef CC_PEI_C
23 #define CC_PEI_C
24
25 #define ENTITY_CC
26 /*==== INCLUDES ===================================================*/
27
28 #include <string.h>
29 #include <stdlib.h>
30 #include <stddef.h>
31 #include "typedefs.h"
32 #include "pcm.h"
33 #include "vsi.h"
34 #include "custom.h"
35 #include "gsm.h"
36 #include "message.h"
37 #include "ccdapi.h"
38 #include "prim.h"
39 #include "cus_cc.h"
40 #include "cnf_cc.h"
41 #include "mon_cc.h"
42 #include "pei.h"
43 #include "tok.h"
44 #include "cc.h"
45 #include "cc_em.h"
46
47
48 /*==== EXPORT =====================================================*/
49 #ifdef TI_PS_HCOMM_CHANGE
50 #else
51 GLOBAL T_HANDLE hCommMMI = VSI_ERROR; /* MMI Communication */
52 GLOBAL T_HANDLE hCommMM = VSI_ERROR; /* MM Communication */
53 #endif
54 GLOBAL T_HANDLE cc_handle = VSI_ERROR;
55
56 #ifdef OPTION_MULTIPLE_INSTANCE
57 GLOBAL T_CC_DATA data_base [MAX_INSTANCES];
58 #else
59 GLOBAL T_CC_DATA data_base;
60 #endif
61
62
63 /*==== PRIVATE ====================================================*/
64
65 static void pei_not_supported (void *data);
66
67 /*==== VARIABLES ==================================================*/
68 #ifdef _SIMULATION_
69 static BOOL first_access = TRUE;
70 #endif /* _SIMULATION_ */
71 static T_MONITOR cc_mon;
72
73 /*==== FUNCTIONS ==================================================*/
74
75 LOCAL const T_FUNC mncc_table[] = {
76 MAK_FUNC_0( cc_mncc_setup_req, MNCC_SETUP_REQ ), /* 0x00 */
77 MAK_FUNC_0( cc_mncc_setup_res, MNCC_SETUP_RES ), /* 0x01 */
78 MAK_FUNC_0( cc_mncc_alert_req, MNCC_ALERT_REQ ), /* 0x02 */
79 MAK_FUNC_0( cc_mncc_disconnect_req, MNCC_DISCONNECT_REQ ), /* 0x03 */
80 MAK_FUNC_0( cc_mncc_release_req, MNCC_RELEASE_REQ ), /* 0x04 */
81 MAK_FUNC_0( cc_mncc_modify_req, MNCC_MODIFY_REQ ), /* 0x05 */
82 MAK_FUNC_0( cc_mncc_configure_req, MNCC_CONFIGURE_REQ ), /* 0x06 */
83 MAK_FUNC_N( pei_not_supported, 0 ), /* 0x07 */ /*removed mncc_notify_XXX*/
84 MAK_FUNC_0( cc_mncc_start_dtmf_req, MNCC_START_DTMF_REQ ), /* 0x08 */
85 MAK_FUNC_0( cc_mncc_hold_req, MNCC_HOLD_REQ ), /* 0x09 */
86 MAK_FUNC_0( cc_mncc_retrieve_req, MNCC_RETRIEVE_REQ ), /* 0x0a */
87 MAK_FUNC_0( cc_mncc_facility_req, MNCC_FACILITY_REQ ), /* 0x0b */
88 MAK_FUNC_0( cc_mncc_user_req, MNCC_USER_REQ ), /* 0x0c */
89 #ifdef SIM_TOOLKIT
90 MAK_FUNC_N( cc_mncc_bearer_cap_req, MNCC_BEARER_CAP_REQ ), /* 0x0d */
91 #else
92 MAK_FUNC_N( pei_not_supported, 0 ), /* 0x0d */
93 #endif /*SIM_TOOLKIT */
94 MAK_FUNC_0( cc_mncc_prompt_res, MNCC_PROMPT_RES ), /* 0x0e */
95 MAK_FUNC_0( cc_mncc_prompt_rej, MNCC_PROMPT_REJ ), /* 0x0f */
96 MAK_FUNC_0( cc_mncc_reject_req, MNCC_REJECT_REQ ), /* 0x10 */
97 MAK_FUNC_0( cc_mncc_sync_req, MNCC_SYNC_REQ ), /* 0x11 */
98 MAK_FUNC_0( cc_mncc_status_res, MNCC_STATUS_RES ) /* 0x12 */
99 };
100
101
102 LOCAL const T_FUNC mmcm_table[] = {
103 MAK_FUNC_0( for_mmcm_est_cnf, MMCM_ESTABLISH_CNF ), /* 0x00 */
104 MAK_FUNC_S( for_mmcm_est_ind, MMCM_ESTABLISH_IND ), /* 0x01 */
105 MAK_FUNC_S( for_mmcm_data_ind, MMCM_DATA_IND ), /* 0x02 */
106 MAK_FUNC_0( for_mmcm_rel_ind, MMCM_RELEASE_IND ), /* 0x03 */
107 MAK_FUNC_0( for_mmcm_err_ind, MMCM_ERROR_IND ), /* 0x04 */
108 MAK_FUNC_N( pei_not_supported, 0 ), /* 0x05 */
109 MAK_FUNC_0( for_mmcm_reest_cnf, MMCM_REESTABLISH_CNF), /* 0x06 */
110 MAK_FUNC_0( for_mmcm_prompt_ind, MMCM_PROMPT_IND ), /* 0x07 */
111 MAK_FUNC_N( pei_not_supported, 0 ), /* 0x08 */
112 MAK_FUNC_0( for_mmcm_sync_ind, MMCM_SYNC_IND ) /* 0x09 */
113 };
114
115
116
117 #ifdef FF_EM_MODE
118 LOCAL const T_FUNC em_table[] = {
119 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E00 */
120 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E01 */
121 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E02 */
122 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E03 */
123 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E04 */
124 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E05 */
125 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E06 */
126 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E07 */
127 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E08 */
128 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E09 */
129 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E0A */
130 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E0B */
131 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E0C */
132 MAK_FUNC_0 (cc_em_cc_event_req , EM_CC_EVENT_REQ ), /* 0x3E0D */
133 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E0E */
134 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E0F */
135 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x3E10 */
136 MAK_FUNC_N (pei_not_supported , 0 ) /* 0x3E11 */
137 };
138 #endif /* FF_EM_MODE */
139
140 /*
141 +--------------------------------------------------------------------+
142 | PROJECT : GSM-PS (6147) MODULE : CC_PEI |
143 | STATE : code ROUTINE : pei_primitive |
144 +--------------------------------------------------------------------+
145
146 PURPOSE : Process protocol specific primitive.
147
148 */
149
150 LOCAL SHORT pei_primitive (void * ptr)
151 {
152 T_PRIM *prim = ptr;
153 /*
154 * | |
155 * MNCC EM UPLINK
156 * | |
157 * +-------v----------v-------+
158 * | CC |
159 * | |
160 * +-------------^------------+
161 * |
162 * MMCM DOWNLINK
163 * |
164 *
165 */
166
167 TRACE_FUNCTION ("pei_primitive()");
168
169 if (prim NEQ NULL)
170 {
171 ULONG opc = prim->custom.opc;
172 USHORT n;
173 const T_FUNC *table;
174
175 VSI_PPM_REC ((T_PRIM_HEADER*)prim, __FILE__, __LINE__);
176
177 PTRACE_IN (opc);
178
179 switch (SAP_NR(opc))
180 {
181 case SAP_NR(MNCC_UL): table = mncc_table; n = TAB_SIZE (mncc_table); break;
182 case SAP_NR(MMCM_DL): table = mmcm_table; n = TAB_SIZE (mmcm_table); break;
183 #ifdef FF_EM_MODE
184 case EM_Ul: table = em_table; n = TAB_SIZE ( em_table); break;
185 #endif /* FF_EM_MODE */
186
187 default : table = NULL; n = 0; break;
188 }
189
190 if (table != NULL )
191 {
192 if (PRIM_NR(opc) < n)
193 {
194 table += PRIM_NR(opc);
195 #ifdef PALLOC_TRANSITION
196 P_SDU(prim) = table->soff ? (T_sdu*) (((char*)&prim->data) + table->soff) : 0;
197 #ifndef NO_COPY_ROUTING
198 P_LEN(prim) = table->size + sizeof (T_PRIM_HEADER);
199 #endif /* #ifndef NO_COPY_ROUTING */
200 #endif /* #ifdef PALLOC_TRANSITION */
201 JUMP (table->func) (P2D(prim));
202 }
203 else
204 {
205 pei_not_supported (P2D(prim));
206 }
207 return PEI_OK;
208 }
209
210 #ifdef GSM_ONLY
211 PFREE (P2D(prim))
212 return PEI_ERROR;
213 #else
214 if (opc & SYS_MASK)
215 vsi_c_primitive (VSI_CALLER prim);
216 else
217 {
218 PFREE (P2D(prim));
219 return PEI_ERROR;
220 }
221 #endif /* else, #ifdef GSM_ONLY */
222 }
223 return PEI_OK;
224 }
225
226 /*
227 +--------------------------------------------------------------------+
228 | PROJECT : GSM-PS (6147) MODULE : CC_PEI |
229 | STATE : code ROUTINE : cc_pei_primitive |
230 +--------------------------------------------------------------------+
231
232 PURPOSE : Re-use a stored primitive
233
234 */
235
236 GLOBAL void cc_pei_primitive (T_PRIM * prim)
237 {
238 pei_primitive (prim);
239 }
240 /*
241 +--------------------------------------------------------------------+
242 | PROJECT : GSM-PS (6147) MODULE : CC_PEI |
243 | STATE : code ROUTINE : pei_not_supported |
244 +--------------------------------------------------------------------+
245
246 PURPOSE : An unsupported primitive is received.
247
248 */
249
250 LOCAL void pei_not_supported (void *data)
251 {
252 TRACE_FUNCTION ("pei_not_supported()");
253
254 PFREE (data);
255 }
256
257
258 /*
259 +--------------------------------------------------------------------+
260 | PROJECT : GSM-PS (6147) MODULE : CC_PEI |
261 | STATE : code ROUTINE : pei_init |
262 +--------------------------------------------------------------------+
263
264 PURPOSE : Initialize Protocol Stack Entity
265
266 */
267
268 LOCAL SHORT pei_init (T_HANDLE handle)
269 {
270 cc_handle = handle;
271
272 TRACE_FUNCTION ("pei_init()");
273
274 #ifdef TI_PS_HCOMM_CHANGE
275 if (!cl_hcom_all_handles_open())
276 {
277 return PEI_ERROR;
278 }
279 #else /* for hCommHandles backward compatibility */
280
281 if (hCommMMI < VSI_OK)
282 {
283 /*
284 * Open MMI (Layer 4)
285 */
286
287 if ((hCommMMI = vsi_c_open (VSI_CALLER ACI_NAME)) < VSI_OK)
288 return PEI_ERROR;
289 }
290
291 if (hCommMM < VSI_OK)
292 {
293 if ((hCommMM = vsi_c_open (VSI_CALLER MM_NAME)) < VSI_OK)
294 return PEI_ERROR;
295 }
296 #endif
297
298 /*
299 * Initialize data base
300 */
301
302 ccd_init ();
303 pcm_Init ();
304 cc_init ();
305 for_init ();
306
307 #ifdef FF_EM_MODE
308 em_init_cc_event_trace();
309 #endif /* FF_EM_MODE */
310
311 return PEI_OK;
312 }
313
314 /*
315 +--------------------------------------------------------------------+
316 | PROJECT : GSM-PS (6147) MODULE : CC_PEI |
317 | STATE : code ROUTINE : pei_timeout |
318 +--------------------------------------------------------------------+
319
320 PURPOSE : Process timeout
321
322 */
323
324 LOCAL SHORT pei_timeout (USHORT index)
325 {
326 tim_exec_timeout (index);
327 return PEI_OK;
328 }
329
330 #ifdef _SIMULATION_
331 /*
332 +--------------------------------------------------------------------+
333 | PROJECT : GSM-PS (6147) MODULE : CC_PEI |
334 | STATE : code ROUTINE : pei_exit |
335 +--------------------------------------------------------------------+
336
337 PURPOSE : Close Resources and terminate
338
339 */
340 LOCAL SHORT pei_exit (void)
341 {
342 GET_INSTANCE_DATA;
343 TRACE_FUNCTION ("pei_exit()");
344 /*
345 * Free all allocated primitives
346 */
347 srv_free_stored_setup ();
348
349 if (cc_data->stored_ccbs_setup NEQ NULL)
350 {
351 PFREE (cc_data->stored_ccbs_setup);
352 cc_data->stored_ccbs_setup = NULL;
353 }
354
355 /*
356 * clean up communication
357 */
358 #ifdef TI_PS_HCOMM_CHANGE
359 #else /* for hCommHandles backward compatibility */
360 vsi_c_close (VSI_CALLER hCommMMI);
361 hCommMMI = VSI_ERROR;
362
363 vsi_c_close (VSI_CALLER hCommMM);
364 hCommMM = VSI_ERROR;
365 #endif
366 return PEI_OK;
367 }
368 #endif /* _SIMULATION_ */
369
370 /*
371 +--------------------------------------------------------------------+
372 | PROJECT : GSM-PS (6147) MODULE : CC_PEI |
373 | STATE : code ROUTINE : pei_config |
374 +--------------------------------------------------------------------+
375
376 PURPOSE : Dynamic Configuration
377
378 */
379
380 #if !defined (NCONFIG)
381 LOCAL const KW_DATA kwtab[] = {
382 #if defined (WIN32)
383 CC_STD, ID_STD,
384 #endif
385 "", 0
386 };
387 #endif /* !NCONFIG */
388
389 /* Implements Measure#36 */
390 #if !defined(NCONFIG)
391 LOCAL SHORT pei_config (T_PEI_CONFIG inString)
392 {
393 char * s = inString;
394 SHORT valno;
395 char * keyw;
396 char * val [10];
397
398 TRACE_FUNCTION ("pei_config()");
399 TRACE_EVENT (s);
400
401 tok_init(s);
402
403 /*
404 * Parse next keyword and number of variables
405 */
406 while ((valno=tok_next(&keyw,val)) NEQ TOK_EOCS)
407 {
408 switch ( tok_key((KW_DATA *)kwtab,keyw))
409 {
410 case TOK_NOT_FOUND:
411 TRACE_ERROR ("[PEI_CONFIG]: Illegal Keyword");
412 TRACE_EVENT_P1("val no: %d", valno); /* Dummy trace event to avoid warning for valno*/
413 break;
414 #ifdef WIN32
415 case ID_STD:
416 if (valno EQ 1)
417 {
418 EXTERN UBYTE pcm_read;
419 std = atoi (val[0]);
420 pcm_read = FALSE;
421 pcm_Init ();
422 }
423 else
424 {
425 TRACE_ERROR ("[PEI_CONFIG]: Wrong Number of Parameters");
426 }
427 break;
428 #endif /* WIN32 */
429
430 default:
431 break;
432 }
433
434
435 }
436 return PEI_OK;
437 }
438 #endif /* !NCONFIG */
439
440
441 /*
442 +--------------------------------------------------------------------+
443 | PROJECT : GSM-PS (6147) MODULE : CC_PEI |
444 | STATE : code ROUTINE : cc_pei_config |
445 +--------------------------------------------------------------------+
446
447 PURPOSE : Dynamic Configuration
448
449 */
450 /* Implements Measure#36 */
451 #if !defined(NCONFIG)
452 GLOBAL SHORT cc_pei_config ( char * inString, char * dummy )
453 {
454 pei_config ( inString );
455
456 return PEI_OK;
457 }
458 #endif /* !NCONFIG */
459
460
461 /*
462 +--------------------------------------------------------------------+
463 | PROJECT : GSM-PS (6147) MODULE : CC_PEI |
464 | STATE : code ROUTINE : pei_monitor |
465 +--------------------------------------------------------------------+
466
467 PURPOSE : Monitoring of physical Parameters
468
469 */
470
471
472 LOCAL SHORT pei_monitor (void ** monitor)
473 {
474 TRACE_FUNCTION ("pei_monitor()");
475
476 /* Implements Measure#32: Row 99 */
477
478 * monitor = &cc_mon;
479
480 return PEI_OK;
481 }
482
483 /*
484 +--------------------------------------------------------------------+
485 | PROJECT : GSM-PS (6147) MODULE : CC_PEI |
486 | STATE : code ROUTINE : pei_create |
487 +--------------------------------------------------------------------+
488
489 PURPOSE : Create the Protocol Stack Entity
490
491 */
492
493
494 GLOBAL SHORT cc_pei_create (T_PEI_INFO **info)
495 {
496 static const T_PEI_INFO pei_info =
497 {
498 "CC",
499 {
500 pei_init,
501 #ifdef _SIMULATION_
502 pei_exit,
503 #else
504 NULL,
505 #endif
506 pei_primitive,
507 pei_timeout,
508 NULL, /* no signal function */
509 NULL, /* no run function */
510 /* Implements Measure#36 */
511 #if defined(NCONFIG)
512 NULL, /* no pei_config function */
513 #else /* not NCONFIG */
514 pei_config,
515 #endif /* NCONFIG */
516 pei_monitor,
517 },
518 1024, /* Stack Size */
519 10, /* Queue Entries */
520 165, /* Priority */
521 NUM_OF_CC_TIMERS, /* number of timer */
522 0x03|PRIM_NO_SUSPEND /* flags */
523 };
524
525 TRACE_FUNCTION ("pei_create()");
526
527 /*
528 * Close Resources if open
529 */
530
531 #ifdef _SIMULATION_
532 if (first_access)
533 first_access = FALSE;
534 else
535 pei_exit ();
536 #endif
537
538 /*
539 * Export startup configuration data
540 */
541
542 *info = (T_PEI_INFO *)&pei_info;
543
544 return PEI_OK;
545 }
546
547 #endif /* #ifndef CC_PEI_C */