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"
134 EXTERN S32 clusterMode;
137 PUBLIC pthread_t tmpRegTidMap[20];
139 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
140 EXTERN unsigned int tlPost(void *handle);
141 #ifdef XEON_SPECIFIC_CHANGES
142 EXTERN 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)
171 Ent ent, /* entity */
172 Inst inst, /* instance */
173 PAIFS16 initFnct /* initialization function */
176 PUBLIC S16 SRegInit(ent, inst, initFnct)
177 Ent ent; /* entity */
178 Inst inst; /* instance */
179 PAIFS16 initFnct; /* initialization function */
182 /* ss021.103 - Addition for return value and pointer */
183 S16 ret; /* return value */
189 #if (ERRCLASS & ERRCLS_INT_PAR)
190 /* check entity and instance ranges */
191 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
193 SSLOGERROR(ERRCLS_INT_PAR, ESS350, ERRZERO, "Invalid entity/instance");
197 /* check initialization function */
198 if (initFnct == NULLP)
200 SSLOGERROR(ERRCLS_INT_PAR, ESS351, ERRZERO, "Null pointer");
205 /* ss021.103 - Modification to store initialization function */
206 /* Acquire the counting semaphore for all other system
207 * tasks (this call is either running in one system task's
208 * context, or in SInit()'s context). Once we have all of
209 * them, SPstTsk() cannot run, so we can do things to the
213 /* ss025.103 - Addition of lock around counting semaphore */
214 /* lock system task table */
215 ret = SLock(&osCp.sTskTblLock);
218 SSLOGERROR(ERRCLS_DEBUG, ESS352, ERRZERO,
219 "Could not lock system task table");
223 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
227 #if (ERRCLASS & ERRCLS_DEBUG)
228 SSLOGERROR(ERRCLS_DEBUG, ESS353, ERRZERO,
229 "Could not lock TAPA task table");
236 #if (ERRCLASS & ERRCLS_INT_PAR)
237 /* check count of tasks */
238 if (osCp.numTTsks == SS_MAX_TTSKS)
240 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
241 SSLOGERROR(ERRCLS_INT_PAR, ESS354, ERRZERO, "Too many tasks");
243 /* ss025.103 - Addition of unlock around counting semephore */
244 if ( SUnlock(&osCp.sTskTblLock) != ROK)
246 #if (ERRCLASS & ERRCLS_DEBUG)
247 SSLOGERROR(ERRCLS_DEBUG, ESS355, ERRZERO,
248 "Could not give the Semaphore");
256 /* check if entity and instance already registered */
257 if (osCp.tTskIds[ent][inst] != SS_TSKNC)
259 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
260 SSLOGERROR(ERRCLS_INT_PAR, ESS356, ERRZERO,
261 "Entity and instance already registered");
263 /* ss025.103 - Addition of unlock around counting semaphore */
264 if ( SUnlock(&osCp.sTskTblLock) != ROK)
266 #if (ERRCLASS & ERRCLS_DEBUG)
267 SSLOGERROR(ERRCLS_DEBUG, ESS357, ERRZERO,
268 "Could not give the Semaphore");
277 tTsk = &osCp.tTskTbl[osCp.nxtTTskEntry];
282 tTsk->tskType = (Ttype)NULLD;
283 tTsk->tskPrior = (Prior)NULLD;
284 tTsk->initTsk = initFnct;
285 tTsk->actvTsk = (ActvTsk)NULLP;
288 osCp.tTskIds[ent][inst] = osCp.nxtTTskEntry;
289 osCp.nxtTTskEntry = tTsk->nxt;
292 /* Activate initialization function, if present. Like
293 * SRegInit(), we use hard-coded parameters. Note: we
294 * assume that the initialization function is not
295 * going to call SRegTTsk() or SPstTsk(). If it does,
296 * this thread will freeze up as we are holding the
297 * TAPA task table counting semaphore.
299 /* ss024.103 - Modification for memory calculator tool */
301 (Void)(*initFnct)(ent, inst, DFLT_REGION, PWR_UP);
303 (Void)(*initFnct)(ent, inst, SS_STATIC_REGION, PWR_UP);
304 #endif /* USE_MEMCAL */
306 /* unlock the table */
307 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
309 /* ss025.103 - Addition of unlock around counting semaphore */
310 if ( SUnlock(&osCp.sTskTblLock) != ROK)
312 #if (ERRCLASS & ERRCLS_DEBUG)
313 SSLOGERROR(ERRCLS_DEBUG, ESS358, ERRZERO,
314 "Could not give the Semaphore");
328 * Desc: This function is used to register an activation function
329 * for the layer. The system services will invoke the
330 * function passed to it whenever a task buffer is received.
331 * The activation function will be used by the layer to receive
332 * messages from other entities. It allows a priority to be
333 * associated with the task so that it can be preempted if
337 * RFAILED - failed, general (optional)
338 * ROUTRES - failed, out of resources (optional)
340 * Notes: We pass NULLP for the initialization function, because
341 * it is assumed that whoever is using this call will also
342 * be calling SRegInit().
348 PUBLIC S16 SRegActvTsk
350 Ent ent, /* entity */
351 Inst inst, /* instance */
352 Ttype ttype, /* task type */
353 Prior prior, /* task priority */
354 ActvTsk actvTsk /* activate task function */
357 PUBLIC S16 SRegActvTsk(ent, inst, ttype, prior, actvTsk)
358 Ent ent; /* entity */
359 Inst inst; /* instance */
360 Ttype ttype; /* task type */
361 Prior prior; /* task priority */
362 ActvTsk actvTsk; /* activate task function */
368 /* ss021.103 - Addition for pointer */
374 #if (ERRCLASS & ERRCLS_INT_PAR)
375 /* check entity and instance ranges */
376 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
378 SSLOGERROR(ERRCLS_INT_PAR, ESS359, ERRZERO, "Invalid entity/instance");
382 /* check activation function */
383 if (actvTsk == NULLP)
385 SSLOGERROR(ERRCLS_INT_PAR, ESS360, ERRZERO, "Null pointer");
389 /* check task type */
390 if (ttype != TTNORM && ttype != TTPERM)
392 SSLOGERROR(ERRCLS_INT_PAR, ESS361, ERRZERO, "Invalid task type");
393 /* ss021.103 - Addition of return fail for invalid task type */
397 /* check task priority */
400 SSLOGERROR(ERRCLS_INT_PAR, ESS362, ERRZERO, "Invalid task priority");
405 /* lock system task table */
406 ret = SLock(&osCp.sTskTblLock);
409 SSLOGERROR(ERRCLS_DEBUG, ESS363, ERRZERO,
410 "Could not lock system task table");
414 /* lock TAPA task table */
415 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
418 if ( SUnlock(&osCp.sTskTblLock) != ROK)
420 #if (ERRCLASS & ERRCLS_DEBUG)
421 SSLOGERROR(ERRCLS_DEBUG, ESS364, ERRZERO,
422 "Could not give the Semaphore");
427 SSLOGERROR(ERRCLS_DEBUG, ESS365, ERRZERO,
428 "Could not lock TAPA task table");
431 /* ss021.103 - Modification for SRegInit not called yet */
432 /* check if entity and instance already registered */
433 if (osCp.tTskIds[ent][inst] == SS_TSKNC)
436 #if (ERRCLASS & ERRCLS_INT_PAR)
437 /* check count of tasks */
438 if (osCp.numTTsks == SS_MAX_TTSKS)
440 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
442 /* ss025.103 - Addition of unlock around counting semaphore */
443 if ( SUnlock(&osCp.sTskTblLock) != ROK)
445 #if (ERRCLASS & ERRCLS_DEBUG)
446 SSLOGERROR(ERRCLS_DEBUG, ESS366, ERRZERO,
447 "Could not give the Semaphore");
451 SSLOGERROR(ERRCLS_INT_PAR, ESS367, ERRZERO, "Too many tasks");
456 tTsk = &osCp.tTskTbl[osCp.nxtTTskEntry];
460 tTsk->initTsk = (PAIFS16)NULLP;
461 tTsk->actvTsk = (ActvTsk)NULLP;
464 osCp.tTskIds[ent][inst] = osCp.nxtTTskEntry;
465 osCp.nxtTTskEntry = tTsk->nxt;
470 /* check and bump the priority if it is a permanent task */
476 /* ss021.103 - Modification to register task information */
477 /* We fill up the current available slot with all the
478 * information we've been given. Update table information,
479 * and the task is registered.
482 tTsk = &osCp.tTskTbl[osCp.tTskIds[ent][inst]];
484 #if (ERRCLASS & ERRCLS_INT_PAR)
485 if (tTsk->actvTsk != (ActvTsk)NULLP)
487 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
489 if ( SUnlock(&osCp.sTskTblLock) != ROK)
491 #if (ERRCLASS & ERRCLS_DEBUG)
492 SSLOGERROR(ERRCLS_DEBUG, ESS368, ERRZERO,
493 "Could not give the Semaphore");
498 SSLOGERROR(ERRCLS_INT_PAR, ESS369, ERRZERO,
499 "ActvTask already registered");
504 tTsk->tskType = ttype;
505 tTsk->tskPrior = prior;
506 tTsk->actvTsk = actvTsk;
508 /* unlock the table */
509 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
511 if ( SUnlock(&osCp.sTskTblLock) != ROK)
513 #if (ERRCLASS & ERRCLS_DEBUG)
514 SSLOGERROR(ERRCLS_DEBUG, ESS370, ERRZERO,
515 "Could not give the Semaphore");
520 /* Now we create a system task--one per TAPA task is the
521 * semantics of SRegActvTsk().
524 spri = SS_NORM_TSK_PRI;
526 spri = SS_PERM_TSK_PRI;
528 ret = SCreateSTsk(spri, &sTskId);
532 #if (ERRCLASS & ERRCLS_DEBUG)
533 SSLOGERROR(ERRCLS_DEBUG, ESS371, (ErrVal) ret,
534 "Could not create system task");
537 SDeregTTsk(ent, inst);
542 /* Attach the TAPA task we just registered, to the system
543 * task we just created.
545 ret = SAttachTTsk(ent, inst, sTskId);
549 #if (ERRCLASS & ERRCLS_DEBUG)
550 SSLOGERROR(ERRCLS_DEBUG, ESS372, (ErrVal) ret,
551 "Could not attach TAPA task to system task");
553 SDestroySTsk(sTskId);
554 SDeregTTsk(ent, inst);
565 * Fun: Deregister Initialize, task buffer and timer
567 * Desc: This function is used to deregister the initialization,
568 * activation and timer functions for a task.
578 PUBLIC S16 SDeregInitTskTmr
580 Ent ent, /* entity */
581 Inst inst /* instance */
584 PUBLIC S16 SDeregInitTskTmr(ent, inst)
585 Ent ent; /* entity */
586 Inst inst; /* instance */
597 TRC1(SDeregInitTskTmr);
600 #if (ERRCLASS & ERRCLS_INT_PAR)
601 /* check entity and instance ranges */
602 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
604 SSLOGERROR(ERRCLS_INT_PAR, ESS373, ERRZERO, "Invalid entity/instance");
609 /* ss025.103 - Addition of lock around counting semaphore */
610 /* lock system task table */
611 ret = SLock(&osCp.sTskTblLock);
614 SSLOGERROR(ERRCLS_DEBUG, ESS374, ERRZERO,
615 "Could not lock system task table");
619 /* lock the TAPA task table */
620 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
624 #if (ERRCLASS & ERRCLS_DEBUG)
625 SSLOGERROR(ERRCLS_DEBUG, ESS375, ERRZERO,
626 "Could not lock TAPA task table");
633 #if (ERRCLASS & ERRCLS_INT_PAR)
634 /* check whether this entity is registered */
635 if (osCp.tTskIds[ent][inst] == SS_TSKNC)
637 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
638 SSLOGERROR(ERRCLS_INT_PAR, ESS376, ERRZERO, "Unknown task");
640 /* ss025.103 - Addition of unlock around counting semaphore */
641 if ( SUnlock(&osCp.sTskTblLock) != ROK)
643 #if (ERRCLASS & ERRCLS_DEBUG)
644 SSLOGERROR(ERRCLS_DEBUG, ESS377, ERRZERO,
645 "Could not give the Semaphore");
655 /* get out the TAPA task entry */
656 tTsk = &osCp.tTskTbl[osCp.tTskIds[ent][inst]];
658 /* get out the system task that's running this TAPA task */
661 /* get out the ID of this system task */
664 sTskId = sTsk->tskId;
669 /* unlock the TAPA task table */
670 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
672 /* ss025.103 - Addition of unlock around counting semaphore */
673 if ( SUnlock(&osCp.sTskTblLock) != ROK)
675 #if (ERRCLASS & ERRCLS_DEBUG)
676 SSLOGERROR(ERRCLS_DEBUG, ESS378, ERRZERO,
677 "Could not give the Semaphore");
683 /* deregister the TAPA task */
684 if (SDeregTTsk(ent, inst) != ROK)
690 /* Now, if the TAPA task was attached, and nobody else is using that
691 * system task, we should destroy it.
697 /* lock the system task table */
698 ret = SLock(&osCp.sTskTblLock);
702 #if (ERRCLASS & ERRCLS_DEBUG)
703 SSLOGERROR(ERRCLS_DEBUG, ESS379, (ErrVal) ret,
704 "Could not lock system task table");
710 idx = (SsIdx) sTskId;
711 sTsk = &osCp.sTskTbl[idx];
713 /* check if the system task is still around */
714 if (sTsk->used != TRUE)
717 /* ss006.13: addition */
718 if ( SUnlock(&osCp.sTskTblLock) != ROK)
720 #if (ERRCLASS & ERRCLS_DEBUG)
721 SSLOGERROR(ERRCLS_DEBUG, ESS380, ERRZERO,
722 "Could not give the Semaphore");
730 /* check if the system task is dying already */
734 /* ss006.13: addition */
735 if ( SUnlock(&osCp.sTskTblLock) != ROK)
737 #if (ERRCLASS & ERRCLS_DEBUG)
738 SSLOGERROR(ERRCLS_DEBUG, ESS381, ERRZERO,
739 "Could not give the Semaphore");
747 /* If this system task entry has no more TAPA tasks attached,
748 * we destroy it, otherwise we do nothing.
750 if (sTsk->numTTsks == 0)
752 sTsk->termPend = TRUE;
759 /* ss006.13: addition */
760 if ( SUnlock(&osCp.sTskTblLock) != ROK)
762 #if (ERRCLASS & ERRCLS_DEBUG)
763 SSLOGERROR(ERRCLS_DEBUG, ESS382, ERRZERO,
764 "Could not give the Semaphore");
769 /* If we're destroying the system task, ask the implementation
774 ret = ssdDestroySTsk(sTsk);
779 #if (ERRCLASS & ERRCLS_DEBUG)
780 SSLOGERROR(ERRCLS_DEBUG, ESS383, (ErrVal) ret,
781 "Could not destroy system task");
791 } /* SDeregInitTskTmr */
793 #endif /* SS_MULTIPLE_PROCS */
798 * Fun: Register a TAPA task
800 * Desc: This function is used to register a TAPA task,
801 * and its initialization and activation functions.
804 * RFAILED - failed, general (optional)
805 * ROUTRES - failed, out of resources (optional)
812 /* ss029.103: modification: procId added */
813 #ifndef SS_MULTIPLE_PROCS
818 Ent ent, /* entity */
819 Inst inst, /* instance */
820 Ttype type, /* task type */
821 Prior prior, /* task priority */
822 PAIFS16 initTsk, /* initialization function */
823 ActvTsk actvTsk /* activation function */
826 PUBLIC S16 SRegTTsk(ent, inst, type, prior, initTsk, actvTsk)
827 Ent ent; /* entity */
828 Inst inst; /* instance */
829 Ttype type; /* task type */
830 Prior prior; /* task priority */
831 PAIFS16 initTsk; /* initialization function */
832 ActvTsk actvTsk; /* activation function */
835 #else /* SS_MULTIPLE_PROCS */
840 ProcId proc, /* processor */
841 Ent ent, /* entity */
842 Inst inst, /* instance */
843 Ttype type, /* task type */
844 Prior prior, /* task priority */
845 PAIFS16 initTsk, /* initialization function */
846 ActvTsk actvTsk /* activation function */
849 PUBLIC S16 SRegTTsk(proc, ent, inst, type, prior, initTsk, actvTsk)
850 ProcId proc; /* processor */
851 Ent ent; /* entity */
852 Inst inst; /* instance */
853 Ttype type; /* task type */
854 Prior prior; /* task priority */
855 PAIFS16 initTsk; /* initialization function */
856 ActvTsk actvTsk; /* activation function */
859 #endif /* SS_MULTIPLE_PROCS */
864 /* ss029.103: addition: multiple procIds related changes */
865 #ifdef SS_MULTIPLE_PROCS
872 #if (ERRCLASS & ERRCLS_INT_PAR)
874 /* check entity and instance ranges */
875 /* ss029.103: addition: multiple procIds related changes */
876 #ifdef SS_MULTIPLE_PROCS
877 if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST))
879 SSLOGERROR(ERRCLS_INT_PAR, ESS384, ERRZERO, "Invalid proc/entity/instance");
882 #else /* SS_MULTIPLE_PROCS */
883 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
885 SSLOGERROR(ERRCLS_INT_PAR, ESS385, ERRZERO, "Invalid entity/instance");
888 #endif /* SS_MULTIPLE_PROCS */
890 /* check activation function */
891 if (actvTsk == NULLP)
893 SSLOGERROR(ERRCLS_INT_PAR, ESS386, ERRZERO, "Null pointer");
897 /* check task type */
898 if (type != TTNORM && type != TTPERM)
900 SSLOGERROR(ERRCLS_INT_PAR, ESS387, ERRZERO, "Invalid task type");
901 /* ss021.103 - Addition of return fail for invalid task type */
905 /* check task priority */
908 SSLOGERROR(ERRCLS_INT_PAR, ESS388, ERRZERO, "Invalid task priority");
913 /* ss029.103: addition: multiple procIds related changes */
914 #ifdef SS_MULTIPLE_PROCS
915 /* retrieve proc id index in the proc id table */
916 procIdIdx = SGetProcIdIdx(proc);
918 /* Check whether the proc id exist in the proc id table */
919 if (procIdIdx == SS_INV_PROCID_IDX)
921 #if (ERRCLASS & ERRCLS_INT_PAR)
922 SSLOGERROR(ERRCLS_INT_PAR, ESS389, ERRZERO,
923 "Could not find proc table index");
928 #endif /* SS_MULTIPLE_PROCS */
932 /* Acquire the counting semaphore for all other system
933 * tasks (this call is either running in one system task's
934 * context, or in SInit()'s context). Once we have all of
935 * them, SPstTsk() cannot run, so we can do things to the
939 /* ss025.103 - Addition of lock around counting semaphore */
940 /* lock system task table */
941 ret = SLock(&osCp.sTskTblLock);
944 SSLOGERROR(ERRCLS_DEBUG, ESS390, ERRZERO,
945 "Could not lock system task table");
949 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
953 #if (ERRCLASS & ERRCLS_DEBUG)
954 SSLOGERROR(ERRCLS_DEBUG, ESS391, ERRZERO,
955 "Could not lock TAPA task table");
958 /* ss025.103 - Addition of unlock around counting semaphore */
959 if ( SUnlock(&osCp.sTskTblLock) != ROK)
961 #if (ERRCLASS & ERRCLS_DEBUG)
962 SSLOGERROR(ERRCLS_DEBUG, ESS392, ERRZERO,
963 "Could not give the Semaphore");
972 #if (ERRCLASS & ERRCLS_DEBUG)
973 /* check count of tasks */
974 if (osCp.numTTsks == SS_MAX_TTSKS)
976 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
977 SSLOGERROR(ERRCLS_DEBUG, ESS393, ERRZERO, "Too many tasks");
979 /* ss025.103 - Addition of unlock around counting semaphore */
980 if ( SUnlock(&osCp.sTskTblLock) != ROK)
982 #if (ERRCLASS & ERRCLS_DEBUG)
983 SSLOGERROR(ERRCLS_DEBUG, ESS394, ERRZERO,
984 "Could not give the Semaphore");
992 /* check if entity and instance already registered */
993 /* ss029.103: addition: multiple procIds related changes */
994 #ifdef SS_MULTIPLE_PROCS
995 if (osCp.tTskIds[procIdIdx][ent][inst] != SS_TSKNC)
997 if (osCp.tTskIds[ent][inst] != SS_TSKNC)
998 #endif /* SS_MULTIPLE_PROCS */
1000 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1001 SSLOGERROR(ERRCLS_DEBUG, ESS395, ERRZERO,
1002 "Entity and instance already registered");
1004 /* ss025.103 - Addition of unlock around counting semaphore */
1005 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1007 #if (ERRCLASS & ERRCLS_DEBUG)
1008 SSLOGERROR(ERRCLS_DEBUG, ESS396, ERRZERO,
1009 "Could not give the Semaphore");
1019 /* We fill up the current available slot with all the
1020 * information we've been given. Update table information,
1021 * and the task is registered.
1023 tTsk = &osCp.tTskTbl[osCp.nxtTTskEntry];
1025 /* ss029.103: addition: procId added */
1026 #ifdef SS_MULTIPLE_PROCS
1028 #endif /* SS_MULTIPLE_PROCS */
1031 tTsk->tskType = type;
1032 tTsk->tskPrior = prior;
1033 tTsk->initTsk = initTsk;
1034 tTsk->actvTsk = actvTsk;
1037 /* ss001.301: additions */
1038 #ifdef SS_HISTOGRAM_SUPPORT
1040 #endif /* SS_HISTOGRAM_SUPPORT */
1042 /* ss029.103: addition: multiple procIds related changes */
1043 #ifdef SS_MULTIPLE_PROCS
1044 osCp.tTskIds[procIdIdx][ent][inst] = osCp.nxtTTskEntry;
1046 osCp.tTskIds[ent][inst] = osCp.nxtTTskEntry;
1047 #endif /* SS_MULTIPLE_PROCS */
1048 osCp.nxtTTskEntry = tTsk->nxt;
1052 /* Activate initialization function, if present. Like
1053 * SRegInit(), we use hard-coded parameters. Note: we
1054 * assume that the initialization function is not
1055 * going to call SRegTTsk() or SPstTsk(). If it does,
1056 * this thread will freeze up as we are holding the
1057 * TAPA task table counting semaphore.
1059 /* ss024.103 - Modification for memory calculator tool */
1060 if (initTsk != NULLP)
1062 /* ss029.103: addition: multiple procIds related changes */
1063 #ifdef SS_MULTIPLE_PROCS
1066 #endif /* SS_MULTIPLE_PROCS */
1068 /* ss029.103: addition: multiple procIds related changes */
1069 #ifndef SS_MULTIPLE_PROCS
1072 #ifndef SS_MULTICORE_SUPPORT
1073 (Void)(*initTsk)(ent, inst, DFLT_REGION, PWR_UP);
1076 (Void)(*initTsk)(ent, inst, SS_STATIC_REGION, PWR_UP);
1077 #endif /* USE_MEMCAL */
1079 #else /* SS_MULTIPLE_PROCS */
1082 #ifndef SS_MULTICORE_SUPPORT
1083 (Void)(*initTsk)(proc, ent, inst, DFLT_REGION, PWR_UP, &xxCb);
1084 #endif /* SS_MULTICORE_SUPPORT */
1086 (Void)(*initTsk)(proc, ent, inst, SS_STATIC_REGION, PWR_UP, &xxCb);
1087 #endif /* USE_MEMCAL */
1090 * store the control block. The control block may be NULL in some cases
1092 idx = osCp.tTskIds[procIdIdx][ent][inst];
1094 osCp.tTskTbl[idx].xxCb = xxCb;
1096 /* ss032.103 do a debug print if xxCb is NULLP */
1099 SSLOGERROR(ERRCLS_INT_PAR, ERRZERO, ERRZERO, "Null pointer");
1101 #endif /* SS_MULTIPLE_PROCS */
1104 /* unlock the table */
1105 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1107 /* ss025.103 - Addition of unlock around counting semaphore */
1108 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1110 #if (ERRCLASS & ERRCLS_DEBUG)
1111 SSLOGERROR(ERRCLS_DEBUG, ESS397, ERRZERO,
1112 "Could not give the Semaphore");
1119 /* ss002.301 Additions */
1122 * Fun: Register a call back function with SSI
1124 * Desc: This function is used to register a callback function
1128 * RFAILED - failed, general (optional)
1135 #ifndef SS_MULTIPLE_PROCS
1137 PUBLIC S16 SRegCbTsk
1139 Ent ent, /* entity */
1140 Inst inst, /* instance */
1141 ActvTsk cbTsk /* Callback Function */
1144 PUBLIC S16 SRegCbTsk(ent, inst, cbTsk)
1145 Ent ent; /* entity */
1146 Inst inst; /* instance */
1150 #else /* SS_MULTIPLE_PROCS */
1153 PUBLIC S16 SRegCbTsk
1155 ProcId proc, /* processor */
1156 Ent ent, /* entity */
1157 Inst inst, /* instance */
1161 PUBLIC S16 SRegCbTsk(proc, ent, inst, cbTsk)
1162 ProcId proc; /* processor */
1163 Ent ent; /* entity */
1164 Inst inst; /* instance */
1167 #endif /* SS_MULTIPLE_PROCS */
1172 #ifdef SS_MULTIPLE_PROCS
1174 #endif /* SS_MULTIPLE_PROCS */
1178 #if (ERRCLASS & ERRCLS_INT_PAR)
1179 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
1181 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SRegCbTsk() : Invalid entity/instance");
1187 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, " SRegCbTsk() : Null pointer");
1192 #ifdef SS_MULTIPLE_PROCS
1193 /* retrieve proc id index in the proc id table */
1194 procIdIdx = SGetProcIdIdx(proc);
1196 /* Check whether the proc id exist in the proc id table */
1197 if (procIdIdx == SS_INV_PROCID_IDX)
1199 #if (ERRCLASS & ERRCLS_INT_PAR)
1200 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO,
1201 " SRegCbTsk() : Could not find proc table index");
1206 #endif /* SS_MULTIPLE_PROCS */
1208 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
1212 #if (ERRCLASS & ERRCLS_DEBUG)
1213 SSLOGERROR(ERRCLS_DEBUG, ESSXXX, ERRZERO,
1214 "SRegCbTsk() : Could not lock TAPA task table");
1219 #ifdef SS_MULTIPLE_PROCS
1220 idx = osCp.tTskIds[procIdIdx][ent][inst];
1221 #else /* SS_MULTIPLE_PROCS */
1222 idx = osCp.tTskIds[ent][inst];
1223 #endif /* SS_MULTIPLE_PROCS */
1225 #if (ERRCLASS & ERRCLS_INT_PAR)
1226 if (idx == SS_TSKNC)
1228 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1229 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SRegCbTsk() : Unknown task");
1233 tTsk = &osCp.tTskTbl[idx];
1234 tTsk->cbTsk = cbTsk;
1236 /* unlock the table */
1237 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1244 * Fun: Deregister TAPA task
1246 * Desc: This function is used to deregister a TAPA task.
1247 * All information about the task is removed from the
1251 * RFAILED - failed, general (optional)
1258 /* ss029.103: addition: procId added */
1259 #ifndef SS_MULTIPLE_PROCS
1262 PUBLIC S16 SDeregTTsk
1264 Ent ent, /* entity */
1265 Inst inst /* instance */
1268 PUBLIC S16 SDeregTTsk(ent, inst)
1269 Ent ent; /* entity */
1270 Inst inst; /* instance */
1273 #else /* SS_MULTIPLE_PROCS */
1276 PUBLIC S16 SDeregTTsk
1278 ProcId proc, /* processor */
1279 Ent ent, /* entity */
1280 Inst inst /* instance */
1283 PUBLIC S16 SDeregTTsk(proc, ent, inst)
1284 ProcId proc; /* processor */
1285 Ent ent; /* entity */
1286 Inst inst; /* instance */
1288 #endif /* SS_MULTIPLE_PROCS */
1291 /* ss029.103: modification: The subscript should be consistent type */
1295 /* ss029.103: addition: multiple procIds related changes */
1296 #ifdef SS_MULTIPLE_PROCS
1298 #endif /* SS_MULTIPLE_PROCS */
1299 /* ss002.301 Additions */
1306 #if (ERRCLASS & ERRCLS_INT_PAR)
1307 /* check entity and instance ranges */
1308 /* ss029.103: addition: multiple procIds related changes */
1309 #ifdef SS_MULTIPLE_PROCS
1310 if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST))
1312 SSLOGERROR(ERRCLS_INT_PAR, ESS398, ERRZERO, "Invalid processor/entity/instance");
1315 #else /* SS_MULTIPLE_PROCS */
1316 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
1318 SSLOGERROR(ERRCLS_INT_PAR, ESS399, ERRZERO, "Invalid entity/instance");
1321 #endif /* SS_MULTIPLE_PROCS */
1325 /* ss029.103: addition: multiple procIds related changes */
1326 #ifdef SS_MULTIPLE_PROCS
1327 /* Find the proc table index */
1328 procIdIdx = SGetProcIdIdx(proc);
1330 if (procIdIdx == SS_INV_PROCID)
1332 #if (ERRCLASS & ERRCLS_DEBUG)
1333 SSLOGERROR(ERRCLS_DEBUG, ESS400, ERRZERO,
1334 "Could not find proc id index");
1338 #endif /* SS_MULTIPLE_PROCS */
1340 /* We deregister all timers for this TAPA task, since it's going
1341 * away now. Lock the timer table and iterate through it, removing
1342 * all timers owned by this task.
1344 if (SLock(&osCp.tmrTblLock) != ROK)
1346 #if (ERRCLASS & ERRCLS_DEBUG)
1347 SSLOGERROR(ERRCLS_DEBUG, ESS401, ERRZERO,
1348 "Could not lock timer table");
1353 for (idx = 0; idx < SS_MAX_TMRS; idx++)
1355 /* ss029.103: addition: multiple procIds related changes */
1356 #ifdef SS_MULTIPLE_PROCS
1357 if ((osCp.tmrTbl[idx].ownerProc == proc) &&
1358 (osCp.tmrTbl[idx].ownerEnt == ent) &&
1359 (osCp.tmrTbl[idx].ownerInst == inst))
1360 #else /* SS_MULTIPLE_PROCS */
1361 if ((osCp.tmrTbl[idx].ownerEnt == ent) &&
1362 (osCp.tmrTbl[idx].ownerInst == inst))
1363 #endif /* SS_MULTIPLE_PROCS */
1365 /* shut down this timer */
1366 tmr = &osCp.tmrTbl[idx];
1367 if (ssdDeregTmr(tmr) == ROK)
1371 /* ss029.103: addition: multiple procIds related changes */
1372 #ifdef SS_MULTIPLE_PROCS
1373 tmr->ownerProc = PROCNC;
1375 * ss015.301 - Modifed in initialization as timer activation
1376 * functions enclosed in a union. Also initialized the mtFlag
1379 #endif /* SS_MULTIPLE_PROCS */
1380 tmr->ownerEnt = ENTNC;
1381 tmr->ownerInst = INSTNC;
1383 tmr->ssTmrActvFn.actvFnc.tmrActvFn = NULLP;
1384 #ifndef SS_MULTIPLE_PROCS
1386 tmr->ssTmrActvFn.mtFlag = FALSE;
1387 tmr->ssTmrActvFn.actvFnc.tmrActvFnMt = NULLP;
1390 tmr->nxt = osCp.nxtTmrEntry;
1391 osCp.nxtTmrEntry = (SsIdx)idx;
1397 /* ss006.13: addition */
1398 if ( SUnlock(&osCp.tmrTblLock) != ROK)
1400 #if (ERRCLASS & ERRCLS_DEBUG)
1401 SSLOGERROR(ERRCLS_DEBUG, ESS402, ERRZERO,
1402 "Could not give the Semaphore");
1407 #if (ERRCLASS & ERRCLS_DEBUG)
1408 SSLOGERROR(ERRCLS_DEBUG, ESS403, ERRZERO,
1409 "Could not deregister task's timer(s)");
1418 /* ss006.13: addition */
1419 if ( SUnlock(&osCp.tmrTblLock) != ROK)
1421 #if (ERRCLASS & ERRCLS_DEBUG)
1422 SSLOGERROR(ERRCLS_DEBUG, ESS404, ERRZERO,
1423 "Could not give the Semaphore");
1427 /* ss002.301 Additions */
1428 /* Acquire the counting semaphore for all TAPA tasks. Once
1429 * we have all of them, both SPstTsk() and SRegTTsk() cannot
1430 * run, so we can do things to the TAPA task table.
1432 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
1435 /* ss002.301 Additions */
1437 #if (ERRCLASS & ERRCLS_DEBUG)
1438 SSLOGERROR(ERRCLS_DEBUG, ESS411, ERRZERO,
1439 "Could not lock TAPA task table");
1446 /* get out the TAPA task entry */
1447 /* ss029.103: addition: multiple procIds related changes */
1448 #ifdef SS_MULTIPLE_PROCS
1449 idx = osCp.tTskIds[procIdIdx][ent][inst];
1450 #else /* SS_MULTIPLE_PROCS */
1451 idx = osCp.tTskIds[ent][inst];
1452 #endif /* SS_MULTIPLE_PROCS */
1455 /* make sure this TAPA task exists */
1456 if (idx == SS_TSKNC)
1458 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1460 SSLOGERROR(ERRCLS_INT_PAR, ESS412, ERRZERO, "Unknown task");
1461 /* ss002.301 Additions */
1465 tTsk = &osCp.tTskTbl[idx];
1467 /* unlock the TAPA task table */
1468 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1470 /*Check whether the thread calling this funtion is the same as the system task to which the
1471 TAPA task detremined by passed entity and instance is attached*/
1474 /*ss014.301 SSI-4GMX specific changes*/
1475 #ifndef SS_4GMX_LCORE
1476 if((tTsk->sTsk == NULLP) || (SS_CHECK_CUR_STSK(tTsk->sTsk)))
1478 #ifdef SS_MULTIPLE_PROCS
1479 ssdProcTTskTerm(procIdIdx, tTsk, idx);
1481 ssdProcTTskTerm(tTsk, idx);
1488 if (SGetMsg(SS_DFLT_REGION, SS_DFLT_POOL, &mBuf) != ROK)
1491 #if (ERRCLASS & ERRCLASS_DEBUG)
1492 SSLOGERROR(ERRCLS_DEBUG, ESS415, ERRZERO, "Could not get a message");
1499 mInfo = (SsMsgInfo *)mBuf->b_rptr;
1500 mInfo->eventInfo.event = SS_EVNT_TTSK_TERM;
1502 mInfo->pst.dstEnt = ent;
1503 mInfo->pst.dstInst = inst;
1505 /* we dont care who is calling SDeregTTsk()
1506 so we dont fill srcEnt and dstInst in mInfo->pst */
1508 /* mt028.201: modification: multiple procs support related changes */
1509 /* source proc id is not needed so we dont fill it */
1510 #ifndef SS_MULTIPLE_PROCS
1511 mInfo->pst.dstProcId = SFndProcId();
1512 #else /* SS_MULTIPLE_PROCS */
1513 mInfo->pst.dstProcId = proc;
1514 #endif /* SS_MULTIPLE_PROCS */
1515 /* ss002.301 Additions */
1516 mInfo->pst.selector = SEL_LC_NEW;
1517 mInfo->pst.region = DFLT_REGION;
1518 mInfo->pst.pool = DFLT_POOL;
1519 mInfo->pst.prior = PRIOR0;
1520 mInfo->pst.route = RTESPEC;
1521 mInfo->pst.event = 0;
1522 /* write the timer message to the queue of the destination task */
1523 if (ssDmndQPutLast(&tTsk->sTsk->dQ, mBuf,
1524 (tTsk->tskPrior * SS_MAX_MSG_PRI) + PRIOR0) != ROK)
1526 SS_RELEASE_SEMA(&osCp.tTskTblSem);
1528 #if (ERRCLASS & ERRCLS_DEBUG)
1529 SSLOGERROR(ERRCLS_INT_PAR, ESS416, ERRZERO, "Could not write to demand queue");
1542 * Fun: Create system task
1544 * Desc: This function is used to create a system task. An
1545 * entry is located in the system task table and the
1546 * implementation-specific function is called.
1549 * RFAILED - failed, general (optional)
1550 * ROUTRES - failed, out of resources (optional)
1558 PUBLIC S16 SCreateSTsk
1560 SSTskPrior tskPrior, /* task priority */
1561 SSTskId *tskId /* filled in with system task ID */
1564 PUBLIC S16 SCreateSTsk(tskPrior, tskId)
1565 SSTskPrior tskPrior; /* task priority */
1566 SSTskId *tskId; /* filled in with system task ID */
1576 #if (ERRCLASS & ERRCLS_INT_PAR)
1577 /* check task ID pointer */
1580 SSLOGERROR(ERRCLS_INT_PAR, ESS417, ERRZERO, "Null pointer");
1584 /* check system task priority */
1585 if (tskPrior > SS_LOWEST_STSK_PRIOR)
1587 SSLOGERROR(ERRCLS_INT_PAR, ESS418, ERRZERO,
1588 "Invalid system task priority");
1594 /* lock the system task table */
1595 ret = SLock(&osCp.sTskTblLock);
1599 #if (ERRCLASS & ERRCLS_DEBUG)
1600 SSLOGERROR(ERRCLS_DEBUG, ESS419, (ErrVal) ret,
1601 "Could not lock system task table");
1608 #ifdef SS_SINGLE_THREADED
1609 /* When singlethreaded, we only need to create one... */
1610 /* ss001.301: additions */
1612 #ifndef SS_MULTICORE_SUPPORT
1613 if (osCp.numSTsks == 1)
1615 if (osCp.numSTsks == 2)
1616 #endif /* SS_MULTICORE_SUPPORT */
1618 #ifndef SS_MULTICORE_SUPPORT
1619 if (osCp.numSTsks == 3)
1621 if (osCp.numSTsks == 4)
1622 #endif /* SS_MULTICORE_SUPPORT */
1623 #endif /* SS_WATCHDOG */
1625 /* ss001.301: additions */
1627 #ifndef SS_MULTICORE_SUPPORT
1629 osCp.sTskTbl[0].termPend = FALSE;
1632 osCp.sTskTbl[1].termPend = FALSE;
1633 #endif /* SS_MULTICORE_SUPPORT */
1635 #ifndef SS_MULTICORE_SUPPORT
1637 osCp.sTskTbl[2].termPend = FALSE;
1640 osCp.sTskTbl[3].termPend = FALSE;
1641 #endif /* SS_MULTICORE_SUPPORT */
1642 #endif /* SS_WATCHDOG */
1644 /* ss006.13: addition */
1645 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1647 #if (ERRCLASS & ERRCLS_DEBUG)
1648 SSLOGERROR(ERRCLS_DEBUG, ESS420, ERRZERO,
1649 "Could not give the Semaphore");
1655 #endif /* SS_SINGLE_THREADED */
1658 /* check count of system tasks */
1659 if (osCp.numSTsks == SS_MAX_STSKS)
1662 /* ss006.13: addition */
1663 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1665 #if (ERRCLASS & ERRCLS_DEBUG)
1666 SSLOGERROR(ERRCLS_DEBUG, ESS421, ERRZERO,
1667 "Could not give the Semaphore");
1672 #if (ERRCLASS & ERRCLS_ADD_RES)
1673 SSLOGERROR(ERRCLS_ADD_RES, ESS422, ERRZERO, "Too many system tasks");
1680 /* initialize the system task entry with the information we have */
1681 sTsk = &osCp.sTskTbl[osCp.nxtSTskEntry];
1683 /* store the system task priority */
1684 sTsk->tskPrior = tskPrior;
1686 /*ss014.301 SSI-4GMX specific changes*/
1687 #ifndef SS_4GMX_LCORE
1688 /* initialize the demand queue */
1689 if (ssInitDmndQ(&sTsk->dQ) != ROK)
1692 /* ss006.13: addition */
1693 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1695 #if (ERRCLASS & ERRCLS_DEBUG)
1696 SSLOGERROR(ERRCLS_DEBUG, ESS423, ERRZERO,
1697 "Could not give the Semaphore");
1702 #if (ERRCLASS & ERRCLS_DEBUG)
1703 SSLOGERROR(ERRCLS_DEBUG, ESS424, (ErrVal) ret,
1704 "Could not initialize demand queue");
1710 /* initialize the system task entry lock */
1711 if (SInitLock(&sTsk->lock, SS_STSKENTRY_LOCK) != ROK)
1713 ssDestroyDmndQ(&sTsk->dQ);
1715 /* ss006.13: addition */
1716 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1718 #if (ERRCLASS & ERRCLS_DEBUG)
1719 SSLOGERROR(ERRCLS_DEBUG, ESS425, ERRZERO,
1720 "Could not give the Semaphore");
1725 #if (ERRCLASS & ERRCLS_DEBUG)
1726 SSLOGERROR(ERRCLS_DEBUG, ESS426, (ErrVal) ret,
1727 "Could not initialize system task entry lock");
1734 /* we ask the implementation to start this system task */
1735 ret = ssdCreateSTsk(sTsk);
1738 /* failed, clean up */
1739 SDestroyLock(&sTsk->lock);
1740 /*ss014.301 SSI-4GMX specific changes*/
1741 #ifndef SS_4GMX_LCORE
1742 ssDestroyDmndQ(&sTsk->dQ);
1747 /* ss006.13: addition */
1748 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1750 #if (ERRCLASS & ERRCLS_DEBUG)
1751 SSLOGERROR(ERRCLS_DEBUG, ESS427, ERRZERO,
1752 "Could not give the Semaphore");
1757 #if (ERRCLASS & ERRCLS_DEBUG)
1758 SSLOGERROR(ERRCLS_DEBUG, ESS428, (ErrVal) ret,
1759 "Could not create system task");
1765 /* success, update the table */
1766 *tskId = osCp.nxtSTskEntry;
1767 sTsk->tskId = osCp.nxtSTskEntry;
1769 sTsk->termPend = FALSE;
1770 osCp.nxtSTskEntry = sTsk->nxt;
1773 #ifdef SS_LOCKLESS_MEMORY
1774 tmpRegTidMap[sTsk->region] = sTsk->dep.tId;
1775 #endif /* SS_LOCKLESS_MEMORY */
1776 /* unlock the system task table */
1778 /* ss006.13: addition */
1779 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1781 #if (ERRCLASS & ERRCLS_DEBUG)
1782 SSLOGERROR(ERRCLS_DEBUG, ESS429, ERRZERO,
1783 "Could not give the Semaphore");
1792 /* ss001.301: additions */
1793 #ifdef SS_LOGGER_SUPPORT
1796 * Fun: Register logger configuration
1798 * Desc: This function is used to configure the config information
1799 * of the logger.The log file name, path and the size limits
1800 * of the log file are updated in the SSI control block.
1805 * RFAILED - failed, general (optional)
1806 * ROUTRES - failed, out of resources (optional)
1814 PUBLIC S16 SRegLogCfg
1823 PUBLIC S16 SRegLogCfg(mode, path, size, IPA, port)
1837 /*ss013.301: Fixed Warnings for 32/64 bit compilation*/
1838 struct sockaddr_in localAddr={0};
1839 struct sockaddr_in remoteAddr ={0};
1843 #if (ERRCLASS & ERRCLS_INT_PAR)
1846 /* Initialize the lock, return on failure */
1847 if( SInitLock(&(osCp.logger.bufLock),SS_LOCK_MUTEX) != ROK)
1852 SLock(&osCp.logger.bufLock);
1854 /* Initialize the logger configuration flag */
1855 osCp.logger.configured = FALSE;
1857 if( osCp.logger.started == TRUE)
1859 (Void)SUnlock(&(osCp.logger.bufLock));
1863 /* set the mode of the logging */
1866 case SS_LOG_TO_FILE:
1867 osCp.logger.opt |= 0x01;
1869 case SS_LOG_TO_SOCKET:
1870 osCp.logger.opt |= 0x02;
1874 osCp.logger.opt |= 0x03; break;
1878 if (osCp.logger.opt & 0x01)
1880 osCp.logger.filep = fopen(path, "wb");
1881 if(osCp.logger.filep == NULLP)
1883 SDisplay(0,"Error Opening Log File \n");
1884 (Void)SUnlock(&(osCp.logger.bufLock));
1887 strcpy(osCp.logger.filePath,path);
1891 if (osCp.logger.opt & 0x02)
1894 if ((iRes = WSAStartup(MAKEWORD(2,2), &wsaData)) != NO_ERROR)
1896 SDisplay(0, "Error at WSAStartup!\n");
1897 (Void)SUnlock(&(osCp.logger.bufLock));
1901 osCp.logger.socketdes = socket(AF_INET, SOCK_DGRAM, 0);
1902 if(osCp.logger.socketdes == -1)
1904 SDisplay(0,"Error Opening Log Socket \n");
1908 (Void)SUnlock(&(osCp.logger.bufLock));
1911 /* bind to local address */
1912 localAddr.sin_family = AF_INET;
1913 localAddr.sin_port = port;
1914 localAddr.sin_addr.s_addr = INADDR_ANY;
1915 if (bind(osCp.logger.socketdes, (struct sockaddr*)&localAddr, sizeof(struct sockaddr)) < 0)
1917 SDisplay(0,"Error binding to local port \n");
1919 closesocket(osCp.logger.socketdes);
1922 close(osCp.logger.socketdes);
1924 (Void)SUnlock(&(osCp.logger.bufLock));
1927 /* remote address */
1928 remoteAddr.sin_family = AF_INET;
1929 remoteAddr.sin_port = htons(port);
1932 SDisplay(0,"Invalid remote IP Address \n");
1934 closesocket(osCp.logger.socketdes);
1937 close(osCp.logger.socketdes);
1939 (Void)SUnlock(&(osCp.logger.bufLock));
1942 remoteAddr.sin_addr.s_addr = inet_addr(IPA);
1943 osCp.logger.remoteAddr = remoteAddr;
1947 cmMemset((U8*)osCp.logger.buffer, '\0', sizeof(osCp.logger.buffer));
1949 osCp.logger.maxBufSiz = SS_MAX_LOGBUF_SIZE;
1950 osCp.logger.curBufSiz = 0;
1952 osCp.logger.maxNumFlush = size/osCp.logger.maxBufSiz;
1953 osCp.logger.curNumFlush = 0;
1956 osCp.logger.started = FALSE;
1957 osCp.logger.configured = TRUE;
1959 (Void)SUnlock(&(osCp.logger.bufLock));
1966 * Fun: SFlushBufToLog
1968 * Desc: This function is used flush the buffer to file/socket.
1978 PUBLIC S16 SFlushBufToLog
1983 PUBLIC S16 SFlushBufToLog(logBuf)
1988 PRIVATE U16 logFileCnt = 0;
1989 S8 newFileName[SS_MAX_PATH];
1996 /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
1997 TRC1(SFlushBufToLog)
2001 if (osCp.logger.opt & 0x01)
2003 writeNum = fwrite(buffer, sizeof(U8), cmStrlen((U8 *)buffer),
2006 if (osCp.logger.opt & 0x02)
2008 writeNum = sendto(osCp.logger.socketdes, buffer, cmStrlen((U8 *)buffer), 0, (struct sockaddr*)&osCp.logger.remoteAddr, sizeof(osCp.logger.remoteAddr));
2009 /*ss013.301 : Returned after sending to socket*/
2012 osCp.logger.curNumFlush++;
2013 if(osCp.logger.curNumFlush == osCp.logger.maxNumFlush)
2015 cmMemset((U8 *)newFileName,'\0',sizeof(newFileName));
2016 /*Store the current File*/
2017 oldFileP = osCp.logger.filep;
2018 /*Open a new file and use it as a new log file*/
2019 osCp.logger.curNumFlush = 0;
2021 sprintf(newFileName, "%s%d", osCp.logger.filePath, logFileCnt);
2022 osCp.logger.filep = fopen(newFileName, "wb");
2023 if(osCp.logger.filep == NULLP)
2025 /*MTLOGERROR(ERRCLS_DEBUG, EMTXXX, ERRZERO, "Error Opening Log File. \n");*/
2030 /*SPutSBuf(DFLT_REGION,DFLT_POOL,
2031 (Data *)buffer, (Size)(osCp.logger.maxBufSiz * sizeof(S8)));*/
2034 } /* SFlushBufToLog */
2040 * Desc: This function is used to clean up the logger info.
2055 PUBLIC S16 SCleanUp()
2060 /*Flush the remaining data in the log file*/
2061 SLock(&osCp.logger.bufLock);
2062 if(osCp.logger.started == FALSE)
2064 (Void)SUnlock(&(osCp.logger.bufLock));
2067 if(osCp.logger.curBufSiz)
2069 SFlushBufToLog(osCp.logger.buffer);
2070 osCp.logger.curBufSiz = 0;
2073 if (osCp.logger.opt & 0x01)
2075 fclose(osCp.logger.filep);
2077 if (osCp.logger.opt & 0x02)
2080 closesocket(osCp.logger.socketdes);
2082 close(osCp.logger.socketdes);
2085 osCp.logger.started = FALSE;
2087 (Void)SUnlock(&(osCp.logger.bufLock));
2089 signal(SIGINT, App_SigExitCallBack);
2094 } /* end of SCleanUp */
2098 * Fun: Unregister the logger.
2100 * Desc: This function is used to deregister a logger task.
2103 * RFAILED - failed, general (optional)
2104 * ROUTRES - failed, out of resources (optional)
2112 PUBLIC S16 SDeregLogCfg
2116 PUBLIC S16 SDeregLogCfg()
2127 } /* SDeregLogCfg */
2133 * Desc: To start logger.
2143 PUBLIC Void SStartLogger
2148 PUBLIC Void SStartLogger()
2151 if (osCp.logger.configured == TRUE)
2153 osCp.logger.started = TRUE;
2162 * Desc: To stop logging to file/socket.
2172 PUBLIC Void SStopLogger
2177 PUBLIC Void SStopLogger()
2180 osCp.logger.started = FALSE;
2182 #endif /* SS_LOGGER_SUPPORT */
2184 /** for multi-core support **/
2185 /*ss013.301 : changes related to SS_AFFINITY_SUPPORT*/
2186 #if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT)
2190 * Fun: Register the CPU information
2192 * Desc: This function is used to register the number of cores
2193 * present and the number of threads which can be run on
2197 * RFAILED - failed, general (optional)
2205 PUBLIC S16 SRegCpuInfo
2207 SCpuInfo *cpuInfo /* Information about the cores/threads per core */
2210 PUBLIC S16 SRegCpuInfo (cpuInfo)
2211 SCpuInfo *cpuInfo; /* Information about the cores/threads per core */
2216 /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
2218 /* check the number of cores */
2219 if ( cpuInfo->numCores > SS_MAX_CORES ||
2220 cpuInfo->threadsPerCore > SS_MAX_THREADS_PER_CORE ||
2221 cpuInfo->numCores < 1 || cpuInfo->threadsPerCore < 1 )
2223 SSLOGERROR(ERRCLS_INT_PAR, ESS430, ERRZERO, "Invalid number of cores\n");
2228 SLock(&osCp.mCILock);
2229 osCp.mCInfo.cpuInfo.numCores = cpuInfo->numCores;
2230 osCp.mCInfo.cpuInfo.threadsPerCore = cpuInfo->threadsPerCore;
2231 /* if the cpu register is supplied then use it */
2232 for (; coreCount < cpuInfo->numCores; coreCount++)
2235 for (;thrCnt < SS_MAX_THREADS_PER_CORE;thrCnt++)
2237 osCp.mCInfo.coreInfo[coreCount].tskPerCoreLst[thrCnt] = -1;
2239 osCp.mCInfo.coreInfo[coreCount].exclusive = FALSE;
2240 osCp.mCInfo.coreInfo[coreCount].thrs = osCp.mCInfo.cpuInfo.threadRegister[coreCount]
2241 = cpuInfo->threadRegister[coreCount];
2244 SUnlock(&osCp.mCILock);
2254 * Fun: Get the current core/cpu affinity for a thread/lwp
2256 * Desc: This function is used to get the current processor/core
2257 * affinity for a a system task (thread/lwp). It sets the
2258 * affinity based on the mode supplied by the caller.
2261 * RFAILED - failed, general (optional)
2269 PUBLIC S16 SGetAffinity
2271 SSTskId *tskId, /* filled in with system task ID */
2272 U32 *coreId /* the core/processor id to which the affinity is set */
2275 PUBLIC S16 SGetAffinity(tskId, coreId)
2276 SSTskId *tskId; /* filled in with system task ID */
2277 U32 *coreId; /* the core/processor id to which the affinity is set */
2282 /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
2284 /* implementation specific */
2285 ret = ssdGetAffinity(tskId, coreId);
2289 SSLOGERROR(ERRCLS_INT_PAR, ESS431, ERRZERO, "Failed to get affinity\n");
2294 } /* SGetAffinity */
2299 * Fun: Set the core/cpu affinity for a thread/lwp
2301 * Desc: This function is used to set processor/core affinity for a
2302 * a system task (thread/lwp). It sets the affinity based on the
2303 * mode supplied by the caller.
2306 * RFAILED - failed, general (optional)
2314 PUBLIC S16 SSetAffinity
2316 SSTskId *tskId, /* filled in with system task ID */
2317 SsAffinityMode mode, /* the mode according to which the affinty is set */
2318 U32 coreId, /* the core/processor id to which the affinity has to be set */
2319 SSTskId *tskAssociatedTskId /* filled in with system task ID of the associated layer */
2322 PUBLIC S16 SSetAffinity(tskId, mode, coreId, tskAssociatedTskId)
2323 SSTskId *tskId; /* filled in with system task ID */
2324 SsAffinityMode mode; /* the mode according to which the affinty is set */
2325 U32 coreId; /* the core/processor id to which the affinity has to be set */
2326 SSTskId *tskAssociatedTskId; /* filled in with system task ID of the associated layer */
2331 /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
2333 /* validate the mode */
2334 if (mode < SS_AFFINITY_MODE_DEFAULT ||
2335 mode > SS_AFFINITY_MODE_EXCL)
2337 SSLOGERROR(ERRCLS_INT_PAR, ESS432, ERRZERO, "Invalid mode for setting core affinity\n");
2341 /* check the value of core id */
2342 if (SS_AFFINITY_MODE_SPECIFIC == mode &&
2343 (coreId > osCp.mCInfo.cpuInfo.numCores || coreId < 0))
2345 SSLOGERROR(ERRCLS_INT_PAR, ESS433, ERRZERO, "Invalid core id\n");
2349 /* set affinity according to the mode supplied */
2352 case SS_AFFINITY_MODE_DEFAULT:
2354 U32 coreCounter = 0, coreIndex = 0;
2357 /*ss013.301: Fixed Warnings for 32/64 bit compilation*/
2358 for (coreIndex = osCp.mCInfo.currentCore;
2359 coreCounter < osCp.mCInfo.cpuInfo.numCores;
2362 /* again start from core 0 */
2364 coreIndex = (coreIndex)%osCp.mCInfo.cpuInfo.numCores;
2365 if (!osCp.mCInfo.coreInfo[coreIndex].exclusive
2366 && osCp.mCInfo.cpuInfo.threadRegister[coreIndex])
2368 if (osCp.mCInfo.coreInfo[coreIndex].thrs || !repeatFlag)
2370 /* call the implementation specific affinity function */
2371 ret = ssdSetAffinity(tskId, coreIndex);
2375 SSLOGERROR(ERRCLS_INT_PAR, ESS434, ERRZERO, \
2376 "Failed to set core affinity\n");
2381 SLock(&osCp.mCILock);
2383 /* move the current core index */
2384 osCp.mCInfo.currentCore = (coreIndex+1)%osCp.mCInfo.cpuInfo.numCores;
2386 /* save the tskId in tskList */
2387 osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[
2388 osCp.mCInfo.cpuInfo.threadRegister[coreIndex] -
2389 osCp.mCInfo.coreInfo[coreIndex].thrs] = *tskId;
2391 /* decrement the available thread count in the thread register */
2392 osCp.mCInfo.coreInfo[coreIndex].thrs--;
2395 SUnlock(&osCp.mCILock);
2398 } /* end if there are threads available in the core */
2399 } /* end if the core is not exclusive flagged and
2400 the core has threads for SSI use */
2402 if (coreCounter == osCp.mCInfo.cpuInfo.numCores && repeatFlag)
2405 SSLOGERROR(ERRCLS_INT_PAR, ESS435, ERRZERO, "Overloading of threads per core!!\n");
2406 goto SEARCH_FOR_CORE;
2407 } /* end if no thrs on cores available and overallocation is needed */
2409 } /* end case SS_AFFINITY_MODE_DEFAULT */
2410 case SS_AFFINITY_MODE_SPECIFIC:
2412 /* check if the core is used exclusively for any task */
2413 if (osCp.mCInfo.coreInfo[coreId].exclusive)
2415 SSLOGERROR(ERRCLS_INT_PAR, ESS436, ERRZERO,\
2416 "Can not set core affinity, core is exclusively used for other task\n");
2419 /* call the implementation specific affinity function with the core id supplied by caller */
2420 ret = ssdSetAffinity(tskId, coreId);
2424 SSLOGERROR(ERRCLS_INT_PAR, ESS437, ERRZERO, "Failed to set core affinity\n");
2429 SLock(&osCp.mCILock);
2431 /* move the current core index */
2432 osCp.mCInfo.currentCore = (coreId+1)%osCp.mCInfo.cpuInfo.numCores;
2434 /* save the tskId in tskList */
2435 osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[
2436 osCp.mCInfo.cpuInfo.threadRegister[coreId] -
2437 osCp.mCInfo.coreInfo[coreId].thrs] = *tskId;
2439 /* decrement the available thread count in the thread register */
2440 osCp.mCInfo.coreInfo[coreId].thrs--;
2443 SUnlock(&osCp.mCILock);
2445 if (osCp.mCInfo.coreInfo[coreId].thrs < 0)
2447 SSLOGERROR(ERRCLS_INT_PAR, ESS438, ERRZERO, "Overloading of threads per core!!\n");
2451 } /* end case SS_AFFINITY_MODE_SPECIFIC */
2452 case SS_AFFINITY_MODE_ASSOC:
2454 /* search for the associated tsk id in osCp */
2455 U32 coreIndex = 0, threadIndex = 0;
2456 Bool tskNotFound = TRUE;
2457 for (;tskNotFound && coreIndex < SS_MAX_CORES; coreIndex++)
2459 for (threadIndex = 0; threadIndex < SS_MAX_THREADS_PER_CORE; threadIndex++)
2461 if (osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[threadIndex] == *tskAssociatedTskId)
2463 if (!osCp.mCInfo.coreInfo[coreIndex].exclusive)
2465 /* set the affinity for the given task on to the core coreIndex */
2466 ret = ssdSetAffinity(tskId, coreIndex);
2469 SSLOGERROR(ERRCLS_INT_PAR, ESS439, ERRZERO, "Failed to set core affinity\n");
2474 SLock(&osCp.mCILock);
2476 /* move the current core index */
2477 osCp.mCInfo.currentCore = (coreIndex+1)%osCp.mCInfo.cpuInfo.numCores;
2479 /* save the tskId in tskList */
2480 osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[
2481 osCp.mCInfo.cpuInfo.threadRegister[coreIndex] -
2482 osCp.mCInfo.coreInfo[coreIndex].thrs] = *tskId;
2484 /* decrement the available thread count in the thread register */
2485 osCp.mCInfo.coreInfo[coreIndex].thrs--;
2488 SUnlock(&osCp.mCILock);
2490 if (osCp.mCInfo.coreInfo[coreIndex].thrs < 0)
2492 SSLOGERROR(ERRCLS_INT_PAR, ESS440, ERRZERO,
2493 "Overloading of threads per core!!\n");
2499 SSLOGERROR(ERRCLS_INT_PAR, ESS441, ERRZERO,
2500 "Can not set core affinity, core is exclusively used for other task\n");
2503 tskNotFound = FALSE;
2506 } /* end inner for */
2509 /* check if tskAssociatedTskId is valid or not */
2510 if (coreIndex == SS_MAX_CORES)
2512 SSLOGERROR(ERRCLS_INT_PAR, ESS442, ERRZERO, "Invalid core id\n");
2516 } /* end case SS_AFFINITY_MODE_ASSOC */
2517 case SS_AFFINITY_MODE_EXCL:
2519 /* check if any thread is already running on the core */
2520 if (coreId != SS_DEFAULT_CORE &&
2521 osCp.mCInfo.coreInfo[coreId].thrs == osCp.mCInfo.cpuInfo.threadRegister[coreId] &&
2522 !osCp.mCInfo.coreInfo[coreId].exclusive)
2524 /* call the implementation specific affinity function */
2525 ret = ssdSetAffinity(tskId, coreId);
2529 SSLOGERROR(ERRCLS_INT_PAR, ESS443, ERRZERO, "Failed to set core affinity\n");
2534 SLock(&osCp.mCILock);
2536 /* set the exclusive flag so that the core will not be used for other system tasks */
2537 osCp.mCInfo.coreInfo[coreId].exclusive = TRUE;
2539 /* save the tskId in tskList */
2540 osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[osCp.mCInfo.cpuInfo.threadRegister[coreId] -
2541 osCp.mCInfo.coreInfo[coreId].thrs] = *tskId;
2543 /* decrement the available thread count in the thread register */
2544 osCp.mCInfo.coreInfo[coreId].thrs--;
2547 SUnlock(&osCp.mCILock);
2550 else if (coreId == SS_DEFAULT_CORE)
2552 U32 coreCounter = 0;
2554 /*ss013.301: Fixed Warnings for 32/64 bit compilation*/
2555 for (coreIndex = osCp.mCInfo.currentCore;
2556 coreCounter < osCp.mCInfo.cpuInfo.numCores;
2560 coreIndex = (coreIndex)%osCp.mCInfo.cpuInfo.numCores;
2561 if (!osCp.mCInfo.coreInfo[coreIndex].exclusive
2562 && osCp.mCInfo.cpuInfo.threadRegister[coreIndex])
2564 if ( osCp.mCInfo.coreInfo[coreIndex].thrs ==
2565 osCp.mCInfo.cpuInfo.threadRegister[coreIndex] &&
2566 osCp.mCInfo.coreInfo[coreIndex].thrs)
2568 /* call the implementation specific affinity function */
2569 ret = ssdSetAffinity(tskId, coreIndex);
2573 SSLOGERROR(ERRCLS_INT_PAR, ESS444, ERRZERO, "Failed to set core affinity\n");
2578 SLock(&osCp.mCILock);
2580 /* move the current core index */
2581 osCp.mCInfo.currentCore = (coreIndex+1)%osCp.mCInfo.cpuInfo.numCores;
2583 /* save the tskId in tskList */
2584 osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[
2585 osCp.mCInfo.cpuInfo.threadRegister[coreIndex] -
2586 osCp.mCInfo.coreInfo[coreIndex].thrs] = *tskId;
2588 /* decrement the available thread count in the thread register */
2589 osCp.mCInfo.coreInfo[coreIndex].thrs--;
2591 /* set the exclusive flag so that the core will not
2592 be used for other system tasks */
2593 osCp.mCInfo.coreInfo[coreIndex].exclusive = TRUE;
2596 SUnlock(&osCp.mCILock);
2599 } /* end if there are threads available in the core */
2600 } /* end if the core is not exclusive flagged and
2601 the core has threads for SSI use */
2603 if (coreCounter == osCp.mCInfo.cpuInfo.numCores)
2605 SSLOGERROR(ERRCLS_INT_PAR, ESS445, ERRZERO,
2606 "Failed to set core affinity, no threads on cores available\n");
2608 } /* end if no thrs on cores available */
2613 SSLOGERROR(ERRCLS_INT_PAR, ESS446, ERRZERO, "Can not set exclusive affinity for the core\n");
2617 } /* end case SS_AFFINITY_MODE_EXCL */
2620 SSLOGERROR(ERRCLS_INT_PAR, ESS447, ERRZERO, "Invalid mode for setting core affinity\n");
2622 } /* end default case */
2623 } /* end of switch */
2628 } /* SSetAffinity */
2630 #endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT*/
2632 /** end multi-core support **/
2637 * Fun: Destroy system task
2639 * Desc: This function is used to destroy a system task. The
2640 * entry is located in the system task table and the
2641 * implementation-specific function is called.
2644 * RFAILED - failed, general (optional)
2652 PUBLIC S16 SDestroySTsk
2654 SSTskId tskId /* system task to be destroyed */
2657 PUBLIC S16 SDestroySTsk(tskId)
2658 SSTskId tskId; /* system task to be destroyed */
2662 /* ss029.103: modification: the subscript should be of same type */
2666 /* ss002.301 Additions */
2667 /*ss013.301 : changes related to SS_AFFINITY_SUPPORT*/
2668 #if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT)
2670 #endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT*/
2676 #if (ERRCLASS & ERRCLS_INT_PAR)
2677 /* validate the system task ID */
2678 if (tskId >= SS_MAX_STSKS)
2680 SSLOGERROR(ERRCLS_INT_PAR, ESS448, (ErrVal) tskId, "Invalid task ID");
2686 /* lock the system task table */
2687 ret = SLock(&osCp.sTskTblLock);
2691 #if (ERRCLASS & ERRCLS_DEBUG)
2692 SSLOGERROR(ERRCLS_DEBUG, ESS449, (ErrVal) ret,
2693 "Could not lock system task table");
2700 idx = (SsIdx) tskId;
2701 sTsk = &osCp.sTskTbl[idx];
2704 #if (ERRCLASS & ERRCLS_INT_PAR)
2706 * check to see this system task exists and it is not already scheduled
2709 if (sTsk->used != TRUE)
2712 /* ss006.13: addition */
2713 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2715 #if (ERRCLASS & ERRCLS_DEBUG)
2716 SSLOGERROR(ERRCLS_DEBUG, ESS450, ERRZERO,
2717 "Could not give the Semaphore");
2722 SSLOGERROR(ERRCLS_INT_PAR, ESS451, (ErrVal) idx,
2723 "Invalid system task ID");
2726 else if (sTsk->termPend != FALSE)
2729 /* ss006.13: addition */
2730 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2732 #if (ERRCLASS & ERRCLS_DEBUG)
2733 SSLOGERROR(ERRCLS_DEBUG, ESS452, ERRZERO,
2734 "Could not give the Semaphore");
2739 SSLOGERROR(ERRCLS_INT_PAR, ESS453, (ErrVal) idx,
2740 "Invalid system task ID");
2746 /* lock this system task entry */
2747 if (!SS_CHECK_CUR_STSK(sTsk))
2749 ret = SLock(&sTsk->lock);
2753 /* ss006.13: addition */
2754 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2756 #if (ERRCLASS & ERRCLS_DEBUG)
2757 SSLOGERROR(ERRCLS_DEBUG, ESS454, ERRZERO,
2758 "Could not give the Semaphore");
2763 #if (ERRCLASS & ERRCLS_DEBUG)
2764 SSLOGERROR(ERRCLS_DEBUG, ESS455, (ErrVal) ret,
2765 "Could not lock system task entry");
2772 /* lock the TAPA task table */
2773 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
2776 if (!SS_CHECK_CUR_STSK(sTsk))
2779 /* ss006.13: addition */
2780 if ( SUnlock(&sTsk->lock) != ROK)
2782 #if (ERRCLASS & ERRCLS_DEBUG)
2783 SSLOGERROR(ERRCLS_DEBUG, ESS456, ERRZERO,
2784 "Could not give the Semaphore");
2790 /* ss006.13: addition */
2791 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2793 #if (ERRCLASS & ERRCLS_DEBUG)
2794 SSLOGERROR(ERRCLS_DEBUG, ESS457, ERRZERO,
2795 "Could not give the Semaphore");
2800 #if (ERRCLASS & ERRCLS_DEBUG)
2801 SSLOGERROR(ERRCLS_DEBUG, ESS458, ERRZERO,
2802 "Could not lock TAPA task table");
2809 /* If this system task entry has any TAPA tasks attached,
2810 * we have to detach them
2814 /* detach all TAPA tasks that are attached here */
2815 for (i = 0; i < SS_MAX_TTSKS; i++)
2817 if (sTsk->tTsks[i] == SS_INVALID_IDX)
2820 osCp.tTskTbl[sTsk->tTsks[i]].sTsk = NULLP;
2821 sTsk->tTsks[i] = SS_INVALID_IDX;
2827 /* set the termination pending flag to TRUE */
2828 sTsk->termPend = TRUE;
2831 /* unlock everything */
2832 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
2834 if (!SS_CHECK_CUR_STSK(sTsk))
2837 /* ss006.13: addition */
2838 if ( SUnlock(&sTsk->lock) != ROK)
2840 #if (ERRCLASS & ERRCLS_DEBUG)
2841 SSLOGERROR(ERRCLS_DEBUG, ESS459, ERRZERO,
2842 "Could not give the Semaphore");
2849 /* ss006.13: addition */
2850 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2852 #if (ERRCLASS & ERRCLS_DEBUG)
2853 SSLOGERROR(ERRCLS_DEBUG, ESS460, ERRZERO,
2854 "Could not give the Semaphore");
2860 /* We call this after unlocking because it is possible that the
2861 * caller is this very system task and we need to take care of
2862 * that. The actual mechanism of notifying the thread that it
2863 * has to die, or actually killing the thread is left to the
2866 ret = ssdDestroySTsk(sTsk);
2869 /* Here, we're a little messed up. We've pretty much made this
2870 * system task unusable, but now, its not going to die. So..??
2873 #if (ERRCLASS & ERRCLS_DEBUG)
2874 SSLOGERROR(ERRCLS_DEBUG, ESS461, (ErrVal) ret,
2875 "Could not destroy system task");
2881 /* multi-core support */
2882 /*ss013.301 : changes related to SS_AFFINITY_SUPPORT*/
2883 #if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT)
2885 /* Remove CPU affinity if any */
2886 for (tskInd = 0; tskInd < SS_MAX_STSKS; tskInd++)
2888 if (osCp.sTskTbl[tskInd].tskId == sTsk->tskId)
2890 /* search for the tskId in coreInfo */
2892 for (coreId = 0; coreId < SS_MAX_CORES; coreId++)
2895 for (thrId = 0; thrId < SS_MAX_THREADS_PER_CORE; thrId++)
2897 if (sTsk->tskId == osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[thrId])
2900 SLock(&osCp.mCILock);
2902 /* increment the available threads */
2903 osCp.mCInfo.coreInfo[coreId].thrs++;
2905 /* reset the thread id */
2906 osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[thrId] = 0;
2908 /* if exclusive flag is set then remove it */
2909 if (osCp.mCInfo.coreInfo[coreId].exclusive)
2911 osCp.mCInfo.coreInfo[coreId].exclusive = FALSE;
2912 } /* end if excl set */
2915 SUnlock(&osCp.mCILock);
2918 } /* end if sTsk matched a thread */
2919 } /* end for loop of thread Ids */
2925 #endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT*/
2926 /* end multi-core support */
2928 /* ss019.103 - added to release semaphore for system task */
2930 if (ssPostSema(&osCp.dep.ssStarted) != ROK)
2932 #if (ERRCLASS & ERRCLS_DEBUG)
2933 SSLOGERROR(ERRCLS_DEBUG, ESS462, ERRZERO,
2934 "Could not unlock the Semaphore");
2941 } /* SDestroySTsk */
2947 * Fun: Attach TAPA task
2949 * Desc: This function is used to attach a TAPA task to a
2950 * system task. The system task will begin to execute
2954 * RFAILED - failed, general (optional)
2955 * ROUTRES - failed, out of resources (optional)
2962 /* ss029.103: addition: procId added */
2963 #ifndef SS_MULTIPLE_PROCS
2966 PUBLIC S16 SAttachTTsk
2968 Ent ent, /* entity ID of the task */
2969 Inst inst, /* instance ID of the task */
2970 SSTskId sTskId /* system task to use */
2973 PUBLIC S16 SAttachTTsk(ent, inst, sTskId)
2974 Ent ent; /* entity ID of the task */
2975 Inst inst; /* instance ID of the task */
2976 SSTskId sTskId; /* system task to use */
2979 #else /* SS_MULTIPLE_PROCS */
2982 PUBLIC S16 SAttachTTsk
2984 ProcId proc, /* processor ID of the task */
2985 Ent ent, /* entity ID of the task */
2986 Inst inst, /* instance ID of the task */
2987 SSTskId sTskId /* system task to use */
2990 PUBLIC S16 SAttachTTsk(proc, ent, inst, sTskId)
2991 ProcId proc; /* processor ID of the task */
2992 Ent ent; /* entity ID of the task */
2993 Inst inst; /* instance ID of the task */
2994 SSTskId sTskId; /* system task to use */
2997 #endif /* SS_MULTIPLE_PROCS */
3004 /* ss029.103: addition: multiple procIds related changes */
3005 #ifdef SS_MULTIPLE_PROCS
3007 #endif /* SS_MULTIPLE_PROCS */
3008 #ifdef SS_MULTICORE_SUPPORT
3010 #ifdef SS_MULTIPLE_PROCS
3012 #endif /* SS_MULTIPLE_PROCS */
3019 #if (ERRCLASS & ERRCLS_INT_PAR)
3020 /* check entity and instance range */
3021 /* ss029.103: addition: multiple procIds related changes */
3022 #ifdef SS_MULTIPLE_PROCS
3023 /* check proc, entity and instance range */
3024 if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST))
3026 SSLOGERROR(ERRCLS_INT_PAR, ESS463, ERRZERO, "Invalid processor/entity/instance");
3029 #else /* SS_MULTIPLE_PROCS */
3030 /* check entity and instance range */
3031 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
3033 SSLOGERROR(ERRCLS_INT_PAR, ESS464, ERRZERO, "Invalid entity/instance");
3036 #endif /* SS_MULTIPLE_PROCS */
3038 /* check the system task index */
3039 if ((SsIdx)sTskId >= SS_MAX_STSKS)
3041 SSLOGERROR(ERRCLS_INT_PAR, ESS465, (ErrVal) sTskId,
3042 "Invalid system task ID");
3047 /* ss029.103: addition: multiple procIds related changes */
3048 #ifdef SS_MULTIPLE_PROCS
3049 /* get the proc id idx */
3050 procIdIdx = SGetProcIdIdx(proc);
3052 if (procIdIdx == SS_INV_PROCID)
3054 #if (ERRCLASS & ERRCLS_DEBUG)
3055 SSLOGERROR(ERRCLS_DEBUG, ESS466, ERRZERO,
3056 "Could not find proc id index");
3060 #endif /* SS_MULTIPLE_PROCS */
3062 /* lock the system task table */
3063 ret = SLock(&osCp.sTskTblLock);
3067 #if (ERRCLASS & ERRCLS_DEBUG)
3068 SSLOGERROR(ERRCLS_DEBUG, ESS467, (ErrVal) ret,
3069 "Could not lock system task table");
3076 sTsk = &osCp.sTskTbl[(SsIdx)sTskId];
3079 #if (ERRCLASS & ERRCLS_INT_PAR)
3080 /* verify that this system task exists */
3081 if (sTsk->used == FALSE)
3084 /* ss006.13: addition */
3085 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3087 #if (ERRCLASS & ERRCLS_DEBUG)
3088 SSLOGERROR(ERRCLS_DEBUG, ESS468, ERRZERO,
3089 "Could not give the Semaphore");
3094 SSLOGERROR(ERRCLS_INT_PAR, ESS469, (ErrVal) sTskId,
3095 "Unknown system task ID");
3101 /* lock the system task entry */
3102 if (!SS_CHECK_CUR_STSK(sTsk))
3104 ret = SLock(&sTsk->lock);
3108 /* ss006.13: addition */
3109 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3111 #if (ERRCLASS & ERRCLS_DEBUG)
3112 SSLOGERROR(ERRCLS_DEBUG, ESS470, ERRZERO,
3113 "Could not give the Semaphore");
3118 #if (ERRCLASS & ERRCLS_DEBUG)
3119 SSLOGERROR(ERRCLS_DEBUG, ESS471, (ErrVal) ret,
3120 "Could not lock system task entry");
3128 /* if this system task is about to die, we don't attach */
3129 if (sTsk->termPend == TRUE)
3131 if (!SS_CHECK_CUR_STSK(sTsk))
3134 /* ss006.13: addition */
3135 if ( SUnlock(&sTsk->lock) != ROK)
3137 #if (ERRCLASS & ERRCLS_DEBUG)
3138 SSLOGERROR(ERRCLS_DEBUG, ESS472, ERRZERO,
3139 "Could not give the Semaphore");
3145 /* ss006.13: addition */
3146 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3148 #if (ERRCLASS & ERRCLS_DEBUG)
3149 SSLOGERROR(ERRCLS_DEBUG, ESS473, ERRZERO,
3150 "Could not give the Semaphore");
3159 /* lock the TAPA task table */
3160 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
3163 if (!SS_CHECK_CUR_STSK(sTsk))
3166 /* ss006.13: addition */
3167 if ( SUnlock(&sTsk->lock) != ROK)
3169 #if (ERRCLASS & ERRCLS_DEBUG)
3170 SSLOGERROR(ERRCLS_DEBUG, ESS474, ERRZERO,
3171 "Could not give the Semaphore");
3178 /* ss006.13: addition */
3179 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3181 #if (ERRCLASS & ERRCLS_DEBUG)
3182 SSLOGERROR(ERRCLS_DEBUG, ESS475, ERRZERO,
3183 "Could not give the Semaphore");
3188 #if (ERRCLASS & ERRCLS_DEBUG)
3189 SSLOGERROR(ERRCLS_DEBUG, ESS476, ERRZERO,
3190 "Could not lock TAPA task table");
3197 /* get the index of the TAPA task entry in the table */
3198 /* ss029.103: addition: multiple procIds related changes */
3199 #ifdef SS_MULTIPLE_PROCS
3200 idx = osCp.tTskIds[procIdIdx][ent][inst];
3201 #else /* SS_MULTIPLE_PROCS */
3202 idx = osCp.tTskIds[ent][inst];
3203 #endif /* SS_MULTIPLE_PROCS */
3205 #if (ERRCLASS & ERRCLS_INT_PAR)
3206 /* check out the TAPA task ID */
3207 if (idx == SS_TSKNC)
3209 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3210 if (!SS_CHECK_CUR_STSK(sTsk))
3213 /* ss006.13: addition */
3214 if ( SUnlock(&sTsk->lock) != ROK)
3216 #if (ERRCLASS & ERRCLS_DEBUG)
3217 SSLOGERROR(ERRCLS_DEBUG, ESS477, ERRZERO,
3218 "Could not give the Semaphore");
3224 /* ss006.13: addition */
3225 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3227 #if (ERRCLASS & ERRCLS_DEBUG)
3228 SSLOGERROR(ERRCLS_DEBUG, ESS478, ERRZERO,
3229 "Could not give the Semaphore");
3234 SSLOGERROR(ERRCLS_INT_PAR, ESS479, ERRZERO, "Unknown task");
3240 /* verify that this TAPA task is not already attached */
3241 if (osCp.tTskTbl[idx].sTsk != NULLP)
3243 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3244 if (!SS_CHECK_CUR_STSK(sTsk))
3247 /* ss006.13: addition */
3248 if ( SUnlock(&sTsk->lock) != ROK)
3250 #if (ERRCLASS & ERRCLS_DEBUG)
3251 SSLOGERROR(ERRCLS_DEBUG, ESS480, ERRZERO,
3252 "Could not give the Semaphore");
3258 /* ss006.13: addition */
3259 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3261 #if (ERRCLASS & ERRCLS_DEBUG)
3262 SSLOGERROR(ERRCLS_DEBUG, ESS481, ERRZERO,
3263 "Could not give the Semaphore");
3272 /* verify that there is space for another TAPA task */
3273 if (sTsk->numTTsks == SS_MAX_TTSKS)
3275 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3276 if (!SS_CHECK_CUR_STSK(sTsk))
3279 /* ss006.13: addition */
3280 if ( SUnlock(&sTsk->lock) != ROK)
3282 #if (ERRCLASS & ERRCLS_DEBUG)
3283 SSLOGERROR(ERRCLS_DEBUG, ESS482, ERRZERO,
3284 "Could not give the Semaphore");
3290 /* ss006.13: addition */
3291 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3293 #if (ERRCLASS & ERRCLS_DEBUG)
3294 SSLOGERROR(ERRCLS_DEBUG, ESS483, ERRZERO,
3295 "Could not give the Semaphore");
3304 /* Find place for this TAPA task in the system task's list
3305 * of TAPA tasks to run. Plug in this TAPA task.
3307 for (i = 0; i < SS_MAX_TTSKS; i++)
3309 if (sTsk->tTsks[i] == SS_INVALID_IDX)
3311 sTsk->tTsks[i] = idx;
3318 /* Fill in the system task info in the TAPA task entry, so
3319 * the TAPA task knows who's running it.
3321 osCp.tTskTbl[idx].sTsk = sTsk;
3322 #ifdef SS_MULTICORE_SUPPORT
3323 tTsk = &osCp.tTskTbl[idx];
3324 if(tTsk->initTsk != NULLP)
3326 #ifndef SS_MULTIPLE_PROCS
3327 (Void)(tTsk->initTsk)(tTsk->ent, tTsk->inst, sTsk->region, PWR_UP);
3329 /* retrieve proc id index in the proc id table */
3330 procIdIdx = SGetProcIdIdx(tTsk->proc);
3332 /* Check whether the proc id exist in the proc id table */
3333 if (procIdIdx == SS_INV_PROCID_IDX)
3335 #if (ERRCLASS & ERRCLS_INT_PAR)
3336 SSLOGERROR(ERRCLS_INT_PAR, ESS389, ERRZERO,
3337 "Could not find proc table index");
3342 (Void)(tTsk->initTsk)(tTsk->proc, tTsk->ent, tTsk->inst, sTsk->region, PWR_UP, &xxCb);
3344 * store the control block. The control block may be NULL in some cases
3346 idx = osCp.tTskIds[procIdIdx][tTsk->ent][tTsk->inst];
3347 #if (ERRCLASS & ERRCLS_INT_PAR)
3348 if ( xxCb == NULLP )
3350 SSLOGERROR(ERRCLS_INT_PAR, ERRZERO, ERRZERO,
3354 osCp.tTskTbl[idx].xxCb = xxCb;
3355 #endif /* SS_MULTIPLE_PROCS */
3357 #endif /* SS_MULTICORE_SUPPORT */
3360 /* call the implementation to do anything implementation-specific */
3361 ret = ssdAttachTTsk(&osCp.tTskTbl[idx]);
3364 /* unlock the tables; we're done */
3365 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3366 if (!SS_CHECK_CUR_STSK(sTsk))
3369 /* ss006.13: addition */
3370 if ( SUnlock(&sTsk->lock) != ROK)
3372 #if (ERRCLASS & ERRCLS_DEBUG)
3373 SSLOGERROR(ERRCLS_DEBUG, ESS484, ERRZERO,
3374 "Could not give the Semaphore");
3380 /* ss006.13: addition */
3381 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3383 #if (ERRCLASS & ERRCLS_DEBUG)
3384 SSLOGERROR(ERRCLS_DEBUG, ESS485, ERRZERO,
3385 "Could not give the Semaphore");
3391 /* If the implementation didn't succeed, we have to undo everything.
3392 * We call SDetachTTsk, to make it easier.
3396 /* ss029.103: addition: multiple procIds related changes */
3397 #ifdef SS_MULTIPLE_PROCS
3398 SDetachTTsk(proc, ent, inst);
3399 #else /* SS_MULTIPLE_PROCS */
3400 SDetachTTsk(ent, inst);
3401 #endif /* SS_MULTIPLE_PROCS */
3412 * Fun: Detach TAPA task
3414 * Desc: This function is used to detach a TAPA task from a
3415 * system task. The system task will stop executing
3419 * RFAILED - failed, general (optional)
3426 /* ss029.103: addition: procId added */
3427 #ifndef SS_MULTIPLE_PROCS
3430 PUBLIC S16 SDetachTTsk
3432 Ent ent, /* entity ID of the task */
3433 Inst inst /* instance ID of the task */
3436 PUBLIC S16 SDetachTTsk(ent, inst)
3437 Ent ent; /* entity ID of the task */
3438 Inst inst; /* instance ID of the task */
3441 #else /* SS_MULTIPLE_PROCS */
3444 PUBLIC S16 SDetachTTsk
3446 ProcId proc, /* processor ID of the task */
3447 Ent ent, /* entity ID of the task */
3448 Inst inst /* instance ID of the task */
3451 PUBLIC S16 SDetachTTsk(proc, ent, inst)
3452 ProcId proc; /* processor ID of the task */
3453 Ent ent; /* entity ID of the task */
3454 Inst inst; /* instance ID of the task */
3457 #endif /* SS_MULTIPLE_PROCS */
3465 /* ss029.103: addition: multiple procIds related changes */
3466 #ifdef SS_MULTIPLE_PROCS
3468 #endif /* SS_MULTIPLE_PROCS */
3473 #if (ERRCLASS & ERRCLS_INT_PAR)
3474 /* check entity and instance ranges */
3475 /* ss029.103: addition: multiple procIds related changes */
3476 #ifdef SS_MULTIPLE_PROCS
3477 /* check entity and instance ranges */
3478 if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST))
3480 SSLOGERROR(ERRCLS_INT_PAR, ESS486, ERRZERO, "Invalid processor/entity/instance");
3483 #else /* SS_MULTIPLE_PROCS */
3484 /* check entity and instance ranges */
3485 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
3487 SSLOGERROR(ERRCLS_INT_PAR, ESS487, ERRZERO, "Invalid entity/instance");
3490 #endif /* SS_MULTIPLE_PROCS */
3493 /* ss029.103: addition: multiple procIds related changes */
3494 #ifdef SS_MULTIPLE_PROCS
3495 /* get the proc id idx */
3496 procIdIdx = SGetProcIdIdx(proc);
3498 if (procIdIdx == SS_INV_PROCID)
3500 #if (ERRCLASS & ERRCLS_DEBUG)
3501 SSLOGERROR(ERRCLS_DEBUG, ESS488, ERRZERO,
3502 "Could not find proc id index");
3506 #endif /* SS_MULTIPLE_PROCS */
3509 /* Lock the system task table. We do this to prevent
3510 * the system task from being destroyed and confusing
3511 * matters before we detach.
3513 ret = SLock(&osCp.sTskTblLock);
3517 #if (ERRCLASS & ERRCLS_DEBUG)
3518 SSLOGERROR(ERRCLS_DEBUG, ESS489, (ErrVal) ret,
3519 "Could not lock system task table");
3526 /* lock the TAPA task table */
3527 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
3531 /* ss006.13: addition */
3532 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3534 #if (ERRCLASS & ERRCLS_DEBUG)
3535 SSLOGERROR(ERRCLS_DEBUG, ESS490, ERRZERO,
3536 "Could not give the Semaphore");
3541 #if (ERRCLASS & ERRCLS_DEBUG)
3542 SSLOGERROR(ERRCLS_DEBUG, ESS491, ERRZERO,
3543 "Could not lock TAPA task table");
3550 #if (ERRCLASS & ERRCLS_INT_PAR)
3551 /* Check this TAPA task. We do this with the TAPA task table
3552 * locked, coz we don't want the task to be found, but then
3553 * be deregistered before we lock
3555 /* ss029.103: addition: multiple procIds related changes */
3556 #ifdef SS_MULTIPLE_PROCS
3557 if (osCp.tTskIds[procIdIdx][ent][inst] == SS_TSKNC)
3558 #else /* SS_MULTIPLE_PROCS */
3559 if (osCp.tTskIds[ent][inst] == SS_TSKNC)
3560 #endif /* SS_MULTIPLE_PROCS */
3562 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3564 /* ss006.13: addition */
3565 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3567 #if (ERRCLASS & ERRCLS_DEBUG)
3568 SSLOGERROR(ERRCLS_DEBUG, ESS492, ERRZERO,
3569 "Could not give the Semaphore");
3574 SSLOGERROR(ERRCLS_INT_PAR, ESS493, ERRZERO, "Unknown task");
3579 /* ss029.103: addition: multiple procIds related changes */
3580 #ifdef SS_MULTIPLE_PROCS
3581 idx = osCp.tTskIds[procIdIdx][ent][inst];
3582 #else /* SS_MULTIPLE_PROCS */
3583 idx = osCp.tTskIds[ent][inst];
3584 #endif /* SS_MULTIPLE_PROCS */
3586 tTsk = &osCp.tTskTbl[idx];
3588 /* check if this TAPA task is attached to anyone */
3589 if (tTsk->sTsk == NULLP)
3591 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3593 /* ss006.13: addition */
3594 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3596 #if (ERRCLASS & ERRCLS_DEBUG)
3597 SSLOGERROR(ERRCLS_DEBUG, ESS494, ERRZERO,
3598 "Could not give the Semaphore");
3606 /* we get the system task entry out */
3610 /* We unlock the TAPA task table here, and then re-lock it later
3611 * because of lock sequencing--we have to lock the system task
3612 * entry first, and then the TAPA task table. Note, the system
3613 * task table is locked, so nobody can sneak in and destroy the
3614 * system task while we're doing this.
3616 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3619 /* lock the system task entry */
3620 if (!SS_CHECK_CUR_STSK(sTsk))
3622 ret = SLock(&sTsk->lock);
3626 /* ss006.13: addition */
3627 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3629 #if (ERRCLASS & ERRCLS_DEBUG)
3630 SSLOGERROR(ERRCLS_DEBUG, ESS495, ERRZERO,
3631 "Could not give the Semaphore");
3636 #if (ERRCLASS & ERRCLS_DEBUG)
3637 SSLOGERROR(ERRCLS_DEBUG, ESS496, (ErrVal) ret,
3638 "Could not lock system task entry");
3646 /* now we lock the TAPA task table */
3647 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
3651 /* ss006.13: addition */
3652 if ( SUnlock(&sTsk->lock) != ROK)
3654 #if (ERRCLASS & ERRCLS_DEBUG)
3655 SSLOGERROR(ERRCLS_DEBUG, ESS497, ERRZERO,
3656 "Could not give the Semaphore");
3660 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3662 #if (ERRCLASS & ERRCLS_DEBUG)
3663 SSLOGERROR(ERRCLS_DEBUG, ESS498, ERRZERO,
3664 "Could not give the Semaphore");
3669 #if (ERRCLASS & ERRCLS_DEBUG)
3670 SSLOGERROR(ERRCLS_DEBUG, ESS499, ERRZERO,
3671 "Could not lock TAPA task table");
3678 /* Now, we can safely update both the system task entry
3679 * and the TAPA task entry. First, we update the TAPA
3680 * task entry--nobody is running it now.
3685 /* Remove this TAPA task from the system task's list of
3686 * TAPA tasks to run.
3688 for (i = 0; i < SS_MAX_TTSKS; i++)
3690 if (sTsk->tTsks[i] == idx)
3692 sTsk->tTsks[i] = SS_INVALID_IDX;
3699 /* call the implementation to do anything it needs to */
3700 ret = ssdDetachTTsk(tTsk);
3703 /* unlock the TAPA task table */
3704 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3706 /* unlock the system task entry */
3707 if (!SS_CHECK_CUR_STSK(sTsk))
3710 /* ss006.13: addition */
3711 if ( SUnlock(&sTsk->lock) != ROK)
3713 #if (ERRCLASS & ERRCLS_DEBUG)
3714 SSLOGERROR(ERRCLS_DEBUG, ESS500, ERRZERO,
3715 "Could not give the Semaphore");
3721 /* unlock the system task table */
3723 /* ss006.13: addition */
3724 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3726 #if (ERRCLASS & ERRCLS_DEBUG)
3727 SSLOGERROR(ERRCLS_DEBUG, ESS501, ERRZERO,
3728 "Could not give the Semaphore");
3734 /* If the implementation couldn't detach the task, we just
3735 * return an error, nothing else we can do.
3749 * Fun: Post a message to a task
3751 * Desc: This function is used to post a message to a TAPA
3752 * task. The message is delivered to the demand queue
3753 * of the system task that is running the specified
3757 * RFAILED - failed, general (optional)
3767 Pst *pst, /* post information */
3768 Buffer *mBuf /* message to post */
3771 PUBLIC S16 SPstTsk(pst, mBuf)
3772 Pst *pst; /* post information */
3773 Buffer *mBuf; /* message to post */
3778 #if (defined(SS_DRVR_SUPPORT))
3786 #if (defined(SS_DRVR_SUPPORT) || defined(SS_RTR_SUPPORT))
3789 #ifdef SS_DRVR_SUPPORT
3790 Bool nPstUsed = FALSE;
3792 #if (defined(SS_RTR_SUPPORT))
3795 /* ss029.103: addition: multiple procIds related changes */
3796 #ifdef SS_MULTIPLE_PROCS
3799 #endif /* SS_MULTIPLE_PROCS */
3800 /*ss004.301: Cavium changes */
3801 #ifdef SS_SEUM_CAVIUM
3804 cvmx_wqe_t *workPtr;
3805 #endif /* SS_SEUM_CAVIUM */
3810 #ifdef MSPD_MLOG_NEW
3811 U32 t = MacGetTick();
3817 #if (ERRCLASS & ERRCLS_INT_PAR)
3818 /* check the message buffer */
3821 SSLOGERROR(ERRCLS_INT_PAR, ESS502, ERRZERO, "Invalid message buffer");
3825 /* check the pst structure */
3829 SSLOGERROR(ERRCLS_INT_PAR, ESS503, ERRZERO, "Null pointer");
3832 /* ss021.103 - Addition to check for valid route */
3833 /* ss023.103 - Modification to fix bug in route validation */
3834 /* check the route */
3835 if (pst->route == RTENC)
3838 SSLOGERROR(ERRCLS_INT_PAR, ESS504, ERRZERO, "No route defined");
3843 #ifndef TENB_RTLIN_CHANGES
3844 /* lock the TAPA task table */
3845 SS_ACQUIRE_SEMA(&osCp.tTskTblSem, r);
3850 #if (ERRCLASS & ERRCLS_DEBUG)
3851 SSLOGERROR(ERRCLS_DEBUG, ESS505, ERRZERO,
3852 "Could not lock TAPA task table");
3859 #if (ERRCLASS & ERRCLS_INT_PAR)
3860 /* ss029.103: addition: multiple procIds related changes */
3861 #ifdef SS_MULTIPLE_PROCS
3862 if (pst->srcProcId == SS_INV_PROCID || pst->srcEnt >= SS_MAX_ENT ||
3863 pst->srcInst >= SS_MAX_INST || pst->dstProcId == SS_INV_PROCID ||
3864 pst->dstEnt >= SS_MAX_ENT || pst->dstInst >= SS_MAX_INST)
3865 #else /* SS_MULTIPLE_PROCS */
3866 if (pst->srcEnt >= SS_MAX_ENT || pst->srcInst >= SS_MAX_INST ||
3867 pst->dstEnt >= SS_MAX_ENT || pst->dstInst >= SS_MAX_INST)
3868 #endif /* SS_MULTIPLE_PROCS */
3870 #ifndef TENB_RTLIN_CHANGES
3871 /* ss006.13: addition */
3872 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3874 #if (ERRCLASS & ERRCLS_DEBUG)
3875 SSLOGERROR(ERRCLS_DEBUG, ESS506, ERRZERO,
3876 "Could not release the semaphore");
3884 SSLOGERROR(ERRCLS_INT_PAR, ESS507, ERRZERO,
3885 "Invalid source/destination entity/instance");
3891 /* ss019.103 - modified for use with message router in virtual/physical
3894 #ifdef SS_RTR_SUPPORT
3895 /* check if we have a router task registered for this route */
3896 if (pst->route < RTENC && osCp.rtrTskTbl[pst->route] != NULLP)
3898 /* copy the Pst structure into a local duplicate */
3899 for (i = 0; i < (S16)sizeof(Pst); i++)
3901 *(((U8 *)(&nPst)) + i) = *(((U8 *) pst) + i);
3904 #ifdef SS_DRVR_SUPPORT
3908 /* lock the router task entry */
3910 r = SLock(&osCp.rtrTskLocks[rte]);
3913 /* ss006.13: addition */
3914 #ifndef TENB_RTLIN_CHANGES
3915 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3917 #if (ERRCLASS & ERRCLS_DEBUG)
3918 SSLOGERROR(ERRCLS_DEBUG, ESS508, ERRZERO,
3919 "Could not release the semaphore");
3926 #if (ERRCLASS & ERRCLS_DEBUG)
3927 SSLOGERROR(ERRCLS_DEBUG, ESS509, ERRZERO,
3928 "Could not lock router task entry");
3934 /* call the router activation function */
3935 r = (*osCp.rtrTskTbl[rte])(pst, mBuf);
3937 /* unlock the router task entry */
3939 /* ss006.13: addition */
3940 if ( SUnlock(&osCp.rtrTskLocks[rte]) != ROK)
3942 #if (ERRCLASS & ERRCLS_DEBUG)
3943 SSLOGERROR(ERRCLS_DEBUG, ESS510, ERRZERO,
3944 "Could not give the Semaphore");
3949 if (r == RFAILED || r == ROKIGNORE)
3951 /* ss006.13: addition */
3952 #ifndef TENB_RTLIN_CHANGES
3953 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3955 #if (ERRCLASS & ERRCLS_DEBUG)
3956 SSLOGERROR(ERRCLS_DEBUG, ESS511, ERRZERO,
3957 "Could not release the semaphore");
3962 RETVALUE((r == RFAILED) ? RFAILED : ROK);
3965 #endif /* SS_RTR_SUPPORT */
3967 /* ss029.103: addition: multiple procIds related changes */
3968 #ifdef SS_MULTIPLE_PROCS
3970 /* get proc id index */
3971 srcProcIdIdx = SGetProcIdIdx(pst->srcProcId);
3972 dstProcIdIdx = SGetProcIdIdx(pst->dstProcId);
3974 if (srcProcIdIdx != SS_INV_PROCID_IDX)
3975 srcIdx = osCp.tTskIds[srcProcIdIdx][pst->srcEnt][pst->srcInst];
3977 if (dstProcIdIdx != SS_INV_PROCID_IDX)
3978 dstIdx = osCp.tTskIds[dstProcIdIdx][pst->dstEnt][pst->dstInst];
3980 if (((srcProcIdIdx != SS_INV_PROCID_IDX) && (srcIdx == SS_TSKNC)) ||
3981 ((dstProcIdIdx != SS_INV_PROCID_IDX) && (dstIdx == SS_TSKNC)))
3983 #ifndef TENB_RTLIN_CHANGES
3984 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3986 #if (ERRCLASS & ERRCLS_DEBUG)
3987 SSLOGERROR(ERRCLS_DEBUG, ESS512, ERRZERO,
3988 "Could not release the semaphore");
3996 #if (ERRCLASS & ERRCLS_DEBUG)
3997 SSLOGERROR(ERRCLS_DEBUG, ESS513, ERRZERO, "Unknown task");
4003 #else /* SS_MULTIPLE_PROCS */
4004 /* ss019.103 - modified for use with message router in virtual/physical
4007 /* get the src and destination task */
4008 srcIdx = osCp.tTskIds[pst->srcEnt][pst->srcInst];
4009 dstIdx = osCp.tTskIds[pst->dstEnt][pst->dstInst];
4012 /* If the source/destination processor ID is local, the
4013 * source/destination TAPA task must be local.
4015 if ((pst->srcProcId == osCp.procId && srcIdx == SS_TSKNC)
4016 || (pst->dstProcId == osCp.procId && dstIdx == SS_TSKNC))
4018 /* ss006.13: addition */
4019 #ifndef TENB_RTLIN_CHANGES
4020 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4022 #if (ERRCLASS & ERRCLS_DEBUG)
4023 SSLOGERROR(ERRCLS_DEBUG, ESS514, ERRZERO,
4024 "Could not release the semaphore");
4031 #if (ERRCLASS & ERRCLS_DEBUG)
4032 SSLOGERROR(ERRCLS_DEBUG, ESS515, ERRZERO, "Unknown task");
4038 #endif /* SS_MULTIPLE_PROCS */
4040 #ifdef SS_DRVR_SUPPORT
4041 /* Check for the destination procId. If it is non-local,
4042 * we need to find the driver task that will handle this
4045 /* ss029.103: addition: multiple procIds related changes */
4046 #ifdef SS_MULTIPLE_PROCS
4047 if (dstProcIdIdx == SS_INV_PROCID_IDX)
4048 #else /* SS_MULTIPLE_PROCS */
4049 if (pst->dstProcId != osCp.procId)
4050 #endif /* SS_MULTIPLE_PROCS */
4052 /* Need to optimize this search.
4054 for (i = 0; i < SS_MAX_DRVRTSKS; i++)
4056 if (osCp.drvrTskTbl[i].used
4057 && pst->dstProcId >= osCp.drvrTskTbl[i].low
4058 && pst->dstProcId <= osCp.drvrTskTbl[i].high)
4060 /* Copy the Pst structure into a local duplicate if not
4065 for (j = 0; j < (S16)sizeof(Pst); j++)
4067 *(((U8 *)(&nPst)) + j) = *(((U8 *) pst) + j);
4075 //if (clusterMode == NET_CLUSTER_MODE)
4078 /* lock the driver task entry */
4079 r = SLock(&osCp.drvrTskTbl[i].lock);
4082 /* ss006.13: addition */
4083 #ifndef TENB_RTLIN_CHANGES
4084 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4086 #if (ERRCLASS & ERRCLS_DEBUG)
4087 SSLOGERROR(ERRCLS_DEBUG, ESS516, ERRZERO,
4088 "Could not release the semaphore");
4095 #if (ERRCLASS & ERRCLS_DEBUG)
4096 SSLOGERROR(ERRCLS_DEBUG, ESS517, ERRZERO,
4097 "Could not lock driver task entry");
4105 /*ss014.301 SSI-4GMX specific change*/
4106 #ifndef SS_4GMX_LCORE
4107 CMCHKPKLOG(cmPkInst, osCp.drvrTskTbl[i].channel, mBuf, ESS518, pst);
4110 (osCp.drvrTskTbl[i].actvTsk)(pst, mBuf);
4114 //if (clusterMode == NET_CLUSTER_MODE)
4117 /* ss006.13: addition */
4118 if ( SUnlock(&osCp.drvrTskTbl[i].lock) != ROK)
4120 #if (ERRCLASS & ERRCLS_DEBUG)
4121 SSLOGERROR(ERRCLS_DEBUG, ESS519, ERRZERO,
4122 "Could not give the Semaphore");
4130 /* ss006.13: addition */
4131 #ifndef TENB_RTLIN_CHANGES
4132 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4134 #if (ERRCLASS & ERRCLS_DEBUG)
4135 SSLOGERROR(ERRCLS_DEBUG, ESS520, ERRZERO,
4136 "Could not release the semaphore");
4145 /* ss006.13: addition */
4146 #ifndef TENB_RTLIN_CHANGES
4147 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4149 #if (ERRCLASS & ERRCLS_DEBUG)
4150 SSLOGERROR(ERRCLS_DEBUG, ESS521, ERRZERO,
4151 "Could not release the semaphore");
4158 #if (ERRCLASS & ERRCLS_DEBUG)
4159 SSLOGERROR(ERRCLS_DEBUG, ESS522, ERRZERO,
4160 "Could not find a driver task to handle this proc ID");
4165 #endif /* SS_DRVR_SUPPORT */
4166 /* ss002.301 Modifications */
4167 /* Write the message to the demand queue of the system
4168 * task which is running the destination task
4170 tTsk = &osCp.tTskTbl[dstIdx];
4172 cmMemcpy((U8*)&tempPst, (U8*)pst, sizeof(Pst));
4173 if(tTsk->cbTsk != NULLP)
4175 retValue = tTsk->cbTsk(&tempPst,mBuf);
4178 #ifndef TENB_RTLIN_CHANGES
4179 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4181 #if (ERRCLASS & ERRCLS_DEBUG)
4182 SSLOGERROR(ERRCLS_DEBUG, ESS512, ERRZERO,
4183 "Could not release the semaphore");
4189 #if (ERRCLASS & ERRCLS_DEBUG)
4190 SSLOGERROR(ERRCLS_DEBUG, ESS513, ERRZERO, "call back function failed\n");
4194 #ifdef SS_MULTIPLE_PROCS
4195 dstIdx = osCp.tTskIds[dstProcIdIdx][tempPst.dstEnt][tempPst.dstInst];
4197 dstIdx = osCp.tTskIds[tempPst.dstEnt][tempPst.dstInst];
4199 tTsk = &osCp.tTskTbl[dstIdx];
4202 /* plug the Pst structure into the message information portion */
4203 msgInfo = (SsMsgInfo *) (mBuf->b_rptr);
4204 for (i = 0; i < (S16 )sizeof(Pst); i++)
4205 *(((U8 *)(&msgInfo->pst)) + i) = *(((U8 *) &(tempPst)) + i);
4207 /* ss004.301 : Cavium cahnges */
4208 #ifdef SS_SEUM_CAVIUM
4209 if (pst->dstProcId != osCp.procId)
4211 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4213 #if (ERRCLASS & ERRCLS_DEBUG)
4214 SSLOGERROR(ERRCLS_DEBUG, ESS527, ERRZERO,
4215 "Could not release the semaphore");
4220 /* Copy the message to the FPA region */
4221 ret = SCpyMsgFpa(mBuf, &wqBuf);
4224 /* No need to free the buffer, its already done in called fun */
4228 /* Allocate for the mBuf */
4229 /* ss010.301: Cavium 32 bit changes */
4230 workPtr = cvmx_fpa_alloc(SS_CVMX_WQE_POOL);
4231 if( workPtr == NULLP )
4237 /* Convert the pointers to physical address */
4238 ret = SConvPtrPhy(&wqBuf);
4245 /* Assign the values for work ptr */
4247 workPtr->grp = pst->dstProcId;
4248 workPtr->tag_type = CVMX_POW_TAG_TYPE_NULL;
4249 workPtr->tag = SS_CVMX_MBUF_TAG;
4251 workPtr->packet_ptr.ptr = (Void*)wqBuf;
4253 cvmx_pow_work_submit(workPtr, workPtr->tag, workPtr->tag_type, \
4254 workPtr->qos, workPtr->grp);
4258 #endif /* SS_SEUM_CAVIUM */
4261 /* Write the message to the demand queue of the system
4262 * task which is running the destination task
4264 tTsk = &osCp.tTskTbl[dstIdx];
4265 prior = tTsk->tskPrior;
4267 if (tTsk->sTsk == NULLP)
4269 /* ss006.13: addition */
4270 #ifndef TENB_RTLIN_CHANGES
4271 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4273 #if (ERRCLASS & ERRCLS_DEBUG)
4274 SSLOGERROR(ERRCLS_DEBUG, ESS523, ERRZERO,
4275 "Could not release the semaphore");
4282 #if (ERRCLASS & ERRCLS_DEBUG)
4283 SSLOGERROR(ERRCLS_DEBUG, ESS524, (ErrVal) 0,
4284 "Destination TAPA task is not attached");
4290 #ifdef SS_LOCKLESS_MEMORY
4291 msgInfo->region = tTsk->sTsk->region;
4292 msgInfo->pst.region = tTsk->sTsk->region;
4293 #endif /* SS_LOCKLESS_MEMORY */
4295 /*ss014.301 SSI-4GMX specific changes*/
4296 #ifndef SS_4GMX_LCORE
4297 r = ssDmndQPutLast(&tTsk->sTsk->dQ, mBuf,
4298 ((prior * SS_MAX_MSG_PRI) + tempPst.prior));
4299 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
4301 extern Bool g_usettitmr;
4304 if (tTsk->sTsk->tskPrior == PRIOR0)
4306 SsTTskEntry *srctTsk;
4307 srctTsk = &osCp.tTskTbl[srcIdx];
4308 if ((srctTsk->sTsk == tTsk->sTsk)
4309 #if defined(SPLIT_RLC_DL_TASK) && !defined(RLC_MAC_DAT_REQ_RBUF)
4311 ((pst->dstEnt == ENTRG) &&
4312 (pst->srcEnt == ENTKW) &&
4313 (pst->event == EVTRGUDDATREQ))
4316 #ifdef RGL_SPECIFIC_CHANGES
4317 WLS_WakeUp(mtGetWlsHdl());
4323 else if (tTsk->sTsk->tskPrior == PRIOR0)
4324 #ifdef RGL_SPECIFIC_CHANGES
4325 WLS_WakeUp(mtGetWlsHdl());
4332 if(tTsk->actvTsk != NULLP)
4334 if(tTsk->cbTsk != NULLP)
4336 r = rbICorePstTsk(&tempPst, mBuf, tTsk);
4340 r = rbICorePstTsk(pst, mBuf, tTsk);
4350 /* ss006.13: addition */
4351 #ifndef TENB_RTLIN_CHANGES
4352 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4354 #if (ERRCLASS & ERRCLS_DEBUG)
4355 SSLOGERROR(ERRCLS_DEBUG, ESS525, ERRZERO,
4356 "Could not release the semaphore");
4363 #if (ERRCLASS & ERRCLS_ADD_RES)
4364 SSLOGERROR(ERRCLS_ADD_RES, ESS526, (ErrVal) r,
4365 "Could not write to demand queue");
4372 /* unlock, we're done */
4373 /* ss006.13: addition */
4374 #ifndef TENB_RTLIN_CHANGES
4375 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4377 #if (ERRCLASS & ERRCLS_DEBUG)
4378 SSLOGERROR(ERRCLS_DEBUG, ESS527, ERRZERO,
4379 "Could not release the semaphore");
4386 /* If the implementation has anything to do... note that
4387 * we call it unlocked at this time.
4389 ssdPstTsk(tempPst, mBuf, tTsk);
4394 /* ss001.301: additions */
4395 #ifdef SS_HISTOGRAM_SUPPORT
4398 * fun : SGetTapaTskEntIds
4400 * Desc: Get the tapa task entity id, which are registerd for SSI.
4403 * RFAILED - failed, general (optional)
4404 * ROUTRES - failed, out of resources (optional)
4411 /* ss029.103: modification: procId added */
4414 PUBLIC S16 SGetTapaTskEntIds
4416 Ent *ent /* entity */
4419 PUBLIC S16 SGetTapaTskEntIds(ent)
4420 Ent *ent; /* entity */
4426 TRC1(SGetTapaTskEntIds);
4427 /* Get the tapa task entity Ids from the osCp structure */
4428 for(tskCnt = 0; tskCnt < osCp.numTTsks; tskCnt++)
4430 ent[tskCnt] = osCp.tTskTbl[tskCnt].ent;
4434 } /* SGetTapaTskEntIds */
4438 * Fun: SRegForHstGrm
4440 * Desc: This function is used to register a TAPA task,
4441 * for histogram facilty.
4444 * RFAILED - failed, general (optional)
4445 * ROUTRES - failed, out of resources (optional)
4452 /* ss029.103: modification: procId added */
4455 PUBLIC S16 SRegForHstGrm
4457 Ent ent /* entity */
4460 PUBLIC S16 SRegForHstGrm(ent)
4461 Ent ent; /* entity */
4468 TRC1(SRegForHstGrm);
4470 SS_ACQUIRE_SEMA(&osCp.tTskTblSem, r);
4473 #if (ERRCLASS & ERRCLS_DEBUG)
4474 SSLOGERROR(ERRCLS_DEBUG, ESS623, ERRZERO,
4475 "Could not lock TAPA task table");
4481 for(tskCnt = 0; tskCnt < osCp.numTTsks; tskCnt++)
4483 if(osCp.tTskTbl[tskCnt].ent == ent)
4485 osCp.tTskTbl[tskCnt].hstReg = TRUE;
4490 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4492 #if (ERRCLASS & ERRCLS_DEBUG)
4493 SSLOGERROR(ERRCLS_DEBUG, ESS639, ERRZERO,
4494 "Could not release the semaphore");
4500 } /* SGetTapaTskEntIds */
4504 * Fun: SGetHstGrmInfo
4506 * Desc : Get the Histogram registration for TAPA task
4509 * RFAILED - failed, general (optional)
4510 * ROUTRES - failed, out of resources (optional)
4518 PUBLIC S16 SGetHstGrmInfo
4521 Bool *hstReg /* entity */
4524 PUBLIC S16 SGetHstGrmInfo(entId, hstReg)
4526 Bool *hstReg; /* entity */
4534 TRC1(SGetHstGrmInfo);
4535 for(tskCnt = 0; tskCnt < osCp.numTTsks; tskCnt++)
4537 if( *entId == osCp.tTskTbl[tskCnt].ent)
4539 *hstReg = osCp.tTskTbl[tskCnt].hstReg;
4552 } /* SGetTapaTskEntIds */
4554 #endif /* SS_HISTOGRAM_SUPPORT */
4558 PUBLIC S16 SInitWatchdog
4563 PUBLIC S16 SInitWatchdog(port)
4567 return ssdInitWatchDog(port);
4571 PUBLIC S16 SRegCfgWd
4577 WdUserCallback callback,
4581 PUBLIC S16 SRegCfgWd(numNodes, addr, port, timeout, callback, data)
4586 WdUserCallback callback;
4590 Txt prntBuf[PRNTSZE];
4593 /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
4596 osCp.wdCp.globWd.timeout = timeout;
4597 osCp.wdCp.globWd.callback = callback;
4598 osCp.wdCp.globWd.data = data;
4599 osCp.wdCp.globWd.numNodes = numNodes;
4601 SLock(&osCp.wdCp.wdLock);
4602 for(i = 0; i < SS_MAX_WD_NODES && i < numNodes; i++)
4604 #ifdef SS_WATCHDOG_IPV6
4605 /* ss002.301 Modifications */
4606 inet_pton(AF_INET6,(const char *)addr[i],osCp.wdCp.globWd.wdsta[i].addr);
4608 osCp.wdCp.globWd.wdsta[i].addr.s_addr = inet_addr((const char *)addr[i]);
4609 #endif /* SS_WATCHDOG_IPV6 */
4610 osCp.wdCp.globWd.wdsta[i].port = htons(port[i]);
4611 sprintf(prntBuf, "Configured [%s:%d] for watchdog\n", addr[i], port[i]);
4614 SUnlock(&osCp.wdCp.wdLock);
4615 /* ss002.301 Compilation fixes */
4616 /*ss013.301: Fixed Warnings for 32/64 bit compilation*/
4618 sprintf(prntBuf, "Configured %d nodes with timeout %u for Watchdog\n", osCp.wdCp.globWd.numNodes, osCp.wdCp.globWd.timeout);
4620 sprintf(prntBuf, "Configured %d nodes with timeout %lu for Watchdog\n", osCp.wdCp.globWd.numNodes, osCp.wdCp.globWd.timeout);
4628 PUBLIC S16 SDeregCfgWd
4633 PUBLIC S16 SDeregCfgWd(void)
4637 Txt prntBuf[PRNTSZE];
4640 /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
4643 osCp.wdCp.globWd.timeout = 0;
4644 osCp.wdCp.globWd.callback = 0;
4645 osCp.wdCp.globWd.data = 0;
4646 osCp.wdCp.globWd.numNodes = 0;
4648 SLock(&osCp.wdCp.wdLock);
4649 for(i = 0; i < SS_MAX_WD_NODES; i++)
4651 /* ss002.301 Modifications */
4652 sprintf(prntBuf, "Deregister [%s:%d] for watchdog\n", inet_ntoa(osCp.wdCp.globWd.wdsta[i
4653 ].addr), osCp.wdCp.globWd.wdsta[i].port);
4654 osCp.wdCp.globWd.wdsta[i].addr.s_addr = 0;
4655 osCp.wdCp.globWd.wdsta[i].port = 0;
4658 SUnlock(&osCp.wdCp.wdLock);
4660 /* Implicit watchdog stop during dereg */
4667 PUBLIC S16 SStartHrtBt
4669 U8 timeInterval /* time interval */
4672 PUBLIC S16 SStartHrtBt(timeInterval)
4678 ssdStartWatchDgTmr(NULLP, SS_TMR_HRTBT, timeInterval);
4679 ssdSndHrtBtMsg(TRUE, SS_WD_HB_REQ);
4685 PUBLIC S16 SStopHrtBt
4690 PUBLIC S16 SStopHrtBt()
4696 osCp.wdCp.globWd.watchdogStop = 1;
4702 PUBLIC S16 watchDgActvTsk
4704 Pst *pst, /* post */
4705 Buffer *mBuf /* message buffer */
4708 PUBLIC S16 watchDgActvTsk(pst, mBuf)
4709 Pst *pst; /* post */
4710 Buffer *mBuf; /* message buffer */
4713 /* ss002.301 Fixed warnings */
4716 Txt prntBuf[PRNTSZE];
4719 TRC3(watchDgActvTsk)
4722 sprintf(prntBuf,"watchDgActvTsk: Time: %02d:%02d:%02d\n",dt.hour,dt.min, dt.sec
4730 PUBLIC S16 watchDgRcvrActvTsk
4732 Pst *pst, /* post */
4733 Buffer *mBuf /* message buffer */
4736 PUBLIC S16 watchDgRcvrActvTsk(pst, mBuf)
4737 Pst *pst; /* post */
4738 Buffer *mBuf; /* message buffer */
4744 Txt prntBuf[PRNTSZE];
4747 struct sockaddr_in tmpaddr;
4748 Txt hbMsg[SS_WD_HB_MSG_SIZE];
4749 /* ss002.301 Modifications */
4751 socklen_t socklen = sizeof(struct sockaddr);
4753 int socklen = sizeof(struct sockaddr);
4756 TRC3(watchDgActvTsk)
4760 sprintf(prntBuf,"watchDgRcvrActvTsk: Time: %02d:%02d:%02d\n",dt.hour, dt.min, dt.sec);
4764 while(!osCp.wdCp.globWd.watchdogStop)
4766 err = recvfrom(osCp.wdCp.globWd.sock, hbMsg, SS_WD_HB_MSG_SIZE, 0, (struct sockaddr *)&tmpaddr, &socklen);
4769 sprintf(prntBuf,"watchDgRcvrActvTsk: recvfrom failed, errno %d\n", errno);
4774 if(strcmp(hbMsg, "<HB>REQ</HB>") == 0)
4776 /* Send back the reply */
4778 sprintf(prntBuf,"watchDgRcvrActvTsk: Recvd HB REQ message from [%s:%d]\n", inet_ntoa(tmpaddr.sin_addr), ntohs(tmpaddr.sin_port));
4782 strcpy(hbMsg, "<HB>RSP</HB>");
4783 sendto(osCp.wdCp.globWd.sock, hbMsg, strlen(hbMsg), 0, (struct sockaddr *)&tmpaddr, sizeof(tmpaddr));
4785 else if(strcmp(hbMsg, "<HB>RSP</HB>") == 0)
4787 /* Got a HB RSP, set the status for the correcponding node */
4789 sprintf(prntBuf,"watchDgRcvrActvTsk: Recvd HB RSP message from [%s:%d]\n", inet_ntoa(tmpaddr.sin_addr), ntohs(tmpaddr.sin_port));
4793 SLock(&osCp.wdCp.wdLock);
4794 for(n = 0; n < osCp.wdCp.globWd.numNodes; n++)
4796 if(osCp.wdCp.globWd.wdsta[n].addr.s_addr == tmpaddr.sin_addr.s_addr)
4798 osCp.wdCp.globWd.wdsta[n].status = 1;
4801 SUnlock(&osCp.wdCp.wdLock);
4806 sprintf(prntBuf,"watchDgRcvrActvTsk: Rcvd invalid message\n");
4814 #endif /* SS_WATCHDOG */
4816 /* ss002.301 Modifications */
4817 #ifdef SS_THREAD_PROFILE
4822 * Desc: This function gets the current profile of a system task
4823 * The function sets the Entity, Instance, Event and time taken
4824 * for that thread to execurte the activate function of
4828 * RFAILED - failed, general (optional)
4830 * Notes: This function may be called by the OS or Layer 1
4836 #ifdef SS_MULTIPLE_PROCS
4838 PUBLIC S16 SGetThrdProf
4842 Ent ent, /* entity */
4849 PUBLIC S16 SGetThrdProf(sTskId, procId, ent, inst, evnt, curEvent, curEvtTime, totTime)
4852 Ent ent; /* entity */
4860 PUBLIC S16 SGetThrdProf
4863 Ent ent, /* entity */
4870 PUBLIC S16 SGetThrdProf(sTskId, ent, inst, curEvent,curEvtTime, totTime)
4872 Ent ent; /* entity */
4878 #endif /* SS_MULTIPLE_PROCS */
4883 #ifdef SS_MULTIPLE_PROCS
4890 #if (ERRCLASS & ERRCLS_INT_PAR)
4891 /* check entity and instance range */
4892 #ifdef SS_MULTIPLE_PROCS
4893 /* check proc, entity and instance range */
4894 if ((procId == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST))
4896 SSLOGERROR(ERRCLS_INT_PAR, ESS463, ERRZERO, "Invalid processor/entity/instance");
4899 #else /* SS_MULTIPLE_PROCS */
4900 /* check entity and instance range */
4901 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
4903 SSLOGERROR(ERRCLS_INT_PAR, ESS464, ERRZERO, "Invalid entity/instance");
4906 #endif /* SS_MULTIPLE_PROCS */
4910 ret = SLock(&osCp.sTskTblLock);
4917 #ifdef SS_MULTIPLE_PROCS
4918 procIdIdx = SGetProcIdIdx(procId);
4920 if (procIdIdx == SS_INV_PROCID_IDX)
4925 idx = osCp.tTskIds[procIdIdx][ent][inst];
4926 #else /* SS_MULTIPLE_PROCS */
4927 idx = osCp.tTskIds[ent][inst];
4928 #endif /* SS_MULTIPLE_PROCS */
4930 tTsk = &osCp.tTskTbl[idx];
4933 SUnlock(&osCp.sTskTblLock);
4936 *curEvent = osCp.tTskTbl[idx].curEvent;
4937 *curEvtTime = osCp.tTskTbl[idx].curEvtTime;
4938 *totTime = osCp.tTskTbl[idx].totTime;
4939 *sTskId = osCp.tTskTbl[idx].sTsk->tskId;
4941 SUnlock(&osCp.sTskTblLock);
4944 #endif /* SS_THREAD_PROFILE */
4946 #ifdef SS_FBSED_TSK_REG
4951 * Desc: This function is used to register tasks based on cfg file.
4954 * RFAILED - failed, general (optional)
4961 PUBLIC S16 SRegTskInfo
4966 PUBLIC S16 SRegTskInfo(cfgFile)
4970 return cmCfgrTskReg(cfgFile);
4972 #endif /* SS_FBSED_TSK_REG */
4974 /**********************************************************************
4976 **********************************************************************/