/*
 *  ======== Algorithm_delete ========
 */
Void Algorithm_delete(Algorithm_Handle alg)
{
    Algorithm_Obj *pObject = (Algorithm_Obj *)alg;
    IRES_Status status;

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

    if (pObject != NULL) {
        if (pObject->iresFxns) {
            /* Call RMAN fuction to free resources */
            status = RMAN_freeResources(pObject->alg, pObject->iresFxns,
                    pObject->groupId);
            if (status != IRES_OK) {
                Log_print1(Diags_USER7, "[+7] Algorithm_delete> Freeing "
                        "of alg resources through RMAN FAILED (0x%x)",
                        (IArg)status);
            }
        }

        if (pObject->idma3Fxns) {
            Log_print0(Diags_USER4, "[+4] Algorithm_delete> releasing "
                    "DMA resources");
            DMAN3_releaseDmaChannels(&(pObject->alg), &(pObject->idma3Fxns),1);
        }

        if (pObject->alg) {
            ALG_delete(pObject->groupId, pObject->alg, pObject->useCachedMem);
        }

        Memory_free(pObject, sizeof (*pObject), NULL);
    }

    Log_print0(Diags_EXIT, "[+X] Algorithm_delete> Exit");
}
Esempio n. 2
0
/*
 *  ======== Algorithm_delete ========
 */
Void Algorithm_delete(Algorithm_Handle alg)
{
    Algorithm_Obj *pObject = (Algorithm_Obj *)alg;
    IRES_Status status;

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

    if (pObject != NULL) {
        if (pObject->iresFxns) {
            /* Call RMAN fuction to free resources */
            status = RMAN_freeResources(pObject->alg, pObject->iresFxns,
                    pObject->groupId);
            if (status != IRES_OK) {
                Log_print1(Diags_USER7, "[+7] Algorithm_delete> Freeing "
                        "of alg resources through RMAN FAILED (0x%x)",
                        (IArg)status);
            }
        }

        if (pObject->alg) {
            DSKT2_freeAlg(pObject->groupId, pObject->alg);
        }

        Memory_free(pObject, sizeof (*pObject), NULL);
    }

    Log_print0(Diags_EXIT, "[+X] Algorithm_delete> Exit");
}
Esempio n. 3
0
Int32 SWOSD_close(SWOSD_Obj *pObj)
{
    Int32 scratchId = g_scratchIndex;
    IRES_Status status;
    IRES_Fxns * resFxns = &SWOSD_TI_IRES;
	
    if(pObj->algHndl == NULL)
        return SWOSD_EFAIL;

	/*
	* Deactivate All Resources
	*/
	RMAN_deactivateAllResources((IALG_Handle)pObj->algHndl, resFxns, scratchId);

	/* Deactivate algorithm */
	DSKT2_deactivateAlg(scratchId, (IALG_Handle)pObj->algHndl);

    /*
    * Free resources assigned to this algorihtm
    */
    status = RMAN_freeResources((IALG_Handle)pObj->algHndl, resFxns, scratchId);

    if (IRES_OK != status) {
	    return SWOSD_EFAIL;
    }

    DSKT2_freeAlg(scratchId, (IALG_Handle)pObj->algHndl);

    return SWOSD_SOK;
}
Esempio n. 4
0
/*
 *  ======== rmanTask ========
 */
Void rmanTask(UArg arg0, UArg arg1)
{
    Int            taskId = (Int)arg0;
    Int            index = (Int)arg1;  /* index into attrsTable */
    IALG_Fxns    * algFxns = (IALG_Fxns *)&DUMALG_TI_IDUMALG;
    IRES_Fxns    * resFxns = &DUMALG_TI_IRES;
    IDUMALG_Handle dumHandle = NULL;
    IDUMALG_Params params;
    Int            scratchId = attrsTable[index].scratchId;
    Int            yieldFlag = attrsTable[index].yieldFlag;
    Int            priority = attrsTable[index].priority;
    Arg            resourceId = (Arg)(&(attrsTable[index].id));
    Int            i;
    IRES_Status    status;

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

    params.size = sizeof(IDUMALG_Params);

    Log_print4(Diags_USER4, "[+4] rmanTask> "
            "Task #%d: ScratchId %d, Priority %d Yield %d",
            (IArg)taskId, (IArg)scratchId, (IArg)priority, (IArg)yieldFlag);

    params.yieldFlag  = yieldFlag;
    params.taskId = taskId;

    for (i = 0; i < NUM_RESOURCES; i++) {
        params.hdvicp[i] = *((IRES_HDVICP_RequestType *)resourceId + i);
        Log_print1(Diags_USER4, "[+4] rmanTask> "
                "Requesting resource %d (2 => ANY)",
                (IArg)((Int)params.hdvicp[i]));
    }

    /*
     * Create an instance of the algorithm using "algFxns"
     */
    SemThread_pend(mutex, SemThread_FOREVER, NULL);
    dumHandle = (IDUMALG_Handle)DSKT2_createAlg((Int)scratchId,
            (IALG_Fxns *)algFxns, NULL,(IALG_Params *)&params);

    if (dumHandle == NULL) {
        Log_print0(Diags_USER7, "[+7] rmanTask> Alg creation failed");
        System_abort("DSKT2_createAlg() failed, aborting...\n");
    }

    SemThread_post(mutex, NULL);

    /* Assign resources to the algorithm */
    status = RMAN_assignResources((IALG_Handle)dumHandle, resFxns, scratchId);
    if (status != IRES_OK) {
        Log_print1(Diags_USER7, "[+7] rmanTask> Assign resource failed [%d]",
                (IArg)status);
        System_abort("RMAN_assignResources() failed, aborting...\n");
    }


    /* Activate the Algorithm */
    DSKT2_activateAlg(scratchId, (IALG_Handle)dumHandle);

    /* Activate All Resources */
    RMAN_activateAllResources((IALG_Handle)dumHandle, resFxns, scratchId);

    /* Use IALG interfaces to do something */
    dumHandle->fxns->useHDVICP(dumHandle, taskId);

    /* Deactivate All Resources */
    RMAN_deactivateAllResources((IALG_Handle)dumHandle, resFxns, scratchId);

    /* Deactivate algorithm */
    DSKT2_deactivateAlg(scratchId, (IALG_Handle)dumHandle);

    /* Free resources assigned to this algorihtm */
    status = RMAN_freeResources((IALG_Handle)(dumHandle), resFxns, scratchId);
    if (status != IRES_OK) {
        Log_print1(Diags_USER7, "[+7] rmanTask> Free resource failed [%d]",
                (IArg)status);
        System_abort("RMAN_freeResources() failed, aborting...\n");
    }

    /*
     * Free instance of the algorithm created
     */
    SemThread_pend(mutex, SemThread_FOREVER, NULL);
    DSKT2_freeAlg(scratchId, (IALG_Handle)dumHandle);
    SemThread_post(mutex, NULL);

    SemThread_post(done, NULL);

    Log_print0(Diags_EXIT, "[+X] rmanTask> Exit ");
}
Esempio n. 5
0
/* ARGSUSED - this line tells the compiler to not generate compiler warnings
 * for unused arguments */
