ClRcT corMoTreeDbgInit()
{
    ClRcT ret= CL_OK ;
    ret= dbgAddComponent(COMP_PREFIX, COMP_NAME, COMP_DEBUG_VAR_PTR);
    if (CL_OK != ret)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("dbgAddComponent Failed \n "));
        CL_FUNC_EXIT();
    }
    return ret;
}
ClRcT clHalLibInitialize()
{
    ClRcT rc= CL_OK ; 
    CL_FUNC_ENTER();
    if (CL_TRUE == halInitDone)
    {
        clLogCritical(CL_LOG_AREA_UNSPECIFIED,CL_LOG_CONTEXT_UNSPECIFIED,"\n clHalLibInitialize Called Again \n");
        CL_FUNC_EXIT();
        return (CL_HAL_SET_RC(CL_ERR_INVALID_STATE));
    }
#ifdef DEBUG
    rc= dbgAddComponent(COMP_PREFIX, COMP_NAME, COMP_DEBUG_VAR_PTR);
    if (CL_OK != rc)
    {
        clLogError(CL_LOG_AREA_UNSPECIFIED,CL_LOG_CONTEXT_UNSPECIFIED,"dbgAddComponent Failed \n ");
        CL_FUNC_EXIT();
        return rc;
    }
#endif
    
    memset(&halDevObjTable,0, sizeof(HalDeviceObjTableT));

    halDevObjTable.pphalDeviceObj=(HalDeviceObjectT **)clHeapAllocate((halConfig.
        halNumDevObject)*sizeof(HalDeviceObjectT *));

    if (NULL == halDevObjTable.pphalDeviceObj)
    {
        clLogCritical(CL_LOG_AREA_UNSPECIFIED,CL_LOG_CONTEXT_UNSPECIFIED,"\n clHalLibInitialize Error no memory HAL\n");
        CL_FUNC_EXIT();
        return(CL_HAL_SET_RC(CL_ERR_NO_MEMORY));
    }

    memset(halDevObjTable.pphalDeviceObj,0, ((halConfig.
        halNumDevObject)*sizeof(HalDeviceObjectT *)));
        
    halInitDone = CL_TRUE; 

    /* Create device object(s) from the Configuration Info */
    rc = halDevObjTableCreate ();
    if (rc != CL_OK)
    {
        clLogCritical(CL_LOG_AREA_UNSPECIFIED,CL_LOG_CONTEXT_UNSPECIFIED,"\n halDevObjTableCreate  Failed");
        CL_FUNC_EXIT();
        return rc ;
    }
    clLogTrace(CL_LOG_AREA_UNSPECIFIED,CL_LOG_CONTEXT_UNSPECIFIED,"\nclHalLibInitialize CL_OK\n");
    CL_FUNC_EXIT();
    return (CL_OK) ;
}
/**
 *  Initializes the OM class table.                          
 *
 *  This API initializes the OM class lookup table from the pre-configured<br>
 *    tables: common and application.  It also initializes other tables <br>
 *    and prepares the OM library for usage by other components.
 *
 *  @param pOmCfgData Configuration data for OM
 *
 *  @returns
 *    CL_OK - everything is ok<br>
 *    ==>FIXME:Define(==>FIXME:Define(CL_ERR_INVLD_STATE)<==)<== - wrong initialization state<br>
 *    Runlevel error code - please reference the Runlevel error codes
 *
 */
