
VxWorks
BSP Developer’s Guide, 6.0
34
sysMemTop( )
The sysMemTop( ) routine returns the address of the top of VxWorks memory.
During early BSP development, the sysMemTop( ) routine in sysLib.c simply
returns a constant value based on
LOCAL_MEM_LOCAL_ADRS,
LOCAL_MEM_SIZE, PM_RESERVED_MEM (VxWorks 6.0 only), and
USER_RESERVED_MEM.
In most implementations, sysMemTop( ) calls sysPhysMemTop( ) to obtain the
address at the top of physical memory (for more information, see
sysPhysMemTop( ), p.35). Later, during BSP cleanup, the sysPhysMemTop( )
routine can be enhanced to allow automatic memory sizing.
The following is a macro-controlled version of sysMemTop( ) that can be used by
any BSP to support fixed memory size:
/***************************************************************************
*
* sysMemTop - get the address of the top of VxWorks memory
*
* This routine returns a pointer to the first byte of memory not
* controlled or used by VxWorks.
*
* The user can reserve memory space by defining the macro USER_RESERVED_MEM
* in config.h. This routine returns the address of the reserved memory
* area. The value of USER_RESERVED_MEM is in bytes.
*
* RETURNS: The address of the top of VxWorks memory.
*/
char *sysMemTop
(
void
)
{
static char * memTop = NULL;
if ( memTop == NULL )
{
memTop = sysPhysMemTop () - USER_RESERVED_MEM;
#ifdef INCLUDE_EDR_PM
/* account for ED&R persistent memory */
memTop = memTop - PM_RESERVED_MEM;
#endif
}
return memTop ;
}
Comentários a estes Manuais