Int smain(Int argc, Char * argv[])
{
    IRES_Status status;
    Int size = 0;
    Int scratchId = 2;
    IALG_Fxns * algFxns = (IALG_Fxns *)&TEMPLATE_TI_CODECIRES;
    IRES_Fxns * resFxns = &TEMPLATE_TI_IRES;
    IALG_Handle dumHandle = NULL;
    ITEMPLATE_Status algStatus;

    /*
     * Create an instance of the algorithm using "algFxns"
     */
    dumHandle = DSKT2_createAlg(scratchId, (IALG_Fxns *)algFxns, NULL,
            (IALG_Params *)NULL);

    if (dumHandle == NULL) {
        printf("Alg creation failed \n");
        return -1;
    }

    /*
     * Supply initialization information for the RESMAN while registering
     */
    size = sizeof(IRESMAN_Params);

    configParams.allocFxn = RMAN_PARAMS.allocFxn;
    configParams.freeFxn = RMAN_PARAMS.freeFxn;
    configParams.size = size;

    /*
     *  Register the NULL protocol/resource manager with the generic resource
     *  manager
     */
    status = RMAN_register(&IRESMAN_NULLRES, (IRESMAN_Params *)&configParams);

    if (IRES_EEXISTS == status) {
        printf("Protocol Already Registered\n");
    }

    /* Create an instance of an algorithm that implements IALG and IRES_Fxns */
    if (IRES_OK != RMAN_assignResources((IALG_Handle)dumHandle,
                resFxns,scratchId)) {
        printf("Assign Resource Failed \n");
        return (-1);
    }

    /* Activate the Algorithm */
    DSKT2_activateAlg(scratchId, (IALG_Handle)dumHandle);

    /* Activate All Resources */
    RMAN_activateAllResources((IALG_Handle)dumHandle, resFxns, -1);

    /* Use IALG interfaces to do something */
    ((ITEMPLATE_Handle)dumHandle)->fxns->process((ITEMPLATE_Handle)dumHandle,
            (ITEMPLATE_InArgs *)NULL, (ITEMPLATE_OutArgs *)NULL);

    ((ITEMPLATE_Handle)dumHandle)->fxns->control((ITEMPLATE_Handle)dumHandle,
            (ITEMPLATE_Cmd )0, (ITEMPLATE_DynamicParams *)NULL, &algStatus);

    /* Deactivate All Resources */
    RMAN_deactivateAllResources((IALG_Handle)dumHandle, resFxns, -1);

    /* Deactivate algorithm */
    DSKT2_deactivateAlg(scratchId, (IALG_Handle)dumHandle);

    /* Free resources assigned to this algorihtm */
    if (IRES_OK != RMAN_freeResources((IALG_Handle)(dumHandle),
                resFxns, -1)) {
        printf("Free Resource Failed\n");
        return (-1);
    }

    /* Free instance of the algorithm created */
    DSKT2_freeAlg(scratchId, (IALG_Handle)dumHandle);

    /* Unregister the protocol */
    if (IRES_OK != RMAN_unregister(&IRESMAN_NULLRES)) {
        printf("Unregister Protocol Failed\n");
        return (-1);
    }

    RMAN_exit();

    return (0);
}
Esempio n. 6
0
Int rmanTask(Arg scratchId, Arg resourceId,  Arg priority, Arg taskId, 
        Arg yieldFlag)
{

    Int i;
    IALG_Fxns * algFxns = &DUMALG_TI_IALG;
    IRES_Fxns * resFxns = &DUMALG_TI_IRES;
    IDUMALG_Handle dumHandle = NULL; 
    IDUMALG_Params params;

    GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_ENTER, "_rmanTask> Enter \n");

    params.size = sizeof(IDUMALG_Params);

    GT_4trace(ti_sdo_fc_rman_examples_hdvicp, GT_4CLASS, "_rmanTask> "
            "Task #%d: ScratchId %d, Priority %d Yield %d\n",taskId, scratchId,
            priority, yieldFlag);

    params.yieldFlag  = yieldFlag;
    params.taskId = taskId; 

    for (i = 0; i < NUM_RESOURCES; i++) {
        params.hdvicp[i] = *((IRES_HDVICP_RequestType *)resourceId + i);
        GT_1trace(ti_sdo_fc_rman_examples_hdvicp, GT_4CLASS, "_rmanTask> "
        "Requesting resource %d (2 => ANY)\n",(Int)params.hdvicp[i]);
    }
    /*
     * Create an instance of the algorithm using "algFxns" 
     */
    SEM_pend(mutex, SYS_FOREVER);
    dumHandle = (IDUMALG_Handle)DSKT2_createAlg((Int)scratchId, 
            (IALG_Fxns *)algFxns, NULL,(IALG_Params *)&params);
    if (dumHandle == NULL) {
        GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_7CLASS, "_rmanTask> "
                "Alg creation failed\n");
        return -1;
    } 
    SEM_post(mutex);
    /* Assign resources to the algorithm */
    if (IRES_OK != RMAN_assignResources((IALG_Handle)dumHandle,
                resFxns, scratchId)) {
        GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_7CLASS, "_rmanTask> "
                "Assign resource failed\n");
        return -1;
    }


    /*
     * Activate the Algorithm
     */
    DSKT2_activateAlg(scratchId, (IALG_Handle)dumHandle);

    /*
     * Activate All Resources
     */
    RMAN_activateAllResources((IALG_Handle)dumHandle, resFxns, scratchId);

    /*
     * Use IALG interfaces to do something 
     */
        dumHandle->fxns->useHDVICP(dumHandle, taskId);
    
    /*
     * Deactivate All Resources
     */
    RMAN_deactivateAllResources((IALG_Handle)dumHandle, resFxns, scratchId);

    /*
     * Deactivate algorithm 
     */
    DSKT2_deactivateAlg(scratchId, (IALG_Handle)dumHandle);

    /*
     * Free resources assigned to this algorihtm
     */
    if (IRES_OK != RMAN_freeResources((IALG_Handle)(dumHandle),
                resFxns, scratchId)) {
        GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_7CLASS, "_rmanTask> "
                "Free resource failed\n");
        return -1;
    }

    /*
     * Free instance of the algorithm created
     */
    SEM_pend(mutex, SYS_FOREVER);
    DSKT2_freeAlg(scratchId, (IALG_Handle)dumHandle);
    SEM_post(mutex);

    SEM_post(done);

    GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_ENTER, "_rmanTask> Exit \n");

    return 0;
}
/*
 *  ======== smain ========
 */
