oslessoam.cpp
来自「SAMSUNG S3C6410 CPU BSP for winmobile6」· C++ 代码 · 共 746 行 · 第 1/3 页
CPP
746 行
/*****************************************************************************/
/* */
/* PROJECT : AnyStore II */
/* MODULE : XSR OAM */
/* NAME : OSLess OAM */
/* FILE : OSLessOAM.cpp */
/* PURPOSE : This file contain the OS Adaptation Modules for OSless platform */
/* such as BootLoader */
/* */
/*---------------------------------------------------------------------------*/
/* */
/* COPYRIGHT 2003-2005 SAMSUNG ELECTRONICS CO., LTD. */
/* ALL RIGHTS RESERVED */
/* */
/* Permission is hereby granted to licensees of Samsung Electronics */
/* Co., Ltd. products to use or abstract this computer program for the */
/* sole purpose of implementing a product based on Samsung */
/* Electronics Co., Ltd. products. No other rights to reproduce, use, */
/* or disseminate this computer program, whether in part or in whole, */
/* are granted. */
/* */
/* Samsung Electronics Co., Ltd. makes no representation or warranties */
/* with respect to the performance of this computer program, and */
/* specifically disclaims any responsibility for any damages, */
/* special or consequential, connected with the use of this program. */
/* */
/*---------------------------------------------------------------------------*/
/* */
/* REVISION HISTORY */
/* */
/* 05-AUG-2003 [SongHo Yoon] : first writing */
/* 07-AUG-2003 [Janghwan Kim] : added and modified source code to compile */
/* 09-AUG-2003 [Janghwan Kim] : added OAM_Memcpy, OAM_Memset, OAM_Memcmp */
/* 19-JAN-2003 [SongHo Yoon] : added OAM_USE_STDLIB definition */
/* 19-JAN-2003 [SongHo Yoon] : fixed a bug in OAM_AcquireSM() */
/* change the return value (FALSE32 -> TRUE32)*/
/* 04-NOV-2005 [Younwon Park] : added OAM_GetROLockFlag(VOID) */
/* */
/*****************************************************************************/
#include <Xsr.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
/*****************************************************************************/
/* Global variables definitions */
/*****************************************************************************/
/*****************************************************************************/
/* Local #defines */
/*****************************************************************************/
#define LOCAL_MEM_SIZE OSLESS_MALLOC_POOL_SIZE_BY_KB*1024/sizeof(UINT32)
/*****************************************************************************/
/* Local typedefs */
/*****************************************************************************/
/*****************************************************************************/
/* Local constant definitions */
/*****************************************************************************/
/*****************************************************************************/
/* Static variables definitions */
/*****************************************************************************/
static UINT32 aMemBuf[LOCAL_MEM_SIZE];
static UINT32 nMallocPtr = 0;
/*****************************************************************************/
/* */
/* NAME */
/* OAM_Malloc */
/* DESCRIPTION */
/* This function allocates memory for XSR */
/* */
/* PARAMETERS */
/* nSize [IN] */
/* Size to be allocated */
/* */
/* RETURN VALUES */
/* Pointer of allocated memory */
/* */
/* NOTES */
/* This function is called by function that wants to use memory */
/* */
/*****************************************************************************/
VOID *
OAM_Malloc(UINT32 nSize)
{
UINT32 nAlignSize;
nAlignSize = nSize / sizeof(UINT32);
if (nSize % sizeof(UINT32))
nAlignSize++;
nMallocPtr += nAlignSize;
if (nMallocPtr > LOCAL_MEM_SIZE)
return NULL;
return (VOID *) &(aMemBuf[nMallocPtr - nAlignSize]);
}
/*****************************************************************************/
/* */
/* 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)
{
// _OAM_ASSERT(0);
}
/*****************************************************************************/
/* */
/* 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)
{
#if defined(OAM_USE_STDLIB)
memcpy(pDst, pSrc, nLen);
#else /* OAM_USE_STDLIB */
register INT32 nCnt;
register UINT8 *pD8, *pS8;
register INT32 nL = nLen;
#if defined(OAM_32BIT_MEMCPY_OK)
register UINT32 *pD32, *pS32;
#else
register UINT16 *pD16, *pS16;
#endif
pD8 = (UINT8*)pDst;
pS8 = (UINT8*)pSrc;
#if defined(OAM_32BIT_MEMCPY_OK)
if ( ((INT32)pD8 % sizeof(UINT32)) == 0 && ((INT32)pS8 % sizeof(UINT32))==0 )
{
while ( (INT32)pD8 % sizeof(UINT32) )
{
*pD8++ = *pS8++;
nL--;
if( nL <= 0 )
return;
}
pD32 = (UINT32*)pD8;
pS32 = (UINT32*)pS8;
#else
if ( ((INT32)pD8 % sizeof(UINT16)) == 0 && ((INT32)pS8 % sizeof(UINT16))==0 )
{
while ( (INT16)pD8 % sizeof(UINT16) )
{
*pD8++ = *pS8++;
nL--;
if( nL <= 0 )
return;
}
pD16 = (UINT16*)pD8;
pS16 = (UINT16*)pS8;
#endif
#if defined(OAM_32BIT_MEMCPY_OK)
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 <(INT16)(nL / sizeof(UINT16)); nCnt++)
*pD16++ = *pS16++;
pD8 = (UINT8*)pD16;
pS8 = (UINT8*)pS16;
while( nL % sizeof(UINT16) )
{
*pD8++ = *pS8++;
nL--;
}
#endif
}
else
{
for( nCnt = 0; nCnt < nL; nCnt++)
*pD8++ = *pS8++;
}
#endif /* OAM_USE_STDLIB */
}
/*****************************************************************************/
/* */
/* 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
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?