ClRcT clOmLibInitialize()
{
    ClRcT		rc = CL_OK;
    ClUint32T	classIdx = 0;
    ClUint32T	omCfgDataSz = sizeof(ClOmConfigDataT);
    ClOmClassControlBlockT	*pOmClassEntry = NULL;

    /*
      ClUint32T      cmnOmClassCnt = 0; 
    */
    /*ClUint32T	omClassCnt = 0;
      ClUint32T	skippedClassCnt = 0;*/
    extern ClRcT showMgrModAdd(char *, char *, void (*fp)(char**));
    extern void omShow (char ** );


    CL_FUNC_ENTER();

    /*
     * Check if the OI has its own DB and reload its db
     */
    if(gClOIConfig.oiDBReload)
        return CL_OK;

    /* Get a count of the common classes */


    /* 
       Initialize config data struct and make a 
       copy of the configuration data. 
    */
    memset(&gOmCfgData, 0, omCfgDataSz);
    /* Fill up the gOmCfgData */
    gOmCfgData.maxOmClassBuckets = OM_CLASS_TABLE_MAX_BUCKETS;
    gOmCfgData.minAppOmClassType = OM_APP_MIN_CLASS_TYPE;
    gOmCfgData.maxAppOmClassType = OM_APP_MAX_CLASS_TYPE;
    gOmCfgData.numOfOmClasses = 0;

    /* Create a hash table for storing OM classes */
    rc = clCntHashtblCreate(gOmCfgData.maxOmClassBuckets, omClassKeyCompare, 
                            omClassHashFn, omClassEntryDelCallBack, 
                            omClassEntryDestroyCallBack, CL_CNT_NON_UNIQUE_KEY, &ghOmClassHashTbl);

    if ((rc != CL_OK) || (ghOmClassHashTbl == 0))
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("%s: Failed to create a hash table "
                                       "for OM classes (rc = 0x%x)!!!\n\r", 
                                       __FUNCTION__, rc));
        return (rc);
    }


    /* Consolidate OM class tables into a hash table */
    /* Configure the common OM class table */

    /* Initialize the base class here */


    if ((rc = clOmClassInitialize (&gBaseClassTable, 
                                   gBaseClassTable.eMyClassType, 
                                   gBaseClassTable.maxObjInst,
                                   gBaseClassTable.maxSlots)) != CL_OK)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("%s: Failed to initialize OM with rc = "
                                        "0x%x!\r\n", __FUNCTION__, rc));
        return (rc);
    }




    /* Accumulate the number of classes registered w/ OM */
    /*omClassCnt = classIdx;*/
    pOmClassEntry = NULL;

    /* Configure the application OM class table */
    classIdx = 0;

    if (appOmClassCnt > 0)
    {
        for (; classIdx < appOmClassCnt; classIdx++)
        {
            pOmClassEntry = &(pAppOmClassTbl[classIdx]);
            if (pOmClassEntry->eMyClassType == CL_OM_INVALID_CLASS)
            {
                /* skip invalid class */
                /* 
                   This way invalid classes and missing, i.e. a table
                   size if bigger than the number of classes
                   are allowed in the table.
                */
                /*skippedClassCnt++;*/
                continue;
            }

            if ((rc = clOmClassInitialize (pOmClassEntry, 
                                           pOmClassEntry->eMyClassType, 
                                           pOmClassEntry->maxObjInst,
                                           pOmClassEntry->maxSlots)) != CL_OK)
            {
                CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("%s: Failed to initialize OM with rc = "
                                                "0x%x!\r\n", __FUNCTION__, rc));
                return (rc);
            }
        }
    }
    else
    {
        CL_DEBUG_PRINT(CL_DEBUG_TRACE, ("%s: Not initializing OM Application class "
                                        "table because it does not exist...ignoring.\r\n",
                                        __FUNCTION__));
    }

    /* Get the total number of classes registered w/ OM */
    /*gOmCfgData.numOfOmClasses = omClassCnt + classIdx - skippedClassCnt;*/

    /* Initialize the COR/OM handle translation table */
    if (rc == CL_OK)
    {
        if((rc = omCORTableInit()) != CL_OK)
        {
            CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Failed to setup the COR translation "
                                            "table with rc = 0x%x\r\n", rc));
        }
    }

#ifdef DEBUG
    /* Add OM into the debug agent */
    if (!omClassInitState)
        dbgAddComponent(COMP_PREFIX, COMP_NAME, COMP_DEBUG_VAR_PTR);