Int smain(Int argc, Char * argv[])
{
    ISHMALG_Handle     alg;
    ISHMALG_Fxns       fxns = SHMALG_TI_ISHMALG;
    ISHMALG_Params     params = ISHMALG_PARAMS;
    IRES_Fxns          iresFxns = SHMALG_TI_IRES;
    IRES_Status        status;
    Int                scratchId;
    Bool               passed = FALSE;
    Bool               retVal = TRUE;
    Int                fillVal = 1;

    if (argc > 1) {
        fillVal = atoi(argv[1]);
    }
    params.fillVal = fillVal;

    System_printf("shmbuf_test2> Started. buffer fill value: %d\n", fillVal);

    /* Initialize and register resource manager */
    System_printf("Calling RMAN_init()...\n");
    status = RMAN_init();

    if (status != IRES_OK) {
        /* Test failed */
        System_printf("RMAN_init() failed: %s [%d]\n", getError(status),
                status);
        goto done;
    }

    SHMBUF_PARAMS.bufsize = SHMBUFSIZE;
    SHMBUF_PARAMS.isScratch = TRUE;      /* Make the buffer sharable */

    System_printf("Calling RMAN_register()...\n");
    status = RMAN_register(&SHMBUF_MGRFXNS, (IRESMAN_Params *)&SHMBUF_PARAMS);
    if (status != IRES_OK) {
        /* Test failed */
        System_printf("RMAN_register() failed %s [%d]\n", getError(status),
                status);
        goto done;
    }

    scratchId = 1;
    System_printf("Calling DSKT2_createAlg()...\n");
    alg = (ISHMALG_Handle)DSKT2_createAlg(scratchId, (IALG_Fxns *)&fxns,
            NULL, (IALG_Params *)&params);
    if (alg == NULL) {
        System_printf("DSKT2_createAlg() failed\n");
        goto done;
    }

    /* Assign resources to the algorithm */
    System_printf("Calling RMAN_assignResources()...\n");
    status = RMAN_assignResources((IALG_Handle)alg, &iresFxns, scratchId);

    if (status != IRES_OK) {
        System_printf("RMAN_assignResources() failed %s [%d]\n",
                getError(status), status);
        goto done;
    }

    System_printf("Calling DSKT2_activateAlg()...\n");
    DSKT2_activateAlg(scratchId, (IALG_Handle)alg);

    /* Activate All Resources */
    System_printf("Calling RMAN_activateAllResources()...\n");
    status = RMAN_activateAllResources((IALG_Handle)alg, &iresFxns, scratchId);
    if (status != IRES_OK) {
        System_printf("RMAN_activateAllResourceRMAN_unregister(&SHMBUF_MGRFXNS);s() failed %s [%d]\n",
                getError(status), status);
        goto done;
    }

    /* Use the buffer */
    alg->fxns->useBufs(alg);

    /* Hold onto the resource for awhile */
    System_printf("Sleeping...\n");

    sleep(10);

    /* Check contents of the buffer */
    if (!(retVal = alg->fxns->checkBufs(alg))) {
        System_printf("Buffer overwritten by another alg.\n");
    }

    /* Deactivate All Resources */
    System_printf("Calling RMAN_deactivateAllResources()...\n");
    status = RMAN_deactivateAllResources((IALG_Handle)alg, &iresFxns,
            scratchId);
    if (status != IRES_OK) {
        System_printf("RMAN_deactivateAllResources() failed %s [%d]\n",
                getError(status), status);
        goto done;
    }

    /* Deactivate algorithm */
    System_printf("Calling DSKT2_deactivateAlg()...\n");
    DSKT2_deactivateAlg(scratchId, (IALG_Handle)alg);

    /* Free resources assigned to this algorihtm */
    System_printf("Calling RMAN_freeResources()...\n");
    status = RMAN_freeResources((IALG_Handle)(alg), &iresFxns, scratchId);
    if (status != IRES_OK) {
        System_printf("RMAN_freeResources() failed %s [%d]\n",
                getError(status), status);
        goto done;
    }

    /* Free instance of the algorithm created */
    System_printf("Calling DSKT2_freeAlg()...\n");
    DSKT2_freeAlg(scratchId, (IALG_Handle)alg);

    System_printf("Calling RMAN_unregister()...\n");
    status = RMAN_unregister(&SHMBUF_MGRFXNS);
    if (status != IRES_OK) {
        System_printf("RMAN_unregister() failed %s [%d]\n", getError(status),
                status);
        goto done;
    }

    System_printf("Calling RMAN_exit()...\n");
    status = RMAN_exit();
    if (status != IRES_OK) {
        System_printf("RMAN_exit() failed %s [%d]\n", getError(status),
                status);
        goto done;
    }
    else {
        if (retVal) {
            passed = TRUE;
        }
    }

done:

    RMAN_exit();

    if (passed) {
        System_printf("TEST PASSED\n");
    }
    else {
        System_printf("TEST FAILED\n");
    }

    return (0);
}
Esempio n. 8
0
/* ARGSUSED - this line tells the compiler to not generate compiler warnings 
 * for unused arguments */ 
