/*
 *  ======== Server_init ========
 */
Void Server_init(Void)
{
    Registry_Result result;

    if (curInit++ != 0) {
        return;  /* already initialized */
    }

    /* register with xdc.runtime to get a diags mask */
    result = Registry_addModule(&Registry_CURDESC, MODULE_NAME);
    Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

    /* initialize module state */
    Module.hostProcId = MultiProc_getId("HOST");
    Module.lineId = SystemCfg_LineId;
    Module.eventId = SystemCfg_AppEventId;
    Module.semH = NULL;
    Module.heapH = NULL;
    Module.head = 0;
    Module.tail = 0;
    Module.error = 0;
    Module.rcmServerH = NULL;

    RcmServer_init();
}
示例#2
0
/*
 *  ======== Global_init ========
 */
Void Global_init(Void)
{
    Int i;
    Registry_Result   result;

    /*
     *  No need to reference count for Registry_addModule(), since there
     *  is no way to remove the module.
     */
    if (regInit == 0) {
        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_osal_Global_desc,
                                    Global_MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(Global_MODNAME);
        }
        regInit = 1;
    }

    if (curInit != TRUE) {
        curInit = TRUE;

        Log_print0(Diags_USER4, "[+4] Global_init> "
                   "This program was built with the following packages:" );
        for (i = 0; Global_buildInfo[i] != NULL; i++) {
            Log_print1(Diags_USER4, "[+4] %s", (IArg)(Global_buildInfo[i]));
        }
    }
}
示例#3
0
/*
 *  ======== Algorithm_init ========
 */
Void Algorithm_init()
{
    Registry_Result   result;

    /*
     *  No need to reference count for Registry_addModule(), since there
     *  is no way to remove the module.
     */
    if (regInit == 0) {
        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_algorithm_desc,
                Algorithm_MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(Algorithm_MODNAME);
        }
        regInit = 1;
    }

    if (curInit != TRUE) {
        curInit = TRUE;
        RMAN_init();
        Global_atexit((Fxn)Algorithm_exit);
    }
}
示例#4
0
文件: viddec1.c 项目: mobiaqua/ti-ce
/*
 *  ======== VIDDEC1_create ========
 */
VIDDEC1_Handle VIDDEC1_create(Engine_Handle engine, String name,
    VIDDEC1_Params *params)
{
    Registry_Result   result;
    VIDDEC1_Handle visa;

    /* TODO:M  Race here!  Do we need ATM_Increment in our OSAL? */
    if (regInit == 0) {
        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_video1_viddec1_desc, MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(MODNAME);
        }
        regInit = 1;
    }

    Log_print3(Diags_ENTRY, "[+E] VIDDEC1_create> "
            "Enter (engine=0x%x, name='%s', params=0x%x)",
            (IArg)engine, (IArg)name, (IArg)params);

    visa = VISA_create(engine, name, (IALG_Params *)params,
        sizeof (_VIDDEC1_Msg), VIDDEC1_VISATYPE);

    Log_print1(Diags_EXIT, "[+X] VIDDEC1_create> return (0x%x)", (IArg)visa);

    return (visa);
}
示例#5
0
/*
 *  ======== Loader_init ========
 */
Void Loader_init(Void)
{
    Registry_Result   result;

    /*
     *  No need to reference count for Registry_addModule(), since there
     *  is no way to remove the module.
     */
    if (regInit == 0) {
        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_osal_Loader_desc,
                                    Loader_MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(Loader_MODNAME);
        }
        regInit = 1;
    }

    if (curInit++ == 0) {
        Global_atexit((Fxn)cleanup);
    }
}
示例#6
0
/*
 *  ======== Comm_init ========
 */
