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