FreeCalypso > hg > freecalypso-citrine
comparison gpf/frame/frame.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 | File: frame.c | |
4 +------------------------------------------------------------------------------ | |
5 | Copyright 2002 Texas Instruments Berlin, AG | |
6 | All rights reserved. | |
7 | | |
8 | This file is confidential and a trade secret of Texas | |
9 | Instruments Berlin, AG | |
10 | The receipt of or possession of this file does not convey | |
11 | any rights to reproduce or disclose its contents or to | |
12 | manufacture, use, or sell anything it may describe, in | |
13 | whole, or in part, without the specific written consent of | |
14 | Texas Instruments Berlin, AG. | |
15 +----------------------------------------------------------------------------- | |
16 | Purpose : This Modul defines the general frame functionality. | |
17 +----------------------------------------------------------------------------- | |
18 */ | |
19 | |
20 | |
21 #ifndef __FRAME_C__ | |
22 #define __FRAME_C__ | |
23 #endif | |
24 | |
25 /*==== INCLUDES ===================================================*/ | |
26 | |
27 #include <stdarg.h> | |
28 #include <string.h> | |
29 #include <stdio.h> | |
30 | |
31 #include "gpfconf.h" | |
32 #include "typedefs.h" | |
33 | |
34 #include "glob_defs.h" | |
35 #include "os.h" | |
36 #include "vsi.h" | |
37 #include "pei.h" | |
38 #include "frame.h" | |
39 #include "tools.h" | |
40 #include "gdi.h" | |
41 #include "frm_defs.h" | |
42 #include "frm_types.h" | |
43 #include "frm_glob.h" | |
44 #include "route.h" | |
45 #include "p_frame.h" | |
46 #include "prf_func.h" | |
47 #ifdef _ESF_SUPPORT_ | |
48 #include "esf_func.h" | |
49 #endif | |
50 #include "frm_ext.h" | |
51 | |
52 /*==== TYPES ======================================================*/ | |
53 | |
54 typedef struct | |
55 { | |
56 char const *Name; | |
57 USHORT Id; | |
58 } T_NAME_ID; | |
59 | |
60 /*==== CONSTANTS ==================================================*/ | |
61 | |
62 #define RUNNING 0x01 | |
63 #undef VSI_CALLER | |
64 #define VSI_CALLER TaskHandle, | |
65 | |
66 /*==== EXTERNALS ==================================================*/ | |
67 /* -------------- S H A R E D - BEGIN ---------------- */ | |
68 #ifdef _TOOLS_ | |
69 #pragma data_seg("FRAME_SHARED") | |
70 #endif | |
71 | |
72 #if defined _NUCLEUS_ && !defined _TARGET_ | |
73 extern char TraceBuffer[]; | |
74 #endif | |
75 | |
76 #ifndef _TOOLS_ | |
77 extern const T_MEMORY_POOL_CONFIG memory_pool_config[]; | |
78 extern const T_FRM_PARTITION_GROUP_CONFIG partition_grp_config[]; | |
79 extern T_HANDLE MemoryPoolHandle[]; | |
80 extern OS_HANDLE PoolGroupHandle[]; | |
81 extern const T_DRV_LIST DrvList[]; | |
82 #ifdef MEMORY_SUPERVISION | |
83 extern USHORT NumberOfPPMPartitions; | |
84 extern USHORT NumOfPPMPools; | |
85 extern USHORT NumOfPPMGroups; | |
86 extern USHORT NumOfPrimPools; | |
87 extern USHORT NumOfDmemPools; | |
88 #endif | |
89 #endif | |
90 | |
91 extern T_DRV_LIST const *DriverConfigList; | |
92 | |
93 #ifndef _TOOLS_ | |
94 extern const T_COMPONENT_ADDRESS *ComponentTables[]; | |
95 extern const char * const frame_version_date; | |
96 extern const char * const frame_version_time; | |
97 extern const char * const misc_version_date; | |
98 extern const char * const misc_version_time; | |
99 extern const char * const tif_version_date; | |
100 extern const char * const tif_version_time; | |
101 #endif | |
102 | |
103 #ifdef _TOOLS_ | |
104 __declspec (dllimport) T_HANDLE TST_Handle; | |
105 #else | |
106 extern T_HANDLE TST_Handle; | |
107 #endif | |
108 | |
109 #ifdef MEMORY_SUPERVISION | |
110 extern int ppm_check_partition_owner; | |
111 #endif | |
112 | |
113 /*==== VARIABLES ==================================================*/ | |
114 | |
115 #ifndef RUN_INT_RAM | |
116 UBYTE SuppressOK=1; | |
117 GLOBAL T_HANDLE MemPoolHandle; | |
118 GLOBAL T_HANDLE PrimGroupHandle; | |
119 GLOBAL T_HANDLE DmemGroupHandle; | |
120 GLOBAL T_HANDLE TestGroupHandle; | |
121 GLOBAL T_HANDLE LemuGroupHandle; | |
122 GLOBAL T_HANDLE int_data_pool_handle; | |
123 GLOBAL T_HANDLE ext_data_pool_handle; | |
124 GLOBAL UBYTE FrameEnv=0; | |
125 GLOBAL USHORT TestInterface = 0; | |
126 GLOBAL USHORT NextTimerEntry = 0; | |
127 int time_is_tdma_frame; | |
128 char error_ind_dst[RESOURCE_NAMELEN] = {0}; | |
129 T_FRM_ERROR_IND *frm_error_ind = NULL; | |
130 char check_desclist = FALSE; | |
131 GLOBAL USHORT NumberOfStartedTasks = 0; | |
132 GLOBAL USHORT NumberOfRunningTasks = 0; | |
133 GLOBAL USHORT TooManyTasks = 0; | |
134 | |
135 const T_PEI_INFO DummyInfo = | |
136 { | |
137 "", /* Name */ | |
138 { | |
139 NULL, | |
140 NULL, | |
141 NULL, | |
142 NULL, | |
143 NULL, | |
144 NULL, | |
145 NULL, | |
146 NULL | |
147 }, | |
148 768, /* stack size */ | |
149 10, /* queue entries */ | |
150 1, /* priority */ | |
151 0, /* number of timers */ | |
152 COPY_BY_REF /* Flags */ | |
153 }; | |
154 | |
155 const T_NAME_ID Resource[] = | |
156 { | |
157 { "TASK", OS_OBJTASK}, | |
158 { "QUEUE", OS_OBJQUEUE}, | |
159 { "TIMER", OS_OBJTIMER }, | |
160 { "SEMAPHORE", OS_OBJSEMAPHORE}, | |
161 { "PARTITION", OS_OBJPARTITIONGROUP}, | |
162 { "MEMORY", OS_OBJMEMORYPOOL}, | |
163 { NULL, 0 } | |
164 }; | |
165 | |
166 #ifdef _TOOLS_ | |
167 LOCAL T_COMPONENT_ADDRESS *ComponentTables [NUM_OF_COMPONENT_TABLES+1]={0}; | |
168 typedef void T_INIT_FUNC ( void ); | |
169 T_INIT_FUNC *InitFunc; | |
170 ULONG init_stack_time = 0; | |
171 ULONG init_local_time = 0; | |
172 ULONG MaxPrimPartSize = 65536; | |
173 USHORT TextTracePartitionSize = 260; | |
174 #endif | |
175 | |
176 char TaskName [ RESOURCE_NAMELEN ]; | |
177 | |
178 #else /* RUN_INT_RAM */ | |
179 extern USHORT TestInterface; | |
180 extern USHORT NextTimerEntry; | |
181 extern USHORT NumberOfStartedTasks; | |
182 extern USHORT NumberOfRunningTasks; | |
183 extern USHORT TooManyTasks; | |
184 extern char TaskName[]; | |
185 extern T_HANDLE int_data_pool_handle; | |
186 extern T_HANDLE ext_data_pool_handle; | |
187 #endif /* RUN_INT_RAM */ | |
188 | |
189 #ifdef _TOOLS_ | |
190 #pragma data_seg() | |
191 #endif | |
192 | |
193 #ifdef _ESF_SUPPORT_ | |
194 int esf_init_func2_ready = FALSE; | |
195 int firstTime = TRUE; | |
196 #endif | |
197 | |
198 /* -------------- S H A R E D - END ---------------- */ | |
199 | |
200 | |
201 /*==== PROTOTYPES =================================================*/ | |
202 | |
203 GLOBAL void pf_TaskEntry (T_HANDLE TaskHandle, ULONG Value ); | |
204 LOCAL SHORT pf_HandleMessage (T_HANDLE TaskHandle, OS_QDATA *pMsg ); | |
205 LOCAL LONG pf_CreateTask ( const T_COMPONENT_ADDRESS *Comp ); | |
206 LOCAL void pf_ProcessProtocolPrim ( T_HANDLE TaskHandle, T_VOID_STRUCT *pPrim); | |
207 LOCAL void pf_Reset (T_HANDLE TaskHandle); | |
208 int is_entity_in_task (T_HANDLE t_handle, char *name ); | |
209 int int_vsi_o_ttrace ( T_HANDLE Caller, ULONG TraceClass, const char * const format, va_list varpars ); | |
210 | |
211 #ifndef _TOOLS_ | |
212 GLOBAL void InitializeApplication ( void ); | |
213 #endif | |
214 | |
215 /*==== LINT =======================================================*/ | |
216 | |
217 /*lint -e522 suppress Warning -- Expected void type, assignment, increment or decrement */ | |
218 | |
219 /*==== FUNCTIONS ==================================================*/ | |
220 | |
221 #ifdef _TOOLS_ | |
222 /* | |
223 +------------------------------------------------------------------------------ | |
224 | Function : pf_get_frameenv | |
225 +------------------------------------------------------------------------------ | |
226 | Description : This function returns the current value of FrameEnv | |
227 | | |
228 | Parameters : void | |
229 | | |
230 | Return : FrameEnv | |
231 +------------------------------------------------------------------------------ | |
232 */ | |
233 USHORT pf_get_frameenv (void) | |
234 { | |
235 return (USHORT) FrameEnv; | |
236 } | |
237 | |
238 #endif /* _TOOLS_ */ | |
239 | |
240 #ifndef _TOOLS_ | |
241 #ifndef RUN_INT_RAM | |
242 /* | |
243 +--------------------------------------------------------------------+ | |
244 | PROJECT : GSM-GPF (8415) MODULE : FRAME | | |
245 | STATE : code ROUTINE : StartFrame | | |
246 +--------------------------------------------------------------------+ | |
247 | |
248 PURPOSE : Start the frame | |
249 | |
250 */ | |
251 SHORT StartFrame ( void ) | |
252 { | |
253 prf_init(); | |
254 pf_Init(NULL); | |
255 pf_CreateAllEntities(); | |
256 #ifdef _ESF_SUPPORT_ | |
257 esf_init(); | |
258 esf_init_func1(); | |
259 #endif | |
260 pf_StartAllTasks (); | |
261 return ( PF_OK ); | |
262 } | |
263 #endif | |
264 #endif /* ndef _TOOLS_ */ | |
265 | |
266 #if defined (_LINUX_) || (defined _SOLARIS_) | |
267 int main () | |
268 { | |
269 (void) StartFrame (); | |
270 for (;;) | |
271 { | |
272 os_SuspendTask (0, 1500); | |
273 } | |
274 } | |
275 #endif | |
276 | |
277 #ifndef RUN_INT_RAM | |
278 /* | |
279 +--------------------------------------------------------------------+ | |
280 | PROJECT : GSM-GPF (8415) MODULE : FRAME | | |
281 | STATE : code ROUTINE : is_entity_in_task | | |
282 +--------------------------------------------------------------------+ | |
283 | |
284 PURPOSE : Initialize the frame | |
285 | |
286 */ | |
287 int is_entity_in_task ( T_HANDLE t_handle, char *name ) | |
288 { | |
289 int i; | |
290 | |
291 for ( i = MaxEntities; i > 0; i-- ) | |
292 { | |
293 if ( pf_TaskTable[i].TaskHandle == t_handle ) | |
294 { | |
295 if ( !strncmp (pf_TaskTable[i].Name, name, RESOURCE_NAMELEN-1) ) | |
296 return TRUE; | |
297 } | |
298 } | |
299 return FALSE; | |
300 } | |
301 #endif | |
302 | |
303 #ifndef RUN_INT_RAM | |
304 /* | |
305 +--------------------------------------------------------------------+ | |
306 | PROJECT : GSM-GPF (8415) MODULE : FRAME | | |
307 | STATE : code ROUTINE : pf_Init | | |
308 +--------------------------------------------------------------------+ | |
309 | |
310 PURPOSE : Initialize the frame | |
311 | |
312 */ | |
313 | |
314 /*lint -esym(715,ConfigAddress) only needed for _TOOLS_*/ | |
315 GLOBAL void pf_Init ( T_CONFIGURATION_ADDRESS *ConfigAddress) | |
316 { | |
317 #ifndef _TOOLS_ | |
318 const T_FRM_PARTITION_POOL_CONFIG * pool_config; | |
319 USHORT i = 1,j = 0; | |
320 #endif | |
321 | |
322 #if defined _NUCLEUS_ && !defined _TARGET_ || defined (_LINUX_) | |
323 printf ("FRAME VERSION: %s, %s\n",frame_version_date, frame_version_time); | |
324 printf ("MISC VERSION: %s, %s\n",misc_version_date, misc_version_time); | |
325 printf ("TIF VERSION: %s, %s\n\n",tif_version_date, tif_version_time); | |
326 #endif | |
327 if ( os_Initialize() == OS_ERROR ) | |
328 { | |
329 vsi_o_assert ( 0, OS_SYST_ERR, __FILE__, __LINE__, "OS initialization error" ); | |
330 } | |
331 | |
332 time_is_tdma_frame = 0; | |
333 TestInterface = 0; | |
334 NextTimerEntry = 0; | |
335 #ifdef _TOOLS_ | |
336 ComponentTables[RCV_ADR] = ConfigAddress->RcvAdr; | |
337 ComponentTables[TST_ADR] = ConfigAddress->TstAdr; | |
338 ComponentTables[END_OF_COMP_TABLE] = NULL; | |
339 DriverConfigList = ConfigAddress->DrvListAdr; | |
340 InitFunc = ConfigAddress->InitFuncAdr; | |
341 FrameEnv = *ConfigAddress->FrameEnvAdr; | |
342 #else | |
343 DriverConfigList = &DrvList[0]; | |
344 #endif | |
345 | |
346 #ifndef _TOOLS_ | |
347 | |
348 | |
349 j = 0; | |
350 /* | |
351 * create memory pools | |
352 */ | |
353 while ( memory_pool_config[j].Name != NULL ) | |
354 { | |
355 if ( memory_pool_config[j].Size > 1 ) | |
356 os_CreateMemoryPool ( NO_TASK, | |
357 memory_pool_config[j].Name, | |
358 memory_pool_config[j].PoolAddress, | |
359 memory_pool_config[j].Size, | |
360 (OS_HANDLE*)MemoryPoolHandle[j] ); | |
361 j++; | |
362 } | |
363 | |
364 #ifdef _NUCLEUS_ | |
365 os_SetPoolHandles (ext_data_pool_handle, int_data_pool_handle); | |
366 #endif | |
367 | |
368 /* | |
369 * create partition pools | |
370 */ | |
371 | |
372 for ( i = 0; partition_grp_config[i].name != NULL; i++ ) | |
373 { | |
374 #ifdef MEMORY_SUPERVISION | |
375 // if ( strcmp ("TEST", partition_grp_config[i].name ) ) | |
376 // { | |
377 /* currently all created groups are counted to ease offset calculation for | |
378 partition supervision */ | |
379 NumOfPPMGroups++; | |
380 // } | |
381 #endif | |
382 pool_config = partition_grp_config[i].grp_config; | |
383 while ( pool_config->part_size && pool_config->part_num ) | |
384 { | |
385 os_CreatePartitionPool ( NO_TASK, | |
386 partition_grp_config[i].name, | |
387 pool_config->mem, | |
388 (USHORT)pool_config->part_num, | |
389 pool_config->part_size, | |
390 (OS_HANDLE*)PoolGroupHandle[i] ); | |
391 #ifdef MEMORY_SUPERVISION | |
392 /* TEST pool not under partition supervision */ | |
393 if ( strcmp ("TEST", partition_grp_config[i].name ) ) | |
394 { | |
395 NumOfPPMPools++; | |
396 NumberOfPPMPartitions += pool_config->part_num; | |
397 } | |
398 #endif | |
399 if ( !strcmp ("PRIM", partition_grp_config[i].name ) ) | |
400 { | |
401 if ( MaxPrimPartSize < pool_config->part_size ) | |
402 { | |
403 MaxPrimPartSize = pool_config->part_size; | |
404 } | |
405 #ifdef MEMORY_SUPERVISION | |
406 NumOfPrimPools++; | |
407 #endif | |
408 } | |
409 #ifdef MEMORY_SUPERVISION | |
410 if ( !strcmp ("DMEM", partition_grp_config[i].name ) ) | |
411 { | |
412 NumOfDmemPools++; | |
413 } | |
414 #endif | |
415 pool_config++; | |
416 } | |
417 } | |
418 | |
419 #endif | |
420 /* | |
421 * To allow CCD (TaskHandle = 0) the usage of dynamic Memory to create a semaphore | |
422 * the MemPoolHandle for non-task users is initialized with the handle of the int_data_pool | |
423 * pool. | |
424 */ | |
425 pf_TaskTable[0].MemPoolHandle = int_data_pool_handle; | |
426 strcpy ( pf_TaskTable[0].Name, "IRQ" ); | |
427 | |
428 rt_Init(); | |
429 #ifdef _TOOLS_ | |
430 (InitFunc)(); | |
431 #else | |
432 InitializeApplication(); | |
433 #endif | |
434 #ifdef MEMORY_SUPERVISION | |
435 InitializePPM(); | |
436 #endif /* MEMORY_SUPERVISION */ | |
437 | |
438 InitializeTimer(); | |
439 InitializeDriverConfig(); | |
440 #if !defined _TARGET_ && !defined _TOOLS_ | |
441 vsi_pcheck_init(); | |
442 #endif | |
443 #ifndef _TOOLS_ | |
444 fei_lemu_SendToQueue_init(); | |
445 #endif | |
446 /* | |
447 not needed -> temporarily removed | |
448 vsi_c_init_com_matrix (MaxEntities); | |
449 */ | |
450 } | |
451 #endif | |
452 | |
453 #ifndef RUN_INT_RAM | |
454 /* | |
455 +--------------------------------------------------------------------+ | |
456 | PROJECT : GSM-GPF (8415) MODULE : FRAME | | |
457 | STATE : code ROUTINE : pf_CreateAllEntities| | |
458 +--------------------------------------------------------------------+ | |
459 */ | |
460 GLOBAL SHORT pf_CreateAllEntities (void) | |
461 { | |
462 int i = 0; | |
463 | |
464 while ( ComponentTables[i] != NULL ) | |
465 { | |
466 pf_CreateTask ( ComponentTables[i] ); | |
467 i++; | |
468 } | |
469 InitializeTrace(); | |
470 return PF_OK; | |
471 } | |
472 #endif | |
473 #ifndef RUN_INT_RAM | |
474 /* | |
475 +--------------------------------------------------------------------+ | |
476 | PROJECT : GSM-GPF (8415) MODULE : FRAME | | |
477 | STATE : code ROUTINE : pf_CreateEntity | | |
478 +--------------------------------------------------------------------+ | |
479 */ | |
480 LOCAL LONG pf_CreateTask ( const T_COMPONENT_ADDRESS *Comp ) | |
481 { | |
482 T_PEI_INFO const *Info; | |
483 T_HANDLE TaskHandle; | |
484 T_HANDLE mem_pool_handle = ext_data_pool_handle; | |
485 int Priority = 0; | |
486 ULONG StackSize = 0; | |
487 const T_PEI_FUNC *PeiTable; | |
488 USHORT QueueEntries = 0; | |
489 USHORT NumOfTimers = 0; | |
490 U32 Flags; | |
491 char *Name = NULL; | |
492 static int e_handle = 1; | |
493 int start_e_handle; | |
494 int i; | |
495 | |
496 start_e_handle = e_handle; | |
497 while ( Comp->PeiCreate || Comp->Name ) | |
498 { | |
499 if ( e_handle > MaxEntities ) | |
500 { | |
501 vsi_o_assert ( 0, OS_SYST_ERR, __FILE__, __LINE__, "More than MAX_ENTITIES" ); | |
502 } | |
503 if ( Comp->PeiCreate && Comp->PeiCreate ( &Info ) == PEI_OK ) | |
504 { | |
505 if ( Comp->Priority != ASSIGNED_BY_TI ) | |
506 { | |
507 if ( Priority < Comp->Priority ) | |
508 Priority = Comp->Priority; | |
509 } | |
510 else | |
511 { | |
512 if ( Priority < Info->Priority ) | |
513 Priority = Info->Priority; | |
514 } | |
515 Flags = Info->Flags; | |
516 PeiTable = &Info->PeiTable; | |
517 Name = (char*)Info->Name; | |
518 if ( StackSize < Info->StackSize ) | |
519 StackSize = Info->StackSize; | |
520 pf_TaskTable[e_handle].QueueEntries = Info->QueueEntries; | |
521 NumOfTimers = Info->NumOfTimers; | |
522 } | |
523 else if ( Comp->Name && strlen (Comp->Name) <= RESOURCE_NAMELEN ) | |
524 { | |
525 Flags = DummyInfo.Flags; | |
526 PeiTable = &DummyInfo.PeiTable; | |
527 Name = Comp->Name; | |
528 if ( StackSize < DummyInfo.StackSize ) | |
529 StackSize = DummyInfo.StackSize; | |
530 if ( Priority < DummyInfo.Priority ) | |
531 Priority = DummyInfo.Priority; | |
532 pf_TaskTable[e_handle].QueueEntries = DummyInfo.QueueEntries; | |
533 NumOfTimers = DummyInfo.NumOfTimers; | |
534 } | |
535 else | |
536 return PF_ERROR; | |
537 | |
538 if ( QueueEntries < pf_TaskTable[e_handle].QueueEntries ) | |
539 QueueEntries = pf_TaskTable[e_handle].QueueEntries; | |
540 | |
541 pf_TaskTable[e_handle].Flags = Flags; | |
542 pf_TaskTable[e_handle].PeiTable = PeiTable; | |
543 pf_TaskTable[e_handle].NumOfTimers = NumOfTimers; | |
544 strncpy (pf_TaskTable[e_handle].Name, Name, RESOURCE_NAMELEN); | |
545 pf_TaskTable[e_handle].Name[RESOURCE_NAMELEN-1] = 0; | |
546 if ( pf_TaskTable[e_handle].Flags & INT_DATA_TASK ) | |
547 { | |
548 pf_TaskTable[e_handle].MemPoolHandle = int_data_pool_handle; | |
549 mem_pool_handle = int_data_pool_handle; | |
550 } | |
551 else | |
552 { | |
553 pf_TaskTable[e_handle].MemPoolHandle = ext_data_pool_handle; | |
554 mem_pool_handle = ext_data_pool_handle; | |
555 } | |
556 prf_log_entity_create ((void*)e_handle, Name); | |
557 e_handle++; | |
558 Comp++; | |
559 } | |
560 if ( e_handle > start_e_handle + 1 ) | |
561 Name = (char*)Comp->Priority; | |
562 | |
563 #ifdef MEMORY_SUPERVISION | |
564 StackSize = StackSize + (StackSize>>3); | |
565 #endif | |
566 if ( os_CreateTask (NO_TASK, Name, pf_TaskEntry, StackSize, (USHORT)Priority, &TaskHandle, | |
567 mem_pool_handle) == OS_OK ) | |
568 { | |
569 for ( i = start_e_handle; i < e_handle; i++ ) | |
570 { | |
571 pf_TaskTable[i].TaskHandle = TaskHandle; | |
572 } | |
573 return PF_OK; | |
574 } | |
575 else | |
576 vsi_o_assert ( NO_TASK, OS_SYST_ERR, __FILE__, __LINE__, "Error at creating %s Task", Name ); | |
577 /*lint +e771 */ | |
578 | |
579 return PF_ERROR; | |
580 } | |
581 #endif | |
582 | |
583 #ifndef RUN_INT_RAM | |
584 /* | |
585 +--------------------------------------------------------------------+ | |
586 | PROJECT : GSM-GPF (8415) MODULE : FRAME | | |
587 | STATE : code ROUTINE : pf_StartAllTasks | | |
588 +--------------------------------------------------------------------+ | |
589 */ | |
590 GLOBAL SHORT pf_StartAllTasks ( void ) | |
591 { | |
592 int e_handle; | |
593 int t_handle; | |
594 int started_t_handle = 0; | |
595 | |
596 for ( e_handle = 1; e_handle <= MaxEntities; e_handle++ ) | |
597 { | |
598 if ( pf_TaskTable[e_handle].Name[0] != 0 ) | |
599 { | |
600 if ( (t_handle = pf_TaskTable[e_handle].TaskHandle) != started_t_handle ) | |
601 { | |
602 if ( os_StartTask ( NO_TASK, t_handle, 0 ) == OS_ERROR) | |
603 return OS_ERROR; | |
604 NumberOfStartedTasks++; | |
605 started_t_handle = t_handle; | |
606 } | |
607 } | |
608 } | |
609 return OS_OK; | |
610 } | |
611 #endif | |
612 | |
613 | |
614 #ifndef RUN_FLASH | |
615 /* | |
616 +--------------------------------------------------------------------+ | |
617 | PROJECT : GSM-GPF (8415) MODULE : FRAME | | |
618 | STATE : code ROUTINE : pf_TaskEntry | | |
619 +--------------------------------------------------------------------+ | |
620 */ | |
621 /*lint -esym(715,Value) suppress Info -- Symbol 'Value' not referenced */ | |
622 GLOBAL void pf_TaskEntry (T_HANDLE TaskHandle, ULONG Value ) | |
623 { | |
624 OS_QDATA Msg; | |
625 OS_HANDLE mem_pool_handle = ext_data_pool_handle; | |
626 LONG sts; | |
627 int i; | |
628 int queue_entries; | |
629 int queue_handle; | |
630 int biggest_queue_size = 0; | |
631 int sum_queue_size = 0; | |
632 U32 entity_flags = 0; | |
633 #ifndef _TOOLS_ | |
634 char queue_name [ RESOURCE_NAMELEN ]; | |
635 #endif | |
636 static int entity_init_fail_cnt = 0; | |
637 | |
638 #ifdef _ESF_SUPPORT_ | |
639 { | |
640 /* OS timer should not be started at this point, otherwise risk of | |
641 race condition. | |
642 Furthermore, ESF THIF socket interface can't be used by task tst | |
643 before esf_init_func2() is completed. | |
644 */ | |
645 | |
646 T_HANDLE esf_init_func2_sem; | |
647 T_HANDLE caller; | |
648 | |
649 caller = e_running[os_MyHandle()]; | |
650 esf_init_func2_sem = vsi_s_open (caller, "esf_init_func2_sem", 1); | |
651 | |
652 vsi_s_get (caller, esf_init_func2_sem); /* start of critical section */ | |
653 if (firstTime) | |
654 { | |
655 firstTime = FALSE; | |
656 esf_init_func2(); | |
657 esf_init_func2_ready = TRUE; | |
658 } | |
659 vsi_s_release(caller, esf_init_func2_sem); /* end of critical section */ | |
660 | |
661 while (!esf_init_func2_ready) | |
662 { | |
663 os_SuspendTask(caller, 100); | |
664 } | |
665 } | |
666 #endif | |
667 | |
668 if ( is_entity_in_task ( TaskHandle, FRM_TST_NAME ) == FALSE | |
669 && is_entity_in_task ( TaskHandle, FRM_RCV_NAME ) == FALSE ) | |
670 { | |
671 while ( !(TestInterface & RUNNING) ) | |
672 { | |
673 os_SuspendTask (TaskHandle, 100); | |
674 } | |
675 } | |
676 | |
677 for ( i = MaxEntities; i > 0; i-- ) | |
678 { | |
679 if ( pf_TaskTable[i].TaskHandle == TaskHandle ) | |
680 { | |
681 if ( pf_TaskTable[i].Flags & ADD_QUEUE_SIZES ) | |
682 { | |
683 entity_flags |= ADD_QUEUE_SIZES; | |
684 } | |
685 sum_queue_size += pf_TaskTable[i].QueueEntries; | |
686 if ( biggest_queue_size < pf_TaskTable[i].QueueEntries ) | |
687 { | |
688 biggest_queue_size = pf_TaskTable[i].QueueEntries; | |
689 } | |
690 if ( pf_TaskTable[i].Flags & INT_DATA_TASK ) | |
691 mem_pool_handle = int_data_pool_handle; | |
692 } | |
693 } | |
694 | |
695 /* set queue size depending on the flag exported by the entities */ | |
696 if ( entity_flags & ADD_QUEUE_SIZES ) | |
697 { | |
698 queue_entries = sum_queue_size; | |
699 } | |
700 else | |
701 { | |
702 queue_entries = biggest_queue_size; | |
703 } | |
704 | |
705 #ifdef _TOOLS_ | |
706 if ( os_CreateQueue ( TaskHandle, 0, pf_TaskTable[TaskHandle].Name, (USHORT)queue_entries, &queue_handle, | |
707 pf_TaskTable[TaskHandle].MemPoolHandle) == OS_ERROR ) | |
708 { | |
709 vsi_o_assert ( NO_TASK, OS_SYST_ERR_QUEUE_CREATE, __FILE__, __LINE__, | |
710 "Error at creating %s Queue", pf_TaskTable[TaskHandle].Name ); | |
711 } | |
712 #else | |
713 os_GetTaskName ( TaskHandle, TaskHandle, queue_name ); | |
714 if ( os_CreateQueue ( TaskHandle, 0, queue_name, (USHORT)queue_entries, &queue_handle, mem_pool_handle) == OS_ERROR ) | |
715 { | |
716 vsi_o_assert ( NO_TASK, OS_SYST_ERR_QUEUE_CREATE, __FILE__, __LINE__, "Error at creating %s Queue", queue_name ); | |
717 } | |
718 #endif | |
719 | |
720 for ( i = MaxEntities; i > 0; i-- ) | |
721 { | |
722 if ( pf_TaskTable[i].TaskHandle == TaskHandle ) | |
723 { | |
724 pf_TaskTable[i].QueueHandle = queue_handle; | |
725 pf_TaskTable[i].FirstTimerEntry = &TimerHandleField [ NextTimerEntry ]; | |
726 if ( (NextTimerEntry += pf_TaskTable[i].NumOfTimers) >= MaxTimer ) | |
727 vsi_o_assert ( NO_TASK, OS_SYST_ERR_MAX_TIMER, __FILE__, __LINE__, | |
728 "Number of Timers > MAX_TIMER" ); | |
729 } | |
730 } | |
731 | |
732 for ( i = MaxEntities; i > 0; i-- ) | |
733 { | |
734 if ( pf_TaskTable[i].TaskHandle == TaskHandle ) | |
735 { | |
736 if (pf_TaskTable[i].PeiTable->pei_init != NULL) | |
737 { | |
738 e_running[TaskHandle] = i; | |
739 while (pf_TaskTable[i].PeiTable->pei_init (i) == PEI_ERROR) | |
740 { | |
741 if ( entity_init_fail_cnt++ > (NumberOfStartedTasks * 5) ) | |
742 vsi_o_ttrace(NO_TASK, TC_SYSTEM, "%s pei_init() failed",pf_TaskTable[i].Name ); | |
743 os_SuspendTask (TaskHandle, 100); | |
744 } | |
745 e_running[TaskHandle] = 0; | |
746 } | |
747 } | |
748 } | |
749 | |
750 if ( is_entity_in_task ( TaskHandle, FRM_TST_NAME ) == TRUE ) | |
751 TestInterface |= RUNNING; | |
752 | |
753 | |
754 if ( ++NumberOfRunningTasks == NumberOfStartedTasks ) | |
755 { | |
756 if ( TooManyTasks ) | |
757 vsi_o_assert (NO_TASK, OS_SYST_ERR_MAX_TASK, __FILE__, __LINE__, "Number of entities > MAX_ENTITIES" ); | |
758 vsi_o_ttrace(NO_TASK, TC_SYSTEM, "All tasks entered main loop" ); | |
759 #if defined _NUCLEUS_ && !defined _TARGET_ | |
760 printf ("%s\n","All tasks entered main loop"); | |
761 #endif | |
762 #ifdef _TARGET_ | |
763 // TraceMask[0] = 0; // removed in FreeCalypso - Space Falcon | |
764 os_dar_set_filter(); | |
765 #endif | |
766 } | |
767 for ( i = MaxEntities; i > 0; i-- ) | |
768 { | |
769 if ( pf_TaskTable[i].TaskHandle == TaskHandle ) | |
770 { | |
771 if (pf_TaskTable[i].PeiTable->pei_run != NULL) | |
772 { | |
773 if ( !(pf_TaskTable[i].Flags & PASSIVE_BODY) ) | |
774 { | |
775 /* | |
776 * in the active body variant call pei_run | |
777 */ | |
778 e_running[TaskHandle] = i; | |
779 pf_TaskTable[i].PeiTable->pei_run (TaskHandle, pf_TaskTable[i].QueueHandle ); | |
780 #ifdef _TOOLS_ | |
781 pf_TaskTable[i].PeiTable->pei_exit(); | |
782 NextTimerEntry -= pf_TaskTable[i].NumOfTimers; | |
783 rt_RoutingModify ( TaskHandle, (char*)SYSPRIM_REDIRECT_TOKEN, (char*)SYSPRIM_CLEAR_TOKEN ); | |
784 os_DestroyQueue ( TaskHandle, pf_TaskTable[i].QueueHandle ); | |
785 e_running[TaskHandle] = 0; | |
786 os_DestroyTask ( TaskHandle, TaskHandle ); | |
787 #endif | |
788 e_running[TaskHandle] = 0; | |
789 for (;;) | |
790 os_SuspendTask(TaskHandle,10000); | |
791 } | |
792 } | |
793 } | |
794 } | |
795 | |
796 /* | |
797 * in the passive body variant wait for a message and | |
798 * handle it | |
799 */ | |
800 for ( i = MaxEntities; i > 0; i-- ) | |
801 { | |
802 if ( pf_TaskTable[i].TaskHandle == TaskHandle ) | |
803 { | |
804 break; | |
805 } | |
806 } | |
807 for (;;) | |
808 { | |
809 sts = os_ReceiveFromQueue ( TaskHandle, pf_TaskTable[i].QueueHandle, | |
810 &Msg, OS_SUSPEND ); | |
811 switch ( sts ) | |
812 { | |
813 case OS_OK: | |
814 #if defined (_TOOLS_) || defined (_LINUX_) | |
815 e_running[TaskHandle] = TaskHandle; | |
816 pf_HandleMessage (TaskHandle, &Msg); | |
817 #else | |
818 e_running[TaskHandle] = Msg.e_id; | |
819 prf_log_entity_activate ((void*)Msg.e_id); | |
820 pf_HandleMessage (Msg.e_id, &Msg); | |
821 #endif | |
822 e_running[TaskHandle] = 0; | |
823 #ifdef _NUCLEUS_ | |
824 if ( os_CheckTaskStack ( TaskHandle ) == OS_ERROR ) | |
825 { | |
826 os_GetTaskName ( TaskHandle, TaskHandle, TaskName ); | |
827 vsi_o_assert ( TaskHandle, OS_SYST_ERR_STACK_OVERFLOW, __FILE__, __LINE__, | |
828 "%s Stack overflow", TaskName ); | |
829 } | |
830 #endif | |
831 break; | |
832 case OS_TIMEOUT: | |
833 break; | |
834 case OS_ERROR: | |
835 for(;;) | |
836 os_SuspendTask(TaskHandle,10000); | |
837 /*lint -e527, suppress Warning -- Unreachable */ | |
838 break; | |
839 default: | |
840 for(;;) | |
841 os_SuspendTask(TaskHandle,10000); | |
842 break; | |
843 /*lint +e527 */ | |
844 | |
845 } | |
846 } | |
847 } | |
848 #endif | |
849 | |
850 #ifndef RUN_INT_RAM | |
851 /* | |
852 +--------------------------------------------------------------------+ | |
853 | PROJECT : GSM-GPF (8415) MODULE : FRAME | | |
854 | STATE : code ROUTINE : pf_Timeout | | |
855 +--------------------------------------------------------------------+ | |
856 */ | |
857 GLOBAL void pf_Timeout (T_HANDLE TaskHandle, T_HANDLE EntityHandle, USHORT TimerIndex ) | |
858 { | |
859 OS_QDATA TimeoutMsg; | |
860 | |
861 TimeoutMsg.data16 = MSG_TIMEOUT; | |
862 TimeoutMsg.data32 = (ULONG)TimerIndex; | |
863 #ifdef _TOOLS_ | |
864 TimeoutMsg.len = 0; | |
865 #endif | |
866 TimeoutMsg.e_id = EntityHandle; | |
867 os_GetTime ( 0, &TimeoutMsg.time ); | |
868 | |
869 *(pf_TaskTable[EntityHandle].FirstTimerEntry + TimerIndex) |= TIMEOUT_OCCURRED; | |
870 | |
871 #ifdef _TOOLS_ | |
872 if ( rt_Route (TaskHandle, pf_TaskTable[EntityHandle].QueueHandle, OS_NORMAL, OS_SUSPEND, | |
873 &TimeoutMsg ) == OS_TIMEOUT ) | |
874 #else | |
875 if ( rt_Route (TaskHandle, EntityHandle, OS_NORMAL, OS_SUSPEND, | |
876 &TimeoutMsg ) == OS_TIMEOUT ) | |
877 #endif | |
878 vsi_o_assert ( 0, OS_SYST_ERR_QUEUE_FULL, __FILE__, __LINE__, | |
879 "Timeout write attempt to %s queue failed", pf_TaskTable[EntityHandle].Name ); | |
880 } | |
881 #endif | |
882 | |
883 #ifndef RUN_FLASH | |
884 /* | |
885 +--------------------------------------------------------------------+ | |
886 | PROJECT : GSM-GPF (8415) MODULE : FRAME | | |
887 | STATE : code ROUTINE : pf_HandleMessage | | |
888 +--------------------------------------------------------------------+ | |
889 */ | |
890 LOCAL SHORT pf_HandleMessage (T_HANDLE TaskHandle, OS_QDATA *pMsg ) | |
891 { | |
892 ULONG PrimId = 0; | |
893 | |
894 switch (pMsg->data16) | |
895 { | |
896 case MSG_PRIMITIVE: | |
897 if ( pMsg->ptr != NULL ) | |
898 { | |
899 PrimId = ((T_PRIM_HEADER*)(pMsg->ptr))->opc; | |
900 | |
901 if ( PrimId & SYS_MASK ) | |
902 { | |
903 pf_ProcessSystemPrim ( TaskHandle, pMsg->ptr ); | |
904 } | |
905 else | |
906 { | |
907 pf_ProcessProtocolPrim ( TaskHandle, pMsg->ptr ); | |
908 } | |
909 } | |
910 break; | |
911 case MSG_SIGNAL: | |
912 if ( pf_TaskTable[TaskHandle].PeiTable->pei_signal != NULL ) | |
913 { | |
914 pf_TaskTable[TaskHandle].PeiTable->pei_signal ( pMsg->data32, pMsg->ptr ); | |
915 } | |
916 break; | |
917 case MSG_TIMEOUT: | |
918 if ( *(pf_TaskTable[TaskHandle].FirstTimerEntry + pMsg->data32) & TIMEOUT_OCCURRED ) | |
919 { | |
920 if ( !(*(pf_TaskTable[TaskHandle].FirstTimerEntry + pMsg->data32) & PERIODIC_TIMER) ) | |
921 { | |
922 os_DestroyTimer ( TaskHandle, (OS_HANDLE)(*(pf_TaskTable[TaskHandle].FirstTimerEntry + pMsg->data32) & TIMER_HANDLE_MASK) ); | |
923 *(pf_TaskTable[TaskHandle].FirstTimerEntry + pMsg->data32) = 0; | |
924 } | |
925 else | |
926 { | |
927 *(pf_TaskTable[TaskHandle].FirstTimerEntry + pMsg->data32) &= ~TIMEOUT_OCCURRED; | |
928 } | |
929 vsi_o_ttrace ( TaskHandle, TC_TIMER, "Timeout : Index %d",pMsg->data32) ; | |
930 if ( pf_TaskTable[TaskHandle].PeiTable->pei_timeout != NULL ) | |
931 pf_TaskTable[TaskHandle].PeiTable->pei_timeout ( (USHORT)pMsg->data32 ); | |
932 } | |
933 break; | |
934 default: | |
935 VSI_PPM_FREE(pMsg->ptr); | |
936 os_DeallocatePartition (TaskHandle, pMsg->ptr-PPM_OFFSET ); | |
937 return PF_ERROR; | |
938 /*lint -e527, suppress Warning -- Unreachable */ | |
939 break; | |
940 /*lint +e527 */ | |
941 } | |
942 return PF_OK; | |
943 } | |
944 #endif | |
945 | |
946 #ifndef RUN_FLASH | |
947 /* | |
948 +--------------------------------------------------------------------+ | |
949 | PROJECT : GSM-GPF (8415) MODULE : FRAME | | |
950 | STATE : code ROUTINE : pf_ProcessProtocolPrim| | |
951 +--------------------------------------------------------------------+ | |
952 */ | |
953 LOCAL void pf_ProcessProtocolPrim ( T_HANDLE TaskHandle, T_VOID_STRUCT *pPrim) | |
954 { | |
955 | |
956 if ( TaskHandle != NO_TASK ) | |
957 { | |
958 if (pf_TaskTable[TaskHandle].PeiTable->pei_primitive != NULL) | |
959 { | |
960 #ifdef PRIM_AUTO_FREE | |
961 if ( pf_TaskTable[TaskHandle].Flags & PARTITION_AUTO_FREE ) | |
962 { | |
963 /* | |
964 * TST uses its own partition pool and is handled differently | |
965 */ | |
966 if ( TaskHandle != TST_Handle ) | |
967 { | |
968 processed_prim[TaskHandle] = pPrim; | |
969 freed_prim[TaskHandle] = NULL; | |
970 } | |
971 } | |
972 #endif /* PRIM_AUTO_FREE */ | |
973 #ifdef MEMORY_SUPERVISION | |
974 if ( TaskHandle != TST_Handle ) /* Trace pools are not monitored by PPM */ | |
975 VSI_PPM_RCV(pPrim); | |
976 #endif | |
977 pf_TaskTable[TaskHandle].PeiTable->pei_primitive (pPrim); | |
978 | |
979 #ifdef PRIM_AUTO_FREE | |
980 if ( pf_TaskTable[TaskHandle].Flags & PARTITION_AUTO_FREE ) | |
981 { | |
982 /* | |
983 * if PSTORE was called during the primitive processing, PFREE was no longer | |
984 * blocked inside the entity and it could have happened that a primitive | |
985 * was freed and then newly allocated either by the same or by a different | |
986 * entity (IRQ). To avoid auto free it is checked if an effective free was | |
987 * done with the pointer passed to pei_primitive(). In this case the | |
988 * partition is not freed. | |
989 */ | |
990 if ( freed_prim[TaskHandle] == pPrim ) | |
991 { | |
992 freed_prim[TaskHandle] = NULL; | |
993 return; | |
994 } | |
995 else | |
996 { | |
997 processed_prim[TaskHandle] = NULL; | |
998 | |
999 if ( pPrim != NULL ) | |
1000 { | |
1001 FREE ( P2D(pPrim) ); | |
1002 } | |
1003 return; | |
1004 } | |
1005 } | |
1006 else | |
1007 #endif /* PRIM_AUTO_FREE */ | |
1008 return; | |
1009 } | |
1010 } | |
1011 if ( pPrim != NULL) | |
1012 { | |
1013 #ifndef _TARGET_ | |
1014 vsi_o_ttrace ( NO_TASK, TC_SYSTEM, "Primitive discarded in dummy entity %s, opc 0x%x", | |
1015 pf_TaskTable[TaskHandle].Name, ((T_PRIM_HEADER*)pPrim)->opc ); | |
1016 #endif | |
1017 VSI_PPM_RCV(pPrim); | |
1018 FREE ( P2D(pPrim) ); | |
1019 } | |
1020 } | |
1021 #endif | |
1022 | |
1023 #ifndef RUN_INT_RAM | |
1024 /* | |
1025 +--------------------------------------------------------------------+ | |
1026 | PROJECT : GSM-GPF (8415) MODULE : FRAME | | |
1027 | STATE : code ROUTINE : pf_ProcessSystemPrim | | |
1028 +--------------------------------------------------------------------+ | |
1029 */ | |
1030 GLOBAL void pf_ProcessSystemPrim ( T_HANDLE TaskHandle, T_VOID_STRUCT *pPrim) | |
1031 { | |
1032 char * data; | |
1033 /*lint -e813, suppress Info 813: auto variable 'token' has size '132' -> uncritical in this context */ | |
1034 char token[TRACE_TEXT_SIZE]; | |
1035 /*lint +e813 */ | |
1036 BOOL Error = FALSE; | |
1037 LONG i; | |
1038 unsigned int Length; | |
1039 T_HANDLE min, max; | |
1040 char TraceMaskBuffer[9]; | |
1041 ULONG trace_mask; | |
1042 LONG state; | |
1043 #ifdef _TOOLS_ | |
1044 T_S_HEADER *s_hdr; | |
1045 #endif | |
1046 | |
1047 VSI_PPM_RCV(pPrim); | |
1048 | |
1049 data = (char *)P2D( pPrim ); | |
1050 | |
1051 Length = GetNextToken (data, token, " #"); | |
1052 | |
1053 if (!strcmp (token, SYSPRIM_REDIRECT_TOKEN) | |
1054 OR !strcmp (token, SYSPRIM_DUPLICATE_TOKEN)) | |
1055 { | |
1056 | |
1057 if (TaskHandle NEQ NO_TASK) | |
1058 { | |
1059 /* | |
1060 * Redirect or Duplicate primitives | |
1061 */ | |
1062 if ( (state = rt_RoutingModify (TaskHandle, token, data+strlen(token)+1)) != RT_OK ) | |
1063 { | |
1064 #ifdef NU_DEBUG | |
1065 switch ( state ) | |
1066 { | |
1067 case RT_NO_MEM: | |
1068 vsi_o_ttrace(NO_TASK, TC_SYSTEM, "SYSTEM WARNING: Out of Memory - routing command rejected"); | |
1069 VSI_PPM_FREE(pPrim); | |
1070 os_DeallocatePartition (TaskHandle, pPrim-PPM_OFFSET ); | |
1071 return; | |
1072 /*lint -e527, suppress Warning -- Unreachable */ | |
1073 break; | |
1074 /*lint +e527 */ | |
1075 case RT_ERROR: Error = TRUE; | |
1076 break; | |
1077 } | |
1078 #else | |
1079 Error = TRUE; | |
1080 #endif | |
1081 } | |
1082 } | |
1083 } | |
1084 else if ( !strcmp ( token, SYSPRIM_TRACECLASS_TOKEN) ) | |
1085 { | |
1086 if ( Length < strlen(data)-1 ) | |
1087 { | |
1088 GetNextToken (data+Length+1, token, " #"); | |
1089 trace_mask = ASCIIToHex(token, CHARS_FOR_32BIT); | |
1090 if ( TaskHandle == TST_Handle ) | |
1091 { | |
1092 min = 1; | |
1093 max = MaxEntities; | |
1094 } | |
1095 else | |
1096 { | |
1097 min = TaskHandle; | |
1098 max = TaskHandle; | |
1099 } | |
1100 for ( i = min; i <= max; i++ ) | |
1101 { | |
1102 if ( vsi_settracemask ( TaskHandle, i, trace_mask) == VSI_ERROR ) | |
1103 break; | |
1104 } | |
1105 } | |
1106 else | |
1107 { | |
1108 vsi_gettracemask ( TaskHandle, TaskHandle, &trace_mask); | |
1109 HexToASCII ( trace_mask, TraceMaskBuffer, CHARS_FOR_32BIT ); | |
1110 TraceMaskBuffer[8] = 0; | |
1111 sprintf ( data, "%s %s %s", pf_TaskTable[TaskHandle].Name, SYSPRIM_TRACECLASS_TOKEN, TraceMaskBuffer ); | |
1112 vsi_o_ttrace ( NO_TASK, TC_SYSTEM, data ); | |
1113 } | |
1114 } | |
1115 else if (!strcmp (token, SYSPRIM_CONFIG_TOKEN)) | |
1116 { | |
1117 /* | |
1118 * Dynamic Configuration | |
1119 */ | |
1120 if (TaskHandle != NO_TASK) | |
1121 { | |
1122 /* | |
1123 * call the pei_config function of the entity | |
1124 */ | |
1125 if (pf_TaskTable[TaskHandle].PeiTable->pei_config NEQ NULL) | |
1126 if ( pf_TaskTable[TaskHandle].PeiTable->pei_config ( data+strlen (token)+1 ) == PEI_ERROR ) | |
1127 Error = TRUE; | |
1128 } | |
1129 } | |
1130 #if 0 | |
1131 /* not needed -> temporarily removed */ | |
1132 else if (!strcmp (token, SYSPRIM_ISOLATE_TOKEN)) | |
1133 { | |
1134 if ( rt_isolate_entity (TaskHandle, data+strlen(token)+1) == RT_ERROR ) | |
1135 Error = TRUE; | |
1136 } | |
1137 #endif | |
1138 else if (!strcmp (token, SYSPRIM_REGISTER_ERR_IND)) | |
1139 { | |
1140 strncpy ( error_ind_dst, data+strlen(token)+1, RESOURCE_NAMELEN ); | |
1141 error_ind_dst[RESOURCE_NAMELEN-1] = 0; | |
1142 if ( frm_error_ind == NULL ) | |
1143 { | |
1144 frm_error_ind = (T_FRM_ERROR_IND*)vsi_c_pnew (sizeof(T_FRM_ERROR_IND), FRM_ERROR_IND FILE_LINE_MACRO ); | |
1145 } | |
1146 } | |
1147 else if (!strcmp (token, SYSPRIM_WITHDRAW_ERR_IND)) | |
1148 { | |
1149 if ( frm_error_ind != NULL ) | |
1150 { | |
1151 error_ind_dst[0] = 0; | |
1152 vsi_c_pfree( (T_VOID_STRUCT**)&frm_error_ind FILE_LINE_MACRO ); | |
1153 frm_error_ind = NULL; | |
1154 } | |
1155 } | |
1156 else if (!strcmp (token, SYSPRIM_STATUS_TOKEN)) | |
1157 { | |
1158 GetNextToken (data+strlen(token)+1, token, " #"); | |
1159 VSI_PPM_FREE(pPrim); | |
1160 os_DeallocatePartition (TaskHandle, pPrim-PPM_OFFSET ); | |
1161 i = 0; | |
1162 while ( Resource[i].Name && strcmp ( Resource[i].Name, token ) ) | |
1163 i++; | |
1164 if ( vsi_object_info (TaskHandle, Resource[i].Id, FIRST_ENTRY, token, sizeof(token)) == VSI_OK ) | |
1165 { | |
1166 vsi_o_ttrace ( NO_TASK, TC_SYSTEM, token ); | |
1167 while ( vsi_object_info (TaskHandle, Resource[i].Id, NEXT_ENTRY, token, sizeof(token)) == VSI_OK ) | |
1168 { | |
1169 vsi_o_ttrace ( NO_TASK, TC_SYSTEM, token ); | |
1170 } | |
1171 } | |
1172 return; | |
1173 } | |
1174 #if 0 | |
1175 else if (!strcmp (token, SYSPRIM_READ_COM_MATRIX)) | |
1176 { | |
1177 state = vsi_c_get_com_matrix_entry ( FIRST_ENTRY, token ); | |
1178 if ( state == VSI_OK ) | |
1179 { | |
1180 vsi_o_ttrace ( NO_TASK, TC_SYSTEM, token ); | |
1181 do | |
1182 { | |
1183 if ( (state = vsi_c_get_com_matrix_entry ( NEXT_ENTRY, token)) == VSI_OK ) | |
1184 vsi_o_ttrace ( NO_TASK, TC_SYSTEM, token ); | |
1185 } while ( state == VSI_OK ); | |
1186 } | |
1187 } | |
1188 #endif | |
1189 #ifdef _TARGET_ | |
1190 else if (!strcmp (token, SYSPRIM_READ_FFS_DAR)) | |
1191 { | |
1192 state = os_read_dar_ffs_data ( FIRST_ENTRY, token, TextTracePartitionSize - sizeof(T_S_HEADER) - sizeof(T_PRIM_HEADER) - 1 ); | |
1193 if ( state == OS_OK ) | |
1194 { | |
1195 vsi_o_ttrace ( NO_TASK, TC_SYSTEM, token ); | |
1196 do | |
1197 { | |
1198 if ( (state = os_read_dar_ffs_data ( NEXT_ENTRY, token, TextTracePartitionSize - sizeof(T_S_HEADER) - sizeof(T_PRIM_HEADER) - 1)) == OS_OK ) | |
1199 vsi_o_ttrace ( NO_TASK, TC_SYSTEM, token ); | |
1200 } while ( state == OS_OK ); | |
1201 } | |
1202 else | |
1203 vsi_o_ttrace ( NO_TASK, TC_SYSTEM, "No DAR entry stored" ); | |
1204 | |
1205 } | |
1206 #endif | |
1207 #if !defined _TARGET_ && !defined _TOOLS_ | |
1208 else if (!strcmp (token, SYSPRIM_PCHECK)) | |
1209 { | |
1210 pcheck_active[TaskHandle] = TRUE; | |
1211 } | |
1212 #endif | |
1213 else if (!strcmp (token, SYSPRIM_ROUTE_DESCLIST)) | |
1214 { | |
1215 route_desclist[TaskHandle] = TRUE; | |
1216 } | |
1217 else if (!strcmp (token, SYSPRIM_CHECK_DESCLIST)) | |
1218 { | |
1219 check_desclist = TRUE; | |
1220 } | |
1221 #ifdef _NUCLEUS_ | |
1222 else if (!strcmp (token, SYSPRIM_VERSION_TOKEN)) | |
1223 { | |
1224 vsi_o_ttrace (NO_TASK, TC_SYSTEM,"FRAME VERSION: %s, %s",frame_version_date, frame_version_time); | |
1225 vsi_o_ttrace (NO_TASK, TC_SYSTEM,"MISC VERSION: %s, %s",misc_version_date, misc_version_time); | |
1226 vsi_o_ttrace (NO_TASK, TC_SYSTEM,"TIF VERSION: %s, %s",tif_version_date, tif_version_time); | |
1227 } | |
1228 #endif | |
1229 else if (!strcmp (token, SYSPRIM_RESET_TOKEN)) | |
1230 { | |
1231 /* | |
1232 * Reset | |
1233 */ | |
1234 pf_Reset (TaskHandle); | |
1235 } | |
1236 #ifdef _TOOLS_ | |
1237 else if (!strcmp (token, SYSPRIM_EXIT_TOKEN)) | |
1238 { | |
1239 /* | |
1240 * Exit and delete | |
1241 */ | |
1242 if (pf_TaskTable[TaskHandle].PeiTable->pei_exit != NULL) | |
1243 { | |
1244 pf_TaskTable[TaskHandle].PeiTable->pei_exit(); | |
1245 } | |
1246 VSI_PPM_FREE(pPrim); | |
1247 os_DeallocatePartition (TaskHandle, pPrim-PPM_OFFSET ); | |
1248 vsi_p_delete(0,TaskHandle); | |
1249 } | |
1250 #endif /* _TOOLS_ */ | |
1251 #ifdef MEMORY_SUPERVISION | |
1252 else if (!strcmp (token, SYSPRIM_CHECK_OWNER)) | |
1253 { | |
1254 ppm_check_partition_owner = 1; | |
1255 } | |
1256 else if (!strcmp (token, SYSPRIM_SHOW_MEMORY)) | |
1257 { | |
1258 /* | |
1259 * Show state of the partition pool monitor | |
1260 */ | |
1261 VSI_PPM_FREE(pPrim); | |
1262 os_DeallocatePartition (TaskHandle, pPrim-PPM_OFFSET ); | |
1263 TracePoolstatus (TaskHandle); | |
1264 return; | |
1265 } | |
1266 #endif /* MEMORY_SUPERVISION */ | |
1267 #ifndef _TOOLS_ | |
1268 else if (!strcmp (token, SYSPRIM_SELECT_TIME_TDMA)) | |
1269 { | |
1270 time_is_tdma_frame = 1; | |
1271 } | |
1272 #endif | |
1273 #ifdef _TOOLS_ | |
1274 else if (!strcmp (token, SYSPRIM_IS_STACK_TIME)) | |
1275 { | |
1276 s_hdr = P_SHDR(pPrim); | |
1277 set_stack_time (s_hdr->time); | |
1278 } | |
1279 else if (!strcmp (token, SYSPRIM_REGISTER_TOKEN)) | |
1280 { | |
1281 OS_HANDLE comhandle; | |
1282 GetNextToken (data+strlen(token)+1, token, " #"); | |
1283 if (os_create_extq (token, &comhandle) == OS_OK) | |
1284 { | |
1285 if (!strcmp (token, FRM_PCO_NAME)) | |
1286 { | |
1287 vsi_o_set_htrace (comhandle); | |
1288 } | |
1289 } | |
1290 else | |
1291 Error = TRUE; | |
1292 } | |
1293 else if (!strcmp (token, SYSPRIM_WITHDRAW_TOKEN)) | |
1294 { | |
1295 GetNextToken (data+strlen(token)+1, token, " #"); | |
1296 if (os_destroy_extq (token) == OS_OK) | |
1297 { | |
1298 if (!strcmp (token, FRM_PCO_NAME)) | |
1299 { | |
1300 vsi_o_set_htrace (0); | |
1301 } | |
1302 } | |
1303 else | |
1304 Error = TRUE; | |
1305 } | |
1306 #endif /* _TOOLS_ */ | |
1307 else | |
1308 Error = TRUE; | |
1309 | |
1310 if ( Error ) | |
1311 { | |
1312 vsi_o_ttrace ( NO_TASK, TC_SYSTEM, "SYSTEM WARNING:Invalid system primitive '%s'",data ); | |
1313 } | |
1314 else | |
1315 { | |
1316 if ( !SuppressOK ) | |
1317 { | |
1318 vsi_o_ttrace ( NO_TASK, TC_SYSTEM, "OK (%s %s)", pf_TaskTable[TaskHandle].Name, data ); | |
1319 } | |
1320 } | |
1321 VSI_PPM_FREE(pPrim); | |
1322 os_DeallocatePartition (TaskHandle, pPrim-PPM_OFFSET ); | |
1323 } | |
1324 #endif | |
1325 | |
1326 #ifndef RUN_INT_RAM | |
1327 /* | |
1328 +--------------------------------------------------------------------+ | |
1329 | PROJECT : GSM-GPF (8415) MODULE : FRAME | | |
1330 | STATE : code ROUTINE : pf_Reset | | |
1331 +--------------------------------------------------------------------+ | |
1332 */ | |
1333 LOCAL void pf_Reset (T_HANDLE TaskHandle) | |
1334 { | |
1335 if (TaskHandle != NO_TASK) | |
1336 { | |
1337 if (pf_TaskTable[TaskHandle].PeiTable->pei_exit != NULL) | |
1338 pf_TaskTable[TaskHandle].PeiTable->pei_exit(); | |
1339 /* | |
1340 * reset a single entity | |
1341 */ | |
1342 if (pf_TaskTable[TaskHandle].PeiTable->pei_init != NULL) | |
1343 while (pf_TaskTable[TaskHandle].PeiTable->pei_init(TaskHandle) == PEI_ERROR) | |
1344 os_SuspendTask ( TaskHandle, 5); | |
1345 } | |
1346 else | |
1347 { | |
1348 USHORT Handle; | |
1349 /* | |
1350 * reset all entities | |
1351 */ | |
1352 for (Handle = 1; Handle <= MaxEntities; Handle++) | |
1353 { | |
1354 if (pf_TaskTable[TaskHandle].PeiTable->pei_exit != NULL) | |
1355 pf_TaskTable[TaskHandle].PeiTable->pei_exit(); | |
1356 | |
1357 if (pf_TaskTable[Handle].PeiTable->pei_init != NULL) | |
1358 while (pf_TaskTable[TaskHandle].PeiTable->pei_init(TaskHandle) == PEI_ERROR) | |
1359 os_SuspendTask ( TaskHandle, 5); | |
1360 } | |
1361 } | |
1362 } | |
1363 #endif | |
1364 | |
1365 #ifdef _TOOLS_ | |
1366 /* | |
1367 +--------------------------------------------------------------------+ | |
1368 | PROJECT : GSM-Frame (8415) MODULE : FRAME | | |
1369 | STATE : code ROUTINE : set_stack_time | | |
1370 +--------------------------------------------------------------------+ | |
1371 | |
1372 PURPOSE : stores the local time of stack under test. Used to align | |
1373 timestamps while tracing. | |
1374 | |
1375 */ | |
1376 void set_stack_time ( ULONG time ) | |
1377 { | |
1378 init_stack_time = time; | |
1379 os_GetTime ( NO_TASK, &init_local_time ); | |
1380 } | |
1381 | |
1382 /* | |
1383 +--------------------------------------------------------------------+ | |
1384 | PROJECT : GSM-Frame (8415) MODULE : FRAME | | |
1385 | STATE : code ROUTINE : get_stack_time | | |
1386 +--------------------------------------------------------------------+ | |
1387 | |
1388 PURPOSE : returns the local time of stack under test. Used to align | |
1389 timestamps while tracing. | |
1390 | |
1391 */ | |
1392 void get_local_time ( ULONG *time ) | |
1393 { | |
1394 OS_TIME current_local_time; | |
1395 | |
1396 os_GetTime ( NO_TASK, ¤t_local_time ); | |
1397 *time = init_stack_time + current_local_time - init_local_time; | |
1398 } | |
1399 | |
1400 #endif | |
1401 | |
1402 #ifndef RUN_INT_RAM | |
1403 /* | |
1404 +--------------------------------------------------------------------+ | |
1405 | PROJECT : GSM-Frame (8415) MODULE : FRAME | | |
1406 | STATE : code ROUTINE : pf_handle_error | | |
1407 +--------------------------------------------------------------------+ | |
1408 | |
1409 PURPOSE : frame error and warning handling | |
1410 | |
1411 */ | |
1412 /*lint -e506, suppress Warning 506: Constant value Boolean */ | |
1413 /*lint -e718, suppress nfo 718: Symbol '_va_argref' undeclared, assumed to return int */ | |
1414 int pf_handle_warning ( USHORT cause, const char * const format,...) | |
1415 { | |
1416 T_HANDLE caller; | |
1417 va_list varpars; | |
1418 static int recursion_count = 0; | |
1419 USHORT free; | |
1420 USHORT alloc; | |
1421 | |
1422 /* recursion counter is needed to avoid endless loop when generating warning during processing of warning */ | |
1423 if ( recursion_count == 0 ) | |
1424 { | |
1425 recursion_count++; | |
1426 caller = e_running[os_MyHandle()]; | |
1427 va_start (varpars, format); | |
1428 int_vsi_o_ttrace ( NO_TASK, TC_SYSTEM, format, varpars ); | |
1429 | |
1430 if ( error_ind_dst[0] != 0 ) | |
1431 { | |
1432 /* drop the warning, if there are fewer than 3 partitions available to avoid deadlock */ | |
1433 vsi_m_status ( caller, sizeof(T_FRM_WARNING_IND)+sizeof(T_PRIM_HEADER), PrimGroupHandle, &free, &alloc ); | |
1434 if ( free >= 3 ) | |
1435 { | |
1436 PALLOC(frm_warning_ind,FRM_WARNING_IND); | |
1437 frm_warning_ind->warning_code = cause; | |
1438 #ifdef _TARGET_ | |
1439 /* We will destroy the partition guard pattern if the warning is longer than the warning string in FRM_WARNING_IND */ | |
1440 vsprintf ((char*)frm_warning_ind->warning_string, format, varpars); | |
1441 #else | |
1442 #if defined(_LINUX_) || defined(_SOLARIS_) | |
1443 vsnprintf ((char*)frm_warning_ind->warning_string, | |
1444 sizeof(frm_warning_ind->warning_string), format, varpars); | |
1445 #else | |
1446 _vsnprintf ((char*)frm_warning_ind->warning_string, sizeof(frm_warning_ind->warning_string), format, varpars); | |
1447 #endif | |
1448 #endif | |
1449 vsi_o_primsend ( caller, TC_SYSTEM, 0, error_ind_dst, (unsigned int)FRM_WARNING_IND, frm_warning_ind, sizeof(T_FRM_WARNING_IND) FILE_LINE_MACRO ); | |
1450 } | |
1451 else | |
1452 { | |
1453 vsi_o_ttrace ( NO_TASK, TC_SYSTEM, "FRM_WARNING_IND dropped" ); | |
1454 } | |
1455 } | |
1456 #if defined _NUCLEUS_ && !defined _TARGET_ | |
1457 vsprintf (TraceBuffer, format, varpars); | |
1458 printf ("%s\n",TraceBuffer); | |
1459 #endif | |
1460 #ifdef _NUCLEUS_ | |
1461 os_SystemError ( os_MyHandle(), cause, NULL ); | |
1462 #endif | |
1463 recursion_count--; | |
1464 } | |
1465 return VSI_OK; | |
1466 } | |
1467 /*lint +e718 */ | |
1468 /*lint +e506 */ | |
1469 | |
1470 #endif | |
1471 | |
1472 |