/* * ======== 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(¶ms); params.size = size; params.buf = (Ptr)base; HeapMem_construct(HeapMem_struct(heap), ¶ms); return (TRUE); }
/* * ======== Memory_contigStat ======== */ Bool Memory_contigStat(Memory_Stat *statbuf) { GT_1trace(curTrace, GT_ENTER, "Memory_contigStat(0x%lx)\n", statbuf); return (Memory_segStat(DEFAULTSEGMENT, statbuf)); }
/* * ======== Memory_contigStat ======== */ Bool Memory_contigStat(Memory_Stat *statbuf) { Log_print1(Diags_ENTRY, "[+E] Memory_contigStat(0x%lx)", (IArg)statbuf); return (Memory_segStat(DEFAULTSEGMENT, statbuf)); }
/* * ======== 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); }