Int smain(Int argc, Char * argv[])
{

    Int scratchId1 = 0;
        Int scratchId2 = 0;
    IALG_Status algStatus;
    IALG_Fxns * algFxns = &DUMRES_TI_IALG;
    IRES_Fxns * resFxns = &DUMRES_TI_IRES;
    DUMRES_TI_Handle algHandle1 = NULL; 
    DUMRES_TI_Handle algHandle2 = NULL; 
    EDMA3_RM_Handle rmHandle = NULL;
    EDMA3_RM_ResDesc resObj;

    MEM_Stat stat;
    Bool retVal;
    Int i = 0;
    /*
     * Create 2 instances of the algorithm using "algFxns" 
     */
    algHandle1 = (DUMRES_TI_Handle)DSKT2_createAlg(scratchId1, 
            (IALG_Fxns *)algFxns, NULL,(IALG_Params *)NULL);
    if (algHandle1 == NULL) {
        printf("Alg creation failed for algHandle1\n");
        return -1;
    } 

    algHandle2 = (DUMRES_TI_Handle)DSKT2_createAlg(scratchId2, 
            (IALG_Fxns *)algFxns, NULL,(IALG_Params *)NULL);
    if (algHandle2 == NULL) {
        printf("Alg creation failed for algHandle2\n");
        return -1;
    } 

    /* Assign resources to the algorithm */
    if (IRES_OK != RMAN_assignResources((IALG_Handle)algHandle1,
                resFxns, scratchId1)) {
        GT_0trace(ti_sdo_fc_rman_examples_scratchEdma3_GTMask, GT_7CLASS,
                "Assign Resource Failed \n");
        goto AppEnd1;
    }

    /*
     * Activate the Algorithm
     */
    DSKT2_activateAlg(scratchId1, (IALG_Handle)algHandle1);

    /*
     * Activate All Resources
     */
    RMAN_activateAllResources((IALG_Handle)algHandle1, resFxns, scratchId1);

    /*
     * Use IALG interfaces to do something 
     */
    DSKT2_controlAlg((IALG_Handle)algHandle1, (IALG_Cmd)NULL, &algStatus);
    
    /* Assign resources to the second algorithm */
    if (IRES_OK != RMAN_assignResources((IALG_Handle)algHandle2,
                resFxns, scratchId2)) {
        printf("Assign Resource Failed \n");
        return -1;
    }

    /*
     * Deactivate All Resources
     */
    RMAN_deactivateAllResources((IALG_Handle)algHandle1, resFxns, scratchId1);

    /*
     * Deactivate algorithm 
     */
    DSKT2_deactivateAlg(scratchId1, (IALG_Handle)algHandle1);

    /*
     * Activate the Algorithm
     */
    DSKT2_activateAlg(scratchId2, (IALG_Handle)algHandle2);

    /*
     * Activate All Resources
     */
    RMAN_activateAllResources((IALG_Handle)algHandle2, resFxns, scratchId2);

    /*
     * Free resources assigned to this algorihtm
     */
    if (IRES_OK != RMAN_freeResources((IALG_Handle)(algHandle1),
                resFxns, scratchId1)) {
        printf("Free Resource Failed \n");
        return -1;
    }
    
    /* 
     * Acquire the EDMA3 handle first
     */           
    rmHandle = EDMA3_getResourceManager(NULL, -1);
    
    if (NULL == rmHandle) {
        printf("Error obtaining SYSTEM resource Manager Handle \n");
        return (-1);
    }

    resObj.resId = 151; 
    resObj.type = EDMA3_RM_RES_PARAM_SET;
    

    if (EDMA3_RM_SOK != EDMA3_RM_allocResource(rmHandle, &resObj)) {
        printf("Could not allocate this resource, as it is already owned by "
                "the algorithm\n");
    }

    resObj.resId = 256; 
    if (EDMA3_RM_SOK != EDMA3_RM_allocResource(rmHandle, &resObj)) {
        printf("Error, could not allocate resource %d\n"
                "ERROR for 6467, OK for 6446\n", resObj.resId);
    }
    
    if (EDMA3_RM_SOK != EDMA3_releaseResourceManager(NULL, -1)) {
        printf("Error releasing system resource manager handle\n");
    } 

    /*
     * Deactivate All Resources
     */
    RMAN_deactivateAllResources((IALG_Handle)algHandle2, resFxns, scratchId2);

    /*
     * Deactivate algorithm 
     */
    DSKT2_deactivateAlg(scratchId2, (IALG_Handle)algHandle2);

    /*
     * Free resources assigned to this algorihtm
     */
    if (IRES_OK != RMAN_freeResources((IALG_Handle)(algHandle2),
                resFxns, scratchId2)) {
        printf("Free Resource Failed \n");
        return -1;
    }

AppEnd1:
    /*
     * Free instance of the algorithm created
     */
    DSKT2_freeAlg(scratchId1, (IALG_Handle)algHandle1);

    /*
     * Free instance of the algorithm created
     */
    DSKT2_freeAlg(scratchId2, (IALG_Handle)algHandle2);

    /*
     * Unregister the protocol
     */
    if (IRES_OK != RMAN_unregister(&IRESMAN_EDMA3CHAN)) {
            printf("Unregister Protocol Failed \n");
            return -1;
    }
    for (i = 0; i < MAXMEMSEGMENTS; i++) {
        retVal = MEM_stat(i, &stat);
        if (!retVal) {
            GT_assert(ti_sdo_fc_rman_examples_scratchEdma3_GTMask, 
                    memStat[i].size == 0);
        }
        else {
            if (memStat[i].used != stat.used) {
                GT_3trace(ti_sdo_fc_rman_examples_scratchEdma3_GTMask,
                        GT_7CLASS, "MEM seg [%d]: orig used = 0x%x, "
                        "curr used = 0x%x", i, memStat[i].used, 
                        stat.used);
                return (-1);
            }
        }
    }

        RMAN_exit();

    return (0);
}
Esempio n. 9
0
/* ARGSUSED */
Int rmanTask(Int argc, Char * argv[])
{
    Int i;
    IALG_Fxns * algFxns = (IALG_Fxns *)&DUMALG_TI_IDUMALG;
    IRES_Fxns * resFxns = &DUMALG_TI_IRES;
    IDUMALG_Handle dumHandle = NULL;
    IDUMALG_Params params;
    Int taskId = 1;
    Int scratchId = -1;

    GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_ENTER, "_rmanTask> Enter\n");

    params.size = sizeof(IDUMALG_Params);

    params.yieldFlag  = FALSE;
    params.taskId = taskId;

    /* Configure the params to indicate the HDVICP requirements of each alg */
    for (i = 0; i < NUM_RESOURCES; i++) {
        params.hdvicp[i] = *((IRES_HDVICP_RequestType *)&attrsTable[0].id[i]);
        GT_1trace(ti_sdo_fc_rman_examples_hdvicp, GT_4CLASS, "_rmanTask> "
        "Requesting resource %d (2 => ANY)\n",(Int)params.hdvicp[i]);
    }

    ALG_init();

    /* Create an instance of the algorithm using "algFxns" */
    dumHandle = (IDUMALG_Handle)ALG_create((IALG_Fxns *)algFxns,
            (IALG_Handle)NULL, (IALG_Params *)&params);
    if (dumHandle == NULL) {
        GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_7CLASS, "_rmanTask> "
                "Alg creation failed\n");
        printf("App failed\n");
        return (myIdle(argc, argv));
    }

    /* Assign resources to the algorithm */
    if (IRES_OK != RMAN_assignResources((IALG_Handle)dumHandle,
                resFxns, scratchId)) {
        GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_7CLASS, "_rmanTask> "
                "Assign resource failed\n");
        return (myIdle(argc, argv));
    }


    /* Activate the Algorithm */
    ALG_activate((IALG_Handle)dumHandle);

    /* Activate All Resources */
    RMAN_activateAllResources((IALG_Handle)dumHandle, resFxns, scratchId);

    /* Use IALG interfaces to do something */
    dumHandle->fxns->useHDVICP(dumHandle, taskId);

    /* Deactivate All Resources */
    RMAN_deactivateAllResources((IALG_Handle)dumHandle, resFxns, scratchId);

    /* Deactivate the algorithm */
    ALG_deactivate((IALG_Handle)dumHandle);

    /* Free resources assigned to this algorithm */
    if (IRES_OK != RMAN_freeResources((IALG_Handle)(dumHandle),
                resFxns, scratchId)) {
        GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_7CLASS, "_rmanTask> "
                "Free resource failed\n");
        return (myIdle(argc, argv));
    }

    /* Free instance of the algorithm created */
    ALG_delete((IALG_Handle)dumHandle);

    GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_ENTER, "_rmanTask> Exit\n");

    return (myIdle(argc, argv));
}
Esempio n. 10
0
/* ARGSUSED - this line tells the compiler to not generate compiler warnings
 * for unused arguments */
