1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /********************************************************************20**
21 Name: System Services -- Task Management
25 Desc: Source code for System Services functions for task mgmt.
29 *********************************************************************21*/
32 /* header include files (.h) */
34 #include "envopt.h" /* environment options */
35 #include "envdep.h" /* environment dependent */
36 #include "envind.h" /* environment independent */
38 #include "gen.h" /* general layer */
39 #include "ssi.h" /* system services */
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
52 #ifdef SS_FBSED_TSK_REG
54 #endif /* SS_FBSED_TSK_REG */
56 /* header/extern include files (.x) */
58 #include "gen.x" /* general layer */
59 #include "ssi.x" /* system services */
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
72 #include "cm_mem_wl.x" /* common memory manager */
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 */
79 /* ss001.301: additions */
80 #ifdef SS_LOGGER_SUPPORT
81 /* ss002.301: Fixed warings */
85 #include <sys/socket.h>
86 #include <netinet/in.h>
87 #include <arpa/inet.h>
94 #endif /* SS_LOGGER_SUPPORT */
96 /* ss001.301: additions */
100 #include <sys/time.h>
101 #include <sys/types.h>
103 #include <sys/poll.h>
105 #include <sys/types.h>
106 #include <sys/socket.h>
107 #include <netinet/in.h>
108 #include <arpa/inet.h>
110 #include "winsock2.h"
111 #include "ws2tcpip.h"
113 #endif /* SS_WATCHDOG */
115 /* ss001.301: additions */
116 #ifdef SS_FBSED_TSK_REG
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"
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 */
132 #include "mt_plat_t33.h"
137 pthread_t tmpRegTidMap[20];
139 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
140 unsigned int tlPost(void *handle);
141 #ifdef XEON_SPECIFIC_CHANGES
142 int WLS_WakeUp(void* h);
146 /* ss029.103: modification:
147 Old SSI functions are not supported with multiple procIds */
148 #ifndef SS_MULTIPLE_PROCS
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.
160 * RFAILED - failed, general (optional)
170 Ent ent, /* entity */
171 Inst inst, /* instance */
172 PAIFS16 initFnct /* initialization function */
175 /* ss021.103 - Addition for return value and pointer */
176 S16 ret; /* return value */
181 #if (ERRCLASS & ERRCLS_INT_PAR)
182 /* check entity and instance ranges */
183 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
185 SSLOGERROR(ERRCLS_INT_PAR, ESS350, ERRZERO, "Invalid entity/instance");
189 /* check initialization function */
190 if (initFnct == NULLP)
192 SSLOGERROR(ERRCLS_INT_PAR, ESS351, ERRZERO, "Null pointer");
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
205 /* ss025.103 - Addition of lock around counting semaphore */
206 /* lock system task table */
207 ret = SLock(&osCp.sTskTblLock);
210 SSLOGERROR(ERRCLS_DEBUG, ESS352, ERRZERO,
211 "Could not lock system task table");
215 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
219 #if (ERRCLASS & ERRCLS_DEBUG)
220 SSLOGERROR(ERRCLS_DEBUG, ESS353, ERRZERO,
221 "Could not lock TAPA task table");
228 #if (ERRCLASS & ERRCLS_INT_PAR)
229 /* check count of tasks */
230 if (osCp.numTTsks == SS_MAX_TTSKS)
232 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
233 SSLOGERROR(ERRCLS_INT_PAR, ESS354, ERRZERO, "Too many tasks");
235 /* ss025.103 - Addition of unlock around counting semephore */
236 if ( SUnlock(&osCp.sTskTblLock) != ROK)
238 #if (ERRCLASS & ERRCLS_DEBUG)
239 SSLOGERROR(ERRCLS_DEBUG, ESS355, ERRZERO,
240 "Could not give the Semaphore");
248 /* check if entity and instance already registered */
249 if (osCp.tTskIds[ent][inst] != SS_TSKNC)
251 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
252 SSLOGERROR(ERRCLS_INT_PAR, ESS356, ERRZERO,
253 "Entity and instance already registered");
255 /* ss025.103 - Addition of unlock around counting semaphore */
256 if ( SUnlock(&osCp.sTskTblLock) != ROK)
258 #if (ERRCLASS & ERRCLS_DEBUG)
259 SSLOGERROR(ERRCLS_DEBUG, ESS357, ERRZERO,
260 "Could not give the Semaphore");
269 tTsk = &osCp.tTskTbl[osCp.nxtTTskEntry];
274 tTsk->tskType = (Ttype)NULLD;
275 tTsk->tskPrior = (Prior)NULLD;
276 tTsk->initTsk = initFnct;
277 tTsk->actvTsk = (ActvTsk)NULLP;
280 osCp.tTskIds[ent][inst] = osCp.nxtTTskEntry;
281 osCp.nxtTTskEntry = tTsk->nxt;
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.
291 /* ss024.103 - Modification for memory calculator tool */
293 (Void)(*initFnct)(ent, inst, DFLT_REGION, PWR_UP);
295 (Void)(*initFnct)(ent, inst, SS_STATIC_REGION, PWR_UP);
296 #endif /* USE_MEMCAL */
298 /* unlock the table */
299 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
301 /* ss025.103 - Addition of unlock around counting semaphore */
302 if ( SUnlock(&osCp.sTskTblLock) != ROK)
304 #if (ERRCLASS & ERRCLS_DEBUG)
305 SSLOGERROR(ERRCLS_DEBUG, ESS358, ERRZERO,
306 "Could not give the Semaphore");
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
329 * RFAILED - failed, general (optional)
330 * ROUTRES - failed, out of resources (optional)
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().
341 Ent ent, /* entity */
342 Inst inst, /* instance */
343 Ttype ttype, /* task type */
344 Prior prior, /* task priority */
345 ActvTsk actvTsk /* activate task function */
351 /* ss021.103 - Addition for pointer */
356 #if (ERRCLASS & ERRCLS_INT_PAR)
357 /* check entity and instance ranges */
358 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
360 SSLOGERROR(ERRCLS_INT_PAR, ESS359, ERRZERO, "Invalid entity/instance");
364 /* check activation function */
365 if (actvTsk == NULLP)
367 SSLOGERROR(ERRCLS_INT_PAR, ESS360, ERRZERO, "Null pointer");
371 /* check task type */
372 if (ttype != TTNORM && ttype != TTPERM)
374 SSLOGERROR(ERRCLS_INT_PAR, ESS361, ERRZERO, "Invalid task type");
375 /* ss021.103 - Addition of return fail for invalid task type */
379 /* check task priority */
382 SSLOGERROR(ERRCLS_INT_PAR, ESS362, ERRZERO, "Invalid task priority");
387 /* lock system task table */
388 ret = SLock(&osCp.sTskTblLock);
391 SSLOGERROR(ERRCLS_DEBUG, ESS363, ERRZERO,
392 "Could not lock system task table");
396 /* lock TAPA task table */
397 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
400 if ( SUnlock(&osCp.sTskTblLock) != ROK)
402 #if (ERRCLASS & ERRCLS_DEBUG)
403 SSLOGERROR(ERRCLS_DEBUG, ESS364, ERRZERO,
404 "Could not give the Semaphore");
409 SSLOGERROR(ERRCLS_DEBUG, ESS365, ERRZERO,
410 "Could not lock TAPA task table");
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)
418 #if (ERRCLASS & ERRCLS_INT_PAR)
419 /* check count of tasks */
420 if (osCp.numTTsks == SS_MAX_TTSKS)
422 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
424 /* ss025.103 - Addition of unlock around counting semaphore */
425 if ( SUnlock(&osCp.sTskTblLock) != ROK)
427 #if (ERRCLASS & ERRCLS_DEBUG)
428 SSLOGERROR(ERRCLS_DEBUG, ESS366, ERRZERO,
429 "Could not give the Semaphore");
433 SSLOGERROR(ERRCLS_INT_PAR, ESS367, ERRZERO, "Too many tasks");
438 tTsk = &osCp.tTskTbl[osCp.nxtTTskEntry];
442 tTsk->initTsk = (PAIFS16)NULLP;
443 tTsk->actvTsk = (ActvTsk)NULLP;
446 osCp.tTskIds[ent][inst] = osCp.nxtTTskEntry;
447 osCp.nxtTTskEntry = tTsk->nxt;
452 /* check and bump the priority if it is a permanent task */
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.
464 tTsk = &osCp.tTskTbl[osCp.tTskIds[ent][inst]];
466 #if (ERRCLASS & ERRCLS_INT_PAR)
467 if (tTsk->actvTsk != (ActvTsk)NULLP)
469 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
471 if ( SUnlock(&osCp.sTskTblLock) != ROK)
473 #if (ERRCLASS & ERRCLS_DEBUG)
474 SSLOGERROR(ERRCLS_DEBUG, ESS368, ERRZERO,
475 "Could not give the Semaphore");
480 SSLOGERROR(ERRCLS_INT_PAR, ESS369, ERRZERO,
481 "ActvTask already registered");
486 tTsk->tskType = ttype;
487 tTsk->tskPrior = prior;
488 tTsk->actvTsk = actvTsk;
490 /* unlock the table */
491 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
493 if ( SUnlock(&osCp.sTskTblLock) != ROK)
495 #if (ERRCLASS & ERRCLS_DEBUG)
496 SSLOGERROR(ERRCLS_DEBUG, ESS370, ERRZERO,
497 "Could not give the Semaphore");
502 /* Now we create a system task--one per TAPA task is the
503 * semantics of SRegActvTsk().
506 spri = SS_NORM_TSK_PRI;
508 spri = SS_PERM_TSK_PRI;
510 ret = SCreateSTsk(spri, &sTskId);
514 #if (ERRCLASS & ERRCLS_DEBUG)
515 SSLOGERROR(ERRCLS_DEBUG, ESS371, (ErrVal) ret,
516 "Could not create system task");
519 SDeregTTsk(ent, inst);
524 /* Attach the TAPA task we just registered, to the system
525 * task we just created.
527 ret = SAttachTTsk(ent, inst, sTskId);
531 #if (ERRCLASS & ERRCLS_DEBUG)
532 SSLOGERROR(ERRCLS_DEBUG, ESS372, (ErrVal) ret,
533 "Could not attach TAPA task to system task");
535 SDestroySTsk(sTskId);
536 SDeregTTsk(ent, inst);
547 * Fun: Deregister Initialize, task buffer and timer
549 * Desc: This function is used to deregister the initialization,
550 * activation and timer functions for a task.
561 Ent ent, /* entity */
562 Inst inst /* instance */
575 #if (ERRCLASS & ERRCLS_INT_PAR)
576 /* check entity and instance ranges */
577 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
579 SSLOGERROR(ERRCLS_INT_PAR, ESS373, ERRZERO, "Invalid entity/instance");
584 /* ss025.103 - Addition of lock around counting semaphore */
585 /* lock system task table */
586 ret = SLock(&osCp.sTskTblLock);
589 SSLOGERROR(ERRCLS_DEBUG, ESS374, ERRZERO,
590 "Could not lock system task table");
594 /* lock the TAPA task table */
595 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
599 #if (ERRCLASS & ERRCLS_DEBUG)
600 SSLOGERROR(ERRCLS_DEBUG, ESS375, ERRZERO,
601 "Could not lock TAPA task table");
608 #if (ERRCLASS & ERRCLS_INT_PAR)
609 /* check whether this entity is registered */
610 if (osCp.tTskIds[ent][inst] == SS_TSKNC)
612 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
613 SSLOGERROR(ERRCLS_INT_PAR, ESS376, ERRZERO, "Unknown task");
615 /* ss025.103 - Addition of unlock around counting semaphore */
616 if ( SUnlock(&osCp.sTskTblLock) != ROK)
618 #if (ERRCLASS & ERRCLS_DEBUG)
619 SSLOGERROR(ERRCLS_DEBUG, ESS377, ERRZERO,
620 "Could not give the Semaphore");
630 /* get out the TAPA task entry */
631 tTsk = &osCp.tTskTbl[osCp.tTskIds[ent][inst]];
633 /* get out the system task that's running this TAPA task */
636 /* get out the ID of this system task */
639 sTskId = sTsk->tskId;
644 /* unlock the TAPA task table */
645 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
647 /* ss025.103 - Addition of unlock around counting semaphore */
648 if ( SUnlock(&osCp.sTskTblLock) != ROK)
650 #if (ERRCLASS & ERRCLS_DEBUG)
651 SSLOGERROR(ERRCLS_DEBUG, ESS378, ERRZERO,
652 "Could not give the Semaphore");
658 /* deregister the TAPA task */
659 if (SDeregTTsk(ent, inst) != ROK)
665 /* Now, if the TAPA task was attached, and nobody else is using that
666 * system task, we should destroy it.
672 /* lock the system task table */
673 ret = SLock(&osCp.sTskTblLock);
677 #if (ERRCLASS & ERRCLS_DEBUG)
678 SSLOGERROR(ERRCLS_DEBUG, ESS379, (ErrVal) ret,
679 "Could not lock system task table");
685 idx = (SsIdx) sTskId;
686 sTsk = &osCp.sTskTbl[idx];
688 /* check if the system task is still around */
689 if (sTsk->used != TRUE)
692 /* ss006.13: addition */
693 if ( SUnlock(&osCp.sTskTblLock) != ROK)
695 #if (ERRCLASS & ERRCLS_DEBUG)
696 SSLOGERROR(ERRCLS_DEBUG, ESS380, ERRZERO,
697 "Could not give the Semaphore");
705 /* check if the system task is dying already */
709 /* ss006.13: addition */
710 if ( SUnlock(&osCp.sTskTblLock) != ROK)
712 #if (ERRCLASS & ERRCLS_DEBUG)
713 SSLOGERROR(ERRCLS_DEBUG, ESS381, ERRZERO,
714 "Could not give the Semaphore");
722 /* If this system task entry has no more TAPA tasks attached,
723 * we destroy it, otherwise we do nothing.
725 if (sTsk->numTTsks == 0)
727 sTsk->termPend = TRUE;
734 /* ss006.13: addition */
735 if ( SUnlock(&osCp.sTskTblLock) != ROK)
737 #if (ERRCLASS & ERRCLS_DEBUG)
738 SSLOGERROR(ERRCLS_DEBUG, ESS382, ERRZERO,
739 "Could not give the Semaphore");
744 /* If we're destroying the system task, ask the implementation
749 ret = ssdDestroySTsk(sTsk);
754 #if (ERRCLASS & ERRCLS_DEBUG)
755 SSLOGERROR(ERRCLS_DEBUG, ESS383, (ErrVal) ret,
756 "Could not destroy system task");
766 } /* SDeregInitTskTmr */
768 #endif /* SS_MULTIPLE_PROCS */
773 * Fun: Register a TAPA task
775 * Desc: This function is used to register a TAPA task,
776 * and its initialization and activation functions.
779 * RFAILED - failed, general (optional)
780 * ROUTRES - failed, out of resources (optional)
787 /* ss029.103: modification: procId added */
788 #ifndef SS_MULTIPLE_PROCS
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 */
799 #else /* SS_MULTIPLE_PROCS */
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 */
811 #endif /* SS_MULTIPLE_PROCS */
816 /* ss029.103: addition: multiple procIds related changes */
817 #ifdef SS_MULTIPLE_PROCS
823 #if (ERRCLASS & ERRCLS_INT_PAR)
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))
830 SSLOGERROR(ERRCLS_INT_PAR, ESS384, ERRZERO, "Invalid proc/entity/instance");
833 #else /* SS_MULTIPLE_PROCS */
834 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
836 SSLOGERROR(ERRCLS_INT_PAR, ESS385, ERRZERO, "Invalid entity/instance");
839 #endif /* SS_MULTIPLE_PROCS */
841 /* check activation function */
842 if (actvTsk == NULLP)
844 SSLOGERROR(ERRCLS_INT_PAR, ESS386, ERRZERO, "Null pointer");
848 /* check task type */
849 if (type != TTNORM && type != TTPERM)
851 SSLOGERROR(ERRCLS_INT_PAR, ESS387, ERRZERO, "Invalid task type");
852 /* ss021.103 - Addition of return fail for invalid task type */
856 /* check task priority */
859 SSLOGERROR(ERRCLS_INT_PAR, ESS388, ERRZERO, "Invalid task priority");
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);
869 /* Check whether the proc id exist in the proc id table */
870 if (procIdIdx == SS_INV_PROCID_IDX)
872 #if (ERRCLASS & ERRCLS_INT_PAR)
873 SSLOGERROR(ERRCLS_INT_PAR, ESS389, ERRZERO,
874 "Could not find proc table index");
879 #endif /* SS_MULTIPLE_PROCS */
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
890 /* ss025.103 - Addition of lock around counting semaphore */
891 /* lock system task table */
892 ret = SLock(&osCp.sTskTblLock);
895 SSLOGERROR(ERRCLS_DEBUG, ESS390, ERRZERO,
896 "Could not lock system task table");
900 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
904 #if (ERRCLASS & ERRCLS_DEBUG)
905 SSLOGERROR(ERRCLS_DEBUG, ESS391, ERRZERO,
906 "Could not lock TAPA task table");
909 /* ss025.103 - Addition of unlock around counting semaphore */
910 if ( SUnlock(&osCp.sTskTblLock) != ROK)
912 #if (ERRCLASS & ERRCLS_DEBUG)
913 SSLOGERROR(ERRCLS_DEBUG, ESS392, ERRZERO,
914 "Could not give the Semaphore");
923 #if (ERRCLASS & ERRCLS_DEBUG)
924 /* check count of tasks */
925 if (osCp.numTTsks == SS_MAX_TTSKS)
927 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
928 SSLOGERROR(ERRCLS_DEBUG, ESS393, ERRZERO, "Too many tasks");
930 /* ss025.103 - Addition of unlock around counting semaphore */
931 if ( SUnlock(&osCp.sTskTblLock) != ROK)
933 #if (ERRCLASS & ERRCLS_DEBUG)
934 SSLOGERROR(ERRCLS_DEBUG, ESS394, ERRZERO,
935 "Could not give the Semaphore");
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)
948 if (osCp.tTskIds[ent][inst] != SS_TSKNC)
949 #endif /* SS_MULTIPLE_PROCS */
951 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
952 SSLOGERROR(ERRCLS_DEBUG, ESS395, ERRZERO,
953 "Entity and instance already registered");
955 /* ss025.103 - Addition of unlock around counting semaphore */
956 if ( SUnlock(&osCp.sTskTblLock) != ROK)
958 #if (ERRCLASS & ERRCLS_DEBUG)
959 SSLOGERROR(ERRCLS_DEBUG, ESS396, ERRZERO,
960 "Could not give the Semaphore");
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.
974 tTsk = &osCp.tTskTbl[osCp.nxtTTskEntry];
976 /* ss029.103: addition: procId added */
977 #ifdef SS_MULTIPLE_PROCS
979 #endif /* SS_MULTIPLE_PROCS */
982 tTsk->tskType = type;
983 tTsk->tskPrior = prior;
984 tTsk->initTsk = initTsk;
985 tTsk->actvTsk = actvTsk;
988 /* ss001.301: additions */
989 #ifdef SS_HISTOGRAM_SUPPORT
991 #endif /* SS_HISTOGRAM_SUPPORT */
993 /* ss029.103: addition: multiple procIds related changes */
994 #ifdef SS_MULTIPLE_PROCS
995 osCp.tTskIds[procIdIdx][ent][inst] = osCp.nxtTTskEntry;
997 osCp.tTskIds[ent][inst] = osCp.nxtTTskEntry;
998 #endif /* SS_MULTIPLE_PROCS */
999 osCp.nxtTTskEntry = tTsk->nxt;
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.
1010 /* ss024.103 - Modification for memory calculator tool */
1011 if (initTsk != NULLP)
1013 /* ss029.103: addition: multiple procIds related changes */
1014 #ifdef SS_MULTIPLE_PROCS
1017 #endif /* SS_MULTIPLE_PROCS */
1019 /* ss029.103: addition: multiple procIds related changes */
1020 #ifndef SS_MULTIPLE_PROCS
1023 #ifndef SS_MULTICORE_SUPPORT
1024 (Void)(*initTsk)(ent, inst, DFLT_REGION, PWR_UP);
1027 (Void)(*initTsk)(ent, inst, SS_STATIC_REGION, PWR_UP);
1028 #endif /* USE_MEMCAL */
1030 #else /* SS_MULTIPLE_PROCS */
1033 #ifndef SS_MULTICORE_SUPPORT
1034 (Void)(*initTsk)(proc, ent, inst, DFLT_REGION, PWR_UP, &xxCb);
1035 #endif /* SS_MULTICORE_SUPPORT */
1037 (Void)(*initTsk)(proc, ent, inst, SS_STATIC_REGION, PWR_UP, &xxCb);
1038 #endif /* USE_MEMCAL */
1041 * store the control block. The control block may be NULL in some cases
1043 idx = osCp.tTskIds[procIdIdx][ent][inst];
1045 osCp.tTskTbl[idx].xxCb = xxCb;
1047 /* ss032.103 do a debug print if xxCb is NULLP */
1050 SSLOGERROR(ERRCLS_INT_PAR, ERRZERO, ERRZERO, "Null pointer");
1052 #endif /* SS_MULTIPLE_PROCS */
1055 /* unlock the table */
1056 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1058 /* ss025.103 - Addition of unlock around counting semaphore */
1059 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1061 #if (ERRCLASS & ERRCLS_DEBUG)
1062 SSLOGERROR(ERRCLS_DEBUG, ESS397, ERRZERO,
1063 "Could not give the Semaphore");
1070 /* ss002.301 Additions */
1073 * Fun: Register a call back function with SSI
1075 * Desc: This function is used to register a callback function
1079 * RFAILED - failed, general (optional)
1086 #ifndef SS_MULTIPLE_PROCS
1089 Ent ent, /* entity */
1090 Inst inst, /* instance */
1091 ActvTsk cbTsk /* Callback Function */
1093 #else /* SS_MULTIPLE_PROCS */
1097 ProcId proc, /* processor */
1098 Ent ent, /* entity */
1099 Inst inst, /* instance */
1102 #endif /* SS_MULTIPLE_PROCS */
1107 #ifdef SS_MULTIPLE_PROCS
1109 #endif /* SS_MULTIPLE_PROCS */
1112 #if (ERRCLASS & ERRCLS_INT_PAR)
1113 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
1115 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SRegCbTsk() : Invalid entity/instance");
1121 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, " SRegCbTsk() : Null pointer");
1126 #ifdef SS_MULTIPLE_PROCS
1127 /* retrieve proc id index in the proc id table */
1128 procIdIdx = SGetProcIdIdx(proc);
1130 /* Check whether the proc id exist in the proc id table */
1131 if (procIdIdx == SS_INV_PROCID_IDX)
1133 #if (ERRCLASS & ERRCLS_INT_PAR)
1134 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO,
1135 " SRegCbTsk() : Could not find proc table index");
1140 #endif /* SS_MULTIPLE_PROCS */
1142 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
1146 #if (ERRCLASS & ERRCLS_DEBUG)
1147 SSLOGERROR(ERRCLS_DEBUG, ESSXXX, ERRZERO,
1148 "SRegCbTsk() : Could not lock TAPA task table");
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 */
1159 #if (ERRCLASS & ERRCLS_INT_PAR)
1160 if (idx == SS_TSKNC)
1162 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1163 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SRegCbTsk() : Unknown task");
1167 tTsk = &osCp.tTskTbl[idx];
1168 tTsk->cbTsk = cbTsk;
1170 /* unlock the table */
1171 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1178 * Fun: Deregister TAPA task
1180 * Desc: This function is used to deregister a TAPA task.
1181 * All information about the task is removed from the
1185 * RFAILED - failed, general (optional)
1192 /* ss029.103: addition: procId added */
1193 #ifndef SS_MULTIPLE_PROCS
1197 Ent ent, /* entity */
1198 Inst inst /* instance */
1200 #else /* SS_MULTIPLE_PROCS */
1204 ProcId proc, /* processor */
1205 Ent ent, /* entity */
1206 Inst inst /* instance */
1208 #endif /* SS_MULTIPLE_PROCS */
1211 /* ss029.103: modification: The subscript should be consistent type */
1215 /* ss029.103: addition: multiple procIds related changes */
1216 #ifdef SS_MULTIPLE_PROCS
1218 #endif /* SS_MULTIPLE_PROCS */
1219 /* ss002.301 Additions */
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))
1231 SSLOGERROR(ERRCLS_INT_PAR, ESS398, ERRZERO, "Invalid processor/entity/instance");
1234 #else /* SS_MULTIPLE_PROCS */
1235 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
1237 SSLOGERROR(ERRCLS_INT_PAR, ESS399, ERRZERO, "Invalid entity/instance");
1240 #endif /* SS_MULTIPLE_PROCS */
1244 /* ss029.103: addition: multiple procIds related changes */
1245 #ifdef SS_MULTIPLE_PROCS
1246 /* Find the proc table index */
1247 procIdIdx = SGetProcIdIdx(proc);
1249 if (procIdIdx == SS_INV_PROCID)
1251 #if (ERRCLASS & ERRCLS_DEBUG)
1252 SSLOGERROR(ERRCLS_DEBUG, ESS400, ERRZERO,
1253 "Could not find proc id index");
1257 #endif /* SS_MULTIPLE_PROCS */
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.
1263 if (SLock(&osCp.tmrTblLock) != ROK)
1265 #if (ERRCLASS & ERRCLS_DEBUG)
1266 SSLOGERROR(ERRCLS_DEBUG, ESS401, ERRZERO,
1267 "Could not lock timer table");
1272 for (idx = 0; idx < SS_MAX_TMRS; idx++)
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 */
1284 /* shut down this timer */
1285 tmr = &osCp.tmrTbl[idx];
1286 if (ssdDeregTmr(tmr) == ROK)
1290 /* ss029.103: addition: multiple procIds related changes */
1291 #ifdef SS_MULTIPLE_PROCS
1292 tmr->ownerProc = PROCNC;
1294 * ss015.301 - Modifed in initialization as timer activation
1295 * functions enclosed in a union. Also initialized the mtFlag
1298 #endif /* SS_MULTIPLE_PROCS */
1299 tmr->ownerEnt = ENTNC;
1300 tmr->ownerInst = INSTNC;
1302 tmr->ssTmrActvFn.actvFnc.tmrActvFn = NULLP;
1303 #ifndef SS_MULTIPLE_PROCS
1305 tmr->ssTmrActvFn.mtFlag = FALSE;
1306 tmr->ssTmrActvFn.actvFnc.tmrActvFnMt = NULLP;
1309 tmr->nxt = osCp.nxtTmrEntry;
1310 osCp.nxtTmrEntry = (SsIdx)idx;
1316 /* ss006.13: addition */
1317 if ( SUnlock(&osCp.tmrTblLock) != ROK)
1319 #if (ERRCLASS & ERRCLS_DEBUG)
1320 SSLOGERROR(ERRCLS_DEBUG, ESS402, ERRZERO,
1321 "Could not give the Semaphore");
1326 #if (ERRCLASS & ERRCLS_DEBUG)
1327 SSLOGERROR(ERRCLS_DEBUG, ESS403, ERRZERO,
1328 "Could not deregister task's timer(s)");
1337 /* ss006.13: addition */
1338 if ( SUnlock(&osCp.tmrTblLock) != ROK)
1340 #if (ERRCLASS & ERRCLS_DEBUG)
1341 SSLOGERROR(ERRCLS_DEBUG, ESS404, ERRZERO,
1342 "Could not give the Semaphore");
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.
1351 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
1354 /* ss002.301 Additions */
1356 #if (ERRCLASS & ERRCLS_DEBUG)
1357 SSLOGERROR(ERRCLS_DEBUG, ESS411, ERRZERO,
1358 "Could not lock TAPA task table");
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 */
1374 /* make sure this TAPA task exists */
1375 if (idx == SS_TSKNC)
1377 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1379 SSLOGERROR(ERRCLS_INT_PAR, ESS412, ERRZERO, "Unknown task");
1380 /* ss002.301 Additions */
1384 tTsk = &osCp.tTskTbl[idx];
1386 /* unlock the TAPA task table */
1387 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
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*/
1393 /*ss014.301 SSI-4GMX specific changes*/
1394 #ifndef SS_4GMX_LCORE
1395 if((tTsk->sTsk == NULLP) || (SS_CHECK_CUR_STSK(tTsk->sTsk)))
1397 #ifdef SS_MULTIPLE_PROCS
1398 ssdProcTTskTerm(procIdIdx, tTsk, idx);
1400 ssdProcTTskTerm(tTsk, idx);
1407 if (SGetMsg(SS_DFLT_REGION, SS_DFLT_POOL, &mBuf) != ROK)
1410 #if (ERRCLASS & ERRCLASS_DEBUG)
1411 SSLOGERROR(ERRCLS_DEBUG, ESS415, ERRZERO, "Could not get a message");
1418 mInfo = (SsMsgInfo *)mBuf->b_rptr;
1419 mInfo->eventInfo.event = SS_EVNT_TTSK_TERM;
1421 mInfo->pst.dstEnt = ent;
1422 mInfo->pst.dstInst = inst;
1424 /* we dont care who is calling SDeregTTsk()
1425 so we dont fill srcEnt and dstInst in mInfo->pst */
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)
1445 SS_RELEASE_SEMA(&osCp.tTskTblSem);
1447 #if (ERRCLASS & ERRCLS_DEBUG)
1448 SSLOGERROR(ERRCLS_INT_PAR, ESS416, ERRZERO, "Could not write to demand queue");
1461 * Fun: Create system task
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.
1468 * RFAILED - failed, general (optional)
1469 * ROUTRES - failed, out of resources (optional)
1478 SSTskPrior tskPrior, /* task priority */
1479 SSTskId *tskId /* filled in with system task ID */
1483 SsSTskEntry *sTsk = NULLP;
1488 #if (ERRCLASS & ERRCLS_INT_PAR)
1489 /* check task ID pointer */
1492 SSLOGERROR(ERRCLS_INT_PAR, ESS417, ERRZERO, "Null pointer");
1496 /* check system task priority */
1497 if (tskPrior > SS_LOWEST_STSK_PRIOR)
1499 SSLOGERROR(ERRCLS_INT_PAR, ESS418, ERRZERO,
1500 "Invalid system task priority");
1506 /* lock the system task table */
1507 ret = SLock(&osCp.sTskTblLock);
1511 #if (ERRCLASS & ERRCLS_DEBUG)
1512 SSLOGERROR(ERRCLS_DEBUG, ESS419, (ErrVal) ret,
1513 "Could not lock system task table");
1520 #ifdef SS_SINGLE_THREADED
1521 /* When singlethreaded, we only need to create one... */
1522 /* ss001.301: additions */
1524 #ifndef SS_MULTICORE_SUPPORT
1525 if (osCp.numSTsks == 1)
1527 if (osCp.numSTsks == 2)
1528 #endif /* SS_MULTICORE_SUPPORT */
1530 #ifndef SS_MULTICORE_SUPPORT
1531 if (osCp.numSTsks == 3)
1533 if (osCp.numSTsks == 4)
1534 #endif /* SS_MULTICORE_SUPPORT */
1535 #endif /* SS_WATCHDOG */
1537 /* ss001.301: additions */
1539 #ifndef SS_MULTICORE_SUPPORT
1541 osCp.sTskTbl[0].termPend = FALSE;
1544 osCp.sTskTbl[1].termPend = FALSE;
1545 #endif /* SS_MULTICORE_SUPPORT */
1547 #ifndef SS_MULTICORE_SUPPORT
1549 osCp.sTskTbl[2].termPend = FALSE;
1552 osCp.sTskTbl[3].termPend = FALSE;
1553 #endif /* SS_MULTICORE_SUPPORT */
1554 #endif /* SS_WATCHDOG */
1556 /* ss006.13: addition */
1557 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1559 #if (ERRCLASS & ERRCLS_DEBUG)
1560 SSLOGERROR(ERRCLS_DEBUG, ESS420, ERRZERO,
1561 "Could not give the Semaphore");
1567 #endif /* SS_SINGLE_THREADED */
1570 /* check count of system tasks */
1571 if (osCp.numSTsks == SS_MAX_STSKS)
1574 /* ss006.13: addition */
1575 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1577 #if (ERRCLASS & ERRCLS_DEBUG)
1578 SSLOGERROR(ERRCLS_DEBUG, ESS421, ERRZERO,
1579 "Could not give the Semaphore");
1584 #if (ERRCLASS & ERRCLS_ADD_RES)
1585 SSLOGERROR(ERRCLS_ADD_RES, ESS422, ERRZERO, "Too many system tasks");
1592 /* initialize the system task entry with the information we have */
1593 sTsk = &osCp.sTskTbl[osCp.nxtSTskEntry];
1595 /* store the system task priority */
1596 sTsk->tskPrior = tskPrior;
1598 /*ss014.301 SSI-4GMX specific changes*/
1599 #ifndef SS_4GMX_LCORE
1600 /* initialize the demand queue */
1601 if (ssInitDmndQ(&sTsk->dQ) != ROK)
1604 /* ss006.13: addition */
1605 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1607 #if (ERRCLASS & ERRCLS_DEBUG)
1608 SSLOGERROR(ERRCLS_DEBUG, ESS423, ERRZERO,
1609 "Could not give the Semaphore");
1614 #if (ERRCLASS & ERRCLS_DEBUG)
1615 SSLOGERROR(ERRCLS_DEBUG, ESS424, (ErrVal) ret,
1616 "Could not initialize demand queue");
1622 /* initialize the system task entry lock */
1623 if (SInitLock(&sTsk->lock, SS_STSKENTRY_LOCK) != ROK)
1625 ssDestroyDmndQ(&sTsk->dQ);
1627 /* ss006.13: addition */
1628 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1630 #if (ERRCLASS & ERRCLS_DEBUG)
1631 SSLOGERROR(ERRCLS_DEBUG, ESS425, ERRZERO,
1632 "Could not give the Semaphore");
1637 #if (ERRCLASS & ERRCLS_DEBUG)
1638 SSLOGERROR(ERRCLS_DEBUG, ESS426, (ErrVal) ret,
1639 "Could not initialize system task entry lock");
1646 /* we ask the implementation to start this system task */
1647 ret = ssdCreateSTsk(sTsk);
1650 /* failed, clean up */
1651 SDestroyLock(&sTsk->lock);
1652 /*ss014.301 SSI-4GMX specific changes*/
1653 #ifndef SS_4GMX_LCORE
1654 ssDestroyDmndQ(&sTsk->dQ);
1659 /* ss006.13: addition */
1660 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1662 #if (ERRCLASS & ERRCLS_DEBUG)
1663 SSLOGERROR(ERRCLS_DEBUG, ESS427, ERRZERO,
1664 "Could not give the Semaphore");
1669 #if (ERRCLASS & ERRCLS_DEBUG)
1670 SSLOGERROR(ERRCLS_DEBUG, ESS428, (ErrVal) ret,
1671 "Could not create system task");
1677 /* success, update the table */
1678 *tskId = osCp.nxtSTskEntry;
1679 sTsk->tskId = osCp.nxtSTskEntry;
1681 sTsk->termPend = FALSE;
1682 osCp.nxtSTskEntry = sTsk->nxt;
1685 #ifdef SS_LOCKLESS_MEMORY
1686 tmpRegTidMap[sTsk->region] = sTsk->dep.tId;
1687 #endif /* SS_LOCKLESS_MEMORY */
1688 /* unlock the system task table */
1690 /* ss006.13: addition */
1691 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1693 #if (ERRCLASS & ERRCLS_DEBUG)
1694 SSLOGERROR(ERRCLS_DEBUG, ESS429, ERRZERO,
1695 "Could not give the Semaphore");
1704 /* ss001.301: additions */
1705 #ifdef SS_LOGGER_SUPPORT
1708 * Fun: Register logger configuration
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.
1717 * RFAILED - failed, general (optional)
1718 * ROUTRES - failed, out of resources (optional)
1740 /*ss013.301: Fixed Warnings for 32/64 bit compilation*/
1741 struct sockaddr_in localAddr={0};
1742 struct sockaddr_in remoteAddr ={0};
1745 #if (ERRCLASS & ERRCLS_INT_PAR)
1748 /* Initialize the lock, return on failure */
1749 if( SInitLock(&(osCp.logger.bufLock),SS_LOCK_MUTEX) != ROK)
1754 SLock(&osCp.logger.bufLock);
1756 /* Initialize the logger configuration flag */
1757 osCp.logger.configured = FALSE;
1759 if( osCp.logger.started == TRUE)
1761 (Void)SUnlock(&(osCp.logger.bufLock));
1765 /* set the mode of the logging */
1768 case SS_LOG_TO_FILE:
1769 osCp.logger.opt |= 0x01;
1771 case SS_LOG_TO_SOCKET:
1772 osCp.logger.opt |= 0x02;
1776 osCp.logger.opt |= 0x03; break;
1780 if (osCp.logger.opt & 0x01)
1782 osCp.logger.filep = fopen(path, "wb");
1783 if(osCp.logger.filep == NULLP)
1785 SDisplay(0,"Error Opening Log File \n");
1786 (Void)SUnlock(&(osCp.logger.bufLock));
1789 strcpy(osCp.logger.filePath,path);
1793 if (osCp.logger.opt & 0x02)
1796 if ((iRes = WSAStartup(MAKEWORD(2,2), &wsaData)) != NO_ERROR)
1798 SDisplay(0, "Error at WSAStartup!\n");
1799 (Void)SUnlock(&(osCp.logger.bufLock));
1803 osCp.logger.socketdes = socket(AF_INET, SOCK_DGRAM, 0);
1804 if(osCp.logger.socketdes == -1)
1806 SDisplay(0,"Error Opening Log Socket \n");
1810 (Void)SUnlock(&(osCp.logger.bufLock));
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)
1819 SDisplay(0,"Error binding to local port \n");
1821 closesocket(osCp.logger.socketdes);
1824 close(osCp.logger.socketdes);
1826 (Void)SUnlock(&(osCp.logger.bufLock));
1829 /* remote address */
1830 remoteAddr.sin_family = AF_INET;
1831 remoteAddr.sin_port = htons(port);
1834 SDisplay(0,"Invalid remote IP Address \n");
1836 closesocket(osCp.logger.socketdes);
1839 close(osCp.logger.socketdes);
1841 (Void)SUnlock(&(osCp.logger.bufLock));
1844 remoteAddr.sin_addr.s_addr = inet_addr(IPA);
1845 osCp.logger.remoteAddr = remoteAddr;
1849 memset(osCp.logger.buffer, '\0', sizeof(osCp.logger.buffer));
1851 osCp.logger.maxBufSiz = SS_MAX_LOGBUF_SIZE;
1852 osCp.logger.curBufSiz = 0;
1854 osCp.logger.maxNumFlush = size/osCp.logger.maxBufSiz;
1855 osCp.logger.curNumFlush = 0;
1858 osCp.logger.started = FALSE;
1859 osCp.logger.configured = TRUE;
1861 (Void)SUnlock(&(osCp.logger.bufLock));
1868 * Fun: SFlushBufToLog
1870 * Desc: This function is used flush the buffer to file/socket.
1879 S16 SFlushBufToLog (S8 *logBuf)
1882 static uint16_t logFileCnt = 0;
1883 S8 newFileName[SS_MAX_PATH];
1890 /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
1894 if (osCp.logger.opt & 0x01)
1896 writeNum = fwrite(buffer, sizeof(uint8_t), cmStrlen((uint8_t *)buffer),
1899 if (osCp.logger.opt & 0x02)
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*/
1905 osCp.logger.curNumFlush++;
1906 if(osCp.logger.curNumFlush == osCp.logger.maxNumFlush)
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;
1914 sprintf(newFileName, "%s%d", osCp.logger.filePath, logFileCnt);
1915 osCp.logger.filep = fopen(newFileName, "wb");
1916 if(osCp.logger.filep == NULLP)
1918 /*MTLOGERROR(ERRCLS_DEBUG, EMTXXX, ERRZERO, "Error Opening Log File. \n");*/
1923 /*SPutSBuf(DFLT_REGION,DFLT_POOL,
1924 (Data *)buffer, (Size)(osCp.logger.maxBufSiz * sizeof(S8)));*/
1927 } /* SFlushBufToLog */
1933 * Desc: This function is used to clean up the logger info.
1945 /*Flush the remaining data in the log file*/
1946 SLock(&osCp.logger.bufLock);
1947 if(osCp.logger.started == FALSE)
1949 (Void)SUnlock(&(osCp.logger.bufLock));
1952 if(osCp.logger.curBufSiz)
1954 SFlushBufToLog(osCp.logger.buffer);
1955 osCp.logger.curBufSiz = 0;
1958 if (osCp.logger.opt & 0x01)
1960 fclose(osCp.logger.filep);
1962 if (osCp.logger.opt & 0x02)
1965 closesocket(osCp.logger.socketdes);
1967 close(osCp.logger.socketdes);
1970 osCp.logger.started = FALSE;
1972 (Void)SUnlock(&(osCp.logger.bufLock));
1974 signal(SIGINT, App_SigExitCallBack);
1979 } /* end of SCleanUp */
1983 * Fun: Unregister the logger.
1985 * Desc: This function is used to deregister a logger task.
1988 * RFAILED - failed, general (optional)
1989 * ROUTRES - failed, out of resources (optional)
2005 } /* SDeregLogCfg */
2011 * Desc: To start logger.
2020 Void SStartLogger(void)
2022 if (osCp.logger.configured == TRUE)
2024 osCp.logger.started = TRUE;
2033 * Desc: To stop logging to file/socket.
2042 Void SStopLogger(void)
2044 osCp.logger.started = FALSE;
2046 #endif /* SS_LOGGER_SUPPORT */
2048 /** for multi-core support **/
2049 /*ss013.301 : changes related to SS_AFFINITY_SUPPORT*/
2050 #if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT)
2054 * Fun: Register the CPU information
2056 * Desc: This function is used to register the number of cores
2057 * present and the number of threads which can be run on
2061 * RFAILED - failed, general (optional)
2070 SCpuInfo *cpuInfo /* Information about the cores/threads per core */
2073 uint32_t coreCount = 0;
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 )
2081 SSLOGERROR(ERRCLS_INT_PAR, ESS430, ERRZERO, "Invalid number of cores\n");
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++)
2092 uint32_t thrCnt = 0;
2093 for (;thrCnt < SS_MAX_THREADS_PER_CORE;thrCnt++)
2095 osCp.mCInfo.coreInfo[coreCount].tskPerCoreLst[thrCnt] = -1;
2097 osCp.mCInfo.coreInfo[coreCount].exclusive = FALSE;
2098 osCp.mCInfo.coreInfo[coreCount].thrs = osCp.mCInfo.cpuInfo.threadRegister[coreCount]
2099 = cpuInfo->threadRegister[coreCount];
2102 SUnlock(&osCp.mCILock);
2112 * Fun: Get the current core/cpu affinity for a thread/lwp
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.
2119 * RFAILED - failed, general (optional)
2128 SSTskId *tskId, /* filled in with system task ID */
2129 uint32_t *coreId /* the core/processor id to which the affinity is set */
2134 /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
2135 /* implementation specific */
2136 ret = ssdGetAffinity(tskId, coreId);
2140 SSLOGERROR(ERRCLS_INT_PAR, ESS431, ERRZERO, "Failed to get affinity\n");
2145 } /* SGetAffinity */
2150 * Fun: Set the core/cpu affinity for a thread/lwp
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.
2157 * RFAILED - failed, general (optional)
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 */
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)
2179 SSLOGERROR(ERRCLS_INT_PAR, ESS432, ERRZERO, "Invalid mode for setting core affinity\n");
2183 /* check the value of core id */
2184 if (SS_AFFINITY_MODE_SPECIFIC == mode &&
2185 (coreId > osCp.mCInfo.cpuInfo.numCores || coreId < 0))
2187 SSLOGERROR(ERRCLS_INT_PAR, ESS433, ERRZERO, "Invalid core id\n");
2191 /* set affinity according to the mode supplied */
2194 case SS_AFFINITY_MODE_DEFAULT:
2196 uint32_t coreCounter = 0, coreIndex = 0;
2199 /*ss013.301: Fixed Warnings for 32/64 bit compilation*/
2200 for (coreIndex = osCp.mCInfo.currentCore;
2201 coreCounter < osCp.mCInfo.cpuInfo.numCores;
2204 /* again start from core 0 */
2206 coreIndex = (coreIndex)%osCp.mCInfo.cpuInfo.numCores;
2207 if (!osCp.mCInfo.coreInfo[coreIndex].exclusive
2208 && osCp.mCInfo.cpuInfo.threadRegister[coreIndex])
2210 if (osCp.mCInfo.coreInfo[coreIndex].thrs || !repeatFlag)
2212 /* call the implementation specific affinity function */
2213 ret = ssdSetAffinity(tskId, coreIndex);
2217 SSLOGERROR(ERRCLS_INT_PAR, ESS434, ERRZERO, \
2218 "Failed to set core affinity\n");
2223 SLock(&osCp.mCILock);
2225 /* move the current core index */
2226 osCp.mCInfo.currentCore = (coreIndex+1)%osCp.mCInfo.cpuInfo.numCores;
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;
2233 /* decrement the available thread count in the thread register */
2234 osCp.mCInfo.coreInfo[coreIndex].thrs--;
2237 SUnlock(&osCp.mCILock);
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 */
2244 if (coreCounter == osCp.mCInfo.cpuInfo.numCores && repeatFlag)
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 */
2251 } /* end case SS_AFFINITY_MODE_DEFAULT */
2252 case SS_AFFINITY_MODE_SPECIFIC:
2254 /* check if the core is used exclusively for any task */
2255 if (osCp.mCInfo.coreInfo[coreId].exclusive)
2257 SSLOGERROR(ERRCLS_INT_PAR, ESS436, ERRZERO,\
2258 "Can not set core affinity, core is exclusively used for other task\n");
2261 /* call the implementation specific affinity function with the core id supplied by caller */
2262 ret = ssdSetAffinity(tskId, coreId);
2266 SSLOGERROR(ERRCLS_INT_PAR, ESS437, ERRZERO, "Failed to set core affinity\n");
2271 SLock(&osCp.mCILock);
2273 /* move the current core index */
2274 osCp.mCInfo.currentCore = (coreId+1)%osCp.mCInfo.cpuInfo.numCores;
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;
2281 /* decrement the available thread count in the thread register */
2282 osCp.mCInfo.coreInfo[coreId].thrs--;
2285 SUnlock(&osCp.mCILock);
2287 if (osCp.mCInfo.coreInfo[coreId].thrs < 0)
2289 SSLOGERROR(ERRCLS_INT_PAR, ESS438, ERRZERO, "Overloading of threads per core!!\n");
2293 } /* end case SS_AFFINITY_MODE_SPECIFIC */
2294 case SS_AFFINITY_MODE_ASSOC:
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++)
2301 for (threadIndex = 0; threadIndex < SS_MAX_THREADS_PER_CORE; threadIndex++)
2303 if (osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[threadIndex] == *tskAssociatedTskId)
2305 if (!osCp.mCInfo.coreInfo[coreIndex].exclusive)
2307 /* set the affinity for the given task on to the core coreIndex */
2308 ret = ssdSetAffinity(tskId, coreIndex);
2311 SSLOGERROR(ERRCLS_INT_PAR, ESS439, ERRZERO, "Failed to set core affinity\n");
2316 SLock(&osCp.mCILock);
2318 /* move the current core index */
2319 osCp.mCInfo.currentCore = (coreIndex+1)%osCp.mCInfo.cpuInfo.numCores;
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;
2326 /* decrement the available thread count in the thread register */
2327 osCp.mCInfo.coreInfo[coreIndex].thrs--;
2330 SUnlock(&osCp.mCILock);
2332 if (osCp.mCInfo.coreInfo[coreIndex].thrs < 0)
2334 SSLOGERROR(ERRCLS_INT_PAR, ESS440, ERRZERO,
2335 "Overloading of threads per core!!\n");
2341 SSLOGERROR(ERRCLS_INT_PAR, ESS441, ERRZERO,
2342 "Can not set core affinity, core is exclusively used for other task\n");
2345 tskNotFound = FALSE;
2348 } /* end inner for */
2351 /* check if tskAssociatedTskId is valid or not */
2352 if (coreIndex == SS_MAX_CORES)
2354 SSLOGERROR(ERRCLS_INT_PAR, ESS442, ERRZERO, "Invalid core id\n");
2358 } /* end case SS_AFFINITY_MODE_ASSOC */
2359 case SS_AFFINITY_MODE_EXCL:
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)
2366 /* call the implementation specific affinity function */
2367 ret = ssdSetAffinity(tskId, coreId);
2371 SSLOGERROR(ERRCLS_INT_PAR, ESS443, ERRZERO, "Failed to set core affinity\n");
2376 SLock(&osCp.mCILock);
2378 /* set the exclusive flag so that the core will not be used for other system tasks */
2379 osCp.mCInfo.coreInfo[coreId].exclusive = TRUE;
2381 /* save the tskId in tskList */
2382 osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[osCp.mCInfo.cpuInfo.threadRegister[coreId] -
2383 osCp.mCInfo.coreInfo[coreId].thrs] = *tskId;
2385 /* decrement the available thread count in the thread register */
2386 osCp.mCInfo.coreInfo[coreId].thrs--;
2389 SUnlock(&osCp.mCILock);
2392 else if (coreId == SS_DEFAULT_CORE)
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;
2402 coreIndex = (coreIndex)%osCp.mCInfo.cpuInfo.numCores;
2403 if (!osCp.mCInfo.coreInfo[coreIndex].exclusive
2404 && osCp.mCInfo.cpuInfo.threadRegister[coreIndex])
2406 if ( osCp.mCInfo.coreInfo[coreIndex].thrs ==
2407 osCp.mCInfo.cpuInfo.threadRegister[coreIndex] &&
2408 osCp.mCInfo.coreInfo[coreIndex].thrs)
2410 /* call the implementation specific affinity function */
2411 ret = ssdSetAffinity(tskId, coreIndex);
2415 SSLOGERROR(ERRCLS_INT_PAR, ESS444, ERRZERO, "Failed to set core affinity\n");
2420 SLock(&osCp.mCILock);
2422 /* move the current core index */
2423 osCp.mCInfo.currentCore = (coreIndex+1)%osCp.mCInfo.cpuInfo.numCores;
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;
2430 /* decrement the available thread count in the thread register */
2431 osCp.mCInfo.coreInfo[coreIndex].thrs--;
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;
2438 SUnlock(&osCp.mCILock);
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 */
2445 if (coreCounter == osCp.mCInfo.cpuInfo.numCores)
2447 SSLOGERROR(ERRCLS_INT_PAR, ESS445, ERRZERO,
2448 "Failed to set core affinity, no threads on cores available\n");
2450 } /* end if no thrs on cores available */
2455 SSLOGERROR(ERRCLS_INT_PAR, ESS446, ERRZERO, "Can not set exclusive affinity for the core\n");
2459 } /* end case SS_AFFINITY_MODE_EXCL */
2462 SSLOGERROR(ERRCLS_INT_PAR, ESS447, ERRZERO, "Invalid mode for setting core affinity\n");
2464 } /* end default case */
2465 } /* end of switch */
2470 } /* SSetAffinity */
2472 #endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT*/
2474 /** end multi-core support **/
2479 * Fun: Destroy system task
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.
2486 * RFAILED - failed, general (optional)
2495 SSTskId tskId /* system task to be destroyed */
2499 /* ss029.103: modification: the subscript should be of same type */
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*/
2512 #if (ERRCLASS & ERRCLS_INT_PAR)
2513 /* validate the system task ID */
2514 if (tskId >= SS_MAX_STSKS)
2516 SSLOGERROR(ERRCLS_INT_PAR, ESS448, (ErrVal) tskId, "Invalid task ID");
2522 /* lock the system task table */
2523 ret = SLock(&osCp.sTskTblLock);
2527 #if (ERRCLASS & ERRCLS_DEBUG)
2528 SSLOGERROR(ERRCLS_DEBUG, ESS449, (ErrVal) ret,
2529 "Could not lock system task table");
2536 idx = (SsIdx) tskId;
2537 sTsk = &osCp.sTskTbl[idx];
2540 #if (ERRCLASS & ERRCLS_INT_PAR)
2542 * check to see this system task exists and it is not already scheduled
2545 if (sTsk->used != TRUE)
2548 /* ss006.13: addition */
2549 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2551 #if (ERRCLASS & ERRCLS_DEBUG)
2552 SSLOGERROR(ERRCLS_DEBUG, ESS450, ERRZERO,
2553 "Could not give the Semaphore");
2558 SSLOGERROR(ERRCLS_INT_PAR, ESS451, (ErrVal) idx,
2559 "Invalid system task ID");
2562 else if (sTsk->termPend != FALSE)
2565 /* ss006.13: addition */
2566 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2568 #if (ERRCLASS & ERRCLS_DEBUG)
2569 SSLOGERROR(ERRCLS_DEBUG, ESS452, ERRZERO,
2570 "Could not give the Semaphore");
2575 SSLOGERROR(ERRCLS_INT_PAR, ESS453, (ErrVal) idx,
2576 "Invalid system task ID");
2582 /* lock this system task entry */
2583 if (!SS_CHECK_CUR_STSK(sTsk))
2585 ret = SLock(&sTsk->lock);
2589 /* ss006.13: addition */
2590 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2592 #if (ERRCLASS & ERRCLS_DEBUG)
2593 SSLOGERROR(ERRCLS_DEBUG, ESS454, ERRZERO,
2594 "Could not give the Semaphore");
2599 #if (ERRCLASS & ERRCLS_DEBUG)
2600 SSLOGERROR(ERRCLS_DEBUG, ESS455, (ErrVal) ret,
2601 "Could not lock system task entry");
2608 /* lock the TAPA task table */
2609 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
2612 if (!SS_CHECK_CUR_STSK(sTsk))
2615 /* ss006.13: addition */
2616 if ( SUnlock(&sTsk->lock) != ROK)
2618 #if (ERRCLASS & ERRCLS_DEBUG)
2619 SSLOGERROR(ERRCLS_DEBUG, ESS456, ERRZERO,
2620 "Could not give the Semaphore");
2626 /* ss006.13: addition */
2627 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2629 #if (ERRCLASS & ERRCLS_DEBUG)
2630 SSLOGERROR(ERRCLS_DEBUG, ESS457, ERRZERO,
2631 "Could not give the Semaphore");
2636 #if (ERRCLASS & ERRCLS_DEBUG)
2637 SSLOGERROR(ERRCLS_DEBUG, ESS458, ERRZERO,
2638 "Could not lock TAPA task table");
2645 /* If this system task entry has any TAPA tasks attached,
2646 * we have to detach them
2650 /* detach all TAPA tasks that are attached here */
2651 for (i = 0; i < SS_MAX_TTSKS; i++)
2653 if (sTsk->tTsks[i] == SS_INVALID_IDX)
2656 osCp.tTskTbl[sTsk->tTsks[i]].sTsk = NULLP;
2657 sTsk->tTsks[i] = SS_INVALID_IDX;
2663 /* set the termination pending flag to TRUE */
2664 sTsk->termPend = TRUE;
2667 /* unlock everything */
2668 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
2670 if (!SS_CHECK_CUR_STSK(sTsk))
2673 /* ss006.13: addition */
2674 if ( SUnlock(&sTsk->lock) != ROK)
2676 #if (ERRCLASS & ERRCLS_DEBUG)
2677 SSLOGERROR(ERRCLS_DEBUG, ESS459, ERRZERO,
2678 "Could not give the Semaphore");
2685 /* ss006.13: addition */
2686 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2688 #if (ERRCLASS & ERRCLS_DEBUG)
2689 SSLOGERROR(ERRCLS_DEBUG, ESS460, ERRZERO,
2690 "Could not give the Semaphore");
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
2702 ret = ssdDestroySTsk(sTsk);
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..??
2709 #if (ERRCLASS & ERRCLS_DEBUG)
2710 SSLOGERROR(ERRCLS_DEBUG, ESS461, (ErrVal) ret,
2711 "Could not destroy system task");
2717 /* multi-core support */
2718 /*ss013.301 : changes related to SS_AFFINITY_SUPPORT*/
2719 #if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT)
2721 /* Remove CPU affinity if any */
2722 for (tskInd = 0; tskInd < SS_MAX_STSKS; tskInd++)
2724 if (osCp.sTskTbl[tskInd].tskId == sTsk->tskId)
2726 /* search for the tskId in coreInfo */
2727 uint32_t coreId = 0;
2728 for (coreId = 0; coreId < SS_MAX_CORES; coreId++)
2731 for (thrId = 0; thrId < SS_MAX_THREADS_PER_CORE; thrId++)
2733 if (sTsk->tskId == osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[thrId])
2736 SLock(&osCp.mCILock);
2738 /* increment the available threads */
2739 osCp.mCInfo.coreInfo[coreId].thrs++;
2741 /* reset the thread id */
2742 osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[thrId] = 0;
2744 /* if exclusive flag is set then remove it */
2745 if (osCp.mCInfo.coreInfo[coreId].exclusive)
2747 osCp.mCInfo.coreInfo[coreId].exclusive = FALSE;
2748 } /* end if excl set */
2751 SUnlock(&osCp.mCILock);
2754 } /* end if sTsk matched a thread */
2755 } /* end for loop of thread Ids */
2761 #endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT*/
2762 /* end multi-core support */
2764 /* ss019.103 - added to release semaphore for system task */
2766 if (ssPostSema(&osCp.dep.ssStarted) != ROK)
2768 #if (ERRCLASS & ERRCLS_DEBUG)
2769 SSLOGERROR(ERRCLS_DEBUG, ESS462, ERRZERO,
2770 "Could not unlock the Semaphore");
2777 } /* SDestroySTsk */
2783 * Fun: Attach TAPA task
2785 * Desc: This function is used to attach a TAPA task to a
2786 * system task. The system task will begin to execute
2790 * RFAILED - failed, general (optional)
2791 * ROUTRES - failed, out of resources (optional)
2798 /* ss029.103: addition: procId added */
2799 #ifndef SS_MULTIPLE_PROCS
2803 Ent ent, /* entity ID of the task */
2804 Inst inst, /* instance ID of the task */
2805 SSTskId sTskId /* system task to use */
2808 #else /* SS_MULTIPLE_PROCS */
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 */
2817 #endif /* SS_MULTIPLE_PROCS */
2823 /* ss029.103: addition: multiple procIds related changes */
2824 #ifdef SS_MULTIPLE_PROCS
2826 #endif /* SS_MULTIPLE_PROCS */
2827 #ifdef SS_MULTICORE_SUPPORT
2829 #ifdef SS_MULTIPLE_PROCS
2831 #endif /* SS_MULTIPLE_PROCS */
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))
2844 SSLOGERROR(ERRCLS_INT_PAR, ESS463, ERRZERO, "Invalid processor/entity/instance");
2847 #else /* SS_MULTIPLE_PROCS */
2848 /* check entity and instance range */
2849 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
2851 SSLOGERROR(ERRCLS_INT_PAR, ESS464, ERRZERO, "Invalid entity/instance");
2854 #endif /* SS_MULTIPLE_PROCS */
2856 /* check the system task index */
2857 if ((SsIdx)sTskId >= SS_MAX_STSKS)
2859 SSLOGERROR(ERRCLS_INT_PAR, ESS465, (ErrVal) sTskId,
2860 "Invalid system task ID");
2865 /* ss029.103: addition: multiple procIds related changes */
2866 #ifdef SS_MULTIPLE_PROCS
2867 /* get the proc id idx */
2868 procIdIdx = SGetProcIdIdx(proc);
2870 if (procIdIdx == SS_INV_PROCID)
2872 #if (ERRCLASS & ERRCLS_DEBUG)
2873 SSLOGERROR(ERRCLS_DEBUG, ESS466, ERRZERO,
2874 "Could not find proc id index");
2878 #endif /* SS_MULTIPLE_PROCS */
2880 /* lock the system task table */
2881 ret = SLock(&osCp.sTskTblLock);
2885 #if (ERRCLASS & ERRCLS_DEBUG)
2886 SSLOGERROR(ERRCLS_DEBUG, ESS467, (ErrVal) ret,
2887 "Could not lock system task table");
2894 sTsk = &osCp.sTskTbl[(SsIdx)sTskId];
2897 #if (ERRCLASS & ERRCLS_INT_PAR)
2898 /* verify that this system task exists */
2899 if (sTsk->used == FALSE)
2902 /* ss006.13: addition */
2903 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2905 #if (ERRCLASS & ERRCLS_DEBUG)
2906 SSLOGERROR(ERRCLS_DEBUG, ESS468, ERRZERO,
2907 "Could not give the Semaphore");
2912 SSLOGERROR(ERRCLS_INT_PAR, ESS469, (ErrVal) sTskId,
2913 "Unknown system task ID");
2919 /* lock the system task entry */
2920 if (!SS_CHECK_CUR_STSK(sTsk))
2922 ret = SLock(&sTsk->lock);
2926 /* ss006.13: addition */
2927 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2929 #if (ERRCLASS & ERRCLS_DEBUG)
2930 SSLOGERROR(ERRCLS_DEBUG, ESS470, ERRZERO,
2931 "Could not give the Semaphore");
2936 #if (ERRCLASS & ERRCLS_DEBUG)
2937 SSLOGERROR(ERRCLS_DEBUG, ESS471, (ErrVal) ret,
2938 "Could not lock system task entry");
2946 /* if this system task is about to die, we don't attach */
2947 if (sTsk->termPend == TRUE)
2949 if (!SS_CHECK_CUR_STSK(sTsk))
2952 /* ss006.13: addition */
2953 if ( SUnlock(&sTsk->lock) != ROK)
2955 #if (ERRCLASS & ERRCLS_DEBUG)
2956 SSLOGERROR(ERRCLS_DEBUG, ESS472, ERRZERO,
2957 "Could not give the Semaphore");
2963 /* ss006.13: addition */
2964 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2966 #if (ERRCLASS & ERRCLS_DEBUG)
2967 SSLOGERROR(ERRCLS_DEBUG, ESS473, ERRZERO,
2968 "Could not give the Semaphore");
2977 /* lock the TAPA task table */
2978 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
2981 if (!SS_CHECK_CUR_STSK(sTsk))
2984 /* ss006.13: addition */
2985 if ( SUnlock(&sTsk->lock) != ROK)
2987 #if (ERRCLASS & ERRCLS_DEBUG)
2988 SSLOGERROR(ERRCLS_DEBUG, ESS474, ERRZERO,
2989 "Could not give the Semaphore");
2996 /* ss006.13: addition */
2997 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2999 #if (ERRCLASS & ERRCLS_DEBUG)
3000 SSLOGERROR(ERRCLS_DEBUG, ESS475, ERRZERO,
3001 "Could not give the Semaphore");
3006 #if (ERRCLASS & ERRCLS_DEBUG)
3007 SSLOGERROR(ERRCLS_DEBUG, ESS476, ERRZERO,
3008 "Could not lock TAPA task table");
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 */
3023 #if (ERRCLASS & ERRCLS_INT_PAR)
3024 /* check out the TAPA task ID */
3025 if (idx == SS_TSKNC)
3027 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3028 if (!SS_CHECK_CUR_STSK(sTsk))
3031 /* ss006.13: addition */
3032 if ( SUnlock(&sTsk->lock) != ROK)
3034 #if (ERRCLASS & ERRCLS_DEBUG)
3035 SSLOGERROR(ERRCLS_DEBUG, ESS477, ERRZERO,
3036 "Could not give the Semaphore");
3042 /* ss006.13: addition */
3043 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3045 #if (ERRCLASS & ERRCLS_DEBUG)
3046 SSLOGERROR(ERRCLS_DEBUG, ESS478, ERRZERO,
3047 "Could not give the Semaphore");
3052 SSLOGERROR(ERRCLS_INT_PAR, ESS479, ERRZERO, "Unknown task");
3058 /* verify that this TAPA task is not already attached */
3059 if (osCp.tTskTbl[idx].sTsk != NULLP)
3061 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3062 if (!SS_CHECK_CUR_STSK(sTsk))
3065 /* ss006.13: addition */
3066 if ( SUnlock(&sTsk->lock) != ROK)
3068 #if (ERRCLASS & ERRCLS_DEBUG)
3069 SSLOGERROR(ERRCLS_DEBUG, ESS480, ERRZERO,
3070 "Could not give the Semaphore");
3076 /* ss006.13: addition */
3077 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3079 #if (ERRCLASS & ERRCLS_DEBUG)
3080 SSLOGERROR(ERRCLS_DEBUG, ESS481, ERRZERO,
3081 "Could not give the Semaphore");
3090 /* verify that there is space for another TAPA task */
3091 if (sTsk->numTTsks == SS_MAX_TTSKS)
3093 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3094 if (!SS_CHECK_CUR_STSK(sTsk))
3097 /* ss006.13: addition */
3098 if ( SUnlock(&sTsk->lock) != ROK)
3100 #if (ERRCLASS & ERRCLS_DEBUG)
3101 SSLOGERROR(ERRCLS_DEBUG, ESS482, ERRZERO,
3102 "Could not give the Semaphore");
3108 /* ss006.13: addition */
3109 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3111 #if (ERRCLASS & ERRCLS_DEBUG)
3112 SSLOGERROR(ERRCLS_DEBUG, ESS483, ERRZERO,
3113 "Could not give the Semaphore");
3122 /* Find place for this TAPA task in the system task's list
3123 * of TAPA tasks to run. Plug in this TAPA task.
3125 for (i = 0; i < SS_MAX_TTSKS; i++)
3127 if (sTsk->tTsks[i] == SS_INVALID_IDX)
3129 sTsk->tTsks[i] = idx;
3136 /* Fill in the system task info in the TAPA task entry, so
3137 * the TAPA task knows who's running it.
3139 osCp.tTskTbl[idx].sTsk = sTsk;
3140 #ifdef SS_MULTICORE_SUPPORT
3141 tTsk = &osCp.tTskTbl[idx];
3142 if(tTsk->initTsk != NULLP)
3144 #ifndef SS_MULTIPLE_PROCS
3145 (Void)(tTsk->initTsk)(tTsk->ent, tTsk->inst, sTsk->region, PWR_UP);
3147 /* retrieve proc id index in the proc id table */
3148 procIdIdx = SGetProcIdIdx(tTsk->proc);
3150 /* Check whether the proc id exist in the proc id table */
3151 if (procIdIdx == SS_INV_PROCID_IDX)
3153 #if (ERRCLASS & ERRCLS_INT_PAR)
3154 SSLOGERROR(ERRCLS_INT_PAR, ESS389, ERRZERO,
3155 "Could not find proc table index");
3160 (Void)(tTsk->initTsk)(tTsk->proc, tTsk->ent, tTsk->inst, sTsk->region, PWR_UP, &xxCb);
3162 * store the control block. The control block may be NULL in some cases
3164 idx = osCp.tTskIds[procIdIdx][tTsk->ent][tTsk->inst];
3165 #if (ERRCLASS & ERRCLS_INT_PAR)
3166 if ( xxCb == NULLP )
3168 SSLOGERROR(ERRCLS_INT_PAR, ERRZERO, ERRZERO,
3172 osCp.tTskTbl[idx].xxCb = xxCb;
3173 #endif /* SS_MULTIPLE_PROCS */
3175 #endif /* SS_MULTICORE_SUPPORT */
3178 /* call the implementation to do anything implementation-specific */
3179 ret = ssdAttachTTsk(&osCp.tTskTbl[idx]);
3182 /* unlock the tables; we're done */
3183 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3184 if (!SS_CHECK_CUR_STSK(sTsk))
3187 /* ss006.13: addition */
3188 if ( SUnlock(&sTsk->lock) != ROK)
3190 #if (ERRCLASS & ERRCLS_DEBUG)
3191 SSLOGERROR(ERRCLS_DEBUG, ESS484, ERRZERO,
3192 "Could not give the Semaphore");
3198 /* ss006.13: addition */
3199 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3201 #if (ERRCLASS & ERRCLS_DEBUG)
3202 SSLOGERROR(ERRCLS_DEBUG, ESS485, ERRZERO,
3203 "Could not give the Semaphore");
3209 /* If the implementation didn't succeed, we have to undo everything.
3210 * We call SDetachTTsk, to make it easier.
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 */
3230 * Fun: Detach TAPA task
3232 * Desc: This function is used to detach a TAPA task from a
3233 * system task. The system task will stop executing
3237 * RFAILED - failed, general (optional)
3244 /* ss029.103: addition: procId added */
3245 #ifndef SS_MULTIPLE_PROCS
3249 Ent ent, /* entity ID of the task */
3250 Inst inst /* instance ID of the task */
3253 #else /* SS_MULTIPLE_PROCS */
3257 ProcId proc, /* processor ID of the task */
3258 Ent ent, /* entity ID of the task */
3259 Inst inst /* instance ID of the task */
3262 #endif /* SS_MULTIPLE_PROCS */
3270 /* ss029.103: addition: multiple procIds related changes */
3271 #ifdef SS_MULTIPLE_PROCS
3273 #endif /* SS_MULTIPLE_PROCS */
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))
3284 SSLOGERROR(ERRCLS_INT_PAR, ESS486, ERRZERO, "Invalid processor/entity/instance");
3287 #else /* SS_MULTIPLE_PROCS */
3288 /* check entity and instance ranges */
3289 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
3291 SSLOGERROR(ERRCLS_INT_PAR, ESS487, ERRZERO, "Invalid entity/instance");
3294 #endif /* SS_MULTIPLE_PROCS */
3297 /* ss029.103: addition: multiple procIds related changes */
3298 #ifdef SS_MULTIPLE_PROCS
3299 /* get the proc id idx */
3300 procIdIdx = SGetProcIdIdx(proc);
3302 if (procIdIdx == SS_INV_PROCID)
3304 #if (ERRCLASS & ERRCLS_DEBUG)
3305 SSLOGERROR(ERRCLS_DEBUG, ESS488, ERRZERO,
3306 "Could not find proc id index");
3310 #endif /* SS_MULTIPLE_PROCS */
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.
3317 ret = SLock(&osCp.sTskTblLock);
3321 #if (ERRCLASS & ERRCLS_DEBUG)
3322 SSLOGERROR(ERRCLS_DEBUG, ESS489, (ErrVal) ret,
3323 "Could not lock system task table");
3330 /* lock the TAPA task table */
3331 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
3335 /* ss006.13: addition */
3336 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3338 #if (ERRCLASS & ERRCLS_DEBUG)
3339 SSLOGERROR(ERRCLS_DEBUG, ESS490, ERRZERO,
3340 "Could not give the Semaphore");
3345 #if (ERRCLASS & ERRCLS_DEBUG)
3346 SSLOGERROR(ERRCLS_DEBUG, ESS491, ERRZERO,
3347 "Could not lock TAPA task table");
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
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 */
3366 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3368 /* ss006.13: addition */
3369 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3371 #if (ERRCLASS & ERRCLS_DEBUG)
3372 SSLOGERROR(ERRCLS_DEBUG, ESS492, ERRZERO,
3373 "Could not give the Semaphore");
3378 SSLOGERROR(ERRCLS_INT_PAR, ESS493, ERRZERO, "Unknown task");
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 */
3390 tTsk = &osCp.tTskTbl[idx];
3392 /* check if this TAPA task is attached to anyone */
3393 if (tTsk->sTsk == NULLP)
3395 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3397 /* ss006.13: addition */
3398 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3400 #if (ERRCLASS & ERRCLS_DEBUG)
3401 SSLOGERROR(ERRCLS_DEBUG, ESS494, ERRZERO,
3402 "Could not give the Semaphore");
3410 /* we get the system task entry out */
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.
3420 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3423 /* lock the system task entry */
3424 if (!SS_CHECK_CUR_STSK(sTsk))
3426 ret = SLock(&sTsk->lock);
3430 /* ss006.13: addition */
3431 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3433 #if (ERRCLASS & ERRCLS_DEBUG)
3434 SSLOGERROR(ERRCLS_DEBUG, ESS495, ERRZERO,
3435 "Could not give the Semaphore");
3440 #if (ERRCLASS & ERRCLS_DEBUG)
3441 SSLOGERROR(ERRCLS_DEBUG, ESS496, (ErrVal) ret,
3442 "Could not lock system task entry");
3450 /* now we lock the TAPA task table */
3451 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
3455 /* ss006.13: addition */
3456 if ( SUnlock(&sTsk->lock) != ROK)
3458 #if (ERRCLASS & ERRCLS_DEBUG)
3459 SSLOGERROR(ERRCLS_DEBUG, ESS497, ERRZERO,
3460 "Could not give the Semaphore");
3464 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3466 #if (ERRCLASS & ERRCLS_DEBUG)
3467 SSLOGERROR(ERRCLS_DEBUG, ESS498, ERRZERO,
3468 "Could not give the Semaphore");
3473 #if (ERRCLASS & ERRCLS_DEBUG)
3474 SSLOGERROR(ERRCLS_DEBUG, ESS499, ERRZERO,
3475 "Could not lock TAPA task table");
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.
3489 /* Remove this TAPA task from the system task's list of
3490 * TAPA tasks to run.
3492 for (i = 0; i < SS_MAX_TTSKS; i++)
3494 if (sTsk->tTsks[i] == idx)
3496 sTsk->tTsks[i] = SS_INVALID_IDX;
3503 /* call the implementation to do anything it needs to */
3504 ret = ssdDetachTTsk(tTsk);
3507 /* unlock the TAPA task table */
3508 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3510 /* unlock the system task entry */
3511 if (!SS_CHECK_CUR_STSK(sTsk))
3514 /* ss006.13: addition */
3515 if ( SUnlock(&sTsk->lock) != ROK)
3517 #if (ERRCLASS & ERRCLS_DEBUG)
3518 SSLOGERROR(ERRCLS_DEBUG, ESS500, ERRZERO,
3519 "Could not give the Semaphore");
3525 /* unlock the system task table */
3527 /* ss006.13: addition */
3528 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3530 #if (ERRCLASS & ERRCLS_DEBUG)
3531 SSLOGERROR(ERRCLS_DEBUG, ESS501, ERRZERO,
3532 "Could not give the Semaphore");
3538 /* If the implementation couldn't detach the task, we just
3539 * return an error, nothing else we can do.
3553 * Fun: Post a message to a task
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
3561 * RFAILED - failed, general (optional)
3570 Pst *pst, /* post information */
3571 Buffer *mBuf /* message to post */
3576 #if (defined(SS_DRVR_SUPPORT))
3584 #if (defined(SS_DRVR_SUPPORT) || defined(SS_RTR_SUPPORT))
3587 #ifdef SS_DRVR_SUPPORT
3588 Bool nPstUsed = FALSE;
3590 #if (defined(SS_RTR_SUPPORT))
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
3602 cvmx_wqe_t *workPtr;
3603 #endif /* SS_SEUM_CAVIUM */
3608 #ifdef MSPD_MLOG_NEW
3609 uint32_t t = MacGetTick();
3614 #if (ERRCLASS & ERRCLS_INT_PAR)
3615 /* check the message buffer */
3618 SSLOGERROR(ERRCLS_INT_PAR, ESS502, ERRZERO, "Invalid message buffer");
3622 /* check the pst structure */
3626 SSLOGERROR(ERRCLS_INT_PAR, ESS503, ERRZERO, "Null pointer");
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)
3635 SSLOGERROR(ERRCLS_INT_PAR, ESS504, ERRZERO, "No route defined");
3640 #ifndef TENB_RTLIN_CHANGES
3641 /* lock the TAPA task table */
3642 SS_ACQUIRE_SEMA(&osCp.tTskTblSem, r);
3647 #if (ERRCLASS & ERRCLS_DEBUG)
3648 SSLOGERROR(ERRCLS_DEBUG, ESS505, ERRZERO,
3649 "Could not lock TAPA task table");
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 */
3667 #ifndef TENB_RTLIN_CHANGES
3668 /* ss006.13: addition */
3669 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3671 #if (ERRCLASS & ERRCLS_DEBUG)
3672 SSLOGERROR(ERRCLS_DEBUG, ESS506, ERRZERO,
3673 "Could not release the semaphore");
3681 SSLOGERROR(ERRCLS_INT_PAR, ESS507, ERRZERO,
3682 "Invalid source/destination entity/instance");
3688 /* ss019.103 - modified for use with message router in virtual/physical
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)
3695 /* copy the Pst structure into a local duplicate */
3696 for (i = 0; i < (S16)sizeof(Pst); i++)
3698 *(((uint8_t *)(&nPst)) + i) = *(((uint8_t *) pst) + i);
3701 #ifdef SS_DRVR_SUPPORT
3705 /* lock the router task entry */
3707 r = SLock(&osCp.rtrTskLocks[rte]);
3710 /* ss006.13: addition */
3711 #ifndef TENB_RTLIN_CHANGES
3712 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3714 #if (ERRCLASS & ERRCLS_DEBUG)
3715 SSLOGERROR(ERRCLS_DEBUG, ESS508, ERRZERO,
3716 "Could not release the semaphore");
3723 #if (ERRCLASS & ERRCLS_DEBUG)
3724 SSLOGERROR(ERRCLS_DEBUG, ESS509, ERRZERO,
3725 "Could not lock router task entry");
3731 /* call the router activation function */
3732 r = (*osCp.rtrTskTbl[rte])(pst, mBuf);
3734 /* unlock the router task entry */
3736 /* ss006.13: addition */
3737 if ( SUnlock(&osCp.rtrTskLocks[rte]) != ROK)
3739 #if (ERRCLASS & ERRCLS_DEBUG)
3740 SSLOGERROR(ERRCLS_DEBUG, ESS510, ERRZERO,
3741 "Could not give the Semaphore");
3746 if (r == RFAILED || r == ROKIGNORE)
3748 /* ss006.13: addition */
3749 #ifndef TENB_RTLIN_CHANGES
3750 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3752 #if (ERRCLASS & ERRCLS_DEBUG)
3753 SSLOGERROR(ERRCLS_DEBUG, ESS511, ERRZERO,
3754 "Could not release the semaphore");
3759 return ((r == RFAILED) ? RFAILED : ROK);
3762 #endif /* SS_RTR_SUPPORT */
3764 /* ss029.103: addition: multiple procIds related changes */
3765 #ifdef SS_MULTIPLE_PROCS
3767 /* get proc id index */
3768 srcProcIdIdx = SGetProcIdIdx(pst->srcProcId);
3769 dstProcIdIdx = SGetProcIdIdx(pst->dstProcId);
3771 if (srcProcIdIdx != SS_INV_PROCID_IDX)
3772 srcIdx = osCp.tTskIds[srcProcIdIdx][pst->srcEnt][pst->srcInst];
3774 if (dstProcIdIdx != SS_INV_PROCID_IDX)
3775 dstIdx = osCp.tTskIds[dstProcIdIdx][pst->dstEnt][pst->dstInst];
3777 if (((srcProcIdIdx != SS_INV_PROCID_IDX) && (srcIdx == SS_TSKNC)) ||
3778 ((dstProcIdIdx != SS_INV_PROCID_IDX) && (dstIdx == SS_TSKNC)))
3780 #ifndef TENB_RTLIN_CHANGES
3781 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3783 #if (ERRCLASS & ERRCLS_DEBUG)
3784 SSLOGERROR(ERRCLS_DEBUG, ESS512, ERRZERO,
3785 "Could not release the semaphore");
3793 #if (ERRCLASS & ERRCLS_DEBUG)
3794 SSLOGERROR(ERRCLS_DEBUG, ESS513, ERRZERO, "Unknown task");
3800 #else /* SS_MULTIPLE_PROCS */
3801 /* ss019.103 - modified for use with message router in virtual/physical
3804 /* get the src and destination task */
3805 srcIdx = osCp.tTskIds[pst->srcEnt][pst->srcInst];
3806 dstIdx = osCp.tTskIds[pst->dstEnt][pst->dstInst];
3809 /* If the source/destination processor ID is local, the
3810 * source/destination TAPA task must be local.
3812 if ((pst->srcProcId == osCp.procId && srcIdx == SS_TSKNC)
3813 || (pst->dstProcId == osCp.procId && dstIdx == SS_TSKNC))
3815 /* ss006.13: addition */
3816 #ifndef TENB_RTLIN_CHANGES
3817 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3819 #if (ERRCLASS & ERRCLS_DEBUG)
3820 SSLOGERROR(ERRCLS_DEBUG, ESS514, ERRZERO,
3821 "Could not release the semaphore");
3828 #if (ERRCLASS & ERRCLS_DEBUG)
3829 SSLOGERROR(ERRCLS_DEBUG, ESS515, ERRZERO, "Unknown task");
3835 #endif /* SS_MULTIPLE_PROCS */
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
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 */
3849 /* Need to optimize this search.
3851 for (i = 0; i < SS_MAX_DRVRTSKS; i++)
3853 if (osCp.drvrTskTbl[i].used
3854 && pst->dstProcId >= osCp.drvrTskTbl[i].low
3855 && pst->dstProcId <= osCp.drvrTskTbl[i].high)
3857 /* Copy the Pst structure into a local duplicate if not
3862 for (j = 0; j < (S16)sizeof(Pst); j++)
3864 *(((uint8_t *)(&nPst)) + j) = *(((uint8_t *) pst) + j);
3872 //if (clusterMode == NET_CLUSTER_MODE)
3875 /* lock the driver task entry */
3876 r = SLock(&osCp.drvrTskTbl[i].lock);
3879 /* ss006.13: addition */
3880 #ifndef TENB_RTLIN_CHANGES
3881 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3883 #if (ERRCLASS & ERRCLS_DEBUG)
3884 SSLOGERROR(ERRCLS_DEBUG, ESS516, ERRZERO,
3885 "Could not release the semaphore");
3892 #if (ERRCLASS & ERRCLS_DEBUG)
3893 SSLOGERROR(ERRCLS_DEBUG, ESS517, ERRZERO,
3894 "Could not lock driver task entry");
3902 /*ss014.301 SSI-4GMX specific change*/
3903 #ifndef SS_4GMX_LCORE
3904 CMCHKPKLOG(cmPkInst, osCp.drvrTskTbl[i].channel, mBuf, ESS518, pst);
3907 (osCp.drvrTskTbl[i].actvTsk)(pst, mBuf);
3911 //if (clusterMode == NET_CLUSTER_MODE)
3914 /* ss006.13: addition */
3915 if ( SUnlock(&osCp.drvrTskTbl[i].lock) != ROK)
3917 #if (ERRCLASS & ERRCLS_DEBUG)
3918 SSLOGERROR(ERRCLS_DEBUG, ESS519, ERRZERO,
3919 "Could not give the Semaphore");
3927 /* ss006.13: addition */
3928 #ifndef TENB_RTLIN_CHANGES
3929 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3931 #if (ERRCLASS & ERRCLS_DEBUG)
3932 SSLOGERROR(ERRCLS_DEBUG, ESS520, ERRZERO,
3933 "Could not release the semaphore");
3942 /* ss006.13: addition */
3943 #ifndef TENB_RTLIN_CHANGES
3944 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3946 #if (ERRCLASS & ERRCLS_DEBUG)
3947 SSLOGERROR(ERRCLS_DEBUG, ESS521, ERRZERO,
3948 "Could not release the semaphore");
3955 #if (ERRCLASS & ERRCLS_DEBUG)
3956 SSLOGERROR(ERRCLS_DEBUG, ESS522, ERRZERO,
3957 "Could not find a driver task to handle this proc ID");
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
3967 tTsk = &osCp.tTskTbl[dstIdx];
3969 memcpy(&tempPst, pst, sizeof(Pst));
3970 if(tTsk->cbTsk != NULLP)
3972 retValue = tTsk->cbTsk(&tempPst,mBuf);
3975 #ifndef TENB_RTLIN_CHANGES
3976 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3978 #if (ERRCLASS & ERRCLS_DEBUG)
3979 SSLOGERROR(ERRCLS_DEBUG, ESS512, ERRZERO,
3980 "Could not release the semaphore");
3986 #if (ERRCLASS & ERRCLS_DEBUG)
3987 SSLOGERROR(ERRCLS_DEBUG, ESS513, ERRZERO, "call back function failed\n");
3991 #ifdef SS_MULTIPLE_PROCS
3992 dstIdx = osCp.tTskIds[dstProcIdIdx][tempPst.dstEnt][tempPst.dstInst];
3994 dstIdx = osCp.tTskIds[tempPst.dstEnt][tempPst.dstInst];
3996 tTsk = &osCp.tTskTbl[dstIdx];
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);
4004 /* ss004.301 : Cavium cahnges */
4005 #ifdef SS_SEUM_CAVIUM
4006 if (pst->dstProcId != osCp.procId)
4008 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4010 #if (ERRCLASS & ERRCLS_DEBUG)
4011 SSLOGERROR(ERRCLS_DEBUG, ESS527, ERRZERO,
4012 "Could not release the semaphore");
4017 /* Copy the message to the FPA region */
4018 ret = SCpyMsgFpa(mBuf, &wqBuf);
4021 /* No need to free the buffer, its already done in called fun */
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 )
4034 /* Convert the pointers to physical address */
4035 ret = SConvPtrPhy(&wqBuf);
4042 /* Assign the values for work ptr */
4044 workPtr->grp = pst->dstProcId;
4045 workPtr->tag_type = CVMX_POW_TAG_TYPE_NULL;
4046 workPtr->tag = SS_CVMX_MBUF_TAG;
4048 workPtr->packet_ptr.ptr = (Void*)wqBuf;
4050 cvmx_pow_work_submit(workPtr, workPtr->tag, workPtr->tag_type, \
4051 workPtr->qos, workPtr->grp);
4055 #endif /* SS_SEUM_CAVIUM */
4058 /* Write the message to the demand queue of the system
4059 * task which is running the destination task
4061 tTsk = &osCp.tTskTbl[dstIdx];
4062 prior = tTsk->tskPrior;
4064 if (tTsk->sTsk == NULLP)
4066 /* ss006.13: addition */
4067 #ifndef TENB_RTLIN_CHANGES
4068 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4070 #if (ERRCLASS & ERRCLS_DEBUG)
4071 SSLOGERROR(ERRCLS_DEBUG, ESS523, ERRZERO,
4072 "Could not release the semaphore");
4079 #if (ERRCLASS & ERRCLS_DEBUG)
4080 SSLOGERROR(ERRCLS_DEBUG, ESS524, (ErrVal) 0,
4081 "Destination TAPA task is not attached");
4087 #ifdef SS_LOCKLESS_MEMORY
4088 msgInfo->region = tTsk->sTsk->region;
4089 msgInfo->pst.region = tTsk->sTsk->region;
4090 #endif /* SS_LOCKLESS_MEMORY */
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
4101 if (tTsk->sTsk->tskPrior == PRIOR0)
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)
4108 ((pst->dstEnt == ENTMAC) &&
4109 (pst->srcEnt == ENTRLC) &&
4110 (pst->event == EVTRGUDDATREQ))
4113 #ifdef RGL_SPECIFIC_CHANGES
4114 WLS_WakeUp(mtGetWlsHdl());
4120 else if (tTsk->sTsk->tskPrior == PRIOR0)
4121 #ifdef RGL_SPECIFIC_CHANGES
4122 WLS_WakeUp(mtGetWlsHdl());
4129 if(tTsk->actvTsk != NULLP)
4131 if(tTsk->cbTsk != NULLP)
4133 r = rbICorePstTsk(&tempPst, mBuf, tTsk);
4137 r = rbICorePstTsk(pst, mBuf, tTsk);
4147 /* ss006.13: addition */
4148 #ifndef TENB_RTLIN_CHANGES
4149 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4151 #if (ERRCLASS & ERRCLS_DEBUG)
4152 SSLOGERROR(ERRCLS_DEBUG, ESS525, ERRZERO,
4153 "Could not release the semaphore");
4160 #if (ERRCLASS & ERRCLS_ADD_RES)
4161 SSLOGERROR(ERRCLS_ADD_RES, ESS526, (ErrVal) r,
4162 "Could not write to demand queue");
4169 /* unlock, we're done */
4170 /* ss006.13: addition */
4171 #ifndef TENB_RTLIN_CHANGES
4172 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4174 #if (ERRCLASS & ERRCLS_DEBUG)
4175 SSLOGERROR(ERRCLS_DEBUG, ESS527, ERRZERO,
4176 "Could not release the semaphore");
4183 /* If the implementation has anything to do... note that
4184 * we call it unlocked at this time.
4186 ssdPstTsk(tempPst, mBuf, tTsk);
4191 /* ss001.301: additions */
4192 #ifdef SS_HISTOGRAM_SUPPORT
4195 * fun : SGetTapaTskEntIds
4197 * Desc: Get the tapa task entity id, which are registerd for SSI.
4200 * RFAILED - failed, general (optional)
4201 * ROUTRES - failed, out of resources (optional)
4208 /* ss029.103: modification: procId added */
4210 S16 SGetTapaTskEntIds
4212 Ent *ent /* entity */
4216 uint32_t tskCnt = 0;
4218 /* Get the tapa task entity Ids from the osCp structure */
4219 for(tskCnt = 0; tskCnt < osCp.numTTsks; tskCnt++)
4221 ent[tskCnt] = osCp.tTskTbl[tskCnt].ent;
4225 } /* SGetTapaTskEntIds */
4229 * Fun: SRegForHstGrm
4231 * Desc: This function is used to register a TAPA task,
4232 * for histogram facilty.
4235 * RFAILED - failed, general (optional)
4236 * ROUTRES - failed, out of resources (optional)
4243 /* ss029.103: modification: procId added */
4247 Ent ent /* entity */
4251 uint32_t tskCnt = 0;
4255 SS_ACQUIRE_SEMA(&osCp.tTskTblSem, r);
4258 #if (ERRCLASS & ERRCLS_DEBUG)
4259 SSLOGERROR(ERRCLS_DEBUG, ESS623, ERRZERO,
4260 "Could not lock TAPA task table");
4266 for(tskCnt = 0; tskCnt < osCp.numTTsks; tskCnt++)
4268 if(osCp.tTskTbl[tskCnt].ent == ent)
4270 osCp.tTskTbl[tskCnt].hstReg = TRUE;
4275 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4277 #if (ERRCLASS & ERRCLS_DEBUG)
4278 SSLOGERROR(ERRCLS_DEBUG, ESS639, ERRZERO,
4279 "Could not release the semaphore");
4285 } /* SGetTapaTskEntIds */
4289 * Fun: SGetHstGrmInfo
4291 * Desc : Get the Histogram registration for TAPA task
4294 * RFAILED - failed, general (optional)
4295 * ROUTRES - failed, out of resources (optional)
4305 Bool *hstReg /* entity */
4309 uint32_t tskCnt = 0;
4313 for(tskCnt = 0; tskCnt < osCp.numTTsks; tskCnt++)
4315 if( *entId == osCp.tTskTbl[tskCnt].ent)
4317 *hstReg = osCp.tTskTbl[tskCnt].hstReg;
4330 } /* SGetTapaTskEntIds */
4332 #endif /* SS_HISTOGRAM_SUPPORT */
4335 S16 SInitWatchdog(uint16_t port)
4337 return ssdInitWatchDog(port);
4346 WdUserCallback callback,
4350 Txt prntBuf[PRNTSZE];
4353 /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
4355 osCp.wdCp.globWd.timeout = timeout;
4356 osCp.wdCp.globWd.callback = callback;
4357 osCp.wdCp.globWd.data = data;
4358 osCp.wdCp.globWd.numNodes = numNodes;
4360 SLock(&osCp.wdCp.wdLock);
4361 for(i = 0; i < SS_MAX_WD_NODES && i < numNodes; i++)
4363 #ifdef SS_WATCHDOG_IPV6
4364 /* ss002.301 Modifications */
4365 inet_pton(AF_INET6,(const char *)addr[i],osCp.wdCp.globWd.wdsta[i].addr);
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]);
4373 SUnlock(&osCp.wdCp.wdLock);
4374 /* ss002.301 Compilation fixes */
4375 /*ss013.301: Fixed Warnings for 32/64 bit compilation*/
4377 sprintf(prntBuf, "Configured %d nodes with timeout %u for Watchdog\n", osCp.wdCp.globWd.numNodes, osCp.wdCp.globWd.timeout);
4379 sprintf(prntBuf, "Configured %d nodes with timeout %lu for Watchdog\n", osCp.wdCp.globWd.numNodes, osCp.wdCp.globWd.timeout);
4386 S16 SDeregCfgWd(void)
4388 Txt prntBuf[PRNTSZE];
4391 /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
4393 osCp.wdCp.globWd.timeout = 0;
4394 osCp.wdCp.globWd.callback = 0;
4395 osCp.wdCp.globWd.data = 0;
4396 osCp.wdCp.globWd.numNodes = 0;
4398 SLock(&osCp.wdCp.wdLock);
4399 for(i = 0; i < SS_MAX_WD_NODES; i++)
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;
4408 SUnlock(&osCp.wdCp.wdLock);
4410 /* Implicit watchdog stop during dereg */
4418 uint8_t timeInterval /* time interval */
4422 ssdStartWatchDgTmr(NULLP, SS_TMR_HRTBT, timeInterval);
4423 ssdSndHrtBtMsg(TRUE, SS_WD_HB_REQ);
4428 S16 SStopHrtBt(void)
4431 osCp.wdCp.globWd.watchdogStop = 1;
4438 Pst *pst, /* post */
4439 Buffer *mBuf /* message buffer */
4442 /* ss002.301 Fixed warnings */
4445 Txt prntBuf[PRNTSZE];
4450 sprintf(prntBuf,"watchDgActvTsk: Time: %02d:%02d:%02d\n",dt.hour,dt.min, dt.sec
4457 S16 watchDgRcvrActvTsk
4459 Pst *pst, /* post */
4460 Buffer *mBuf /* message buffer */
4466 Txt prntBuf[PRNTSZE];
4469 struct sockaddr_in tmpaddr;
4470 Txt hbMsg[SS_WD_HB_MSG_SIZE];
4471 /* ss002.301 Modifications */
4473 socklen_t socklen = sizeof(struct sockaddr);
4475 int socklen = sizeof(struct sockaddr);
4481 sprintf(prntBuf,"watchDgRcvrActvTsk: Time: %02d:%02d:%02d\n",dt.hour, dt.min, dt.sec);
4485 while(!osCp.wdCp.globWd.watchdogStop)
4487 err = recvfrom(osCp.wdCp.globWd.sock, hbMsg, SS_WD_HB_MSG_SIZE, 0, (struct sockaddr *)&tmpaddr, &socklen);
4490 sprintf(prntBuf,"watchDgRcvrActvTsk: recvfrom failed, errno %d\n", errno);
4495 if(strcmp(hbMsg, "<HB>REQ</HB>") == 0)
4497 /* Send back the reply */
4499 sprintf(prntBuf,"watchDgRcvrActvTsk: Recvd HB REQ message from [%s:%d]\n", inet_ntoa(tmpaddr.sin_addr), ntohs(tmpaddr.sin_port));
4503 strcpy(hbMsg, "<HB>RSP</HB>");
4504 sendto(osCp.wdCp.globWd.sock, hbMsg, strlen(hbMsg), 0, (struct sockaddr *)&tmpaddr, sizeof(tmpaddr));
4506 else if(strcmp(hbMsg, "<HB>RSP</HB>") == 0)
4508 /* Got a HB RSP, set the status for the correcponding node */
4510 sprintf(prntBuf,"watchDgRcvrActvTsk: Recvd HB RSP message from [%s:%d]\n", inet_ntoa(tmpaddr.sin_addr), ntohs(tmpaddr.sin_port));
4514 SLock(&osCp.wdCp.wdLock);
4515 for(n = 0; n < osCp.wdCp.globWd.numNodes; n++)
4517 if(osCp.wdCp.globWd.wdsta[n].addr.s_addr == tmpaddr.sin_addr.s_addr)
4519 osCp.wdCp.globWd.wdsta[n].status = 1;
4522 SUnlock(&osCp.wdCp.wdLock);
4527 sprintf(prntBuf,"watchDgRcvrActvTsk: Rcvd invalid message\n");
4535 #endif /* SS_WATCHDOG */
4537 /* ss002.301 Modifications */
4538 #ifdef SS_THREAD_PROFILE
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
4549 * RFAILED - failed, general (optional)
4551 * Notes: This function may be called by the OS or Layer 1
4557 #ifdef SS_MULTIPLE_PROCS
4562 Ent ent, /* entity */
4565 uint32_t *curEvtTime,
4572 Ent ent, /* entity */
4575 uint32_t *curEvtTime,
4578 #endif /* SS_MULTIPLE_PROCS */
4583 #ifdef SS_MULTIPLE_PROCS
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))
4595 SSLOGERROR(ERRCLS_INT_PAR, ESS463, ERRZERO, "Invalid processor/entity/instance");
4598 #else /* SS_MULTIPLE_PROCS */
4599 /* check entity and instance range */
4600 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
4602 SSLOGERROR(ERRCLS_INT_PAR, ESS464, ERRZERO, "Invalid entity/instance");
4605 #endif /* SS_MULTIPLE_PROCS */
4609 ret = SLock(&osCp.sTskTblLock);
4616 #ifdef SS_MULTIPLE_PROCS
4617 procIdIdx = SGetProcIdIdx(procId);
4619 if (procIdIdx == SS_INV_PROCID_IDX)
4624 idx = osCp.tTskIds[procIdIdx][ent][inst];
4625 #else /* SS_MULTIPLE_PROCS */
4626 idx = osCp.tTskIds[ent][inst];
4627 #endif /* SS_MULTIPLE_PROCS */
4629 tTsk = &osCp.tTskTbl[idx];
4632 SUnlock(&osCp.sTskTblLock);
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;
4640 SUnlock(&osCp.sTskTblLock);
4643 #endif /* SS_THREAD_PROFILE */
4645 #ifdef SS_FBSED_TSK_REG
4650 * Desc: This function is used to register tasks based on cfg file.
4653 * RFAILED - failed, general (optional)
4659 S16 SRegTskInfo(uint8_t *cfgFile)
4661 return cmCfgrTskReg(cfgFile);
4663 #endif /* SS_FBSED_TSK_REG */
4665 /**********************************************************************
4667 **********************************************************************/