#endif

    omClassInitState = CL_TRUE;
    /* add the om to show manager */ 
    /*@todo: Navdeep (show manager dependency) 
      showMgrModAdd(COMP_PREFIX, COMP_NAME, omShow); 
    */
    CL_FUNC_EXIT();
    return (rc);
}
ClRcT clOmLibInitializeExtended(void)
{
    ClRcT		rc = CL_OK;
    ClUint32T	classIdx = 0;
    ClUint32T	omCfgDataSz = sizeof(ClOmConfigDataT);
    ClOmClassControlBlockT	*pOmClassEntry = NULL;
    ClCharT oiClassFile[CL_MAX_NAME_LENGTH] = {0};
    ClCharT oiRouteFile[CL_MAX_NAME_LENGTH] = {0};
    ClCharT *pOIClassFile = oiClassFile;
    ClCharT *pOIRouteFile = oiRouteFile;
    extern ClRcT showMgrModAdd(char *, char *, void (*fp)(char**));
    extern void omShow (char ** );


    CL_FUNC_ENTER();

    /*
     *First load the OI class configuration. into COR
     */
    if(!gClOIConfig.pOIClassFile)
    {
        clLogError("OI", "CONFIG", "No OI class file is specified to configure the OI classes");
        return CL_OM_SET_RC(CL_ERR_INVALID_PARAMETER);
    }
    if(!gClOIConfig.pOIRouteFile)
    {
        clLogError("OI", "CONFIG", "No OI route file is specified to configure the OI objects");
        return CL_OM_SET_RC(CL_ERR_INVALID_PARAMETER);
    }

    if(gClOIConfig.pOIClassPath)
        snprintf(oiClassFile, sizeof(oiClassFile), "%s/%s", gClOIConfig.pOIClassPath, 
                 gClOIConfig.pOIClassFile);
    else
        pOIClassFile = (ClCharT*)gClOIConfig.pOIClassFile;

    if(gClOIConfig.pOIRoutePath)
        snprintf(oiRouteFile, sizeof(oiRouteFile), "%s/%s", gClOIConfig.pOIRoutePath,
                 gClOIConfig.pOIRouteFile);
    else
        pOIRouteFile = (ClCharT*)gClOIConfig.pOIRouteFile;

    rc = clCorConfigLoad(pOIClassFile, pOIRouteFile);
    if(rc != CL_OK)
    {
        clLogError("OI", "CONFIG", "Loading OI class configuration [%s] to COR returned with error [%#x]",
                   pOIClassFile, rc);
        return rc;
    }

    /* 
       Initialize config data struct and make a 
       copy of the configuration data. 
    */
    memset(&gOmCfgData, 0, omCfgDataSz);
    /* Fill up the gOmCfgData */
    gOmCfgData.maxOmClassBuckets = OM_CLASS_TABLE_MAX_BUCKETS;
    gOmCfgData.minAppOmClassType = OM_APP_MIN_CLASS_TYPE;
    gOmCfgData.maxAppOmClassType = OM_APP_MAX_CLASS_TYPE;
    gOmCfgData.numOfOmClasses = 0;

    /* Create a hash table for storing OM classes */
    rc = clCntHashtblCreate(gOmCfgData.maxOmClassBuckets, omClassKeyCompare, 
                            omClassHashFn, omClassEntryDelCallBack, 
                            omClassEntryDestroyCallBack, CL_CNT_NON_UNIQUE_KEY, &ghOmClassHashTbl);

    rc |= clCntHashtblCreate(gOmCfgData.maxOmClassBuckets, omClassNameKeyCompare, 
                            omClassNameHashFn, omClassEntryDelCallBack, 
                            omClassEntryDestroyCallBack, CL_CNT_NON_UNIQUE_KEY, &ghOmClassNameHashTbl);

    if ((rc != CL_OK) || (ghOmClassHashTbl == 0) 
        || (ghOmClassNameHashTbl == 0))
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("%s: Failed to create a hash table "
                                       "for OM classes (rc = 0x%x)!!!\n\r", __FUNCTION__, rc));
        return (rc);
    }


    /* Consolidate OM class tables into a hash table */
    /* Configure the common OM class table */

    /* Initialize the base class here */


    if ((rc = clOmClassInitialize (&gBaseClassTable, 
                                   gBaseClassTable.eMyClassType, 
                                   gBaseClassTable.maxObjInst,
                                   gBaseClassTable.maxSlots)) != CL_OK)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("%s: Failed to initialize OM with rc = "
                                        "0x%x!\r\n", __FUNCTION__, rc));
        return (rc);
    }


    /* Accumulate the number of classes registered w/ OM */
    /*omClassCnt = classIdx;*/
    pOmClassEntry = NULL;

    /* Configure the application OM class table */
    classIdx = 0;

    if (appOmClassCnt > 0)
    {
        for (; classIdx < appOmClassCnt; classIdx++)
        {
            pOmClassEntry = &(pAppOmClassTbl[classIdx]);
            if (pOmClassEntry->eMyClassType == CL_OM_INVALID_CLASS)
            {
                /* skip invalid class */
                /* 
                   This way invalid classes and missing, i.e. a table
                   size if bigger than the number of classes
                   are allowed in the table.
                */
                /*skippedClassCnt++;*/
                continue;
            }

            if ((rc = clOmClassNameInitialize (pOmClassEntry, 
                                               pOmClassEntry->className,
                                               pOmClassEntry->maxObjInst,
                                               pOmClassEntry->maxSlots)) != CL_OK)
            {
                CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("%s: Failed to initialize OM with rc = "
                                                "0x%x!\r\n", __FUNCTION__, rc));
                return (rc);
            }
        }
    }
    else
    {
        CL_DEBUG_PRINT(CL_DEBUG_TRACE, ("%s: Not initializing OM Application class "
                                        "table because it does not exist...ignoring.\r\n",
                                        __FUNCTION__));
    }

    /* Get the total number of classes registered w/ OM */
    /*gOmCfgData.numOfOmClasses = omClassCnt + classIdx - skippedClassCnt;*/

    /* Initialize the COR/OM handle translation table */
    if (rc == CL_OK)
    {
        if((rc = omCORTableInit()) != CL_OK)
        {
            CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Failed to setup the COR translation "
                                            "table with rc = 0x%x\r\n", rc));
        }
    }