Int smain(UArg arg0, UArg arg1)
{
    IRES_Status         status;
    Int                 size = 0;
    Int                 scratchId = 2;
    IALG_Status         algStatus;
    IALG_Fxns         * algFxns = &DUMRES_TI_IALG;
    IRES_Fxns         * resFxns = &DUMRES_TI_IRES;
    DUMRES_TI_Handle    dumHandle = NULL;


    status = RMAN_init();
    if (IRES_OK != status) {
        System_abort("RMAN initialization Failed \n");
    }

    /*
     * Create an instance of the algorithm using "algFxns"
     */
    dumHandle = (DUMRES_TI_Handle)DSKT2_createAlg(scratchId,
            (IALG_Fxns *)algFxns, NULL, (IALG_Params *)NULL);
    if (dumHandle == NULL) {
        System_abort("Alg creation failed \n");
    }

    /* Create an instance of an algorithm that implements IALG and IRES_Fxns */
    status = RMAN_assignResources((IALG_Handle)dumHandle, resFxns, scratchId);
    if (status != IRES_OK) {
        System_printf("Assign Resource Failed [%d]\n", status);
        System_abort("Aborting...\n");
    }


    /* Activate the Algorithm */
    DSKT2_activateAlg(scratchId, (IALG_Handle)dumHandle);

    /* Activate All Resources */
    RMAN_activateAllResources((IALG_Handle)dumHandle, resFxns, scratchId);

    /* Use IALG interfaces to do something */
    DSKT2_controlAlg((IALG_Handle)dumHandle, (IALG_Cmd)NULL, &algStatus);

    /* Deactivate All Resources */
    RMAN_deactivateAllResources((IALG_Handle)dumHandle, resFxns, scratchId);

    /* Deactivate algorithm */
    DSKT2_deactivateAlg(scratchId, (IALG_Handle)dumHandle);

    /* Free resources assigned to this algorihtm */
    status = RMAN_freeResources((IALG_Handle)(dumHandle), resFxns, scratchId);
    if (status != IRES_OK) {
        System_printf("Free Resource Failed [%d]\n", status);
        System_abort("Aborting...\n");
    }

    /* Free instance of the algorithm created */
    DSKT2_freeAlg(scratchId, (IALG_Handle)dumHandle);

    RMAN_exit();
        
    return (1);
}
Esempio n. 11
0
/* ARGSUSED - this line tells the compiler to not generate compiler warnings
 * for unused arguments */
