comparison g23m-gsm/l1/l1_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 L1.
19 +-----------------------------------------------------------------------------
20 */
21
22 #define L1_PEI_C
23
24 #include "config.h"
25 #include "fixedconf.h"
26 #include "condat-features.h"
27
28 #define ENTITY_L1
29
30 #define CUST_OS_C
31 /*==== INCLUDES =============================================================*/
32
33 #if 1
34 #include <string.h>
35 #if defined (NEW_FRAME)
36 #include "typedefs.h" /* to get Condat data types */
37 #else
38 #include "stddefs.h" /* to get Condat data types */
39 #endif
40 #include "vsi.h" /* to get a lot of macros */
41 #include "custom.h"
42 #ifdef GPRS
43 #include "macdef.h"
44 #include "gprs.h"
45 #endif
46 #include "gsm.h" /* to get a lot of macros */
47 #include "prim.h" /* to get the definitions of used SAP and directions */
48 #include "pei.h" /* to get PEI interface */
49 #include "tools.h" /* to get common tools */
50 #include "l1.h" /* to get the global entity definitions */
51 #include "cust_os.h" /* to get cust_os definitions */
52
53 #else /* 1 */
54
55 #if defined NEW_FRAME
56
57 #include <string.h>
58 #include <stdio.h>
59 #include "typedefs.h"
60 #include "pconst.cdg"
61 #include "mconst.cdg"
62 #include "message.h"
63 #include "ccdapi.h"
64 #include "vsi.h"
65 #include "custom.h"
66 #include "gsm.h"
67 #include "prim.h"
68 #include "cnf_l1.h"
69 #include "mon_l1.h"
70 #include "cus_l1.h"
71 #include "pei.h"
72 #include "tok.h"
73 #include "l1.h"
74
75 #else
76
77 #include <string.h>
78 #include <stdio.h>
79 #include "stddefs.h"
80 #include "pconst.cdg"
81 #include "mconst.cdg"
82 #include "message.h"
83 #include "ccdapi.h"
84 #include "custom.h"
85 #include "gsm.h"
86 #include "prim.h"
87 #include "cnf_l1.h"
88 #include "mon_l1.h"
89 #include "vsi.h"
90 #include "pei.h"
91 #include "tok.h"
92 #include "l1.h"
93
94 #endif
95 #endif /* 1 */
96
97 /*==== CONSTS ================================================================*/
98
99 /*==== TYPES =================================================================*/
100
101 typedef struct
102 {
103 char *version;
104 } T_MONITOR;
105
106 /*==== LOCALS ================================================================*/
107
108 static T_MONITOR l1_mon;
109 static USHORT first_access = TRUE;
110
111 /*==== PROTOTYPES ============================================================*/
112
113 SHORT pei_create (T_PEI_INFO **info);
114
115 void l1_create_HISR (void);
116 void l1a_task(unsigned arcg, void *argv);
117
118 /*==== PRIVATE FUNCTIONS =====================================================*/
119
120
121 /*
122 +------------------------------------------------------------------------------
123 | Function : pei_primitive
124 +------------------------------------------------------------------------------
125 | Description : Process protocol specific primitive.
126 |
127 | Parameters : prim - pointer to the received primitive
128 |
129 | Return : PEI_OK - function succeeded
130 | PEI_ERROR - function failed
131 +------------------------------------------------------------------------------
132
133 | |
134 PL PPC(GPRS only) UPLINK
135 | |
136 +------v-----------v-------+
137 | |
138 | L1 ASYNC |
139 | |
140 +-------------^------------+
141 |
142 L1 SYNC DOWNLINK
143 |
144
145 */
146 #if defined (NEW_FRAME)
147 LOCAL SHORT pei_primitive (void * ptr)
148 #else
149 EXPORT T_PEI_RETURN pei_primitive (T_PRIM * prim)
150 #endif
151 {
152 #if defined (NEW_FRAME)
153 T_PRIM *prim = (T_PRIM*)ptr;
154 #endif
155
156 USHORT opc = prim->custom.opc;
157
158 /*
159 * primitive is not a GSM primitive - forward it to the environment
160 */
161 if (opc & SYS_MASK)
162 vsi_c_primitive (VSI_CALLER prim);
163 else
164 {
165 PFREE (P2D(prim));
166 return PEI_ERROR;
167 }
168
169 return PEI_OK;
170 }
171
172 /*
173 +------------------------------------------------------------------------------
174 | Function : pei_init
175 +------------------------------------------------------------------------------
176 | Description : Initialize Protocol Stack Entity
177 |
178 | Parameters : handle - task handle
179 |
180 | Return : PEI_OK - entity initialised
181 | PEI_ERROR - entity not (yet) initialised
182 +------------------------------------------------------------------------------
183 */
184 #if defined (NEW_FRAME)
185 LOCAL SHORT pei_init ( T_HANDLE Handle )
186 #else
187 T_PEI_RETURN pei_init (void)
188 #endif
189 {
190 #if defined (NEW_FRAME)
191 L1_Handle = Handle;
192 #endif
193
194
195
196 #ifdef TI_PS_HCOMM_CHANGE
197 #ifdef NEW_FRAME
198 if ( first_access == TRUE )
199 {
200 first_access = FALSE;
201 _osx_init();
202 }
203 #endif
204
205 if (!cl_hcom_all_handles_open()) return PEI_ERROR;
206
207 #ifdef NEW_FRAME
208 _osx_open (VSI_CALLER L1_QUEUE, _hCommL1);
209 #endif
210 _osx_open (VSI_CALLER DL_QUEUE, _hCommPL);
211 _osx_open (VSI_CALLER RR_QUEUE, _hCommPL);
212
213 _osx_open (VSI_CALLER GPF_ACI_QUEUE, _hCommMMI);
214 #else
215 #ifdef NEW_FRAME
216 if ( first_access == TRUE )
217 {
218 first_access = FALSE;
219 _osx_init();
220 }
221 /*
222 * Associate own "queue" handle (a task handle in the end) with L1_QUEUE,
223 * in order to be able to receive primitives.
224 */
225 if (hCommL1 < VSI_OK)
226 {
227 if ((hCommL1 = vsi_c_open (VSI_CALLER L1_NAME)) < VSI_OK)
228 return PEI_ERROR;
229 _osx_open (VSI_CALLER L1_QUEUE, hCommL1);
230 }
231 #endif
232
233 if (hCommPL < VSI_OK)
234 {
235 if ((hCommPL = vsi_c_open (VSI_CALLER PL_NAME)) < VSI_OK)
236 return PEI_ERROR;
237 _osx_open (VSI_CALLER DL_QUEUE, hCommPL);
238 _osx_open (VSI_CALLER RR_QUEUE, hCommPL);
239 }
240
241 if (hCommACI < VSI_OK)
242 {
243 if ((hCommACI = vsi_c_open (VSI_CALLER ACI_NAME)) < VSI_OK)
244 return PEI_ERROR;
245 _osx_open (VSI_CALLER GPF_ACI_QUEUE, hCommACI);
246 }
247 #endif /* TI_PS_HCOMM_CHANGE */
248
249 #ifdef GPRS
250 if (hCommGRR < VSI_OK)
251 {
252 if ((hCommGRR = vsi_c_open (VSI_CALLER GRR_NAME)) < VSI_OK)
253 return PEI_ERROR;
254 _osx_open (VSI_CALLER GRR_QUEUE, hCommGRR);
255 }
256
257 if (hCommLLC < VSI_OK)
258 {
259 if ((hCommLLC = vsi_c_open (VSI_CALLER LLC_NAME)) < VSI_OK)
260 return PEI_ERROR;
261 _osx_open (VSI_CALLER LLC_QUEUE, hCommLLC);
262 }
263
264 if (hCommSNDCP < VSI_OK)
265 {
266 if ((hCommSNDCP = vsi_c_open (VSI_CALLER SNDCP_NAME)) < VSI_OK)
267 return PEI_ERROR;
268 _osx_open (VSI_CALLER SNDCP_QUEUE, hCommSNDCP);
269 }
270 #endif
271
272 /*
273 * Register VSI_CALLER as generic caller entity.
274 */
275 _osx_open (VSI_CALLER 0, 0);
276
277 l1_create_HISR ();
278
279 return PEI_OK;
280 }
281
282 /*
283 +------------------------------------------------------------------------------
284 | Function : pei_timeout
285 +------------------------------------------------------------------------------
286 | Description : Process timeout.
287 |
288 | Parameters : index - timer index
289 |
290 | Return : PEI_OK - timeout processed
291 | PEI_ERROR - timeout not processed
292 +------------------------------------------------------------------------------
293 */
294 #if !defined (NEW_FRAME)
295
296 T_PEI_RETURN l1_pei_timeout (T_VSI_THANDLE handle)
297 {
298 TRACE_FUNCTION ("pei_timeout()")
299
300 return PEI_OK;
301 }
302
303 #endif
304
305 /*
306 +------------------------------------------------------------------------------
307 | Function : pei_exit
308 +------------------------------------------------------------------------------
309 | Description : Close Resources and terminate.
310 |
311 | Parameters : -
312 |
313 | Return : PEI_OK - exit sucessful
314 +------------------------------------------------------------------------------
315 */
316 #if defined (NEW_FRAME)
317 LOCAL SHORT pei_exit (void)
318 #else
319 T_PEI_RETURN l1_pei_exit (void)
320 #endif
321 {
322
323
324
325 #ifdef TI_PS_HCOMM_CHANGE
326 #else
327 vsi_c_close (VSI_CALLER hCommPL);
328 hCommPL = VSI_ERROR;
329 #endif
330 return PEI_OK;
331 }
332
333 /*
334 +------------------------------------------------------------------------------
335 | Function : pei_run
336 +------------------------------------------------------------------------------
337 | Description : Process Primitives, main loop is located in the
338 | Protocol Stack Entity.
339 | Only needed in active body variant
340 |
341 | Parameters : taskhandle - handle of current process
342 | comhandle - queue handle of current process
343 |
344 | Return : PEI_OK - sucessful
345 | PEI_ERROR - not successful
346 +------------------------------------------------------------------------------
347 */
348 #if defined (NEW_FRAME)
349 LOCAL SHORT pei_run ( T_HANDLE taskhandle, T_HANDLE comhandle )
350 #else
351 T_PEI_RETURN l1_pei_run (T_VSI_CHANDLE comhandle)
352 #endif
353 {
354
355 #ifdef TI_PS_HCOMM_CHANGE
356 #else
357 hCommL1 = comhandle;
358 #endif
359
360
361 l1a_task (0, NULL);
362 return PEI_OK;
363 }
364
365 /*
366 +------------------------------------------------------------------------------
367 | Function : pei_config
368 +------------------------------------------------------------------------------
369 | Description : Dynamic Configuration.
370 |
371 | Parameters : in_string - configuration string
372 |
373 | Return : PEI_OK - sucessful
374 | PEI_ERROR - not successful
375 +------------------------------------------------------------------------------
376 */
377 LOCAL SHORT pei_config (T_PEI_CONFIG inString)
378 {
379
380
381 if ( _osx_config ( inString ) == OSX_OK )
382 return PEI_OK;
383 else
384 return PEI_ERROR;
385 }
386
387 /*
388 +------------------------------------------------------------------------------
389 | Function : pei_monitor
390 +------------------------------------------------------------------------------
391 | Description : Monitoring of physical Parameters.
392 |
393 | Parameters : out_monitor - return the address of the data to be monitored
394 |
395 | Return : PEI_OK - sucessful (address in out_monitor is valid)
396 | PEI_ERROR - not successful
397 +------------------------------------------------------------------------------
398 */
399 #if defined (NEW_FRAME)
400 LOCAL SHORT pei_monitor (void ** monitor)
401 #else
402 T_PEI_RETURN l1_pei_monitor (void ** monitor)
403 #endif
404 {
405
406
407 l1_mon.version = "ALR 2.0.0";
408 *monitor = &l1_mon;
409
410 return PEI_OK;
411 }
412
413
414 /*==== PUBLIC FUNCTIONS =====================================================*/
415
416 /*
417 +------------------------------------------------------------------------------
418 | Function : pei_create
419 +------------------------------------------------------------------------------
420 | Description : Create the Protocol Stack Entity.
421 |
422 | Parameters : info - Pointer to the structure of entity parameters
423 |
424 | Return : PEI_OK - entity created successfully
425 |
426 +------------------------------------------------------------------------------
427 */
428 #if defined (NEW_FRAME)
429
430 GLOBAL SHORT l1_pei_create ( T_PEI_INFO **info )
431 {
432 static T_PEI_INFO pei_info =
433 {
434 "L1",
435 {
436 pei_init,
437 #ifdef _SIMULATION_
438 pei_exit,
439 #else
440 NULL,
441 #endif
442 NULL, /* no primitive function */
443 NULL, /* no timeout function */
444 NULL, /* no signal function */
445 pei_run,
446 pei_config,
447 pei_monitor,
448 },
449 #if defined (GPRS)
450 2800, /* Stack Size */
451 #else
452 #if defined (FAX_AND_DATA)
453 2800, /* Stack Size */
454 #else
455 1805, /* Stacksize */
456 #endif
457 #endif
458 10, /* Queue Entries */
459 235, /* Priority */
460 0, /* number of timer */
461 #ifdef GPRS
462 COPY_BY_REF|TRC_NO_SUSPEND|PRIM_NO_SUSPEND /* flags */
463 #else
464 COPY_BY_REF|TRC_NO_SUSPEND|PRIM_NO_SUSPEND /* flags */
465 #endif
466 };
467
468 /*
469 * export startup configuration data
470 */
471 *info = &pei_info;
472 /*
473 * Initialize entity data
474 */
475
476 return PEI_OK;
477 }
478
479 #else /* NEW_FRAME */
480
481 T_PEI_RETURN pei_create (T_VSI_CNAME * name)
482 {
483 TRACE_FUNCTION ("pei_create()")
484
485 *name = L1_NAME;
486
487 return PEI_OK;
488 }
489
490 #endif /* NEW_FRAME */
491
492 /*==== END OF FILE ==========================================================*/