comparison src/g23m-fad/fad/fad_pei.c @ 174:90eb61ecd093

src/g23m-fad: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 12 Oct 2016 05:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
173:bf64d785238a 174:90eb61ecd093
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 component Fax Adaptation 3.45 of the mobile station.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef FAD_PEI_C
23 #define FAD_PEI_C
24 #endif
25
26 #define ENTITY_FAD
27
28 /*==== INCLUDES ===================================================*/
29
30 #include <string.h>
31 #include <stdlib.h>
32 #include <stddef.h>
33 #include "typedefs.h"
34 #include "pcm.h"
35 #include "vsi.h"
36 #include "custom.h"
37 #include "gsm.h"
38 #include "message.h"
39 #include "ccdapi.h"
40 #include "prim.h"
41 #include "cus_fad.h"
42 #include "cnf_fad.h"
43 #include "mon_fad.h"
44 #include "pei.h"
45 #include "tok.h"
46 #include "fad.h"
47
48 /*==== CONST ======================================================*/
49
50 /*==== VAR EXPORT =================================================*/
51
52 /*==== VAR LOCAL ==================================================*/
53
54 LOCAL BOOL first_access = TRUE;
55 LOCAL T_MONITOR fad_mon;
56
57 /*==== FUNCTIONS ==================================================*/
58
59 /*
60 +--------------------------------------------------------------------+
61 | PROJECT : GSM-F&D (8411) MODULE : FAD_PEI |
62 | STATE : code ROUTINE : pei_not_supported |
63 +--------------------------------------------------------------------+
64
65 PURPOSE : An unsupported primitive is received.
66
67 */
68
69 LOCAL void pei_not_supported (void *data)
70 {
71 TRACE_FUNCTION ("pei_not_supported()");
72 PFREE (data);
73 }
74
75 /*
76 *
77 * Use MAK_FUNC_0 for primitives which contains no SDU.
78 *
79 * Use MAK_FUNC_S for primitives which contains a SDU.
80 */
81
82 /*
83 * jumptable for the entity service access point. Contains
84 * the processing-function addresses and opcodes of
85 * request and response primitives.
86 *
87 */
88
89 LOCAL const T_FUNC fad_table[] = {
90 MAK_FUNC_0( ker_fad_activate_req , FAD_ACTIVATE_REQ ),
91 MAK_FUNC_0( ker_fad_deactivate_req, FAD_DEACTIVATE_REQ ),
92 MAK_FUNC_0( ker_fad_modify_req, FAD_MODIFY_REQ ),
93 MAK_FUNC_S( ker_fad_data_req, FAD_DATA_REQ ),
94 MAK_FUNC_0( ker_fad_snd_tcf_req, FAD_SND_TCF_REQ ),
95 MAK_FUNC_0( ker_fad_rcv_tcf_req, FAD_RCV_TCF_REQ ),
96 MAK_FUNC_0( ker_fad_ready_req, FAD_READY_REQ ),
97 MAK_FUNC_0( ker_fad_ignore_req , FAD_IGNORE_REQ )
98 };
99
100 /*
101 * jumptable for the service access point which are used by
102 * the entity. Contains the processing-function addresses and
103 * opcodes of indication and confirm primitives.
104 *
105 */
106 LOCAL const T_FUNC ra_table[] = {
107 MAK_FUNC_0( snd_ra_ready_ind, RA_READY_IND ),
108 MAK_FUNC_S( rcv_ra_data_ind, RA_DATA_IND )
109 };
110
111 /*
112 +--------------------------------------------------------------------+
113 | PROJECT : GSM-F&D (8411) MODULE : FAD_PEI |
114 | STATE : code ROUTINE : pei_primitive |
115 +--------------------------------------------------------------------+
116
117 PURPOSE : Process protocol specific primitive.
118
119 */
120 LOCAL SHORT pei_primitive (void * ptr)
121 {
122 T_PRIM *prim = ptr;
123 /*
124 * @ADAPT@
125 * |
126 * T30 UPPER LAYER
127 * |
128 * v
129 * +-----------(fad)----------+
130 * | |
131 * | FAD |
132 * | |
133 * +-------------^------------+
134 * |
135 * RA LOWER LAYER
136 * |
137 *
138 */
139
140 TRACE_FUNCTION ("pei_primitive()");
141
142 if (prim NEQ NULL)
143 {
144 ULONG opc = prim->custom.opc;
145 USHORT n;
146 const T_FUNC *table;
147
148 VSI_PPM_REC ((T_PRIM_HEADER *)prim, __FILE__, __LINE__);
149 PTRACE_IN (opc);
150 fad_data = GET_INSTANCE (prim);
151
152 switch (SAP_NR(opc))
153 {
154 case SAP_NR(FAD_UL): table = fad_table; n = TAB_SIZE (fad_table); break;
155 case SAP_NR(RA_DL ): table = ra_table; n = TAB_SIZE (ra_table); break;
156 default : table = NULL; n = 0; break;
157 }
158
159 if (table NEQ NULL )
160 {
161 if (PRIM_NR(opc) < n)
162 {
163 table += PRIM_NR(opc);
164 #ifdef PALLOC_TRANSITION
165 P_SDU(prim) = table->soff ? (T_sdu*) (((char*)&prim->data) + table->soff) : 0;
166 #ifndef NO_COPY_ROUTING
167 P_LEN(prim) = table->size + sizeof (T_PRIM_HEADER);
168 #endif /* NO_COPY_ROUTING */
169 #endif /* PALLOC_TRANSITION */
170 JUMP (table->func) (P2D(prim));
171 }
172 else
173 {
174 pei_not_supported (P2D(prim));
175 }
176 return PEI_OK;
177 }
178 /*
179 * Primitive is no GSM Primitive
180 * then forward to the environment
181 */
182
183 #ifdef GSM_ONLY
184 PFREE (P2D(prim))
185 return PEI_ERROR;
186 #else
187 if (opc & SYS_MASK)
188 vsi_c_primitive (VSI_CALLER prim);
189 else
190 {
191 PFREE (P2D(prim));
192 return PEI_ERROR;
193 }
194 #endif
195 }
196 return PEI_OK;
197 }
198
199 /*
200 +--------------------------------------------------------------------+
201 | PROJECT : GSM-F&D (8411) MODULE : FAD_PEI |
202 | STATE : code ROUTINE : pei_init |
203 +--------------------------------------------------------------------+
204
205 PURPOSE : Initialize Protocol Stack Entity
206
207 */
208 LOCAL SHORT pei_init (T_HANDLE handle)
209 {
210 TRACE_FUNCTION ("pei_init()");
211
212 fad_handle = handle;
213
214 if (hCommT30 < VSI_OK)
215 {
216 if ((hCommT30 = vsi_c_open (VSI_CALLER T30_NAME)) < VSI_OK)
217 return PEI_ERROR;
218 }
219
220 #ifdef _SIMULATION_
221 if (hCommRA < VSI_OK)
222 {
223 if ((hCommRA = vsi_c_open (VSI_CALLER RA_NAME)) < VSI_OK)
224 return PEI_ERROR;
225 }
226 #endif
227
228 fad_data = &fad_data_base[0];
229 fad_data_magic_num = 0; /* memory is not yet initialized */
230 return PEI_OK;
231 }
232
233 /*
234 +--------------------------------------------------------------------+
235 | PROJECT : GSM-F&D (8411) MODULE : FAD_PEI |
236 | STATE : code ROUTINE : pei_timeout |
237 +--------------------------------------------------------------------+
238
239 PURPOSE : Process timeout
240
241 */
242 LOCAL SHORT pei_timeout (USHORT index)
243 {
244
245 fad_exec_timeout (index);
246
247 return PEI_OK;
248 }
249
250 /*
251 +--------------------------------------------------------------------+
252 | PROJECT : GSM-F&D (8411) MODULE : FAD_PEI |
253 | STATE : code ROUTINE : pei_signal |
254 +--------------------------------------------------------------------+
255
256 PURPOSE : Functional interface to signal a primitive.
257
258 */
259
260 LOCAL SHORT pei_signal (ULONG opc, void *primData)
261 {
262 #ifdef OPTION_SIGNAL
263
264 if (fad_data_magic_num NEQ FAD_DATA_MAGIC_NUM)
265 /* memory is not initialized */
266 {
267 /* ignore received signals */
268 return PEI_OK;
269 }
270
271 fad_data = GET_INSTANCE (primData);
272
273 switch (opc)
274 {
275 case RA_DATA_IND:
276 rcv_ra_data_ind
277 (
278 (T_RA_DATA_IND *)primData
279 );
280 break;
281 case RA_READY_IND:
282 snd_ra_ready_ind
283 (
284 (T_RA_READY_IND *)primData
285 );
286 break;
287 }
288 #endif
289 return PEI_OK;
290 }
291
292 /*
293 +--------------------------------------------------------------------+
294 | PROJECT : GSM-F&D (8411) MODULE : FAD_PEI |
295 | STATE : code ROUTINE : pei_exit |
296 +--------------------------------------------------------------------+
297
298 PURPOSE : Close Resources and terminate
299
300 */
301
302 LOCAL SHORT pei_exit (void)
303 {
304 TRACE_FUNCTION ("pei_exit()");
305
306 /*
307 * clean up communication
308 */
309 vsi_c_close (VSI_CALLER hCommT30);
310 hCommT30= VSI_ERROR;
311
312 return PEI_OK;
313 }
314
315 /*
316 +--------------------------------------------------------------------+
317 | PROJECT : GSM-F&D (8411) MODULE : FAD_PEI |
318 | STATE : code ROUTINE : pei_config |
319 +--------------------------------------------------------------------+
320
321 PURPOSE : Dynamic Configuration
322
323 */
324
325 #if !defined (NCONFIG)
326
327 LOCAL KW_DATA kwtab[] = {
328 "", 0
329 };
330
331 #endif
332
333 LOCAL SHORT pei_config (T_PEI_CONFIG inString)
334 {
335 #if !defined (NCONFIG)
336 char *s = inString;
337 char *keyw;
338 char *val [10];
339
340 TRACE_FUNCTION ("pei_config()");
341 TRACE_EVENT (s);
342
343 tok_init (s);
344
345 /*
346 * Parse next keyword and number of variables
347 */
348
349 while (tok_next(&keyw,val) NEQ TOK_EOCS)
350 {
351 switch (tok_key((KW_DATA *)kwtab, keyw))
352 {
353 case TOK_NOT_FOUND:
354 TRACE_ERROR ("[PEI_CONFIG]: Illegal Keyword");
355 break;
356
357 default:
358 break;
359 }
360
361 }
362 #endif
363 return PEI_OK;
364 }
365
366 /*
367 +--------------------------------------------------------------------+
368 | PROJECT : GSM-F&D (8411) MODULE : FAD_PEI |
369 | STATE : code ROUTINE : pei_monitor |
370 +--------------------------------------------------------------------+
371
372 PURPOSE : Monitoring of physical Parameters
373
374 */
375 LOCAL SHORT pei_monitor (void **monitor)
376 {
377 TRACE_FUNCTION ("pei_monitor()");
378
379 fad_mon.version = VERSION_FAD;
380 *monitor = &fad_mon;
381 return PEI_OK;
382 }
383
384 /*
385 +--------------------------------------------------------------------+
386 | PROJECT : GSM-F&D (8411) MODULE : FAD_PEI |
387 | STATE : code ROUTINE : pei_create |
388 +--------------------------------------------------------------------+
389
390 PURPOSE : Create the Protocol Stack Entity
391
392 */
393
394 /*lint -e714 : Symbol not referenced */
395 /*lint -e765 : external could be made static */
396 GLOBAL SHORT fad_pei_create (T_PEI_INFO **info)
397 {
398 static const T_PEI_INFO pei_info =
399 {
400 "FAD",
401 {
402 pei_init,
403 pei_exit,
404 pei_primitive,
405 pei_timeout,
406 pei_signal,
407 NULL, /* no run function */
408 pei_config,
409 pei_monitor
410 },
411 1024, /* Stack Size */
412 10, /* Queue Entries */
413 215, /* Priority */
414 0, /* number of timer */
415 0x03|PRIM_NO_SUSPEND /* flags */
416 };
417
418 TRACE_FUNCTION ("pei_create()");
419
420 /*
421 * Close Resources if open
422 */
423
424 if (first_access)
425 first_access = FALSE;
426 else
427 pei_exit ();
428
429 /*
430 * Export startup configuration data
431 */
432
433 *info = (T_PEI_INFO *)&pei_info;
434
435 return PEI_OK;
436 }