#ifdef DEBUG
    /* Add OM into the debug agent */
    if (!omClassInitState)
        dbgAddComponent(COMP_PREFIX, COMP_NAME, COMP_DEBUG_VAR_PTR);
#endif

    omClassInitState = CL_TRUE;
    /* add the om to show manager */ 
    /*@todo: Navdeep (show manager dependency) 
      showMgrModAdd(COMP_PREFIX, COMP_NAME, omShow); 
    */
    CL_FUNC_EXIT();
    return (rc);
}
ClRcT
clTimerInitialize (ClPtrT pConfig)
{
    ClRcT returnCode = CL_ERR_INVALID_HANDLE;

    CL_FUNC_ENTER();
    /* TBD: check whether the OSAL has been initialized before going ahead with Timer init */
    returnCode = clOsalInitialize(NULL);
    if(CL_OK != returnCode) {
        CL_FUNC_EXIT();
        return(returnCode);
    }

    if (gActiveTimerQueue.timerServiceInitialized == 1) {
        CL_FUNC_EXIT();
        CL_DEBUG_PRINT (CL_DEBUG_INFO,("\nTimer already initialized"));
        return (CL_OK);
    }

#ifdef DEBUG
    returnCode= dbgAddComponent (COMP_PREFIX, COMP_NAME, COMP_DEBUG_VAR_PTR);
    if (CL_OK != returnCode)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("dbgAddComponent Failed \n "));
        CL_FUNC_EXIT();
        return (returnCode);
    }
