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