comparison gsm-fw/L1/stand/l1_pei.c @ 613:9e605ec89ed0

gsm-fw/L1/stand: starting work on our version of standalone L1
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 29 Aug 2014 17:25:46 +0000
parents
children 4274171eabd2
comparison
equal deleted inserted replaced
612:700d450bb8da 613:9e605ec89ed0
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 #if defined (NEW_FRAME)
187 L1_Handle = Handle;
188 #endif
189
190
191
192 #ifdef TI_PS_HCOMM_CHANGE
193 #ifdef NEW_FRAME
194 if ( first_access == TRUE )
195 {
196 first_access = FALSE;
197 _osx_init();
198 }
199 #endif
200
201 if (!cl_hcom_all_handles_open()) return PEI_ERROR;
202
203 #ifdef NEW_FRAME
204 _osx_open (VSI_CALLER L1_QUEUE, _hCommL1);
205 #endif
206 _osx_open (VSI_CALLER DL_QUEUE, _hCommPL);
207 _osx_open (VSI_CALLER RR_QUEUE, _hCommPL);
208
209 _osx_open (VSI_CALLER GPF_ACI_QUEUE, _hCommMMI);
210 #else
211 #ifdef NEW_FRAME
212 if ( first_access == TRUE )
213 {
214 first_access = FALSE;
215 _osx_init();
216 }
217 /*
218 * Associate own "queue" handle (a task handle in the end) with L1_QUEUE,
219 * in order to be able to receive primitives.
220 */
221 if (hCommL1 < VSI_OK)
222 {
223 if ((hCommL1 = vsi_c_open (VSI_CALLER L1_NAME)) < VSI_OK)
224 return PEI_ERROR;
225 _osx_open (VSI_CALLER L1_QUEUE, hCommL1);
226 }
227 #endif
228
229 if (hCommPL < VSI_OK)
230 {
231 if ((hCommPL = vsi_c_open (VSI_CALLER PL_NAME)) < VSI_OK)
232 return PEI_ERROR;
233 _osx_open (VSI_CALLER DL_QUEUE, hCommPL);
234 _osx_open (VSI_CALLER RR_QUEUE, hCommPL);
235 }
236
237 if (hCommACI < VSI_OK)
238 {
239 if ((hCommACI = vsi_c_open (VSI_CALLER ACI_NAME)) < VSI_OK)
240 return PEI_ERROR;
241 _osx_open (VSI_CALLER GPF_ACI_QUEUE, hCommACI);
242 }
243 #endif /* TI_PS_HCOMM_CHANGE */
244
245 #ifdef GPRS
246 if (hCommGRR < VSI_OK)
247 {
248 if ((hCommGRR = vsi_c_open (VSI_CALLER GRR_NAME)) < VSI_OK)
249 return PEI_ERROR;
250 _osx_open (VSI_CALLER GRR_QUEUE, hCommGRR);
251 }
252
253 if (hCommLLC < VSI_OK)
254 {
255 if ((hCommLLC = vsi_c_open (VSI_CALLER LLC_NAME)) < VSI_OK)
256 return PEI_ERROR;
257 _osx_open (VSI_CALLER LLC_QUEUE, hCommLLC);
258 }
259
260 if (hCommSNDCP < VSI_OK)
261 {
262 if ((hCommSNDCP = vsi_c_open (VSI_CALLER SNDCP_NAME)) < VSI_OK)
263 return PEI_ERROR;
264 _osx_open (VSI_CALLER SNDCP_QUEUE, hCommSNDCP);
265 }
266 #endif
267
268 /*
269 * Register VSI_CALLER as generic caller entity.
270 */
271 _osx_open (VSI_CALLER 0, 0);
272
273 l1_create_ISR ();
274
275 return PEI_OK;
276 }
277
278 /*
279 +------------------------------------------------------------------------------
280 | Function : pei_timeout
281 +------------------------------------------------------------------------------
282 | Description : Process timeout.
283 |
284 | Parameters : index - timer index
285 |
286 | Return : PEI_OK - timeout processed
287 | PEI_ERROR - timeout not processed
288 +------------------------------------------------------------------------------
289 */
290 #if !defined (NEW_FRAME)
291
292 T_PEI_RETURN l1_pei_timeout (T_VSI_THANDLE handle)
293 {
294 TRACE_FUNCTION ("pei_timeout()")
295
296 return PEI_OK;
297 }
298
299 #endif
300
301 /*
302 +------------------------------------------------------------------------------
303 | Function : pei_exit
304 +------------------------------------------------------------------------------
305 | Description : Close Resources and terminate.
306 |
307 | Parameters : -
308 |
309 | Return : PEI_OK - exit sucessful
310 +------------------------------------------------------------------------------
311 */
312 #if defined (NEW_FRAME)
313 LOCAL SHORT pei_exit (void)
314 #else
315 T_PEI_RETURN l1_pei_exit (void)
316 #endif
317 {
318
319
320
321 #ifdef TI_PS_HCOMM_CHANGE
322 #else
323 vsi_c_close (VSI_CALLER hCommPL);
324 hCommPL = VSI_ERROR;
325 #endif
326 return PEI_OK;
327 }
328
329 /*
330 +------------------------------------------------------------------------------
331 | Function : pei_run
332 +------------------------------------------------------------------------------
333 | Description : Process Primitives, main loop is located in the
334 | Protocol Stack Entity.
335 | Only needed in active body variant
336 |
337 | Parameters : taskhandle - handle of current process
338 | comhandle - queue handle of current process
339 |
340 | Return : PEI_OK - sucessful
341 | PEI_ERROR - not successful
342 +------------------------------------------------------------------------------
343 */
344 #if defined (NEW_FRAME)
345 LOCAL SHORT pei_run ( T_HANDLE taskhandle, T_HANDLE comhandle )
346 #else
347 T_PEI_RETURN l1_pei_run (T_VSI_CHANDLE comhandle)
348 #endif
349 {
350
351 #ifdef TI_PS_HCOMM_CHANGE
352 #else
353 hCommL1 = comhandle;
354 #endif
355
356
357 l1a_task (0, NULL);
358 return PEI_OK;
359 }
360
361 /*
362 +------------------------------------------------------------------------------
363 | Function : pei_config
364 +------------------------------------------------------------------------------
365 | Description : Dynamic Configuration.
366 |
367 | Parameters : in_string - configuration string
368 |
369 | Return : PEI_OK - sucessful
370 | PEI_ERROR - not successful
371 +------------------------------------------------------------------------------
372 */
373 LOCAL SHORT pei_config (T_PEI_CONFIG inString)
374 {
375
376
377 if ( _osx_config ( inString ) == OSX_OK )
378 return PEI_OK;
379 else
380 return PEI_ERROR;
381 }
382
383 /*
384 +------------------------------------------------------------------------------
385 | Function : pei_monitor
386 +------------------------------------------------------------------------------
387 | Description : Monitoring of physical Parameters.
388 |
389 | Parameters : out_monitor - return the address of the data to be monitored
390 |
391 | Return : PEI_OK - sucessful (address in out_monitor is valid)
392 | PEI_ERROR - not successful
393 +------------------------------------------------------------------------------
394 */
395 #if defined (NEW_FRAME)
396 LOCAL SHORT pei_monitor (void ** monitor)
397 #else
398 T_PEI_RETURN l1_pei_monitor (void ** monitor)
399 #endif
400 {
401
402
403 l1_mon.version = "ALR 2.0.0";
404 *monitor = &l1_mon;
405
406 return PEI_OK;
407 }
408
409
410 /*==== PUBLIC FUNCTIONS =====================================================*/
411
412 /*
413 +------------------------------------------------------------------------------
414 | Function : pei_create
415 +------------------------------------------------------------------------------
416 | Description : Create the Protocol Stack Entity.
417 |
418 | Parameters : info - Pointer to the structure of entity parameters
419 |
420 | Return : PEI_OK - entity created successfully
421 |
422 +------------------------------------------------------------------------------
423 */
424 #if defined (NEW_FRAME)
425
426 GLOBAL SHORT l1_pei_create ( T_PEI_INFO **info )
427 {
428 static T_PEI_INFO pei_info =
429 {
430 "L1",
431 {
432 pei_init,
433 #ifdef _SIMULATION_
434 pei_exit,
435 #else
436 NULL,
437 #endif
438 NULL, /* no primitive function */
439 NULL, /* no timeout function */
440 NULL, /* no signal function */
441 pei_run,
442 pei_config,
443 pei_monitor,
444 },
445 #if defined (GPRS)
446 2800, /* Stack Size */
447 #else
448 #if defined (FAX_AND_DATA)
449 2800, /* Stack Size */
450 #else
451 1805, /* Stacksize */
452 #endif
453 #endif
454 10, /* Queue Entries */
455 235, /* Priority */
456 0, /* number of timer */
457 #ifdef GPRS
458 COPY_BY_REF|TRC_NO_SUSPEND|PRIM_NO_SUSPEND /* flags */
459 #else
460 COPY_BY_REF|TRC_NO_SUSPEND|PRIM_NO_SUSPEND /* flags */
461 #endif
462 };
463
464 /*
465 * export startup configuration data
466 */
467 *info = &pei_info;
468 /*
469 * Initialize entity data
470 */
471
472 return PEI_OK;
473 }
474
475 #else /* NEW_FRAME */
476
477 T_PEI_RETURN pei_create (T_VSI_CNAME * name)
478 {
479 TRACE_FUNCTION ("pei_create()")
480
481 *name = L1_NAME;
482
483 return PEI_OK;
484 }
485
486 #endif /* NEW_FRAME */
487
488 /*==== END OF FILE ==========================================================*/