示例#1
0
Int main()
{
    Int size = 0;
    IRES_Status status;
    IRESMAN_Edma3ChanParams configParams; 
    Int i = 0;

    GT_set(MOD_NAME "=01234567");
/*
 * Call to _DSKT2_init is required as it leaks memory when DSKT2 is actually . 
 * Call it before you do MEM_stat
 */
    printf("Testing for Memory Leaks\n");
    _DSKT2_init();
    for (i = 0; i < MAXMEMSEGMENTS; i++) {
        if (!MEM_stat(i, &memStat[i])) {
            memStat[i].size =  memStat[i].used = 0;
            memStat[i].length = 0;
        }
    }

    status = RMAN_init(); 
    if (IRES_OK != status) {
        printf("RMAN initialization Failed \n");
        return -1;
    }

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

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

    status = RMAN_register(&IRESMAN_EDMA3CHAN, (IRESMAN_Params *)&configParams);

    if (IRES_OK != status) {
        printf("Protocol Registration Failed \n");
        return -1;
    }

    return 0;
}
Void  DSKT2_QOS_getStat(Uns heapType, Uns mutexId, Uns *sizeSharedScratch,
    Uns *inHeap)
{
    Int scratchMutexId;
    Int heapId;
    Uns heapStart, heapEnd;
    Uns scratchGroupStart, scratchGroupEnd;
    _DSKT2_ScratchBufferDesc *scrBufDesc;

    DBC_require( (mutexId < DSKT2_NUM_SCRATCH_GROUPS)
                || (mutexId == DSKT2_QOS_ALL_SCRATCHGROUPS));
    GT_assert(ti_sdo_fc_dskt2_GTMask, (mutexId < DSKT2_NUM_SCRATCH_GROUPS)
            || (mutexId == DSKT2_QOS_ALL_SCRATCHGROUPS));

    DBC_require((heapType == DSKT2_QOS_SHARED_SCRATCH_ALLHEAPS)
                || (heapType == DSKT2_QOS_SHARED_SCRATCH_DARAM)
                || (heapType == DSKT2_QOS_SHARED_SCRATCH_SARAM) );

    GT_assert(ti_sdo_fc_dskt2_GTMask,
            (heapType == DSKT2_QOS_SHARED_SCRATCH_ALLHEAPS) || 
            (heapType == DSKT2_QOS_SHARED_SCRATCH_DARAM) || 
            (heapType == DSKT2_QOS_SHARED_SCRATCH_SARAM) );

    _DSKT2_init();

    switch (heapType) {

        case DSKT2_QOS_SHARED_SCRATCH_ALLHEAPS:
                heapStart = 0;
                heapEnd  = DSKT2_NUM_SHAREDHEAPS-1;
                break;

        case DSKT2_QOS_SHARED_SCRATCH_DARAM:
                heapStart = heapEnd = 0;
                *inHeap = _DSKT2_spaceToSeg(IALG_DARAM0);
                break;

        case DSKT2_QOS_SHARED_SCRATCH_SARAM:
                heapStart = heapEnd = 1;
                *inHeap = _DSKT2_spaceToSeg(IALG_SARAM0);
    }

    if (mutexId == DSKT2_QOS_ALL_SCRATCHGROUPS) {
        scratchGroupStart = 0;
        scratchGroupEnd =  DSKT2_NUM_SCRATCH_GROUPS;

    } else {

        scratchGroupStart = scratchGroupEnd = (Uns) mutexId;
    }

    *sizeSharedScratch = 0;

    for (heapId = heapStart; heapId <= heapEnd; heapId++) {

        for (scratchMutexId = scratchGroupStart;
                scratchMutexId <= scratchGroupEnd; scratchMutexId++) {

            scrBufDesc = &_DSKT2_scratchDescTbl[heapId][scratchMutexId];

            if ((scrBufDesc->size > 0) && (scrBufDesc->base != MEM_ILLEGAL )) {
                *sizeSharedScratch += scrBufDesc->size;

            }
        }
    }
}