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 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 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 */
188 #if (ERRCLASS & ERRCLS_INT_PAR)
189 /* check entity and instance ranges */
190 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
192 SSLOGERROR(ERRCLS_INT_PAR, ESS350, ERRZERO, "Invalid entity/instance");
196 /* check initialization function */
197 if (initFnct == NULLP)
199 SSLOGERROR(ERRCLS_INT_PAR, ESS351, ERRZERO, "Null pointer");
204 /* ss021.103 - Modification to store initialization function */
205 /* Acquire the counting semaphore for all other system
206 * tasks (this call is either running in one system task's
207 * context, or in SInit()'s context). Once we have all of
208 * them, SPstTsk() cannot run, so we can do things to the
212 /* ss025.103 - Addition of lock around counting semaphore */
213 /* lock system task table */
214 ret = SLock(&osCp.sTskTblLock);
217 SSLOGERROR(ERRCLS_DEBUG, ESS352, ERRZERO,
218 "Could not lock system task table");
222 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
226 #if (ERRCLASS & ERRCLS_DEBUG)
227 SSLOGERROR(ERRCLS_DEBUG, ESS353, ERRZERO,
228 "Could not lock TAPA task table");
235 #if (ERRCLASS & ERRCLS_INT_PAR)
236 /* check count of tasks */
237 if (osCp.numTTsks == SS_MAX_TTSKS)
239 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
240 SSLOGERROR(ERRCLS_INT_PAR, ESS354, ERRZERO, "Too many tasks");
242 /* ss025.103 - Addition of unlock around counting semephore */
243 if ( SUnlock(&osCp.sTskTblLock) != ROK)
245 #if (ERRCLASS & ERRCLS_DEBUG)
246 SSLOGERROR(ERRCLS_DEBUG, ESS355, ERRZERO,
247 "Could not give the Semaphore");
255 /* check if entity and instance already registered */
256 if (osCp.tTskIds[ent][inst] != SS_TSKNC)
258 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
259 SSLOGERROR(ERRCLS_INT_PAR, ESS356, ERRZERO,
260 "Entity and instance already registered");
262 /* ss025.103 - Addition of unlock around counting semaphore */
263 if ( SUnlock(&osCp.sTskTblLock) != ROK)
265 #if (ERRCLASS & ERRCLS_DEBUG)
266 SSLOGERROR(ERRCLS_DEBUG, ESS357, ERRZERO,
267 "Could not give the Semaphore");
276 tTsk = &osCp.tTskTbl[osCp.nxtTTskEntry];
281 tTsk->tskType = (Ttype)NULLD;
282 tTsk->tskPrior = (Prior)NULLD;
283 tTsk->initTsk = initFnct;
284 tTsk->actvTsk = (ActvTsk)NULLP;
287 osCp.tTskIds[ent][inst] = osCp.nxtTTskEntry;
288 osCp.nxtTTskEntry = tTsk->nxt;
291 /* Activate initialization function, if present. Like
292 * SRegInit(), we use hard-coded parameters. Note: we
293 * assume that the initialization function is not
294 * going to call SRegTTsk() or SPstTsk(). If it does,
295 * this thread will freeze up as we are holding the
296 * TAPA task table counting semaphore.
298 /* ss024.103 - Modification for memory calculator tool */
300 (Void)(*initFnct)(ent, inst, DFLT_REGION, PWR_UP);
302 (Void)(*initFnct)(ent, inst, SS_STATIC_REGION, PWR_UP);
303 #endif /* USE_MEMCAL */
305 /* unlock the table */
306 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
308 /* ss025.103 - Addition of unlock around counting semaphore */
309 if ( SUnlock(&osCp.sTskTblLock) != ROK)
311 #if (ERRCLASS & ERRCLS_DEBUG)
312 SSLOGERROR(ERRCLS_DEBUG, ESS358, ERRZERO,
313 "Could not give the Semaphore");
327 * Desc: This function is used to register an activation function
328 * for the layer. The system services will invoke the
329 * function passed to it whenever a task buffer is received.
330 * The activation function will be used by the layer to receive
331 * messages from other entities. It allows a priority to be
332 * associated with the task so that it can be preempted if
336 * RFAILED - failed, general (optional)
337 * ROUTRES - failed, out of resources (optional)
339 * Notes: We pass NULLP for the initialization function, because
340 * it is assumed that whoever is using this call will also
341 * be calling SRegInit().
349 Ent ent, /* entity */
350 Inst inst, /* instance */
351 Ttype ttype, /* task type */
352 Prior prior, /* task priority */
353 ActvTsk actvTsk /* activate task function */
356 S16 SRegActvTsk(ent, inst, ttype, prior, actvTsk)
357 Ent ent; /* entity */
358 Inst inst; /* instance */
359 Ttype ttype; /* task type */
360 Prior prior; /* task priority */
361 ActvTsk actvTsk; /* activate task function */
367 /* ss021.103 - Addition for pointer */
372 #if (ERRCLASS & ERRCLS_INT_PAR)
373 /* check entity and instance ranges */
374 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
376 SSLOGERROR(ERRCLS_INT_PAR, ESS359, ERRZERO, "Invalid entity/instance");
380 /* check activation function */
381 if (actvTsk == NULLP)
383 SSLOGERROR(ERRCLS_INT_PAR, ESS360, ERRZERO, "Null pointer");
387 /* check task type */
388 if (ttype != TTNORM && ttype != TTPERM)
390 SSLOGERROR(ERRCLS_INT_PAR, ESS361, ERRZERO, "Invalid task type");
391 /* ss021.103 - Addition of return fail for invalid task type */
395 /* check task priority */
398 SSLOGERROR(ERRCLS_INT_PAR, ESS362, ERRZERO, "Invalid task priority");
403 /* lock system task table */
404 ret = SLock(&osCp.sTskTblLock);
407 SSLOGERROR(ERRCLS_DEBUG, ESS363, ERRZERO,
408 "Could not lock system task table");
412 /* lock TAPA task table */
413 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
416 if ( SUnlock(&osCp.sTskTblLock) != ROK)
418 #if (ERRCLASS & ERRCLS_DEBUG)
419 SSLOGERROR(ERRCLS_DEBUG, ESS364, ERRZERO,
420 "Could not give the Semaphore");
425 SSLOGERROR(ERRCLS_DEBUG, ESS365, ERRZERO,
426 "Could not lock TAPA task table");
429 /* ss021.103 - Modification for SRegInit not called yet */
430 /* check if entity and instance already registered */
431 if (osCp.tTskIds[ent][inst] == SS_TSKNC)
434 #if (ERRCLASS & ERRCLS_INT_PAR)
435 /* check count of tasks */
436 if (osCp.numTTsks == SS_MAX_TTSKS)
438 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
440 /* ss025.103 - Addition of unlock around counting semaphore */
441 if ( SUnlock(&osCp.sTskTblLock) != ROK)
443 #if (ERRCLASS & ERRCLS_DEBUG)
444 SSLOGERROR(ERRCLS_DEBUG, ESS366, ERRZERO,
445 "Could not give the Semaphore");
449 SSLOGERROR(ERRCLS_INT_PAR, ESS367, ERRZERO, "Too many tasks");
454 tTsk = &osCp.tTskTbl[osCp.nxtTTskEntry];
458 tTsk->initTsk = (PAIFS16)NULLP;
459 tTsk->actvTsk = (ActvTsk)NULLP;
462 osCp.tTskIds[ent][inst] = osCp.nxtTTskEntry;
463 osCp.nxtTTskEntry = tTsk->nxt;
468 /* check and bump the priority if it is a permanent task */
474 /* ss021.103 - Modification to register task information */
475 /* We fill up the current available slot with all the
476 * information we've been given. Update table information,
477 * and the task is registered.
480 tTsk = &osCp.tTskTbl[osCp.tTskIds[ent][inst]];
482 #if (ERRCLASS & ERRCLS_INT_PAR)
483 if (tTsk->actvTsk != (ActvTsk)NULLP)
485 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
487 if ( SUnlock(&osCp.sTskTblLock) != ROK)
489 #if (ERRCLASS & ERRCLS_DEBUG)
490 SSLOGERROR(ERRCLS_DEBUG, ESS368, ERRZERO,
491 "Could not give the Semaphore");
496 SSLOGERROR(ERRCLS_INT_PAR, ESS369, ERRZERO,
497 "ActvTask already registered");
502 tTsk->tskType = ttype;
503 tTsk->tskPrior = prior;
504 tTsk->actvTsk = actvTsk;
506 /* unlock the table */
507 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
509 if ( SUnlock(&osCp.sTskTblLock) != ROK)
511 #if (ERRCLASS & ERRCLS_DEBUG)
512 SSLOGERROR(ERRCLS_DEBUG, ESS370, ERRZERO,
513 "Could not give the Semaphore");
518 /* Now we create a system task--one per TAPA task is the
519 * semantics of SRegActvTsk().
522 spri = SS_NORM_TSK_PRI;
524 spri = SS_PERM_TSK_PRI;
526 ret = SCreateSTsk(spri, &sTskId);
530 #if (ERRCLASS & ERRCLS_DEBUG)
531 SSLOGERROR(ERRCLS_DEBUG, ESS371, (ErrVal) ret,
532 "Could not create system task");
535 SDeregTTsk(ent, inst);
540 /* Attach the TAPA task we just registered, to the system
541 * task we just created.
543 ret = SAttachTTsk(ent, inst, sTskId);
547 #if (ERRCLASS & ERRCLS_DEBUG)
548 SSLOGERROR(ERRCLS_DEBUG, ESS372, (ErrVal) ret,
549 "Could not attach TAPA task to system task");
551 SDestroySTsk(sTskId);
552 SDeregTTsk(ent, inst);
563 * Fun: Deregister Initialize, task buffer and timer
565 * Desc: This function is used to deregister the initialization,
566 * activation and timer functions for a task.
578 Ent ent, /* entity */
579 Inst inst /* instance */
582 S16 SDeregInitTskTmr(ent, inst)
583 Ent ent; /* entity */
584 Inst inst; /* instance */
597 #if (ERRCLASS & ERRCLS_INT_PAR)
598 /* check entity and instance ranges */
599 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
601 SSLOGERROR(ERRCLS_INT_PAR, ESS373, ERRZERO, "Invalid entity/instance");
606 /* ss025.103 - Addition of lock around counting semaphore */
607 /* lock system task table */
608 ret = SLock(&osCp.sTskTblLock);
611 SSLOGERROR(ERRCLS_DEBUG, ESS374, ERRZERO,
612 "Could not lock system task table");
616 /* lock the TAPA task table */
617 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
621 #if (ERRCLASS & ERRCLS_DEBUG)
622 SSLOGERROR(ERRCLS_DEBUG, ESS375, ERRZERO,
623 "Could not lock TAPA task table");
630 #if (ERRCLASS & ERRCLS_INT_PAR)
631 /* check whether this entity is registered */
632 if (osCp.tTskIds[ent][inst] == SS_TSKNC)
634 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
635 SSLOGERROR(ERRCLS_INT_PAR, ESS376, ERRZERO, "Unknown task");
637 /* ss025.103 - Addition of unlock around counting semaphore */
638 if ( SUnlock(&osCp.sTskTblLock) != ROK)
640 #if (ERRCLASS & ERRCLS_DEBUG)
641 SSLOGERROR(ERRCLS_DEBUG, ESS377, ERRZERO,
642 "Could not give the Semaphore");
652 /* get out the TAPA task entry */
653 tTsk = &osCp.tTskTbl[osCp.tTskIds[ent][inst]];
655 /* get out the system task that's running this TAPA task */
658 /* get out the ID of this system task */
661 sTskId = sTsk->tskId;
666 /* unlock the TAPA task table */
667 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
669 /* ss025.103 - Addition of unlock around counting semaphore */
670 if ( SUnlock(&osCp.sTskTblLock) != ROK)
672 #if (ERRCLASS & ERRCLS_DEBUG)
673 SSLOGERROR(ERRCLS_DEBUG, ESS378, ERRZERO,
674 "Could not give the Semaphore");
680 /* deregister the TAPA task */
681 if (SDeregTTsk(ent, inst) != ROK)
687 /* Now, if the TAPA task was attached, and nobody else is using that
688 * system task, we should destroy it.
694 /* lock the system task table */
695 ret = SLock(&osCp.sTskTblLock);
699 #if (ERRCLASS & ERRCLS_DEBUG)
700 SSLOGERROR(ERRCLS_DEBUG, ESS379, (ErrVal) ret,
701 "Could not lock system task table");
707 idx = (SsIdx) sTskId;
708 sTsk = &osCp.sTskTbl[idx];
710 /* check if the system task is still around */
711 if (sTsk->used != TRUE)
714 /* ss006.13: addition */
715 if ( SUnlock(&osCp.sTskTblLock) != ROK)
717 #if (ERRCLASS & ERRCLS_DEBUG)
718 SSLOGERROR(ERRCLS_DEBUG, ESS380, ERRZERO,
719 "Could not give the Semaphore");
727 /* check if the system task is dying already */
731 /* ss006.13: addition */
732 if ( SUnlock(&osCp.sTskTblLock) != ROK)
734 #if (ERRCLASS & ERRCLS_DEBUG)
735 SSLOGERROR(ERRCLS_DEBUG, ESS381, ERRZERO,
736 "Could not give the Semaphore");
744 /* If this system task entry has no more TAPA tasks attached,
745 * we destroy it, otherwise we do nothing.
747 if (sTsk->numTTsks == 0)
749 sTsk->termPend = TRUE;
756 /* ss006.13: addition */
757 if ( SUnlock(&osCp.sTskTblLock) != ROK)
759 #if (ERRCLASS & ERRCLS_DEBUG)
760 SSLOGERROR(ERRCLS_DEBUG, ESS382, ERRZERO,
761 "Could not give the Semaphore");
766 /* If we're destroying the system task, ask the implementation
771 ret = ssdDestroySTsk(sTsk);
776 #if (ERRCLASS & ERRCLS_DEBUG)
777 SSLOGERROR(ERRCLS_DEBUG, ESS383, (ErrVal) ret,
778 "Could not destroy system task");
788 } /* SDeregInitTskTmr */
790 #endif /* SS_MULTIPLE_PROCS */
795 * Fun: Register a TAPA task
797 * Desc: This function is used to register a TAPA task,
798 * and its initialization and activation functions.
801 * RFAILED - failed, general (optional)
802 * ROUTRES - failed, out of resources (optional)
809 /* ss029.103: modification: procId added */
810 #ifndef SS_MULTIPLE_PROCS
815 Ent ent, /* entity */
816 Inst inst, /* instance */
817 Ttype type, /* task type */
818 Prior prior, /* task priority */
819 PAIFS16 initTsk, /* initialization function */
820 ActvTsk actvTsk /* activation function */
823 S16 SRegTTsk(ent, inst, type, prior, initTsk, actvTsk)
824 Ent ent; /* entity */
825 Inst inst; /* instance */
826 Ttype type; /* task type */
827 Prior prior; /* task priority */
828 PAIFS16 initTsk; /* initialization function */
829 ActvTsk actvTsk; /* activation function */
832 #else /* SS_MULTIPLE_PROCS */
837 ProcId proc, /* processor */
838 Ent ent, /* entity */
839 Inst inst, /* instance */
840 Ttype type, /* task type */
841 Prior prior, /* task priority */
842 PAIFS16 initTsk, /* initialization function */
843 ActvTsk actvTsk /* activation function */
846 S16 SRegTTsk(proc, ent, inst, type, prior, initTsk, actvTsk)
847 ProcId proc; /* processor */
848 Ent ent; /* entity */
849 Inst inst; /* instance */
850 Ttype type; /* task type */
851 Prior prior; /* task priority */
852 PAIFS16 initTsk; /* initialization function */
853 ActvTsk actvTsk; /* activation function */
856 #endif /* SS_MULTIPLE_PROCS */
861 /* ss029.103: addition: multiple procIds related changes */
862 #ifdef SS_MULTIPLE_PROCS
868 #if (ERRCLASS & ERRCLS_INT_PAR)
870 /* check entity and instance ranges */
871 /* ss029.103: addition: multiple procIds related changes */
872 #ifdef SS_MULTIPLE_PROCS
873 if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST))
875 SSLOGERROR(ERRCLS_INT_PAR, ESS384, ERRZERO, "Invalid proc/entity/instance");
878 #else /* SS_MULTIPLE_PROCS */
879 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
881 SSLOGERROR(ERRCLS_INT_PAR, ESS385, ERRZERO, "Invalid entity/instance");
884 #endif /* SS_MULTIPLE_PROCS */
886 /* check activation function */
887 if (actvTsk == NULLP)
889 SSLOGERROR(ERRCLS_INT_PAR, ESS386, ERRZERO, "Null pointer");
893 /* check task type */
894 if (type != TTNORM && type != TTPERM)
896 SSLOGERROR(ERRCLS_INT_PAR, ESS387, ERRZERO, "Invalid task type");
897 /* ss021.103 - Addition of return fail for invalid task type */
901 /* check task priority */
904 SSLOGERROR(ERRCLS_INT_PAR, ESS388, ERRZERO, "Invalid task priority");
909 /* ss029.103: addition: multiple procIds related changes */
910 #ifdef SS_MULTIPLE_PROCS
911 /* retrieve proc id index in the proc id table */
912 procIdIdx = SGetProcIdIdx(proc);
914 /* Check whether the proc id exist in the proc id table */
915 if (procIdIdx == SS_INV_PROCID_IDX)
917 #if (ERRCLASS & ERRCLS_INT_PAR)
918 SSLOGERROR(ERRCLS_INT_PAR, ESS389, ERRZERO,
919 "Could not find proc table index");
924 #endif /* SS_MULTIPLE_PROCS */
928 /* Acquire the counting semaphore for all other system
929 * tasks (this call is either running in one system task's
930 * context, or in SInit()'s context). Once we have all of
931 * them, SPstTsk() cannot run, so we can do things to the
935 /* ss025.103 - Addition of lock around counting semaphore */
936 /* lock system task table */
937 ret = SLock(&osCp.sTskTblLock);
940 SSLOGERROR(ERRCLS_DEBUG, ESS390, ERRZERO,
941 "Could not lock system task table");
945 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
949 #if (ERRCLASS & ERRCLS_DEBUG)
950 SSLOGERROR(ERRCLS_DEBUG, ESS391, ERRZERO,
951 "Could not lock TAPA task table");
954 /* ss025.103 - Addition of unlock around counting semaphore */
955 if ( SUnlock(&osCp.sTskTblLock) != ROK)
957 #if (ERRCLASS & ERRCLS_DEBUG)
958 SSLOGERROR(ERRCLS_DEBUG, ESS392, ERRZERO,
959 "Could not give the Semaphore");
968 #if (ERRCLASS & ERRCLS_DEBUG)
969 /* check count of tasks */
970 if (osCp.numTTsks == SS_MAX_TTSKS)
972 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
973 SSLOGERROR(ERRCLS_DEBUG, ESS393, ERRZERO, "Too many tasks");
975 /* ss025.103 - Addition of unlock around counting semaphore */
976 if ( SUnlock(&osCp.sTskTblLock) != ROK)
978 #if (ERRCLASS & ERRCLS_DEBUG)
979 SSLOGERROR(ERRCLS_DEBUG, ESS394, ERRZERO,
980 "Could not give the Semaphore");
988 /* check if entity and instance already registered */
989 /* ss029.103: addition: multiple procIds related changes */
990 #ifdef SS_MULTIPLE_PROCS
991 if (osCp.tTskIds[procIdIdx][ent][inst] != SS_TSKNC)
993 if (osCp.tTskIds[ent][inst] != SS_TSKNC)
994 #endif /* SS_MULTIPLE_PROCS */
996 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
997 SSLOGERROR(ERRCLS_DEBUG, ESS395, ERRZERO,
998 "Entity and instance already registered");
1000 /* ss025.103 - Addition of unlock around counting semaphore */
1001 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1003 #if (ERRCLASS & ERRCLS_DEBUG)
1004 SSLOGERROR(ERRCLS_DEBUG, ESS396, ERRZERO,
1005 "Could not give the Semaphore");
1015 /* We fill up the current available slot with all the
1016 * information we've been given. Update table information,
1017 * and the task is registered.
1019 tTsk = &osCp.tTskTbl[osCp.nxtTTskEntry];
1021 /* ss029.103: addition: procId added */
1022 #ifdef SS_MULTIPLE_PROCS
1024 #endif /* SS_MULTIPLE_PROCS */
1027 tTsk->tskType = type;
1028 tTsk->tskPrior = prior;
1029 tTsk->initTsk = initTsk;
1030 tTsk->actvTsk = actvTsk;
1033 /* ss001.301: additions */
1034 #ifdef SS_HISTOGRAM_SUPPORT
1036 #endif /* SS_HISTOGRAM_SUPPORT */
1038 /* ss029.103: addition: multiple procIds related changes */
1039 #ifdef SS_MULTIPLE_PROCS
1040 osCp.tTskIds[procIdIdx][ent][inst] = osCp.nxtTTskEntry;
1042 osCp.tTskIds[ent][inst] = osCp.nxtTTskEntry;
1043 #endif /* SS_MULTIPLE_PROCS */
1044 osCp.nxtTTskEntry = tTsk->nxt;
1048 /* Activate initialization function, if present. Like
1049 * SRegInit(), we use hard-coded parameters. Note: we
1050 * assume that the initialization function is not
1051 * going to call SRegTTsk() or SPstTsk(). If it does,
1052 * this thread will freeze up as we are holding the
1053 * TAPA task table counting semaphore.
1055 /* ss024.103 - Modification for memory calculator tool */
1056 if (initTsk != NULLP)
1058 /* ss029.103: addition: multiple procIds related changes */
1059 #ifdef SS_MULTIPLE_PROCS
1062 #endif /* SS_MULTIPLE_PROCS */
1064 /* ss029.103: addition: multiple procIds related changes */
1065 #ifndef SS_MULTIPLE_PROCS
1068 #ifndef SS_MULTICORE_SUPPORT
1069 (Void)(*initTsk)(ent, inst, DFLT_REGION, PWR_UP);
1072 (Void)(*initTsk)(ent, inst, SS_STATIC_REGION, PWR_UP);
1073 #endif /* USE_MEMCAL */
1075 #else /* SS_MULTIPLE_PROCS */
1078 #ifndef SS_MULTICORE_SUPPORT
1079 (Void)(*initTsk)(proc, ent, inst, DFLT_REGION, PWR_UP, &xxCb);
1080 #endif /* SS_MULTICORE_SUPPORT */
1082 (Void)(*initTsk)(proc, ent, inst, SS_STATIC_REGION, PWR_UP, &xxCb);
1083 #endif /* USE_MEMCAL */
1086 * store the control block. The control block may be NULL in some cases
1088 idx = osCp.tTskIds[procIdIdx][ent][inst];
1090 osCp.tTskTbl[idx].xxCb = xxCb;
1092 /* ss032.103 do a debug print if xxCb is NULLP */
1095 SSLOGERROR(ERRCLS_INT_PAR, ERRZERO, ERRZERO, "Null pointer");
1097 #endif /* SS_MULTIPLE_PROCS */
1100 /* unlock the table */
1101 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1103 /* ss025.103 - Addition of unlock around counting semaphore */
1104 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1106 #if (ERRCLASS & ERRCLS_DEBUG)
1107 SSLOGERROR(ERRCLS_DEBUG, ESS397, ERRZERO,
1108 "Could not give the Semaphore");
1115 /* ss002.301 Additions */
1118 * Fun: Register a call back function with SSI
1120 * Desc: This function is used to register a callback function
1124 * RFAILED - failed, general (optional)
1131 #ifndef SS_MULTIPLE_PROCS
1135 Ent ent, /* entity */
1136 Inst inst, /* instance */
1137 ActvTsk cbTsk /* Callback Function */
1140 S16 SRegCbTsk(ent, inst, cbTsk)
1141 Ent ent; /* entity */
1142 Inst inst; /* instance */
1146 #else /* SS_MULTIPLE_PROCS */
1151 ProcId proc, /* processor */
1152 Ent ent, /* entity */
1153 Inst inst, /* instance */
1157 S16 SRegCbTsk(proc, ent, inst, cbTsk)
1158 ProcId proc; /* processor */
1159 Ent ent; /* entity */
1160 Inst inst; /* instance */
1163 #endif /* SS_MULTIPLE_PROCS */
1168 #ifdef SS_MULTIPLE_PROCS
1170 #endif /* SS_MULTIPLE_PROCS */
1173 #if (ERRCLASS & ERRCLS_INT_PAR)
1174 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
1176 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SRegCbTsk() : Invalid entity/instance");
1182 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, " SRegCbTsk() : Null pointer");
1187 #ifdef SS_MULTIPLE_PROCS
1188 /* retrieve proc id index in the proc id table */
1189 procIdIdx = SGetProcIdIdx(proc);
1191 /* Check whether the proc id exist in the proc id table */
1192 if (procIdIdx == SS_INV_PROCID_IDX)
1194 #if (ERRCLASS & ERRCLS_INT_PAR)
1195 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO,
1196 " SRegCbTsk() : Could not find proc table index");
1201 #endif /* SS_MULTIPLE_PROCS */
1203 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
1207 #if (ERRCLASS & ERRCLS_DEBUG)
1208 SSLOGERROR(ERRCLS_DEBUG, ESSXXX, ERRZERO,
1209 "SRegCbTsk() : Could not lock TAPA task table");
1214 #ifdef SS_MULTIPLE_PROCS
1215 idx = osCp.tTskIds[procIdIdx][ent][inst];
1216 #else /* SS_MULTIPLE_PROCS */
1217 idx = osCp.tTskIds[ent][inst];
1218 #endif /* SS_MULTIPLE_PROCS */
1220 #if (ERRCLASS & ERRCLS_INT_PAR)
1221 if (idx == SS_TSKNC)
1223 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1224 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SRegCbTsk() : Unknown task");
1228 tTsk = &osCp.tTskTbl[idx];
1229 tTsk->cbTsk = cbTsk;
1231 /* unlock the table */
1232 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1239 * Fun: Deregister TAPA task
1241 * Desc: This function is used to deregister a TAPA task.
1242 * All information about the task is removed from the
1246 * RFAILED - failed, general (optional)
1253 /* ss029.103: addition: procId added */
1254 #ifndef SS_MULTIPLE_PROCS
1259 Ent ent, /* entity */
1260 Inst inst /* instance */
1263 S16 SDeregTTsk(ent, inst)
1264 Ent ent; /* entity */
1265 Inst inst; /* instance */
1268 #else /* SS_MULTIPLE_PROCS */
1273 ProcId proc, /* processor */
1274 Ent ent, /* entity */
1275 Inst inst /* instance */
1278 S16 SDeregTTsk(proc, ent, inst)
1279 ProcId proc; /* processor */
1280 Ent ent; /* entity */
1281 Inst inst; /* instance */
1283 #endif /* SS_MULTIPLE_PROCS */
1286 /* ss029.103: modification: The subscript should be consistent type */
1290 /* ss029.103: addition: multiple procIds related changes */
1291 #ifdef SS_MULTIPLE_PROCS
1293 #endif /* SS_MULTIPLE_PROCS */
1294 /* ss002.301 Additions */
1300 #if (ERRCLASS & ERRCLS_INT_PAR)
1301 /* check entity and instance ranges */
1302 /* ss029.103: addition: multiple procIds related changes */
1303 #ifdef SS_MULTIPLE_PROCS
1304 if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST))
1306 SSLOGERROR(ERRCLS_INT_PAR, ESS398, ERRZERO, "Invalid processor/entity/instance");
1309 #else /* SS_MULTIPLE_PROCS */
1310 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
1312 SSLOGERROR(ERRCLS_INT_PAR, ESS399, ERRZERO, "Invalid entity/instance");
1315 #endif /* SS_MULTIPLE_PROCS */
1319 /* ss029.103: addition: multiple procIds related changes */
1320 #ifdef SS_MULTIPLE_PROCS
1321 /* Find the proc table index */
1322 procIdIdx = SGetProcIdIdx(proc);
1324 if (procIdIdx == SS_INV_PROCID)
1326 #if (ERRCLASS & ERRCLS_DEBUG)
1327 SSLOGERROR(ERRCLS_DEBUG, ESS400, ERRZERO,
1328 "Could not find proc id index");
1332 #endif /* SS_MULTIPLE_PROCS */
1334 /* We deregister all timers for this TAPA task, since it's going
1335 * away now. Lock the timer table and iterate through it, removing
1336 * all timers owned by this task.
1338 if (SLock(&osCp.tmrTblLock) != ROK)
1340 #if (ERRCLASS & ERRCLS_DEBUG)
1341 SSLOGERROR(ERRCLS_DEBUG, ESS401, ERRZERO,
1342 "Could not lock timer table");
1347 for (idx = 0; idx < SS_MAX_TMRS; idx++)
1349 /* ss029.103: addition: multiple procIds related changes */
1350 #ifdef SS_MULTIPLE_PROCS
1351 if ((osCp.tmrTbl[idx].ownerProc == proc) &&
1352 (osCp.tmrTbl[idx].ownerEnt == ent) &&
1353 (osCp.tmrTbl[idx].ownerInst == inst))
1354 #else /* SS_MULTIPLE_PROCS */
1355 if ((osCp.tmrTbl[idx].ownerEnt == ent) &&
1356 (osCp.tmrTbl[idx].ownerInst == inst))
1357 #endif /* SS_MULTIPLE_PROCS */
1359 /* shut down this timer */
1360 tmr = &osCp.tmrTbl[idx];
1361 if (ssdDeregTmr(tmr) == ROK)
1365 /* ss029.103: addition: multiple procIds related changes */
1366 #ifdef SS_MULTIPLE_PROCS
1367 tmr->ownerProc = PROCNC;
1369 * ss015.301 - Modifed in initialization as timer activation
1370 * functions enclosed in a union. Also initialized the mtFlag
1373 #endif /* SS_MULTIPLE_PROCS */
1374 tmr->ownerEnt = ENTNC;
1375 tmr->ownerInst = INSTNC;
1377 tmr->ssTmrActvFn.actvFnc.tmrActvFn = NULLP;
1378 #ifndef SS_MULTIPLE_PROCS
1380 tmr->ssTmrActvFn.mtFlag = FALSE;
1381 tmr->ssTmrActvFn.actvFnc.tmrActvFnMt = NULLP;
1384 tmr->nxt = osCp.nxtTmrEntry;
1385 osCp.nxtTmrEntry = (SsIdx)idx;
1391 /* ss006.13: addition */
1392 if ( SUnlock(&osCp.tmrTblLock) != ROK)
1394 #if (ERRCLASS & ERRCLS_DEBUG)
1395 SSLOGERROR(ERRCLS_DEBUG, ESS402, ERRZERO,
1396 "Could not give the Semaphore");
1401 #if (ERRCLASS & ERRCLS_DEBUG)
1402 SSLOGERROR(ERRCLS_DEBUG, ESS403, ERRZERO,
1403 "Could not deregister task's timer(s)");
1412 /* ss006.13: addition */
1413 if ( SUnlock(&osCp.tmrTblLock) != ROK)
1415 #if (ERRCLASS & ERRCLS_DEBUG)
1416 SSLOGERROR(ERRCLS_DEBUG, ESS404, ERRZERO,
1417 "Could not give the Semaphore");
1421 /* ss002.301 Additions */
1422 /* Acquire the counting semaphore for all TAPA tasks. Once
1423 * we have all of them, both SPstTsk() and SRegTTsk() cannot
1424 * run, so we can do things to the TAPA task table.
1426 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
1429 /* ss002.301 Additions */
1431 #if (ERRCLASS & ERRCLS_DEBUG)
1432 SSLOGERROR(ERRCLS_DEBUG, ESS411, ERRZERO,
1433 "Could not lock TAPA task table");
1440 /* get out the TAPA task entry */
1441 /* ss029.103: addition: multiple procIds related changes */
1442 #ifdef SS_MULTIPLE_PROCS
1443 idx = osCp.tTskIds[procIdIdx][ent][inst];
1444 #else /* SS_MULTIPLE_PROCS */
1445 idx = osCp.tTskIds[ent][inst];
1446 #endif /* SS_MULTIPLE_PROCS */
1449 /* make sure this TAPA task exists */
1450 if (idx == SS_TSKNC)
1452 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1454 SSLOGERROR(ERRCLS_INT_PAR, ESS412, ERRZERO, "Unknown task");
1455 /* ss002.301 Additions */
1459 tTsk = &osCp.tTskTbl[idx];
1461 /* unlock the TAPA task table */
1462 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1464 /*Check whether the thread calling this funtion is the same as the system task to which the
1465 TAPA task detremined by passed entity and instance is attached*/
1468 /*ss014.301 SSI-4GMX specific changes*/
1469 #ifndef SS_4GMX_LCORE
1470 if((tTsk->sTsk == NULLP) || (SS_CHECK_CUR_STSK(tTsk->sTsk)))
1472 #ifdef SS_MULTIPLE_PROCS
1473 ssdProcTTskTerm(procIdIdx, tTsk, idx);
1475 ssdProcTTskTerm(tTsk, idx);
1482 if (SGetMsg(SS_DFLT_REGION, SS_DFLT_POOL, &mBuf) != ROK)
1485 #if (ERRCLASS & ERRCLASS_DEBUG)
1486 SSLOGERROR(ERRCLS_DEBUG, ESS415, ERRZERO, "Could not get a message");
1493 mInfo = (SsMsgInfo *)mBuf->b_rptr;
1494 mInfo->eventInfo.event = SS_EVNT_TTSK_TERM;
1496 mInfo->pst.dstEnt = ent;
1497 mInfo->pst.dstInst = inst;
1499 /* we dont care who is calling SDeregTTsk()
1500 so we dont fill srcEnt and dstInst in mInfo->pst */
1502 /* mt028.201: modification: multiple procs support related changes */
1503 /* source proc id is not needed so we dont fill it */
1504 #ifndef SS_MULTIPLE_PROCS
1505 mInfo->pst.dstProcId = SFndProcId();
1506 #else /* SS_MULTIPLE_PROCS */
1507 mInfo->pst.dstProcId = proc;
1508 #endif /* SS_MULTIPLE_PROCS */
1509 /* ss002.301 Additions */
1510 mInfo->pst.selector = SEL_LC_NEW;
1511 mInfo->pst.region = DFLT_REGION;
1512 mInfo->pst.pool = DFLT_POOL;
1513 mInfo->pst.prior = PRIOR0;
1514 mInfo->pst.route = RTESPEC;
1515 mInfo->pst.event = 0;
1516 /* write the timer message to the queue of the destination task */
1517 if (ssDmndQPutLast(&tTsk->sTsk->dQ, mBuf,
1518 (tTsk->tskPrior * SS_MAX_MSG_PRI) + PRIOR0) != ROK)
1520 SS_RELEASE_SEMA(&osCp.tTskTblSem);
1522 #if (ERRCLASS & ERRCLS_DEBUG)
1523 SSLOGERROR(ERRCLS_INT_PAR, ESS416, ERRZERO, "Could not write to demand queue");
1536 * Fun: Create system task
1538 * Desc: This function is used to create a system task. An
1539 * entry is located in the system task table and the
1540 * implementation-specific function is called.
1543 * RFAILED - failed, general (optional)
1544 * ROUTRES - failed, out of resources (optional)
1554 SSTskPrior tskPrior, /* task priority */
1555 SSTskId *tskId /* filled in with system task ID */
1558 S16 SCreateSTsk(tskPrior, tskId)
1559 SSTskPrior tskPrior; /* task priority */
1560 SSTskId *tskId; /* filled in with system task ID */
1569 #if (ERRCLASS & ERRCLS_INT_PAR)
1570 /* check task ID pointer */
1573 SSLOGERROR(ERRCLS_INT_PAR, ESS417, ERRZERO, "Null pointer");
1577 /* check system task priority */
1578 if (tskPrior > SS_LOWEST_STSK_PRIOR)
1580 SSLOGERROR(ERRCLS_INT_PAR, ESS418, ERRZERO,
1581 "Invalid system task priority");
1587 /* lock the system task table */
1588 ret = SLock(&osCp.sTskTblLock);
1592 #if (ERRCLASS & ERRCLS_DEBUG)
1593 SSLOGERROR(ERRCLS_DEBUG, ESS419, (ErrVal) ret,
1594 "Could not lock system task table");
1601 #ifdef SS_SINGLE_THREADED
1602 /* When singlethreaded, we only need to create one... */
1603 /* ss001.301: additions */
1605 #ifndef SS_MULTICORE_SUPPORT
1606 if (osCp.numSTsks == 1)
1608 if (osCp.numSTsks == 2)
1609 #endif /* SS_MULTICORE_SUPPORT */
1611 #ifndef SS_MULTICORE_SUPPORT
1612 if (osCp.numSTsks == 3)
1614 if (osCp.numSTsks == 4)
1615 #endif /* SS_MULTICORE_SUPPORT */
1616 #endif /* SS_WATCHDOG */
1618 /* ss001.301: additions */
1620 #ifndef SS_MULTICORE_SUPPORT
1622 osCp.sTskTbl[0].termPend = FALSE;
1625 osCp.sTskTbl[1].termPend = FALSE;
1626 #endif /* SS_MULTICORE_SUPPORT */
1628 #ifndef SS_MULTICORE_SUPPORT
1630 osCp.sTskTbl[2].termPend = FALSE;
1633 osCp.sTskTbl[3].termPend = FALSE;
1634 #endif /* SS_MULTICORE_SUPPORT */
1635 #endif /* SS_WATCHDOG */
1637 /* ss006.13: addition */
1638 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1640 #if (ERRCLASS & ERRCLS_DEBUG)
1641 SSLOGERROR(ERRCLS_DEBUG, ESS420, ERRZERO,
1642 "Could not give the Semaphore");
1648 #endif /* SS_SINGLE_THREADED */
1651 /* check count of system tasks */
1652 if (osCp.numSTsks == SS_MAX_STSKS)
1655 /* ss006.13: addition */
1656 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1658 #if (ERRCLASS & ERRCLS_DEBUG)
1659 SSLOGERROR(ERRCLS_DEBUG, ESS421, ERRZERO,
1660 "Could not give the Semaphore");
1665 #if (ERRCLASS & ERRCLS_ADD_RES)
1666 SSLOGERROR(ERRCLS_ADD_RES, ESS422, ERRZERO, "Too many system tasks");
1673 /* initialize the system task entry with the information we have */
1674 sTsk = &osCp.sTskTbl[osCp.nxtSTskEntry];
1676 /* store the system task priority */
1677 sTsk->tskPrior = tskPrior;
1679 /*ss014.301 SSI-4GMX specific changes*/
1680 #ifndef SS_4GMX_LCORE
1681 /* initialize the demand queue */
1682 if (ssInitDmndQ(&sTsk->dQ) != ROK)
1685 /* ss006.13: addition */
1686 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1688 #if (ERRCLASS & ERRCLS_DEBUG)
1689 SSLOGERROR(ERRCLS_DEBUG, ESS423, ERRZERO,
1690 "Could not give the Semaphore");
1695 #if (ERRCLASS & ERRCLS_DEBUG)
1696 SSLOGERROR(ERRCLS_DEBUG, ESS424, (ErrVal) ret,
1697 "Could not initialize demand queue");
1703 /* initialize the system task entry lock */
1704 if (SInitLock(&sTsk->lock, SS_STSKENTRY_LOCK) != ROK)
1706 ssDestroyDmndQ(&sTsk->dQ);
1708 /* ss006.13: addition */
1709 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1711 #if (ERRCLASS & ERRCLS_DEBUG)
1712 SSLOGERROR(ERRCLS_DEBUG, ESS425, ERRZERO,
1713 "Could not give the Semaphore");
1718 #if (ERRCLASS & ERRCLS_DEBUG)
1719 SSLOGERROR(ERRCLS_DEBUG, ESS426, (ErrVal) ret,
1720 "Could not initialize system task entry lock");
1727 /* we ask the implementation to start this system task */
1728 ret = ssdCreateSTsk(sTsk);
1731 /* failed, clean up */
1732 SDestroyLock(&sTsk->lock);
1733 /*ss014.301 SSI-4GMX specific changes*/
1734 #ifndef SS_4GMX_LCORE
1735 ssDestroyDmndQ(&sTsk->dQ);
1740 /* ss006.13: addition */
1741 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1743 #if (ERRCLASS & ERRCLS_DEBUG)
1744 SSLOGERROR(ERRCLS_DEBUG, ESS427, ERRZERO,
1745 "Could not give the Semaphore");
1750 #if (ERRCLASS & ERRCLS_DEBUG)
1751 SSLOGERROR(ERRCLS_DEBUG, ESS428, (ErrVal) ret,
1752 "Could not create system task");
1758 /* success, update the table */
1759 *tskId = osCp.nxtSTskEntry;
1760 sTsk->tskId = osCp.nxtSTskEntry;
1762 sTsk->termPend = FALSE;
1763 osCp.nxtSTskEntry = sTsk->nxt;
1766 #ifdef SS_LOCKLESS_MEMORY
1767 tmpRegTidMap[sTsk->region] = sTsk->dep.tId;
1768 #endif /* SS_LOCKLESS_MEMORY */
1769 /* unlock the system task table */
1771 /* ss006.13: addition */
1772 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1774 #if (ERRCLASS & ERRCLS_DEBUG)
1775 SSLOGERROR(ERRCLS_DEBUG, ESS429, ERRZERO,
1776 "Could not give the Semaphore");
1785 /* ss001.301: additions */
1786 #ifdef SS_LOGGER_SUPPORT
1789 * Fun: Register logger configuration
1791 * Desc: This function is used to configure the config information
1792 * of the logger.The log file name, path and the size limits
1793 * of the log file are updated in the SSI control block.
1798 * RFAILED - failed, general (optional)
1799 * ROUTRES - failed, out of resources (optional)
1816 S16 SRegLogCfg(mode, path, size, IPA, port)
1830 /*ss013.301: Fixed Warnings for 32/64 bit compilation*/
1831 struct sockaddr_in localAddr={0};
1832 struct sockaddr_in remoteAddr ={0};
1835 #if (ERRCLASS & ERRCLS_INT_PAR)
1838 /* Initialize the lock, return on failure */
1839 if( SInitLock(&(osCp.logger.bufLock),SS_LOCK_MUTEX) != ROK)
1844 SLock(&osCp.logger.bufLock);
1846 /* Initialize the logger configuration flag */
1847 osCp.logger.configured = FALSE;
1849 if( osCp.logger.started == TRUE)
1851 (Void)SUnlock(&(osCp.logger.bufLock));
1855 /* set the mode of the logging */
1858 case SS_LOG_TO_FILE:
1859 osCp.logger.opt |= 0x01;
1861 case SS_LOG_TO_SOCKET:
1862 osCp.logger.opt |= 0x02;
1866 osCp.logger.opt |= 0x03; break;
1870 if (osCp.logger.opt & 0x01)
1872 osCp.logger.filep = fopen(path, "wb");
1873 if(osCp.logger.filep == NULLP)
1875 SDisplay(0,"Error Opening Log File \n");
1876 (Void)SUnlock(&(osCp.logger.bufLock));
1879 strcpy(osCp.logger.filePath,path);
1883 if (osCp.logger.opt & 0x02)
1886 if ((iRes = WSAStartup(MAKEWORD(2,2), &wsaData)) != NO_ERROR)
1888 SDisplay(0, "Error at WSAStartup!\n");
1889 (Void)SUnlock(&(osCp.logger.bufLock));
1893 osCp.logger.socketdes = socket(AF_INET, SOCK_DGRAM, 0);
1894 if(osCp.logger.socketdes == -1)
1896 SDisplay(0,"Error Opening Log Socket \n");
1900 (Void)SUnlock(&(osCp.logger.bufLock));
1903 /* bind to local address */
1904 localAddr.sin_family = AF_INET;
1905 localAddr.sin_port = port;
1906 localAddr.sin_addr.s_addr = INADDR_ANY;
1907 if (bind(osCp.logger.socketdes, (struct sockaddr*)&localAddr, sizeof(struct sockaddr)) < 0)
1909 SDisplay(0,"Error binding to local port \n");
1911 closesocket(osCp.logger.socketdes);
1914 close(osCp.logger.socketdes);
1916 (Void)SUnlock(&(osCp.logger.bufLock));
1919 /* remote address */
1920 remoteAddr.sin_family = AF_INET;
1921 remoteAddr.sin_port = htons(port);
1924 SDisplay(0,"Invalid remote IP Address \n");
1926 closesocket(osCp.logger.socketdes);
1929 close(osCp.logger.socketdes);
1931 (Void)SUnlock(&(osCp.logger.bufLock));
1934 remoteAddr.sin_addr.s_addr = inet_addr(IPA);
1935 osCp.logger.remoteAddr = remoteAddr;
1939 memset(osCp.logger.buffer, '\0', sizeof(osCp.logger.buffer));
1941 osCp.logger.maxBufSiz = SS_MAX_LOGBUF_SIZE;
1942 osCp.logger.curBufSiz = 0;
1944 osCp.logger.maxNumFlush = size/osCp.logger.maxBufSiz;
1945 osCp.logger.curNumFlush = 0;
1948 osCp.logger.started = FALSE;
1949 osCp.logger.configured = TRUE;
1951 (Void)SUnlock(&(osCp.logger.bufLock));
1958 * Fun: SFlushBufToLog
1960 * Desc: This function is used flush the buffer to file/socket.
1975 S16 SFlushBufToLog(logBuf)
1980 PRIVATE U16 logFileCnt = 0;
1981 S8 newFileName[SS_MAX_PATH];
1988 /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
1992 if (osCp.logger.opt & 0x01)
1994 writeNum = fwrite(buffer, sizeof(U8), cmStrlen((U8 *)buffer),
1997 if (osCp.logger.opt & 0x02)
1999 writeNum = sendto(osCp.logger.socketdes, buffer, cmStrlen((U8 *)buffer), 0, (struct sockaddr*)&osCp.logger.remoteAddr, sizeof(osCp.logger.remoteAddr));
2000 /*ss013.301 : Returned after sending to socket*/
2003 osCp.logger.curNumFlush++;
2004 if(osCp.logger.curNumFlush == osCp.logger.maxNumFlush)
2006 memset(newFileName,'\0',sizeof(newFileName));
2007 /*Store the current File*/
2008 oldFileP = osCp.logger.filep;
2009 /*Open a new file and use it as a new log file*/
2010 osCp.logger.curNumFlush = 0;
2012 sprintf(newFileName, "%s%d", osCp.logger.filePath, logFileCnt);
2013 osCp.logger.filep = fopen(newFileName, "wb");
2014 if(osCp.logger.filep == NULLP)
2016 /*MTLOGERROR(ERRCLS_DEBUG, EMTXXX, ERRZERO, "Error Opening Log File. \n");*/
2021 /*SPutSBuf(DFLT_REGION,DFLT_POOL,
2022 (Data *)buffer, (Size)(osCp.logger.maxBufSiz * sizeof(S8)));*/
2025 } /* SFlushBufToLog */
2031 * Desc: This function is used to clean up the logger info.
2050 /*Flush the remaining data in the log file*/
2051 SLock(&osCp.logger.bufLock);
2052 if(osCp.logger.started == FALSE)
2054 (Void)SUnlock(&(osCp.logger.bufLock));
2057 if(osCp.logger.curBufSiz)
2059 SFlushBufToLog(osCp.logger.buffer);
2060 osCp.logger.curBufSiz = 0;
2063 if (osCp.logger.opt & 0x01)
2065 fclose(osCp.logger.filep);
2067 if (osCp.logger.opt & 0x02)
2070 closesocket(osCp.logger.socketdes);
2072 close(osCp.logger.socketdes);
2075 osCp.logger.started = FALSE;
2077 (Void)SUnlock(&(osCp.logger.bufLock));
2079 signal(SIGINT, App_SigExitCallBack);
2084 } /* end of SCleanUp */
2088 * Fun: Unregister the logger.
2090 * Desc: This function is used to deregister a logger task.
2093 * RFAILED - failed, general (optional)
2094 * ROUTRES - failed, out of resources (optional)
2116 } /* SDeregLogCfg */
2122 * Desc: To start logger.
2140 if (osCp.logger.configured == TRUE)
2142 osCp.logger.started = TRUE;
2151 * Desc: To stop logging to file/socket.
2169 osCp.logger.started = FALSE;
2171 #endif /* SS_LOGGER_SUPPORT */
2173 /** for multi-core support **/
2174 /*ss013.301 : changes related to SS_AFFINITY_SUPPORT*/
2175 #if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT)
2179 * Fun: Register the CPU information
2181 * Desc: This function is used to register the number of cores
2182 * present and the number of threads which can be run on
2186 * RFAILED - failed, general (optional)
2196 SCpuInfo *cpuInfo /* Information about the cores/threads per core */
2199 S16 SRegCpuInfo (cpuInfo)
2200 SCpuInfo *cpuInfo; /* Information about the cores/threads per core */
2205 /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
2206 /* check the number of cores */
2207 if ( cpuInfo->numCores > SS_MAX_CORES ||
2208 cpuInfo->threadsPerCore > SS_MAX_THREADS_PER_CORE ||
2209 cpuInfo->numCores < 1 || cpuInfo->threadsPerCore < 1 )
2211 SSLOGERROR(ERRCLS_INT_PAR, ESS430, ERRZERO, "Invalid number of cores\n");
2216 SLock(&osCp.mCILock);
2217 osCp.mCInfo.cpuInfo.numCores = cpuInfo->numCores;
2218 osCp.mCInfo.cpuInfo.threadsPerCore = cpuInfo->threadsPerCore;
2219 /* if the cpu register is supplied then use it */
2220 for (; coreCount < cpuInfo->numCores; coreCount++)
2223 for (;thrCnt < SS_MAX_THREADS_PER_CORE;thrCnt++)
2225 osCp.mCInfo.coreInfo[coreCount].tskPerCoreLst[thrCnt] = -1;
2227 osCp.mCInfo.coreInfo[coreCount].exclusive = FALSE;
2228 osCp.mCInfo.coreInfo[coreCount].thrs = osCp.mCInfo.cpuInfo.threadRegister[coreCount]
2229 = cpuInfo->threadRegister[coreCount];
2232 SUnlock(&osCp.mCILock);
2242 * Fun: Get the current core/cpu affinity for a thread/lwp
2244 * Desc: This function is used to get the current processor/core
2245 * affinity for a a system task (thread/lwp). It sets the
2246 * affinity based on the mode supplied by the caller.
2249 * RFAILED - failed, general (optional)
2259 SSTskId *tskId, /* filled in with system task ID */
2260 U32 *coreId /* the core/processor id to which the affinity is set */
2263 S16 SGetAffinity(tskId, coreId)
2264 SSTskId *tskId; /* filled in with system task ID */
2265 U32 *coreId; /* the core/processor id to which the affinity is set */
2270 /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
2271 /* implementation specific */
2272 ret = ssdGetAffinity(tskId, coreId);
2276 SSLOGERROR(ERRCLS_INT_PAR, ESS431, ERRZERO, "Failed to get affinity\n");
2281 } /* SGetAffinity */
2286 * Fun: Set the core/cpu affinity for a thread/lwp
2288 * Desc: This function is used to set processor/core affinity for a
2289 * a system task (thread/lwp). It sets the affinity based on the
2290 * mode supplied by the caller.
2293 * RFAILED - failed, general (optional)
2303 SSTskId *tskId, /* filled in with system task ID */
2304 SsAffinityMode mode, /* the mode according to which the affinty is set */
2305 U32 coreId, /* the core/processor id to which the affinity has to be set */
2306 SSTskId *tskAssociatedTskId /* filled in with system task ID of the associated layer */
2309 S16 SSetAffinity(tskId, mode, coreId, tskAssociatedTskId)
2310 SSTskId *tskId; /* filled in with system task ID */
2311 SsAffinityMode mode; /* the mode according to which the affinty is set */
2312 U32 coreId; /* the core/processor id to which the affinity has to be set */
2313 SSTskId *tskAssociatedTskId; /* filled in with system task ID of the associated layer */
2318 /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
2319 /* validate the mode */
2320 if (mode < SS_AFFINITY_MODE_DEFAULT ||
2321 mode > SS_AFFINITY_MODE_EXCL)
2323 SSLOGERROR(ERRCLS_INT_PAR, ESS432, ERRZERO, "Invalid mode for setting core affinity\n");
2327 /* check the value of core id */
2328 if (SS_AFFINITY_MODE_SPECIFIC == mode &&
2329 (coreId > osCp.mCInfo.cpuInfo.numCores || coreId < 0))
2331 SSLOGERROR(ERRCLS_INT_PAR, ESS433, ERRZERO, "Invalid core id\n");
2335 /* set affinity according to the mode supplied */
2338 case SS_AFFINITY_MODE_DEFAULT:
2340 U32 coreCounter = 0, coreIndex = 0;
2343 /*ss013.301: Fixed Warnings for 32/64 bit compilation*/
2344 for (coreIndex = osCp.mCInfo.currentCore;
2345 coreCounter < osCp.mCInfo.cpuInfo.numCores;
2348 /* again start from core 0 */
2350 coreIndex = (coreIndex)%osCp.mCInfo.cpuInfo.numCores;
2351 if (!osCp.mCInfo.coreInfo[coreIndex].exclusive
2352 && osCp.mCInfo.cpuInfo.threadRegister[coreIndex])
2354 if (osCp.mCInfo.coreInfo[coreIndex].thrs || !repeatFlag)
2356 /* call the implementation specific affinity function */
2357 ret = ssdSetAffinity(tskId, coreIndex);
2361 SSLOGERROR(ERRCLS_INT_PAR, ESS434, ERRZERO, \
2362 "Failed to set core affinity\n");
2367 SLock(&osCp.mCILock);
2369 /* move the current core index */
2370 osCp.mCInfo.currentCore = (coreIndex+1)%osCp.mCInfo.cpuInfo.numCores;
2372 /* save the tskId in tskList */
2373 osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[
2374 osCp.mCInfo.cpuInfo.threadRegister[coreIndex] -
2375 osCp.mCInfo.coreInfo[coreIndex].thrs] = *tskId;
2377 /* decrement the available thread count in the thread register */
2378 osCp.mCInfo.coreInfo[coreIndex].thrs--;
2381 SUnlock(&osCp.mCILock);
2384 } /* end if there are threads available in the core */
2385 } /* end if the core is not exclusive flagged and
2386 the core has threads for SSI use */
2388 if (coreCounter == osCp.mCInfo.cpuInfo.numCores && repeatFlag)
2391 SSLOGERROR(ERRCLS_INT_PAR, ESS435, ERRZERO, "Overloading of threads per core!!\n");
2392 goto SEARCH_FOR_CORE;
2393 } /* end if no thrs on cores available and overallocation is needed */
2395 } /* end case SS_AFFINITY_MODE_DEFAULT */
2396 case SS_AFFINITY_MODE_SPECIFIC:
2398 /* check if the core is used exclusively for any task */
2399 if (osCp.mCInfo.coreInfo[coreId].exclusive)
2401 SSLOGERROR(ERRCLS_INT_PAR, ESS436, ERRZERO,\
2402 "Can not set core affinity, core is exclusively used for other task\n");
2405 /* call the implementation specific affinity function with the core id supplied by caller */
2406 ret = ssdSetAffinity(tskId, coreId);
2410 SSLOGERROR(ERRCLS_INT_PAR, ESS437, ERRZERO, "Failed to set core affinity\n");
2415 SLock(&osCp.mCILock);
2417 /* move the current core index */
2418 osCp.mCInfo.currentCore = (coreId+1)%osCp.mCInfo.cpuInfo.numCores;
2420 /* save the tskId in tskList */
2421 osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[
2422 osCp.mCInfo.cpuInfo.threadRegister[coreId] -
2423 osCp.mCInfo.coreInfo[coreId].thrs] = *tskId;
2425 /* decrement the available thread count in the thread register */
2426 osCp.mCInfo.coreInfo[coreId].thrs--;
2429 SUnlock(&osCp.mCILock);
2431 if (osCp.mCInfo.coreInfo[coreId].thrs < 0)
2433 SSLOGERROR(ERRCLS_INT_PAR, ESS438, ERRZERO, "Overloading of threads per core!!\n");
2437 } /* end case SS_AFFINITY_MODE_SPECIFIC */
2438 case SS_AFFINITY_MODE_ASSOC:
2440 /* search for the associated tsk id in osCp */
2441 U32 coreIndex = 0, threadIndex = 0;
2442 Bool tskNotFound = TRUE;
2443 for (;tskNotFound && coreIndex < SS_MAX_CORES; coreIndex++)
2445 for (threadIndex = 0; threadIndex < SS_MAX_THREADS_PER_CORE; threadIndex++)
2447 if (osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[threadIndex] == *tskAssociatedTskId)
2449 if (!osCp.mCInfo.coreInfo[coreIndex].exclusive)
2451 /* set the affinity for the given task on to the core coreIndex */
2452 ret = ssdSetAffinity(tskId, coreIndex);
2455 SSLOGERROR(ERRCLS_INT_PAR, ESS439, ERRZERO, "Failed to set core affinity\n");
2460 SLock(&osCp.mCILock);
2462 /* move the current core index */
2463 osCp.mCInfo.currentCore = (coreIndex+1)%osCp.mCInfo.cpuInfo.numCores;
2465 /* save the tskId in tskList */
2466 osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[
2467 osCp.mCInfo.cpuInfo.threadRegister[coreIndex] -
2468 osCp.mCInfo.coreInfo[coreIndex].thrs] = *tskId;
2470 /* decrement the available thread count in the thread register */
2471 osCp.mCInfo.coreInfo[coreIndex].thrs--;
2474 SUnlock(&osCp.mCILock);
2476 if (osCp.mCInfo.coreInfo[coreIndex].thrs < 0)
2478 SSLOGERROR(ERRCLS_INT_PAR, ESS440, ERRZERO,
2479 "Overloading of threads per core!!\n");
2485 SSLOGERROR(ERRCLS_INT_PAR, ESS441, ERRZERO,
2486 "Can not set core affinity, core is exclusively used for other task\n");
2489 tskNotFound = FALSE;
2492 } /* end inner for */
2495 /* check if tskAssociatedTskId is valid or not */
2496 if (coreIndex == SS_MAX_CORES)
2498 SSLOGERROR(ERRCLS_INT_PAR, ESS442, ERRZERO, "Invalid core id\n");
2502 } /* end case SS_AFFINITY_MODE_ASSOC */
2503 case SS_AFFINITY_MODE_EXCL:
2505 /* check if any thread is already running on the core */
2506 if (coreId != SS_DEFAULT_CORE &&
2507 osCp.mCInfo.coreInfo[coreId].thrs == osCp.mCInfo.cpuInfo.threadRegister[coreId] &&
2508 !osCp.mCInfo.coreInfo[coreId].exclusive)
2510 /* call the implementation specific affinity function */
2511 ret = ssdSetAffinity(tskId, coreId);
2515 SSLOGERROR(ERRCLS_INT_PAR, ESS443, ERRZERO, "Failed to set core affinity\n");
2520 SLock(&osCp.mCILock);
2522 /* set the exclusive flag so that the core will not be used for other system tasks */
2523 osCp.mCInfo.coreInfo[coreId].exclusive = TRUE;
2525 /* save the tskId in tskList */
2526 osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[osCp.mCInfo.cpuInfo.threadRegister[coreId] -
2527 osCp.mCInfo.coreInfo[coreId].thrs] = *tskId;
2529 /* decrement the available thread count in the thread register */
2530 osCp.mCInfo.coreInfo[coreId].thrs--;
2533 SUnlock(&osCp.mCILock);
2536 else if (coreId == SS_DEFAULT_CORE)
2538 U32 coreCounter = 0;
2540 /*ss013.301: Fixed Warnings for 32/64 bit compilation*/
2541 for (coreIndex = osCp.mCInfo.currentCore;
2542 coreCounter < osCp.mCInfo.cpuInfo.numCores;
2546 coreIndex = (coreIndex)%osCp.mCInfo.cpuInfo.numCores;
2547 if (!osCp.mCInfo.coreInfo[coreIndex].exclusive
2548 && osCp.mCInfo.cpuInfo.threadRegister[coreIndex])
2550 if ( osCp.mCInfo.coreInfo[coreIndex].thrs ==
2551 osCp.mCInfo.cpuInfo.threadRegister[coreIndex] &&
2552 osCp.mCInfo.coreInfo[coreIndex].thrs)
2554 /* call the implementation specific affinity function */
2555 ret = ssdSetAffinity(tskId, coreIndex);
2559 SSLOGERROR(ERRCLS_INT_PAR, ESS444, ERRZERO, "Failed to set core affinity\n");
2564 SLock(&osCp.mCILock);
2566 /* move the current core index */
2567 osCp.mCInfo.currentCore = (coreIndex+1)%osCp.mCInfo.cpuInfo.numCores;
2569 /* save the tskId in tskList */
2570 osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[
2571 osCp.mCInfo.cpuInfo.threadRegister[coreIndex] -
2572 osCp.mCInfo.coreInfo[coreIndex].thrs] = *tskId;
2574 /* decrement the available thread count in the thread register */
2575 osCp.mCInfo.coreInfo[coreIndex].thrs--;
2577 /* set the exclusive flag so that the core will not
2578 be used for other system tasks */
2579 osCp.mCInfo.coreInfo[coreIndex].exclusive = TRUE;
2582 SUnlock(&osCp.mCILock);
2585 } /* end if there are threads available in the core */
2586 } /* end if the core is not exclusive flagged and
2587 the core has threads for SSI use */
2589 if (coreCounter == osCp.mCInfo.cpuInfo.numCores)
2591 SSLOGERROR(ERRCLS_INT_PAR, ESS445, ERRZERO,
2592 "Failed to set core affinity, no threads on cores available\n");
2594 } /* end if no thrs on cores available */
2599 SSLOGERROR(ERRCLS_INT_PAR, ESS446, ERRZERO, "Can not set exclusive affinity for the core\n");
2603 } /* end case SS_AFFINITY_MODE_EXCL */
2606 SSLOGERROR(ERRCLS_INT_PAR, ESS447, ERRZERO, "Invalid mode for setting core affinity\n");
2608 } /* end default case */
2609 } /* end of switch */
2614 } /* SSetAffinity */
2616 #endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT*/
2618 /** end multi-core support **/
2623 * Fun: Destroy system task
2625 * Desc: This function is used to destroy a system task. The
2626 * entry is located in the system task table and the
2627 * implementation-specific function is called.
2630 * RFAILED - failed, general (optional)
2640 SSTskId tskId /* system task to be destroyed */
2643 S16 SDestroySTsk(tskId)
2644 SSTskId tskId; /* system task to be destroyed */
2648 /* ss029.103: modification: the subscript should be of same type */
2652 /* ss002.301 Additions */
2653 /*ss013.301 : changes related to SS_AFFINITY_SUPPORT*/
2654 #if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT)
2656 #endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT*/
2661 #if (ERRCLASS & ERRCLS_INT_PAR)
2662 /* validate the system task ID */
2663 if (tskId >= SS_MAX_STSKS)
2665 SSLOGERROR(ERRCLS_INT_PAR, ESS448, (ErrVal) tskId, "Invalid task ID");
2671 /* lock the system task table */
2672 ret = SLock(&osCp.sTskTblLock);
2676 #if (ERRCLASS & ERRCLS_DEBUG)
2677 SSLOGERROR(ERRCLS_DEBUG, ESS449, (ErrVal) ret,
2678 "Could not lock system task table");
2685 idx = (SsIdx) tskId;
2686 sTsk = &osCp.sTskTbl[idx];
2689 #if (ERRCLASS & ERRCLS_INT_PAR)
2691 * check to see this system task exists and it is not already scheduled
2694 if (sTsk->used != TRUE)
2697 /* ss006.13: addition */
2698 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2700 #if (ERRCLASS & ERRCLS_DEBUG)
2701 SSLOGERROR(ERRCLS_DEBUG, ESS450, ERRZERO,
2702 "Could not give the Semaphore");
2707 SSLOGERROR(ERRCLS_INT_PAR, ESS451, (ErrVal) idx,
2708 "Invalid system task ID");
2711 else if (sTsk->termPend != FALSE)
2714 /* ss006.13: addition */
2715 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2717 #if (ERRCLASS & ERRCLS_DEBUG)
2718 SSLOGERROR(ERRCLS_DEBUG, ESS452, ERRZERO,
2719 "Could not give the Semaphore");
2724 SSLOGERROR(ERRCLS_INT_PAR, ESS453, (ErrVal) idx,
2725 "Invalid system task ID");
2731 /* lock this system task entry */
2732 if (!SS_CHECK_CUR_STSK(sTsk))
2734 ret = SLock(&sTsk->lock);
2738 /* ss006.13: addition */
2739 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2741 #if (ERRCLASS & ERRCLS_DEBUG)
2742 SSLOGERROR(ERRCLS_DEBUG, ESS454, ERRZERO,
2743 "Could not give the Semaphore");
2748 #if (ERRCLASS & ERRCLS_DEBUG)
2749 SSLOGERROR(ERRCLS_DEBUG, ESS455, (ErrVal) ret,
2750 "Could not lock system task entry");
2757 /* lock the TAPA task table */
2758 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
2761 if (!SS_CHECK_CUR_STSK(sTsk))
2764 /* ss006.13: addition */
2765 if ( SUnlock(&sTsk->lock) != ROK)
2767 #if (ERRCLASS & ERRCLS_DEBUG)
2768 SSLOGERROR(ERRCLS_DEBUG, ESS456, ERRZERO,
2769 "Could not give the Semaphore");
2775 /* ss006.13: addition */
2776 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2778 #if (ERRCLASS & ERRCLS_DEBUG)
2779 SSLOGERROR(ERRCLS_DEBUG, ESS457, ERRZERO,
2780 "Could not give the Semaphore");
2785 #if (ERRCLASS & ERRCLS_DEBUG)
2786 SSLOGERROR(ERRCLS_DEBUG, ESS458, ERRZERO,
2787 "Could not lock TAPA task table");
2794 /* If this system task entry has any TAPA tasks attached,
2795 * we have to detach them
2799 /* detach all TAPA tasks that are attached here */
2800 for (i = 0; i < SS_MAX_TTSKS; i++)
2802 if (sTsk->tTsks[i] == SS_INVALID_IDX)
2805 osCp.tTskTbl[sTsk->tTsks[i]].sTsk = NULLP;
2806 sTsk->tTsks[i] = SS_INVALID_IDX;
2812 /* set the termination pending flag to TRUE */
2813 sTsk->termPend = TRUE;
2816 /* unlock everything */
2817 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
2819 if (!SS_CHECK_CUR_STSK(sTsk))
2822 /* ss006.13: addition */
2823 if ( SUnlock(&sTsk->lock) != ROK)
2825 #if (ERRCLASS & ERRCLS_DEBUG)
2826 SSLOGERROR(ERRCLS_DEBUG, ESS459, ERRZERO,
2827 "Could not give the Semaphore");
2834 /* ss006.13: addition */
2835 if ( SUnlock(&osCp.sTskTblLock) != ROK)
2837 #if (ERRCLASS & ERRCLS_DEBUG)
2838 SSLOGERROR(ERRCLS_DEBUG, ESS460, ERRZERO,
2839 "Could not give the Semaphore");
2845 /* We call this after unlocking because it is possible that the
2846 * caller is this very system task and we need to take care of
2847 * that. The actual mechanism of notifying the thread that it
2848 * has to die, or actually killing the thread is left to the
2851 ret = ssdDestroySTsk(sTsk);
2854 /* Here, we're a little messed up. We've pretty much made this
2855 * system task unusable, but now, its not going to die. So..??
2858 #if (ERRCLASS & ERRCLS_DEBUG)
2859 SSLOGERROR(ERRCLS_DEBUG, ESS461, (ErrVal) ret,
2860 "Could not destroy system task");
2866 /* multi-core support */
2867 /*ss013.301 : changes related to SS_AFFINITY_SUPPORT*/
2868 #if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT)
2870 /* Remove CPU affinity if any */
2871 for (tskInd = 0; tskInd < SS_MAX_STSKS; tskInd++)
2873 if (osCp.sTskTbl[tskInd].tskId == sTsk->tskId)
2875 /* search for the tskId in coreInfo */
2877 for (coreId = 0; coreId < SS_MAX_CORES; coreId++)
2880 for (thrId = 0; thrId < SS_MAX_THREADS_PER_CORE; thrId++)
2882 if (sTsk->tskId == osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[thrId])
2885 SLock(&osCp.mCILock);
2887 /* increment the available threads */
2888 osCp.mCInfo.coreInfo[coreId].thrs++;
2890 /* reset the thread id */
2891 osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[thrId] = 0;
2893 /* if exclusive flag is set then remove it */
2894 if (osCp.mCInfo.coreInfo[coreId].exclusive)
2896 osCp.mCInfo.coreInfo[coreId].exclusive = FALSE;
2897 } /* end if excl set */
2900 SUnlock(&osCp.mCILock);
2903 } /* end if sTsk matched a thread */
2904 } /* end for loop of thread Ids */
2910 #endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT*/
2911 /* end multi-core support */
2913 /* ss019.103 - added to release semaphore for system task */
2915 if (ssPostSema(&osCp.dep.ssStarted) != ROK)
2917 #if (ERRCLASS & ERRCLS_DEBUG)
2918 SSLOGERROR(ERRCLS_DEBUG, ESS462, ERRZERO,
2919 "Could not unlock the Semaphore");
2926 } /* SDestroySTsk */
2932 * Fun: Attach TAPA task
2934 * Desc: This function is used to attach a TAPA task to a
2935 * system task. The system task will begin to execute
2939 * RFAILED - failed, general (optional)
2940 * ROUTRES - failed, out of resources (optional)
2947 /* ss029.103: addition: procId added */
2948 #ifndef SS_MULTIPLE_PROCS
2953 Ent ent, /* entity ID of the task */
2954 Inst inst, /* instance ID of the task */
2955 SSTskId sTskId /* system task to use */
2958 S16 SAttachTTsk(ent, inst, sTskId)
2959 Ent ent; /* entity ID of the task */
2960 Inst inst; /* instance ID of the task */
2961 SSTskId sTskId; /* system task to use */
2964 #else /* SS_MULTIPLE_PROCS */
2969 ProcId proc, /* processor ID of the task */
2970 Ent ent, /* entity ID of the task */
2971 Inst inst, /* instance ID of the task */
2972 SSTskId sTskId /* system task to use */
2975 S16 SAttachTTsk(proc, ent, inst, sTskId)
2976 ProcId proc; /* processor ID of the task */
2977 Ent ent; /* entity ID of the task */
2978 Inst inst; /* instance ID of the task */
2979 SSTskId sTskId; /* system task to use */
2982 #endif /* SS_MULTIPLE_PROCS */
2989 /* ss029.103: addition: multiple procIds related changes */
2990 #ifdef SS_MULTIPLE_PROCS
2992 #endif /* SS_MULTIPLE_PROCS */
2993 #ifdef SS_MULTICORE_SUPPORT
2995 #ifdef SS_MULTIPLE_PROCS
2997 #endif /* SS_MULTIPLE_PROCS */
3003 #if (ERRCLASS & ERRCLS_INT_PAR)
3004 /* check entity and instance range */
3005 /* ss029.103: addition: multiple procIds related changes */
3006 #ifdef SS_MULTIPLE_PROCS
3007 /* check proc, entity and instance range */
3008 if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST))
3010 SSLOGERROR(ERRCLS_INT_PAR, ESS463, ERRZERO, "Invalid processor/entity/instance");
3013 #else /* SS_MULTIPLE_PROCS */
3014 /* check entity and instance range */
3015 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
3017 SSLOGERROR(ERRCLS_INT_PAR, ESS464, ERRZERO, "Invalid entity/instance");
3020 #endif /* SS_MULTIPLE_PROCS */
3022 /* check the system task index */
3023 if ((SsIdx)sTskId >= SS_MAX_STSKS)
3025 SSLOGERROR(ERRCLS_INT_PAR, ESS465, (ErrVal) sTskId,
3026 "Invalid system task ID");
3031 /* ss029.103: addition: multiple procIds related changes */
3032 #ifdef SS_MULTIPLE_PROCS
3033 /* get the proc id idx */
3034 procIdIdx = SGetProcIdIdx(proc);
3036 if (procIdIdx == SS_INV_PROCID)
3038 #if (ERRCLASS & ERRCLS_DEBUG)
3039 SSLOGERROR(ERRCLS_DEBUG, ESS466, ERRZERO,
3040 "Could not find proc id index");
3044 #endif /* SS_MULTIPLE_PROCS */
3046 /* lock the system task table */
3047 ret = SLock(&osCp.sTskTblLock);
3051 #if (ERRCLASS & ERRCLS_DEBUG)
3052 SSLOGERROR(ERRCLS_DEBUG, ESS467, (ErrVal) ret,
3053 "Could not lock system task table");
3060 sTsk = &osCp.sTskTbl[(SsIdx)sTskId];
3063 #if (ERRCLASS & ERRCLS_INT_PAR)
3064 /* verify that this system task exists */
3065 if (sTsk->used == FALSE)
3068 /* ss006.13: addition */
3069 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3071 #if (ERRCLASS & ERRCLS_DEBUG)
3072 SSLOGERROR(ERRCLS_DEBUG, ESS468, ERRZERO,
3073 "Could not give the Semaphore");
3078 SSLOGERROR(ERRCLS_INT_PAR, ESS469, (ErrVal) sTskId,
3079 "Unknown system task ID");
3085 /* lock the system task entry */
3086 if (!SS_CHECK_CUR_STSK(sTsk))
3088 ret = SLock(&sTsk->lock);
3092 /* ss006.13: addition */
3093 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3095 #if (ERRCLASS & ERRCLS_DEBUG)
3096 SSLOGERROR(ERRCLS_DEBUG, ESS470, ERRZERO,
3097 "Could not give the Semaphore");
3102 #if (ERRCLASS & ERRCLS_DEBUG)
3103 SSLOGERROR(ERRCLS_DEBUG, ESS471, (ErrVal) ret,
3104 "Could not lock system task entry");
3112 /* if this system task is about to die, we don't attach */
3113 if (sTsk->termPend == TRUE)
3115 if (!SS_CHECK_CUR_STSK(sTsk))
3118 /* ss006.13: addition */
3119 if ( SUnlock(&sTsk->lock) != ROK)
3121 #if (ERRCLASS & ERRCLS_DEBUG)
3122 SSLOGERROR(ERRCLS_DEBUG, ESS472, ERRZERO,
3123 "Could not give the Semaphore");
3129 /* ss006.13: addition */
3130 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3132 #if (ERRCLASS & ERRCLS_DEBUG)
3133 SSLOGERROR(ERRCLS_DEBUG, ESS473, ERRZERO,
3134 "Could not give the Semaphore");
3143 /* lock the TAPA task table */
3144 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
3147 if (!SS_CHECK_CUR_STSK(sTsk))
3150 /* ss006.13: addition */
3151 if ( SUnlock(&sTsk->lock) != ROK)
3153 #if (ERRCLASS & ERRCLS_DEBUG)
3154 SSLOGERROR(ERRCLS_DEBUG, ESS474, ERRZERO,
3155 "Could not give the Semaphore");
3162 /* ss006.13: addition */
3163 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3165 #if (ERRCLASS & ERRCLS_DEBUG)
3166 SSLOGERROR(ERRCLS_DEBUG, ESS475, ERRZERO,
3167 "Could not give the Semaphore");
3172 #if (ERRCLASS & ERRCLS_DEBUG)
3173 SSLOGERROR(ERRCLS_DEBUG, ESS476, ERRZERO,
3174 "Could not lock TAPA task table");
3181 /* get the index of the TAPA task entry in the table */
3182 /* ss029.103: addition: multiple procIds related changes */
3183 #ifdef SS_MULTIPLE_PROCS
3184 idx = osCp.tTskIds[procIdIdx][ent][inst];
3185 #else /* SS_MULTIPLE_PROCS */
3186 idx = osCp.tTskIds[ent][inst];
3187 #endif /* SS_MULTIPLE_PROCS */
3189 #if (ERRCLASS & ERRCLS_INT_PAR)
3190 /* check out the TAPA task ID */
3191 if (idx == SS_TSKNC)
3193 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3194 if (!SS_CHECK_CUR_STSK(sTsk))
3197 /* ss006.13: addition */
3198 if ( SUnlock(&sTsk->lock) != ROK)
3200 #if (ERRCLASS & ERRCLS_DEBUG)
3201 SSLOGERROR(ERRCLS_DEBUG, ESS477, ERRZERO,
3202 "Could not give the Semaphore");
3208 /* ss006.13: addition */
3209 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3211 #if (ERRCLASS & ERRCLS_DEBUG)
3212 SSLOGERROR(ERRCLS_DEBUG, ESS478, ERRZERO,
3213 "Could not give the Semaphore");
3218 SSLOGERROR(ERRCLS_INT_PAR, ESS479, ERRZERO, "Unknown task");
3224 /* verify that this TAPA task is not already attached */
3225 if (osCp.tTskTbl[idx].sTsk != NULLP)
3227 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3228 if (!SS_CHECK_CUR_STSK(sTsk))
3231 /* ss006.13: addition */
3232 if ( SUnlock(&sTsk->lock) != ROK)
3234 #if (ERRCLASS & ERRCLS_DEBUG)
3235 SSLOGERROR(ERRCLS_DEBUG, ESS480, ERRZERO,
3236 "Could not give the Semaphore");
3242 /* ss006.13: addition */
3243 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3245 #if (ERRCLASS & ERRCLS_DEBUG)
3246 SSLOGERROR(ERRCLS_DEBUG, ESS481, ERRZERO,
3247 "Could not give the Semaphore");
3256 /* verify that there is space for another TAPA task */
3257 if (sTsk->numTTsks == SS_MAX_TTSKS)
3259 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3260 if (!SS_CHECK_CUR_STSK(sTsk))
3263 /* ss006.13: addition */
3264 if ( SUnlock(&sTsk->lock) != ROK)
3266 #if (ERRCLASS & ERRCLS_DEBUG)
3267 SSLOGERROR(ERRCLS_DEBUG, ESS482, ERRZERO,
3268 "Could not give the Semaphore");
3274 /* ss006.13: addition */
3275 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3277 #if (ERRCLASS & ERRCLS_DEBUG)
3278 SSLOGERROR(ERRCLS_DEBUG, ESS483, ERRZERO,
3279 "Could not give the Semaphore");
3288 /* Find place for this TAPA task in the system task's list
3289 * of TAPA tasks to run. Plug in this TAPA task.
3291 for (i = 0; i < SS_MAX_TTSKS; i++)
3293 if (sTsk->tTsks[i] == SS_INVALID_IDX)
3295 sTsk->tTsks[i] = idx;
3302 /* Fill in the system task info in the TAPA task entry, so
3303 * the TAPA task knows who's running it.
3305 osCp.tTskTbl[idx].sTsk = sTsk;
3306 #ifdef SS_MULTICORE_SUPPORT
3307 tTsk = &osCp.tTskTbl[idx];
3308 if(tTsk->initTsk != NULLP)
3310 #ifndef SS_MULTIPLE_PROCS
3311 (Void)(tTsk->initTsk)(tTsk->ent, tTsk->inst, sTsk->region, PWR_UP);
3313 /* retrieve proc id index in the proc id table */
3314 procIdIdx = SGetProcIdIdx(tTsk->proc);
3316 /* Check whether the proc id exist in the proc id table */
3317 if (procIdIdx == SS_INV_PROCID_IDX)
3319 #if (ERRCLASS & ERRCLS_INT_PAR)
3320 SSLOGERROR(ERRCLS_INT_PAR, ESS389, ERRZERO,
3321 "Could not find proc table index");
3326 (Void)(tTsk->initTsk)(tTsk->proc, tTsk->ent, tTsk->inst, sTsk->region, PWR_UP, &xxCb);
3328 * store the control block. The control block may be NULL in some cases
3330 idx = osCp.tTskIds[procIdIdx][tTsk->ent][tTsk->inst];
3331 #if (ERRCLASS & ERRCLS_INT_PAR)
3332 if ( xxCb == NULLP )
3334 SSLOGERROR(ERRCLS_INT_PAR, ERRZERO, ERRZERO,
3338 osCp.tTskTbl[idx].xxCb = xxCb;
3339 #endif /* SS_MULTIPLE_PROCS */
3341 #endif /* SS_MULTICORE_SUPPORT */
3344 /* call the implementation to do anything implementation-specific */
3345 ret = ssdAttachTTsk(&osCp.tTskTbl[idx]);
3348 /* unlock the tables; we're done */
3349 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3350 if (!SS_CHECK_CUR_STSK(sTsk))
3353 /* ss006.13: addition */
3354 if ( SUnlock(&sTsk->lock) != ROK)
3356 #if (ERRCLASS & ERRCLS_DEBUG)
3357 SSLOGERROR(ERRCLS_DEBUG, ESS484, ERRZERO,
3358 "Could not give the Semaphore");
3364 /* ss006.13: addition */
3365 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3367 #if (ERRCLASS & ERRCLS_DEBUG)
3368 SSLOGERROR(ERRCLS_DEBUG, ESS485, ERRZERO,
3369 "Could not give the Semaphore");
3375 /* If the implementation didn't succeed, we have to undo everything.
3376 * We call SDetachTTsk, to make it easier.
3380 /* ss029.103: addition: multiple procIds related changes */
3381 #ifdef SS_MULTIPLE_PROCS
3382 SDetachTTsk(proc, ent, inst);
3383 #else /* SS_MULTIPLE_PROCS */
3384 SDetachTTsk(ent, inst);
3385 #endif /* SS_MULTIPLE_PROCS */
3396 * Fun: Detach TAPA task
3398 * Desc: This function is used to detach a TAPA task from a
3399 * system task. The system task will stop executing
3403 * RFAILED - failed, general (optional)
3410 /* ss029.103: addition: procId added */
3411 #ifndef SS_MULTIPLE_PROCS
3416 Ent ent, /* entity ID of the task */
3417 Inst inst /* instance ID of the task */
3420 S16 SDetachTTsk(ent, inst)
3421 Ent ent; /* entity ID of the task */
3422 Inst inst; /* instance ID of the task */
3425 #else /* SS_MULTIPLE_PROCS */
3430 ProcId proc, /* processor ID of the task */
3431 Ent ent, /* entity ID of the task */
3432 Inst inst /* instance ID of the task */
3435 S16 SDetachTTsk(proc, ent, inst)
3436 ProcId proc; /* processor ID of the task */
3437 Ent ent; /* entity ID of the task */
3438 Inst inst; /* instance ID of the task */
3441 #endif /* SS_MULTIPLE_PROCS */
3449 /* ss029.103: addition: multiple procIds related changes */
3450 #ifdef SS_MULTIPLE_PROCS
3452 #endif /* SS_MULTIPLE_PROCS */
3456 #if (ERRCLASS & ERRCLS_INT_PAR)
3457 /* check entity and instance ranges */
3458 /* ss029.103: addition: multiple procIds related changes */
3459 #ifdef SS_MULTIPLE_PROCS
3460 /* check entity and instance ranges */
3461 if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST))
3463 SSLOGERROR(ERRCLS_INT_PAR, ESS486, ERRZERO, "Invalid processor/entity/instance");
3466 #else /* SS_MULTIPLE_PROCS */
3467 /* check entity and instance ranges */
3468 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
3470 SSLOGERROR(ERRCLS_INT_PAR, ESS487, ERRZERO, "Invalid entity/instance");
3473 #endif /* SS_MULTIPLE_PROCS */
3476 /* ss029.103: addition: multiple procIds related changes */
3477 #ifdef SS_MULTIPLE_PROCS
3478 /* get the proc id idx */
3479 procIdIdx = SGetProcIdIdx(proc);
3481 if (procIdIdx == SS_INV_PROCID)
3483 #if (ERRCLASS & ERRCLS_DEBUG)
3484 SSLOGERROR(ERRCLS_DEBUG, ESS488, ERRZERO,
3485 "Could not find proc id index");
3489 #endif /* SS_MULTIPLE_PROCS */
3492 /* Lock the system task table. We do this to prevent
3493 * the system task from being destroyed and confusing
3494 * matters before we detach.
3496 ret = SLock(&osCp.sTskTblLock);
3500 #if (ERRCLASS & ERRCLS_DEBUG)
3501 SSLOGERROR(ERRCLS_DEBUG, ESS489, (ErrVal) ret,
3502 "Could not lock system task table");
3509 /* lock the TAPA task table */
3510 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
3514 /* ss006.13: addition */
3515 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3517 #if (ERRCLASS & ERRCLS_DEBUG)
3518 SSLOGERROR(ERRCLS_DEBUG, ESS490, ERRZERO,
3519 "Could not give the Semaphore");
3524 #if (ERRCLASS & ERRCLS_DEBUG)
3525 SSLOGERROR(ERRCLS_DEBUG, ESS491, ERRZERO,
3526 "Could not lock TAPA task table");
3533 #if (ERRCLASS & ERRCLS_INT_PAR)
3534 /* Check this TAPA task. We do this with the TAPA task table
3535 * locked, coz we don't want the task to be found, but then
3536 * be deregistered before we lock
3538 /* ss029.103: addition: multiple procIds related changes */
3539 #ifdef SS_MULTIPLE_PROCS
3540 if (osCp.tTskIds[procIdIdx][ent][inst] == SS_TSKNC)
3541 #else /* SS_MULTIPLE_PROCS */
3542 if (osCp.tTskIds[ent][inst] == SS_TSKNC)
3543 #endif /* SS_MULTIPLE_PROCS */
3545 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3547 /* ss006.13: addition */
3548 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3550 #if (ERRCLASS & ERRCLS_DEBUG)
3551 SSLOGERROR(ERRCLS_DEBUG, ESS492, ERRZERO,
3552 "Could not give the Semaphore");
3557 SSLOGERROR(ERRCLS_INT_PAR, ESS493, ERRZERO, "Unknown task");
3562 /* ss029.103: addition: multiple procIds related changes */
3563 #ifdef SS_MULTIPLE_PROCS
3564 idx = osCp.tTskIds[procIdIdx][ent][inst];
3565 #else /* SS_MULTIPLE_PROCS */
3566 idx = osCp.tTskIds[ent][inst];
3567 #endif /* SS_MULTIPLE_PROCS */
3569 tTsk = &osCp.tTskTbl[idx];
3571 /* check if this TAPA task is attached to anyone */
3572 if (tTsk->sTsk == NULLP)
3574 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3576 /* ss006.13: addition */
3577 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3579 #if (ERRCLASS & ERRCLS_DEBUG)
3580 SSLOGERROR(ERRCLS_DEBUG, ESS494, ERRZERO,
3581 "Could not give the Semaphore");
3589 /* we get the system task entry out */
3593 /* We unlock the TAPA task table here, and then re-lock it later
3594 * because of lock sequencing--we have to lock the system task
3595 * entry first, and then the TAPA task table. Note, the system
3596 * task table is locked, so nobody can sneak in and destroy the
3597 * system task while we're doing this.
3599 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3602 /* lock the system task entry */
3603 if (!SS_CHECK_CUR_STSK(sTsk))
3605 ret = SLock(&sTsk->lock);
3609 /* ss006.13: addition */
3610 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3612 #if (ERRCLASS & ERRCLS_DEBUG)
3613 SSLOGERROR(ERRCLS_DEBUG, ESS495, ERRZERO,
3614 "Could not give the Semaphore");
3619 #if (ERRCLASS & ERRCLS_DEBUG)
3620 SSLOGERROR(ERRCLS_DEBUG, ESS496, (ErrVal) ret,
3621 "Could not lock system task entry");
3629 /* now we lock the TAPA task table */
3630 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
3634 /* ss006.13: addition */
3635 if ( SUnlock(&sTsk->lock) != ROK)
3637 #if (ERRCLASS & ERRCLS_DEBUG)
3638 SSLOGERROR(ERRCLS_DEBUG, ESS497, ERRZERO,
3639 "Could not give the Semaphore");
3643 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3645 #if (ERRCLASS & ERRCLS_DEBUG)
3646 SSLOGERROR(ERRCLS_DEBUG, ESS498, ERRZERO,
3647 "Could not give the Semaphore");
3652 #if (ERRCLASS & ERRCLS_DEBUG)
3653 SSLOGERROR(ERRCLS_DEBUG, ESS499, ERRZERO,
3654 "Could not lock TAPA task table");
3661 /* Now, we can safely update both the system task entry
3662 * and the TAPA task entry. First, we update the TAPA
3663 * task entry--nobody is running it now.
3668 /* Remove this TAPA task from the system task's list of
3669 * TAPA tasks to run.
3671 for (i = 0; i < SS_MAX_TTSKS; i++)
3673 if (sTsk->tTsks[i] == idx)
3675 sTsk->tTsks[i] = SS_INVALID_IDX;
3682 /* call the implementation to do anything it needs to */
3683 ret = ssdDetachTTsk(tTsk);
3686 /* unlock the TAPA task table */
3687 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
3689 /* unlock the system task entry */
3690 if (!SS_CHECK_CUR_STSK(sTsk))
3693 /* ss006.13: addition */
3694 if ( SUnlock(&sTsk->lock) != ROK)
3696 #if (ERRCLASS & ERRCLS_DEBUG)
3697 SSLOGERROR(ERRCLS_DEBUG, ESS500, ERRZERO,
3698 "Could not give the Semaphore");
3704 /* unlock the system task table */
3706 /* ss006.13: addition */
3707 if ( SUnlock(&osCp.sTskTblLock) != ROK)
3709 #if (ERRCLASS & ERRCLS_DEBUG)
3710 SSLOGERROR(ERRCLS_DEBUG, ESS501, ERRZERO,
3711 "Could not give the Semaphore");
3717 /* If the implementation couldn't detach the task, we just
3718 * return an error, nothing else we can do.
3732 * Fun: Post a message to a task
3734 * Desc: This function is used to post a message to a TAPA
3735 * task. The message is delivered to the demand queue
3736 * of the system task that is running the specified
3740 * RFAILED - failed, general (optional)
3750 Pst *pst, /* post information */
3751 Buffer *mBuf /* message to post */
3754 S16 SPstTsk(pst, mBuf)
3755 Pst *pst; /* post information */
3756 Buffer *mBuf; /* message to post */
3761 #if (defined(SS_DRVR_SUPPORT))
3769 #if (defined(SS_DRVR_SUPPORT) || defined(SS_RTR_SUPPORT))
3772 #ifdef SS_DRVR_SUPPORT
3773 Bool nPstUsed = FALSE;
3775 #if (defined(SS_RTR_SUPPORT))
3778 /* ss029.103: addition: multiple procIds related changes */
3779 #ifdef SS_MULTIPLE_PROCS
3782 #endif /* SS_MULTIPLE_PROCS */
3783 /*ss004.301: Cavium changes */
3784 #ifdef SS_SEUM_CAVIUM
3787 cvmx_wqe_t *workPtr;
3788 #endif /* SS_SEUM_CAVIUM */
3793 #ifdef MSPD_MLOG_NEW
3794 U32 t = MacGetTick();
3799 #if (ERRCLASS & ERRCLS_INT_PAR)
3800 /* check the message buffer */
3803 SSLOGERROR(ERRCLS_INT_PAR, ESS502, ERRZERO, "Invalid message buffer");
3807 /* check the pst structure */
3811 SSLOGERROR(ERRCLS_INT_PAR, ESS503, ERRZERO, "Null pointer");
3814 /* ss021.103 - Addition to check for valid route */
3815 /* ss023.103 - Modification to fix bug in route validation */
3816 /* check the route */
3817 if (pst->route == RTENC)
3820 SSLOGERROR(ERRCLS_INT_PAR, ESS504, ERRZERO, "No route defined");
3825 #ifndef TENB_RTLIN_CHANGES
3826 /* lock the TAPA task table */
3827 SS_ACQUIRE_SEMA(&osCp.tTskTblSem, r);
3832 #if (ERRCLASS & ERRCLS_DEBUG)
3833 SSLOGERROR(ERRCLS_DEBUG, ESS505, ERRZERO,
3834 "Could not lock TAPA task table");
3841 #if (ERRCLASS & ERRCLS_INT_PAR)
3842 /* ss029.103: addition: multiple procIds related changes */
3843 #ifdef SS_MULTIPLE_PROCS
3844 if (pst->srcProcId == SS_INV_PROCID || pst->srcEnt >= SS_MAX_ENT ||
3845 pst->srcInst >= SS_MAX_INST || pst->dstProcId == SS_INV_PROCID ||
3846 pst->dstEnt >= SS_MAX_ENT || pst->dstInst >= SS_MAX_INST)
3847 #else /* SS_MULTIPLE_PROCS */
3848 if (pst->srcEnt >= SS_MAX_ENT || pst->srcInst >= SS_MAX_INST ||
3849 pst->dstEnt >= SS_MAX_ENT || pst->dstInst >= SS_MAX_INST)
3850 #endif /* SS_MULTIPLE_PROCS */
3852 #ifndef TENB_RTLIN_CHANGES
3853 /* ss006.13: addition */
3854 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3856 #if (ERRCLASS & ERRCLS_DEBUG)
3857 SSLOGERROR(ERRCLS_DEBUG, ESS506, ERRZERO,
3858 "Could not release the semaphore");
3866 SSLOGERROR(ERRCLS_INT_PAR, ESS507, ERRZERO,
3867 "Invalid source/destination entity/instance");
3873 /* ss019.103 - modified for use with message router in virtual/physical
3876 #ifdef SS_RTR_SUPPORT
3877 /* check if we have a router task registered for this route */
3878 if (pst->route < RTENC && osCp.rtrTskTbl[pst->route] != NULLP)
3880 /* copy the Pst structure into a local duplicate */
3881 for (i = 0; i < (S16)sizeof(Pst); i++)
3883 *(((U8 *)(&nPst)) + i) = *(((U8 *) pst) + i);
3886 #ifdef SS_DRVR_SUPPORT
3890 /* lock the router task entry */
3892 r = SLock(&osCp.rtrTskLocks[rte]);
3895 /* ss006.13: addition */
3896 #ifndef TENB_RTLIN_CHANGES
3897 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3899 #if (ERRCLASS & ERRCLS_DEBUG)
3900 SSLOGERROR(ERRCLS_DEBUG, ESS508, ERRZERO,
3901 "Could not release the semaphore");
3908 #if (ERRCLASS & ERRCLS_DEBUG)
3909 SSLOGERROR(ERRCLS_DEBUG, ESS509, ERRZERO,
3910 "Could not lock router task entry");
3916 /* call the router activation function */
3917 r = (*osCp.rtrTskTbl[rte])(pst, mBuf);
3919 /* unlock the router task entry */
3921 /* ss006.13: addition */
3922 if ( SUnlock(&osCp.rtrTskLocks[rte]) != ROK)
3924 #if (ERRCLASS & ERRCLS_DEBUG)
3925 SSLOGERROR(ERRCLS_DEBUG, ESS510, ERRZERO,
3926 "Could not give the Semaphore");
3931 if (r == RFAILED || r == ROKIGNORE)
3933 /* ss006.13: addition */
3934 #ifndef TENB_RTLIN_CHANGES
3935 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3937 #if (ERRCLASS & ERRCLS_DEBUG)
3938 SSLOGERROR(ERRCLS_DEBUG, ESS511, ERRZERO,
3939 "Could not release the semaphore");
3944 return ((r == RFAILED) ? RFAILED : ROK);
3947 #endif /* SS_RTR_SUPPORT */
3949 /* ss029.103: addition: multiple procIds related changes */
3950 #ifdef SS_MULTIPLE_PROCS
3952 /* get proc id index */
3953 srcProcIdIdx = SGetProcIdIdx(pst->srcProcId);
3954 dstProcIdIdx = SGetProcIdIdx(pst->dstProcId);
3956 if (srcProcIdIdx != SS_INV_PROCID_IDX)
3957 srcIdx = osCp.tTskIds[srcProcIdIdx][pst->srcEnt][pst->srcInst];
3959 if (dstProcIdIdx != SS_INV_PROCID_IDX)
3960 dstIdx = osCp.tTskIds[dstProcIdIdx][pst->dstEnt][pst->dstInst];
3962 if (((srcProcIdIdx != SS_INV_PROCID_IDX) && (srcIdx == SS_TSKNC)) ||
3963 ((dstProcIdIdx != SS_INV_PROCID_IDX) && (dstIdx == SS_TSKNC)))
3965 #ifndef TENB_RTLIN_CHANGES
3966 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
3968 #if (ERRCLASS & ERRCLS_DEBUG)
3969 SSLOGERROR(ERRCLS_DEBUG, ESS512, ERRZERO,
3970 "Could not release the semaphore");
3978 #if (ERRCLASS & ERRCLS_DEBUG)
3979 SSLOGERROR(ERRCLS_DEBUG, ESS513, ERRZERO, "Unknown task");
3985 #else /* SS_MULTIPLE_PROCS */
3986 /* ss019.103 - modified for use with message router in virtual/physical
3989 /* get the src and destination task */
3990 srcIdx = osCp.tTskIds[pst->srcEnt][pst->srcInst];
3991 dstIdx = osCp.tTskIds[pst->dstEnt][pst->dstInst];
3994 /* If the source/destination processor ID is local, the
3995 * source/destination TAPA task must be local.
3997 if ((pst->srcProcId == osCp.procId && srcIdx == SS_TSKNC)
3998 || (pst->dstProcId == osCp.procId && dstIdx == SS_TSKNC))
4000 /* ss006.13: addition */
4001 #ifndef TENB_RTLIN_CHANGES
4002 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4004 #if (ERRCLASS & ERRCLS_DEBUG)
4005 SSLOGERROR(ERRCLS_DEBUG, ESS514, ERRZERO,
4006 "Could not release the semaphore");
4013 #if (ERRCLASS & ERRCLS_DEBUG)
4014 SSLOGERROR(ERRCLS_DEBUG, ESS515, ERRZERO, "Unknown task");
4020 #endif /* SS_MULTIPLE_PROCS */
4022 #ifdef SS_DRVR_SUPPORT
4023 /* Check for the destination procId. If it is non-local,
4024 * we need to find the driver task that will handle this
4027 /* ss029.103: addition: multiple procIds related changes */
4028 #ifdef SS_MULTIPLE_PROCS
4029 if (dstProcIdIdx == SS_INV_PROCID_IDX)
4030 #else /* SS_MULTIPLE_PROCS */
4031 if (pst->dstProcId != osCp.procId)
4032 #endif /* SS_MULTIPLE_PROCS */
4034 /* Need to optimize this search.
4036 for (i = 0; i < SS_MAX_DRVRTSKS; i++)
4038 if (osCp.drvrTskTbl[i].used
4039 && pst->dstProcId >= osCp.drvrTskTbl[i].low
4040 && pst->dstProcId <= osCp.drvrTskTbl[i].high)
4042 /* Copy the Pst structure into a local duplicate if not
4047 for (j = 0; j < (S16)sizeof(Pst); j++)
4049 *(((U8 *)(&nPst)) + j) = *(((U8 *) pst) + j);
4057 //if (clusterMode == NET_CLUSTER_MODE)
4060 /* lock the driver task entry */
4061 r = SLock(&osCp.drvrTskTbl[i].lock);
4064 /* ss006.13: addition */
4065 #ifndef TENB_RTLIN_CHANGES
4066 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4068 #if (ERRCLASS & ERRCLS_DEBUG)
4069 SSLOGERROR(ERRCLS_DEBUG, ESS516, ERRZERO,
4070 "Could not release the semaphore");
4077 #if (ERRCLASS & ERRCLS_DEBUG)
4078 SSLOGERROR(ERRCLS_DEBUG, ESS517, ERRZERO,
4079 "Could not lock driver task entry");
4087 /*ss014.301 SSI-4GMX specific change*/
4088 #ifndef SS_4GMX_LCORE
4089 CMCHKPKLOG(cmPkInst, osCp.drvrTskTbl[i].channel, mBuf, ESS518, pst);
4092 (osCp.drvrTskTbl[i].actvTsk)(pst, mBuf);
4096 //if (clusterMode == NET_CLUSTER_MODE)
4099 /* ss006.13: addition */
4100 if ( SUnlock(&osCp.drvrTskTbl[i].lock) != ROK)
4102 #if (ERRCLASS & ERRCLS_DEBUG)
4103 SSLOGERROR(ERRCLS_DEBUG, ESS519, ERRZERO,
4104 "Could not give the Semaphore");
4112 /* ss006.13: addition */
4113 #ifndef TENB_RTLIN_CHANGES
4114 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4116 #if (ERRCLASS & ERRCLS_DEBUG)
4117 SSLOGERROR(ERRCLS_DEBUG, ESS520, ERRZERO,
4118 "Could not release the semaphore");
4127 /* ss006.13: addition */
4128 #ifndef TENB_RTLIN_CHANGES
4129 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4131 #if (ERRCLASS & ERRCLS_DEBUG)
4132 SSLOGERROR(ERRCLS_DEBUG, ESS521, ERRZERO,
4133 "Could not release the semaphore");
4140 #if (ERRCLASS & ERRCLS_DEBUG)
4141 SSLOGERROR(ERRCLS_DEBUG, ESS522, ERRZERO,
4142 "Could not find a driver task to handle this proc ID");
4147 #endif /* SS_DRVR_SUPPORT */
4148 /* ss002.301 Modifications */
4149 /* Write the message to the demand queue of the system
4150 * task which is running the destination task
4152 tTsk = &osCp.tTskTbl[dstIdx];
4154 memcpy(&tempPst, pst, sizeof(Pst));
4155 if(tTsk->cbTsk != NULLP)
4157 retValue = tTsk->cbTsk(&tempPst,mBuf);
4160 #ifndef TENB_RTLIN_CHANGES
4161 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4163 #if (ERRCLASS & ERRCLS_DEBUG)
4164 SSLOGERROR(ERRCLS_DEBUG, ESS512, ERRZERO,
4165 "Could not release the semaphore");
4171 #if (ERRCLASS & ERRCLS_DEBUG)
4172 SSLOGERROR(ERRCLS_DEBUG, ESS513, ERRZERO, "call back function failed\n");
4176 #ifdef SS_MULTIPLE_PROCS
4177 dstIdx = osCp.tTskIds[dstProcIdIdx][tempPst.dstEnt][tempPst.dstInst];
4179 dstIdx = osCp.tTskIds[tempPst.dstEnt][tempPst.dstInst];
4181 tTsk = &osCp.tTskTbl[dstIdx];
4184 /* plug the Pst structure into the message information portion */
4185 msgInfo = (SsMsgInfo *) (mBuf->b_rptr);
4186 for (i = 0; i < (S16 )sizeof(Pst); i++)
4187 *(((U8 *)(&msgInfo->pst)) + i) = *(((U8 *) &(tempPst)) + i);
4189 /* ss004.301 : Cavium cahnges */
4190 #ifdef SS_SEUM_CAVIUM
4191 if (pst->dstProcId != osCp.procId)
4193 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4195 #if (ERRCLASS & ERRCLS_DEBUG)
4196 SSLOGERROR(ERRCLS_DEBUG, ESS527, ERRZERO,
4197 "Could not release the semaphore");
4202 /* Copy the message to the FPA region */
4203 ret = SCpyMsgFpa(mBuf, &wqBuf);
4206 /* No need to free the buffer, its already done in called fun */
4210 /* Allocate for the mBuf */
4211 /* ss010.301: Cavium 32 bit changes */
4212 workPtr = cvmx_fpa_alloc(SS_CVMX_WQE_POOL);
4213 if( workPtr == NULLP )
4219 /* Convert the pointers to physical address */
4220 ret = SConvPtrPhy(&wqBuf);
4227 /* Assign the values for work ptr */
4229 workPtr->grp = pst->dstProcId;
4230 workPtr->tag_type = CVMX_POW_TAG_TYPE_NULL;
4231 workPtr->tag = SS_CVMX_MBUF_TAG;
4233 workPtr->packet_ptr.ptr = (Void*)wqBuf;
4235 cvmx_pow_work_submit(workPtr, workPtr->tag, workPtr->tag_type, \
4236 workPtr->qos, workPtr->grp);
4240 #endif /* SS_SEUM_CAVIUM */
4243 /* Write the message to the demand queue of the system
4244 * task which is running the destination task
4246 tTsk = &osCp.tTskTbl[dstIdx];
4247 prior = tTsk->tskPrior;
4249 if (tTsk->sTsk == NULLP)
4251 /* ss006.13: addition */
4252 #ifndef TENB_RTLIN_CHANGES
4253 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4255 #if (ERRCLASS & ERRCLS_DEBUG)
4256 SSLOGERROR(ERRCLS_DEBUG, ESS523, ERRZERO,
4257 "Could not release the semaphore");
4264 #if (ERRCLASS & ERRCLS_DEBUG)
4265 SSLOGERROR(ERRCLS_DEBUG, ESS524, (ErrVal) 0,
4266 "Destination TAPA task is not attached");
4272 #ifdef SS_LOCKLESS_MEMORY
4273 msgInfo->region = tTsk->sTsk->region;
4274 msgInfo->pst.region = tTsk->sTsk->region;
4275 #endif /* SS_LOCKLESS_MEMORY */
4277 /*ss014.301 SSI-4GMX specific changes*/
4278 #ifndef SS_4GMX_LCORE
4279 r = ssDmndQPutLast(&tTsk->sTsk->dQ, mBuf,
4280 ((prior * SS_MAX_MSG_PRI) + tempPst.prior));
4281 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
4283 extern Bool g_usettitmr;
4286 if (tTsk->sTsk->tskPrior == PRIOR0)
4288 SsTTskEntry *srctTsk;
4289 srctTsk = &osCp.tTskTbl[srcIdx];
4290 if ((srctTsk->sTsk == tTsk->sTsk)
4291 #if defined(SPLIT_RLC_DL_TASK) && !defined(RLC_MAC_DAT_REQ_RBUF)
4293 ((pst->dstEnt == ENTMAC) &&
4294 (pst->srcEnt == ENTRLC) &&
4295 (pst->event == EVTRGUDDATREQ))
4298 #ifdef RGL_SPECIFIC_CHANGES
4299 WLS_WakeUp(mtGetWlsHdl());
4305 else if (tTsk->sTsk->tskPrior == PRIOR0)
4306 #ifdef RGL_SPECIFIC_CHANGES
4307 WLS_WakeUp(mtGetWlsHdl());
4314 if(tTsk->actvTsk != NULLP)
4316 if(tTsk->cbTsk != NULLP)
4318 r = rbICorePstTsk(&tempPst, mBuf, tTsk);
4322 r = rbICorePstTsk(pst, mBuf, tTsk);
4332 /* ss006.13: addition */
4333 #ifndef TENB_RTLIN_CHANGES
4334 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4336 #if (ERRCLASS & ERRCLS_DEBUG)
4337 SSLOGERROR(ERRCLS_DEBUG, ESS525, ERRZERO,
4338 "Could not release the semaphore");
4345 #if (ERRCLASS & ERRCLS_ADD_RES)
4346 SSLOGERROR(ERRCLS_ADD_RES, ESS526, (ErrVal) r,
4347 "Could not write to demand queue");
4354 /* unlock, we're done */
4355 /* ss006.13: addition */
4356 #ifndef TENB_RTLIN_CHANGES
4357 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4359 #if (ERRCLASS & ERRCLS_DEBUG)
4360 SSLOGERROR(ERRCLS_DEBUG, ESS527, ERRZERO,
4361 "Could not release the semaphore");
4368 /* If the implementation has anything to do... note that
4369 * we call it unlocked at this time.
4371 ssdPstTsk(tempPst, mBuf, tTsk);
4376 /* ss001.301: additions */
4377 #ifdef SS_HISTOGRAM_SUPPORT
4380 * fun : SGetTapaTskEntIds
4382 * Desc: Get the tapa task entity id, which are registerd for SSI.
4385 * RFAILED - failed, general (optional)
4386 * ROUTRES - failed, out of resources (optional)
4393 /* ss029.103: modification: procId added */
4396 S16 SGetTapaTskEntIds
4398 Ent *ent /* entity */
4401 S16 SGetTapaTskEntIds(ent)
4402 Ent *ent; /* entity */
4408 /* Get the tapa task entity Ids from the osCp structure */
4409 for(tskCnt = 0; tskCnt < osCp.numTTsks; tskCnt++)
4411 ent[tskCnt] = osCp.tTskTbl[tskCnt].ent;
4415 } /* SGetTapaTskEntIds */
4419 * Fun: SRegForHstGrm
4421 * Desc: This function is used to register a TAPA task,
4422 * for histogram facilty.
4425 * RFAILED - failed, general (optional)
4426 * ROUTRES - failed, out of resources (optional)
4433 /* ss029.103: modification: procId added */
4438 Ent ent /* entity */
4441 S16 SRegForHstGrm(ent)
4442 Ent ent; /* entity */
4450 SS_ACQUIRE_SEMA(&osCp.tTskTblSem, r);
4453 #if (ERRCLASS & ERRCLS_DEBUG)
4454 SSLOGERROR(ERRCLS_DEBUG, ESS623, ERRZERO,
4455 "Could not lock TAPA task table");
4461 for(tskCnt = 0; tskCnt < osCp.numTTsks; tskCnt++)
4463 if(osCp.tTskTbl[tskCnt].ent == ent)
4465 osCp.tTskTbl[tskCnt].hstReg = TRUE;
4470 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
4472 #if (ERRCLASS & ERRCLS_DEBUG)
4473 SSLOGERROR(ERRCLS_DEBUG, ESS639, ERRZERO,
4474 "Could not release the semaphore");
4480 } /* SGetTapaTskEntIds */
4484 * Fun: SGetHstGrmInfo
4486 * Desc : Get the Histogram registration for TAPA task
4489 * RFAILED - failed, general (optional)
4490 * ROUTRES - failed, out of resources (optional)
4501 Bool *hstReg /* entity */
4504 S16 SGetHstGrmInfo(entId, hstReg)
4506 Bool *hstReg; /* entity */
4514 for(tskCnt = 0; tskCnt < osCp.numTTsks; tskCnt++)
4516 if( *entId == osCp.tTskTbl[tskCnt].ent)
4518 *hstReg = osCp.tTskTbl[tskCnt].hstReg;
4531 } /* SGetTapaTskEntIds */
4533 #endif /* SS_HISTOGRAM_SUPPORT */
4542 S16 SInitWatchdog(port)
4546 return ssdInitWatchDog(port);
4556 WdUserCallback callback,
4560 S16 SRegCfgWd(numNodes, addr, port, timeout, callback, data)
4565 WdUserCallback callback;
4569 Txt prntBuf[PRNTSZE];
4572 /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
4574 osCp.wdCp.globWd.timeout = timeout;
4575 osCp.wdCp.globWd.callback = callback;
4576 osCp.wdCp.globWd.data = data;
4577 osCp.wdCp.globWd.numNodes = numNodes;
4579 SLock(&osCp.wdCp.wdLock);
4580 for(i = 0; i < SS_MAX_WD_NODES && i < numNodes; i++)
4582 #ifdef SS_WATCHDOG_IPV6
4583 /* ss002.301 Modifications */
4584 inet_pton(AF_INET6,(const char *)addr[i],osCp.wdCp.globWd.wdsta[i].addr);
4586 osCp.wdCp.globWd.wdsta[i].addr.s_addr = inet_addr((const char *)addr[i]);
4587 #endif /* SS_WATCHDOG_IPV6 */
4588 osCp.wdCp.globWd.wdsta[i].port = htons(port[i]);
4589 sprintf(prntBuf, "Configured [%s:%d] for watchdog\n", addr[i], port[i]);
4592 SUnlock(&osCp.wdCp.wdLock);
4593 /* ss002.301 Compilation fixes */
4594 /*ss013.301: Fixed Warnings for 32/64 bit compilation*/
4596 sprintf(prntBuf, "Configured %d nodes with timeout %u for Watchdog\n", osCp.wdCp.globWd.numNodes, osCp.wdCp.globWd.timeout);
4598 sprintf(prntBuf, "Configured %d nodes with timeout %lu for Watchdog\n", osCp.wdCp.globWd.numNodes, osCp.wdCp.globWd.timeout);
4611 S16 SDeregCfgWd(void)
4615 Txt prntBuf[PRNTSZE];
4618 /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/
4620 osCp.wdCp.globWd.timeout = 0;
4621 osCp.wdCp.globWd.callback = 0;
4622 osCp.wdCp.globWd.data = 0;
4623 osCp.wdCp.globWd.numNodes = 0;
4625 SLock(&osCp.wdCp.wdLock);
4626 for(i = 0; i < SS_MAX_WD_NODES; i++)
4628 /* ss002.301 Modifications */
4629 sprintf(prntBuf, "Deregister [%s:%d] for watchdog\n", inet_ntoa(osCp.wdCp.globWd.wdsta[i
4630 ].addr), osCp.wdCp.globWd.wdsta[i].port);
4631 osCp.wdCp.globWd.wdsta[i].addr.s_addr = 0;
4632 osCp.wdCp.globWd.wdsta[i].port = 0;
4635 SUnlock(&osCp.wdCp.wdLock);
4637 /* Implicit watchdog stop during dereg */
4646 U8 timeInterval /* time interval */
4649 S16 SStartHrtBt(timeInterval)
4654 ssdStartWatchDgTmr(NULLP, SS_TMR_HRTBT, timeInterval);
4655 ssdSndHrtBtMsg(TRUE, SS_WD_HB_REQ);
4671 osCp.wdCp.globWd.watchdogStop = 1;
4679 Pst *pst, /* post */
4680 Buffer *mBuf /* message buffer */
4683 S16 watchDgActvTsk(pst, mBuf)
4684 Pst *pst; /* post */
4685 Buffer *mBuf; /* message buffer */
4688 /* ss002.301 Fixed warnings */
4691 Txt prntBuf[PRNTSZE];
4696 sprintf(prntBuf,"watchDgActvTsk: Time: %02d:%02d:%02d\n",dt.hour,dt.min, dt.sec
4704 S16 watchDgRcvrActvTsk
4706 Pst *pst, /* post */
4707 Buffer *mBuf /* message buffer */
4710 S16 watchDgRcvrActvTsk(pst, mBuf)
4711 Pst *pst; /* post */
4712 Buffer *mBuf; /* message buffer */
4718 Txt prntBuf[PRNTSZE];
4721 struct sockaddr_in tmpaddr;
4722 Txt hbMsg[SS_WD_HB_MSG_SIZE];
4723 /* ss002.301 Modifications */
4725 socklen_t socklen = sizeof(struct sockaddr);
4727 int socklen = sizeof(struct sockaddr);
4733 sprintf(prntBuf,"watchDgRcvrActvTsk: Time: %02d:%02d:%02d\n",dt.hour, dt.min, dt.sec);
4737 while(!osCp.wdCp.globWd.watchdogStop)
4739 err = recvfrom(osCp.wdCp.globWd.sock, hbMsg, SS_WD_HB_MSG_SIZE, 0, (struct sockaddr *)&tmpaddr, &socklen);
4742 sprintf(prntBuf,"watchDgRcvrActvTsk: recvfrom failed, errno %d\n", errno);
4747 if(strcmp(hbMsg, "<HB>REQ</HB>") == 0)
4749 /* Send back the reply */
4751 sprintf(prntBuf,"watchDgRcvrActvTsk: Recvd HB REQ message from [%s:%d]\n", inet_ntoa(tmpaddr.sin_addr), ntohs(tmpaddr.sin_port));
4755 strcpy(hbMsg, "<HB>RSP</HB>");
4756 sendto(osCp.wdCp.globWd.sock, hbMsg, strlen(hbMsg), 0, (struct sockaddr *)&tmpaddr, sizeof(tmpaddr));
4758 else if(strcmp(hbMsg, "<HB>RSP</HB>") == 0)
4760 /* Got a HB RSP, set the status for the correcponding node */
4762 sprintf(prntBuf,"watchDgRcvrActvTsk: Recvd HB RSP message from [%s:%d]\n", inet_ntoa(tmpaddr.sin_addr), ntohs(tmpaddr.sin_port));
4766 SLock(&osCp.wdCp.wdLock);
4767 for(n = 0; n < osCp.wdCp.globWd.numNodes; n++)
4769 if(osCp.wdCp.globWd.wdsta[n].addr.s_addr == tmpaddr.sin_addr.s_addr)
4771 osCp.wdCp.globWd.wdsta[n].status = 1;
4774 SUnlock(&osCp.wdCp.wdLock);
4779 sprintf(prntBuf,"watchDgRcvrActvTsk: Rcvd invalid message\n");
4787 #endif /* SS_WATCHDOG */
4789 /* ss002.301 Modifications */
4790 #ifdef SS_THREAD_PROFILE
4795 * Desc: This function gets the current profile of a system task
4796 * The function sets the Entity, Instance, Event and time taken
4797 * for that thread to execurte the activate function of
4801 * RFAILED - failed, general (optional)
4803 * Notes: This function may be called by the OS or Layer 1
4809 #ifdef SS_MULTIPLE_PROCS
4815 Ent ent, /* entity */
4822 S16 SGetThrdProf(sTskId, procId, ent, inst, evnt, curEvent, curEvtTime, totTime)
4825 Ent ent; /* entity */
4836 Ent ent, /* entity */
4843 S16 SGetThrdProf(sTskId, ent, inst, curEvent,curEvtTime, totTime)
4845 Ent ent; /* entity */
4851 #endif /* SS_MULTIPLE_PROCS */
4856 #ifdef SS_MULTIPLE_PROCS
4862 #if (ERRCLASS & ERRCLS_INT_PAR)
4863 /* check entity and instance range */
4864 #ifdef SS_MULTIPLE_PROCS
4865 /* check proc, entity and instance range */
4866 if ((procId == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST))
4868 SSLOGERROR(ERRCLS_INT_PAR, ESS463, ERRZERO, "Invalid processor/entity/instance");
4871 #else /* SS_MULTIPLE_PROCS */
4872 /* check entity and instance range */
4873 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
4875 SSLOGERROR(ERRCLS_INT_PAR, ESS464, ERRZERO, "Invalid entity/instance");
4878 #endif /* SS_MULTIPLE_PROCS */
4882 ret = SLock(&osCp.sTskTblLock);
4889 #ifdef SS_MULTIPLE_PROCS
4890 procIdIdx = SGetProcIdIdx(procId);
4892 if (procIdIdx == SS_INV_PROCID_IDX)
4897 idx = osCp.tTskIds[procIdIdx][ent][inst];
4898 #else /* SS_MULTIPLE_PROCS */
4899 idx = osCp.tTskIds[ent][inst];
4900 #endif /* SS_MULTIPLE_PROCS */
4902 tTsk = &osCp.tTskTbl[idx];
4905 SUnlock(&osCp.sTskTblLock);
4908 *curEvent = osCp.tTskTbl[idx].curEvent;
4909 *curEvtTime = osCp.tTskTbl[idx].curEvtTime;
4910 *totTime = osCp.tTskTbl[idx].totTime;
4911 *sTskId = osCp.tTskTbl[idx].sTsk->tskId;
4913 SUnlock(&osCp.sTskTblLock);
4916 #endif /* SS_THREAD_PROFILE */
4918 #ifdef SS_FBSED_TSK_REG
4923 * Desc: This function is used to register tasks based on cfg file.
4926 * RFAILED - failed, general (optional)
4938 S16 SRegTskInfo(cfgFile)
4942 return cmCfgrTskReg(cfgFile);
4944 #endif /* SS_FBSED_TSK_REG */
4946 /**********************************************************************
4948 **********************************************************************/