Пример #1
0
static inline Void _FNPROF_InitHeap()
{
  HeapMem_Params heapMemPrm;

  UTILS_assert((FNPROF_GBLINFO.hProfileHeapExtMem == NULL));
  /* create memory pool heap  */

  HeapMem_Params_init(&heapMemPrm);

  heapMemPrm.buf = cProfileHeapExtMem;
  heapMemPrm.size = sizeof(cProfileHeapExtMem);

  FNPROF_GBLINFO.hProfileHeapExtMem = HeapMem_Handle_upCast(HeapMem_create(&heapMemPrm, NULL));

  UTILS_assert((FNPROF_GBLINFO.hProfileHeapExtMem != NULL));

  UTILS_assert((FNPROF_GBLINFO.hProfileHeapIntMem == NULL));
  /* create memory pool heap  */

  HeapMem_Params_init(&heapMemPrm);

  heapMemPrm.buf = cProfileHeapIntMem;
  heapMemPrm.size = sizeof(cProfileHeapIntMem);

  FNPROF_GBLINFO.hProfileHeapIntMem = HeapMem_Handle_upCast(HeapMem_create(&heapMemPrm, NULL));

  UTILS_assert((FNPROF_GBLINFO.hProfileHeapIntMem != NULL));

}
Пример #2
0
/*
 *  ======== MEM_define ========
 */
extern Int MEM_define(Ptr base, MEM_sizep length, MEM_Attrs *attrs)
{
    Int                 id;
    IArg                key;
    HeapMem_Params      params;
    HeapMem_Handle      heap;
    IHeap_Handle       *tmpTable;
    Error_Block         eb;

    HeapMem_Params_init(&params);
    params.size = length;
    params.buf = base;
    Error_init(&eb);
    heap = HeapMem_create(&params, &eb);
    if (heap == NULL) {
        return(-1);
    }

    /* Use HeapMem's gate for thread-safety */
    key = HeapMem_enter();

    /* look for empty slot in memory table */
    for (id = 0; id < MEM_tabSize; id++) {
        if (MEM_table[id] == NULL) {
            break;
        }
    }

    /* increase table size if no empty slot found */
    if (id == MEM_tabSize) {
        tmpTable = Memory_calloc(MEM_table[0],
                 (MEM_tabSize + 1) * sizeof(IHeap_Handle), 0, &eb);
        if (tmpTable == NULL) {
            HeapMem_leave(key);
            return(-1);
        }

        memcpy(tmpTable, MEM_table, MEM_tabSize * sizeof(IHeap_Handle));

        if ((MEM_tabSize != 0) && (staticTable != TRUE)) {
            Memory_free(MEM_table[0], MEM_table, MEM_tabSize * sizeof(IHeap_Handle));
        }

        staticTable = FALSE;
        MEM_table = tmpTable;
        MEM_tabSize++;
    }

    MEM_table[id] = HeapMem_Handle_to_xdc_runtime_IHeap(heap);

    HeapMem_leave(key);

    return (id);
}
Пример #3
0
/* ========================================================================== */
TIMM_OSAL_ERRORTYPE TIMM_OSAL_CreateMemoryPool (void)
{
    TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE;
    HeapMem_Params heapMemPrm;

    /* create memory pool heap  */

    HeapMem_Params_init(&heapMemPrm);

    heapMemPrm.buf = g_IntHeapMemory_0;
    heapMemPrm.size = sizeof(g_IntHeapMemory_0);

    g_IntHeapMemory_Handle_0 = HeapMem_create(&heapMemPrm, NULL);

    assert(g_IntHeapMemory_Handle_0 != NULL);

    HeapMem_Params_init(&heapMemPrm);

    heapMemPrm.buf = g_IntHeapMemory_1;
    heapMemPrm.size = sizeof(g_IntHeapMemory_1);

    g_IntHeapMemory_Handle_1 = HeapMem_create(&heapMemPrm, NULL);

    assert(g_IntHeapMemory_Handle_1 != NULL);

    HeapMem_Params_init(&heapMemPrm);

    heapMemPrm.buf = g_IntHeapMemory_2;
    heapMemPrm.size = sizeof(g_IntHeapMemory_2);

    g_IntHeapMemory_Handle_2 = HeapMem_create(&heapMemPrm, NULL);

    assert(g_IntHeapMemory_Handle_2 != NULL);

    /*Nothing to be done*/
    return bReturnStatus;
}