コード例 #1
0
ファイル: mem.c プロジェクト: CheredHerry/ti-bios
/*
 *  ======== MEM_free ========
 */
Bool MEM_free(Int id, Ptr addr, size_t size)
{
    if (id < 0) {
        SYS_error("MEM", SYS_EFREE, id, addr, size);
        return (FALSE);
    }

    /*
     *  Allow non-legacy apps to use modules that use MEM (e.g. drivers).
     *  Use the default heap in xdc.runtime.Memory.
     */
    if (MEM_tabSize == 0) {
        xdc_runtime_Memory_free(NULL, addr, size);
        return (TRUE);
    }
    
    if (((Uns)id < MEM_tabSize) && (MEM_table[id] != NULL)) {
        xdc_runtime_Memory_free(MEM_table[id], addr, size);
        return (TRUE);
    }
    else {
        SYS_error("MEM", SYS_EFREE, id, addr, size);
        return (FALSE);
    }
}
コード例 #2
0
Int SystemCfg_delete(SystemCfg_Object **objPtr)
{
    Int                 bufSize;
    List_Elem *         elem = NULL;
    SystemCfg_Object *  obj;
    IArg                key;


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

    /* remove object from module list */
    key = GateH_enter(Mod_gate);

    while ((elem = List_next(Mod_objList, elem)) != NULL) {
        obj = (SystemCfg_Object *)elem;

        if (obj == *objPtr) {
            List_remove(Mod_objList, elem);
            break;
        }
    }

    GateH_leave(Mod_gate, key);

    /* delete sync object */
    if ((*objPtr)->semH != NULL) {
        Semaphore_destruct(&(*objPtr)->semObj);
        (*objPtr)->semH = NULL;
    }

    /* free the name buffer */
    bufSize = strlen((*objPtr)->remoteProcName) + 1;
    xdc_runtime_Memory_free(NULL, (Ptr)((*objPtr)->remoteProcName), bufSize);

    /* free the object memory */
    xdc_runtime_Memory_free(NULL, (Ptr)(*objPtr), sizeof(SystemCfg_Object));
    *objPtr = NULL;

    Log_print1(Diags_EXIT, "<-- "FXNN": %d", (IArg)SystemCfg_S_SUCCESS);
    return(SystemCfg_S_SUCCESS);
}
コード例 #3
0
/*
 *  ======== Processor_delete ========
 */
Void Processor_delete(Processor_Handle proc)
{
    Log_print1(Diags_ENTRY, "[+E] Processor_delete> Enter(proc=0x%x)",
            (IArg)proc);

#if MESSAGEQ_ENABLED
    if (proc != NULL) {
        procDelete(proc);

        Log_print1(Diags_USER1,
                "[+1] Processor_delete(0x%x) freeing object ...", (IArg)proc);
        xdc_runtime_Memory_free(NULL, proc, sizeof(Processor_Obj));
    }
#endif
    Log_print0(Diags_EXIT, "[+X] Processor_delete> return");
}
コード例 #4
0
ファイル: RcmClient.c プロジェクト: GAnthony/sysbios-rpmsg
Int RcmClient_create(String server, const RcmClient_Params *params,
        RcmClient_Handle *handle)
{
    RcmClient_Object *obj;
    Error_Block eb;
    Int status = RcmClient_S_SUCCESS;


    Log_print1(Diags_ENTRY, "--> %s: ()", (IArg)FXNN);

    /* initialize the error block */
    Error_init(&eb);
    *handle = (RcmClient_Handle)NULL;

    /* TODO: add check that params was initialized correctly */

    /* allocate the object */
    obj = (RcmClient_Handle)xdc_runtime_Memory_calloc(RcmClient_Module_heap(),
        sizeof(RcmClient_Object), sizeof(Int), &eb);

    if (NULL == obj) {
        Log_error2(FXNN": out of memory: heap=0x%x, size=%u",
            (IArg)RcmClient_Module_heap(), sizeof(RcmClient_Object));
        status = RcmClient_E_NOMEMORY;
        goto leave;
    }

    Log_print1(Diags_LIFECYCLE, FXNN": instance create: 0x%x", (IArg)obj);

    /* object-specific initialization */
    status = RcmClient_Instance_init(obj, server, params);

    if (status < 0) {
        RcmClient_Instance_finalize(obj);
        xdc_runtime_Memory_free(RcmClient_Module_heap(),
            (Ptr)obj, sizeof(RcmClient_Object));
        goto leave;
    }

    /* success, return opaque pointer */
    *handle = (RcmClient_Handle)obj;


leave:
    Log_print2(Diags_EXIT, "<-- %s: %d", (IArg)FXNN, (IArg)status);
    return(status);
}
コード例 #5
0
ファイル: RcmClient.c プロジェクト: GAnthony/sysbios-rpmsg
Int RcmClient_delete(RcmClient_Handle *handlePtr)
{
    RcmClient_Object *obj = (RcmClient_Object *)(*handlePtr);
    Int status = RcmClient_S_SUCCESS;


    Log_print1(Diags_ENTRY, "--> %s: ()", (IArg)FXNN);

    /* finalize the object */
    status = RcmClient_Instance_finalize(obj);

    /* free the object memory */
    Log_print1(Diags_LIFECYCLE, FXNN": instance delete: 0x%x", (IArg)obj);

    xdc_runtime_Memory_free(RcmClient_Module_heap(),
        (Ptr)obj, sizeof(RcmClient_Object));
    *handlePtr = NULL;

    Log_print2(Diags_EXIT, "<-- %s: %d", (IArg)FXNN, (IArg)status);
    return(status);
}
コード例 #6
0
ファイル: Memory_BIOS.c プロジェクト: mobiaqua/ti-ce
/*
 *  ======== 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);
}
コード例 #7
0
ファイル: Memory_BIOS.c プロジェクト: mobiaqua/ti-ce
/*
 *  ======== segFree ========
 */
static inline Void segFree(IHeap_Handle heap, Ptr addr, UInt size)
{
    xdc_runtime_Memory_free(heap, addr, size);
}