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 -- Timing
25 Desc: Source code for System Services related to timing.
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_msg.h" /* messaging */
45 #include "ss_mem.h" /* memory management interface */
46 #include "ss_gen.h" /* general */
47 #include "cm_mem.h" /* memory management */
51 /* header/extern include files (.x) */
53 #include "gen.x" /* general layer */
54 #include "ssi.x" /* system services */
56 #include "ss_dep.x" /* implementation-specific */
57 #include "ss_queue.x" /* queues */
58 #include "ss_task.x" /* tasking */
59 #include "ss_timer.x" /* timers */
60 #include "ss_strm.x" /* STREAMS */
61 #include "ss_msg.x" /* messaging */
62 #include "ss_mem.x" /* memory management interface */
63 #include "ss_drvr.x" /* driver tasks */
64 #ifdef SS_LOCKLESS_MEMORY
67 #include "cm_mem_wl.x" /* common memory manager */
69 #include "cm_mem.x" /* common memory manager */
70 #endif /* SS_LOCKLESS_MEMORY */
71 #include "ss_gen.x" /* general */
74 /* Forward declarations */
76 /* ss041.103 Declaration for STmrRegHndlr */
77 /* ss015.301 Changed the timer activation function type as all timer activation
78 * functions are enclosed in a union.
80 #ifndef SS_MULTIPLE_PROCS
81 PRIVATE S16 STmrRegHndlr ARGS((
86 SsTmrActvFn ssTmrActvFn
88 /* ss015.301: Removed the timer handler prototypes guarded under SS_MT_TMR and
89 * handled mtFlag in existing timer handlers.
91 #else /* SS_MULTIPLE_PROCS */
92 PRIVATE S16 STmrRegHndlr ARGS((
98 SsTmrActvFn ssTmrActvFn
100 #endif /* SS_MULTIPLE_PROCS */
102 /* ss041.103 Declaration for STmrDeregHndlr */
103 #ifndef SS_MULTIPLE_PROCS
104 PRIVATE S16 STmrDeregHndlr ARGS((
109 SsTmrActvFn ssTmrActvFn
111 /* ss015.301 Removed the timer handler prototypes guarded under SS_MT_TMR and
112 * handled mtFlag in existing timer handlers.
114 #else /* SS_MULTIPLE_PROCS */
115 PRIVATE S16 STmrDeregHndlr ARGS((
121 SsTmrActvFn ssTmrActvFn
123 #endif /* SS_MULTIPLE_PROCS */
127 /* ss028.103 - Modification for SRegCfgTmr Support */
130 * Fun: Register Configurable Timer Task - timer
132 * Desc: This function is used to register a timer function for the
133 * layer. The system services will periodically invoke the
134 * function passed to it. The timer function will be used by the
135 * layer to manage the layers internal protocol timers.
138 * RFAILED - failed, general (optional)
139 * ROUTRES - failed, out of resources (optional)
146 /* ss029.103: addition: procId added and timer function type modified */
147 #ifndef SS_MULTIPLE_PROCS
149 PUBLIC S16 SRegCfgTmr
151 Ent ent, /* entity */
152 Inst inst, /* instance */
153 S16 period, /* period */
154 S16 units, /* period units */
155 PFS16 tmrFnct /* timer function, typically SActvTmr */
158 PUBLIC S16 SRegCfgTmr(ent, inst, period, units, tmrFnct)
159 Ent ent; /* entity */
160 Inst inst; /* instance */
161 S16 period; /* period */
162 S16 units; /* period units*/
163 PFS16 tmrFnct; /* timer function, typically SActvTmr */
167 /* ss015.301 - Enclosed all timer activation functions in a union. */
168 SsTmrActvFn ssTmrActvFn;
169 /* ss041.103 - Moved handling to STmrRegHndlr */
173 ssTmrActvFn.mtFlag = FALSE;
174 ssTmrActvFn.actvFnc.tmrActvFn = tmrFnct;
175 ret = STmrRegHndlr(ent, inst, period, units, ssTmrActvFn);
180 #else /* SS_MULTIPLE_PROCS */
183 PUBLIC S16 SRegCfgTmr
185 ProcId proc, /* processor */
186 Ent ent, /* entity */
187 Inst inst, /* instance */
188 S16 period, /* period */
189 S16 units, /* period units */
190 PAIFTMRS16 tmrFnct /* timer function, typically SActvTmr */
193 PUBLIC S16 SRegCfgTmr(proc, ent, inst, period, units, tmrFnct)
194 ProcId proc; /* processor */
195 Ent ent; /* entity */
196 Inst inst; /* instance */
197 S16 period; /* period */
198 S16 units; /* period units*/
199 PAIFTMRS16 tmrFnct; /* timer function, typically SActvTmr */
204 /* ss015.301 - Enclosed all timer activation functions in a union. */
205 SsTmrActvFn ssTmrActvFn;
206 /* ss041.103 - Moved handling to STmrRegHndlr */
210 ssTmrActvFn.mtFlag = FALSE;
211 ssTmrActvFn.actvFnc.tmrActvFn = tmrFnct;
212 ret = STmrRegHndlr(proc, ent, inst, period, units, ssTmrActvFn);
217 #endif /* SS_MULTIPLE_PROCS */
220 #ifndef SS_MULTIPLE_PROCS
221 /* ss041.103 - New function for MT timer reg */
225 * Fun: Register Configurable Timer Task - timer
227 * Desc: This function is used to register a timer function for the
228 * layer. The system services will periodically invoke the
229 * function passed to it. The timer function will be used by the
230 * layer to manage the layers internal protocol timers.
233 * RFAILED - failed, general (optional)
234 * ROUTRES - failed, out of resources (optional)
236 * Notes: By invoking this function, Ent and Inst are passed in the
237 * timer activation function.
243 PUBLIC S16 SRegCfgTmrMt
245 Ent ent, /* entity */
246 Inst inst, /* instance */
247 S16 period, /* period */
248 S16 units, /* period units */
249 PAIFTMRS16 tmrFnctMt /* timer function, typically SActvTmr */
252 PUBLIC S16 SRegCfgTmrMt(ent, inst, period, units, tmrFnctMt)
253 Ent ent; /* entity */
254 Inst inst; /* instance */
255 S16 period; /* period */
256 S16 units; /* period units*/
257 PAIFTMRS16 tmrFnctMt; /* timer function, typically SActvTmr */
261 /* ss015.301 - Enclosed all timer activation functions in a union. */
262 SsTmrActvFn ssTmrActvFn;
266 ssTmrActvFn.actvFnc.tmrActvFnMt = tmrFnctMt;
267 ssTmrActvFn.mtFlag = TRUE;
268 ret = STmrRegHndlr(ent, inst, period, units, ssTmrActvFn);
272 #endif /* SS_MT_TMR */
273 #endif /* not SS_MULTIPLE_PROCS */
275 /* ss041.103 - Function for timer registration handling */
278 * Fun: Timer registration handler function
280 * Desc: This function is called by the timer registration interface
281 * functions, and does the actual handling for timer
285 * RFAILED - failed, general (optional)
286 * ROUTRES - failed, out of resources (optional)
294 /* ss015.301 Changed the timer activation function type as all timer activation
295 * functions are enclosed in a union.
298 #ifndef SS_MULTIPLE_PROCS
301 PRIVATE S16 STmrRegHndlr
303 Ent ent, /* entity */
304 Inst inst, /* instance */
305 S16 period, /* period */
306 S16 units, /* period units */
307 SsTmrActvFn ssTmrActvFn /* timer function, typically SActvTmr */
310 PRIVATE S16 STmrRegHndlr(ent, inst, period, units, ssTmrActvFn)
311 Ent ent; /* entity */
312 Inst inst; /* instance */
313 S16 period; /* period */
314 S16 units; /* period units*/
315 SsTmrActvFn ssTmrActvFn; /* timer function, typically SActvTmr */
317 /* ss015.301: Removed the timer handler prototypes guarded
318 * under SS_MT_TMR and handled mtFlag in existing timer handlers.
321 #else /* SS_MULTIPLE_PROCS */
324 PRIVATE S16 STmrRegHndlr
326 ProcId proc, /* processor */
327 Ent ent, /* entity */
328 Inst inst, /* instance */
329 S16 period, /* period */
330 S16 units, /* period units */
331 SsTmrActvFn ssTmrActvFn /* timer function */
334 PRIVATE S16 STmrRegHndlr(proc, ent, inst, period, units, ssTmrActvFn)
335 ProcId proc; /* processor */
336 Ent ent; /* entity */
337 Inst inst; /* instance */
338 S16 period; /* period */
339 S16 units; /* period units*/
340 SsTmrActvFn ssTmrActvFn; /* timer function */
343 #endif /* SS_MULTIPLE_PROCS */
345 #if (ERRCLASS & ERRCLS_INT_PAR)
350 #ifdef SS_MULTIPLE_PROCS
351 #if (ERRCLASS & ERRCLS_INT_PAR)
353 #endif /* ERRCLASS & ERRCLS_INT_PAR */
354 #endif /* SS_MULTPLE_PROCS */
358 #if (ERRCLASS & ERRCLS_INT_PAR)
360 #ifdef SS_MULTIPLE_PROCS
361 if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST))
363 SSLOGERROR(ERRCLS_INT_PAR, ESS528, ERRZERO, "Invalid processor/entity/instance");
366 #else /* SS_MULTIPLE_PROCS */
367 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
369 SSLOGERROR(ERRCLS_INT_PAR, ESS529, ERRZERO, "Invalid entity/instance");
372 #endif /* SS_MULTIPLE_PROCS */
377 SSLOGERROR(ERRCLS_INT_PAR, ESS530, ERRZERO, "Invalid period");
381 /* check period units*/
382 if ((units < 1) || (units > SS_TICKS_SEC))
384 SSLOGERROR(ERRCLS_INT_PAR, ESS531, ERRZERO, "Invalid period units");
388 if(ssTmrActvFn.mtFlag == TRUE)
390 /* ss015.301 Enclosed all timer activation functions in a union. */
391 #ifndef SS_MULTIPLE_PROCS
393 if (ssTmrActvFn.actvFnc.tmrActvFnMt == NULLP)
395 SSLOGERROR(ERRCLS_INT_PAR, ESS532, ERRZERO, "Null pointer");
407 if (ssTmrActvFn.actvFnc.tmrActvFn == NULLP)
409 SSLOGERROR(ERRCLS_INT_PAR, ESS532, ERRZERO, "Null pointer");
414 #ifdef SS_MULTIPLE_PROCS
415 /* check if the procId has been registered with SSI */
416 procIdIdx = SGetProcIdIdx(proc);
418 if (procIdIdx == SS_INV_PROCID_IDX)
420 SSLOGERROR(ERRCLS_INT_PAR, ESS533, ERRZERO,
421 "Could not find proc id index");
424 #endif /* SS_MULTIPLE_PROCS */
428 /* lock TAPA task table */
429 SS_ACQUIRE_SEMA(&osCp.tTskTblSem, ret);
432 SSLOGERROR(ERRCLS_DEBUG, ESS534, ERRZERO,
433 "Could not lock TAPA task table");
437 #ifdef SS_MULTIPLE_PROCS
438 if (osCp.tTskIds[procIdIdx][ent][inst] == SS_TSKNC)
439 #else /* SS_MULTIPLE_PROCS */
440 if (osCp.tTskIds[ent][inst] == SS_TSKNC)
441 #endif /* SS_MULTIPLE_PROCS */
443 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
445 #if (ERRCLASS & ERRCLS_DEBUG)
446 SSLOGERROR(ERRCLS_DEBUG, ESS535, ERRZERO,
447 "Could not release the semaphore");
451 SSLOGERROR(ERRCLS_INT_PAR, ESS536, ERRZERO, "Unknown task");
454 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
456 #if (ERRCLASS & ERRCLS_DEBUG)
457 SSLOGERROR(ERRCLS_DEBUG, ESS537, ERRZERO,
458 "Could not release the semaphore");
465 /* lock the timer table */
466 ret = SLock(&osCp.tmrTblLock);
470 #if (ERRCLASS & ERRCLS_DEBUG)
471 SSLOGERROR(ERRCLS_DEBUG, ESS538, (ErrVal) ret,
472 "Could not lock timer table");
478 /* check if we've got room for another timer */
479 if (osCp.numTmrs == SS_MAX_TMRS)
481 if ( SUnlock(&osCp.tmrTblLock) != ROK)
483 #if (ERRCLASS & ERRCLS_DEBUG)
484 SSLOGERROR(ERRCLS_DEBUG, ESS539, ERRZERO,
485 "Could not unlock the semaphore");
490 #if (ERRCLASS & ERRCLS_DEBUG)
491 SSLOGERROR(ERRCLS_DEBUG, ESS540, ERRZERO, "Too many timers");
497 #if (ERRCLASS & ERRCLS_INT_PAR)
498 /* check through the timer table for a matching timer entry */
499 for (i = 0; i < SS_MAX_TMRS; i++)
501 if ((osCp.tmrTbl[i].ownerEnt == ent)
502 #ifdef SS_MULTIPLE_PROCS
503 && (osCp.tmrTbl[i].ownerProc == proc)
504 #endif /* SS_MULTIPLE_PROCS */
505 && (osCp.tmrTbl[i].ownerInst == inst)
506 /* ss041.103 - Added mtFlag check */
507 /* ss015.301 Enclosed all timer activation functions in a union. */
508 #ifndef SS_MULTIPLE_PROCS
510 && (osCp.tmrTbl[i].ssTmrActvFn.mtFlag == ssTmrActvFn.mtFlag)
511 && ((ssTmrActvFn.mtFlag == FALSE
512 && osCp.tmrTbl[i].ssTmrActvFn.actvFnc.tmrActvFn == ssTmrActvFn.actvFnc.tmrActvFn)
513 || osCp.tmrTbl[i].ssTmrActvFn.actvFnc.tmrActvFnMt == ssTmrActvFn.actvFnc.tmrActvFnMt)
515 && (osCp.tmrTbl[i].ssTmrActvFn.actvFnc.tmrActvFn == ssTmrActvFn.actvFnc.tmrActvFn)
518 && (osCp.tmrTbl[i].ssTmrActvFn.actvFnc.tmrActvFn == ssTmrActvFn.actvFnc.tmrActvFn)
520 && (osCp.tmrTbl[i].interval == (U32) ((period * SS_TICKS_SEC) / units)))
522 /* is this timer in use ? (unexpired) */
523 if (osCp.tmrTbl[i].used == TRUE)
525 /* to prevent the same timer to be registered with SS UNLOCK and */
527 if (SUnlock(&osCp.tmrTblLock) != ROK)
529 #if (ERRCLASS & ERRCLS_DEBUG)
530 SSLOGERROR(ERRCLS_DEBUG, ESS541, ERRZERO, "Could not unlock the semaphore");
540 /* fill in the information we have into the timer entry */
541 tmr = &osCp.tmrTbl[osCp.nxtTmrEntry];
542 tmr->tmrId = osCp.nxtTmrEntry;
543 #ifdef SS_MULTIPLE_PROCS
544 tmr->ownerProc = proc;
545 #endif /* SS_MULTIPLE_PROCS */
547 tmr->ownerInst = inst;
548 tmr->interval = (U32) ((period * SS_TICKS_SEC) / units);
549 tmr->ssTmrActvFn.mtFlag = ssTmrActvFn.mtFlag;
552 /* ss015.301 Enclosed all timer activation functions in a union. */
553 #ifndef SS_MULTIPLE_PROCS
555 if (ssTmrActvFn.mtFlag == TRUE)
557 tmr->ssTmrActvFn.actvFnc.tmrActvFnMt = ssTmrActvFn.actvFnc.tmrActvFnMt;
563 tmr->ssTmrActvFn.actvFnc.tmrActvFn = ssTmrActvFn.actvFnc.tmrActvFn;
567 /* ask the implementation to start the timer */
568 ret = ssdRegTmr(tmr);
572 #ifdef SS_MULTIPLE_PROCS
573 tmr->ownerProc = PROCNC;
574 #endif /* SS_MULTIPLE_PROCS */
575 tmr->ownerEnt = ENTNC;
576 tmr->ownerInst = INSTNC;
578 /* ss015.301 Enclosed all timer activation functions in a union. */
579 tmr->ssTmrActvFn.mtFlag = FALSE;
580 tmr->ssTmrActvFn.actvFnc.tmrActvFn = NULLP;
581 #ifndef SS_MULTIPLE_PROCS
583 tmr->ssTmrActvFn.actvFnc.tmrActvFnMt = NULLP;
590 osCp.nxtTmrEntry = tmr->nxt;
595 /* unlock the timer table */
596 if ( SUnlock(&osCp.tmrTblLock) != ROK)
598 #if (ERRCLASS & ERRCLS_DEBUG)
599 SSLOGERROR(ERRCLS_DEBUG, ESS542, ERRZERO,
600 "Could not unlock the semaphore");
614 * Desc: This function is used to deregister a timer function.
617 * RFAILED - failed, general (optional)
624 /* ss029.103: addition: procId added and timer function type modified */
625 #ifndef SS_MULTIPLE_PROCS
628 PUBLIC S16 SDeregCfgTmr
630 Ent ent, /* entity */
631 Inst inst, /* instance */
632 S16 period, /* period */
633 S16 units, /* period units */
634 PFS16 tmrFnct /* timer function */
637 PUBLIC S16 SDeregCfgTmr(ent, inst, period, units, tmrFnct)
638 Ent ent; /* entity */
639 Inst inst; /* instance */
640 S16 period; /* period */
641 S16 units; /* period units*/
642 PFS16 tmrFnct; /* timer function */
646 /* ss015.301 Enclosed all timer activation functions in a union. */
647 SsTmrActvFn ssTmrActvFn;
648 /* ss041.103 - Moved handling to STmrDeregHndlr */
652 ssTmrActvFn.mtFlag = FALSE;
653 ssTmrActvFn.actvFnc.tmrActvFn = tmrFnct;
654 ret = STmrDeregHndlr(ent, inst, period, units, ssTmrActvFn);
659 #else /* SS_MULTIPLE_PROCS */
662 PUBLIC S16 SDeregCfgTmr
664 ProcId proc, /* processor */
665 Ent ent, /* entity */
666 Inst inst, /* instance */
667 S16 period, /* period */
668 S16 units, /* period units */
669 PAIFTMRS16 tmrFnct /* timer function */
672 PUBLIC S16 SDeregCfgTmr(proc, ent, inst, period, units, tmrFnct)
673 ProcId proc; /* processor */
674 Ent ent; /* entity */
675 Inst inst; /* instance */
676 S16 period; /* period */
677 S16 units; /* period units*/
678 PAIFTMRS16 tmrFnct; /* timer function */
682 /* ss015.301 Enclosed all timer activation functions in a union. */
683 SsTmrActvFn ssTmrActvFn;
685 /* ss041.103 - Moved handling to STmrDeregHndlr */
689 ssTmrActvFn.mtFlag = FALSE;
690 ssTmrActvFn.actvFnc.tmrActvFn = tmrFnct;
691 ret = STmrDeregHndlr(proc, ent, inst, period, units, ssTmrActvFn);
696 #endif /* SS_MULTIPLE_PROCS */
699 /* ss041.103 - Addition to support MT timer dereg */
700 #ifndef SS_MULTIPLE_PROCS
704 * Fun: SDeregCfgTmrMt
706 * Desc: This function is used to deregister an MT timer function.
709 * RFAILED - failed, general (optional)
717 PUBLIC S16 SDeregCfgTmrMt
719 Ent ent, /* entity */
720 Inst inst, /* instance */
721 S16 period, /* period */
722 S16 units, /* period units */
723 PAIFTMRS16 tmrFnctMt /* timer function */
726 PUBLIC S16 SDeregCfgTmrMt(ent, inst, period, units, tmrFnctMt)
727 Ent ent; /* entity */
728 Inst inst; /* instance */
729 S16 period; /* period */
730 S16 units; /* period units*/
731 PAIFTMRS16 tmrFnctMt; /* timer function */
735 /* ss015.301 Enclosed all timer activation functions in a union. */
736 SsTmrActvFn ssTmrActvFn;
738 TRC1(SDeregCfgTmrMt);
740 ssTmrActvFn.actvFnc.tmrActvFnMt = tmrFnctMt;
741 ssTmrActvFn.mtFlag = TRUE;
743 ret = STmrDeregHndlr(ent, inst, period, units, ssTmrActvFn);
747 #endif /* SS_MT_TMR */
748 #endif /* not SS_MULTIPLE_PROCS */
751 /* ss041.103 - Addition of STmrDeregHndlr */
754 * Fun: STmrDeregHndlr
756 * Desc: This function is used to deregister a timer function.
759 * RFAILED - failed, general (optional)
766 /* ss029.103: addition: procId added and timer function type modified */
768 /* ss015.301 Changed the timer activation function type as all timer activation
769 * functions are enclosed in a union.
771 #ifndef SS_MULTIPLE_PROCS
773 PRIVATE S16 STmrDeregHndlr
775 Ent ent, /* entity */
776 Inst inst, /* instance */
777 S16 period, /* period */
778 S16 units, /* period units */
779 SsTmrActvFn ssTmrActvFn /* timer function */
782 /* ss017.301: Modified the prototype of STmrDeregHndlr for Non-ANSI
785 PRIVATE S16 STmrDeregHndlr(ent, inst, period, units, ssTmrActvFn)
786 Ent ent; /* entity */
787 Inst inst; /* instance */
788 S16 period; /* period */
789 S16 units; /* period units*/
790 SsTmrActvFn ssTmrActvFn; /* timer function */
792 /* ss015.301: Removed the timer handler prototypes guarded under SS_MT_TMR
793 * and handled mtFlag in existing timer handlers.
796 #else /* SS_MULTIPLE_PROCS */
799 PRIVATE S16 STmrDeregHndlr
801 ProcId proc, /* processor */
802 Ent ent, /* entity */
803 Inst inst, /* instance */
804 S16 period, /* period */
805 S16 units, /* period units */
806 SsTmrActvFn ssTmrActvFn /* timer function */
809 PRIVATE S16 STmrDeregHndlr(proc, ent, inst, period, units, ssTmrActvFn)
810 ProcId proc; /* processor */
811 Ent ent; /* entity */
812 Inst inst; /* instance */
813 S16 period; /* period */
814 S16 units; /* period units*/
815 SsTmrActvFn ssTmrActvFn; /* timer function */
818 #endif /* SS_MULTIPLE_PROCS */
823 #ifdef SS_MULTIPLE_PROCS
824 #if (ERRCLASS & ERRCLS_INT_PAR)
826 #endif /* ERRCLASS & ERRCLS_INT_PAR */
827 #endif /* SS_MULTIPLE_PROCS */
830 TRC1(STmrDeregHndlr);
833 #if (ERRCLASS & ERRCLS_INT_PAR)
835 #ifdef SS_MULTIPLE_PROCS
836 if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST))
838 SSLOGERROR(ERRCLS_INT_PAR, ESS543, ERRZERO, "Invalid processor/entity/instance");
842 #else /* SS_MULTIPLE_PROCS */
843 if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST)
845 SSLOGERROR(ERRCLS_INT_PAR, ESS544, ERRZERO, "Invalid entity/instance");
848 #endif /* SS_MULTIPLE_PROCS */
852 SSLOGERROR(ERRCLS_INT_PAR, ESS545, ERRZERO, "Invalid period");
856 /* check period units */
857 if ((units < 1) || (units > SS_TICKS_SEC))
859 SSLOGERROR(ERRCLS_INT_PAR, ESS546, ERRZERO, "Invalid period units");
863 /* check timer function */
864 if(ssTmrActvFn.mtFlag == TRUE)
866 #ifndef SS_MULTIPLE_PROCS
868 if (ssTmrActvFn.actvFnc.tmrActvFnMt == NULLP)
870 SSLOGERROR(ERRCLS_INT_PAR, ESS547, ERRZERO, "Null pointer");
883 if (ssTmrActvFn.actvFnc.tmrActvFn == NULLP)
885 SSLOGERROR(ERRCLS_INT_PAR, ESS547, ERRZERO, "Null pointer");
890 #ifdef SS_MULTIPLE_PROCS
891 /* check if the procId has been registered with SSI */
892 procIdIdx = SGetProcIdIdx(proc);
894 if (procIdIdx == SS_INV_PROCID_IDX)
896 SSLOGERROR(ERRCLS_INT_PAR, ESS548, ERRZERO,
897 "Could not find proc id index");
900 #endif /* SS_MULTIPLE_PROCS */
903 /* lock TAPA task table */
904 SS_ACQUIRE_SEMA(&osCp.tTskTblSem, ret);
907 SSLOGERROR(ERRCLS_DEBUG, ESS549, ERRZERO,
908 "Could not lock TAPA task table");
912 #ifdef SS_MULTIPLE_PROCS
913 if (osCp.tTskIds[procIdIdx][ent][inst] == SS_TSKNC)
914 #else /* SS_MULTIPLE_PROCS */
915 if (osCp.tTskIds[ent][inst] == SS_TSKNC)
916 #endif /* SS_MULTIPLE_PROCS */
918 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
920 #if (ERRCLASS & ERRCLS_DEBUG)
921 SSLOGERROR(ERRCLS_DEBUG, ESS550, ERRZERO,
922 "Could not release the semaphore");
926 SSLOGERROR(ERRCLS_INT_PAR, ESS551, ERRZERO, "Unknown task");
929 if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK)
931 #if (ERRCLASS & ERRCLS_DEBUG)
932 SSLOGERROR(ERRCLS_DEBUG, ESS552, ERRZERO,
933 "Could not release the semaphore");
940 /* lock the timer table */
941 ret = SLock(&osCp.tmrTblLock);
945 #if (ERRCLASS & ERRCLS_DEBUG)
946 SSLOGERROR(ERRCLS_DEBUG, ESS553, (ErrVal) ret,
947 "Could not lock timer table");
953 /* Note: Right now, we're using ent, inst and tmrActvFn to locate
954 * the timer,, this will change to using tmrId, some day.
957 /* locate the timer to delete in the timer table */
958 for (idx = 0; idx < SS_MAX_TMRS; idx++)
960 /* ss021.103 - Modification find timer by ent, inst, func, and period */
961 /* ss029.103: addition: multiple procId related changes */
962 if (osCp.tmrTbl[idx].ownerEnt == ent
963 #ifdef SS_MULTIPLE_PROCS
964 && osCp.tmrTbl[idx].ownerProc == proc
965 #endif /* SS_MULTIPLE_PROCS */
966 && osCp.tmrTbl[idx].ownerInst == inst
967 #ifndef SS_MULTIPLE_PROCS
970 * ss015.301 - Modifed as timer activation functions
971 * enclosed in a union.
973 && osCp.tmrTbl[idx].ssTmrActvFn.mtFlag == ssTmrActvFn.mtFlag
974 && ((ssTmrActvFn.mtFlag == FALSE
975 && osCp.tmrTbl[idx].ssTmrActvFn.actvFnc.tmrActvFn == ssTmrActvFn.actvFnc.tmrActvFn)
976 || osCp.tmrTbl[idx].ssTmrActvFn.actvFnc.tmrActvFnMt == ssTmrActvFn.actvFnc.tmrActvFnMt)
978 && osCp.tmrTbl[idx].ssTmrActvFn.actvFnc.tmrActvFn == ssTmrActvFn.actvFnc.tmrActvFn
981 && osCp.tmrTbl[idx].ssTmrActvFn.actvFnc.tmrActvFn == ssTmrActvFn.actvFnc.tmrActvFn
983 && osCp.tmrTbl[idx].interval == (U32) ((period * SS_TICKS_SEC) / units))
989 if (idx == SS_MAX_TMRS)
991 if ( SUnlock(&osCp.tmrTblLock) != ROK)
993 #if (ERRCLASS & ERRCLS_DEBUG)
994 SSLOGERROR(ERRCLS_DEBUG, ESS554, ERRZERO,
995 "Could not unlock the semaphore");
1000 #if (ERRCLASS & ERRCLS_DEBUG)
1001 SSLOGERROR(ERRCLS_DEBUG, ESS555, ERRZERO, "Could not locate timer");
1008 /* ask the implementation to shut down this timer */
1009 tmr = &osCp.tmrTbl[idx];
1010 ret = ssdDeregTmr(tmr);
1015 #ifdef SS_MULTIPLE_PROCS
1016 tmr->ownerProc = PROCNC;
1017 #endif /* SS_MULTIPLE_PROCS */
1018 tmr->ownerEnt = ENTNC;
1019 tmr->ownerInst = INSTNC;
1022 * ss015.301: Modifed as timer activation functions enclosed in a union.
1024 tmr->ssTmrActvFn.mtFlag = FALSE;
1025 tmr->ssTmrActvFn.actvFnc.tmrActvFn = NULLP;
1026 #ifndef SS_MULTIPLE_PROCS
1028 tmr->ssTmrActvFn.actvFnc.tmrActvFnMt = NULLP;
1032 tmr->nxt = osCp.nxtTmrEntry;
1033 osCp.nxtTmrEntry = (SsIdx)idx;
1038 /* unlock the timer table */
1039 if ( SUnlock(&osCp.tmrTblLock) != ROK)
1041 #if (ERRCLASS & ERRCLS_DEBUG)
1042 SSLOGERROR(ERRCLS_DEBUG, ESS556, ERRZERO,
1043 "Could not unlock the semaphore");
1052 /**********************************************************************
1054 **********************************************************************/