Bool Comm_init(Void)
{
    Registry_Result   result;

    /*
     *  No need to reference count for Registry_addModule(), since there
     *  is no way to remove the module.
     */
    if (regInit == 0) {
        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_ipc_comm_desc, Comm_MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(Comm_MODNAME);
        }
        regInit = 1;
    }

    if (curInit++ == 0) {
        /* TODO:M not process safe (right?) */
        userName = getenv("LOGNAME");
        if (userName == NULL) {
            userName = "";
        }
    }

    return (TRUE);
}
示例#7
0
Int main(Int argc, Char* argv[])
{
    Error_Block     eb;
    Task_Params     taskParams;
    Registry_Result result;

    Log_print0(Diags_ENTRY, "--> main:");

    /* must initialize the error block before using it */
    Error_init(&eb);

    /* create main thread (interrupts not enabled in main on BIOS) */
    Task_Params_init(&taskParams);
    taskParams.instance->name = "smain";
    taskParams.stackSize = 0x1000;
    Task_create(smain, &taskParams, &eb);

    if (Error_check(&eb)) {
        System_abort("main: failed to create application startup thread");
    }

    /* register with xdc.runtime to get a diags mask */
    result = Registry_addModule(&Registry_CURDESC, MODULE_NAME);
    Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

    /* start scheduler, this never returns */
    BIOS_start();

    /* should never get here */
    Log_print0(Diags_EXIT, "<-- main:");
    return (0);
}
示例#8
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;
}
示例#9
0
Void randNumInit()
{
    Registry_Result   result;

    result = Registry_addModule(&randDesc, RANDNUM_MODNAME);

    if (result != Registry_SUCCESS) {
        printf("Registry_addModule failed\n");
    }
}
示例#10
0
/*
 *  ======== VIDENCCOPY_TI_alloc ========
 */
Int VIDENCCOPY_TI_alloc(const IALG_Params *algParams,
    IALG_Fxns **pf, IALG_MemRec memTab[])
{
    Registry_Result   result;


    /*
     *  No need to reference count for Registry_addModule(), since there
     *  is no way to remove the module.
     */
    if (regInit == 0) {
        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_examples_codecs_videnc_copy_desc,
                MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(MODNAME);
        }
        regInit = 1;
    }

    Log_print3(Diags_ENTRY, "[+E] VIDENCCOPY_TI_alloc(0x%x, 0x%x, 0x%x)",
            (IArg)algParams, (IArg)pf, (IArg)memTab);

    /* Request memory for my object */
    memTab[0].size = sizeof(VIDENCCOPY_TI_Obj);
    memTab[0].alignment = 0;
    memTab[0].space = IALG_EXTERNAL;
    memTab[0].attrs = IALG_PERSIST;

	// ADD BY ZHENGHANG
   	memTab[1].size = sizeof(char)*25000 * 1024;
    memTab[1].alignment = 0;
    memTab[1].space = IALG_EXTERNAL;//IALG_DARAM0;
    memTab[1].attrs = IALG_PERSIST;

	// ADD BY ZHOULU	
	memTab[2].size = sizeof(char) * 150000 * 1024;
	memTab[2].alignment = 0;
	memTab[2].space = IALG_EXTERNAL;
	memTab[2].attrs = IALG_PERSIST;

	memTab[3].size = sizeof(char) * 127*1024;
	memTab[3].alignment = 0;
	memTab[3].space = IALG_DARAM0;
	memTab[3].attrs = IALG_PERSIST;

//IALG_DARAM0;
    return (4);
}
示例#11
0
/*
 *  ======== Pd_init ========
 */
Void Pd_init(Void)
{
    Registry_Result     result;


    if (curInit++ != 0) {
        return;  /* already initialized */
    }

    /* register with xdc.runtime to get a diags mask */
    result = Registry_addModule(&Registry_CURDESC, MODULE_NAME);
    Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);
}
示例#12
0
/*!
 * ======== _VirtQueue_init ========
 *
 * This function adds the VirtQueue "module" to the Registry so that
 * DIAGS will work with this non-XDC module.
 * Since VirtQueue_init is not called by XDC-VirtQueue module clients, this
 * function is called in the first VirtQueue fxn called: VirtQueue_create.
 */
