comparison src/g23m-gsm/l1/l1_pei.c @ 1:d393cd9bb723

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