Example #1
0
/*
 *  ======== IRESMAN_VICP_init ========
 */
IRES_Status IRESMAN_VICP_init(IRESMAN_Params * initArgs)
/* ARGSUSED - this line tells the compiler not to warn about unused args. */
{
    int i;
    IRESMAN_VicpParams * resmanArgs = (IRESMAN_VicpParams *)initArgs;
    Registry_Result result;

    if (!regInit) {
        /*
         *  Enable logging. We only want to do this once, since there is
         *  no Registry_removeModule().
         */
        result = Registry_addModule(&ti_sdo_fc_ires_vicp_desc,
                VICP_MODNAME);

        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the FC default */
            FCSettings_init();
            FCSettings_setDiags(VICP_MODNAME);
        }
        regInit = 1;
    }

    Assert_isTrue(initArgs != NULL, (Assert_Id)NULL);

    /*  Check if already initialized */
    if (_initialized) {
       return IRES_EEXISTS;
    }

    /*
     * Information regarding the memory allocation/free functions
     * is stored as part of the internal state of the resource
     * manager
     */
    _resmanInternalState.allocFxn = resmanArgs->baseConfig.allocFxn;
    _resmanInternalState.freeFxn = resmanArgs->baseConfig.freeFxn;

    /*
     * Set resource status to default
     */
   _resmanInternalState.IMXbusy = IRESMAN_VICP_RESOURCEFREE;
   _resmanInternalState.VLCDbusy = IRESMAN_VICP_RESOURCEFREE;
   _resmanInternalState.SEQbusy = IRESMAN_VICP_RESOURCEFREE;

    for(i = 0; i < 3; i++) {
        _resmanInternalState.refCount[i] = 0;
    }

    /* Set Initalized flag to 1 if successful */
    _initialized = 1;

     return IRES_OK;
}
/*
 *  ======== addModule ========
 */
static Void addModule()
{
    Registry_Result result;

    result = Registry_addModule(&ti_sdo_fc_memutils_desc,
            MEMUTILS_MODNAME);
    Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

    if (result == Registry_SUCCESS) {
        /* Set the diags mask to the FC default */
        FCSettings_init();
        FCSettings_setDiags(MEMUTILS_MODNAME);
    }
    regInit = 1;
}
Example #3
0
/*
 *  ======== RMP_init ========
 */
Void RMP_init(Void)
{
    Registry_Result result;

    if (refCount++ == 0) {
        FCSettings_init();

        result = Registry_addModule(&ti_sdo_fc_utils_rmmp_desc, RMMP_MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the FC default */
            FCSettings_setDiags(RMMP_MODNAME);
        }
    }
}
Example #4
0
/*
 *  ======== initBuf ========
 *  Initialize the BUFRES resource manager.
 */
static IRES_Status initBuf(IRESMAN_Params *args)
{
    BUFRES_Params    *cArgs = (BUFRES_Params *)args;
    IRES_Status       status = IRES_OK;
    Registry_Result   result;
    static Int regInit = 0;  /* Registry_addModule() called */

    if (regInit == 0) {
        result = Registry_addModule(&bufres_desc, BUFRES_MODNAME);

        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the FC default */
            FCSettings_init();
            FCSettings_setDiags(BUFRES_MODNAME);
        }

        regInit = 1;
    }

    Log_print0(Diags_ENTRY, "[+E] BUFRES initBuf> entered");

    if (curInit++) {
        /* Already initialized */
        return (IRES_EINIT);
    }

    Assert_isTrue(args != NULL, (Assert_Id)NULL);
    Assert_isTrue(args->allocFxn != NULL, (Assert_Id)NULL);
    Assert_isTrue(args->freeFxn != NULL, (Assert_Id)NULL);

    allocFxn = args->allocFxn;
    freeFxn = args->freeFxn;

    /* Initialize the Buffer Resource Manager based on config params */
    buffer.base = cArgs->base;
    buffer.length = cArgs->length;
    buffer.scratchId = -1;
    buffer.refCount = 0;

    Log_print1(Diags_EXIT, "[+X] BUFRES initBuf> returning 0x%x",(IArg)status);

    return (status);
}
Example #5
0
/*
 *  ======== IRESMAN_HDVICP_init ========
 * Function to initialize the device specific resource manager implementation
 */