static Void _VirtQueue_init()
{
    static int initialized = 0;

    if (!initialized) {
        Registry_Result result;

        /* register with xdc.runtime to get a diags mask */
        result = Registry_addModule(&Registry_CURDESC, MODULE_NAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        initialized = 1;
    }
}
示例#13
0
/*
 *  ======== Server_init ========
 */
Void Server_init(Void)
{
    Registry_Result result;

    /* register with xdc.runtime to get a diags mask */
    result = Registry_addModule(&Registry_CURDESC, MODULE_NAME);
    Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

    /* initialize module object state */
    Module.hostProcId = MultiProc_getId("HOST");
    Module.slaveQue = NULL;
    Module.hostGateMPHandle = NULL;
    Module.slaveGateMPHandle = NULL;
}
/*
 *  ======== 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;
}
示例#15
0
/*
 *  ======== RcmClient_init ========
 *
 *  This function *must* be serialized by the caller
 */
Void RcmClient_init(Void)
{
    Registry_Result result;


    if (curInit++ != 0) {
        return; /* module already initialized */
    }

    /* register with xdc.runtime to get a diags mask */
    result = Registry_addModule(&Registry_CURDESC, MODULE_NAME);
    Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

    /* the size of object and struct must be the same */
    Assert_isTrue(sizeof(RcmClient_Object) == sizeof(RcmClient_Struct), NULL);
}
示例#16
0
文件: rmmp.c 项目: mobiaqua/ti-fc
/*
 *  ======== 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);
        }
    }
}
示例#17
0
文件: bufres.c 项目: mobiaqua/ti-fc
/*
 *  ======== 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);
}
示例#18
0
/*
 *  ======== Memory_init ========
 */
Bool Memory_init(Void)
{
    Registry_Result   result;

    /*
     *  No need to reference count for Registry_addModule(), since there
     *  is no way to remove the module.
     */
    if (regInit == 0) {
        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_osal_Memory_desc,
                Memory_MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(Memory_MODNAME);
        }
        regInit = 1;
    }

    if (curInit != TRUE) {
        curInit = TRUE;
        moduleLock = Lock_create(NULL);
        if (moduleLock == NULL) {
            Log_print0(Diags_USER7, "[+7] Memory_init> "
                    "ERROR: could not create pthread mutex.");
            assert(FALSE);
        }

        if (CMEM_init() == -1) {
            Log_print0(Diags_USER7, "[+7] Memory_init> "
                    "ERROR: Failed to initialize CMEM");
        }
        else {
            cmemInitialized = TRUE;
        }

        Global_atexit((Fxn)cleanup);
    }

    return (cmemInitialized);
}
示例#19
0
/*
 *  ======== CESettings_init ========
 */
Void CESettings_init()
{
    Registry_Result result;

    if (curInit++ == 0) {
        /*
         *  Enable logging. This code needs to be placed in an init function
         *  so the app has a chance to call Diags_setMask() before any other
         *  function in this module is called. Calling Diags_setMask() before
         *  Registry_addModule() has no effect.
         */
        result = Registry_addModule(&ti_sdo_ce_settings_desc,
                CESETTINGS_MODNAME);

        if (result != Registry_SUCCESS) {
            /* Can't do logging */
            Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);
        }
    }
}
/*
 *  ======== SystemCfg_init ========
 */
Void SystemCfg_init(Void)
{
    Registry_Result     result;
    GateHwi_Handle      gate;


    if (curInit++ != 0) {
        return;  /* already initialized */
    }

    /* register with xdc.runtime to get a diags mask */
    result = Registry_addModule(&Registry_CURDESC, MODULE_NAME);
    Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

    List_construct(&Mod_objListStruct, NULL);
    Mod_objList = List_handle(&Mod_objListStruct);

    GateHwi_construct(&Mod_gateStruct, NULL);
    gate = GateHwi_handle(&Mod_gateStruct);
    Mod_gate = GateHwi_Handle_upCast(gate);
}
/*
 *  ======== Processor_init ========
 */
Void Processor_init(Void)
{
    Registry_Result   result;

    /*
     *  No need to reference count for Registry_addModule(), since there
     *  is no way to remove the module.
     */
    if (regInit == 0) {
        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_ipc_processor_desc,
                Processor_MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(Processor_MODNAME);
        }
        regInit = 1;
    }
}
/*
 *  ======== Algorithm_init ========
 */
Void Algorithm_init()
{
    Registry_Result   result;

    /*
     *  No need to reference count for Registry_addModule(), since there
     *  is no way to remove the module.
     */
    if (regInit == 0) {
        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_algorithm_desc,
                Algorithm_MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(Algorithm_MODNAME);
        }
        regInit = 1;
    }

    if (curInit++ == 0) {
        RMAN_init();
        DMAN3_CE_init();

        /*
         *  NOTE: We are calling ALG_init() here rather than calling it in
         *  CERuntime_init(). This simplifies the auto-generation of
         *  CERuntime_init(), since ALG is not used in Algorithm_BIOS.c.
         *  Since ALG_init() is called here, to keep the symmetry, we will
         *  also call ALG_exit() from Algorithm_exit(), rather than having
         *  ALG_init() register its exit function through Global_atexit().
         */
        ALG_init();
        Global_atexit((Fxn)Algorithm_exit);
    }
}
示例#23
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);
}
示例#24
0
/*
 *  ======== Memory_init ========
 */