Int smain(Int argc, Char * argv[])
{
    IRES_Status     status;
    Int             scratchId = 2;
    IALG_Fxns     * algFxns = (IALG_Fxns *)&DUMRES_TI_IDUMRES;
    IRES_Fxns     * resFxns = &DUMRES_TI_IRES;
    IDUMRES_Handle  dumHandle = NULL;
    IDUMRES_Params  params;
    Int             sleepTime = 0;

    if (argc > 1) {
        sleepTime = atoi(argv[1]);
    }

    if (argc > 2) {
        scratchId = atoi(argv[2]);
    }

    ALG_init();

    /* Create an instance of the algorithm using "algFxns" */
    //params.taskId = taskId;
    params.taskId = 6;
    dumHandle = (IDUMRES_Handle)ALG_create( (IALG_Fxns *)algFxns,
            (IALG_Handle)NULL, (IALG_Params *)&params);
    if (dumHandle == NULL) {
        printf("Alg creation failed \n");
        return (-1);
    }

    /* Create an instance of an algorithm that implements IALG and IRES_Fxns */
    status = RMAN_assignResources((IALG_Handle)dumHandle, resFxns,scratchId);
    if (IRES_OK != status) {
        printf("Assign Resource Failed \n");
        result = FALSE;
    }
    else {
        ALG_activate((IALG_Handle)dumHandle);

        /* Activate All Resources */
        RMAN_activateAllResources((IALG_Handle)dumHandle, resFxns, -1);

        SLEEP(sleepTime);

        /* Deactivate All Resources */
        RMAN_deactivateAllResources((IALG_Handle)dumHandle, resFxns, -1);

        ALG_deactivate((IALG_Handle)dumHandle);

        /* Free resources assigned to this algorihtm */
        status = RMAN_freeResources((IALG_Handle)(dumHandle), resFxns,
                scratchId);
        if (IRES_OK != status) {
            printf("Free Resource Failed \n");
            result = FALSE;
        }
    }

    ALG_delete((IALG_Handle)dumHandle);

    status = RMAN_exit();

    if (status != IRES_OK) {
        result = FALSE;
    }

    if (result) {
        printf("TEST PASSED\n");
    }
    else {
        printf("TEST FAILED.\n");
    }
}
Esempio n. 12
0
/* ARGSUSED - this line tells the compiler to not generate compiler warnings 
 * for unused arguments */ 