IRES_Status IRESMAN_HDVICP_init(IRESMAN_Params * initArgs)
{
    IRESMAN_HdVicpParams * resmanArgs = (IRESMAN_HdVicpParams *)initArgs;
    Registry_Result result;

    if (!regInit) {
        /*
         *  Enable logging. We only want to do this once, since there is
         *  no Registry_removeModule().
         */
        result = Registry_addModule(&ti_sdo_fc_ires_hdvicp_desc,
                HDVICP_MODNAME);

        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the FC default */
            FCSettings_init();
            FCSettings_setDiags(HDVICP_MODNAME);
        }
        regInit = 1;
    }

    Log_print1(Diags_ENTRY, "[+E] IRESMAN_HDVICP_init> Enter (initArgs=0x%x)",
            (IArg)initArgs);

    Assert_isTrue(initArgs != NULL, (Assert_Id)NULL);

    /* Check if already initialized */
    if (_initialized) {
       Log_print0(Diags_EXIT,
               "[+X] IRESMAN_HDVICP_init> Exit (status=IRES_EEXISTS)");

       return (IRES_EEXISTS);
    }

    /*
     * Information regarding the memory allocation/free functions
     * is stored as part of the internal state of the resource
     * manager
     */
    allocFxn = resmanArgs->baseConfig.allocFxn;
    freeFxn = resmanArgs->baseConfig.freeFxn;

#ifdef xdc_target__os_Linux
    if (gate == NULL) {
        OsalSupport_createGate(_HDVICP_ipcKeyBase);
    }
    if (gate == NULL) {
        Log_print0(Diags_USER7,
                "[+7] IRESMAN_VICP2_init> Failed to create gate");

        Log_print0(Diags_EXIT,
                "[+X] IRESMAN_VICP2_init> Exit (status=IRES_EFAIL)");

        return (IRES_EFAIL);
    }
#endif

    getInternalState();

    if ((NULL == _resmanInternalState) ||
            (_resmanInternalState->sharedMemId == -1)) {

        Log_print0(Diags_USER7,
                "[+7] IRESMAN_VICP2_init> Failed to obtain Internal state "
                "Object");

        Log_print0(Diags_EXIT,
                "[+X] IRESMAN_VICP2_init> Exit (status=IRES_EFAIL)");

        return (IRES_EFAIL);
    }

    _resmanInternalState->numOpens++;

    if (sizeof(IRESMAN_Params) == resmanArgs->baseConfig.size) {
        _resmanInternalState->numResources = _HDVICP_NUMRESOURCES;
    }
    else {
        _resmanInternalState->numResources = resmanArgs->numResources;
    }

    Assert_isTrue(
            _resmanInternalState->numResources <= IRES_HDVICP_MAXRESOURCES,
            (Assert_Id)NULL);

    /* Set Initalized flag to 1 if successful */
     _initialized = 1;

     Log_print0(Diags_EXIT, "[+X] IRESMAN_HDVICP_init> Exit (status=IRES_OK)");

     return (IRES_OK);
}
/*
 *  ======== RMAN_init ========
 *  Initialize the RMAN object with static information from the headers/
 *  configuration etc. This function has to return successfully before the
 *  other APIs can be called
 */