Bool Memory_init(Void)
{
    Registry_Result   result;
    Int               i;
    Memory_Stat       stat;

    static Bool curInit = FALSE;

    if (curInit != TRUE) {
        curInit = TRUE;
        Memory_DEFAULTPARAMS.seg = (UInt)xdc_runtime_Memory_defaultHeapInstance;

        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_osal_Memory_desc,
                Memory_MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(Memory_MODNAME);
        }

        ti_sdo_ce_osal_Memory_cfgInit();

        /*
         *  Note: Memory_originalBase and Memory_originalSize are only
         *  accessed through the RMS server thread, so we don't need to
         *  alloc these buffers inside a Gate_enter() call.
         */
        if ((Memory_numHeaps > 0) && (Memory_originalBase == NULL)) {
            Memory_originalBase = xdc_runtime_Memory_alloc(NULL,
                    Memory_numHeaps * sizeof(Uint32), 0, NULL);
            if (Memory_originalBase == NULL) {
                Log_print0(Diags_USER7, "Memory_init> Memory_alloc() failed");
                return (FALSE);
            }
        }

        if ((Memory_numHeaps > 0) && (Memory_originalSize == NULL)) {
            Memory_originalSize = xdc_runtime_Memory_alloc(NULL,
                    Memory_numHeaps * sizeof(Uint32), 0, NULL);
            if (Memory_originalSize == NULL) {
                xdc_runtime_Memory_free(NULL, Memory_originalBase,
                        sizeof(Uint32) * Memory_numHeaps);
                Log_print0(Diags_USER7, "Memory_init> Memory_alloc() failed");
                return (FALSE);
            }
        }

        /*
         *  Keep track of original size and base of memory heaps in case
         *  someone does a Memory_redefine() then a Memory_restoreHeap().
         */
        for (i = 0; i < Memory_numHeaps; i++) {
            if (!Memory_segStat(i, &stat)) {
                Log_print1(Diags_USER7, "Memory_init> Memory_segStat(%d) "
                        "failed!", (IArg)i);
                Memory_originalBase[i] = (UInt32)-1;
                Memory_originalSize[i] = 0;
            }
            else {
                Memory_originalBase[i] = stat.base;
                Memory_originalSize[i] = stat.size;
            }
        }
    }

    return (TRUE);
}
示例#25
0
/*
 *  ======== 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);
}
/*
 *  ======== Processor_init ========
 */
Void Processor_init(Void)
{
    GateThread_Params params;
    Registry_Result   result;

    /*
     *  No need to reference count for Registry_addModule(), since there
     *  is no way to remove the module.
     */
    if (regInit == 0) {
        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_ipc_processor_desc,
                Processor_MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(Processor_MODNAME);
        }
        regInit = 1;
    }

    if (curInit != TRUE) {
        curInit = TRUE;

        /* Semaphore with count 0, will be posted when a command is present */
        dcmd.cmdPresent = SemThread_create(0, NULL, NULL);

        /* Semaphore with count 0, will be posted when reply is ready */
        dcmd.replyPresent = SemThread_create(0, NULL, NULL);

        /*
         *  Create lock to allow only one thread at a time to send command
         *  to the daemon.
         */
        GateThread_Params_init(&params);
        dcmd.gate = GateThread_create(&params, NULL);

        if ((dcmd.cmdPresent == NULL) || (dcmd.replyPresent == NULL) ||
                (dcmd.gate == NULL)) {
            // TODO: Shouldn't we abort?
            Log_print0(Diags_USER7, "[+7] Processor_init> ERROR: cannot"
                    " create semaphores or lock");
        }

        Log_print0(Diags_USER2, "[+2] Processor_init> SysLink_setup()...");

        SysLink_setup();
        Log_print0(Diags_USER2, "[+2] Processor_init> "
                "... SysLink_setup() done");

        if ((dcmd.dproc = Thread_create((Thread_RunFxn)daemon, NULL, NULL))
                == NULL) {
            Log_print0(Diags_USER7, "[+7] Processor_init> "
                    "ERROR: cannot create DSP daemon");
        }

        if (Thread_start(NULL) != TRUE) {
            Log_print0(Diags_USER7, "[+7] Processor_init> "
                    "ERROR: cannot start threads");
        }

        Global_atexit((Fxn)cleanup);
    }
}