Int smain(Int argc, String argv[])
{

    Int scratchId1 = 0;
        Int scratchId2 = 1;
/*      IALG_Status algStatus;*/
    IALG_Fxns * algFxns = &DUMRES_TI_IALG;
    IRES_Fxns * resFxns = &DUMRES_TI_IRES;
    DUMRES_TI_Handle dumHandle1 = NULL; 
    DUMRES_TI_Handle dumHandle2 = NULL; 
    EDMA3_Handle rmHandle = NULL;
    EDMA3_ResDesc resObj;
    Bool status = TRUE; 
    IDUMRES_Params params;

    if (argc > 1) {
        scratchId1 = atoi(argv[1]);
    }
 
    if (argc > 2) {
        scratchId2 = atoi(argv[2]);
    }
    ALG_init();
    /*
     * Create an instance of the algorithm using "algFxns" 
     */
    params.algNum = 1;
    dumHandle1 = (DUMRES_TI_Handle)ALG_create((IALG_Fxns *)algFxns,
            (IALG_Handle)NULL, (IALG_Params *)&params);
    if (dumHandle1 == NULL) {
        printf("Alg1 creation failed \n");
        return -1;
    } 

    params.algNum = 2;
    dumHandle2 = (DUMRES_TI_Handle)ALG_create((IALG_Fxns *)algFxns,
            (IALG_Handle)NULL, (IALG_Params *)&params);
    if (dumHandle2 == NULL) {
        printf("Alg2 creation failed \n");
        return -1;
    } 

    /* Create an instance of an algorithm that implements IALG and IRES_Fxns */
    if (IRES_OK != RMAN_assignResources((IALG_Handle)dumHandle1,
                resFxns,scratchId1)) {
        printf("Assign Resource Failed \n");
        status = FALSE;
        goto AppEnd1;
    }

    /*
     * Activate the Algorithm
     */
    ALG_activate((IALG_Handle)dumHandle1);

    /*
     * Activate All Resources
     */
    RMAN_activateAllResources((IALG_Handle)dumHandle1, resFxns, scratchId1);

    /*
     * Use IALG interfaces to do something 
     */
    //TODO: DSKT2_controlAlg((IALG_Handle)dumHandle, (IALG_Cmd)NULL, &algStatus);
    
    /* Assign resources to the second algorithm */
    if (IRES_OK != RMAN_assignResources((IALG_Handle)dumHandle2,
                resFxns, scratchId2)) {
        printf("Assign Resource Failed \n");
        return -1;
    }
    /*
     * Deactivate All Resources
     */
    RMAN_deactivateAllResources((IALG_Handle)dumHandle1, resFxns, scratchId1);

    /*
     * Deactivate algorithm 
     */
    ALG_deactivate((IALG_Handle)dumHandle1);

    /*
     * Activate the Algorithm
     */
    ALG_activate((IALG_Handle)dumHandle2);

    /*
     * Activate All Resources
     */
    RMAN_activateAllResources((IALG_Handle)dumHandle2, resFxns, scratchId2);

    /*
     * Free resources assigned to this algorihtm
     */
    if (IRES_OK != RMAN_freeResources((IALG_Handle)(dumHandle1),
                resFxns, scratchId1)) {
        printf("Free Resource Failed \n");
        return -1;
    }
    /* 
     * Acquire the EDMA3 handle first
     */           
    rmHandle = EDMA3_getResourceManager((IALG_Handle)NULL, (Int)-1);
    
    if (NULL == rmHandle) {
        printf("Error obtaining SYSTEM resource Manager Handle \n");
        return (-1);
    }

    resObj.resId = 65; 
    resObj.type = EDMA3_RES_PARAM_SET;
    

    if (EDMA3_SOK != EDMA3_allocResource(rmHandle, &resObj)) {
        printf("Note, could not allocate this resource.\n");
    }

    resObj.resId = 126; 
    if (EDMA3_SOK != EDMA3_allocResource(rmHandle, &resObj)) {
        printf("Note, could not allocate resource %d\n", resObj.resId);
    }
    
    if (EDMA3_SOK != EDMA3_releaseResourceManager(NULL, -1)) {
        printf("Note, releasing system resource manager handle\n");
    } 

    /*
     * Deactivate All Resources
     */
    RMAN_deactivateAllResources((IALG_Handle)dumHandle2, resFxns, scratchId2);

    /*
     * Deactivate algorithm 
     */
    ALG_deactivate((IALG_Handle)dumHandle2);

    /*
     * Free resources assigned to this algorihtm
     */
    if (IRES_OK != RMAN_freeResources((IALG_Handle)(dumHandle2),
                resFxns, scratchId2)) {
        printf("Free Resource Failed \n");
        return -1;
    }

AppEnd1:
    /*
     * Free instance of the algorithm created
     */
    ALG_delete((IALG_Handle)dumHandle1);

    /*
     * Free instance of the algorithm created
     */
    ALG_delete((IALG_Handle)dumHandle2);

    RMAN_exit();

    if (status)
        printf("Application exiting normally\n");

    return (0);
}
Esempio n. 13
0
/*
 *  ======== RMAN_assignResources ========
 *  Assign resources to the algorithm indicated by alg. The resource
 *  requirements can be determined by using the IRES_Fxns implementation
 */
