comparison src/gpf/frame/frame.c @ 5:1ea54a97e831

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