Adding new commiter to ODU-High repo
[o-du/l2.git] / src / mt / ss_task.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18 \f
19 /********************************************************************20**
20  
21      Name:     System Services -- Task Management
22  
23      Type:     C source file
24  
25      Desc:     Source code for System Services functions for task mgmt.
26  
27      File:     ss_task.c
28  
29 *********************************************************************21*/
30
31 \f
32 /* header include files (.h) */
33
34 #include "envopt.h"        /* environment options */
35 #include "envdep.h"        /* environment dependent */
36 #include "envind.h"        /* environment independent */
37   
38 #include "gen.h"           /* general layer */
39 #include "ssi.h"           /* system services */
40
41 #include "ss_err.h"        /* errors */
42 #include "ss_dep.h"        /* implementation-specific */
43 #include "ss_queue.h"      /* queues */
44 #include "ss_task.h"       /* tasking */
45 #include "ss_msg.h"        /* messaging */
46 #include "ss_mem.h"        /* memory management interface */
47 #include "ss_gen.h"        /* general */
48 #include "cm_mem.h"        /* memory management */
49 #ifdef SPLIT_RLC_DL_TASK
50 #include "rgu.h"
51 #endif
52 #ifdef SS_FBSED_TSK_REG
53 #include "cm_task.h"
54 #endif /* SS_FBSED_TSK_REG */
55
56 /* header/extern include files (.x) */
57
58 #include "gen.x"           /* general layer */
59 #include "ssi.x"           /* system services */
60
61 #include "ss_dep.x"        /* implementation-specific */
62 #include "ss_queue.x"      /* queues */
63 #include "ss_task.x"       /* tasking */
64 #include "ss_timer.x"      /* timers */
65 #include "ss_strm.x"       /* STREAMS */
66 #include "ss_msg.x"        /* messaging */
67 #include "ss_mem.x"        /* memory management interface */
68 #include "ss_drvr.x"       /* driver tasks */
69 #ifdef SS_LOCKLESS_MEMORY
70 #include "cm_llist.x"
71 #include "cm_hash.x"
72 #include "cm_mem_wl.x"        /* common memory manager */
73 #else
74 #include "cm_mem.x"        /* common memory manager */
75 #endif /* SS_LOCKLESS_MEMORY */
76 #include "ss_gen.x"        /* general */
77 #include "cm_lib.x"        /* general */
78
79 /* ss001.301: additions */
80 #ifdef SS_LOGGER_SUPPORT 
81 /* ss002.301: Fixed warings */
82 #ifdef SS_MT 
83 #include <fcntl.h>
84 #include <sys/stat.h>
85 #include <sys/socket.h>
86 #include <netinet/in.h>
87 #include <arpa/inet.h>
88 #endif /* SS_MT */
89 #ifdef WIN32
90 #include <stdio.h>
91 #include "winsock2.h"
92 #include "ws2tcpip.h"
93 #endif /* WIN32 */
94 #endif /*  SS_LOGGER_SUPPORT */
95
96 /* ss001.301: additions */
97 #ifdef SS_WATCHDOG 
98 #include <stdio.h>
99 #ifdef SS_MT 
100 #include <sys/time.h>
101 #include <sys/types.h>
102 #include <unistd.h>
103 #include <sys/poll.h>
104 #include <fcntl.h>
105 #include <sys/types.h>
106 #include <sys/socket.h>
107 #include <netinet/in.h>
108 #include <arpa/inet.h>
109 #elif WIN32
110 #include "winsock2.h"
111 #include "ws2tcpip.h"
112 #endif /* WIN32 */
113 #endif /* SS_WATCHDOG */
114
115 /* ss001.301: additions */
116 #ifdef SS_FBSED_TSK_REG 
117 #include "cm_task.x"
118 #endif /* SS_FBSED_TSK_REG */
119 /* ss004.301 : Cavium changes */
120 #ifdef SS_SEUM_CAVIUM
121 /* cvmx includes files */
122 #include "cvmx-config.h"
123 #include "cvmx.h"
124 #include "cvmx-pow.h"
125 #include "cvmx-tim.h"
126 #include "cvmx-fpa.h"
127 #include "cvmx-helper-fpa.h"
128 #include "cvmx-malloc.h"
129 #endif /* SS_SEUM_CAVIUM */
130 #ifdef L2_L3_SPLIT
131 #include "signal.h"
132 #include "mt_plat_t33.h"
133 #include "mt_4gmx.x"
134 S32 clusterMode;
135 #endif 
136
137 pthread_t tmpRegTidMap[20];
138
139 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
140 unsigned int tlPost(void *handle);
141 #ifdef XEON_SPECIFIC_CHANGES
142 int          WLS_WakeUp(void* h);
143 #endif
144 #endif
145
146 /* ss029.103: modification: 
147    Old SSI functions are not supported with multiple procIds */ 
148 #ifndef SS_MULTIPLE_PROCS
149 \f
150 /*
151 *
152 *       Fun:   SRegInit
153 *
154 *       Desc:  This function is used to register an initialization function
155 *              for the layer. The system services will invoke the function
156 *              passed to it one time. The initialization function will be
157 *              used by the layer to initilize the layer.
158 *
159 *       Ret:   ROK      - ok
160 *              RFAILED  - failed, general (optional)
161 *
162 *       Notes:
163 *
164 *       File:  ss_task.c
165 *
166 */
167   
168 S16 SRegInit
169 (
170 Ent ent,                    /* entity */
171 Inst inst,                  /* instance */
172 PAIFS16 initFnct            /* initialization function */
173 )
174 {
175    /* ss021.103 - Addition for return value and pointer */
176    S16         ret;     /* return value */
177    SsTTskEntry *tTsk;
178
179
180
181 #if (ERRCLASS & ERRCLS_INT_PAR)
182    /* check entity and instance ranges */
183    if (ent >= SS_MAX_ENT ||  inst >= SS_MAX_INST)
184    {
185       SSLOGERROR(ERRCLS_INT_PAR, ESS350, ERRZERO, "Invalid entity/instance");
186       return RFAILED;
187    }
188
189    /* check initialization function */
190    if (initFnct == NULLP)
191    {
192       SSLOGERROR(ERRCLS_INT_PAR, ESS351, ERRZERO, "Null pointer");
193       return RFAILED;
194    }
195 #endif
196
197    /* ss021.103 - Modification to store initialization function */
198    /* Acquire the counting semaphore for all other system
199     *  tasks (this call is either running in one system task's
200     *  context, or in SInit()'s context). Once we have all of
201     *  them, SPstTsk() cannot run, so we can do things to the
202     *  TAPA task table.
203     */
204
205    /* ss025.103 - Addition of lock around counting semaphore */
206    /* lock system task table */
207    ret = SLock(&osCp.sTskTblLock);
208    if (ret != ROK)
209    {
210       SSLOGERROR(ERRCLS_DEBUG, ESS352, ERRZERO,
211                      "Could not lock system task table");
212       return RFAILED;
213    }
214
215    SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
216    if (ret != ROK)
217    {
218
219 #if (ERRCLASS & ERRCLS_DEBUG)
220       SSLOGERROR(ERRCLS_DEBUG, ESS353, ERRZERO,
221                  "Could not lock TAPA task table");
222 #endif
223
224       return RFAILED;
225    }
226
227
228 #if (ERRCLASS & ERRCLS_INT_PAR)
229    /* check count of tasks */
230    if (osCp.numTTsks == SS_MAX_TTSKS)
231    {
232       SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
233       SSLOGERROR(ERRCLS_INT_PAR, ESS354, ERRZERO, "Too many tasks");
234
235       /* ss025.103 - Addition of unlock around counting semephore */
236       if ( SUnlock(&osCp.sTskTblLock) != ROK)
237       {
238 #if (ERRCLASS & ERRCLS_DEBUG)
239          SSLOGERROR(ERRCLS_DEBUG, ESS355, ERRZERO,
240                       "Could not give the Semaphore");
241          return RFAILED;
242 #endif
243       }
244
245       return (ROUTRES);
246    }
247
248    /* check if entity and instance already registered */
249    if (osCp.tTskIds[ent][inst] != SS_TSKNC)
250    {
251       SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
252       SSLOGERROR(ERRCLS_INT_PAR, ESS356, ERRZERO,
253                  "Entity and instance already registered");
254
255       /* ss025.103 - Addition of unlock around counting semaphore */
256       if ( SUnlock(&osCp.sTskTblLock) != ROK)
257       {
258 #if (ERRCLASS & ERRCLS_DEBUG)
259          SSLOGERROR(ERRCLS_DEBUG, ESS357, ERRZERO,
260                          "Could not give the Semaphore");
261          return RFAILED;
262 #endif
263       }
264
265       return RFAILED;
266    }
267 #endif
268
269    tTsk = &osCp.tTskTbl[osCp.nxtTTskEntry];
270
271    tTsk->used     = TRUE;
272    tTsk->ent      = ent;
273    tTsk->inst     = inst;
274    tTsk->tskType  = (Ttype)NULLD;
275    tTsk->tskPrior = (Prior)NULLD;
276    tTsk->initTsk  = initFnct;
277    tTsk->actvTsk  = (ActvTsk)NULLP;
278    tTsk->sTsk     = NULLP;
279
280    osCp.tTskIds[ent][inst] = osCp.nxtTTskEntry;
281    osCp.nxtTTskEntry = tTsk->nxt;
282    osCp.numTTsks++;
283
284    /* Activate initialization function, if present. Like
285     *  SRegInit(), we use hard-coded parameters. Note: we
286     *  assume that the initialization function is not
287     *  going to call SRegTTsk() or SPstTsk(). If it does,
288     *  this thread will freeze up as we are holding the
289     *  TAPA task table counting semaphore.
290     */
291    /* ss024.103 - Modification for memory calculator tool */
292 #ifndef USE_MEMCAL
293    (Void)(*initFnct)(ent, inst, DFLT_REGION, PWR_UP);
294 #else
295    (Void)(*initFnct)(ent, inst, SS_STATIC_REGION, PWR_UP);
296 #endif /* USE_MEMCAL */
297
298    /* unlock the table */
299    SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
300
301    /* ss025.103 - Addition of unlock around counting semaphore */
302    if ( SUnlock(&osCp.sTskTblLock) != ROK)
303    {
304 #if (ERRCLASS & ERRCLS_DEBUG)
305       SSLOGERROR(ERRCLS_DEBUG, ESS358, ERRZERO,
306                       "Could not give the Semaphore");
307       return RFAILED;
308 #endif
309    }
310
311    return ROK;
312 } /* SRegInit */
313
314
315 \f
316 /*
317 *
318 *       Fun:   SRegActvTsk
319 *
320 *       Desc:  This function is used to register an activation function
321 *              for the layer. The system services will invoke the
322 *              function passed to it whenever a task buffer is received.
323 *              The activation function will be used by the layer to receive
324 *              messages from other entities.  It allows a priority to be
325 *              associated with the task so that it can be preempted if
326 *              necessary.
327 *
328 *       Ret:   ROK      - ok
329 *              RFAILED  - failed, general (optional)
330 *              ROUTRES  - failed, out of resources (optional)
331 *
332 *       Notes: We pass NULLP for the initialization function, because
333 *              it is assumed that whoever is using this call will also
334 *              be calling SRegInit().
335 *
336 *       File:  ss_task.c
337 *
338 */
339 S16 SRegActvTsk
340 (
341 Ent ent,                       /* entity */
342 Inst inst,                     /* instance */
343 Ttype ttype,                   /* task type */
344 Prior prior,                   /* task priority */
345 ActvTsk actvTsk                /* activate task function */
346 )
347 {
348    S16 ret;
349    SSTskId sTskId;
350    Prior spri;
351    /* ss021.103 - Addition for pointer */
352    SsTTskEntry *tTsk;
353
354
355
356 #if (ERRCLASS & ERRCLS_INT_PAR)
357    /* check entity and instance ranges */
358    if (ent >= SS_MAX_ENT ||  inst >= SS_MAX_INST)
359    {
360       SSLOGERROR(ERRCLS_INT_PAR, ESS359, ERRZERO, "Invalid entity/instance");
361       return RFAILED;
362    }
363
364    /* check activation function */
365    if (actvTsk == NULLP)
366    {
367       SSLOGERROR(ERRCLS_INT_PAR, ESS360, ERRZERO, "Null pointer");
368       return RFAILED;
369    }
370
371    /* check task type */
372    if (ttype != TTNORM  &&  ttype != TTPERM)
373    {
374       SSLOGERROR(ERRCLS_INT_PAR, ESS361, ERRZERO, "Invalid task type");
375       /* ss021.103 - Addition of return fail for invalid task type */
376       return RFAILED;
377    }
378
379    /* check task priority */
380    if (prior > PRIOR3)
381    {
382       SSLOGERROR(ERRCLS_INT_PAR, ESS362, ERRZERO, "Invalid task priority");
383       return RFAILED;
384    }
385 #endif
386
387    /* lock system task table */
388    ret = SLock(&osCp.sTskTblLock);
389    if (ret != ROK)
390    {
391       SSLOGERROR(ERRCLS_DEBUG, ESS363, ERRZERO,
392                      "Could not lock system task table");
393       return RFAILED;
394    }
395
396    /* lock TAPA task table */
397    SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
398    if (ret != ROK)
399    {
400       if ( SUnlock(&osCp.sTskTblLock) != ROK)
401       {
402 #if (ERRCLASS & ERRCLS_DEBUG)
403          SSLOGERROR(ERRCLS_DEBUG, ESS364, ERRZERO,
404                          "Could not give the Semaphore");
405          return RFAILED;
406 #endif
407       }
408  
409       SSLOGERROR(ERRCLS_DEBUG, ESS365, ERRZERO,
410                      "Could not lock TAPA task table");
411       return RFAILED;
412    }
413    /* ss021.103 - Modification for SRegInit not called yet */
414    /* check if entity and instance already registered */
415    if (osCp.tTskIds[ent][inst] == SS_TSKNC)
416    {
417
418 #if (ERRCLASS & ERRCLS_INT_PAR)
419       /* check count of tasks */
420       if (osCp.numTTsks == SS_MAX_TTSKS)
421       {
422          SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
423
424          /* ss025.103 - Addition of unlock around counting semaphore */
425          if ( SUnlock(&osCp.sTskTblLock) != ROK)
426          {
427 #if (ERRCLASS & ERRCLS_DEBUG)
428             SSLOGERROR(ERRCLS_DEBUG, ESS366, ERRZERO,
429                          "Could not give the Semaphore");
430             return RFAILED;
431 #endif
432          }
433          SSLOGERROR(ERRCLS_INT_PAR, ESS367, ERRZERO, "Too many tasks");
434          return (ROUTRES);
435       }
436 #endif
437
438       tTsk = &osCp.tTskTbl[osCp.nxtTTskEntry];
439       tTsk->used     = TRUE;
440       tTsk->ent      = ent;
441       tTsk->inst     = inst;
442       tTsk->initTsk  = (PAIFS16)NULLP;
443       tTsk->actvTsk  = (ActvTsk)NULLP;
444       tTsk->sTsk     = NULLP;
445
446       osCp.tTskIds[ent][inst] = osCp.nxtTTskEntry;
447       osCp.nxtTTskEntry = tTsk->nxt;
448       osCp.numTTsks++;
449    }
450
451
452    /* check and bump the priority if it is a permanent task */
453    if(ttype == TTPERM)
454    {
455       prior = PRIOR3;
456    }
457
458    /* ss021.103 - Modification to register task information */
459    /*  We fill up the current available slot with all the
460     *  information we've been given. Update table information,
461     *  and the task is registered.
462     */
463
464    tTsk = &osCp.tTskTbl[osCp.tTskIds[ent][inst]];
465    
466 #if (ERRCLASS & ERRCLS_INT_PAR)
467    if (tTsk->actvTsk != (ActvTsk)NULLP)
468    {
469       SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
470
471       if ( SUnlock(&osCp.sTskTblLock) != ROK)
472       {
473 #if (ERRCLASS & ERRCLS_DEBUG)
474          SSLOGERROR(ERRCLS_DEBUG, ESS368, ERRZERO,
475                     "Could not give the Semaphore");
476          return RFAILED;
477 #endif
478       }
479
480       SSLOGERROR(ERRCLS_INT_PAR, ESS369, ERRZERO, 
481                  "ActvTask already registered");
482       return RFAILED;
483    }
484 #endif
485
486    tTsk->tskType  = ttype;
487    tTsk->tskPrior = prior;
488    tTsk->actvTsk  = actvTsk;
489
490    /* unlock the table */
491    SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
492
493    if ( SUnlock(&osCp.sTskTblLock) != ROK)
494    {
495 #if (ERRCLASS & ERRCLS_DEBUG)
496       SSLOGERROR(ERRCLS_DEBUG, ESS370, ERRZERO,
497                       "Could not give the Semaphore");
498       return RFAILED;
499 #endif
500    }
501
502    /*  Now we create a system task--one per TAPA task is the
503     *  semantics of SRegActvTsk().
504     */
505    if (ttype == TTNORM)
506       spri = SS_NORM_TSK_PRI;
507    else
508       spri = SS_PERM_TSK_PRI;
509
510    ret = SCreateSTsk(spri, &sTskId);
511    if (ret != ROK)
512    {
513
514 #if (ERRCLASS & ERRCLS_DEBUG)
515       SSLOGERROR(ERRCLS_DEBUG, ESS371, (ErrVal) ret,
516                      "Could not create system task");
517 #endif
518
519       SDeregTTsk(ent, inst);
520       return (ret);
521    }
522
523
524    /*  Attach the TAPA task we just registered, to the system
525     *  task we just created.
526     */
527    ret = SAttachTTsk(ent, inst, sTskId);
528    if (ret != ROK)
529    {
530
531 #if (ERRCLASS & ERRCLS_DEBUG)
532       SSLOGERROR(ERRCLS_DEBUG, ESS372, (ErrVal) ret,
533                      "Could not attach TAPA task to system task");
534 #endif
535       SDestroySTsk(sTskId);
536       SDeregTTsk(ent, inst);
537    }
538
539
540    return (ret);
541
542 } /* SRegActvTsk */
543  
544 \f
545 /*
546 *
547 *       Fun:   Deregister Initialize, task buffer and timer
548 *
549 *       Desc:  This function is used to deregister the initialization,
550 *              activation and timer functions for a task.
551 *
552 *       Ret:   ROK      - ok
553 *
554 *       Notes: None.
555 *
556 *       File:  ss_task.c
557 *
558 */
559 S16 SDeregInitTskTmr
560 (
561 Ent ent,                       /* entity */
562 Inst inst                      /* instance */
563 )
564 {
565    SsTTskEntry *tTsk;
566    SsSTskEntry *sTsk;
567    S16         ret;
568    SSTskId     sTskId;
569    SsIdx       idx;
570    Bool        destroySTsk;
571
572
573
574
575 #if (ERRCLASS & ERRCLS_INT_PAR)
576    /* check entity and instance ranges */
577    if (ent >= SS_MAX_ENT  ||  inst >= SS_MAX_INST)
578    {
579       SSLOGERROR(ERRCLS_INT_PAR, ESS373, ERRZERO, "Invalid entity/instance");
580       return RFAILED;
581    }
582 #endif
583
584    /* ss025.103 - Addition of lock around counting semaphore */
585    /* lock system task table */
586    ret = SLock(&osCp.sTskTblLock);
587    if (ret != ROK)
588    {
589       SSLOGERROR(ERRCLS_DEBUG, ESS374, ERRZERO,
590                      "Could not lock system task table");
591       return RFAILED;
592    }
593
594    /* lock the TAPA task table */
595    SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
596    if (ret != ROK)
597    {
598
599 #if (ERRCLASS & ERRCLS_DEBUG)
600       SSLOGERROR(ERRCLS_DEBUG, ESS375, ERRZERO,
601                      "Could not lock TAPA task table");
602 #endif
603
604       return RFAILED;
605    }
606
607
608 #if (ERRCLASS & ERRCLS_INT_PAR)
609    /* check whether this entity is registered */
610    if (osCp.tTskIds[ent][inst] == SS_TSKNC)
611    {
612       SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
613       SSLOGERROR(ERRCLS_INT_PAR, ESS376, ERRZERO, "Unknown task");
614
615       /* ss025.103 - Addition of unlock around counting semaphore */
616       if ( SUnlock(&osCp.sTskTblLock) != ROK)
617       {
618 #if (ERRCLASS & ERRCLS_DEBUG)
619          SSLOGERROR(ERRCLS_DEBUG, ESS377, ERRZERO,
620                          "Could not give the Semaphore");
621          return RFAILED;
622 #endif
623       }
624
625       return RFAILED;
626    }
627 #endif
628
629
630    /* get out the TAPA task entry */
631    tTsk = &osCp.tTskTbl[osCp.tTskIds[ent][inst]];
632
633    /* get out the system task that's running this TAPA task */
634    sTsk = tTsk->sTsk;
635
636    /* get out the ID of this system task */
637    if (sTsk != NULLP)
638    {
639       sTskId = sTsk->tskId;
640    }
641    else 
642       sTskId = 0;
643
644    /* unlock the TAPA task table */
645    SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
646
647    /* ss025.103 - Addition of unlock around counting semaphore */
648    if ( SUnlock(&osCp.sTskTblLock) != ROK)
649    {
650 #if (ERRCLASS & ERRCLS_DEBUG)
651       SSLOGERROR(ERRCLS_DEBUG, ESS378, ERRZERO,
652                       "Could not give the Semaphore");
653       return RFAILED;
654 #endif
655    }
656
657
658    /* deregister the TAPA task */
659    if (SDeregTTsk(ent, inst) != ROK)
660    {
661       return RFAILED;
662    }
663
664
665    /* Now, if the TAPA task was attached, and nobody else is using that
666     *  system task, we should destroy it.
667     */
668    if (sTsk != NULLP)
669    {
670       destroySTsk = FALSE;
671
672       /* lock the system task table */
673       ret = SLock(&osCp.sTskTblLock);
674       if (ret != ROK)
675       {
676
677 #if (ERRCLASS & ERRCLS_DEBUG)
678          SSLOGERROR(ERRCLS_DEBUG, ESS379, (ErrVal) ret,
679                         "Could not lock system task table");
680 #endif
681
682          return RFAILED;
683       }
684
685       idx = (SsIdx) sTskId;
686       sTsk = &osCp.sTskTbl[idx];
687
688       /* check if the system task is still around */
689       if (sTsk->used != TRUE)
690       {
691
692 /* ss006.13: addition */
693          if ( SUnlock(&osCp.sTskTblLock) != ROK)
694          {
695 #if (ERRCLASS & ERRCLS_DEBUG)
696             SSLOGERROR(ERRCLS_DEBUG, ESS380, ERRZERO,
697                          "Could not give the Semaphore");
698             return RFAILED;
699 #endif
700          }
701
702          return ROK;
703       }
704
705       /* check if the system task is dying already */
706       if (sTsk->termPend)
707       {
708
709   /* ss006.13: addition */
710          if ( SUnlock(&osCp.sTskTblLock) != ROK)
711          {
712 #if (ERRCLASS & ERRCLS_DEBUG)
713             SSLOGERROR(ERRCLS_DEBUG, ESS381, ERRZERO,
714                          "Could not give the Semaphore");
715             return RFAILED;
716 #endif
717          }
718          return ROK;
719       }
720
721
722       /* If this system task entry has no more TAPA tasks attached,
723        *  we destroy it, otherwise we do nothing.
724        */
725       if (sTsk->numTTsks == 0)
726       {
727          sTsk->termPend = TRUE;
728          destroySTsk = TRUE;
729       }
730
731
732       /* unlock */
733
734   /* ss006.13: addition */
735       if ( SUnlock(&osCp.sTskTblLock) != ROK)
736       {
737 #if (ERRCLASS & ERRCLS_DEBUG)
738           SSLOGERROR(ERRCLS_DEBUG, ESS382, ERRZERO,
739                       "Could not give the Semaphore");
740           return RFAILED;
741 #endif
742       }
743
744       /* If we're destroying the system task, ask the implementation
745        *  to do it.
746        */
747       if (destroySTsk)
748       {
749          ret = ssdDestroySTsk(sTsk);
750          if (ret != ROK)
751          {
752             /* oops? */
753
754 #if (ERRCLASS & ERRCLS_DEBUG)
755             SSLOGERROR(ERRCLS_DEBUG, ESS383, (ErrVal) ret,
756                         "Could not destroy system task");
757 #endif
758
759             return RFAILED;
760          }
761       }
762    }
763
764
765    return ROK;
766 } /* SDeregInitTskTmr */
767
768 #endif /* SS_MULTIPLE_PROCS */
769
770 \f
771 /*
772 *
773 *       Fun:   Register a TAPA task
774 *
775 *       Desc:  This function is used to register a TAPA task,
776 *              and its initialization and activation functions.
777 *
778 *       Ret:   ROK      - ok
779 *              RFAILED  - failed, general (optional)
780 *              ROUTRES  - failed, out of resources (optional)
781 *
782 *       Notes:
783 *
784 *       File:  ss_task.c
785 *
786 */
787 /* ss029.103: modification: procId added */ 
788 #ifndef SS_MULTIPLE_PROCS
789
790 S16 SRegTTsk
791 (
792 Ent ent,                        /* entity */
793 Inst inst,                      /* instance */
794 Ttype type,                     /* task type */
795 Prior prior,                    /* task priority */
796 PAIFS16 initTsk,                /* initialization function */
797 ActvTsk actvTsk                 /* activation function */
798 )
799 #else /* SS_MULTIPLE_PROCS */
800
801 S16 SRegTTsk
802 (
803 ProcId proc,                    /* processor */
804 Ent ent,                        /* entity */
805 Inst inst,                      /* instance */
806 Ttype type,                     /* task type */
807 Prior prior,                    /* task priority */
808 PAIFS16 initTsk,                /* initialization function */
809 ActvTsk actvTsk                 /* activation function */
810 )
811 #endif /* SS_MULTIPLE_PROCS */
812
813 {
814    S16 ret = ROK;
815    SsTTskEntry *tTsk;
816 /* ss029.103: addition: multiple procIds related changes */ 
817 #ifdef SS_MULTIPLE_PROCS
818    uint16_t procIdIdx;
819 #endif
820
821
822
823 #if (ERRCLASS & ERRCLS_INT_PAR)
824
825    /* check entity and instance ranges */
826 /* ss029.103: addition: multiple procIds related changes */ 
827 #ifdef SS_MULTIPLE_PROCS
828    if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) ||  (inst >= SS_MAX_INST))
829    {
830       SSLOGERROR(ERRCLS_INT_PAR, ESS384, ERRZERO, "Invalid proc/entity/instance");
831       return RFAILED;
832    }
833 #else /* SS_MULTIPLE_PROCS */
834    if (ent >= SS_MAX_ENT ||  inst >= SS_MAX_INST)
835    {
836       SSLOGERROR(ERRCLS_INT_PAR, ESS385, ERRZERO, "Invalid entity/instance");
837       return RFAILED;
838    }
839 #endif /* SS_MULTIPLE_PROCS */
840
841    /* check activation function */
842    if (actvTsk == NULLP)
843    {
844       SSLOGERROR(ERRCLS_INT_PAR, ESS386, ERRZERO, "Null pointer");
845       return RFAILED;
846    }
847
848    /* check task type */
849    if (type != TTNORM  &&  type != TTPERM)
850    {
851       SSLOGERROR(ERRCLS_INT_PAR, ESS387, ERRZERO, "Invalid task type");
852       /* ss021.103 - Addition of return fail for invalid task type */
853       return RFAILED;
854    }
855
856    /* check task priority */
857    if (prior > PRIOR3)
858    {
859       SSLOGERROR(ERRCLS_INT_PAR, ESS388, ERRZERO, "Invalid task priority");
860       return RFAILED;
861    }
862 #endif
863
864 /* ss029.103: addition: multiple procIds related changes */ 
865 #ifdef SS_MULTIPLE_PROCS
866    /* retrieve proc id index in the proc id table */
867    procIdIdx = SGetProcIdIdx(proc); 
868
869    /* Check whether the proc id exist in the proc id table */
870    if (procIdIdx == SS_INV_PROCID_IDX)
871    {
872 #if (ERRCLASS & ERRCLS_INT_PAR)
873        SSLOGERROR(ERRCLS_INT_PAR, ESS389, ERRZERO,
874                      "Could not find proc table index");
875 #endif
876
877       return RFAILED;
878    }
879 #endif /* SS_MULTIPLE_PROCS */
880
881
882
883    /* Acquire the counting semaphore for all other system
884     *  tasks (this call is either running in one system task's
885     *  context, or in SInit()'s context). Once we have all of
886     *  them, SPstTsk() cannot run, so we can do things to the
887     *  TAPA task table.
888     */
889
890    /* ss025.103 - Addition of lock around counting semaphore */
891    /* lock system task table */
892    ret = SLock(&osCp.sTskTblLock);
893    if (ret != ROK)
894    {
895       SSLOGERROR(ERRCLS_DEBUG, ESS390, ERRZERO,
896                      "Could not lock system task table");
897       return RFAILED;
898    }
899
900    SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
901    if (ret != ROK)
902    {
903
904 #if (ERRCLASS & ERRCLS_DEBUG)
905       SSLOGERROR(ERRCLS_DEBUG, ESS391, ERRZERO,
906                      "Could not lock TAPA task table");
907 #endif
908
909       /* ss025.103 - Addition of unlock around counting semaphore */
910       if ( SUnlock(&osCp.sTskTblLock) != ROK)
911       {
912 #if (ERRCLASS & ERRCLS_DEBUG)
913          SSLOGERROR(ERRCLS_DEBUG, ESS392, ERRZERO,
914                       "Could not give the Semaphore");
915          return RFAILED;
916 #endif
917       }
918
919       return RFAILED;
920    }
921
922
923 #if (ERRCLASS & ERRCLS_DEBUG)
924    /* check count of tasks */
925    if (osCp.numTTsks == SS_MAX_TTSKS)
926    {
927       SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
928       SSLOGERROR(ERRCLS_DEBUG, ESS393, ERRZERO, "Too many tasks");
929
930       /* ss025.103 - Addition of unlock around counting semaphore */
931       if ( SUnlock(&osCp.sTskTblLock) != ROK)
932       {
933 #if (ERRCLASS & ERRCLS_DEBUG)
934          SSLOGERROR(ERRCLS_DEBUG, ESS394, ERRZERO,
935                       "Could not give the Semaphore");
936          return RFAILED;
937 #endif
938       }
939
940       return (ROUTRES);
941    }
942
943    /* check if entity and instance already registered */
944 /* ss029.103: addition: multiple procIds related changes */ 
945 #ifdef SS_MULTIPLE_PROCS
946    if (osCp.tTskIds[procIdIdx][ent][inst] != SS_TSKNC)
947 #else
948    if (osCp.tTskIds[ent][inst] != SS_TSKNC)
949 #endif /* SS_MULTIPLE_PROCS */
950    {
951       SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
952       SSLOGERROR(ERRCLS_DEBUG, ESS395, ERRZERO,
953                   "Entity and instance already registered");
954
955       /* ss025.103 - Addition of unlock around counting semaphore */
956       if ( SUnlock(&osCp.sTskTblLock) != ROK)
957       {
958 #if (ERRCLASS & ERRCLS_DEBUG)
959          SSLOGERROR(ERRCLS_DEBUG, ESS396, ERRZERO,
960                       "Could not give the Semaphore");
961          return RFAILED;
962 #endif
963       }
964
965       return RFAILED;
966    }
967 #endif
968
969
970    /*  We fill up the current available slot with all the
971     *  information we've been given. Update table information,
972     *  and the task is registered.
973     */
974    tTsk = &osCp.tTskTbl[osCp.nxtTTskEntry];
975    tTsk->used     = TRUE;
976 /* ss029.103: addition: procId added */ 
977 #ifdef SS_MULTIPLE_PROCS
978    tTsk->proc     = proc;
979 #endif /* SS_MULTIPLE_PROCS */
980    tTsk->ent      = ent;
981    tTsk->inst     = inst;
982    tTsk->tskType  = type;
983    tTsk->tskPrior = prior;
984    tTsk->initTsk  = initTsk;
985    tTsk->actvTsk  = actvTsk;
986    tTsk->sTsk     = NULLP;
987
988 /* ss001.301: additions */
989 #ifdef SS_HISTOGRAM_SUPPORT 
990    tTsk->hstReg   = 0;
991 #endif /* SS_HISTOGRAM_SUPPORT */
992
993 /* ss029.103: addition: multiple procIds related changes */ 
994 #ifdef SS_MULTIPLE_PROCS
995    osCp.tTskIds[procIdIdx][ent][inst] = osCp.nxtTTskEntry;
996 #else
997    osCp.tTskIds[ent][inst] = osCp.nxtTTskEntry;
998 #endif /* SS_MULTIPLE_PROCS */
999    osCp.nxtTTskEntry = tTsk->nxt;
1000    osCp.numTTsks++;
1001
1002
1003    /* Activate initialization function, if present. Like
1004     *  SRegInit(), we use hard-coded parameters. Note: we
1005     *  assume that the initialization function is not
1006     *  going to call SRegTTsk() or SPstTsk(). If it does,
1007     *  this thread will freeze up as we are holding the
1008     *  TAPA task table counting semaphore.
1009     */
1010    /* ss024.103 - Modification for memory calculator tool */
1011    if (initTsk != NULLP)
1012    {
1013 /* ss029.103: addition: multiple procIds related changes */ 
1014 #ifdef SS_MULTIPLE_PROCS
1015       SsIdx idx;
1016       Void *xxCb = NULLP;
1017 #endif /* SS_MULTIPLE_PROCS */
1018
1019 /* ss029.103: addition: multiple procIds related changes */ 
1020 #ifndef SS_MULTIPLE_PROCS
1021
1022 #ifndef USE_MEMCAL
1023 #ifndef SS_MULTICORE_SUPPORT
1024       (Void)(*initTsk)(ent, inst, DFLT_REGION, PWR_UP);
1025 #endif
1026 #else
1027       (Void)(*initTsk)(ent, inst, SS_STATIC_REGION, PWR_UP);
1028 #endif /* USE_MEMCAL */
1029
1030 #else /* SS_MULTIPLE_PROCS */
1031
1032 #ifndef USE_MEMCAL
1033 #ifndef SS_MULTICORE_SUPPORT
1034       (Void)(*initTsk)(proc, ent, inst, DFLT_REGION, PWR_UP, &xxCb);
1035 #endif /* SS_MULTICORE_SUPPORT */
1036 #else
1037       (Void)(*initTsk)(proc, ent, inst, SS_STATIC_REGION, PWR_UP, &xxCb);
1038 #endif /* USE_MEMCAL */
1039
1040       /*
1041        * store the control block. The control block may be NULL in some cases
1042        */
1043       idx = osCp.tTskIds[procIdIdx][ent][inst]; 
1044
1045       osCp.tTskTbl[idx].xxCb = xxCb;
1046
1047       /* ss032.103 do a debug print if xxCb is NULLP */
1048       if (xxCb == NULLP)
1049       {
1050          SSLOGERROR(ERRCLS_INT_PAR, ERRZERO, ERRZERO, "Null pointer");
1051       }
1052 #endif /* SS_MULTIPLE_PROCS */
1053    }
1054
1055    /* unlock the table */
1056    SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1057
1058    /* ss025.103 - Addition of unlock around counting semaphore */
1059    if ( SUnlock(&osCp.sTskTblLock) != ROK)
1060    {
1061 #if (ERRCLASS & ERRCLS_DEBUG)
1062       SSLOGERROR(ERRCLS_DEBUG, ESS397, ERRZERO,
1063                       "Could not give the Semaphore");
1064 #endif
1065       return RFAILED;
1066    }
1067
1068    return ROK;
1069 } /* SRegTTsk */
1070  /* ss002.301 Additions */
1071 /*
1072 *
1073 *       Fun:   Register a call back function with SSI
1074 *
1075 *       Desc:  This function is used to register a callback function
1076 *              
1077 *
1078 *       Ret:   ROK      - ok
1079 *              RFAILED  - failed, general (optional)
1080 *
1081 *       Notes:
1082 *
1083 *       File:  sm_task.c
1084 *
1085 **/
1086 #ifndef SS_MULTIPLE_PROCS
1087 S16 SRegCbTsk
1088 (
1089 Ent ent,                        /* entity */
1090 Inst inst,                      /* instance */
1091 ActvTsk cbTsk                   /* Callback Function */
1092 )
1093 #else /* SS_MULTIPLE_PROCS */
1094
1095 S16 SRegCbTsk 
1096 (
1097 ProcId proc,                    /* processor */
1098 Ent ent,                        /* entity */
1099 Inst inst,                       /* instance */
1100 ActvTsk cbTsk 
1101 )
1102 #endif /* SS_MULTIPLE_PROCS */
1103 {
1104    SsTTskEntry *tTsk;
1105    SsIdx idx;
1106         S16   ret = ROK;
1107 #ifdef SS_MULTIPLE_PROCS
1108    uint16_t procIdIdx;
1109 #endif /* SS_MULTIPLE_PROCS */
1110
1111
1112 #if (ERRCLASS & ERRCLS_INT_PAR)
1113    if (ent >= SS_MAX_ENT ||  inst >= SS_MAX_INST)
1114    {
1115       SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SRegCbTsk() : Invalid entity/instance");
1116       return RFAILED;
1117    }
1118
1119    if (cbTsk == NULLP)
1120    {
1121       SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, " SRegCbTsk() : Null pointer");
1122       return RFAILED;
1123    }
1124 #endif
1125
1126 #ifdef SS_MULTIPLE_PROCS
1127    /* retrieve proc id index in the proc id table */
1128    procIdIdx = SGetProcIdIdx(proc); 
1129
1130    /* Check whether the proc id exist in the proc id table */
1131    if (procIdIdx == SS_INV_PROCID_IDX)
1132    {
1133 #if (ERRCLASS & ERRCLS_INT_PAR)
1134        SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO,
1135                      " SRegCbTsk() : Could not find proc table index");
1136 #endif
1137
1138       return RFAILED;
1139    }
1140 #endif /* SS_MULTIPLE_PROCS */
1141
1142    SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
1143    if (ret != ROK)
1144    {
1145
1146 #if (ERRCLASS & ERRCLS_DEBUG)
1147       SSLOGERROR(ERRCLS_DEBUG, ESSXXX, ERRZERO,
1148                      "SRegCbTsk() : Could not lock TAPA task table");
1149 #endif
1150       return RFAILED;
1151    }
1152
1153 #ifdef SS_MULTIPLE_PROCS
1154    idx = osCp.tTskIds[procIdIdx][ent][inst];
1155 #else /* SS_MULTIPLE_PROCS */
1156    idx = osCp.tTskIds[ent][inst];
1157 #endif /* SS_MULTIPLE_PROCS */
1158
1159 #if (ERRCLASS & ERRCLS_INT_PAR)
1160    if (idx == SS_TSKNC)
1161    {
1162       SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1163       SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SRegCbTsk() : Unknown task");
1164       return RFAILED;
1165    }
1166 #endif
1167    tTsk = &osCp.tTskTbl[idx];
1168    tTsk->cbTsk  = cbTsk;
1169
1170    /* unlock the table */
1171    SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1172    return ROK;
1173 }
1174
1175 \f
1176 /*
1177 *
1178 *       Fun:   Deregister TAPA task
1179 *
1180 *       Desc:  This function is used to deregister a TAPA task.
1181 *              All information about the task is removed from the
1182 *              task table.
1183 *
1184 *       Ret:   ROK      - ok
1185 *              RFAILED  - failed, general (optional)
1186 *
1187 *       Notes:
1188 *
1189 *       File:  ss_task.c
1190 *
1191 */
1192 /* ss029.103: addition: procId added */ 
1193 #ifndef SS_MULTIPLE_PROCS
1194
1195 S16 SDeregTTsk
1196 (
1197 Ent ent,                        /* entity */
1198 Inst inst                       /* instance */
1199 )
1200 #else /* SS_MULTIPLE_PROCS */
1201
1202 S16 SDeregTTsk
1203 (
1204 ProcId proc,                    /* processor */
1205 Ent ent,                        /* entity */
1206 Inst inst                       /* instance */
1207 )
1208 #endif /* SS_MULTIPLE_PROCS */
1209 {
1210    S16          ret;
1211    /* ss029.103: modification: The subscript should be consistent type */
1212    SsIdx        idx;
1213    SsTTskEntry *tTsk;
1214    SsTmrEntry  *tmr;
1215 /* ss029.103: addition: multiple procIds related changes */ 
1216 #ifdef SS_MULTIPLE_PROCS
1217    uint16_t procIdIdx;
1218 #endif /* SS_MULTIPLE_PROCS */
1219  /* ss002.301 Additions */
1220    Buffer *mBuf;
1221    SsMsgInfo *mInfo;
1222
1223
1224
1225 #if (ERRCLASS & ERRCLS_INT_PAR)
1226    /* check entity and instance ranges */
1227 /* ss029.103: addition: multiple procIds related changes */ 
1228 #ifdef SS_MULTIPLE_PROCS
1229    if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) ||  (inst >= SS_MAX_INST))
1230    {
1231       SSLOGERROR(ERRCLS_INT_PAR, ESS398, ERRZERO, "Invalid processor/entity/instance");
1232       return RFAILED;
1233    }
1234 #else /* SS_MULTIPLE_PROCS */
1235    if (ent >= SS_MAX_ENT ||  inst >= SS_MAX_INST)
1236    {
1237       SSLOGERROR(ERRCLS_INT_PAR, ESS399, ERRZERO, "Invalid entity/instance");
1238       return RFAILED;
1239    }
1240 #endif /* SS_MULTIPLE_PROCS */
1241
1242 #endif
1243
1244 /* ss029.103: addition: multiple procIds related changes */ 
1245 #ifdef SS_MULTIPLE_PROCS
1246    /* Find the proc table index */
1247    procIdIdx = SGetProcIdIdx(proc);
1248
1249    if (procIdIdx == SS_INV_PROCID)
1250    {
1251 #if (ERRCLASS & ERRCLS_DEBUG)
1252       SSLOGERROR(ERRCLS_DEBUG, ESS400, ERRZERO,
1253                              "Could not find proc id index");
1254 #endif
1255       return RFAILED;
1256    }
1257 #endif /* SS_MULTIPLE_PROCS */
1258
1259    /* We deregister all timers for this TAPA task, since it's going
1260     *  away now. Lock the timer table and iterate through it, removing
1261     *  all timers owned by this task.
1262     */
1263    if (SLock(&osCp.tmrTblLock) != ROK)
1264    {
1265 #if (ERRCLASS & ERRCLS_DEBUG)
1266       SSLOGERROR(ERRCLS_DEBUG, ESS401, ERRZERO,
1267                              "Could not lock timer table");
1268 #endif
1269       return RFAILED;
1270    }
1271
1272    for (idx = 0;  idx < SS_MAX_TMRS;  idx++)
1273    {
1274 /* ss029.103: addition: multiple procIds related changes */ 
1275 #ifdef SS_MULTIPLE_PROCS
1276       if ((osCp.tmrTbl[idx].ownerProc == proc) &&  
1277           (osCp.tmrTbl[idx].ownerEnt == ent) &&  
1278           (osCp.tmrTbl[idx].ownerInst == inst))
1279 #else /* SS_MULTIPLE_PROCS */
1280       if ((osCp.tmrTbl[idx].ownerEnt == ent) &&  
1281           (osCp.tmrTbl[idx].ownerInst == inst))
1282 #endif /* SS_MULTIPLE_PROCS */
1283       {
1284          /* shut down this timer */
1285          tmr = &osCp.tmrTbl[idx];
1286          if (ssdDeregTmr(tmr) == ROK)
1287          {
1288             tmr->used      = FALSE;
1289             tmr->tmrId     = 0;
1290 /* ss029.103: addition: multiple procIds related changes */ 
1291 #ifdef SS_MULTIPLE_PROCS
1292             tmr->ownerProc  = PROCNC;
1293             /*
1294              *  ss015.301 - Modifed in initialization as timer activation 
1295              *  functions enclosed in a union. Also initialized the mtFlag
1296              *  to FALSE 
1297              */
1298 #endif /* SS_MULTIPLE_PROCS */
1299             tmr->ownerEnt  = ENTNC;
1300             tmr->ownerInst = INSTNC;
1301             tmr->interval  = 0;
1302             tmr->ssTmrActvFn.actvFnc.tmrActvFn = NULLP;
1303 #ifndef SS_MULTIPLE_PROCS
1304 #ifdef SS_MT_TMR 
1305             tmr->ssTmrActvFn.mtFlag = FALSE; 
1306             tmr->ssTmrActvFn.actvFnc.tmrActvFnMt = NULLP;
1307 #endif
1308 #endif
1309             tmr->nxt = osCp.nxtTmrEntry;
1310             osCp.nxtTmrEntry = (SsIdx)idx;
1311             osCp.numTmrs--;
1312          }
1313          else
1314          {
1315
1316   /* ss006.13: addition */
1317           if ( SUnlock(&osCp.tmrTblLock) != ROK)
1318           {
1319 #if (ERRCLASS & ERRCLS_DEBUG)
1320              SSLOGERROR(ERRCLS_DEBUG, ESS402, ERRZERO,
1321                       "Could not give the Semaphore");
1322              return RFAILED;
1323 #endif
1324           }
1325
1326 #if (ERRCLASS & ERRCLS_DEBUG)
1327             SSLOGERROR(ERRCLS_DEBUG, ESS403, ERRZERO,
1328                         "Could not deregister task's timer(s)");
1329 #endif
1330             return RFAILED;
1331
1332          }
1333       }
1334    }
1335
1336
1337   /* ss006.13: addition */
1338           if ( SUnlock(&osCp.tmrTblLock) != ROK)
1339           {
1340 #if (ERRCLASS & ERRCLS_DEBUG)
1341              SSLOGERROR(ERRCLS_DEBUG, ESS404, ERRZERO,
1342                       "Could not give the Semaphore");
1343              return RFAILED;
1344 #endif
1345           }
1346  /* ss002.301 Additions */
1347    /* Acquire the counting semaphore for all TAPA tasks. Once
1348     *  we have all of them, both SPstTsk() and SRegTTsk() cannot
1349     *  run, so we can do things to the TAPA task table.
1350     */
1351    SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
1352    if (ret != ROK)
1353    {
1354  /* ss002.301 Additions */
1355
1356 #if (ERRCLASS & ERRCLS_DEBUG)
1357       SSLOGERROR(ERRCLS_DEBUG, ESS411, ERRZERO,
1358                      "Could not lock TAPA task table");
1359 #endif
1360
1361       return RFAILED;
1362    }
1363
1364
1365    /* get out the TAPA task entry */
1366 /* ss029.103: addition: multiple procIds related changes */ 
1367 #ifdef SS_MULTIPLE_PROCS
1368    idx = osCp.tTskIds[procIdIdx][ent][inst];
1369 #else /* SS_MULTIPLE_PROCS */
1370    idx = osCp.tTskIds[ent][inst];
1371 #endif /* SS_MULTIPLE_PROCS */
1372
1373
1374    /* make sure this TAPA task exists */
1375    if (idx == SS_TSKNC)
1376    {
1377       SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1378
1379       SSLOGERROR(ERRCLS_INT_PAR, ESS412, ERRZERO, "Unknown task");
1380  /* ss002.301 Additions */
1381       return RFAILED;
1382    }
1383
1384    tTsk = &osCp.tTskTbl[idx];
1385
1386    /* unlock the TAPA task table */
1387    SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1388
1389    /*Check whether the thread calling this funtion is the same as the system task to which the 
1390      TAPA task detremined by passed entity and instance is attached*/
1391    /* 100178 */
1392    
1393 /*ss014.301 SSI-4GMX specific changes*/   
1394 #ifndef SS_4GMX_LCORE
1395    if((tTsk->sTsk == NULLP) || (SS_CHECK_CUR_STSK(tTsk->sTsk)))
1396    { 
1397 #ifdef SS_MULTIPLE_PROCS
1398       ssdProcTTskTerm(procIdIdx, tTsk, idx);
1399 #else
1400       ssdProcTTskTerm(tTsk, idx);
1401 #endif
1402
1403    }
1404    else
1405    {
1406         /*Allocate memory*/
1407         if (SGetMsg(SS_DFLT_REGION, SS_DFLT_POOL, &mBuf) != ROK)
1408         {
1409
1410 #if (ERRCLASS & ERRCLASS_DEBUG)
1411         SSLOGERROR(ERRCLS_DEBUG, ESS415, ERRZERO, "Could not get a message");
1412 #endif
1413
1414         return RFAILED;
1415         }
1416
1417         /* Update message*/
1418         mInfo = (SsMsgInfo *)mBuf->b_rptr;
1419         mInfo->eventInfo.event = SS_EVNT_TTSK_TERM;
1420
1421         mInfo->pst.dstEnt = ent;
1422         mInfo->pst.dstInst = inst;
1423
1424         /* we dont care who is calling SDeregTTsk()
1425         so we dont fill srcEnt and dstInst in mInfo->pst */
1426  
1427         /* mt028.201: modification: multiple procs support related changes */
1428         /* source proc id is not needed so we dont fill it */
1429 #ifndef SS_MULTIPLE_PROCS
1430         mInfo->pst.dstProcId = SFndProcId();
1431 #else /* SS_MULTIPLE_PROCS */
1432         mInfo->pst.dstProcId = proc;
1433 #endif /* SS_MULTIPLE_PROCS */
1434  /* ss002.301 Additions */
1435         mInfo->pst.selector = SEL_LC_NEW;
1436         mInfo->pst.region = DFLT_REGION;
1437         mInfo->pst.pool = DFLT_POOL;
1438         mInfo->pst.prior = PRIOR0;
1439         mInfo->pst.route = RTESPEC;
1440         mInfo->pst.event = 0;
1441    /* write the timer message to the queue of the destination task */
1442         if (ssDmndQPutLast(&tTsk->sTsk->dQ, mBuf,
1443                 (tTsk->tskPrior * SS_MAX_MSG_PRI) + PRIOR0) != ROK)
1444         {
1445         SS_RELEASE_SEMA(&osCp.tTskTblSem);
1446         SPutMsg(mBuf);
1447 #if (ERRCLASS & ERRCLS_DEBUG)
1448         SSLOGERROR(ERRCLS_INT_PAR, ESS416, ERRZERO, "Could not write to demand queue");
1449 #endif
1450         return RFAILED;
1451         }
1452    }
1453 #endif
1454
1455    return ROK;
1456 } /* SDeregTTsk */
1457
1458 \f
1459 /*
1460 *
1461 *       Fun:   Create system task
1462 *
1463 *       Desc:  This function is used to create a system task. An
1464 *              entry is located in the system task table and the
1465 *              implementation-specific function is called.
1466 *
1467 *       Ret:   ROK      - ok
1468 *              RFAILED  - failed, general (optional)
1469 *              ROUTRES  - failed, out of resources (optional)
1470 *
1471 *       Notes:
1472 *
1473 *       File:  ss_task.c
1474 *
1475 */
1476 S16 SCreateSTsk
1477 (
1478 SSTskPrior tskPrior,            /* task priority */
1479 SSTskId *tskId                  /* filled in with system task ID */
1480 )
1481 {
1482    S16 ret = ROK;
1483    SsSTskEntry *sTsk = NULLP;
1484
1485
1486
1487
1488 #if (ERRCLASS & ERRCLS_INT_PAR)
1489    /* check task ID pointer */
1490    if (tskId == NULLP)
1491    {
1492       SSLOGERROR(ERRCLS_INT_PAR, ESS417, ERRZERO, "Null pointer");
1493       return RFAILED;
1494    }
1495
1496    /* check system task priority */
1497    if (tskPrior > SS_LOWEST_STSK_PRIOR)
1498    {
1499       SSLOGERROR(ERRCLS_INT_PAR, ESS418, ERRZERO,
1500                      "Invalid system task priority");
1501       return RFAILED;
1502    }
1503 #endif
1504
1505
1506    /* lock the system task table */ 
1507    ret = SLock(&osCp.sTskTblLock);
1508    if (ret != ROK)
1509    {
1510
1511 #if (ERRCLASS & ERRCLS_DEBUG)
1512       SSLOGERROR(ERRCLS_DEBUG, ESS419, (ErrVal) ret,
1513                      "Could not lock system task table");
1514 #endif
1515
1516       return RFAILED;
1517    }
1518
1519
1520 #ifdef SS_SINGLE_THREADED
1521    /* When singlethreaded, we only need to create one... */
1522 /* ss001.301: additions */
1523 #ifndef SS_WATCHDOG 
1524 #ifndef SS_MULTICORE_SUPPORT
1525    if (osCp.numSTsks == 1)
1526 #else
1527    if (osCp.numSTsks == 2)
1528 #endif /* SS_MULTICORE_SUPPORT */
1529 #else
1530 #ifndef SS_MULTICORE_SUPPORT
1531    if (osCp.numSTsks == 3)
1532 #else      
1533    if (osCp.numSTsks == 4)
1534 #endif /* SS_MULTICORE_SUPPORT */
1535 #endif /* SS_WATCHDOG */
1536    {
1537 /* ss001.301: additions */
1538 #ifndef SS_WATCHDOG 
1539 #ifndef SS_MULTICORE_SUPPORT
1540       *tskId = 0;
1541       osCp.sTskTbl[0].termPend = FALSE;
1542 #else
1543       *tskId = 1;
1544       osCp.sTskTbl[1].termPend = FALSE;
1545 #endif /* SS_MULTICORE_SUPPORT */
1546 #else
1547 #ifndef SS_MULTICORE_SUPPORT
1548       *tskId = 2;
1549       osCp.sTskTbl[2].termPend = FALSE;
1550 #else 
1551       *tskId = 3;
1552       osCp.sTskTbl[3].termPend = FALSE;
1553 #endif /* SS_MULTICORE_SUPPORT */
1554 #endif /* SS_WATCHDOG */
1555
1556   /* ss006.13: addition */
1557       if ( SUnlock(&osCp.sTskTblLock) != ROK)
1558       {
1559 #if (ERRCLASS & ERRCLS_DEBUG)
1560            SSLOGERROR(ERRCLS_DEBUG, ESS420, ERRZERO,
1561                        "Could not give the Semaphore");
1562            return RFAILED;
1563 #endif
1564       }
1565       return ROK;
1566    }
1567 #endif /* SS_SINGLE_THREADED */
1568
1569
1570    /* check count of system tasks */
1571    if (osCp.numSTsks == SS_MAX_STSKS)
1572    {
1573
1574   /* ss006.13: addition */
1575       if ( SUnlock(&osCp.sTskTblLock) != ROK)
1576       {
1577 #if (ERRCLASS & ERRCLS_DEBUG)
1578            SSLOGERROR(ERRCLS_DEBUG, ESS421, ERRZERO,
1579                        "Could not give the Semaphore");
1580            return RFAILED;
1581 #endif
1582       }
1583
1584 #if (ERRCLASS & ERRCLS_ADD_RES)
1585       SSLOGERROR(ERRCLS_ADD_RES, ESS422, ERRZERO, "Too many system tasks");
1586 #endif
1587
1588       return (ROUTRES);
1589    }
1590
1591
1592    /* initialize the system task entry with the information we have */
1593    sTsk = &osCp.sTskTbl[osCp.nxtSTskEntry];
1594
1595    /* store the system task priority */
1596    sTsk->tskPrior = tskPrior;
1597
1598 /*ss014.301 SSI-4GMX specific changes*/   
1599 #ifndef SS_4GMX_LCORE
1600    /* initialize the demand queue */
1601    if (ssInitDmndQ(&sTsk->dQ) != ROK)
1602    {
1603
1604   /* ss006.13: addition */
1605       if ( SUnlock(&osCp.sTskTblLock) != ROK)
1606       {
1607 #if (ERRCLASS & ERRCLS_DEBUG)
1608            SSLOGERROR(ERRCLS_DEBUG, ESS423, ERRZERO,
1609                        "Could not give the Semaphore");
1610            return RFAILED;
1611 #endif
1612       }
1613
1614 #if (ERRCLASS & ERRCLS_DEBUG)
1615       SSLOGERROR(ERRCLS_DEBUG, ESS424, (ErrVal) ret,
1616                   "Could not initialize demand queue");
1617 #endif
1618
1619       return RFAILED;
1620    }
1621
1622    /* initialize the system task entry lock */
1623    if (SInitLock(&sTsk->lock, SS_STSKENTRY_LOCK) != ROK)
1624    {
1625       ssDestroyDmndQ(&sTsk->dQ);
1626
1627   /* ss006.13: addition */
1628       if ( SUnlock(&osCp.sTskTblLock) != ROK)
1629       {
1630 #if (ERRCLASS & ERRCLS_DEBUG)
1631            SSLOGERROR(ERRCLS_DEBUG, ESS425, ERRZERO,
1632                        "Could not give the Semaphore");
1633            return RFAILED;
1634 #endif
1635       }
1636
1637 #if (ERRCLASS & ERRCLS_DEBUG)
1638       SSLOGERROR(ERRCLS_DEBUG, ESS426, (ErrVal) ret,
1639                   "Could not initialize system task entry lock");
1640 #endif
1641
1642       return RFAILED;
1643    }
1644 #endif
1645
1646    /* we ask the implementation to start this system task */
1647    ret = ssdCreateSTsk(sTsk);
1648    if (ret != ROK)
1649    {
1650       /* failed, clean up */
1651       SDestroyLock(&sTsk->lock);
1652 /*ss014.301 SSI-4GMX specific changes*/   
1653 #ifndef SS_4GMX_LCORE
1654       ssDestroyDmndQ(&sTsk->dQ);
1655 #endif
1656       sTsk->tskPrior = 0;
1657
1658
1659   /* ss006.13: addition */
1660       if ( SUnlock(&osCp.sTskTblLock) != ROK)
1661       {
1662 #if (ERRCLASS & ERRCLS_DEBUG)
1663            SSLOGERROR(ERRCLS_DEBUG, ESS427, ERRZERO,
1664                        "Could not give the Semaphore");
1665            return RFAILED;
1666 #endif
1667       }
1668
1669 #if (ERRCLASS & ERRCLS_DEBUG)
1670       SSLOGERROR(ERRCLS_DEBUG, ESS428, (ErrVal) ret,
1671                   "Could not create system task");
1672 #endif
1673
1674       return RFAILED;
1675    }
1676
1677    /* success, update the table */
1678    *tskId = osCp.nxtSTskEntry;
1679    sTsk->tskId       = osCp.nxtSTskEntry;
1680    sTsk->used        = TRUE;
1681    sTsk->termPend    = FALSE;
1682    osCp.nxtSTskEntry = sTsk->nxt;
1683    osCp.numSTsks++;
1684
1685 #ifdef SS_LOCKLESS_MEMORY
1686    tmpRegTidMap[sTsk->region] = sTsk->dep.tId;
1687 #endif /* SS_LOCKLESS_MEMORY */
1688    /* unlock the system task table */
1689
1690   /* ss006.13: addition */
1691       if ( SUnlock(&osCp.sTskTblLock) != ROK)
1692       {
1693 #if (ERRCLASS & ERRCLS_DEBUG)
1694            SSLOGERROR(ERRCLS_DEBUG, ESS429, ERRZERO,
1695                        "Could not give the Semaphore");
1696            return RFAILED;
1697 #endif
1698       }
1699
1700    return ROK;
1701
1702 } /* SCreateSTsk */
1703
1704 /* ss001.301: additions */
1705 #ifdef SS_LOGGER_SUPPORT 
1706 /*
1707 *
1708 *       Fun:   Register logger configuration 
1709 *
1710 *       Desc:  This function is used to configure the config information
1711 *              of the logger.The log file name, path and the size limits
1712 *              of the log file are updated in the SSI control block. 
1713 *
1714 *
1715 *
1716 *       Ret:   ROK      - ok
1717 *              RFAILED  - failed, general (optional)
1718 *              ROUTRES  - failed, out of resources (optional)
1719 *
1720 *       Notes:
1721 *
1722 *       File:  ss_task.c
1723 *
1724 */
1725 S16 SRegLogCfg
1726 (
1727 uint8_t mode,
1728 S8 *path,
1729 uint32_t size,
1730 S8 *IPA,
1731 uint16_t port
1732 )
1733 {
1734
1735 #ifdef WIN32
1736    WSADATA wsaData;
1737         uint32_t iRes;
1738 #endif
1739
1740    /*ss013.301: Fixed Warnings for 32/64 bit compilation*/ 
1741    struct sockaddr_in localAddr={0};
1742    struct sockaddr_in remoteAddr ={0};
1743
1744
1745 #if (ERRCLASS & ERRCLS_INT_PAR)
1746 #endif
1747
1748    /* Initialize the lock, return on failure */
1749    if( SInitLock(&(osCp.logger.bufLock),SS_LOCK_MUTEX) != ROK)
1750         {
1751       return RFAILED;
1752    } /* if */
1753
1754    SLock(&osCp.logger.bufLock);
1755
1756         /* Initialize the logger configuration flag */
1757         osCp.logger.configured = FALSE;
1758
1759    if( osCp.logger.started == TRUE)
1760    {
1761       (Void)SUnlock(&(osCp.logger.bufLock));
1762       return RFAILED;
1763    }
1764
1765         /* set the mode of the logging */
1766         switch (mode)
1767         {
1768            case SS_LOG_TO_FILE: 
1769                    osCp.logger.opt |= 0x01; 
1770                    break;
1771            case SS_LOG_TO_SOCKET: 
1772                    osCp.logger.opt |= 0x02; 
1773                    break;
1774            case SS_LOG_ALL: 
1775                 default:  
1776                    osCp.logger.opt |= 0x03; break;
1777         }
1778     
1779    /*Open log file*/
1780         if (osCp.logger.opt & 0x01)
1781         {
1782       osCp.logger.filep = fopen(path, "wb");
1783       if(osCp.logger.filep == NULLP)
1784       {
1785          SDisplay(0,"Error Opening Log File \n");
1786          (Void)SUnlock(&(osCp.logger.bufLock));
1787          return RFAILED;
1788       }
1789       strcpy(osCp.logger.filePath,path);
1790         }
1791
1792    /*Open socket */
1793         if (osCp.logger.opt & 0x02)
1794         {
1795 #ifdef WIN32
1796                         if ((iRes = WSAStartup(MAKEWORD(2,2), &wsaData)) != NO_ERROR)
1797                         {
1798                            SDisplay(0, "Error at WSAStartup!\n");
1799             (Void)SUnlock(&(osCp.logger.bufLock));
1800                                 return RFAILED;
1801                         }
1802 #endif
1803       osCp.logger.socketdes = socket(AF_INET, SOCK_DGRAM, 0);
1804       if(osCp.logger.socketdes == -1)
1805       {
1806          SDisplay(0,"Error Opening Log Socket  \n");
1807 #ifdef WIN32
1808                         WSACleanup();
1809 #endif
1810          (Void)SUnlock(&(osCp.logger.bufLock));
1811          return RFAILED;
1812       }
1813                 /* bind to local address */
1814                 localAddr.sin_family = AF_INET;
1815                 localAddr.sin_port = port;
1816                 localAddr.sin_addr.s_addr = INADDR_ANY;
1817                 if (bind(osCp.logger.socketdes, (struct sockaddr*)&localAddr, sizeof(struct sockaddr)) < 0)
1818                 {
1819          SDisplay(0,"Error binding to local port \n");
1820 #ifdef WIN32
1821                         closesocket(osCp.logger.socketdes);
1822                         WSACleanup();
1823 #else
1824                         close(osCp.logger.socketdes);
1825 #endif
1826          (Void)SUnlock(&(osCp.logger.bufLock));
1827          return RFAILED;
1828                 }
1829                 /* remote address */
1830                 remoteAddr.sin_family = AF_INET;
1831                 remoteAddr.sin_port = htons(port);
1832                 if (!IPA)
1833                 {
1834          SDisplay(0,"Invalid remote IP Address \n");
1835 #ifdef WIN32
1836                         closesocket(osCp.logger.socketdes);
1837                         WSACleanup();
1838 #else
1839                         close(osCp.logger.socketdes);
1840 #endif
1841          (Void)SUnlock(&(osCp.logger.bufLock));
1842          return RFAILED;
1843                 }
1844                 remoteAddr.sin_addr.s_addr = inet_addr(IPA);
1845                 osCp.logger.remoteAddr = remoteAddr;
1846
1847         }
1848
1849    memset(osCp.logger.buffer, '\0', sizeof(osCp.logger.buffer));
1850    
1851    osCp.logger.maxBufSiz = SS_MAX_LOGBUF_SIZE;
1852    osCp.logger.curBufSiz = 0;
1853
1854    osCp.logger.maxNumFlush = size/osCp.logger.maxBufSiz;
1855    osCp.logger.curNumFlush = 0;
1856
1857
1858    osCp.logger.started = FALSE;
1859         osCp.logger.configured = TRUE;
1860
1861    (Void)SUnlock(&(osCp.logger.bufLock));
1862
1863    return ROK;
1864 } /* SRegLogCfg */
1865
1866 /*
1867 *
1868 *       Fun:   SFlushBufToLog
1869 *
1870 *       Desc:  This function is used flush the buffer to file/socket.
1871 *
1872 *       Ret:   ROK
1873 *
1874 *       Notes:
1875 *
1876 *       File:  ss_task.c
1877 *
1878 --*/
1879 S16 SFlushBufToLog (S8 *logBuf)
1880 {
1881    S8 *buffer;
1882    static uint16_t logFileCnt = 0;
1883    S8 newFileName[SS_MAX_PATH];
1884 #ifdef WIN32
1885    size_t writeNum;
1886 #else
1887    ssize_t writeNum;
1888 #endif
1889    FILE* oldFileP;
1890    /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
1891
1892    buffer = logBuf;
1893
1894         if (osCp.logger.opt & 0x01)
1895         {
1896       writeNum = fwrite(buffer, sizeof(uint8_t), cmStrlen((uint8_t *)buffer), 
1897                                   osCp.logger.filep);
1898         }
1899         if (osCp.logger.opt & 0x02)
1900         {
1901       writeNum = sendto(osCp.logger.socketdes, buffer, cmStrlen((uint8_t *)buffer), 0, (struct sockaddr*)&osCp.logger.remoteAddr, sizeof(osCp.logger.remoteAddr));
1902       /*ss013.301 : Returned after sending to socket*/
1903       return ROK;
1904         }
1905    osCp.logger.curNumFlush++;
1906    if(osCp.logger.curNumFlush == osCp.logger.maxNumFlush)
1907    {
1908       memset(newFileName,'\0',sizeof(newFileName));
1909       /*Store the current File*/
1910       oldFileP = osCp.logger.filep;
1911       /*Open a new file and use it as a new log file*/
1912       osCp.logger.curNumFlush = 0;
1913       logFileCnt++;
1914       sprintf(newFileName, "%s%d", osCp.logger.filePath, logFileCnt);
1915       osCp.logger.filep = fopen(newFileName, "wb");
1916       if(osCp.logger.filep == NULLP)
1917       {
1918           /*MTLOGERROR(ERRCLS_DEBUG, EMTXXX, ERRZERO, "Error Opening Log File. \n");*/
1919       }
1920
1921       fclose(oldFileP);
1922    }
1923    /*SPutSBuf(DFLT_REGION,DFLT_POOL,
1924             (Data *)buffer, (Size)(osCp.logger.maxBufSiz * sizeof(S8)));*/
1925  
1926    return ROK;
1927 } /* SFlushBufToLog */
1928
1929 /*
1930 *
1931 *       Fun:   SCleanUp
1932 *
1933 *       Desc:  This function is used to clean up the logger info.
1934 *
1935 *       Ret:   task id
1936 *
1937 *       Notes:
1938 *
1939 *       File:  ss_task.c
1940 *
1941 --*/
1942 S16 SCleanUp(Void)
1943 {
1944
1945    /*Flush the remaining data in the log file*/
1946    SLock(&osCp.logger.bufLock);
1947    if(osCp.logger.started == FALSE)
1948    {
1949       (Void)SUnlock(&(osCp.logger.bufLock));
1950       return ROK;
1951    }
1952    if(osCp.logger.curBufSiz)
1953    {
1954       SFlushBufToLog(osCp.logger.buffer);
1955       osCp.logger.curBufSiz = 0;
1956
1957    }
1958         if (osCp.logger.opt & 0x01)
1959         {
1960       fclose(osCp.logger.filep);
1961         }
1962         if (osCp.logger.opt & 0x02)
1963         {
1964 #ifdef WIN32
1965       closesocket(osCp.logger.socketdes);
1966 #else
1967       close(osCp.logger.socketdes);
1968 #endif
1969         }
1970    osCp.logger.started = FALSE;
1971
1972    (Void)SUnlock(&(osCp.logger.bufLock));
1973 #ifdef L2_L3_SPLIT
1974    signal(SIGINT, App_SigExitCallBack);
1975 #endif 
1976
1977    return ROK;
1978
1979 } /* end of SCleanUp */
1980
1981 /*
1982 *
1983 *       Fun:   Unregister the logger.
1984 *
1985 *       Desc:  This function is used to deregister a logger task. 
1986 *
1987 *       Ret:   ROK      - ok
1988 *              RFAILED  - failed, general (optional)
1989 *              ROUTRES  - failed, out of resources (optional)
1990 *
1991 *       Notes:
1992 *
1993 *       File:  ss_task.c
1994 *
1995 */
1996 S16 SDeregLogCfg()
1997 {
1998
1999
2000  
2001    SCleanUp();   
2002
2003    return ROK;
2004
2005 } /* SDeregLogCfg */
2006
2007 /*
2008 *
2009 *       Fun:   SStartLogger
2010 *
2011 *       Desc:  To start logger.
2012 *
2013 *       Ret:   Void
2014 *
2015 *       Notes:
2016 *
2017 *       File:  ss_task.c
2018 *
2019 */
2020 Void SStartLogger(void)
2021 {
2022         if (osCp.logger.configured == TRUE)
2023         {
2024       osCp.logger.started = TRUE;
2025         }
2026 }
2027
2028
2029 /*
2030 *
2031 *       Fun:   SStopLogger
2032 *
2033 *       Desc:  To stop logging to file/socket.
2034 *
2035 *       Ret:   Void
2036 *
2037 *       Notes:
2038 *
2039 *       File:  ss_task.c
2040 *
2041 */
2042 Void SStopLogger(void)
2043 {
2044    osCp.logger.started = FALSE;
2045 }
2046 #endif /* SS_LOGGER_SUPPORT */
2047
2048 /** for multi-core support **/
2049 /*ss013.301 : changes related to SS_AFFINITY_SUPPORT*/
2050 #if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT)
2051
2052 /*
2053 *
2054 *       Fun:   Register the CPU information
2055 *
2056 *       Desc:  This function is used to register the number of cores
2057 *              present and the number of threads which can be run on
2058 *              each core.
2059 *
2060 *       Ret:   ROK      - ok
2061 *              RFAILED  - failed, general (optional)
2062 *
2063 *       Notes:
2064 *
2065 *       File:  ss_task.c
2066 *
2067 */
2068 S16 SRegCpuInfo 
2069 (
2070 SCpuInfo *cpuInfo    /* Information about the cores/threads per core */
2071 )
2072 {
2073    uint32_t coreCount = 0;
2074
2075    /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
2076    /* check the number of cores */
2077    if ( cpuInfo->numCores > SS_MAX_CORES || 
2078         cpuInfo->threadsPerCore > SS_MAX_THREADS_PER_CORE || 
2079         cpuInfo->numCores < 1 || cpuInfo->threadsPerCore < 1 )
2080    {
2081        SSLOGERROR(ERRCLS_INT_PAR, ESS430, ERRZERO, "Invalid number of cores\n");
2082        return RFAILED;
2083    }
2084
2085    /* lock mCInfo */
2086    SLock(&osCp.mCILock);
2087    osCp.mCInfo.cpuInfo.numCores = cpuInfo->numCores;
2088    osCp.mCInfo.cpuInfo.threadsPerCore = cpuInfo->threadsPerCore;
2089    /* if the cpu register is supplied then use it */
2090    for (; coreCount < cpuInfo->numCores; coreCount++)
2091    {
2092       uint32_t thrCnt = 0;
2093       for (;thrCnt < SS_MAX_THREADS_PER_CORE;thrCnt++)
2094       {
2095          osCp.mCInfo.coreInfo[coreCount].tskPerCoreLst[thrCnt] = -1;
2096       } /* for */
2097       osCp.mCInfo.coreInfo[coreCount].exclusive = FALSE;
2098       osCp.mCInfo.coreInfo[coreCount].thrs = osCp.mCInfo.cpuInfo.threadRegister[coreCount] 
2099       = cpuInfo->threadRegister[coreCount];
2100    }
2101    /* unlock mCInfo */
2102    SUnlock(&osCp.mCILock);
2103
2104    return ROK;
2105
2106 } /* SRegCpuInfo */
2107
2108
2109
2110 /*
2111 *
2112 *       Fun:   Get the current core/cpu affinity for a thread/lwp
2113 *
2114 *       Desc:  This function is used to get the current processor/core 
2115 *              affinity for a a system task (thread/lwp). It sets the 
2116 *              affinity based on the mode supplied by the caller. 
2117 *
2118 *       Ret:   ROK      - ok
2119 *              RFAILED  - failed, general (optional)
2120 *
2121 *       Notes:
2122 *
2123 *       File:  ss_task.c
2124 *
2125 */
2126 S16 SGetAffinity
2127 (
2128 SSTskId *tskId,                  /* filled in with system task ID */
2129 uint32_t *coreId                      /* the core/processor id to which the affinity is set */
2130 )
2131 {
2132    S16 ret;
2133
2134     /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
2135     /* implementation specific */
2136     ret = ssdGetAffinity(tskId, coreId);
2137
2138     if (ret != ROK)
2139     {
2140        SSLOGERROR(ERRCLS_INT_PAR, ESS431, ERRZERO, "Failed to get affinity\n");
2141        return RFAILED;
2142     } /* end if */
2143
2144    return ROK;
2145 } /* SGetAffinity */
2146
2147
2148 /*
2149 *
2150 *       Fun:   Set the core/cpu affinity for a thread/lwp
2151 *
2152 *       Desc:  This function is used to set processor/core affinity for a 
2153 *              a system task (thread/lwp). It sets the affinity based on the
2154 *              mode supplied by the caller. 
2155 *
2156 *       Ret:   ROK      - ok
2157 *              RFAILED  - failed, general (optional)
2158 *
2159 *       Notes:
2160 *
2161 *       File:  ss_task.c
2162 *
2163 */
2164 S16 SSetAffinity
2165 (
2166 SSTskId *tskId,                  /* filled in with system task ID */
2167 SsAffinityMode mode,             /* the mode according to which the affinty is set */
2168 uint32_t coreId,                      /* the core/processor id to which the affinity has to be set */
2169 SSTskId *tskAssociatedTskId      /* filled in with system task ID of the associated layer */
2170 )
2171 {
2172    S16 ret;
2173   
2174    /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
2175    /* validate the mode */
2176    if (mode < SS_AFFINITY_MODE_DEFAULT || 
2177        mode > SS_AFFINITY_MODE_EXCL)
2178    {
2179       SSLOGERROR(ERRCLS_INT_PAR, ESS432, ERRZERO, "Invalid mode for setting core affinity\n");
2180       return RFAILED;
2181    } /* end if */
2182
2183    /* check the value of core id */
2184    if (SS_AFFINITY_MODE_SPECIFIC == mode && 
2185        (coreId > osCp.mCInfo.cpuInfo.numCores || coreId < 0))
2186    {
2187       SSLOGERROR(ERRCLS_INT_PAR, ESS433, ERRZERO, "Invalid core id\n");
2188       return RFAILED;
2189    } /* end if */
2190
2191    /* set affinity according to the mode supplied */
2192    switch (mode)
2193    {
2194        case SS_AFFINITY_MODE_DEFAULT:
2195        {
2196            uint32_t coreCounter = 0, coreIndex = 0;
2197            S8 repeatFlag = 1;
2198            SEARCH_FOR_CORE:
2199               /*ss013.301: Fixed Warnings for 32/64 bit compilation*/ 
2200               for (coreIndex = osCp.mCInfo.currentCore;  
2201                    coreCounter < osCp.mCInfo.cpuInfo.numCores; 
2202                    coreCounter++ )
2203                   {
2204                      /* again start from core 0 */ 
2205                      ++coreIndex;
2206                      coreIndex = (coreIndex)%osCp.mCInfo.cpuInfo.numCores;
2207                      if (!osCp.mCInfo.coreInfo[coreIndex].exclusive 
2208                          && osCp.mCInfo.cpuInfo.threadRegister[coreIndex])
2209                      {
2210                          if (osCp.mCInfo.coreInfo[coreIndex].thrs || !repeatFlag)  
2211                          {
2212                              /* call the implementation specific affinity function */
2213                              ret = ssdSetAffinity(tskId, coreIndex); 
2214      
2215                              if (ret != ROK)
2216                              {
2217                                  SSLOGERROR(ERRCLS_INT_PAR, ESS434, ERRZERO, \
2218                                             "Failed to set core affinity\n");
2219                                  return RFAILED;
2220                              } /* end if */
2221   
2222                              /* lock mCInfo */
2223                              SLock(&osCp.mCILock);
2224
2225                              /* move the current core index */
2226                              osCp.mCInfo.currentCore = (coreIndex+1)%osCp.mCInfo.cpuInfo.numCores;
2227   
2228                              /* save the tskId in tskList */
2229                               osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[
2230                               osCp.mCInfo.cpuInfo.threadRegister[coreIndex] - 
2231                               osCp.mCInfo.coreInfo[coreIndex].thrs] = *tskId;
2232
2233                              /* decrement the available thread count in the thread register */
2234                               osCp.mCInfo.coreInfo[coreIndex].thrs--;
2235
2236                              /* unlock mCInfo */
2237                               SUnlock(&osCp.mCILock);
2238   
2239                               break;
2240                           } /* end if there are threads available in the core */    
2241                       } /* end if the core is not exclusive flagged and 
2242                            the core has threads for SSI use */
2243                   } /* end for */
2244                  if (coreCounter == osCp.mCInfo.cpuInfo.numCores && repeatFlag)
2245                  {
2246                      repeatFlag = 0;
2247                      SSLOGERROR(ERRCLS_INT_PAR, ESS435, ERRZERO, "Overloading of threads per core!!\n");
2248                      goto SEARCH_FOR_CORE; 
2249                  } /* end if no thrs on cores available and overallocation is needed */
2250               break;
2251           } /* end case SS_AFFINITY_MODE_DEFAULT */
2252           case SS_AFFINITY_MODE_SPECIFIC:
2253           {
2254               /* check if the core is used exclusively for any task */
2255               if (osCp.mCInfo.coreInfo[coreId].exclusive)
2256               {
2257                   SSLOGERROR(ERRCLS_INT_PAR, ESS436, ERRZERO,\
2258                              "Can not set core affinity, core is exclusively used for other task\n");
2259                   return RFAILED;
2260               } /* end if */
2261               /* call the implementation specific affinity function with the core id supplied by caller */
2262               ret = ssdSetAffinity(tskId, coreId);
2263
2264               if (ret != ROK)
2265               {
2266                   SSLOGERROR(ERRCLS_INT_PAR, ESS437, ERRZERO, "Failed to set core affinity\n");
2267                   return RFAILED;
2268               } /* end if */
2269
2270               /* lock mCInfo */
2271               SLock(&osCp.mCILock);
2272
2273               /* move the current core index */
2274                osCp.mCInfo.currentCore = (coreId+1)%osCp.mCInfo.cpuInfo.numCores;
2275
2276               /* save the tskId in tskList */
2277               osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[
2278               osCp.mCInfo.cpuInfo.threadRegister[coreId] - 
2279               osCp.mCInfo.coreInfo[coreId].thrs] = *tskId;
2280  
2281               /* decrement the available thread count in the thread register */
2282               osCp.mCInfo.coreInfo[coreId].thrs--;
2283  
2284               /* unlock mCInfo */
2285               SUnlock(&osCp.mCILock);
2286
2287               if (osCp.mCInfo.coreInfo[coreId].thrs < 0)
2288               {
2289                   SSLOGERROR(ERRCLS_INT_PAR, ESS438, ERRZERO, "Overloading of threads per core!!\n");
2290               } /* end else */
2291
2292              break;
2293           } /* end case SS_AFFINITY_MODE_SPECIFIC */
2294           case SS_AFFINITY_MODE_ASSOC:
2295           {
2296               /* search for the associated tsk id in osCp */
2297               uint32_t coreIndex = 0, threadIndex = 0;
2298               Bool tskNotFound = TRUE;
2299               for (;tskNotFound && coreIndex < SS_MAX_CORES; coreIndex++)
2300               {
2301                   for (threadIndex = 0; threadIndex < SS_MAX_THREADS_PER_CORE; threadIndex++)
2302                   {
2303                       if (osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[threadIndex] == *tskAssociatedTskId)
2304                       {
2305                           if (!osCp.mCInfo.coreInfo[coreIndex].exclusive)
2306                           {
2307                               /* set the affinity for the given task on to the core coreIndex */
2308                               ret = ssdSetAffinity(tskId, coreIndex);
2309                               if (ret != ROK)
2310                               {
2311                                   SSLOGERROR(ERRCLS_INT_PAR, ESS439, ERRZERO, "Failed to set core affinity\n");
2312                                   return RFAILED;
2313                               } /* end if */
2314     
2315                               /* lock mCInfo */
2316                               SLock(&osCp.mCILock);
2317
2318                              /* move the current core index */
2319                               osCp.mCInfo.currentCore = (coreIndex+1)%osCp.mCInfo.cpuInfo.numCores;
2320     
2321                              /* save the tskId in tskList */
2322                              osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[               
2323                              osCp.mCInfo.cpuInfo.threadRegister[coreIndex] - 
2324                              osCp.mCInfo.coreInfo[coreIndex].thrs] = *tskId;
2325  
2326                             /* decrement the available thread count in the thread register */
2327                              osCp.mCInfo.coreInfo[coreIndex].thrs--;
2328  
2329                             /* unlock mCInfo */
2330                             SUnlock(&osCp.mCILock);
2331
2332                             if (osCp.mCInfo.coreInfo[coreIndex].thrs < 0) 
2333                             {
2334                                 SSLOGERROR(ERRCLS_INT_PAR, ESS440, ERRZERO, 
2335                                            "Overloading of threads per core!!\n");
2336                             } /* end if */
2337
2338                          } /* end if */
2339                          else
2340                          {
2341                              SSLOGERROR(ERRCLS_INT_PAR, ESS441, ERRZERO, 
2342                                         "Can not set core affinity, core is exclusively used for other task\n");
2343                              return RFAILED;
2344                          } /* end else */
2345                          tskNotFound = FALSE;
2346                            break;
2347                       } /* end if */
2348                   } /* end inner for */
2349                } /* end for */
2350
2351                /* check if tskAssociatedTskId is valid or not */
2352                if (coreIndex == SS_MAX_CORES)
2353                 {
2354                     SSLOGERROR(ERRCLS_INT_PAR, ESS442, ERRZERO, "Invalid core id\n");
2355                     return RFAILED;
2356                 } /* if */
2357              break;
2358           } /* end case SS_AFFINITY_MODE_ASSOC */
2359           case SS_AFFINITY_MODE_EXCL:
2360           {
2361              /* check if any thread is already running on the core */
2362              if (coreId != SS_DEFAULT_CORE && 
2363                  osCp.mCInfo.coreInfo[coreId].thrs == osCp.mCInfo.cpuInfo.threadRegister[coreId] &&
2364                 !osCp.mCInfo.coreInfo[coreId].exclusive)
2365               {
2366                  /* call the implementation specific affinity function */
2367                  ret = ssdSetAffinity(tskId, coreId);
2368     
2369                  if (ret != ROK)
2370                  {
2371                     SSLOGERROR(ERRCLS_INT_PAR, ESS443, ERRZERO, "Failed to set core affinity\n");
2372                     return RFAILED;
2373                  } /* end if */
2374
2375                  /* lock mCInfo */
2376                  SLock(&osCp.mCILock);
2377
2378                  /* set the exclusive flag so that the core will not be used for other system tasks */
2379                   osCp.mCInfo.coreInfo[coreId].exclusive = TRUE;
2380  
2381                   /* save the tskId in tskList */
2382                   osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[osCp.mCInfo.cpuInfo.threadRegister[coreId] - 
2383                   osCp.mCInfo.coreInfo[coreId].thrs] = *tskId;
2384
2385                   /* decrement the available thread count in the thread register */
2386                   osCp.mCInfo.coreInfo[coreId].thrs--;
2387  
2388                  /* unlock mCInfo */
2389                   SUnlock(&osCp.mCILock);
2390
2391              } /* end if */
2392              else if (coreId == SS_DEFAULT_CORE)
2393              {
2394                  uint32_t coreCounter = 0;
2395                  uint32_t coreIndex = 0;
2396                  /*ss013.301: Fixed Warnings for 32/64 bit compilation*/ 
2397                  for (coreIndex = osCp.mCInfo.currentCore;  
2398                       coreCounter < osCp.mCInfo.cpuInfo.numCores; 
2399                       coreCounter++)
2400                      {
2401                         ++coreIndex;
2402                         coreIndex = (coreIndex)%osCp.mCInfo.cpuInfo.numCores;
2403                         if (!osCp.mCInfo.coreInfo[coreIndex].exclusive 
2404                             && osCp.mCInfo.cpuInfo.threadRegister[coreIndex])
2405                         {
2406                             if ( osCp.mCInfo.coreInfo[coreIndex].thrs == 
2407                                  osCp.mCInfo.cpuInfo.threadRegister[coreIndex] &&
2408                                  osCp.mCInfo.coreInfo[coreIndex].thrs)  
2409                             {
2410                                /* call the implementation specific affinity function */
2411                                 ret = ssdSetAffinity(tskId, coreIndex);
2412         
2413                                 if (ret != ROK)
2414                                  {
2415                                     SSLOGERROR(ERRCLS_INT_PAR, ESS444, ERRZERO, "Failed to set core affinity\n");
2416                                     return RFAILED;
2417                                  } /* end if */
2418      
2419                                  /* lock mCInfo */
2420                                  SLock(&osCp.mCILock);
2421
2422                                  /* move the current core index */
2423                                  osCp.mCInfo.currentCore = (coreIndex+1)%osCp.mCInfo.cpuInfo.numCores;
2424       
2425                                  /* save the tskId in tskList */
2426                                  osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[               
2427                                  osCp.mCInfo.cpuInfo.threadRegister[coreIndex] - 
2428                                  osCp.mCInfo.coreInfo[coreIndex].thrs] = *tskId;
2429  
2430                                 /* decrement the available thread count in the thread register */
2431                                  osCp.mCInfo.coreInfo[coreIndex].thrs--;
2432  
2433                                /* set the exclusive flag so that the core will not 
2434                                   be used for other system tasks */
2435                                   osCp.mCInfo.coreInfo[coreIndex].exclusive = TRUE;
2436
2437                                   /* unlock mCInfo */
2438                                   SUnlock(&osCp.mCILock);
2439
2440                                   break;
2441                                } /* end if there are threads available in the core */    
2442                             } /* end if the core is not exclusive flagged and 
2443                                  the core has threads for SSI use */
2444                          } /* end for */
2445                   if (coreCounter == osCp.mCInfo.cpuInfo.numCores)
2446                   {
2447                      SSLOGERROR(ERRCLS_INT_PAR, ESS445, ERRZERO, 
2448                                 "Failed to set core affinity, no threads on cores available\n");
2449                      return RFAILED;
2450                   } /* end if no thrs on cores available */
2451
2452               } /* else if */
2453               else
2454               {
2455                  SSLOGERROR(ERRCLS_INT_PAR, ESS446, ERRZERO, "Can not set exclusive affinity for the core\n");
2456                  return RFAILED;
2457               } /* end else */
2458             break;
2459          } /* end case SS_AFFINITY_MODE_EXCL */
2460          default:
2461          {
2462             SSLOGERROR(ERRCLS_INT_PAR, ESS447, ERRZERO, "Invalid mode for setting core affinity\n");
2463             return RFAILED;
2464          } /* end default case */
2465     } /* end of switch */
2466
2467     return ROK;
2468                
2469
2470 } /* SSetAffinity */
2471
2472 #endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT*/
2473
2474 /** end multi-core support **/
2475
2476 \f
2477 /*
2478 *
2479 *       Fun:   Destroy system task
2480 *
2481 *       Desc:  This function is used to destroy a system task. The
2482 *              entry is located in the system task table and the
2483 *              implementation-specific function is called.
2484 *
2485 *       Ret:   ROK      - ok
2486 *              RFAILED  - failed, general (optional)
2487 *
2488 *       Notes:
2489 *
2490 *       File:  ss_task.c
2491 *
2492 */
2493 S16 SDestroySTsk
2494 (
2495 SSTskId tskId                   /* system task to be destroyed */
2496 )
2497 {
2498    S16 ret;
2499    /* ss029.103: modification: the subscript should be of same type */
2500    SsIdx i;
2501    SsIdx idx;
2502    SsSTskEntry *sTsk;
2503         /* ss002.301 Additions */
2504 /*ss013.301 : changes related to SS_AFFINITY_SUPPORT*/
2505 #if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT)
2506    uint32_t tskInd = 0;
2507 #endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT*/
2508
2509
2510
2511
2512 #if (ERRCLASS & ERRCLS_INT_PAR)
2513    /* validate the system task ID */
2514    if (tskId >= SS_MAX_STSKS)
2515    {
2516       SSLOGERROR(ERRCLS_INT_PAR, ESS448, (ErrVal) tskId, "Invalid task ID");
2517       return RFAILED;
2518    }
2519 #endif
2520
2521
2522    /* lock the system task table */
2523    ret = SLock(&osCp.sTskTblLock);
2524    if (ret != ROK)
2525    {
2526
2527 #if (ERRCLASS & ERRCLS_DEBUG)
2528       SSLOGERROR(ERRCLS_DEBUG, ESS449, (ErrVal) ret,
2529                      "Could not lock system task table");
2530 #endif
2531
2532       return RFAILED;
2533    }
2534
2535
2536    idx = (SsIdx) tskId;
2537    sTsk = &osCp.sTskTbl[idx];
2538
2539
2540 #if (ERRCLASS & ERRCLS_INT_PAR)
2541    /* 
2542     * check to see this system task exists and it is not already scheduled
2543     *  for termination 
2544     */
2545    if (sTsk->used != TRUE)
2546    {
2547
2548   /* ss006.13: addition */
2549       if ( SUnlock(&osCp.sTskTblLock) != ROK)
2550       {
2551 #if (ERRCLASS & ERRCLS_DEBUG)
2552            SSLOGERROR(ERRCLS_DEBUG, ESS450, ERRZERO,
2553                        "Could not give the Semaphore");
2554            return RFAILED;
2555 #endif
2556       }
2557
2558       SSLOGERROR(ERRCLS_INT_PAR, ESS451, (ErrVal) idx,
2559                         "Invalid system task ID");
2560       return RFAILED;
2561    }
2562    else if (sTsk->termPend != FALSE)
2563    {
2564
2565   /* ss006.13: addition */
2566       if ( SUnlock(&osCp.sTskTblLock) != ROK)
2567       {
2568 #if (ERRCLASS & ERRCLS_DEBUG)
2569            SSLOGERROR(ERRCLS_DEBUG, ESS452, ERRZERO,
2570                        "Could not give the Semaphore");
2571            return RFAILED;
2572 #endif
2573       }
2574
2575       SSLOGERROR(ERRCLS_INT_PAR, ESS453, (ErrVal) idx,
2576                         "Invalid system task ID");
2577       return RFAILED;
2578    }
2579 #endif
2580
2581
2582    /* lock this system task entry */
2583    if (!SS_CHECK_CUR_STSK(sTsk))
2584    {
2585       ret = SLock(&sTsk->lock);
2586       if (ret != ROK)
2587       {
2588
2589   /* ss006.13: addition */
2590          if ( SUnlock(&osCp.sTskTblLock) != ROK)
2591          {
2592 #if (ERRCLASS & ERRCLS_DEBUG)
2593              SSLOGERROR(ERRCLS_DEBUG, ESS454, ERRZERO,
2594                        "Could not give the Semaphore");
2595              return RFAILED;
2596 #endif
2597          }
2598
2599 #if (ERRCLASS & ERRCLS_DEBUG)
2600          SSLOGERROR(ERRCLS_DEBUG, ESS455, (ErrVal) ret,
2601                         "Could not lock system task entry");
2602 #endif
2603
2604          return RFAILED;
2605       }
2606    }
2607
2608    /* lock the TAPA task table */
2609    SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
2610    if (ret != ROK)
2611    {
2612       if (!SS_CHECK_CUR_STSK(sTsk))
2613       {
2614
2615   /* ss006.13: addition */
2616          if ( SUnlock(&sTsk->lock) != ROK)
2617          {
2618 #if (ERRCLASS & ERRCLS_DEBUG)
2619              SSLOGERROR(ERRCLS_DEBUG, ESS456, ERRZERO,
2620                        "Could not give the Semaphore");
2621              return RFAILED;
2622 #endif
2623          }
2624       }
2625
2626   /* ss006.13: addition */
2627          if ( SUnlock(&osCp.sTskTblLock) != ROK)
2628          {
2629 #if (ERRCLASS & ERRCLS_DEBUG)
2630              SSLOGERROR(ERRCLS_DEBUG, ESS457, ERRZERO,
2631                        "Could not give the Semaphore");
2632              return RFAILED;
2633 #endif
2634          }
2635
2636 #if (ERRCLASS & ERRCLS_DEBUG)
2637       SSLOGERROR(ERRCLS_DEBUG, ESS458, ERRZERO,
2638                      "Could not lock TAPA task table");
2639 #endif
2640
2641       return RFAILED;
2642    }
2643
2644
2645    /* If this system task entry has any TAPA tasks attached,
2646     *  we have to detach them
2647     */
2648    if (sTsk->numTTsks)
2649    {
2650       /* detach all TAPA tasks that are attached here */
2651       for (i = 0;  i < SS_MAX_TTSKS;  i++)
2652       {
2653          if (sTsk->tTsks[i] == SS_INVALID_IDX)
2654             continue;
2655
2656          osCp.tTskTbl[sTsk->tTsks[i]].sTsk = NULLP;
2657          sTsk->tTsks[i] = SS_INVALID_IDX;
2658          sTsk->numTTsks--;
2659       }
2660    }
2661
2662
2663    /* set the termination pending flag to TRUE */
2664    sTsk->termPend = TRUE;
2665
2666
2667    /* unlock everything */
2668    SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
2669
2670    if (!SS_CHECK_CUR_STSK(sTsk))
2671    {
2672
2673   /* ss006.13: addition */
2674       if ( SUnlock(&sTsk->lock) != ROK)
2675       {
2676 #if (ERRCLASS & ERRCLS_DEBUG)
2677           SSLOGERROR(ERRCLS_DEBUG, ESS459, ERRZERO,
2678                        "Could not give the Semaphore");
2679           return RFAILED;
2680 #endif
2681       }
2682    }
2683
2684
2685   /* ss006.13: addition */
2686    if ( SUnlock(&osCp.sTskTblLock) != ROK)
2687    {
2688 #if (ERRCLASS & ERRCLS_DEBUG)
2689         SSLOGERROR(ERRCLS_DEBUG, ESS460, ERRZERO,
2690                      "Could not give the Semaphore");
2691         return RFAILED;
2692 #endif
2693     }
2694
2695
2696    /* We call this after unlocking because it is possible that the
2697     *  caller is this very system task and we need to take care of
2698     *  that. The actual mechanism of notifying the thread that it
2699     *  has to die, or actually killing the thread is left to the
2700     *  implementation.
2701     */
2702    ret = ssdDestroySTsk(sTsk);
2703    if (ret != ROK)
2704    {
2705       /* Here, we're a little messed up. We've pretty much made this
2706        *  system task unusable, but now, its not going to die. So..??
2707        */
2708
2709 #if (ERRCLASS & ERRCLS_DEBUG)
2710       SSLOGERROR(ERRCLS_DEBUG, ESS461, (ErrVal) ret,
2711                   "Could not destroy system task");
2712 #endif
2713
2714       return RFAILED;
2715    }
2716    
2717    /* multi-core support */
2718 /*ss013.301 : changes related to SS_AFFINITY_SUPPORT*/
2719 #if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT)
2720
2721    /* Remove CPU affinity if any */
2722    for (tskInd = 0;  tskInd < SS_MAX_STSKS;  tskInd++)
2723    {
2724       if (osCp.sTskTbl[tskInd].tskId == sTsk->tskId)
2725       {
2726           /* search for the tskId in coreInfo */
2727           uint32_t coreId = 0;
2728           for (coreId = 0; coreId < SS_MAX_CORES; coreId++)
2729           {
2730              uint32_t thrId = 0;
2731              for (thrId = 0; thrId < SS_MAX_THREADS_PER_CORE; thrId++)
2732              {
2733                 if (sTsk->tskId == osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[thrId])
2734                  {
2735                     /* lock mCInfo */
2736                     SLock(&osCp.mCILock);
2737
2738                     /* increment the available threads */
2739                     osCp.mCInfo.coreInfo[coreId].thrs++;
2740
2741                     /* reset the thread id */
2742                     osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[thrId] = 0;
2743
2744                     /* if exclusive flag is set then remove it */
2745                    if (osCp.mCInfo.coreInfo[coreId].exclusive)
2746                    {
2747                       osCp.mCInfo.coreInfo[coreId].exclusive = FALSE;
2748                    } /* end if excl set */
2749
2750                    /* unlock mCInfo */
2751                    SUnlock(&osCp.mCILock);
2752
2753                    break;
2754                 } /* end if sTsk matched a thread */
2755              } /* end for loop of thread Ids */
2756           } /* for */
2757           break;
2758       } /* end if */
2759    } /* end for */
2760
2761 #endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT*/
2762 /* end multi-core support */
2763
2764    /* ss019.103 - added to release semaphore for system task */
2765 #ifndef NS
2766    if (ssPostSema(&osCp.dep.ssStarted) != ROK)
2767    {
2768 #if (ERRCLASS & ERRCLS_DEBUG)
2769        SSLOGERROR(ERRCLS_DEBUG, ESS462, ERRZERO,
2770                          "Could not unlock the Semaphore");
2771        return RFAILED;
2772 #endif
2773    }
2774 #endif
2775    
2776    return ROK;
2777 } /* SDestroySTsk */
2778
2779
2780 \f
2781 /*
2782 *
2783 *       Fun:   Attach TAPA task
2784 *
2785 *       Desc:  This function is used to attach a TAPA task to a
2786 *              system task. The system task will begin to execute
2787 *              the TAPA task.
2788 *
2789 *       Ret:   ROK      - ok
2790 *              RFAILED  - failed, general (optional)
2791 *              ROUTRES  - failed, out of resources (optional)
2792 *
2793 *       Notes:
2794 *
2795 *       File:  ss_task.c
2796 *
2797 */
2798 /* ss029.103: addition: procId added */ 
2799 #ifndef SS_MULTIPLE_PROCS
2800
2801 S16 SAttachTTsk
2802 (
2803 Ent ent,                        /* entity ID of the task */
2804 Inst inst,                      /* instance ID of the task */
2805 SSTskId sTskId                  /* system task to use */
2806 )
2807
2808 #else /* SS_MULTIPLE_PROCS */
2809
2810 S16 SAttachTTsk
2811 (
2812 ProcId proc,                    /* processor ID of the task */
2813 Ent ent,                        /* entity ID of the task */
2814 Inst inst,                      /* instance ID of the task */
2815 SSTskId sTskId                  /* system task to use */
2816 )
2817 #endif /* SS_MULTIPLE_PROCS */
2818 {
2819    S16 ret;
2820    S16 i;
2821    SsIdx idx;
2822    SsSTskEntry *sTsk;
2823 /* ss029.103: addition: multiple procIds related changes */ 
2824 #ifdef SS_MULTIPLE_PROCS
2825    uint16_t procIdIdx;
2826 #endif /* SS_MULTIPLE_PROCS */
2827 #ifdef SS_MULTICORE_SUPPORT
2828    SsTTskEntry *tTsk;
2829 #ifdef SS_MULTIPLE_PROCS
2830    void *xxCb;
2831 #endif /* SS_MULTIPLE_PROCS */
2832 #endif
2833
2834
2835
2836
2837 #if (ERRCLASS & ERRCLS_INT_PAR)
2838    /* check entity and instance range */
2839 /* ss029.103: addition: multiple procIds related changes */ 
2840 #ifdef SS_MULTIPLE_PROCS
2841    /* check proc, entity and instance range */
2842    if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) ||  (inst >= SS_MAX_INST))
2843    {
2844       SSLOGERROR(ERRCLS_INT_PAR, ESS463, ERRZERO, "Invalid processor/entity/instance");
2845       return RFAILED;
2846    }
2847 #else /* SS_MULTIPLE_PROCS */
2848    /* check entity and instance range */
2849    if (ent >= SS_MAX_ENT ||  inst >= SS_MAX_INST)
2850    {
2851       SSLOGERROR(ERRCLS_INT_PAR, ESS464, ERRZERO, "Invalid entity/instance");
2852       return RFAILED;
2853    }
2854 #endif /* SS_MULTIPLE_PROCS */
2855
2856    /* check the system task index */
2857    if ((SsIdx)sTskId >= SS_MAX_STSKS)
2858    {
2859       SSLOGERROR(ERRCLS_INT_PAR, ESS465, (ErrVal) sTskId,
2860                   "Invalid system task ID");
2861       return RFAILED;
2862    }
2863 #endif
2864
2865 /* ss029.103: addition: multiple procIds related changes */ 
2866 #ifdef SS_MULTIPLE_PROCS
2867    /* get the proc id idx */
2868    procIdIdx = SGetProcIdIdx(proc);
2869
2870    if (procIdIdx == SS_INV_PROCID)
2871    {
2872 #if (ERRCLASS & ERRCLS_DEBUG)
2873       SSLOGERROR(ERRCLS_DEBUG, ESS466, ERRZERO,
2874                              "Could not find proc id index");
2875 #endif
2876       return RFAILED;
2877    }
2878 #endif /* SS_MULTIPLE_PROCS */
2879
2880    /* lock the system task table */
2881    ret = SLock(&osCp.sTskTblLock);
2882    if (ret != ROK)
2883    {
2884
2885 #if (ERRCLASS & ERRCLS_DEBUG)
2886       SSLOGERROR(ERRCLS_DEBUG, ESS467, (ErrVal) ret,
2887                      "Could not lock system task table");
2888 #endif
2889
2890       return RFAILED;
2891    }
2892
2893
2894    sTsk = &osCp.sTskTbl[(SsIdx)sTskId];
2895
2896
2897 #if (ERRCLASS & ERRCLS_INT_PAR)
2898    /* verify that this system task exists */
2899    if (sTsk->used == FALSE)
2900    {
2901
2902   /* ss006.13: addition */
2903       if ( SUnlock(&osCp.sTskTblLock) != ROK)
2904       {
2905 #if (ERRCLASS & ERRCLS_DEBUG)
2906           SSLOGERROR(ERRCLS_DEBUG, ESS468, ERRZERO,
2907                      "Could not give the Semaphore");
2908           return RFAILED;
2909 #endif
2910       }
2911
2912       SSLOGERROR(ERRCLS_INT_PAR, ESS469, (ErrVal) sTskId,
2913                      "Unknown system task ID");
2914       return RFAILED;
2915    }
2916 #endif
2917
2918
2919    /* lock the system task entry */
2920    if (!SS_CHECK_CUR_STSK(sTsk))
2921    {
2922       ret = SLock(&sTsk->lock);
2923       if (ret != ROK)
2924       {
2925
2926   /* ss006.13: addition */
2927         if ( SUnlock(&osCp.sTskTblLock) != ROK)
2928         {
2929 #if (ERRCLASS & ERRCLS_DEBUG)
2930             SSLOGERROR(ERRCLS_DEBUG, ESS470, ERRZERO,
2931                      "Could not give the Semaphore");
2932             return RFAILED;
2933 #endif
2934         }
2935
2936 #if (ERRCLASS & ERRCLS_DEBUG)
2937          SSLOGERROR(ERRCLS_DEBUG, ESS471, (ErrVal) ret,
2938                         "Could not lock system task entry");
2939 #endif
2940
2941          return RFAILED;
2942       }
2943    }
2944
2945
2946    /* if this system task is about to die, we don't attach */
2947    if (sTsk->termPend == TRUE)
2948    {
2949       if (!SS_CHECK_CUR_STSK(sTsk))
2950       {
2951
2952   /* ss006.13: addition */
2953         if ( SUnlock(&sTsk->lock) != ROK)
2954         {
2955 #if (ERRCLASS & ERRCLS_DEBUG)
2956             SSLOGERROR(ERRCLS_DEBUG, ESS472, ERRZERO,
2957                      "Could not give the Semaphore");
2958             return RFAILED;
2959 #endif
2960         }
2961       }
2962
2963   /* ss006.13: addition */
2964       if ( SUnlock(&osCp.sTskTblLock) != ROK)
2965       {
2966 #if (ERRCLASS & ERRCLS_DEBUG)
2967           SSLOGERROR(ERRCLS_DEBUG, ESS473, ERRZERO,
2968                      "Could not give the Semaphore");
2969           return RFAILED;
2970 #endif
2971       }
2972
2973       return RFAILED;
2974    }
2975
2976
2977    /* lock the TAPA task table */
2978    SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
2979    if (ret != ROK)
2980    {
2981       if (!SS_CHECK_CUR_STSK(sTsk))
2982       {
2983
2984   /* ss006.13: addition */
2985         if ( SUnlock(&sTsk->lock) != ROK)
2986         {
2987 #if (ERRCLASS & ERRCLS_DEBUG)
2988             SSLOGERROR(ERRCLS_DEBUG, ESS474, ERRZERO,
2989                      "Could not give the Semaphore");
2990             return RFAILED;
2991 #endif
2992         }
2993       }
2994
2995
2996   /* ss006.13: addition */
2997       if ( SUnlock(&osCp.sTskTblLock) != ROK)
2998       {
2999 #if (ERRCLASS & ERRCLS_DEBUG)
3000           SSLOGERROR(ERRCLS_DEBUG, ESS475, ERRZERO,
3001                      "Could not give the Semaphore");
3002           return RFAILED;
3003 #endif
3004       }
3005
3006 #if (ERRCLASS & ERRCLS_DEBUG)
3007       SSLOGERROR(ERRCLS_DEBUG, ESS476, ERRZERO,
3008                      "Could not lock TAPA task table");
3009 #endif
3010
3011       return RFAILED;
3012    }
3013
3014
3015    /* get the index of the TAPA task entry in the table */
3016 /* ss029.103: addition: multiple procIds related changes */ 
3017 #ifdef SS_MULTIPLE_PROCS
3018    idx = osCp.tTskIds[procIdIdx][ent][inst];
3019 #else /* SS_MULTIPLE_PROCS */
3020    idx = osCp.tTskIds[ent][inst];
3021 #endif /* SS_MULTIPLE_PROCS */
3022
3023 #if (ERRCLASS & ERRCLS_INT_PAR)
3024    /* check out the TAPA task ID */
3025    if (idx == SS_TSKNC)
3026    {
3027       SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3028       if (!SS_CHECK_CUR_STSK(sTsk))
3029       {
3030
3031   /* ss006.13: addition */
3032         if ( SUnlock(&sTsk->lock) != ROK)
3033         {
3034 #if (ERRCLASS & ERRCLS_DEBUG)
3035             SSLOGERROR(ERRCLS_DEBUG, ESS477, ERRZERO,
3036                      "Could not give the Semaphore");
3037             return RFAILED;
3038 #endif
3039         }
3040       }
3041
3042   /* ss006.13: addition */
3043       if ( SUnlock(&osCp.sTskTblLock) != ROK)
3044       {
3045 #if (ERRCLASS & ERRCLS_DEBUG)
3046           SSLOGERROR(ERRCLS_DEBUG, ESS478, ERRZERO,
3047                      "Could not give the Semaphore");
3048           return RFAILED;
3049 #endif
3050       }
3051
3052       SSLOGERROR(ERRCLS_INT_PAR, ESS479, ERRZERO, "Unknown task");
3053       return RFAILED;
3054    }
3055 #endif
3056
3057
3058    /* verify that this TAPA task is not already attached */
3059    if (osCp.tTskTbl[idx].sTsk != NULLP)
3060    {
3061       SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3062       if (!SS_CHECK_CUR_STSK(sTsk))
3063       {
3064
3065   /* ss006.13: addition */
3066         if ( SUnlock(&sTsk->lock) != ROK)
3067         {
3068 #if (ERRCLASS & ERRCLS_DEBUG)
3069             SSLOGERROR(ERRCLS_DEBUG, ESS480, ERRZERO,
3070                      "Could not give the Semaphore");
3071             return RFAILED;
3072 #endif
3073         }
3074       }
3075
3076   /* ss006.13: addition */
3077       if ( SUnlock(&osCp.sTskTblLock) != ROK)
3078       {
3079 #if (ERRCLASS & ERRCLS_DEBUG)
3080           SSLOGERROR(ERRCLS_DEBUG, ESS481, ERRZERO,
3081                      "Could not give the Semaphore");
3082           return RFAILED;
3083 #endif
3084       }
3085
3086       return RFAILED;
3087    }
3088
3089
3090    /* verify that there is space for another TAPA task */
3091    if (sTsk->numTTsks == SS_MAX_TTSKS)
3092    {
3093       SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3094       if (!SS_CHECK_CUR_STSK(sTsk))
3095       {
3096
3097   /* ss006.13: addition */
3098         if ( SUnlock(&sTsk->lock) != ROK)
3099         {
3100 #if (ERRCLASS & ERRCLS_DEBUG)
3101             SSLOGERROR(ERRCLS_DEBUG, ESS482, ERRZERO,
3102                      "Could not give the Semaphore");
3103             return RFAILED;
3104 #endif
3105         }
3106       }
3107
3108   /* ss006.13: addition */
3109       if ( SUnlock(&osCp.sTskTblLock) != ROK)
3110       {
3111 #if (ERRCLASS & ERRCLS_DEBUG)
3112           SSLOGERROR(ERRCLS_DEBUG, ESS483, ERRZERO,
3113                      "Could not give the Semaphore");
3114           return RFAILED;
3115 #endif
3116       }
3117
3118       return (ROUTRES);
3119    }
3120
3121
3122    /*  Find place for this TAPA task in the system task's list
3123     *  of TAPA tasks to run. Plug in this TAPA task.
3124     */
3125    for (i = 0;  i < SS_MAX_TTSKS;  i++)
3126    {
3127       if (sTsk->tTsks[i] == SS_INVALID_IDX)
3128       {
3129          sTsk->tTsks[i] = idx;
3130          sTsk->numTTsks++;
3131          break;
3132       }
3133    }
3134
3135
3136    /* Fill in the system task info in the TAPA task entry, so
3137     *  the TAPA task knows who's running it.
3138     */
3139    osCp.tTskTbl[idx].sTsk = sTsk;
3140 #ifdef SS_MULTICORE_SUPPORT
3141    tTsk = &osCp.tTskTbl[idx];
3142    if(tTsk->initTsk != NULLP)
3143    {
3144 #ifndef SS_MULTIPLE_PROCS 
3145        (Void)(tTsk->initTsk)(tTsk->ent, tTsk->inst, sTsk->region, PWR_UP);
3146 #else
3147           /* retrieve proc id index in the proc id table */
3148         procIdIdx = SGetProcIdIdx(tTsk->proc);
3149
3150         /* Check whether the proc id exist in the proc id table */
3151         if (procIdIdx == SS_INV_PROCID_IDX)
3152         {
3153 #if (ERRCLASS & ERRCLS_INT_PAR)
3154                 SSLOGERROR(ERRCLS_INT_PAR, ESS389, ERRZERO,
3155                      "Could not find proc table index");
3156 #endif
3157
3158               return RFAILED;
3159         }
3160        (Void)(tTsk->initTsk)(tTsk->proc, tTsk->ent, tTsk->inst, sTsk->region, PWR_UP, &xxCb);
3161        /* 
3162         * store the control block. The control block may be NULL in some cases
3163         */
3164        idx = osCp.tTskIds[procIdIdx][tTsk->ent][tTsk->inst];
3165 #if (ERRCLASS & ERRCLS_INT_PAR)
3166        if ( xxCb == NULLP )
3167        {
3168                 SSLOGERROR(ERRCLS_INT_PAR, ERRZERO, ERRZERO,
3169                                          "Null pointer");
3170        }
3171 #endif
3172         osCp.tTskTbl[idx].xxCb = xxCb;
3173 #endif /* SS_MULTIPLE_PROCS */
3174    }
3175 #endif /* SS_MULTICORE_SUPPORT */
3176
3177
3178    /* call the implementation to do anything implementation-specific */
3179    ret = ssdAttachTTsk(&osCp.tTskTbl[idx]);
3180
3181
3182    /* unlock the tables; we're done */
3183    SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3184    if (!SS_CHECK_CUR_STSK(sTsk))
3185    {
3186
3187   /* ss006.13: addition */
3188       if ( SUnlock(&sTsk->lock) != ROK)
3189       {
3190 #if (ERRCLASS & ERRCLS_DEBUG)
3191           SSLOGERROR(ERRCLS_DEBUG, ESS484, ERRZERO,
3192                      "Could not give the Semaphore");
3193           return RFAILED;
3194 #endif
3195       }
3196    }
3197
3198   /* ss006.13: addition */
3199    if ( SUnlock(&osCp.sTskTblLock) != ROK)
3200    {
3201 #if (ERRCLASS & ERRCLS_DEBUG)
3202         SSLOGERROR(ERRCLS_DEBUG, ESS485, ERRZERO,
3203                      "Could not give the Semaphore");
3204         return RFAILED;
3205 #endif
3206    }
3207
3208
3209    /* If the implementation didn't succeed, we have to undo everything.
3210     *  We call SDetachTTsk, to make it easier.
3211     */
3212    if (ret != ROK)
3213    {
3214 /* ss029.103: addition: multiple procIds related changes */ 
3215 #ifdef SS_MULTIPLE_PROCS
3216       SDetachTTsk(proc, ent, inst);
3217 #else /* SS_MULTIPLE_PROCS */
3218       SDetachTTsk(ent, inst);
3219 #endif /* SS_MULTIPLE_PROCS */
3220       return RFAILED;
3221    }
3222
3223
3224    return ROK;
3225 } /* SAttachTTsk */
3226
3227 \f
3228 /*
3229 *
3230 *       Fun:   Detach TAPA task
3231 *
3232 *       Desc:  This function is used to detach a TAPA task from a
3233 *              system task. The system task will stop executing
3234 *              the TAPA task.
3235 *
3236 *       Ret:   ROK      - ok
3237 *              RFAILED  - failed, general (optional)
3238 *
3239 *       Notes:
3240 *
3241 *       File:  ss_task.c
3242 *
3243 */
3244 /* ss029.103: addition: procId added */ 
3245 #ifndef SS_MULTIPLE_PROCS
3246
3247 S16 SDetachTTsk
3248 (
3249 Ent ent,                        /* entity ID of the task */
3250 Inst inst                       /* instance ID of the task */
3251 )
3252
3253 #else /* SS_MULTIPLE_PROCS */
3254
3255 S16 SDetachTTsk
3256 (
3257 ProcId proc,                    /* processor ID of the task */
3258 Ent ent,                        /* entity ID of the task */
3259 Inst inst                       /* instance ID of the task */
3260 )
3261
3262 #endif /* SS_MULTIPLE_PROCS */
3263
3264 {
3265    S16 ret;
3266    S16 i;
3267    SsIdx idx;
3268    SsTTskEntry *tTsk;
3269    SsSTskEntry *sTsk;
3270 /* ss029.103: addition: multiple procIds related changes */ 
3271 #ifdef SS_MULTIPLE_PROCS
3272    uint16_t procIdIdx;
3273 #endif /* SS_MULTIPLE_PROCS */
3274
3275
3276
3277 #if (ERRCLASS & ERRCLS_INT_PAR)
3278    /* check entity and instance ranges */
3279 /* ss029.103: addition: multiple procIds related changes */ 
3280 #ifdef SS_MULTIPLE_PROCS
3281    /* check entity and instance ranges */
3282    if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) ||  (inst >= SS_MAX_INST))
3283    {
3284       SSLOGERROR(ERRCLS_INT_PAR, ESS486, ERRZERO, "Invalid processor/entity/instance");
3285       return RFAILED;
3286    }
3287 #else /* SS_MULTIPLE_PROCS */
3288    /* check entity and instance ranges */
3289    if (ent >= SS_MAX_ENT ||  inst >= SS_MAX_INST)
3290    {
3291       SSLOGERROR(ERRCLS_INT_PAR, ESS487, ERRZERO, "Invalid entity/instance");
3292       return RFAILED;
3293    }
3294 #endif /* SS_MULTIPLE_PROCS */
3295 #endif
3296
3297 /* ss029.103: addition: multiple procIds related changes */ 
3298 #ifdef SS_MULTIPLE_PROCS
3299    /* get the proc id idx */
3300    procIdIdx = SGetProcIdIdx(proc);
3301
3302    if (procIdIdx == SS_INV_PROCID)
3303    {
3304 #if (ERRCLASS & ERRCLS_DEBUG)
3305       SSLOGERROR(ERRCLS_DEBUG, ESS488, ERRZERO,
3306                              "Could not find proc id index");
3307 #endif
3308       return RFAILED;
3309    }
3310 #endif /* SS_MULTIPLE_PROCS */
3311
3312
3313    /* Lock the system task table. We do this to prevent
3314     *  the system task from being destroyed and confusing
3315     *  matters before we detach.
3316     */
3317    ret = SLock(&osCp.sTskTblLock);
3318    if (ret != ROK)
3319    {
3320
3321 #if (ERRCLASS & ERRCLS_DEBUG)
3322       SSLOGERROR(ERRCLS_DEBUG, ESS489, (ErrVal) ret,
3323                      "Could not lock system task table");
3324 #endif
3325
3326       return RFAILED;
3327    }
3328
3329
3330    /* lock the TAPA task table */
3331    SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
3332    if (ret != ROK)
3333    {
3334
3335   /* ss006.13: addition */
3336     if ( SUnlock(&osCp.sTskTblLock) != ROK)
3337     {
3338 #if (ERRCLASS & ERRCLS_DEBUG)
3339         SSLOGERROR(ERRCLS_DEBUG, ESS490, ERRZERO,
3340                      "Could not give the Semaphore");
3341         return RFAILED;
3342 #endif
3343     }
3344
3345 #if (ERRCLASS & ERRCLS_DEBUG)
3346       SSLOGERROR(ERRCLS_DEBUG, ESS491, ERRZERO,
3347                      "Could not lock TAPA task table");
3348 #endif
3349
3350       return RFAILED;
3351    }
3352
3353
3354 #if (ERRCLASS & ERRCLS_INT_PAR)
3355    /* Check this TAPA task. We do this with the TAPA task table
3356     *  locked, coz we don't want the task to be found, but then
3357     *  be deregistered before we lock
3358     */
3359 /* ss029.103: addition: multiple procIds related changes */ 
3360 #ifdef SS_MULTIPLE_PROCS
3361    if (osCp.tTskIds[procIdIdx][ent][inst] == SS_TSKNC)
3362 #else /* SS_MULTIPLE_PROCS */
3363    if (osCp.tTskIds[ent][inst] == SS_TSKNC)
3364 #endif /* SS_MULTIPLE_PROCS */
3365    {
3366       SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3367
3368   /* ss006.13: addition */
3369      if ( SUnlock(&osCp.sTskTblLock) != ROK)
3370      {
3371 #if (ERRCLASS & ERRCLS_DEBUG)
3372         SSLOGERROR(ERRCLS_DEBUG, ESS492, ERRZERO,
3373                      "Could not give the Semaphore");
3374         return RFAILED;
3375 #endif
3376      }
3377
3378       SSLOGERROR(ERRCLS_INT_PAR, ESS493, ERRZERO, "Unknown task");
3379       return RFAILED;
3380    }
3381 #endif
3382
3383 /* ss029.103: addition: multiple procIds related changes */ 
3384 #ifdef SS_MULTIPLE_PROCS
3385    idx = osCp.tTskIds[procIdIdx][ent][inst];
3386 #else /* SS_MULTIPLE_PROCS */
3387    idx = osCp.tTskIds[ent][inst];
3388 #endif /* SS_MULTIPLE_PROCS */
3389
3390    tTsk = &osCp.tTskTbl[idx];
3391
3392    /* check if this TAPA task is attached to anyone */
3393    if (tTsk->sTsk == NULLP)
3394    {
3395       SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3396
3397   /* ss006.13: addition */
3398      if ( SUnlock(&osCp.sTskTblLock) != ROK)
3399      {
3400 #if (ERRCLASS & ERRCLS_DEBUG)
3401         SSLOGERROR(ERRCLS_DEBUG, ESS494, ERRZERO,
3402                      "Could not give the Semaphore");
3403         return RFAILED;
3404 #endif
3405      }
3406       return ROK;
3407    }
3408
3409
3410    /* we get the system task entry out */
3411    sTsk = tTsk->sTsk;
3412
3413
3414    /* We unlock the TAPA task table here, and then re-lock it later
3415     *  because of lock sequencing--we have to lock the system task
3416     *  entry first, and then the TAPA task table. Note, the system
3417     *  task table is locked, so nobody can sneak in and destroy the
3418     *  system task while we're doing this.
3419     */
3420    SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3421
3422
3423    /* lock the system task entry */
3424    if (!SS_CHECK_CUR_STSK(sTsk))
3425    {
3426       ret = SLock(&sTsk->lock);
3427       if (ret != ROK)
3428       {
3429
3430   /* ss006.13: addition */
3431        if ( SUnlock(&osCp.sTskTblLock) != ROK)
3432        {
3433 #if (ERRCLASS & ERRCLS_DEBUG)
3434           SSLOGERROR(ERRCLS_DEBUG, ESS495, ERRZERO,
3435                      "Could not give the Semaphore");
3436           return RFAILED;
3437 #endif
3438        }
3439
3440 #if (ERRCLASS & ERRCLS_DEBUG)
3441          SSLOGERROR(ERRCLS_DEBUG, ESS496, (ErrVal) ret,
3442                         "Could not lock system task entry");
3443 #endif
3444
3445          return RFAILED;
3446       }
3447    }
3448
3449
3450    /* now we lock the TAPA task table */
3451    SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
3452    if (ret != ROK)
3453    {
3454
3455   /* ss006.13: addition */
3456       if ( SUnlock(&sTsk->lock) != ROK)
3457       {
3458 #if (ERRCLASS & ERRCLS_DEBUG)
3459           SSLOGERROR(ERRCLS_DEBUG, ESS497, ERRZERO,
3460                      "Could not give the Semaphore");
3461           return RFAILED;
3462 #endif
3463       }
3464       if ( SUnlock(&osCp.sTskTblLock) != ROK)
3465       {
3466 #if (ERRCLASS & ERRCLS_DEBUG)
3467           SSLOGERROR(ERRCLS_DEBUG, ESS498, ERRZERO,
3468                      "Could not give the Semaphore");
3469           return RFAILED;
3470 #endif
3471       }
3472
3473 #if (ERRCLASS & ERRCLS_DEBUG)
3474       SSLOGERROR(ERRCLS_DEBUG, ESS499, ERRZERO,
3475                      "Could not lock TAPA task table");
3476 #endif
3477
3478       return RFAILED;
3479    }
3480
3481
3482    /* Now, we can safely update both the system task entry
3483     *  and the TAPA task entry. First, we update the TAPA
3484     *  task entry--nobody is running it now.
3485     */
3486    tTsk->sTsk = NULLP;
3487
3488
3489    /*  Remove this TAPA task from the system task's list of
3490     *  TAPA tasks to run.
3491     */
3492    for (i = 0;  i < SS_MAX_TTSKS;  i++)
3493    {
3494       if (sTsk->tTsks[i] == idx)
3495       {
3496          sTsk->tTsks[i] = SS_INVALID_IDX;
3497          sTsk->numTTsks--;
3498          break;
3499       }
3500    }
3501
3502
3503    /* call the implementation to do anything it needs to */
3504    ret = ssdDetachTTsk(tTsk);
3505
3506
3507    /* unlock the TAPA task table */
3508    SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3509
3510    /* unlock the system task entry */
3511    if (!SS_CHECK_CUR_STSK(sTsk))
3512    {
3513
3514   /* ss006.13: addition */
3515       if ( SUnlock(&sTsk->lock) != ROK)
3516       {
3517 #if (ERRCLASS & ERRCLS_DEBUG)
3518           SSLOGERROR(ERRCLS_DEBUG, ESS500, ERRZERO,
3519                      "Could not give the Semaphore");
3520           return RFAILED;
3521 #endif
3522       }
3523    }
3524
3525    /* unlock the system task table */
3526
3527   /* ss006.13: addition */
3528       if ( SUnlock(&osCp.sTskTblLock) != ROK)
3529       {
3530 #if (ERRCLASS & ERRCLS_DEBUG)
3531           SSLOGERROR(ERRCLS_DEBUG, ESS501, ERRZERO,
3532                      "Could not give the Semaphore");
3533           return RFAILED;
3534 #endif
3535       }
3536
3537
3538    /* If the implementation couldn't detach the task, we just
3539     *  return an error, nothing else we can do.
3540     */
3541    if (ret != ROK)
3542    {
3543       return RFAILED;
3544    }
3545
3546
3547    return ROK;
3548 } /* SDetachTTsk */
3549
3550 \f
3551 /*
3552 *
3553 *       Fun:   Post a message to a task
3554 *
3555 *       Desc:  This function is used to post a message to a TAPA
3556 *              task. The message is delivered to the demand queue
3557 *              of the system task that is running the specified
3558 *              destination task.
3559 *
3560 *       Ret:   ROK      - ok
3561 *              RFAILED  - failed, general (optional)
3562 *
3563 *       Notes:
3564 *
3565 *       File:  ss_task.c
3566 *
3567 */
3568 S16 SPstTsk
3569 (
3570 Pst *pst,                       /* post information */
3571 Buffer *mBuf                    /* message to post */
3572 )
3573 {
3574    S16 r;
3575    S16 i;
3576 #if (defined(SS_DRVR_SUPPORT))
3577    S16 j;
3578 #endif
3579    SsIdx dstIdx;
3580    SsIdx srcIdx;
3581    Prior prior;
3582    SsTTskEntry *tTsk;
3583    SsMsgInfo *msgInfo;
3584 #if (defined(SS_DRVR_SUPPORT)  ||  defined(SS_RTR_SUPPORT))
3585    Pst nPst;
3586 #endif
3587 #ifdef SS_DRVR_SUPPORT
3588    Bool nPstUsed = FALSE;
3589 #endif
3590 #if (defined(SS_RTR_SUPPORT))
3591    Route rte;
3592 #endif
3593 /* ss029.103: addition: multiple procIds related changes */ 
3594 #ifdef SS_MULTIPLE_PROCS
3595    uint16_t srcProcIdIdx;
3596    uint16_t dstProcIdIdx;
3597 #endif /* SS_MULTIPLE_PROCS */
3598 /*ss004.301: Cavium changes */
3599 #ifdef SS_SEUM_CAVIUM
3600    Buffer  *wqBuf;
3601    S16     ret;
3602    cvmx_wqe_t *workPtr;
3603 #endif /* SS_SEUM_CAVIUM */
3604
3605         S16  retValue = 0; 
3606    Pst  tempPst;
3607
3608 #ifdef MSPD_MLOG_NEW
3609    uint32_t t = MacGetTick();
3610 #endif
3611  
3612
3613
3614 #if (ERRCLASS & ERRCLS_INT_PAR)
3615    /* check the message buffer */
3616    if (mBuf == NULLP)
3617    {
3618       SSLOGERROR(ERRCLS_INT_PAR, ESS502, ERRZERO, "Invalid message buffer");
3619       return RFAILED;
3620    }
3621
3622    /* check the pst structure */
3623    if (pst == NULLP)
3624    {
3625       SPutMsg(mBuf);
3626       SSLOGERROR(ERRCLS_INT_PAR, ESS503, ERRZERO, "Null pointer");
3627       return RFAILED;
3628    }
3629    /* ss021.103 - Addition to check for valid route */
3630    /* ss023.103 - Modification to fix bug in route validation */
3631    /* check the route */
3632    if (pst->route == RTENC)
3633    {
3634       SPutMsg(mBuf);
3635       SSLOGERROR(ERRCLS_INT_PAR, ESS504, ERRZERO, "No route defined");
3636       return RFAILED;
3637    }
3638 #endif
3639
3640 #ifndef TENB_RTLIN_CHANGES
3641    /* lock the TAPA task table */
3642    SS_ACQUIRE_SEMA(&osCp.tTskTblSem, r);
3643    if (r != ROK)
3644    {
3645       SPutMsg(mBuf);
3646
3647 #if (ERRCLASS & ERRCLS_DEBUG)
3648       SSLOGERROR(ERRCLS_DEBUG, ESS505, ERRZERO,
3649                      "Could not lock TAPA task table");
3650 #endif
3651
3652       return RFAILED;
3653    }
3654 #endif
3655
3656 #if (ERRCLASS & ERRCLS_INT_PAR)
3657 /* ss029.103: addition: multiple procIds related changes */ 
3658 #ifdef SS_MULTIPLE_PROCS
3659    if (pst->srcProcId == SS_INV_PROCID || pst->srcEnt >= SS_MAX_ENT       ||
3660        pst->srcInst >= SS_MAX_INST     || pst->dstProcId == SS_INV_PROCID ||
3661        pst->dstEnt >= SS_MAX_ENT       ||  pst->dstInst >= SS_MAX_INST)
3662 #else /* SS_MULTIPLE_PROCS */
3663    if (pst->srcEnt >= SS_MAX_ENT       ||  pst->srcInst >= SS_MAX_INST    ||
3664        pst->dstEnt >= SS_MAX_ENT       ||  pst->dstInst >= SS_MAX_INST)
3665 #endif /* SS_MULTIPLE_PROCS */
3666    {
3667 #ifndef TENB_RTLIN_CHANGES
3668  /* ss006.13: addition */
3669       if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3670       {
3671 #if (ERRCLASS & ERRCLS_DEBUG)
3672       SSLOGERROR(ERRCLS_DEBUG, ESS506, ERRZERO,
3673                      "Could not release the semaphore");
3674       return RFAILED;
3675 #endif
3676       }
3677 #endif
3678
3679       SPutMsg(mBuf);
3680
3681       SSLOGERROR(ERRCLS_INT_PAR, ESS507, ERRZERO,
3682                   "Invalid source/destination entity/instance");
3683
3684       return RFAILED;
3685    }
3686 #endif
3687
3688    /* ss019.103 - modified for use with message router in virtual/physical
3689     * configuration */
3690
3691 #ifdef SS_RTR_SUPPORT
3692    /* check if we have a router task registered for this route */
3693    if (pst->route < RTENC  &&  osCp.rtrTskTbl[pst->route] != NULLP)
3694    {
3695       /* copy the Pst structure into a local duplicate */
3696       for (i = 0;  i < (S16)sizeof(Pst);  i++)
3697       {
3698          *(((uint8_t *)(&nPst)) + i) = *(((uint8_t *) pst) + i);
3699       }
3700       pst = &nPst;
3701 #ifdef SS_DRVR_SUPPORT
3702       nPstUsed = TRUE;
3703 #endif
3704
3705       /* lock the router task entry */
3706       rte = pst->route;
3707       r = SLock(&osCp.rtrTskLocks[rte]);
3708       if (r != ROK)
3709       {
3710  /* ss006.13: addition */
3711 #ifndef TENB_RTLIN_CHANGES
3712          if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3713          {
3714 #if (ERRCLASS & ERRCLS_DEBUG)
3715             SSLOGERROR(ERRCLS_DEBUG, ESS508, ERRZERO,
3716                      "Could not release the semaphore");
3717             return RFAILED;
3718 #endif
3719           }
3720 #endif
3721          SPutMsg(mBuf);
3722
3723 #if (ERRCLASS & ERRCLS_DEBUG)
3724          SSLOGERROR(ERRCLS_DEBUG, ESS509, ERRZERO,
3725                      "Could not lock router task entry");
3726 #endif
3727
3728          return RFAILED;
3729       }
3730
3731       /* call the router activation function */
3732       r = (*osCp.rtrTskTbl[rte])(pst, mBuf);
3733
3734       /* unlock the router task entry */
3735
3736   /* ss006.13: addition */
3737       if ( SUnlock(&osCp.rtrTskLocks[rte]) != ROK)
3738       {
3739 #if (ERRCLASS & ERRCLS_DEBUG)
3740           SSLOGERROR(ERRCLS_DEBUG, ESS510, ERRZERO,
3741                      "Could not give the Semaphore");
3742           return RFAILED;
3743 #endif
3744       }
3745
3746       if (r == RFAILED  ||  r == ROKIGNORE)
3747       {
3748  /* ss006.13: addition */
3749 #ifndef TENB_RTLIN_CHANGES
3750          if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3751          {
3752 #if (ERRCLASS & ERRCLS_DEBUG)
3753             SSLOGERROR(ERRCLS_DEBUG, ESS511, ERRZERO,
3754                      "Could not release the semaphore");
3755             return RFAILED;
3756 #endif
3757           }
3758 #endif
3759          return ((r == RFAILED) ? RFAILED : ROK);
3760       }
3761    }
3762 #endif  /* SS_RTR_SUPPORT */
3763
3764 /* ss029.103: addition: multiple procIds related changes */ 
3765 #ifdef SS_MULTIPLE_PROCS
3766
3767    /* get proc id index */
3768    srcProcIdIdx = SGetProcIdIdx(pst->srcProcId);
3769    dstProcIdIdx = SGetProcIdIdx(pst->dstProcId);
3770
3771    if (srcProcIdIdx != SS_INV_PROCID_IDX)
3772       srcIdx = osCp.tTskIds[srcProcIdIdx][pst->srcEnt][pst->srcInst];
3773
3774    if (dstProcIdIdx != SS_INV_PROCID_IDX)
3775       dstIdx = osCp.tTskIds[dstProcIdIdx][pst->dstEnt][pst->dstInst];
3776
3777    if (((srcProcIdIdx != SS_INV_PROCID_IDX) && (srcIdx == SS_TSKNC)) || 
3778        ((dstProcIdIdx != SS_INV_PROCID_IDX) && (dstIdx == SS_TSKNC)))
3779    {
3780 #ifndef TENB_RTLIN_CHANGES
3781       if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3782       {
3783 #if (ERRCLASS & ERRCLS_DEBUG)
3784       SSLOGERROR(ERRCLS_DEBUG, ESS512, ERRZERO,
3785                      "Could not release the semaphore");
3786       return RFAILED;
3787 #endif
3788       }
3789 #endif
3790
3791       SPutMsg(mBuf);
3792
3793 #if (ERRCLASS & ERRCLS_DEBUG)
3794       SSLOGERROR(ERRCLS_DEBUG, ESS513, ERRZERO, "Unknown task");
3795 #endif
3796
3797       return RFAILED;
3798    }
3799
3800 #else /* SS_MULTIPLE_PROCS */
3801    /* ss019.103 - modified for use with message router in virtual/physical
3802     * configuration */
3803
3804    /* get the src and destination task */
3805    srcIdx = osCp.tTskIds[pst->srcEnt][pst->srcInst];
3806    dstIdx = osCp.tTskIds[pst->dstEnt][pst->dstInst];
3807
3808
3809    /* If the source/destination processor ID is local, the
3810     *  source/destination TAPA task must be local.
3811     */
3812    if ((pst->srcProcId == osCp.procId  &&  srcIdx == SS_TSKNC) 
3813       ||  (pst->dstProcId == osCp.procId  &&  dstIdx == SS_TSKNC))
3814    {
3815  /* ss006.13: addition */
3816 #ifndef TENB_RTLIN_CHANGES
3817       if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3818       {
3819 #if (ERRCLASS & ERRCLS_DEBUG)
3820       SSLOGERROR(ERRCLS_DEBUG, ESS514, ERRZERO,
3821                      "Could not release the semaphore");
3822       return RFAILED;
3823 #endif
3824       }
3825 #endif
3826       SPutMsg(mBuf);
3827
3828 #if (ERRCLASS & ERRCLS_DEBUG)
3829       SSLOGERROR(ERRCLS_DEBUG, ESS515, ERRZERO, "Unknown task");
3830 #endif
3831
3832       return RFAILED;
3833    }
3834
3835 #endif /* SS_MULTIPLE_PROCS */
3836
3837 #ifdef SS_DRVR_SUPPORT
3838    /* Check for the destination procId. If it is non-local,
3839     *  we need to find the driver task that will handle this
3840     *  message.
3841     */
3842 /* ss029.103: addition: multiple procIds related changes */ 
3843 #ifdef SS_MULTIPLE_PROCS
3844    if (dstProcIdIdx == SS_INV_PROCID_IDX)
3845 #else /* SS_MULTIPLE_PROCS */
3846    if (pst->dstProcId != osCp.procId)
3847 #endif /* SS_MULTIPLE_PROCS */
3848    {
3849       /*  Need to optimize this search.
3850        */
3851       for (i = 0;  i < SS_MAX_DRVRTSKS;  i++)
3852       {
3853          if (osCp.drvrTskTbl[i].used
3854                &&  pst->dstProcId >= osCp.drvrTskTbl[i].low
3855                &&  pst->dstProcId <= osCp.drvrTskTbl[i].high)
3856          {
3857             /* Copy the Pst structure into a local duplicate if not
3858              *  already done.
3859              */
3860             if (!nPstUsed)
3861             {
3862                for (j = 0;  j < (S16)sizeof(Pst);  j++)
3863                {
3864                   *(((uint8_t *)(&nPst)) + j) = *(((uint8_t *) pst) + j);
3865                }
3866                pst = &nPst;
3867                nPstUsed = TRUE;
3868             }
3869
3870
3871 #ifdef L2_L3_SPLIT           
3872 //if (clusterMode == NET_CLUSTER_MODE)
3873 {
3874 #endif
3875             /* lock the driver task entry */
3876             r = SLock(&osCp.drvrTskTbl[i].lock);
3877             if (r != ROK)
3878             {
3879  /* ss006.13: addition */
3880 #ifndef TENB_RTLIN_CHANGES
3881                if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3882                {
3883 #if (ERRCLASS & ERRCLS_DEBUG)
3884                   SSLOGERROR(ERRCLS_DEBUG, ESS516, ERRZERO,
3885                      "Could not release the semaphore");
3886                   return RFAILED;
3887 #endif
3888                }
3889 #endif
3890                SPutMsg(mBuf);
3891
3892 #if (ERRCLASS & ERRCLS_DEBUG)
3893                SSLOGERROR(ERRCLS_DEBUG, ESS517, ERRZERO,
3894                            "Could not lock driver task entry");
3895 #endif
3896
3897                return RFAILED;
3898             }
3899 #ifdef L2_L3_SPLIT
3900 }
3901 #endif
3902 /*ss014.301 SSI-4GMX specific change*/
3903 #ifndef SS_4GMX_LCORE
3904             CMCHKPKLOG(cmPkInst, osCp.drvrTskTbl[i].channel, mBuf, ESS518, pst);
3905 #endif
3906
3907             (osCp.drvrTskTbl[i].actvTsk)(pst, mBuf);
3908
3909             /* unlock */
3910 #ifdef L2_L3_SPLIT           
3911 //if (clusterMode == NET_CLUSTER_MODE)
3912 {
3913 #endif
3914              /* ss006.13: addition */
3915             if ( SUnlock(&osCp.drvrTskTbl[i].lock) != ROK)
3916             {
3917 #if (ERRCLASS & ERRCLS_DEBUG)
3918               SSLOGERROR(ERRCLS_DEBUG, ESS519, ERRZERO,
3919                      "Could not give the Semaphore");
3920               return RFAILED;
3921 #endif
3922             }
3923 #ifdef L2_L3_SPLIT
3924 }
3925 #endif
3926
3927  /* ss006.13: addition */
3928 #ifndef TENB_RTLIN_CHANGES
3929             if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3930             {
3931 #if (ERRCLASS & ERRCLS_DEBUG)
3932                SSLOGERROR(ERRCLS_DEBUG, ESS520, ERRZERO,
3933                      "Could not release the semaphore");
3934                return RFAILED;
3935 #endif
3936             }
3937 #endif
3938             return ROK;
3939          }
3940       }
3941
3942  /* ss006.13: addition */
3943 #ifndef TENB_RTLIN_CHANGES
3944       if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3945       {
3946 #if (ERRCLASS & ERRCLS_DEBUG)
3947            SSLOGERROR(ERRCLS_DEBUG, ESS521, ERRZERO,
3948                      "Could not release the semaphore");
3949             return RFAILED;
3950 #endif
3951       }
3952 #endif
3953       SPutMsg(mBuf);
3954
3955 #if (ERRCLASS & ERRCLS_DEBUG)
3956       SSLOGERROR(ERRCLS_DEBUG, ESS522, ERRZERO,
3957                   "Could not find a driver task to handle this proc ID");
3958 #endif
3959
3960       return RFAILED;
3961    }
3962 #endif  /* SS_DRVR_SUPPORT */
3963  /* ss002.301 Modifications */
3964    /*  Write the message to the demand queue of the system
3965     *  task which is running the destination task
3966     */
3967    tTsk = &osCp.tTskTbl[dstIdx];
3968
3969    memcpy(&tempPst, pst, sizeof(Pst));
3970    if(tTsk->cbTsk != NULLP)
3971    {
3972       retValue = tTsk->cbTsk(&tempPst,mBuf);
3973                 if(retValue != ROK)
3974                 {
3975 #ifndef TENB_RTLIN_CHANGES
3976               if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3977            {
3978 #if (ERRCLASS & ERRCLS_DEBUG)
3979                 SSLOGERROR(ERRCLS_DEBUG, ESS512, ERRZERO,
3980                      "Could not release the semaphore");
3981                 return RFAILED;
3982 #endif
3983         }
3984 #endif
3985
3986 #if (ERRCLASS & ERRCLS_DEBUG)
3987         SSLOGERROR(ERRCLS_DEBUG, ESS513, ERRZERO, "call back function failed\n");
3988 #endif
3989                         return ROK;
3990                 }
3991 #ifdef SS_MULTIPLE_PROCS
3992                 dstIdx = osCp.tTskIds[dstProcIdIdx][tempPst.dstEnt][tempPst.dstInst];
3993 #else
3994       dstIdx = osCp.tTskIds[tempPst.dstEnt][tempPst.dstInst];
3995 #endif 
3996       tTsk = &osCp.tTskTbl[dstIdx];
3997    }
3998
3999    /* plug the Pst structure into the message information portion */
4000    msgInfo = (SsMsgInfo *) (mBuf->b_rptr);
4001    for (i = 0;  i < (S16 )sizeof(Pst);  i++)
4002       *(((uint8_t *)(&msgInfo->pst)) + i) = *(((uint8_t *) &(tempPst)) + i);
4003
4004 /* ss004.301 : Cavium cahnges */
4005 #ifdef SS_SEUM_CAVIUM
4006    if (pst->dstProcId != osCp.procId)
4007    {
4008       if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4009       {
4010 #if (ERRCLASS & ERRCLS_DEBUG)
4011          SSLOGERROR(ERRCLS_DEBUG, ESS527, ERRZERO,
4012             "Could not release the semaphore");
4013          return RFAILED;
4014 #endif
4015       }
4016
4017       /* Copy the message to the FPA region */
4018       ret = SCpyMsgFpa(mBuf, &wqBuf);
4019       if( ret != ROK )
4020       {
4021          /* No need to free the buffer, its already done in called fun */
4022          return RFAILED;
4023       }
4024
4025       /* Allocate for the mBuf */
4026       /* ss010.301: Cavium 32 bit changes */
4027       workPtr = cvmx_fpa_alloc(SS_CVMX_WQE_POOL);
4028       if( workPtr == NULLP )
4029       {
4030          SPutFpaMsg(wqBuf);
4031          return RFAILED;
4032       }
4033
4034       /* Convert the pointers to physical address */
4035       ret = SConvPtrPhy(&wqBuf);
4036       if( ret != ROK )
4037       {
4038          SPutFpaMsg(wqBuf);
4039          return RFAILED;
4040       }
4041
4042       /* Assign the values for work ptr */
4043       workPtr->qos      = 0;
4044       workPtr->grp      = pst->dstProcId;
4045       workPtr->tag_type = CVMX_POW_TAG_TYPE_NULL;
4046       workPtr->tag      = SS_CVMX_MBUF_TAG;
4047
4048       workPtr->packet_ptr.ptr = (Void*)wqBuf;
4049
4050       cvmx_pow_work_submit(workPtr, workPtr->tag, workPtr->tag_type, \
4051             workPtr->qos, workPtr->grp);
4052
4053       return ROK;
4054    }
4055 #endif /* SS_SEUM_CAVIUM */
4056
4057
4058    /*  Write the message to the demand queue of the system
4059     *  task which is running the destination task
4060     */
4061    tTsk = &osCp.tTskTbl[dstIdx];
4062    prior = tTsk->tskPrior;
4063
4064    if (tTsk->sTsk == NULLP)
4065    {
4066  /* ss006.13: addition */
4067 #ifndef TENB_RTLIN_CHANGES
4068       if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4069       {
4070 #if (ERRCLASS & ERRCLS_DEBUG)
4071            SSLOGERROR(ERRCLS_DEBUG, ESS523, ERRZERO,
4072                      "Could not release the semaphore");
4073             return RFAILED;
4074 #endif
4075       }
4076 #endif
4077       SPutMsg(mBuf);
4078
4079 #if (ERRCLASS & ERRCLS_DEBUG)
4080       SSLOGERROR(ERRCLS_DEBUG, ESS524, (ErrVal) 0,
4081                  "Destination TAPA task is not attached");
4082 #endif
4083
4084       return RFAILED;
4085    }
4086
4087 #ifdef SS_LOCKLESS_MEMORY
4088    msgInfo->region = tTsk->sTsk->region;
4089    msgInfo->pst.region = tTsk->sTsk->region;
4090 #endif /* SS_LOCKLESS_MEMORY */
4091
4092 /*ss014.301 SSI-4GMX specific changes*/   
4093 #ifndef SS_4GMX_LCORE
4094    r = ssDmndQPutLast(&tTsk->sTsk->dQ, mBuf,
4095                            ((prior * SS_MAX_MSG_PRI) + tempPst.prior));
4096 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
4097    {
4098       Bool g_usettitmr;
4099       if (g_usettitmr)
4100       {
4101          if (tTsk->sTsk->tskPrior == PRIOR0)
4102          {
4103             SsTTskEntry *srctTsk;
4104             srctTsk = &osCp.tTskTbl[srcIdx];
4105             if ((srctTsk->sTsk == tTsk->sTsk)
4106 #if defined(SPLIT_RLC_DL_TASK) && !defined(RLC_MAC_DAT_REQ_RBUF)
4107                 ||
4108                 ((pst->dstEnt == ENTMAC) && 
4109                  (pst->srcEnt == ENTRLC) && 
4110                  (pst->event == EVTRGUDDATREQ))
4111 #endif
4112                )
4113 #ifdef RGL_SPECIFIC_CHANGES
4114                WLS_WakeUp(mtGetWlsHdl());
4115 #else
4116                tlPost(NULLP);
4117 #endif
4118          }
4119       }
4120       else if (tTsk->sTsk->tskPrior == PRIOR0)
4121 #ifdef RGL_SPECIFIC_CHANGES
4122          WLS_WakeUp(mtGetWlsHdl());
4123 #else
4124          tlPost(NULLP);
4125 #endif
4126    }
4127 #endif 
4128 #else
4129    if(tTsk->actvTsk != NULLP)
4130    {
4131        if(tTsk->cbTsk != NULLP)
4132        {
4133            r = rbICorePstTsk(&tempPst, mBuf, tTsk);
4134        }
4135        else
4136        {
4137            r = rbICorePstTsk(pst, mBuf, tTsk);
4138        }
4139    }
4140    else
4141    {
4142        r = RFAILED;
4143    }
4144 #endif
4145    if (r != ROK)
4146    {
4147  /* ss006.13: addition */
4148 #ifndef TENB_RTLIN_CHANGES
4149       if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4150       {
4151 #if (ERRCLASS & ERRCLS_DEBUG)
4152            SSLOGERROR(ERRCLS_DEBUG, ESS525, ERRZERO,
4153                      "Could not release the semaphore");
4154             return RFAILED;
4155 #endif
4156       }
4157 #endif
4158       SPutMsg(mBuf);
4159
4160 #if (ERRCLASS & ERRCLS_ADD_RES)
4161       SSLOGERROR(ERRCLS_ADD_RES, ESS526, (ErrVal) r,
4162                      "Could not write to demand queue");
4163 #endif
4164
4165       return RFAILED;
4166    }
4167
4168
4169    /* unlock, we're done */
4170  /* ss006.13: addition */
4171 #ifndef TENB_RTLIN_CHANGES
4172    if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4173    {
4174 #if (ERRCLASS & ERRCLS_DEBUG)
4175         SSLOGERROR(ERRCLS_DEBUG, ESS527, ERRZERO,
4176                   "Could not release the semaphore");
4177         return RFAILED;
4178 #endif
4179    }
4180 #endif
4181
4182
4183    /* If the implementation has anything to do... note that
4184     *  we call it unlocked at this time.
4185     */
4186    ssdPstTsk(tempPst, mBuf, tTsk);
4187
4188    return ROK;
4189 } /* SPstTsk */
4190
4191 /* ss001.301: additions */
4192 #ifdef SS_HISTOGRAM_SUPPORT 
4193 /*
4194 *
4195 *       fun :  SGetTapaTskEntIds
4196 *
4197 *       Desc:  Get the tapa task entity id, which are registerd for SSI.
4198 *
4199 *       Ret:   ROK      - ok
4200 *              RFAILED  - failed, general (optional)
4201 *              ROUTRES  - failed, out of resources (optional)
4202 *
4203 *       Notes:
4204 *
4205 *       File:  ss_task.c
4206 *
4207 */
4208 /* ss029.103: modification: procId added */
4209
4210 S16 SGetTapaTskEntIds
4211 (
4212 Ent *ent                        /* entity */
4213 )
4214 {
4215
4216    uint32_t tskCnt = 0;
4217
4218    /* Get the tapa task entity Ids from the osCp structure */
4219    for(tskCnt = 0; tskCnt < osCp.numTTsks; tskCnt++)
4220    {
4221       ent[tskCnt] = osCp.tTskTbl[tskCnt].ent;
4222    }
4223
4224    return ROK;
4225 } /* SGetTapaTskEntIds */
4226
4227 /*
4228 *
4229 *       Fun:   SRegForHstGrm
4230 *
4231 *       Desc:  This function is used to register a TAPA task,
4232 *              for histogram facilty.
4233 *
4234 *       Ret:   ROK      - ok
4235 *              RFAILED  - failed, general (optional)
4236 *              ROUTRES  - failed, out of resources (optional)
4237 *
4238 *       Notes:
4239 *
4240 *       File:  ss_task.c
4241 *
4242 */
4243 /* ss029.103: modification: procId added */
4244
4245 S16 SRegForHstGrm
4246 (
4247 Ent ent                        /* entity */
4248 )
4249 {
4250
4251    uint32_t tskCnt = 0;
4252    S16 r = 0;
4253
4254
4255    SS_ACQUIRE_SEMA(&osCp.tTskTblSem, r);
4256    if (r != ROK)
4257    {
4258 #if (ERRCLASS & ERRCLS_DEBUG)
4259       SSLOGERROR(ERRCLS_DEBUG, ESS623, ERRZERO,
4260                      "Could not lock TAPA task table");
4261 #endif
4262
4263       return RFAILED;
4264    }
4265
4266    for(tskCnt = 0; tskCnt < osCp.numTTsks; tskCnt++)
4267    {
4268       if(osCp.tTskTbl[tskCnt].ent == ent)
4269       {
4270          osCp.tTskTbl[tskCnt].hstReg = TRUE;
4271          break;
4272       }
4273    }
4274
4275    if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4276    {
4277 #if (ERRCLASS & ERRCLS_DEBUG)
4278          SSLOGERROR(ERRCLS_DEBUG, ESS639, ERRZERO,
4279                    "Could not release the semaphore");
4280           return RFAILED;
4281 #endif
4282     }
4283
4284    return ROK;
4285 } /* SGetTapaTskEntIds */
4286
4287 /*
4288 *
4289 *       Fun:   SGetHstGrmInfo
4290 *
4291 *       Desc : Get the Histogram registration for TAPA task
4292 *
4293 *       Ret:   ROK      - ok
4294 *              RFAILED  - failed, general (optional)
4295 *              ROUTRES  - failed, out of resources (optional)
4296 *
4297 *       Notes:
4298 *
4299 *       File:  ss_task.c
4300 *
4301 */
4302 S16 SGetHstGrmInfo
4303 (
4304 Ent   *entId,
4305 Bool  *hstReg                        /* entity */
4306 )
4307 {
4308
4309    uint32_t tskCnt = 0;
4310    Bool found = FALSE;
4311    *hstReg = 0;
4312
4313    for(tskCnt = 0; tskCnt < osCp.numTTsks; tskCnt++)
4314    {
4315       if( *entId == osCp.tTskTbl[tskCnt].ent)
4316       {
4317          *hstReg = osCp.tTskTbl[tskCnt].hstReg;
4318          found = TRUE;
4319           break;
4320       }
4321    }
4322
4323    if(!found)
4324    {
4325       *entId = ENTNC;
4326       *hstReg = TRUE;
4327    }
4328
4329    return ROK;
4330 } /* SGetTapaTskEntIds */
4331
4332 #endif /* SS_HISTOGRAM_SUPPORT */
4333
4334 #ifdef SS_WATCHDOG
4335 S16 SInitWatchdog(uint16_t port)
4336 {
4337  return ssdInitWatchDog(port);
4338 }
4339
4340 S16 SRegCfgWd
4341 (
4342 uint32_t numNodes,
4343 uint8_t  *addr[],
4344 uint16_t port[],
4345 uint32_t timeout,
4346 WdUserCallback callback,
4347 void *data
4348 )
4349 {
4350    Txt prntBuf[PRNTSZE];
4351    int i = 0;
4352
4353    /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
4354
4355    osCp.wdCp.globWd.timeout = timeout;
4356    osCp.wdCp.globWd.callback = callback;
4357    osCp.wdCp.globWd.data = data;
4358    osCp.wdCp.globWd.numNodes = numNodes;
4359
4360    SLock(&osCp.wdCp.wdLock);
4361    for(i = 0; i < SS_MAX_WD_NODES && i < numNodes; i++)
4362    {
4363 #ifdef SS_WATCHDOG_IPV6
4364  /* ss002.301 Modifications */
4365       inet_pton(AF_INET6,(const char *)addr[i],osCp.wdCp.globWd.wdsta[i].addr);
4366 #else
4367       osCp.wdCp.globWd.wdsta[i].addr.s_addr = inet_addr((const char *)addr[i]);
4368 #endif /* SS_WATCHDOG_IPV6 */
4369       osCp.wdCp.globWd.wdsta[i].port = htons(port[i]);
4370       sprintf(prntBuf, "Configured [%s:%d] for watchdog\n", addr[i], port[i]);
4371       SPrint(prntBuf);
4372    }
4373    SUnlock(&osCp.wdCp.wdLock);
4374  /* ss002.301 Compilation fixes */
4375    /*ss013.301: Fixed Warnings for 32/64 bit compilation*/
4376 #ifdef ALIGN_64BIT
4377    sprintf(prntBuf, "Configured %d nodes with timeout %u for Watchdog\n", osCp.wdCp.globWd.numNodes, osCp.wdCp.globWd.timeout);
4378 #else
4379    sprintf(prntBuf, "Configured %d nodes with timeout %lu for Watchdog\n", osCp.wdCp.globWd.numNodes, osCp.wdCp.globWd.timeout);
4380 #endif
4381    SPrint(prntBuf);
4382
4383    return ROK;
4384 }
4385
4386 S16 SDeregCfgWd(void)
4387 {
4388    Txt prntBuf[PRNTSZE];
4389    int i = 0;
4390
4391    /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
4392
4393    osCp.wdCp.globWd.timeout = 0;
4394    osCp.wdCp.globWd.callback = 0;
4395    osCp.wdCp.globWd.data = 0;
4396    osCp.wdCp.globWd.numNodes = 0;
4397
4398    SLock(&osCp.wdCp.wdLock);
4399    for(i = 0; i < SS_MAX_WD_NODES; i++)
4400    {
4401            /* ss002.301 Modifications */
4402       sprintf(prntBuf, "Deregister [%s:%d] for watchdog\n", inet_ntoa(osCp.wdCp.globWd.wdsta[i
4403 ].addr), osCp.wdCp.globWd.wdsta[i].port);
4404       osCp.wdCp.globWd.wdsta[i].addr.s_addr = 0;
4405        osCp.wdCp.globWd.wdsta[i].port = 0;
4406       SPrint(prntBuf);
4407    }
4408    SUnlock(&osCp.wdCp.wdLock);
4409
4410    /* Implicit watchdog stop during dereg */
4411    SStopHrtBt();
4412
4413    return ROK;
4414 }
4415
4416 S16 SStartHrtBt
4417 (
4418 uint8_t timeInterval /* time interval */
4419 )
4420 {
4421
4422    ssdStartWatchDgTmr(NULLP, SS_TMR_HRTBT, timeInterval);
4423    ssdSndHrtBtMsg(TRUE, SS_WD_HB_REQ);
4424
4425    return ROK;
4426 }
4427
4428 S16 SStopHrtBt(void)
4429 {
4430
4431    osCp.wdCp.globWd.watchdogStop = 1;
4432
4433    return ROK;
4434 }
4435
4436 S16 watchDgActvTsk
4437 (
4438 Pst *pst,                   /* post */
4439 Buffer *mBuf                /* message buffer */
4440 )
4441 {
4442 /* ss002.301 Fixed warnings */
4443 #ifdef DEBUGP
4444    DateTime dt;
4445    Txt prntBuf[PRNTSZE];
4446 #endif /* DEBUGP */
4447
4448 #ifdef DEBUGP
4449    SGetDateTime(&dt);
4450    sprintf(prntBuf,"watchDgActvTsk: Time: %02d:%02d:%02d\n",dt.hour,dt.min, dt.sec
4451 );
4452    SPrint(prntBuf);
4453 #endif /* DEBUGP */
4454         return ROK;
4455 }
4456
4457 S16 watchDgRcvrActvTsk
4458 (
4459 Pst *pst,                   /* post */
4460 Buffer *mBuf                /* message buffer */
4461 )
4462 {
4463 #ifdef DEBUGP
4464    DateTime dt;
4465 #endif /* DEBUGP */
4466    Txt prntBuf[PRNTSZE];
4467    uint16_t           n;
4468    S16                    err;
4469    struct sockaddr_in tmpaddr;
4470    Txt           hbMsg[SS_WD_HB_MSG_SIZE];
4471  /* ss002.301 Modifications */
4472 #ifdef SS_LINUX
4473         socklen_t         socklen = sizeof(struct sockaddr);
4474 #else
4475    int           socklen = sizeof(struct sockaddr);
4476 #endif
4477
4478
4479 #ifdef DEBUGP
4480    SGetDateTime(&dt);
4481    sprintf(prntBuf,"watchDgRcvrActvTsk: Time: %02d:%02d:%02d\n",dt.hour, dt.min, dt.sec);
4482    SPrint(prntBuf);
4483 #endif /* DEBUGP */
4484
4485    while(!osCp.wdCp.globWd.watchdogStop)
4486    {
4487       err = recvfrom(osCp.wdCp.globWd.sock, hbMsg, SS_WD_HB_MSG_SIZE, 0, (struct sockaddr *)&tmpaddr, &socklen);
4488       if(err == -1)
4489       {
4490          sprintf(prntBuf,"watchDgRcvrActvTsk: recvfrom failed, errno %d\n", errno);
4491          SPrint(prntBuf);
4492          continue;
4493       }
4494
4495       if(strcmp(hbMsg, "<HB>REQ</HB>") == 0)
4496       {
4497          /* Send back the reply */
4498 #ifdef DEBUGP
4499          sprintf(prntBuf,"watchDgRcvrActvTsk: Recvd HB REQ message from [%s:%d]\n", inet_ntoa(tmpaddr.sin_addr), ntohs(tmpaddr.sin_port));
4500          SPrint(prntBuf);
4501 #endif /* DEBUGP */
4502
4503          strcpy(hbMsg, "<HB>RSP</HB>");
4504          sendto(osCp.wdCp.globWd.sock, hbMsg, strlen(hbMsg), 0, (struct sockaddr *)&tmpaddr, sizeof(tmpaddr));
4505       }
4506       else if(strcmp(hbMsg, "<HB>RSP</HB>") == 0)
4507       {
4508          /* Got a HB RSP, set the status for the correcponding node */
4509 #ifdef DEBUGP
4510          sprintf(prntBuf,"watchDgRcvrActvTsk: Recvd HB RSP message from [%s:%d]\n", inet_ntoa(tmpaddr.sin_addr), ntohs(tmpaddr.sin_port)); 
4511          SPrint(prntBuf);
4512 #endif /* DEBUGP */
4513
4514          SLock(&osCp.wdCp.wdLock);
4515          for(n = 0; n < osCp.wdCp.globWd.numNodes; n++)
4516          {
4517             if(osCp.wdCp.globWd.wdsta[n].addr.s_addr == tmpaddr.sin_addr.s_addr)
4518             {
4519                osCp.wdCp.globWd.wdsta[n].status = 1;
4520             }
4521          }
4522          SUnlock(&osCp.wdCp.wdLock);
4523       }
4524       else
4525       {
4526 #ifdef DEBUGP
4527          sprintf(prntBuf,"watchDgRcvrActvTsk: Rcvd invalid message\n");
4528          SPrint(prntBuf);
4529 #endif /* DEBUGP */
4530       }
4531    }
4532         return ROK;
4533 }
4534
4535 #endif /* SS_WATCHDOG */
4536
4537 /* ss002.301 Modifications */
4538 #ifdef SS_THREAD_PROFILE
4539 /*
4540 *
4541 *       Fun:   SGetThrdProf
4542 *
4543 *       Desc:  This function gets the current profile of a system task
4544 *              The function sets the Entity, Instance, Event and time taken
4545 *              for that thread to execurte the activate function of
4546 *              that entity.
4547 *
4548 *       Ret:   ROK      - ok
4549 *              RFAILED  - failed, general (optional)
4550 *
4551 *       Notes: This function may be called by the OS or Layer 1
4552 *              hardware drivers.
4553 *
4554 *       File:  mt_ss.c
4555 *
4556 */
4557 #ifdef SS_MULTIPLE_PROCS
4558 S16 SGetThrdProf
4559 (
4560 SSTskId *sTskId,
4561 ProcId procId,
4562 Ent ent,                       /* entity */
4563 Inst inst,
4564 Event *curEvent,
4565 uint32_t *curEvtTime,
4566 uint64_t *totTime
4567 )
4568 #else
4569 S16 SGetThrdProf
4570 (
4571 SSTskId *sTskId,
4572 Ent ent,                       /* entity */
4573 Inst inst,
4574 Event *curEvent,
4575 uint32_t *curEvtTime,
4576 uint64_t *totTime
4577 )
4578 #endif /* SS_MULTIPLE_PROCS */
4579 {
4580   S16 ret;
4581    SsIdx idx;
4582    SsTTskEntry *tTsk;
4583 #ifdef SS_MULTIPLE_PROCS
4584    uint16_t procIdIdx;
4585 #endif
4586
4587
4588
4589 #if (ERRCLASS & ERRCLS_INT_PAR)
4590    /* check entity and instance range */
4591 #ifdef SS_MULTIPLE_PROCS
4592    /* check proc, entity and instance range */
4593    if ((procId == SS_INV_PROCID) || (ent >= SS_MAX_ENT) ||  (inst >= SS_MAX_INST))
4594    {
4595       SSLOGERROR(ERRCLS_INT_PAR, ESS463, ERRZERO, "Invalid processor/entity/instance");
4596       return RFAILED;
4597    }
4598 #else /* SS_MULTIPLE_PROCS */
4599    /* check entity and instance range */
4600    if (ent >= SS_MAX_ENT ||  inst >= SS_MAX_INST)
4601    {
4602       SSLOGERROR(ERRCLS_INT_PAR, ESS464, ERRZERO, "Invalid entity/instance");
4603       return RFAILED;
4604    }
4605 #endif /* SS_MULTIPLE_PROCS */
4606 #endif
4607
4608
4609    ret = SLock(&osCp.sTskTblLock);
4610    if (ret != ROK)
4611    {
4612       return RFAILED;
4613    }
4614
4615
4616 #ifdef SS_MULTIPLE_PROCS
4617     procIdIdx = SGetProcIdIdx(procId);
4618
4619     if (procIdIdx == SS_INV_PROCID_IDX)
4620     {
4621       return RFAILED;
4622     }
4623
4624     idx = osCp.tTskIds[procIdIdx][ent][inst];
4625 #else /* SS_MULTIPLE_PROCS */
4626     idx = osCp.tTskIds[ent][inst];
4627 #endif /* SS_MULTIPLE_PROCS */
4628
4629     tTsk = &osCp.tTskTbl[idx];
4630     if(tTsk == NULLP )
4631     {
4632              SUnlock(&osCp.sTskTblLock);
4633              return RFAILED;
4634     }
4635     *curEvent      = osCp.tTskTbl[idx].curEvent;
4636     *curEvtTime    = osCp.tTskTbl[idx].curEvtTime;
4637     *totTime       = osCp.tTskTbl[idx].totTime;
4638     *sTskId        = osCp.tTskTbl[idx].sTsk->tskId;
4639
4640    SUnlock(&osCp.sTskTblLock);
4641    return ROK;
4642 }
4643 #endif /* SS_THREAD_PROFILE */
4644
4645 #ifdef SS_FBSED_TSK_REG
4646 /*
4647 *
4648 *       Fun:   SRegTskInfo
4649 *
4650 *       Desc:  This function is used to register tasks based on cfg file.
4651 *
4652 *       Ret:   ROK      - ok
4653 *              RFAILED  - failed, general (optional)
4654 *
4655 *
4656 *       File:  ss_task.c
4657 *
4658 */
4659 S16 SRegTskInfo(uint8_t *cfgFile)
4660 {
4661    return cmCfgrTskReg(cfgFile); 
4662 }
4663 #endif /* SS_FBSED_TSK_REG */
4664
4665 /**********************************************************************
4666          End of file
4667 **********************************************************************/