📄 oslesswmroam.c
字号:
// RETAILMSG(1, (L"OAM_Malloc : nMallocPtr=0x%x \n", nMallocPtr));
// RETAILMSG(1, (L"OAM_Malloc : nAlignArrayStart=0x%x \n", nAlignArrayStart));
// RETAILMSG(1, (L"OAM_Malloc : nAlignArrayNumber=0x%x \n", nAlignArrayNumber));
for ( i = nAlignArrayStart; i < nAlignArrayStart+nAlignArrayNumber; i++ )
{
memAddr[i] = USED;
}
if (nMallocPtr+nAlignSize > WMR_LOCAL_MEM_SIZE*4)
{
RETAILMSG(1, (L"aMemBuf=0x%x\n", &(aMemBuf[0])));
RETAILMSG(1, (L"nAlignSize=0x%x nMallocPtr=0x%x WMR_LOCAL_MEM_SIZE=0x%x\n", nAlignSize, nMallocPtr, WMR_LOCAL_MEM_SIZE));
return NULL;
}
for ( i = 0; i < OSLESS_MALLOC_POOL_SIZE_BY_KB; i ++ )
{
// RETAILMSG(1, (L"OAM_Malloc : memarray[%d].startAddress=0x%x \n", i, memarray[i].startAddress));
if ( memarray[i].startAddress == 0 )
{
memarray[i].startAddress = (UINT32)(&(aMemBuf[nMallocPtr]));
memarray[i].size = nAlignSize;
break;
}
}
// RETAILMSG(1, (L"OAM_Malloc : memarray[%d].startAddress=0x%x \n", i, memarray[i].startAddress));
// RETAILMSG(1, (L"OAM_Malloc : memarray[%d].size=0x%x \r\n", i, memarray[i].size));
// RETAILMSG(1, (L"OAM_Malloc : &(aMemBuf[0x%x])=0x%x \r\n", nMallocPtr, &(aMemBuf[nMallocPtr])));
return (VOID *) &(aMemBuf[nMallocPtr]);
#endif
}
/*****************************************************************************/
/* */
/* NAME */
/* OAM_Free */
/* DESCRIPTION */
/* This function free memory that XSR allocated */
/* */
/* PARAMETERS */
/* pMem Pointer to be free */
/* */
/* RETURN VALUES */
/* none */
/* */
/* NOTES */
/* This function is called by function that wants to free memory */
/* */
/* */
/*****************************************************************************/
VOID
OAM_Free(VOID *pMem)
{
#ifdef NO_MALLOC // by dodan2 061216
WMR_RTL_PRINT((TEXT("[FTL:ERR] OAM_Free() : NO_MALLOC defined\r\n")));
while(1);
#else
UINT32 i, j;
UINT32 arraynum;
// RETAILMSG(1, (L"OAM_Free : (UINT32)(pMem)=0x%x \n", (UINT32)(pMem)));
if ( (UINT32)(pMem) != 0xFFFFFFFF )
{
for ( i = 0; i < OSLESS_MALLOC_POOL_SIZE_BY_KB; i ++ )
{
// RETAILMSG(1, (L"OAM_Free : i=%d, memarray[%d].startAddress=0x%x \n", i, i, memarray[i].startAddress));
if ( memarray[i].startAddress == (UINT32)(pMem) )
{
// RETAILMSG(1, (L"OAM_Free : memarray[%d].startAddress=0x%x, memarray[%d].size=0x%x \r\n", i, memarray[i].startAddress, i, memarray[i].size));
// RETAILMSG(1, (L"OAM_Free : memarray[%d].size/1024 = 0x%x \n", i, memarray[i].size/1024));
arraynum = ((UINT32)(pMem) - (UINT32)(&(aMemBuf[0])))/1024;
for ( j = 0; j < memarray[i].size/1024; j++ )
{
// RETAILMSG(1, (L"OAM_Free : j=%d, memAddr[%d]=0x%x \n", j, arraynum, memAddr[arraynum]));
memAddr[arraynum] = FREE;
arraynum++;
}
memarray[i].startAddress = 0;
memarray[i].size = 0;
// RETAILMSG(1, (L"OAM_Free : i=%d \r\n"));
break;
}
}
}
// _OAM_ASSERT(0);
#endif
}
/*****************************************************************************/
/* */
/* NAME */
/* OAM_Memcpy */
/* DESCRIPTION */
/* This function copies data from source to destination. */
/* */
/* PARAMETERS */
/* pDst Destination array Pointer to be copied */
/* pSrc Source data allocated Pointer */
/* nLen length to be copied */
/* */
/* RETURN VALUES */
/* none */
/* */
/* NOTES */
/* This function is called by function that wants to copy source buffer */
/* to destination buffer. */
/* */
/*****************************************************************************/
VOID
OAM_Memcpy(VOID *pDst, VOID *pSrc, UINT32 nLen)
{
register INT32 nCnt;
register UINT8 *pD8, *pS8;
register INT32 nL = nLen;
register UINT32 *pD32, *pS32;
pD8 = (UINT8*)pDst;
pS8 = (UINT8*)pSrc;
if ( ((INT32)pD8 % sizeof(UINT32)) == ((INT32)pS8 % sizeof(UINT32)) )
{
while ( (INT32)pD8 % sizeof(UINT32) )
{
*pD8++ = *pS8++;
nL--;
if( nL <= 0 )
return;
}
pD32 = (UINT32*)pD8;
pS32 = (UINT32*)pS8;
for (nCnt = 0; nCnt <(INT32)(nL / sizeof(UINT32)); nCnt++)
*pD32++ = *pS32++;
pD8 = (UINT8*)pD32;
pS8 = (UINT8*)pS32;
while( nL % sizeof(UINT32) )
{
*pD8++ = *pS8++;
nL--;
}
}
else
{
for( nCnt = 0; nCnt < nL; nCnt++)
*pD8++ = *pS8++;
}
}
/*****************************************************************************/
/* */
/* NAME */
/* OAM_Memset */
/* DESCRIPTION */
/* This function set data of specific buffer. */
/* */
/* PARAMETERS */
/* pSrc Source data allocated Pointer */
/* nV Value to be setted */
/* nLen length to be setted */
/* */
/* RETURN VALUES */
/* none */
/* */
/* NOTES */
/* This function is called by function that wants to set source buffer */
/* own data. */
/* */
/*****************************************************************************/
VOID
OAM_Memset(VOID *pDst, UINT8 nV, UINT32 nLen)
{
register UINT8 *pD8;
register UINT32 *pD32;
register UINT8 nV8 = nV;
register UINT32 nV32 = (UINT32)( nV << 24 | nV << 16 | nV << 8 | nV );
register INT32 nL = (INT32)nLen;
register UINT32 nCnt;
pD8 = (UINT8*)pDst;
while ( (INT32)pDst % sizeof(UINT32) )
{
*pD8++ = nV8;
nL--;
if( nL <= 0 )
return;
}
pD32 = (UINT32*)pD8;
for (nCnt = 0; nCnt <(INT32)(nL / sizeof(UINT32)); nCnt++)
*pD32++ = nV32;
pD8 = (UINT8*)pD32;
while( nL % sizeof(UINT32) )
{
*pD8++ = nV8;
nL--;
}
}
/*****************************************************************************/
/* */
/* NAME */
/* OAM_Assert */
/* DESCRIPTION */
/* assert check */
/* */
/* PARAMETERS */
/* bVal check boolean value */
/* szFile file name */
/* nLine line count */
/* */
/* RETURN VALUES */
/* none */
/* */
/* NOTES */
/* This function is used when system can not support debug */
/* print function */
/* */
/*****************************************************************************/
VOID
OAM_Assert(BOOL32 bVal, const UINT8 *szFile, UINT32 nLine)
{
if(!bVal)
{
WMR_RTL_PRINT((TEXT("[FTL:ERR] OAM_Assert Error [%s:%d]!\r\n"), szFile, nLine));
WMR_RTL_PRINT((TEXT("\n <log P1=\"101\" P2=\"WMROAM\" P3=\"\" P4=\"OAM_Assert()\" P5=\"OAM_Assert Error [%x:%d]\" P6=\"\" P7=\"\" />\n"), szFile, nLine));
while(1);
}
}
void
OAM_Init()
{
UINT32 nIdx;
for (nIdx = 0; nIdx < WMR_LOCAL_MEM_SIZE; nIdx++)
{
aMemBuf[nIdx]=0;
}
nMallocPtr = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -