/* * ======== Memory_segStat ======== */ Bool Memory_segStat(Int segId, Memory_Stat *statbuf) { HeapMem_ExtendedStats extStats; xdc_runtime_Memory_Stats memStats; HeapMem_Handle heap; Int numHeaps; // numHeaps = HeapMem_Object_count(); numHeaps = Memory_numHeaps; if ((segId < 0) || (segId >= numHeaps)) { return (FALSE); } //heap = HeapMem_Object_get(NULL, segId); heap = ti_sdo_ce_osal_Memory_heapList[segId]; xdc_runtime_Memory_getStats((xdc_runtime_IHeap_Handle)heap, &memStats); HeapMem_getExtendedStats(heap, &extStats); statbuf->name = ti_sdo_ce_osal_Memory_heapNames[segId]; statbuf->base = (UInt32)extStats.buf; statbuf->size = (UInt)memStats.totalSize; statbuf->used = statbuf->size - (UInt)memStats.totalFreeSize; statbuf->length = (UInt)memStats.largestFreeSize; return (TRUE); }
/* * ======== MEM_stat ======== */ Bool MEM_stat(Int id, MEM_Stat *statbuf) { IArg key; HeapMem_Handle heap; Memory_Stats stat; HeapMem_ExtendedStats extendedStats; if ((id < 0) || ((Uns)id >= MEM_tabSize) || (MEM_table[id] == NULL)) { SYS_error("MEM", SYS_EINVAL); return (FALSE); } heap = HeapMem_Handle_from_xdc_runtime_IHeap(MEM_table[id]); /* Use HeapMem's gate for thread-safety */ key = HeapMem_enter(); HeapMem_getExtendedStats(heap, &extendedStats); Memory_getStats(MEM_table[id], &stat); statbuf->size = stat.totalSize; statbuf->used = stat.totalSize - stat.totalFreeSize; statbuf->length = stat.largestFreeSize; statbuf->space = 1; statbuf->base = extendedStats.buf; HeapMem_leave(key); return (TRUE); }
/* * ======== MEM_getBaseAddress ======== */ Ptr MEM_getBaseAddress(Int id) { HeapMem_ExtendedStats stats; if ((id < 0) || ((Uns)id >= MEM_tabSize) || (MEM_table[id] == NULL)) { SYS_error("MEM", SYS_EINVAL); return (NULL); } HeapMem_getExtendedStats( HeapMem_Handle_from_xdc_runtime_IHeap(MEM_table[id]), &stats); return (stats.buf); }