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 -- general functions
25 Desc: Source code for System Services startup and general
30 *********************************************************************21*/
33 /* header include files (.h) */
37 #include "envopt.h" /* environment options */
38 #include "envdep.h" /* environment dependent */
39 #include "envind.h" /* environment independent */
41 #include "gen.h" /* general layer */
42 #include "ssi.h" /* system services */
44 #include "ss_err.h" /* errors */
45 #include "ss_dep.h" /* implementation-specific */
46 #include "ss_queue.h" /* queues */
47 #include "ss_task.h" /* tasking */
48 #include "ss_msg.h" /* messaging */
49 #include "ss_mem.h" /* memory management interface */
50 #include "ss_gen.h" /* general */
51 /*ss013.301: Fixed Warnings for 32/64 bit compilation*/
52 #ifdef SS_FBSED_TSK_REG
54 #endif /* SS_FBSED_TSK_REG */
57 /* ss001.301: additions */
58 #include "cm_mem.h" /* memory management */
60 /* header/extern include files (.x) */
62 #include "gen.x" /* general layer */
63 #include "ssi.x" /* system services */
65 #include "ss_dep.x" /* implementation-specific */
66 #include "ss_queue.x" /* queues */
67 #include "ss_task.x" /* tasking */
68 #include "ss_timer.x" /* timers */
69 #include "ss_strm.x" /* STREAMS */
70 #include "ss_msg.x" /* messaging */
71 #include "ss_mem.x" /* memory management interface */
72 #include "ss_drvr.x" /* driver tasks */
73 #ifdef SS_LOCKLESS_MEMORY
76 #include "cm_mem_wl.x" /* common memory manager */
78 #include "cm_mem.x" /* common memory manager */
79 #endif /* SS_LOCKLESS_MEMORY */
80 #include "ss_gen.x" /* general */
81 /* ss001.301: additions */
82 #ifdef SS_LOGGER_SUPPORT
84 #endif /* SS_LOGGER_SUPPORT */
85 #ifdef SS_MULTICORE_SUPPORT
89 #include "cm_mem_wl.x"
93 /* Cavium Changes:ss004.301 */
95 #include "cvmx-config.h"
97 #endif /* SS_SEUM_CAVIUM */
99 /*ss011.301 : RMIOS release related changes*/
103 /*ss013.301: Fixed Warnings for 32/64 bit compilation*/
104 #ifdef SS_FBSED_TSK_REG
106 #endif /* SS_FBSED_TSK_REG */
109 /* public variable declarations */
111 /*ss014.301: SSI-4GMX related changes*/
113 PUBLIC VOLATILE SsOs osCp; /* common OS control point */
115 PUBLIC SsOs osCp; /* common OS control point */
119 EXTERN Cntr cfgNumRegs;
120 EXTERN SsRegCfg cfgRegInfo[SS_MAX_REGS];
123 /* ss029.103: modification: multiple procId related changes */
124 #ifdef SS_MULTIPLE_PROCS
125 /* PRIVATE functions */
126 PRIVATE S16 SInsProcId ARGS((ProcId proc));
127 PRIVATE S16 SRemProcId ARGS((ProcId proc));
128 PRIVATE S16 SLockOsCp ARGS((Void));
129 PRIVATE S16 SULockOsCp ARGS((Void));
130 #endif /* SS_MULTIPLE_PROCS */
132 #ifdef SSI_STATIC_MEM_LEAK_DETECTION
133 PRIVATE void InitializeForStaticMemLeak ARGS((void));
134 PRIVATE void InitializeStaticMemAllocInfo ARGS((StaticMemAllocInfo* memAllocInfo));
135 PUBLIC U32 GetNextFreeIdx ARGS((StaticMemAllocInfo * memAllocInfo));
136 PUBLIC void FreeIdx ARGS((U8* ptr, U32 idx, StaticMemAllocInfo* memAllocInfo,U32 size, char*
138 PUBLIC void LogForStaticMemLeak ARGS((StaticMemAllocInfo* memAllocInfo, char* file,
139 U32 line, U32 size, void* ptr, U32 idx));
140 PRIVATE void PrintStaticMemAllocInfo ARGS((StaticMemAllocInfo* memAllocInfo, FILE
143 /* ss001.301: additions */
145 PUBLIC void DumpSSIDemandQDebugInformation()
148 RTLIN_DUMP_DEBUG("Demand Q Information\n");
149 RTLIN_DUMP_DEBUG("====================\n");
150 for(i = 0; i < osCp.numSTsks; i++)
152 SsSTskEntry* tskEntry = &(osCp.sTskTbl[i]);
154 for(j = 0; j < SS_MAX_NUM_DQ; j++)
157 RTLIN_DUMP_DEBUG("Task[%lu] Q[%lu] QSize = %lu region=%d\n", i, j, tskEntry->dQ.queue[j].crntSize,tskEntry->region);
159 RTLIN_DUMP_DEBUG("Task[%u] Q[%u] QSize = %u region=%d\n", i, j, tskEntry->dQ.queue[j].crntSize,tskEntry->region);
165 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
166 pthread_mutex_t dumpingLock = PTHREAD_MUTEX_INITIALIZER;
168 PUBLIC Void mtSigSegvHndlr()
172 printf("Backtrace for thread Id (%lu) total threads = %d\n", (unsigned long) pthread_self(), osCp.numSTsks);
174 for(i = 0; i < osCp.numSTsks; i++)
176 SsSTskEntry* tskEntry = &(osCp.sTskTbl[i]);
177 if((tskEntry->dep.tId != pthread_self()) && (tskEntry->dep.tId != 0))
179 pthread_kill(tskEntry->dep.tId, SIGUSR2);
186 PUBLIC Void mtSigUsr2Hndlr()
188 printf("Backtrace for thread Id (%lu) cause:SIGUSR2(%d)\n",(unsigned long) pthread_self(),SIGUSR2);
190 pthread_mutex_lock(&dumpingLock);
192 pthread_mutex_unlock(&dumpingLock);
204 * Fun: System Services initialization function
206 * Desc: This is the general initialization function for
207 * all System Services implementations. It initializes
208 * all the common global data structures and calls the
209 * implementation-specific initialization and start
236 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
237 Txt prntBufLoc[1000];
238 #ifdef SS_DRVR_SUPPORT
239 SsDrvrTskEntry *drvrTsk;
241 /* ss002.301 : Modications */
244 osCp.configFilePath = "/mnt/tmp/configFile";
246 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
248 /* ss019.103 - Modified for correct initialization of OS control point */
249 /* start initializing OS control point */
250 /* ss029.103: modification: multiple procId related changes */
251 #ifndef SS_MULTIPLE_PROCS
252 /* ss004.301: Cavium changes */
253 #ifdef SS_SEUM_CAVIUM
254 osCp.procId = cvmx_get_core_num();
256 osCp.procId = SS_PROC_ID;
257 #endif /* SS_SEUM_CAVIUM */
258 #else /* SS_MULTIPLE_PROCS */
259 for (i = 0; i < SS_MAX_PROCS; i++)
260 osCp.procLst.procId[i] = PROCNC;
262 osCp.procLst.free = SS_MAX_PROCS;
263 #endif /* SS_MULTIPLE_PROCS */
265 #ifdef SS_THR_REG_MAP
266 cmMemset(osCp.threadMemoryRegionMap, SS_INVALID_THREAD_REG_MAP,
267 (sizeof(Region) * SS_MAX_THREAD_REGION_MAP));
271 /* implementation specific general initialization */
275 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
276 sprintf(prntBufLoc,"\n SInit(): ssdInitGen failed to initialize\
277 implementation specific general information \n");
278 SDisplay(1,prntBufLoc);
282 #ifdef SSI_STATIC_MEM_LEAK_DETECTION
283 InitializeForStaticMemLeak();
285 /* initialize memory information */
288 for (i = 0; i < SS_MAX_REGS; i++)
290 reg = &osCp.regionTbl[i];
301 /* ss007.301 initializing the per region mBufRefLock */
302 SInitLock(®->mBufRefLock, SS_LOCK_MUTEX);
304 /* zero the pool information */
306 for (j = 0; j < SS_MAX_POOLS_PER_REG; j++)
307 reg->poolTbl[j].type = SS_POOL_UND;
309 /* find this region ID in the region configuration structure */
310 for (j = 0; j < cfgNumRegs; j++)
311 if (cfgRegInfo[j].region == i)
314 /* this region is not configured */
318 /* Load the configuration information into the region table.
319 * Note, the region still has to be registered, for it to
322 for (k = 0; k < cfgRegInfo[j].numPools; k++)
324 reg->poolTbl[k].type = cfgRegInfo[j].pools[k].type;
325 if (reg->poolTbl[k].type == SS_POOL_DYNAMIC)
326 reg->poolTbl[k].u.dpool.size = cfgRegInfo[j].pools[k].size;
330 /* Initialization of dynamic regions */
331 for (i = 0; i < SS_MAX_REGS; i++)
333 reg = &osCp.dynRegionTbl[i];
344 /* ss007.301 initializing the per region mBufRefLock */
345 SInitLock(®->mBufRefLock, SS_LOCK_MUTEX);
347 /* zero the pool information */
349 for (j = 0; j < SS_MAX_POOLS_PER_REG; j++)
350 reg->poolTbl[j].type = SS_POOL_UND;
352 /* find this region ID in the region configuration structure */
353 for (j = 0; j < cfgNumRegs; j++)
354 if (cfgRegInfo[j].region == i)
357 /* this region is not configured */
361 /* Load the configuration information into the region table.
362 * Note, the region still has to be registered, for it to
365 for (k = 0; k < cfgRegInfo[j].numPools; k++)
367 reg->poolTbl[k].type = cfgRegInfo[j].pools[k].type;
368 if (reg->poolTbl[k].type == SS_POOL_DYNAMIC)
369 reg->poolTbl[k].u.dpool.size = cfgRegInfo[j].pools[k].size;
373 ret = ssInitSema(&osCp.regionTblSem, SS_MAX_STSKS);
376 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
377 sprintf(prntBufLoc,"\n SInit(): Could not initialize the region Table Semaphore \n");
378 SDisplay(1,prntBufLoc);
382 /* implementation specific memory initialization */
386 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
387 sprintf(prntBufLoc,"\n SInit(): Memory initialization failed \n");
388 SDisplay(1,prntBufLoc);
393 /* initialize TAPA and system task information */
394 /* ss029.103: modification: multiple procId related changes */
395 #ifndef SS_MULTIPLE_PROCS
396 for (i = 0; i < SS_MAX_ENT; i++)
397 for (j = 0; j < SS_MAX_INST; j++)
398 osCp.tTskIds[i][j] = SS_TSKNC;
399 #else /* SS_MULTIPLE_PROCS */
400 for (i = 0; i < SS_MAX_PROCS; i++)
401 for (j = 0; j < SS_MAX_ENT; j++)
402 for (k = 0; k < SS_MAX_INST; k++)
403 osCp.tTskIds[i][j][k] = SS_TSKNC;
404 #endif /* SS_MULTIPLE_PROCS */
406 for (i = 0; i < SS_MAX_TTSKS; i++)
408 tTsk = &osCp.tTskTbl[i];
413 tTsk->tskType = TTUND;
415 tTsk->initTsk = NULLP;
416 tTsk->actvTsk = NULLP;
418 /* ss029.103: addition: TAPA task control block added */
419 #ifdef SS_MULTIPLE_PROCS
421 #endif /* SS_MULTIPLE_PROCS */
427 osCp.nxtTTskEntry = 0;
429 ret = ssInitSema(&osCp.tTskTblSem, SS_MAX_STSKS);
432 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
433 sprintf(prntBufLoc,"\n SInit(): Could not initialize the tTask table Semaphore \n");
434 SDisplay(1,prntBufLoc);
438 #ifdef SS_MULTICORE_SUPPORT
439 /* check whether number of system tasks is
440 * equal to number of (regions-1).
441 * The last region is meant for timer task
442 * which under the current feature has as entry
443 * in system task table.
445 if(SS_MAX_STSKS > SS_MAX_REGS)
447 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
452 /* initialize system task information */
453 for (i = 0; i < SS_MAX_STSKS; i++)
455 sTsk = &osCp.sTskTbl[i];
458 sTsk->termPend = FALSE;
460 for (j = 0; j < SS_MAX_TTSKS; j++)
461 sTsk->tTsks[j] = SS_INVALID_IDX;
465 /* ss002.301 : Modifications */
466 #ifdef SS_MULTICORE_SUPPORT
469 sTsk->region = (SS_MAX_REGS - 1);
479 osCp.nxtSTskEntry = 0;
481 ret = SInitLock(&osCp.sTskTblLock, SS_STSKTBL_LOCK);
484 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
485 sprintf(prntBufLoc,"\n SInit(): Could not initialize the tTask table Semaphore \n");
486 SDisplay(1,prntBufLoc);
490 /* ss028.103 - Addition of lock for mBuf reference count */
491 /* ss007.301 moving the mBufRefLock from common to per region */
492 /* SInitLock(&osCp.mBufRefLock, SS_LOCK_MUTEX);*/
494 /* implementation specific task initialization */
498 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
499 sprintf(prntBufLoc,"\n SInit(): implementation specific task initialization Failed \n");
500 SDisplay(1,prntBufLoc);
504 #ifdef SS_DRVR_SUPPORT
505 /* initialize driver task information */
506 for (i = 0; i < SS_MAX_DRVRTSKS; i++)
508 drvrTsk = &osCp.drvrTskTbl[i];
510 drvrTsk->used = FALSE;
512 drvrTsk->channel = 0;
513 drvrTsk->actvTsk = NULLP;
514 drvrTsk->isTsk = NULLP;
519 osCp.numDrvrTsks = 0;
521 /* implementation specific driver initialization */
525 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
526 sprintf(prntBufLoc,"\n SInit(): ssdInitDrvr failed \n");
527 SDisplay(1,prntBufLoc);
532 /*ss004.301: Cavium Changes */
533 #ifdef SS_SEUM_CAVIUM
534 ret = ssInitRcvWork();
537 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
540 #endif /* SS_SEUM_CAVIUM */
543 /* initialize the demand queue lookup table */
544 osCp.dmndQLookupTbl[0] = 255;
545 osCp.dmndQLookupTbl[1] = 0;
546 osCp.dmndQLookupTbl[2] = 1;
547 osCp.dmndQLookupTbl[3] = 1;
548 for (i = 4; i < 256; i++)
550 if (i >= 128 && i <= 255)
551 osCp.dmndQLookupTbl[i] = 7;
552 if (i >= 64 && i <= 127)
553 osCp.dmndQLookupTbl[i] = 6;
554 if (i >= 32 && i <= 63)
555 osCp.dmndQLookupTbl[i] = 5;
556 if (i >= 16 && i <= 31)
557 osCp.dmndQLookupTbl[i] = 4;
558 if (i >= 8 && i <= 15)
559 osCp.dmndQLookupTbl[i] = 3;
560 if (i >= 4 && i <= 7)
561 osCp.dmndQLookupTbl[i] = 2;
565 /* initialize timer information */
566 for (i = 0; i < SS_MAX_TMRS; i++)
568 tmr = &osCp.tmrTbl[i];
572 tmr->ownerEnt = ENTNC;
573 tmr->ownerInst = INSTNC;
576 * ss015.301 - Modifed in initialization as timer activation
577 * functions enclosed in a union. Also initialized the mtFlag
580 tmr->ssTmrActvFn.actvFnc.tmrActvFn = NULLP;
581 #ifndef SS_MULTIPLE_PROCS
583 tmr->ssTmrActvFn.mtFlag = FALSE;
584 tmr->ssTmrActvFn.actvFnc.tmrActvFnMt = NULLP;
591 osCp.nxtTmrEntry = 0;
593 ret = SInitLock(&osCp.tmrTblLock, SS_TMRTBL_LOCK);
596 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
600 /* implementation specific timer initialization */
604 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
605 sprintf(prntBufLoc,"\n SInit(): Could not initialize the timer \n");
606 SDisplay(1,prntBufLoc);
610 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
611 /* ss005.201: Initialize logging streams */
612 /* implementation specific logging initialization */
616 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
617 sprintf(prntBufLoc,"\n SInit(): Could not initialize the Logging streams \n");
618 SDisplay(1,prntBufLoc);
622 #ifdef SS_LOGGER_SUPPORT /* ss001.301: additions */
623 /* Initialize the lock, return on failure */
624 if( SInitLock(&(osCp.logger.bufLock),SS_LOCK_MUTEX) != ROK)
626 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
627 sprintf(prntBufLoc,"\n SInit(): Could not initialize the Logger Buffer Lock \n");
628 SDisplay(1,prntBufLoc);
632 /* Initialize the logger configuration flag */
633 osCp.logger.configured = FALSE;
634 /* Ss002.301 : Initialised */
635 osCp.logger.started = FALSE;
636 #endif /* SS_LOGGER_SUPPORT */
637 /* ss001.301: additions */
639 #ifdef SS_HISTOGRAM_SUPPORT
640 /* Here we are filling all the tapa entity Ids, which will be
641 * helpful to get the entity Id using file name. */
643 #endif /* SS_HISTOGRAM_SUPPORT */
646 #ifdef SS_FBSED_TSK_REG
647 /* Configure task registration based on the configuration */
648 /*ss013.301 : Fixed warnings for 32/64 bit compilation*/
649 cmCfgrTskReg((U8 *)"task_info.t");
650 #endif /* SS_FBSED_TSK_REG */
652 /*ss011.301 : RMIOS release related changes*/
657 /* call tst() function */
661 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
666 /* call implementation-specific starter function */
674 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
676 #ifdef SS_LOGGER_SUPPORT
677 /* ss005.301: Deinitialize the logging at the end */
678 SDestroyLock(&(osCp.logger.bufLock));
679 /*ss013.301 : Fix for compile time warning*/
681 #endif /* SS_LOGGER_SUPPORT */
686 SDestroyLock(&osCp.tmrTblLock);
689 #ifdef SS_DRVR_SUPPORT
695 SDestroyLock(&osCp.sTskTblLock);
697 if ( (ssDestroySema(&osCp.tTskTblSem)) != ROK)
699 #if (ERRCLASS & ERRCLS_DEBUG)
700 SSLOGERROR(ERRCLS_DEBUG, ESS012, ERRZERO,
701 "Could not destroy the Semaphore");
702 /* ss005.301: Changes, clean the threads and exit */
709 /* ss007.301 destroying the per region mBufRefLock */
710 for (i= 0;i<SS_MAX_REGS;i++)
712 SDestroyLock(&osCp.regionTbl[i].mBufRefLock);
714 /* ss006.13: addition */
715 if ( (ssDestroySema(&osCp.regionTblSem)) != ROK)
717 #if (ERRCLASS & ERRCLS_DEBUG)
718 SSLOGERROR(ERRCLS_DEBUG, ESS013, ERRZERO,
719 "Could not destroy the Semaphore");
720 /* ss005.301: Changes, clean the threads and exit */
731 /* ss033.103: Added SDeInit API to free all the resources */
734 * Fun: System Services de-initialization function
736 * Desc: This is the de-initialization function for System
737 * Services implementations. It releases all the common
738 * global data structures.
763 SDestroyLock(&osCp.tmrTblLock);
765 #ifdef SS_DRVR_SUPPORT
770 SDestroyLock(&osCp.sTskTblLock);
772 if ((ssDestroySema(&osCp.tTskTblSem)) != ROK)
774 #if (ERRCLASS & ERRCLS_DEBUG)
775 SSLOGERROR(ERRCLS_DEBUG, ESS014, ERRZERO,
776 "Could not destroy the Semaphore");
784 if ((ssDestroySema(&osCp.regionTblSem)) != ROK)
786 #if (ERRCLASS & ERRCLS_DEBUG)
787 SSLOGERROR(ERRCLS_DEBUG, ESS015, ERRZERO,
788 "Could not destroy the Semaphore");
795 /* ss007.301 destroying the per region mBufRefLock */
796 for (regCnt = 0; regCnt < SS_MAX_REGS; regCnt++)
798 SDestroyLock(&osCp.regionTbl[regCnt].mBufRefLock);
801 /* ss005.301: Deinitialize the logging at the end */
802 #ifdef SS_LOGGER_SUPPORT
803 SDestroyLock(&(osCp.logger.bufLock));
804 #endif /* SS_LOGGER_SUPPORT */
809 /* ss001.301: additions */
810 #ifdef SS_LOGGER_SUPPORT
812 PUBLIC S16 SWrtLogBuf
814 Txt *buf /* buffer */
817 PUBLIC S16 SWrtLogBuf(buf)
818 Txt *buf; /* buffer */
823 /* buffer synchronisation*/
824 bufSz = cmStrlen((U8 *)buf);
825 SLock(&osCp.logger.bufLock);
826 if(osCp.logger.started == FALSE)
828 (Void)SUnlock(&(osCp.logger.bufLock));
832 * Append the buffer to the global buffer
833 * and increment the current buffer size of the global buffer
835 if(((osCp.logger.curBufSiz) + bufSz) >= osCp.logger.maxBufSiz)
837 SFlushBufToLog(osCp.logger.buffer);
838 osCp.logger.curBufSiz = 0;
839 cmMemset((U8 *)osCp.logger.buffer, '\0', osCp.logger.maxBufSiz);
840 sprintf(osCp.logger.buffer, "%s", buf);
841 osCp.logger.curBufSiz += bufSz;
845 strcat(osCp.logger.buffer,buf);
846 osCp.logger.curBufSiz += bufSz;
848 (Void)SUnlock(&(osCp.logger.bufLock));
851 #endif /* SS_LOGGER_SUPPORT */
856 * Desc: Print a string.
858 * This function should be used for debugging only.
862 * Notes: Text buffer should be null terminated.
864 * SDisplay will replace SPrint.
866 * Typical usage consists of a call to sprintf to
867 * format the string into a buffer followed by a
876 Txt *buf /* buffer */
879 PUBLIC S16 SPrint(buf)
880 Txt *buf; /* buffer */
885 /* ss001.301: additions */
887 #ifdef SS_LOGGER_SUPPORT
889 #endif /* SS_LOGGER_SUPPORT */
893 } /* end of SPrint */
900 * Desc: Invoked by layer when an unrecoverable
901 * software error is detected. This function should
914 Seq seq, /* sequence */
915 Reason reason /* reason */
918 PUBLIC S16 SError(seq, reason)
919 Seq seq; /* sequence */
920 Reason reason; /* reason */
932 sprintf(errBuf, "\n\ndate: %02d/%02d/%04d time: %02d:%02d:%02d\n",
933 (int)dt.month,(int)dt.day,(int)dt.year + 1900,
934 (int)dt.hour,(int)dt.min,(int)dt.sec);
938 ret = ssdError(seq, reason);
949 * Desc: Invoked by layer to log an error.
959 PUBLIC Void SLogError
961 Ent ent, /* Calling layer's entity id */
962 Inst inst, /* Calling layer's instance id */
963 ProcId procId, /* Calling layer's processor id */
964 Txt *file, /* file name where error occured */
965 S32 line, /* line in file where error occured */
966 ErrCls errCls, /* error class */
967 ErrCode errCode, /* layer unique error code */
968 ErrVal errVal, /* error value */
969 Txt *errDesc /* description of error */
972 PUBLIC Void SLogError(ent, inst, procId, file, line,
973 errCls, errCode, errVal, errDesc)
974 Ent ent; /* Calling layer's entity id */
975 Inst inst; /* Calling layer's instance id */
976 ProcId procId; /* Calling layer's processor id */
977 Txt *file; /* file name where error occured */
978 S32 line; /* line in file where error occured */
979 ErrCls errCls; /* error class */
980 ErrCode errCode; /* layer unique error code */
981 ErrVal errVal; /* error value */
982 Txt *errDesc; /* description of error */
991 /*ss014.301: SSI-4GMX related changes*/
992 #ifndef SS_4GMX_LCORE
994 sprintf(errBuf, "\n\ndate: %02d/%02d/%04d time: %02d:%02d:%02d\n",
995 (int)dt.month,(int)dt.day,(int)dt.year + 1900,
996 (int)dt.hour,(int)dt.min,(int)dt.sec);
1000 /* ss001.301: additions */
1001 #ifdef SS_LOGGER_SUPPORT
1003 #endif /* SS_LOGGER_SUPPORT */
1005 ssdLogError(ent, inst, procId, file, line,
1006 errCls, errCode, errVal, errDesc);
1012 /* ss029.103: modification:
1013 SFndProcId function is not supported with multiple procIds */
1014 #ifndef SS_MULTIPLE_PROCS
1020 * Desc: This function finds the local processor ID.
1022 * Ret: local processor id
1030 PUBLIC ProcId SFndProcId
1035 PUBLIC ProcId SFndProcId()
1040 RETVALUE(osCp.procId);
1041 } /* end of SFndProcId */
1048 * Desc: This function stores the local processor ID.
1058 PUBLIC Void SSetProcId
1063 PUBLIC Void SSetProcId(procId)
1069 osCp.procId = procId;
1074 #endif /* SS_MULTIPLE_PROCS */
1076 /* ss029.103: addition: New SSI functions with multiple proc support */
1077 #ifdef SS_MULTIPLE_PROCS
1081 * Fun: SGetProcIdIdx
1083 * Desc: This function finds index of procId in the process id table
1093 PUBLIC U16 SGetProcIdIdx
1098 PUBLIC U16 SGetProcIdIdx(proc)
1105 TRC1(SGetProcIdIdx);
1107 idx = SS_HASH_IDX(proc);
1109 for (i = idx; i < SS_MAX_PROCS; i++)
1110 if (osCp.procLst.procId[i] == proc)
1113 /* search upto idx */
1114 for (i = 0; i < idx; i++)
1115 if (osCp.procLst.procId[i] == proc)
1118 RETVALUE(SS_INV_PROCID_IDX);
1119 } /* SGetProcIdIdx */
1126 * Desc: This function inserts procId in the process id table
1136 PRIVATE S16 SInsProcId
1141 PRIVATE S16 SInsProcId(proc)
1150 idx = SS_HASH_IDX(proc);
1152 for (i = idx; i < SS_MAX_PROCS; i++)
1153 if (osCp.procLst.procId[i] == SS_INV_PROCID)
1155 osCp.procLst.procId[i] = proc;
1156 osCp.procLst.free--;
1160 /* search for free entry upto idx */
1161 for (i = 0; i < idx; i++)
1162 if (osCp.procLst.procId[i] == SS_INV_PROCID)
1164 osCp.procLst.procId[i] = proc;
1165 osCp.procLst.free--;
1177 * Desc: This function inserts procId in the process id table
1187 PRIVATE S16 SRemProcId
1192 PRIVATE S16 SRemProcId(proc)
1201 idx = SS_HASH_IDX(proc);
1203 for (i = idx; i < SS_MAX_PROCS; i++)
1204 if (osCp.procLst.procId[i] == proc)
1206 osCp.procLst.procId[i] = SS_INV_PROCID;
1207 osCp.procLst.free++;
1211 /* search upto idx */
1212 for (i = 0; i < idx; i++)
1213 if (osCp.procLst.procId[i] == proc)
1215 osCp.procLst.procId[i] = SS_INV_PROCID;
1216 osCp.procLst.free++;
1228 * Desc: This function locks OsCp
1238 PRIVATE S16 SLockOsCp
1243 PRIVATE S16 SLockOsCp(Void)
1250 ret = SLock(&osCp.sTskTblLock);
1253 SSLOGERROR(ERRCLS_DEBUG, ESS016, ERRZERO,
1254 "Could not lock system task table");
1258 SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret);
1262 #if (ERRCLASS & ERRCLS_DEBUG)
1263 SSLOGERROR(ERRCLS_DEBUG, ESS017, ERRZERO,
1264 "Could not lock TAPA task table");
1267 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1269 #if (ERRCLASS & ERRCLS_DEBUG)
1270 SSLOGERROR(ERRCLS_DEBUG, ESS018, ERRZERO,
1271 "Could not give the Semaphore");
1288 * Desc: This function locks OsCp
1298 PRIVATE S16 SULockOsCp
1303 PRIVATE S16 SULockOsCp(Void)
1308 /* unlock the table */
1309 SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem);
1311 if ( SUnlock(&osCp.sTskTblLock) != ROK)
1313 #if (ERRCLASS & ERRCLS_DEBUG)
1314 SSLOGERROR(ERRCLS_DEBUG, ESS019, ERRZERO,
1315 "Could not give the Semaphore");
1328 * Fun: SAddProcIdLst
1330 * Desc: This function adds given proc ids to the list
1340 PUBLIC S16 SAddProcIdLst
1346 PUBLIC S16 SAddProcIdLst(numPIds, pIdLst)
1354 TRC1(SAddProcIdLst);
1356 #if (ERRCLASS & ERRCLS_INT_PAR)
1358 if (numPIds > SS_MAX_PROCS)
1360 SSLOGERROR(ERRCLS_INT_PAR, ESS020, ERRZERO, "number of proc Ids exceeds\
1365 /* find if the entry exist in the table */
1366 for (i = 0; i < numPIds; i++)
1368 if (pIdLst[i] == SS_INV_PROCID)
1370 SSLOGERROR(ERRCLS_INT_PAR, ESS021, ERRZERO, "Invalid proc Ids");
1377 if (SLockOsCp() != ROK)
1380 #if (ERRCLASS & ERRCLS_INT_PAR)
1381 for (i = 0; i < numPIds; i++)
1382 if (SGetProcIdIdx(pIdLst[i]) != SS_INV_PROCID_IDX)
1384 SSLOGERROR(ERRCLS_INT_PAR, ESS022, ERRZERO, "Duplicate proc id");
1385 (Void) SULockOsCp();
1389 if (numPIds > osCp.procLst.free)
1391 SSLOGERROR(ERRCLS_INT_PAR, ESS023, ERRZERO, "Total number of proc id \
1393 (Void) SULockOsCp();
1398 /* insert the entries in the table */
1401 for (i = 0; i < numPIds; i++)
1403 if (SInsProcId(pIdLst[i]) == RFAILED)
1405 #if (ERRCLASS & ERRCLS_DEBUG)
1406 SSLOGERROR(ERRCLS_DEBUG, ESS024, ERRZERO,
1407 "Could not insert the proc id");
1409 (Void) SULockOsCp();
1414 /* unlock the table */
1415 if (SULockOsCp() != ROK)
1419 } /* SAddProcIdLst */
1424 * Fun: SRemProcIdLst
1426 * Desc: This function adds given proc ids to the list
1436 PUBLIC S16 SRemProcIdLst
1442 PUBLIC S16 SRemProcIdLst(numPIds, pIdLst)
1449 TRC1(SRemProcIdLst);
1451 #if (ERRCLASS & ERRCLS_INT_PAR)
1453 if (numPIds > SS_MAX_PROCS)
1457 if (SLockOsCp() != ROK)
1460 if (numPIds > (SS_MAX_PROCS - osCp.procLst.free))
1462 (Void) SULockOsCp();
1466 /* find if the entry exist in the table */
1467 for (i = 0; i < numPIds; i++)
1469 if (SGetProcIdIdx(pIdLst[i]) == SS_INV_PROCID_IDX)
1471 (Void) SULockOsCp();
1476 /* insert the entries in the table */
1477 for (i = 0; i < numPIds; i++)
1478 SRemProcId(pIdLst[i]);
1480 if (SULockOsCp() != ROK)
1484 } /* SRemProcIdLst */
1489 * Fun: SGetProcIdLst
1491 * Desc: This function retrieves proc Id list
1501 PUBLIC S16 SGetProcIdLst
1507 PUBLIC S16 SGetProcIdLst(numPIds, pIdLst)
1515 TRC1(SGetProcIdLst);
1517 #if (ERRCLASS & ERRCLS_INT_PAR)
1518 if ((numPIds == NULLP) || (pIdLst == NULLP))
1520 SSLOGERROR(ERRCLS_INT_PAR, ESS025, ERRZERO, "Invalid numPIds/pIdLst");
1525 if (SLockOsCp() != ROK)
1528 for (i = 0; i < SS_MAX_PROCS; i++)
1530 if (osCp.procLst.procId[i] != PROCNC)
1531 pIdLst[count++] = osCp.procLst.procId[i];
1536 if (SULockOsCp() != ROK)
1543 } /* SGetProcIdLst */
1550 * Desc: This function retrieves protocol layer control block for given proc,
1569 PUBLIC S16 SGetXxCb(proc, ent, inst, xxCb)
1581 #if (ERRCLASS & ERRCLS_INT_PAR)
1582 if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST))
1584 SSLOGERROR(ERRCLS_INT_PAR, ESS026, ERRZERO, "Invalid proc/entity/instance");
1590 * ss030.103: delete: locking/unlocking removed as it causes
1591 * deadlock/blockage in some cases
1594 procIdIdx = SGetProcIdIdx(proc);
1596 if (procIdIdx == SS_INV_PROCID_IDX)
1598 #if (ERRCLASS & ERRCLS_INT_PAR)
1599 SSLOGERROR(ERRCLS_INT_PAR, ESS027, ERRZERO, "Could not get proc table idx");
1604 idx = osCp.tTskIds[procIdIdx][ent][inst];
1605 if (idx == SS_TSKNC)
1611 *xxCb = osCp.tTskTbl[idx].xxCb;
1612 /*ss032.103 added a check for NULLP */
1619 #endif /* SS_MULTIPLE_PROCS */
1621 /* ss001.301: additions */
1622 #ifdef SS_HISTOGRAM_SUPPORT
1627 * Desc: It is static data base contains all entity Ids of tapa task.
1628 * This Data base is used to find the entity id using two letter
1629 * prifix product code.
1639 PUBLIC S16 SFillEntIds
1644 PUBLIC S16 SFillEntIds(Void)
1648 U8 entInfo[26][26] = {
1649 /* A B C D E F G H I J K *
1650 L M N O P Q R S T U V *
1652 {ENTAA, ENTAB, ENTAC, ENTNC, ENTAE, ENTAF, ENTNC, ENTAH, ENTNC, ENTNC, ENTNC,
1653 /* A */ ENTAL, ENTAM, ENTNC, ENTNC, ENTAP, ENTAQ, ENTAR, ENTAS, ENTNC, ENTAU, ENTNC,
1654 ENTAW, ENTNC, ENTNC, ENTNC},
1656 /* A B C D E F G H I J K *
1657 L M N O P Q R S T U V *
1659 {ENTNC, ENTNC, ENTNC, ENTBD, ENTNC, ENTNC, ENTNC, ENTNC, ENTBI, ENTNC, ENTNC,
1660 /* B */ ENTNC, ENTBM, ENTNC, ENTNC, ENTNC, ENTNC, ENTBR, ENTBS, ENTNC, ENTNC, ENTBV,
1661 ENTBW, ENTNC, ENTNC, ENTNC},
1662 /* A B C D E F G H I J K *
1663 L M N O P Q R S T U V *
1665 {ENTNC, ENTNC, ENTCC, ENTNC, ENTNC, ENTNC, ENTNC, ENTCH, ENTNC, ENTNC, ENTNC,
1666 /* C */ ENTCL, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTCS, ENTNC, ENTCU, ENTCV,
1667 ENTNC, ENTNC, ENTNC, ENTNC},
1668 /* A B C D E F G H I J K *
1669 L M N O P Q R S T U V *
1671 {ENTNC, ENTDB, ENTNC, ENTNC, ENTNC, ENTNC, ENTDG, ENTNC, ENTDI, ENTNC, ENTDK,
1672 /* D */ ENTNC, ENTDM, ENTDN, ENTNC, ENTDP, ENTNC, ENTNC, ENTNC, ENTDT, ENTDU, ENTDV,
1673 ENTNC, ENTNC, ENTNC, ENTNC},
1674 /* A B C D E F G H I J K *
1675 L M N O P Q R S T U V *
1677 {ENTNC, ENTNC, ENTNC, ENTNC, ENTEC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1678 /* E */ ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTER, ENTES, ENTNC, ENTNC, ENTEV,
1679 ENTNC, ENTNC, ENTNC, ENTNC},
1680 /* A B C D E F G H I J K *
1681 L M N O P Q R S T U V *
1683 {ENTFA, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1684 /* F */ ENTNC, ENTFM, ENTFN, ENTNC, ENTFP, ENTNC, ENTFR, ENTNC, ENTNC, ENTFU, ENTNC,
1685 ENTFW, ENTNC, ENTNC, ENTNC},
1686 /* A B C D E F G H I J K *
1687 L M N O P Q R S T U V *
1689 {ENTGA, ENTGB, ENTGC, ENTGD, ENTGE, ENTGF, ENTGG, ENTGH, ENTGI, ENTNC, ENTNC,
1690 /* G */ ENTGL, ENTGM, ENTGN, ENTGO, ENTGP, ENTNC, ENTGR, ENTGS, ENTGT, ENTGU, ENTNC,
1691 ENTGW, ENTGX, ENTGY, ENTGZ},
1692 /* A B C D E F G H I J K *
1693 L M N O P Q R S T U V *
1695 {ENTNC, ENTNC, ENTHC, ENTNC, ENTHE, ENTNC, ENTHG, ENTNC, ENTHI, ENTNC, ENTNC,
1696 /* H */ ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTHR, ENTHS, ENTNC, ENTHU, ENTNC,
1697 ENTNC, ENTNC, ENTNC, ENTNC},
1698 /* A B C D E F G H I J K *
1699 L M N O P Q R S T U V *
1701 {ENTIA, ENTIB, ENTNC, ENTID, ENTIE, ENTNC, ENTNC, ENTNC, ENTII, ENTNC, ENTNC,
1702 /* I */ ENTNC, ENTIM, ENTIN, ENTNC, ENTNC, ENTIQ, ENTNC, ENTIS, ENTIT, ENTIU, ENTNC,
1703 ENTIW, ENTIX, ENTNC, ENTNC},
1704 /* A B C D E F G H I J K *
1705 L M N O P Q R S T U V *
1707 {ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1708 /* J */ ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1709 ENTNC, ENTNC, ENTNC, ENTNC},
1710 /* A B C D E F G H I J K *
1711 L M N O P Q R S T U V *
1713 {ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1714 /* K */ ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1715 ENTKW, ENTNC, ENTNC, ENTNC},
1716 /* A B C D E F G H I J K *
1717 L M N O P Q R S T U V *
1719 {ENTLA, ENTLB, ENTLC, ENTLD, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTLK,
1720 /* L */ ENTNC, ENTLM, ENTLN, ENTNC, ENTNC, ENTNC, ENTLR, ENTNC, ENTLT, ENTLU, ENTLV,
1721 ENTNC, ENTLX, ENTNC, ENTNC},
1722 /* A B C D E F G H I J K *
1723 L M N O P Q R S T U V *
1725 {ENTMA, ENTNC, ENTMC, ENTMD, ENTME, ENTNC, ENTMG, ENTNC, ENTNC, ENTNC, ENTMK,
1726 /* M */ ENTML, ENTMM, ENTNC, ENTNC, ENTNC, ENTNC, ENTMR, ENTMS, ENTMT, ENTMU, ENTMV,
1727 ENTMW, ENTMX, ENTNC, ENTMZ},
1728 /* A B C D E F G H I J K *
1729 L M N O P Q R S T U V *
1731 {ENTNC, ENTNC, ENTNC, ENTND, ENTNC, ENTNF, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1732 /* N */ ENTNC, ENTNM, ENTNC, ENTNC, ENTNP, ENTNC, ENTNC, ENTNS, ENTNC, ENTNC, ENTNV,
1733 ENTNW, ENTNC, ENTNC, ENTNC},
1734 /* A B C D E F G H I J K *
1735 L M N O P Q R S T U V *
1737 {ENTNC, ENTNC, ENTNC, ENTOD, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1738 /* O */ ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1739 ENTNC, ENTNC, ENTNC, ENTNC},
1740 /* A B C D E F G H I J K *
1741 L M N O P Q R S T U V *
1743 {ENTPA, ENTNC, ENTNC, ENTPD, ENTNC, ENTNC, ENTNC, ENTPH, ENTNC, ENTNC, ENTNC,
1744 /* P */ ENTPL, ENTNC, ENTPN, ENTNC, ENTPN, ENTPQ, ENTPR, ENTNC, ENTNC, ENTPU, ENTPV,
1745 ENTNC, ENTNC, ENTNC, ENTNC},
1746 /* A B C D E F G H I J K *
1747 L M N O P Q R S T U V *
1749 {ENTNC, ENTNC, ENTQC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTQI, ENTNC, ENTNC,
1750 /* Q */ ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1751 ENTQW, ENTNC, ENTNC, ENTNC},
1752 /* A B C D E F G H I J K *
1753 L M N O P Q R S T U V *
1755 {ENTRA, ENTNC, ENTNC, ENTRD, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1756 /* R */ ENTRL, ENTRM, ENTRN, ENTNC, ENTRP, ENTNC, ENTRR, ENTNC, ENTRT, ENTRU, ENTNC,
1757 ENTNC, ENTRX, ENTRY, ENTNC},
1758 /* A B C D E F G H I J K *
1759 L M N O P Q R S T U V *
1761 {ENTSA, ENTSB, ENTSC, ENTSD, ENTSE, ENTSF, ENTSG, ENTSH, ENTSI, ENTNC, ENTNC,
1762 /* S */ ENTNC, ENTSM, ENTSN, ENTSO, ENTSP, ENTNC, ENTSR, ENTSS, ENTST, ENTSU, ENTSV,
1763 ENTNC, ENTNC, ENTNC, ENTSZ},
1764 /* A B C D E F G H I J K *
1765 L M N O P Q R S T U V *
1767 {ENTNC, ENTNC, ENTTC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1768 /* T */ ENTNC, ENTTM, ENTNC, ENTNC, ENTTP, ENTNC, ENTNC, ENTTS, ENTTT, ENTTU, ENTNC,
1769 ENTNC, ENTNC, ENTNC, ENTNC},
1770 /* A B C D E F G H I J K *
1771 L M N O P Q R S T U V *
1773 {ENTNC, ENTNC, ENTNC, ENTUD, ENTNC, ENTNC, ENTNC, ENTUH, ENTNC, ENTNC, ENTNC,
1774 /* U */ ENTUL, ENTUM, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTUS, ENTNC, ENTNC, ENTNC,
1775 ENTNC, ENTNC, ENTNC, ENTUZ},
1776 /* A B C D E F G H I J K *
1777 L M N O P Q R S T U V *
1779 {ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTVF, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1780 /* V */ ENTNC, ENTVM, ENTNC, ENTVO, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTVU, ENTNC,
1781 ENTNC, ENTNC, ENTNC, ENTNC},
1782 /* A B C D E F G H I J K *
1783 L M N O P Q R S T U V *
1785 {ENTNC, ENTNC, ENTWC, ENTWD, ENTNC, ENTNC, ENTNC, ENTNC, ENTWI, ENTNC, ENTNC,
1786 /* W */ ENTNC, ENTNC, ENTWN, ENTNC, ENTNC, ENTNC, ENTNC, ENTWS, ENTNC, ENTWU, ENTNC,
1787 ENTNC, ENTNC, ENTNC, ENTNC},
1788 /* A B C D E F G H I J K *
1789 L M N O P Q R S T U V *
1791 {ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTXG, ENTNC, ENTXI, ENTNC, ENTNC,
1792 /* X */ ENTNC, ENTXM, ENTXN, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTXU, ENTNC,
1793 ENTNC, ENTXX, ENTXY, ENTNC},
1794 /* A B C D E F G H I J K *
1795 L M N O P Q R S T U V *
1797 {ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1798 /* Y */ ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1799 ENTNC, ENTNC, ENTNC, ENTNC},
1800 /* A B C D E F G H I J K *
1801 L M N O P Q R S T U V *
1803 {ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1804 /* Z */ ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC,
1805 ENTNC, ENTNC, ENTNC, ENTNC}
1808 /*ss013.301 :Adding TRC MACRO*/
1810 memcpy((U8*)osCp.entId, (U8*)entInfo, sizeof(entInfo));
1820 * Desc: This function gives the entity Id depending in the
1821 * file name. This function uses the first two letter
1822 * of file name to find the entity id.
1827 * RFAILED Region not registered
1832 PUBLIC S16 SGetEntInd
1838 PUBLIC S16 SGetEntInd(entId, fileName)
1846 /* ss002.301 Additions */
1847 S8 *strippedName = NULLP;
1855 /* ss002.301 Additions */
1856 if ((strippedName = strrchr((const char *)fileName, '/')))
1858 fileName = (U8 *)strippedName + 1;
1861 if(fileName[0] =='l' && fileName[3] == '.')
1863 /* Usally layer manager interface files starts
1864 * with l. so leave the first letter and take
1866 * Eg. Layer manger inteface file name for TUCL is lhi.c.
1867 * so here we leave l and we take hi to get the entity Id. */
1868 letter = ++fileName;
1873 /* Handle exceptional file names */
1877 if (letter[1] == 'g' && letter[2] == 'u')
1889 /* here first two charactes of file name should be alphabets.
1890 * if any one of the letter is non alphabet then we return ENTNC
1891 * as an entity Id */
1892 /* Eg. In fileName l4_ptui.c, second letter is numeral. so we consider
1893 * this file belogs to entity Id ENTNC. */
1894 for(count = 0; count < 2; count++)
1896 /* ss002.301 - Optimizations */
1897 if(letter[count] < 'a' || letter[count] > 'z')
1904 tempIdx = letter[count] - 'a';
1912 secondIdx = tempIdx;
1915 /* First two letter of file name are alphabets the get the
1916 * entity id from the static data base which is loaded in sFillEntIds() */
1917 *entId = osCp.entId[firstIdx][secondIdx];
1921 #endif /* SS_HISTOGRAM_SUPPORT */
1922 #ifdef SS_LOCK_SUPPORT
1923 /* ss002.301 Readwrite lock additions */
1928 * Desc: This function is used to aquire the read write lock
1945 PUBLIC S16 SLockNew(lockId, lockType)
1954 if((retVal = ssdLockNew(lockId, lockType)) != ROK)
1956 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SLockNew(): Failed to aquire the lock\n");
1966 * Desc: This function is used to aquire the read write lock
1976 PUBLIC S16 SInitLockNew
1982 PUBLIC S16 SInitLockNew(lockId, lockType)
1991 if((retVal = ssdInitLockNew(lockId, lockType)) != ROK)
1993 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SInitLockNew(): Initialization of lock Failed\n");
2003 * Desc: This function is used to Unlock the read write lock
2013 PUBLIC S16 SUnlockNew
2019 PUBLIC S16 SUnlockNew(lockId, lockType)
2028 if((retVal = ssdUnlockNew(lockId, lockType)) != ROK)
2030 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SUnlockNew(): Failed to release the lock\n");
2038 * Fun: SDestroyLockNew
2040 * Desc: This function is used to destroy the read write lock
2050 PUBLIC S16 SDestroyLockNew
2056 PUBLIC S16 SDestroyLockNew(lockId, lockType)
2063 TRC1(SDestroyLockNew);
2065 if((retVal = ssdDestroyLockNew(lockId, lockType)) != ROK)
2067 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SDestroyLockNew(): Failed to destroy the lock\n");
2072 #endif /* SS_LOCK_SUPPORT */
2074 #ifdef SSI_STATIC_MEM_LEAK_DETECTION
2075 /* Static memory leak detection changes */
2076 static U32 StaticMemLeakAge;
2077 static U32 StaticMemLeakIntCount = 1;
2079 void PrintStaticMemAllocInfo(StaticMemAllocInfo* memAllocInfo, FILE *opFile)
2083 fprintf(opFile, "Current Time = %ld\n",StaticMemLeakAge);
2085 for(i = 1; i < MAX_MEM_ALLOCATIONS; i++)
2087 if(memAllocInfo->allocations[i].ptr)
2089 fprintf(opFile, "p = %p f = %s l = %ld s = %ld a = %ld\n",
2090 memAllocInfo->allocations[i].ptr,
2091 memAllocInfo->allocations[i].file,
2092 memAllocInfo->allocations[i].lineNo,
2093 memAllocInfo->allocations[i].size,
2094 memAllocInfo->allocations[i].age);
2101 void InitializeStaticMemAllocInfo(StaticMemAllocInfo* memAllocInfo)
2104 /* index 0 is not used; nextIdx as 0 means end of list */
2105 memAllocInfo->nextFreeIdx = 1;
2107 for(i = 1; i < MAX_MEM_ALLOCATIONS; i++)
2109 memAllocInfo->allocations[i].listInfo.nextIdx = i + 1;
2110 memAllocInfo->allocations[i].ptr = 0;
2113 /* override the last one to point to 0 meaning end of list */
2114 memAllocInfo->allocations[MAX_MEM_ALLOCATIONS - 1].listInfo.nextIdx = 0;
2117 U32 GetNextFreeIdx(StaticMemAllocInfo * memAllocInfo)
2119 U32 toBeReturned = memAllocInfo->nextFreeIdx;
2121 U32 newNextFreeIdx = memAllocInfo->allocations[memAllocInfo->nextFreeIdx].listInfo.nextIdx;
2123 if(newNextFreeIdx == 0 || newNextFreeIdx >= MAX_MEM_ALLOCATIONS)
2125 printf("Something wrong in GetNextFreeIdx newNextIdx = %ld\n",newNextFreeIdx);
2128 memAllocInfo->nextFreeIdx = newNextFreeIdx;
2130 return toBeReturned;
2133 #define CRASH_ENB {int *p = 0; *p = 100;}
2134 void FreeIdx(U8* ptr, U32 idx, StaticMemAllocInfo* memAllocInfo,U32 size, char* file, U32 line)
2136 if(idx == 0 || idx >= MAX_MEM_ALLOCATIONS)
2138 printf("Something wrong in FreeIdx... idx = %ld called from %s:%ld\n",idx,file,line);
2141 /*printf("FreeIdx... idx = %d nexFree = %d\n",idx, memAllocInfo->nextFreeIdx);*/
2142 memAllocInfo->allocations[idx].listInfo.nextIdx = memAllocInfo->nextFreeIdx;
2143 if((ptr != memAllocInfo->allocations[idx].ptr) ||
2144 (size != memAllocInfo->allocations[idx].size))
2146 #ifdef XEON_SPECIFIC_CHANGES
2150 printf("Freeing wrong ptr stored = %p trying to free %p freeing size (%ld)"
2151 "allocated size(%ld) from %s:%ld\n",
2152 memAllocInfo->allocations[idx].ptr,
2155 memAllocInfo->allocations[idx].size,
2158 printf("Allocation was done from %s:%ld\n",memAllocInfo->allocations[idx].file, memAllocInfo->allocations[idx].lineNo);
2159 printf("***********************************************************\n");
2163 memAllocInfo->allocations[idx].ptr = 0;
2165 memAllocInfo->nextFreeIdx = idx;
2169 void LogForStaticMemLeak(StaticMemAllocInfo* memAllocInfo, char* file, U32 line, U32 size, void* ptr, U32 idx)
2172 memAllocInfo->allocations[idx].file = file;
2173 memAllocInfo->allocations[idx].lineNo = line;
2174 memAllocInfo->allocations[idx].size = size;
2175 memAllocInfo->allocations[idx].ptr = ptr;
2176 memAllocInfo->allocations[idx].age = StaticMemLeakAge;
2178 if(StaticMemLeakIntCount++ % 256 == 0)
2184 void InitializeForStaticMemLeak()
2188 StaticMemLeakFileArr[0] = fopen("region0.log","w");
2189 StaticMemLeakFileArr[1] = fopen("region1.log","w");
2190 StaticMemLeakFileArr[2] = fopen("region2.log","w");
2191 StaticMemLeakFileArr[3] = fopen("region3.log","w");
2193 if(StaticMemLeakFileArr[0] == NULL ||
2194 StaticMemLeakFileArr[1] == NULL ||
2195 StaticMemLeakFileArr[2] == NULL ||
2196 StaticMemLeakFileArr[3] == NULL)
2199 printf("Could not open files for Static Mem Leak detection logging :( crashing...\n");
2203 for(i = 0; i < 4; i++)
2205 InitializeStaticMemAllocInfo(&SMemLeakInfo[i]);
2209 PUBLIC void DumpStaticMemLeakFiles()
2213 for(i = 0; i < 4; i++)
2215 PrintStaticMemAllocInfo(&SMemLeakInfo[i], StaticMemLeakFileArr[i]);
2218 /* Static memory leak detection changes */
2223 * Fun: ssRegMainThread
2225 * Desc: This function is used to add the memory region
2226 * mapping for the main thread.
2228 * Ret: VOID (Always successful)
2236 PUBLIC S16 SReInitTmr
2241 PUBLIC S16 SReInitTmr()
2245 Txt prntBuf[PRNTSZE];
2247 sprintf(prntBuf, "\n SReInitTmr(): ReStarting the Tmr\n");
2248 SDisplay(1,prntBuf);
2249 ret = ssdReInitTmr();
2252 /*ss012.301 : Fix log related issue to suite MT and NS implementations*/
2253 SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SReInitTmr(): Failed to Restart the Tmr\n");
2261 * Fun: SGetConfigPath
2263 * Desc: This function is used to Get config files path
2265 * Ret: S8* config file Path
2272 PUBLIC S8* SGetConfigPath(Void)
2274 return osCp.configFilePath;
2277 /**********************************************************************
2279 **********************************************************************/