Ejemplo n.º 1
0
/*
 *  ======== MEM_alloc ========
 */
Ptr MEM_alloc(Int id, size_t size, size_t align)
{
    Error_Block eb;
    
    Error_init(&eb);
    
    if (id < 0) {
        SYS_error( "MEM", SYS_EALLOC, id, size, align );
        return (NULL);
    }

    /*
     *  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) {
        return (xdc_runtime_Memory_alloc(NULL, size, align, &eb));
    }
   
    if ((Uns)id >= MEM_tabSize) {
        SYS_error( "MEM", SYS_EALLOC, id, size, align );
        return (NULL);
    }
   
    if (MEM_table[id] == NULL) {
        SYS_error( "MEM", SYS_EALLOC, id, size, align );
        return(FALSE);
    }

    return (xdc_runtime_Memory_alloc(MEM_table[id], size, align, &eb));
}
Ejemplo n.º 2
0
/*
 *  ======== segAlloc ========
 */
static inline Ptr segAlloc(IHeap_Handle heap, UInt size, UInt align)
{
    if (align == Memory_DEFAULTALIGNMENT) {
        align = 0;
    }

    return (xdc_runtime_Memory_alloc(heap, size, align, NULL));
}
Ejemplo n.º 3
0
/*
 *  ======== Processor_create ========
 */
Processor_Handle Processor_create(String imageName, String linkCfg,
    Processor_Attrs *attrs)
{
    Processor_Handle proc = NULL;

    Log_print3(Diags_ENTRY, "[+E] Processor_create> "
            "Enter(imageName='%s', linkCfg='%s', attrs=0x%x)",
            (IArg)imageName, (IArg)linkCfg, (IArg)attrs);

#if MESSAGEQ_ENABLED
    /* This implementation requires attrs->name to be provided */
    if ((attrs == NULL) || (attrs->cpuId == NULL)) {
        Log_print0(Diags_USER7, "[+7] Processor_create> ERROR: invalid attrs");
        return (NULL);
    }

    if ((proc = xdc_runtime_Memory_alloc(NULL, sizeof(Processor_Obj),
            0, NULL)) == NULL) {
        Log_print0(Diags_USER7, "[+7] Processor_create> "
                "ERROR: Memory_alloc failed");
        return (NULL);
    }

    proc->hHeap = NULL;
    proc->heapId = (UInt16)Processor_INVALID;

    if (!procCreate(proc, attrs->cpuId)) {
        Processor_delete(proc);
        return (NULL);
    }
#endif

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

    return (proc);
}
Ejemplo n.º 4
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);
}