⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ebootwmroam.c

📁 6410BSP3
💻 C
📖 第 1 页 / 共 2 页
字号:
	if (nSize % sizeof(UINT32))
		nAlignSize++;

	nMallocPtr += nAlignSize;
 	if (nMallocPtr > WMR_LOCAL_MEM_SIZE)
 		return NULL;

	return (VOID *) &(aMemBuf[nMallocPtr - nAlignSize]);
#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
	WMR_RTL_PRINT((TEXT("[FTL:ERR]  OAM_Free() : NO_MALLOC defined\r\n")));
	while(1);
#else
	// no function
#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 + -