#endif

    /* create a pool of free timers */
    returnCode = tsFreeTimersPoolCreate ();

    if (returnCode != CL_OK) {

        CL_DEBUG_PRINT (CL_DEBUG_ERROR,("\nTimer Init : NOT DONE"));
        CL_FUNC_EXIT();
        return (CL_ERR_UNSPECIFIED);
    }

    /* create the active timers queue */
    returnCode = tsActiveTimersQueueCreate ();

    if (returnCode != CL_OK) {
        /* debug message */
        returnCode = tsFreeTimersPoolDestroy ();
        CL_DEBUG_PRINT (CL_DEBUG_ERROR,("\nTimer Init : NOT DONE"));
        CL_FUNC_EXIT();
        return (CL_ERR_UNSPECIFIED);
    }

    /* create re-enqueue Queue */
    returnCode = clQueueCreate(0,
                               deQueueCallBack,
                               deQueueCallBack,
                               &(gActiveTimerQueue.reEnqueueQueue));

    if (returnCode != CL_OK) {
        /* debug message */
        returnCode = tsFreeTimersPoolDestroy ();
        returnCode = tsActiveTimersQueueDestroy ();
        CL_DEBUG_PRINT (CL_DEBUG_ERROR,("\nTimer Init : NOT DONE"));
        CL_FUNC_EXIT();
        return (CL_ERR_UNSPECIFIED);
    }

    CL_DEBUG_PRINT (CL_DEBUG_INFO,("\nTimer Init : DONE"));
    CL_FUNC_EXIT();
    return (CL_OK);
}
示例#6
0
ClRcT clRmdObjInit(ClRmdObjHandleT *p)
{
    ClRcT retCode = CL_OK;
    ClRmdObjT *pRmdObject = NULL;
    //unsigned long timeStamp = 0;
    struct timeval tm1;

#ifdef DEBUG
    static ClUint8T rmdAddedTodbgComp = CL_FALSE;

    if (CL_FALSE == rmdAddedTodbgComp)
    {
        retCode = dbgAddComponent(COMP_PREFIX, COMP_NAME, COMP_DEBUG_VAR_PTR);
        rmdAddedTodbgComp = CL_TRUE;
        if (CL_OK != retCode)
        {
            clLogError("OBG","INI","dbgAddComponent FAILED ");
            CL_FUNC_EXIT();
            return retCode;
        }
    }
#endif
    CL_FUNC_ENTER();

    if (NULL == p)
    {
        RMD_DBG1((" RMD Invalid Object handle passed\n"));
        CL_FUNC_EXIT();
        return ((CL_RMD_RC(CL_ERR_INVALID_PARAMETER)));
    }

    retCode = clOsalInitialize(NULL);

    retCode = clTimerInitialize(NULL);
    pRmdObject = (ClRmdObjT *) clHeapAllocate(sizeof(ClRmdObjT));

    if (NULL == pRmdObject)
    {
        RMD_DBG1((" RMD No Memory\n"));
        CL_FUNC_EXIT();
        return ((CL_RMD_RC(CL_ERR_NO_MEMORY)));
    }

    gettimeofday(&tm1, NULL);
    //timeStamp = tm1.tv_sec * 1000000 + tm1.tv_usec;
    pRmdObject->msgId = 1;
    retCode = clOsalMutexCreate(&pRmdObject->semaForSendHashTable);

    if (CL_OK != CL_GET_ERROR_CODE(retCode))
    {
        RMD_DBG1((" RMD send Mutex creation failed\n"));
        CL_FUNC_EXIT();
        return (retCode);
    }
    retCode = clOsalMutexCreate(&pRmdObject->semaForRecvHashTable);

    if (CL_OK != CL_GET_ERROR_CODE(retCode))
    {
        RMD_DBG1((" RMD  recv Mutex creation failed\n"));

        IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForSendHashTable));
        CL_FUNC_EXIT();
        return (retCode);
    }

    retCode =
        clCntHashtblCreate(NUMBER_OF_RECV_BUCKETS, recvKeyCompare,
                           recvHashFunction, recvHashDeleteCallBack,
                           recvHashDeleteCallBack, CL_CNT_UNIQUE_KEY,
                           &pRmdObject->rcvRecContainerHandle);
    if (CL_OK != CL_GET_ERROR_CODE(retCode))
    {
        RMD_DBG1((" RMD  send Hash table creation failed\n"));

        IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForRecvHashTable));
        IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForSendHashTable));
        CL_FUNC_EXIT();
        return (retCode);
    }
    retCode =
        clCntHashtblCreate(NUMBER_OF_SEND_BUCKETS, sendKeyCompare,
                           sendHashFunction, sendHashDeleteCallBack,
                           sendHashDestroyCallBack, CL_CNT_UNIQUE_KEY,
                           &pRmdObject->sndRecContainerHandle);
    if (CL_OK != CL_GET_ERROR_CODE(retCode))
    {
        RMD_DBG1((" RMD  recv Hash table creation failed\n"));

        IGNORE_RETURN(clCntDelete(pRmdObject->rcvRecContainerHandle));
        IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForRecvHashTable));
        IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForSendHashTable));
        CL_FUNC_EXIT();
        return (retCode);
    }

    pRmdObject->responseCntxtDbHdl = 0;
    retCode = clHandleDatabaseCreate(NULL, &pRmdObject->responseCntxtDbHdl);
    if (retCode != CL_OK)
    {
        RMD_DBG1((" RMD  Sync Handle Database create failed\n"));
        IGNORE_RETURN(clCntDelete(pRmdObject->sndRecContainerHandle));
        IGNORE_RETURN(clCntDelete(pRmdObject->rcvRecContainerHandle));
        IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForRecvHashTable));
        IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForSendHashTable));

        CL_FUNC_EXIT();
        return retCode;
    }

    pRmdObject->numAtmostOnceEntry = 0;
    pRmdObject->lastAtmostOnceCleanupTime = clOsalStopWatchTimeGet();
    pRmdObject->rmdStats.nRmdCalls = 0;
    pRmdObject->rmdStats.nFailedCalls = 0;
    pRmdObject->rmdStats.nResendRequests = 0;
    pRmdObject->rmdStats.nRmdReplies = 0;
    pRmdObject->rmdStats.nBadReplies = 0;
    pRmdObject->rmdStats.nRmdRequests = 0;
    pRmdObject->rmdStats.nBadRequests = 0;
    pRmdObject->rmdStats.nCallTimeouts = 0;
    pRmdObject->rmdStats.nDupRequests = 0;
    pRmdObject->rmdStats.nAtmostOnceCalls = 0;
    pRmdObject->rmdStats.nResendReplies = 0;
    pRmdObject->rmdStats.nReplySend = 0;
    pRmdObject->rmdStats.nRmdCallOptimized = 0;
    *p = (ClRmdObjHandleT) pRmdObject;
    CL_FUNC_EXIT();
    return (CL_OK);
}