/*************************************************************************\ * Copyright (c) 2009 Helmholtz-Zentrum Berlin fuer Materialien und Energie. * Copyright (c) 2002 The University of Chicago, as Operator of Argonne * National Laboratory. * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS BASE Versions 3.13.7 * and higher are distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ /* * Author: Ralph Lange (HZB/BESSY) * * Modification History * 2009-05-15 Ralph Lange (HZB/BESSY) * Restructured OSD parts * * 2011-03-25 E.Bjorklund (LANSCE) * Translate between the devIocStats memeory info structure * and its vxWorks 6 counterpart. * */ /* osdMemUsage.c - vxWorks implementation */ #include /* #include */ #include static memInfo nope = { 0, 0, 0, 0, 0, 0 }; int devIocStatsInitMemUsage (void) { return OK; } int devIocStatsGetMemUsage (memInfo *pmi) { /*============================================================================== * For VxWorks 6 and above, use memPartGetInfo to retrieve the data */ #if _WRS_VXWORKS_MAJOR >= 6 *pmi = nope; /* Clear out the memory info structure */ MEM_PART_STATS vxPmi; /* vxWorks memory partition info structure */ int status = memPartInfoGet (memSysPartId, &vxPmi); if (0 == status) { pmi->numBytesTotal = vxPmi.numBytesFree + vxPmi.numBytesAlloc; pmi->numBytesFree = vxPmi.numBytesFree; pmi->numBytesAlloc = vxPmi.numBytesAlloc; pmi->numBlocksFree = vxPmi.numBlocksFree; pmi->numBlocksAlloc = vxPmi.numBlocksAlloc; pmi->maxBlockSizeFree = vxPmi.maxBlockSizeFree; }/* end if memPartInfoGet succeeded*/ return status; /*============================================================================== * For VxWorks 5, walk the list manually */ #else /* Added by LTH because memPartInfoGet() has a bug when "walking" the list */ FAST PART_ID partId = memSysPartId; BLOCK_HDR * pHdr; DL_NODE * pNode; *pmi = nope; if (ID_IS_SHARED (partId)) /* partition is shared? */ { /* shared partitions not supported yet */ return (ERROR); } /* partition is local */ if (OBJ_VERIFY (partId, memPartClassId) != OK) return (ERROR); /* take and keep semaphore until done */ semTake (&partId->sem, WAIT_FOREVER); for (pNode = DLL_FIRST (&partId->freeList); pNode != NULL; pNode = DLL_NEXT (pNode)) { pHdr = NODE_TO_HDR (pNode); { pmi->numBlocksFree ++ ; pmi->numBytesFree += 2 * pHdr->nWords; if(2 * pHdr->nWords > pmi->maxBlockSizeFree) pmi->maxBlockSizeFree = 2 * pHdr->nWords; } } pmi->numBytesAlloc = 2 * partId->curWordsAllocated; pmi->numBlocksAlloc = partId->curBlocksAllocated; semGive (&partId->sem); pmi->numBytesTotal = sysPhysMemTop(); return (OK); #endif }