comparison src/g23m-gsm/ss/ss_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 SS of the mobile station.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef SS_PEI_C
23 #define SS_PEI_C
24
25 #define ENTITY_SS
26
27
28 /*==== INCLUDES ===================================================*/
29 #if defined (NEW_FRAME)
30
31 #include <string.h>
32 #include <stdlib.h>
33 #include <stddef.h>
34 #include "typedefs.h"
35 #include "pcm.h"
36 #include "pconst.cdg"
37 #include "mconst.cdg"
38 #include "message.h"
39 #include "ccdapi.h"
40 #include "vsi.h"
41 #include "custom.h"
42 #include "gsm.h"
43 #include "prim.h"
44 #include "cnf_ss.h"
45 #include "mon_ss.h"
46 #include "pei.h"
47 #include "tok.h"
48 #include "ss.h"
49 #include "ss_em.h"
50
51 #else
52
53 #include <string.h>
54 #include <stdlib.h>
55 #include <stddef.h>
56 #include "stddefs.h"
57 #include "pcm.h"
58 #include "pconst.cdg"
59 #include "mconst.cdg"
60 #include "message.h"
61 #include "ccdapi.h"
62 #include "custom.h"
63 #include "gsm.h"
64 #include "prim.h"
65 #include "cnf_ss.h"
66 #include "mon_ss.h"
67 #include "vsi.h"
68 #include "pei.h"
69 #include "tok.h"
70 #include "ss.h"
71 #include "ss_em.h"
72
73 #endif
74
75 /*==== CONST ======================================================*/
76 /*
77 * instance management
78 */
79 #ifdef OPTION_MULTIPLE_INSTANCE
80 #define GET_INSTANCE(p) &ss_data_base[p->custom.route.inst_no]
81 #else
82 #define GET_INSTANCE(p) &ss_data_base
83 #endif
84
85 /*==== VAR EXPORT =================================================*/
86 #ifdef TI_PS_HCOMM_CHANGE
87 #if defined (NEW_FRAME)
88 GLOBAL T_HANDLE ss_handle;
89 #endif
90 #else /* TI_PS_HCOMM_CHANGE */
91 #if defined (NEW_FRAME)
92 GLOBAL T_HANDLE hCommMMI = VSI_ERROR;/* MMI Communication */
93 GLOBAL T_HANDLE hCommMM = VSI_ERROR;/* MM Communication */
94 GLOBAL T_HANDLE ss_handle;
95 #else
96 GLOBAL T_VSI_CHANDLE hCommMMI = VSI_ERROR;/* MMI Communication */
97 GLOBAL T_VSI_CHANDLE hCommMM = VSI_ERROR;/* MM Communication */
98 #endif
99 #endif /* TI_PS_HCOMM_CHANGE */
100
101 #ifdef OPTION_MULTI_INSTANCE
102 GLOBAL T_SS_DATA ss_data_base [SS_INSTANCES];
103 #else
104 GLOBAL T_SS_DATA ss_data_base;
105 #endif
106
107
108 /*==== VAR LOCAL ==================================================*/
109 #ifdef _SIMULATION_
110 LOCAL BOOL first_access = TRUE;
111 #endif
112
113 LOCAL T_MONITOR ss_mon;
114
115 /*==== FUNCTIONS ==================================================*/
116
117 /*
118 +--------------------------------------------------------------------+
119 | PROJECT : GSM-PS (6147) MODULE : SS_PEI |
120 | STATE : code ROUTINE : pei_not_supported |
121 +--------------------------------------------------------------------+
122
123 PURPOSE : An unsupported primitive is received.
124
125 */
126 LOCAL void pei_not_supported (void *data)
127 {
128 TRACE_FUNCTION ("pei_not_supported()");
129
130 PFREE (data)
131 }
132
133 LOCAL const T_FUNC mnss_table[] = {
134 MAK_FUNC_0 (ss_mnss_begin_req , MNSS_BEGIN_REQ ),
135 MAK_FUNC_0 (ss_mnss_facility_req, MNSS_FACILITY_REQ),
136 MAK_FUNC_0 (ss_mnss_end_req , MNSS_END_REQ )
137 };
138
139 LOCAL const T_FUNC mmss_table[] = {
140 MAK_FUNC_S (for_mmss_data_ind , MMSS_DATA_IND ),
141 MAK_FUNC_0 ( ss_mmss_error_ind , MMSS_ERROR_IND ),
142 MAK_FUNC_0 ( ss_mmss_establish_cnf, MMSS_ESTABLISH_CNF),
143 MAK_FUNC_S (for_mmss_establish_ind, MMSS_ESTABLISH_IND),
144 MAK_FUNC_0 ( ss_mmss_release_ind , MMSS_RELEASE_IND )
145 };
146
147 #ifdef FF_EM_MODE
148 LOCAL const T_FUNC em_table[] = {
149 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x00 */
150 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x01 */
151 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x02 */
152 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x03 */
153 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x04 */
154 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x05 */
155 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x06 */
156 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x07 */
157 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x08 */
158 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x09 */
159 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x0A */
160 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x0B */
161 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x0C */
162 MAK_FUNC_N (pei_not_supported , 0 ), /* 0x0D */
163 MAK_FUNC_0 (ss_em_ss_event_req , EM_SS_EVENT_REQ ) /* 0x0E */
164 };
165 #endif /* FF_EM_MODE */
166
167 /*
168 +--------------------------------------------------------------------+
169 | PROJECT : GSM-PS (6147) MODULE : SS_PEI |
170 | STATE : code ROUTINE : pei_primitive |
171 +--------------------------------------------------------------------+
172
173 PURPOSE : Process protocol specific primitive.
174
175 */
176 #if defined (NEW_FRAME)
177 LOCAL SHORT pei_primitive (void * ptr)
178 #else
179 T_PEI_RETURN pei_primitive (T_PRIM * prim)
180 #endif
181 {
182 #if defined (NEW_FRAME)
183 T_PRIM *prim = ptr;
184 #endif
185 /*
186 * | |
187 * MNSS EM UPLINK
188 * | |
189 * +-------v----------v-------+
190 * | |
191 * | SS |
192 * | |
193 * +-------------^------------+
194 * |
195 * MMSS DOWNLINK
196 * |
197 *
198 */
199
200 TRACE_FUNCTION ("pei_primitive()");
201
202 /*
203 * No timer functionality
204 */
205
206 if (prim NEQ NULL)
207 {
208 ULONG opc = prim->custom.opc;
209 USHORT n;
210 const T_FUNC *table;
211 #if defined (NEW_FRAME)
212 VSI_PPM_REC ((T_PRIM_HEADER*)prim, __FILE__, __LINE__);
213 #endif
214
215 PTRACE_IN (opc);
216
217 switch (SAP_NR(opc))
218 {
219 case SAP_NR(MNSS_UL): table = mnss_table; n = TAB_SIZE (mnss_table); break;
220 case SAP_NR(MMSS_DL): table = mmss_table; n = TAB_SIZE (mmss_table); break;
221 #ifdef FF_EM_MODE
222 case EM_Ul: table = em_table; n = TAB_SIZE ( em_table); break;
223 #endif /* FF_EM_MODE */
224 default: table = NULL; n = 0; break;
225 }
226
227 if (table != NULL)
228 {
229 if (PRIM_NR(opc) < n)
230 {
231 table += PRIM_NR(opc);
232 #ifdef PALLOC_TRANSITION
233 P_SDU(prim) = table->soff ? (T_sdu*) (((char*)&prim->data) + table->soff) : 0;
234 #ifndef NO_COPY_ROUTING
235 P_LEN(prim) = table->size + sizeof (T_PRIM_HEADER);
236 #endif /* NO_COPY_ROUTING */
237 #endif /* PALLOC_TRANSITION */
238 JUMP (table->func) (P2D(prim));
239 }
240 else
241 {
242 pei_not_supported (P2D(prim));
243 }
244 return PEI_OK;
245 }
246
247 /*
248 * Primitive is no GSM Primitive
249 * then forward to the environment
250 */
251
252 #ifdef GSM_ONLY
253 PFREE (P2D(prim))
254
255 return PEI_ERROR;
256 #else
257 if (opc & SYS_MASK)
258 vsi_c_primitive (VSI_CALLER prim);
259 else
260 {
261 PFREE (P2D(prim));
262 return PEI_ERROR;
263 }
264 #endif
265 }
266 return PEI_OK;
267 }
268
269 /*
270 +--------------------------------------------------------------------+
271 | PROJECT : GSM-PS (6147) MODULE : SS_PEI |
272 | STATE : code ROUTINE : pei_init |
273 +--------------------------------------------------------------------+
274
275 PURPOSE : Initialize Protocol Stack Entity
276
277 */
278 #if defined (NEW_FRAME)
279 LOCAL SHORT pei_init (T_HANDLE handle)
280 #else
281 T_PEI_RETURN pei_init (void)
282 #endif
283 {
284 #ifdef OPTION_MULTI_INSTANCE
285 USHORT i;
286 #endif
287
288 #if defined (NEW_FRAME)
289 ss_handle = handle;
290 #endif
291
292 TRACE_FUNCTION ("pei_init()");
293 #ifdef TI_PS_HCOMM_CHANGE
294 if (!cl_hcom_all_handles_open())
295 {
296 return PEI_ERROR;
297 }
298 #else /* for hCommHandles backward compatibility */
299 if (hCommMMI < VSI_OK)
300 {
301 /*
302 * Open MMI (Layer 4)
303 */
304
305 if ((hCommMMI = vsi_c_open (VSI_CALLER ACI_NAME)) < VSI_OK)
306 return PEI_ERROR;
307 }
308
309 if (hCommMM < VSI_OK)
310 {
311 if ((hCommMM = vsi_c_open (VSI_CALLER MM_NAME)) < VSI_OK)
312 return PEI_ERROR;
313 }
314 #endif
315
316 #ifdef OPTION_MULTI_INSTANCE
317 for (i=0;i<MAX_INSTANCES;i++)
318 ss_init_ss_data (&ss_data_base[i]);
319 #else
320 ss_init_ss_data ();
321 #endif
322 ccd_init ();
323
324 #ifdef FF_EM_MODE
325 em_init_ss_event_trace();
326 #endif /* FF_EM_MODE */
327
328 return PEI_OK;
329 }
330
331 /*
332 +--------------------------------------------------------------------+
333 | PROJECT : GSM-PS (6147) MODULE : SS_PEI |
334 | STATE : code ROUTINE : pei_timeout |
335 +--------------------------------------------------------------------+
336
337 PURPOSE : Process timeout
338
339 */
340 #if !defined (NEW_FRAME)
341 T_PEI_RETURN pei_timeout (T_VSI_THANDLE handle)
342 {
343 TRACE_FUNCTION ("pei_timeout ()");
344 /*
345 * No Timer Functionality
346 */
347
348 return PEI_OK;
349 }
350 #endif
351
352
353 #ifdef _SIMULATION_
354 /*
355 +--------------------------------------------------------------------+
356 | PROJECT : GSM-PS (6147) MODULE : SS_PEI |
357 | STATE : code ROUTINE : pei_exit |
358 +--------------------------------------------------------------------+
359
360 PURPOSE : Close Resources and terminate
361
362 */
363 #if defined (NEW_FRAME)
364 LOCAL SHORT pei_exit (void)
365 #else
366 T_PEI_RETURN pei_exit (void)
367 #endif
368 {
369 TRACE_FUNCTION ("pei_exit()");
370
371 /*
372 * clean up communication
373 */
374 #ifdef TI_PS_HCOMM_CHANGE
375 #else /* for hCommHandles backward compatibility */
376 vsi_c_close (VSI_CALLER hCommMMI);
377 hCommMMI = VSI_ERROR;
378
379 vsi_c_close (VSI_CALLER hCommMM);
380 hCommMM = VSI_ERROR;
381 #endif
382 return PEI_OK;
383 }
384 #endif
385
386 /*
387 +--------------------------------------------------------------------+
388 | PROJECT : GSM-PS (6147) MODULE : SS_PEI |
389 | STATE : code ROUTINE : pei_run |
390 +--------------------------------------------------------------------+
391
392 PURPOSE : Process Primitives, main loop is located in the
393 Protocol Stack Entity
394
395 */
396 #if !defined (NEW_FRAME)
397 T_PEI_RETURN pei_run (T_VSI_CHANDLE handle)
398 {
399 return PEI_OK;
400 }
401 #endif
402
403 /*
404 +--------------------------------------------------------------------+
405 | PROJECT : GSM-PS (6147) MODULE : SS_PEI |
406 | STATE : code ROUTINE : pei_config |
407 +--------------------------------------------------------------------+
408
409 PURPOSE : Dynamic Configuration
410
411 */
412 /* Implements Measure#36 */
413 #ifndef NCONFIG
414 #if defined (NEW_FRAME)
415 LOCAL SHORT pei_config (T_PEI_CONFIG inString)
416 #else
417 T_PEI_RETURN pei_config (T_PEI_CONFIG inString,
418 T_PEI_CONFIG outString)
419 #endif
420 {
421 return PEI_OK;
422 }
423 #endif /* !NCONFIG */
424
425 #if defined (NEW_FRAME)
426 /*
427 +--------------------------------------------------------------------+
428 | PROJECT : GSM-PS (6147) MODULE : SS_PEI |
429 | STATE : code ROUTINE : ss_pei_config |
430 +--------------------------------------------------------------------+
431
432 PURPOSE : Dynamic Configuration
433
434 */
435 /* Implements Measure#36 */
436 #ifndef NCONFIG
437 GLOBAL SHORT ss_pei_config ( char * inString, char * dummy )
438 {
439 pei_config ( inString );
440
441 return PEI_OK;
442 }
443 #endif /* !NCONFIG */
444 #endif
445
446 /*
447 +--------------------------------------------------------------------+
448 | PROJECT : GSM-PS (6147) MODULE : SS_PEI |
449 | STATE : code ROUTINE : pei_monitor |
450 +--------------------------------------------------------------------+
451
452 PURPOSE : Monitoring of physical Parameters
453
454 */
455 #if defined (NEW_FRAME)
456 LOCAL SHORT pei_monitor (void ** monitor)
457 #else
458 T_PEI_RETURN pei_monitor (void ** monitor)
459 #endif
460 {
461 TRACE_FUNCTION ("pei_monitor()");
462
463 /* Implements Measure#32: Row 12 */
464
465 *monitor = &ss_mon;
466
467 return PEI_OK;
468 }
469
470 /*
471 +--------------------------------------------------------------------+
472 | PROJECT : GSM-PS (6147) MODULE : SS_PEI |
473 | STATE : code ROUTINE : pei_create |
474 +--------------------------------------------------------------------+
475
476 PURPOSE : Create the Protocol Stack Entity
477
478 */
479 #if defined (NEW_FRAME)
480 GLOBAL SHORT ss_pei_create (T_PEI_INFO **info)
481 {
482 static const T_PEI_INFO pei_info =
483 {
484 "SS",
485 {
486 pei_init,
487 #ifdef _SIMULATION_
488 pei_exit,
489 #else
490 NULL,
491 #endif
492 pei_primitive,
493 NULL, /* no timeout function */
494 NULL, /* no signal function */
495 NULL, /* no run function */
496 /* Implements Measure#36 */
497 #ifdef NCONFIG
498 NULL, /* no pei_config function */
499 #else /* NCONFIG */
500 pei_config,
501 #endif /* NCONFIG */
502 pei_monitor,
503 },
504 924, /* Stack Size */
505 10, /* Queue Entries */
506 145, /* Priority */
507 0, /* number of timer */
508 0x03|PRIM_NO_SUSPEND /* flags */
509 };
510
511 TRACE_FUNCTION ("pei_create()");
512
513 /*
514 * Close Resources if open
515 */
516
517 #ifdef _SIMULATION_
518 if (first_access)
519 first_access = FALSE;
520 else
521 pei_exit ();
522 #endif
523
524 /*
525 * Export startup configuration data
526 */
527
528 *info = (T_PEI_INFO *)&pei_info;
529
530 return PEI_OK;
531 }
532
533 #else
534
535 T_PEI_RETURN pei_create (T_VSI_CNAME * name)
536 {
537 TRACE_FUNCTION ("pei_create()")
538
539 /*
540 * Close Resources if open
541 */
542
543 #ifdef _SIMULATION_
544 if (first_access)
545 first_access = FALSE;
546 else
547 pei_exit ();
548 #endif
549
550 /*
551 * Initialize entity data
552 */
553
554 *name = SS_NAME;
555
556 return PEI_OK;
557 }
558 #endif
559
560 #endif