Esempio n. 1
0
/*
 *  ======== Memory_redefine ========
 */
Bool ti_sdo_ce_osal_Memory_redefine(Int segId, Uint32 base, Uint32 size)
{
    HeapMem_Params params;
    HeapMem_Handle heap;
    Memory_Stat    stat;

    if ((segId < 0) || (segId >= Memory_numHeaps)) {
        Log_print2(Diags_USER7, "Memory_redefine> segId (%d) out of range. "
                "Should be < %d", (IArg)segId,
                (IArg)Memory_numHeaps);
        return (FALSE);
    }

    if (!Memory_segStat(segId, &stat)) {
        Log_print0(Diags_USER7, "Memory_redefine> Memory_segStat() failed!");
        return (FALSE);
    }

    if (stat.used > 0) {
        Log_print0(Diags_USER7, "Memory_redefine> Heap in use!");
        return (FALSE);
    }

    heap = ti_sdo_ce_osal_Memory_heapList[segId];

    HeapMem_destruct(HeapMem_struct(heap));

    HeapMem_Params_init(&params);
    params.size = size;
    params.buf = (Ptr)base;

    HeapMem_construct(HeapMem_struct(heap), &params);

    return (TRUE);
}
Esempio n. 2
0
/*
 *  ======== MEM_redefine ========
 */
Void MEM_redefine(Int id, Ptr base, MEM_sizep length)
{
    IArg           key;
    HeapMem_Params params;
    HeapMem_Handle heap;

    /* Make sure the segid is valid. */    
    if ((id < 0) || (id == 0) || ((Uns)id >= MEM_tabSize)) {
        SYS_error("MEM", SYS_EINVAL);
        return;
    }
    
    key = HeapMem_enter();
    
    if (MEM_table[id] == NULL) {
        HeapMem_leave(key);
        SYS_error("MEM", SYS_EINVAL);        
        return;
    }
    
    heap = HeapMem_Handle_from_xdc_runtime_IHeap(MEM_table[id]);

    HeapMem_destruct(HeapMem_struct(heap));

    HeapMem_Params_init(&params);
    params.size = length;
    params.buf = base;

    HeapMem_construct(HeapMem_struct(heap), &params);

    HeapMem_leave(key);
}
Esempio n. 3
0
/*
 *  ======== main ========
 */
Int main()
{
    /* Call board init functions */
    Board_initGeneral();

    /* Construct BIOS objects */
    Task_Params taskParams;
    HeapBuf_Params heapBufParams;
    HeapMem_Params heapMemParams;

    /* Construct writer/reader Task threads */
    Task_Params_init(&taskParams);
    taskParams.stackSize = TASKSTACKSIZE;
    taskParams.stack = &task0Stack;
    Task_construct(&task0Struct, (Task_FuncPtr)task0Fxn, &taskParams, NULL);

    taskParams.stack = &task1Stack;
    Task_construct(&task1Struct, (Task_FuncPtr)task1Fxn, &taskParams, NULL);

    /* Construct two heaps to be used by two separate tasks for alloc and free. */
    HeapBuf_Params_init(&heapBufParams);
    heapBufParams.blockSize = HEAPBUFSIZE / 2;
    heapBufParams.numBlocks = 2;
    heapBufParams.align = 8;
    heapBufParams.buf = heapBufBuffer;
    heapBufParams.bufSize = HEAPBUFSIZE;
    HeapBuf_construct(&heapBufStruct, &heapBufParams, NULL);
    task0Heap = HeapBuf_handle(&heapBufStruct);

    HeapMem_Params_init(&heapMemParams);

    heapMemParams.size = HEAPMEMSIZE;
    heapMemParams.minBlockAlign = 8;
    heapMemParams.buf = heapMemBuffer;
    HeapMem_construct(&heapMemStruct, &heapMemParams);
    task1Heap = HeapMem_handle(&heapMemStruct);

    System_printf("Memory example started.\n");

    BIOS_start();    /* Does not return */
    return(0);
}