IRES_Status RMAN_init()
{
    Int             i = 0;
    IRES_Status     status;
    IRESMAN_Params  nullParams;
    Registry_Result regResult;


    /*
     *  Register the module name for logging only once. Do this before any
     *  Log functions are called.
     */
    if (regInit == 0) {
        regResult = Registry_addModule(&ti_sdo_fc_rman_desc, RMAN_MODNAME);

        Assert_isTrue(regResult == Registry_SUCCESS, (Assert_Id)NULL);

        /* Set diags mask to FC default */
        FCSettings_init();
        FCSettings_setDiags(RMAN_MODNAME);
        regInit = 1;
    }

    /* Ensure it is called/initialized at least once */
    if (rmanInit++) {
        Log_print0(Diags_ENTRY, "[+E] RMAN_init> Enter");
        Log_print0(Diags_EXIT, "[+X] RMAN_init> Exit (status=IRES_OK)");

        /* TODO: Return IRES_OK even if RMAN_init() failed earlier? */
        return (IRES_OK);
    }

    Log_print0(Diags_ENTRY, "[+E] RMAN_init> Enter");

    if ((NULL == RMAN_PARAMS.allocFxn) || (NULL == RMAN_PARAMS.freeFxn)) {
        Log_print0(Diags_USER7, "[+7] RMAN_init> RMAN_PARAMS not "
                "configured with allocFxn and freeFxn functions");

        initStatus = IRES_ENOMEM;
    }
    else {
        /* Set initStatus to IRES_OK so RMAN_register() can succeed. */
        initStatus = IRES_OK;
    }

    if (initStatus == IRES_OK) {
        /* Create a lock for protecting RMAN_data object */
        gate = OsalSupport_createGate(ti_sdo_fc_rman_RMAN_ipcKey);

        if (gate == NULL) {
            Log_print1(Diags_USER7,
                    "[+7] RMAN_init> Failed to create IPC gate, key = 0x%x",
                    ti_sdo_fc_rman_RMAN_ipcKey);

            initStatus = IRES_ENOMEM;
        }
    }

    if (initStatus == IRES_OK) {
        /*
         *  Register the NULL resource.
         */
        resTable.tableSize = RMAN_PARAMS.numRegistries;

        /* Initialize the registry table and the free index table */
        for (i = 0; i < resTable.tableSize; i++) {
            RMAN_TABLE[i] = NULL;
            RMAN_FREE_ENTRIES[i] = 0;
        }

        resTable.tableIndex = 0;
        resTable.freeIndex = -1;

        /* First pre-register the NULL resource */
        nullParams.allocFxn = RMAN_PARAMS.allocFxn;
        nullParams.freeFxn = RMAN_PARAMS.freeFxn;
        nullParams.size = sizeof(IRESMAN_Params);

        status = RMAN_register(&IRESMAN_NULLRES, &nullParams);
        if (status != IRES_OK) {
            Log_print1(Diags_USER7, "[+7] RMAN_init> Register failed "
                    "on NULL IRESMAN implementation: %d", (IArg)status);
            initStatus = status;
        }
    }

    if (initStatus == IRES_OK) {
        /*
         *  In this function, we can populate the RMAN_registryEntries,
         *  RMAN_registeryResmanArgs and fix RMAN_numRegistryEntries
         */
        initStatus = RMAN_autoRegister();
    }

    /*
     * Static registration of Resource Registry entries
     */
    if ((initStatus == IRES_OK) && (RMAN_registryEntries != NULL)) {

        Assert_isTrue(RMAN_numRegistryEntries < resTable.tableSize,
                (Assert_Id)NULL);
        Log_print0(Diags_USER2, "[+2] RMAN_init> Registering statically "
                "added resources");
        /*
         *  Copy the entries from the static configuration into the resource
         *  table.
         */
        for (i = 0; i < RMAN_numRegistryEntries; i++) {

            status = RMAN_register(RMAN_registryEntries[i],
                    RMAN_registryResmanArgs[i]);

            if (status != IRES_OK) {
                Log_print2(Diags_USER7, "[+7] RMAN_init> Register failed on "
                        "IRESMAN implementation 0x%x, status: %d",
                        (IArg)(RMAN_registryEntries[i]), (IArg)status);

                initStatus = status;
                break;
            }
        }
    }

    getInternalState();

    if (NULL == rmanInternalState) {
        initStatus = IRES_EFAIL;
    }

    Log_print1(Diags_EXIT, "[+X] RMAN_init> Exit (status=%d)",
            (IArg)initStatus);

    return (initStatus);
}