IRES_Status RMAN_assignResources(IALG_Handle alg, IRES_Fxns * resFxns,
        Int scratchGroupId)
{
    Int              numResources;
    Int              k;
    Int              n = 0;
    size_t           resDescSize;
    IRESMAN_Fxns   * resman = NULL;
    IRES_Status      status = IRES_OK;
    IRES_Status      freeStatus = IRES_OK;
    IRES_Status      algStatus = IRES_OK;
    IRES_YieldFxn    yieldFxn = NULL;
    IRES_YieldArgs * yieldArgs = NULL;
    IRES_ResourceDescriptor * resDesc = NULL;
    IArg             key;


    if (initStatus != IRES_OK) {
        Log_print0(Diags_USER7, "[+7] RMAN_assignResources> "
                "RMAN_init call hasn't happened successfully. Please "
                "initialize RMAN before calling any other RMAN API");

        Log_print0(Diags_EXIT, "[+X] RMAN_assignResources> "
                "Exit (status=IRES_ENOINIT)");
        return (IRES_ENOINIT);
    }

    Assert_isTrue(resFxns != NULL, (Assert_Id)NULL);
    Assert_isTrue(RMAN_PARAMS.allocFxn != NULL, (Assert_Id)NULL);
    Assert_isTrue(RMAN_PARAMS.freeFxn != NULL, (Assert_Id)NULL);

    Log_print3(Diags_ENTRY, "[+E] RMAN_assignResources> "
            "Enter (alg=0x%x, resFxns=0x%x, scratchGroupId=%d)",
            (IArg)alg, (IArg)resFxns, (IArg)scratchGroupId);

    /*
     *  Get resource requirements of the algorithm
     */
    numResources = (resFxns->numResourceDescriptors)(alg);
    resDescSize = numResources * sizeof(IRES_ResourceDescriptor);

    /* Allocate memory to hold algorithm's resource descriptors */
    if ((resDesc = myAlloc(resDescSize, 0)) == NULL) {
        Log_print1(Diags_USER7, "[+7] RMAN_assignResources> "
                "Could not allocate memory size 0x%x in space "
                "IALG_EXTERNAL of type IALG_PERSIST", (IArg)resDescSize);

        Log_print0(Diags_EXIT, "[+X] RMAN_assignResources> "
                "Exit (status=IRES_ENOMEM)");

        return (IRES_ENOMEM);
    }

    algStatus = resFxns->getResourceDescriptors(alg, resDesc);

    if (algStatus != IRES_OK) {
        Log_print3(Diags_USER7, "[+7] RMAN_assignResources> Error obtaining "
                "Resource Descriptors [status: %d] from alg 0x%x, "
                "IRES interface 0x%x",
                (IArg)algStatus, (IArg)alg, (IArg)resDesc);

        status = IRES_EALG;
    }

    if (status == IRES_OK) {
        /* For each requested resource */
        for (n = 0 ; n < numResources; n++) {
            /* If someone populated the resource descriptor improperly, bail */
            if ((resDesc[n].resourceName == NULL) ||
                    (resDesc[n].revision == NULL)) {

                Log_print0(Diags_USER7, "[+7] RMAN_assignResources> "
                        "Resource protocol and/or version were NULL. "
                        "Most likely an issue  with the algorithm's "
                        "getResourceRequestDescriptor implementation.");

                status = IRES_EALG;
                break;
            }

            resman = getResman(resDesc[n].resourceName, resDesc[n].revision);

            if (resman != NULL) {
                /*
                 *  Call getHandle on the IRESMAN implementation using
                 *  the protocolArgs extracted.
                 */
                Log_print1(Diags_USER2, "[+2] RMAN_assignResources> Call "
                        "getHandle on the IRESMAN implementation 0x%x",
                        (IArg)resman);

                /* Acquire lock */
                key = IGateProvider_enter(gate);

                resDesc[n].handle = resman->getHandle(alg, &resDesc[n],
                        scratchGroupId, &status);

                /* Release lock */
                IGateProvider_leave(gate, key);

                if (IRES_OK != status) {
                    break;
                }
            }
            else {
                Log_print2(Diags_USER7, "[+7] RMAN_assignResources> "
                        "Resource protocol %s and version 0x%x didn't match "
                        "any registered protocol.",
                        (IArg)(resDesc[n].resourceName),
                        (IArg)(resDesc[n].revision));

                status = IRES_ENOTFOUND;
                break;
            }
        }
    }

    /* n = number of resources allocated */

    /*
     * Return those handles to IALG using the appropriate IRES call
     */
    if (IRES_OK == status) {

        if ((RMAN_PARAMS.yieldFxn != NULL) &&
                (ti_sdo_fc_rman_RMAN_setYieldArgs != NULL)) {

            yieldFxn = RMAN_PARAMS.yieldFxn;

            yieldArgs = ti_sdo_fc_rman_RMAN_setYieldArgs(scratchGroupId,
                    RMAN_PARAMS.yieldSamePriority);
        }

        /* Acquire lock */
        key = IGateProvider_enter(gate);

        algStatus = resFxns->initResources(alg, resDesc, yieldFxn, yieldArgs);

        /* Release lock */
        IGateProvider_leave(gate, key);

        if (algStatus != IRES_OK) {
            Log_print1(Diags_USER7, "[+7] RMAN_assignResources> "
                    "resFxns->initResources() failed [%d]", (IArg)algStatus);
            status = IRES_EALG;
        }
    }

    if (status != IRES_OK) {
        /*
         *  Error somewhere in initialization of resource handles
         *  Free all allocated handles.
         */

        for (k = 0; k < n; k++) {
            resman = getResman(resDesc[k].resourceName, resDesc[k].revision);

            if (NULL == resman) {
                /* Resource table is messed up - bail out */
                Log_print2(Diags_USER7, "[+7] RMAN_assignResources> Could "
                        "not find IRESMAN matching resource %s version 0x%x",
                        (IArg)(resDesc[k].resourceName),
                        (IArg)(resDesc[k].revision));

                status = IRES_EFAIL;
                break;
            }

            /* Acquire lock */
            key = IGateProvider_enter(gate);

            freeStatus = resman->freeHandle(alg, resDesc[k].handle, &resDesc[k],
                                scratchGroupId);

            /* Release lock */
            IGateProvider_leave(gate, key);

            if (freeStatus != IRES_OK) {
                /*
                 *  If we can't free the resource handle, something is really
                 *  messed up. Don't try to free anything else.
                 */
                status = IRES_EFAIL;
                Log_print2(Diags_USER7, "[+7] RMAN_assignResources> Free "
                        "handle failed [%d] on IRESMAN implementation 0x%x",
                        (IArg)status, (IArg)resman);

                break;
            }
        }
    }
    else {
        /* Status is OKAY, add entry to table */
        /*
        if (FALSE == addVTableEntry((IALG_Fxns *)alg->fxns,
                resFxns)) {
        */
        if (FALSE == addVTableEntry((IALG_Handle)alg, resFxns)) {
/* TODO: Add trace */
            status = IRES_EFAIL;
            RMAN_freeResources(alg, resFxns, scratchGroupId);
        }
    }

    if (resDesc) {
        myFree(resDesc, resDescSize);
    }

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

    return (status);
}