arm_ucos/src/common/memtest.c
/**********************************************************************
 *
 * Function:    memTestDevice()
 *
 * Description: Test the integrity of a physical memory device by
 *              performing an increment/decrement test over the
 *              entire region.  In the process every storage bit 
 *              in the device is tested as a zero and a one.  The
 *              base address and the size of the region are
 *              selected by the caller.
 *
 * Notes:       
 *
 * Returns:     NULL if the test succeeds.
 *
 *              A non-zero result is the first address at which an
 *              incorrect value was read back.  By examining the
 *              contents of memory, it may be possible to gather
 *              additional information about the problem.
 *
 **********************************************************************/


Test the integrity of a physical memory device by
performing an increment/decrement test over the
entire region.  In the process every storage bit
in the device is tested as a zero and a one.  The
base address and the size of the region are
selected by the caller.



NULL if the test succeeds.

A non-zero result is the first address at which an
incorrect value was read back.  By examining the
contents of memory, it may be possible to gather
additional information about the problem.
Test the integrity of a physical memory device by performing an increment / decrement test over the entire region . In the process every storage bit in the device is tested as a zero and a one . The base address and the size of the region are selected by the caller . NULL if the test succeeds . A non - zero result is the first address at which an incorrect value was read back . By examining the contents of memory it may be possible to gather additional information about the problem .
datum * 
memTestDevice(volatile datum * baseAddress, unsigned long nBytes)	
{
    unsigned long offset;
    unsigned long nWords = nBytes / sizeof(datum);
    datum pattern;
    datum antipattern;
    for (pattern = 1, offset = 0; offset < nWords; pattern++, offset++)
    {
        baseAddress[offset] = pattern;
    }
    for (pattern = 1, offset = 0; offset < nWords; pattern++, offset++)
    {
        if (baseAddress[offset] != pattern)
        {
            return ((datum *) &baseAddress[offset]);
        }
        antipattern = ~pattern;
        baseAddress[offset] = antipattern;
    }
    for (pattern = 1, offset = 0; offset < nWords; pattern++, offset++)
    {
        antipattern = ~pattern;
        if (baseAddress[offset] != antipattern)
        {
            return ((datum *) &baseAddress[offset]);
        }
    }
    return (NULL);
}
datum * memTestDevice ( volatile datum * baseAddress , unsigned long nBytes ) { unsigned long offset ; unsigned long nWords = nBytes / sizeof ( datum ) ; datum pattern ; datum antipattern ; for ( pattern = 1 , offset = 0 ; offset < nWords ; pattern ++ , offset ++ ) { baseAddress [ offset ] = pattern ; } for ( pattern = 1 , offset = 0 ; offset < nWords ; pattern ++ , offset ++ ) { if ( baseAddress [ offset ] != pattern ) { return ( ( datum * ) & baseAddress [ offset ] ) ; } antipattern = ~ pattern ; baseAddress [ offset ] = antipattern ; } for ( pattern = 1 , offset = 0 ; offset < nWords ; pattern ++ , offset ++ ) { antipattern = ~ pattern ; if ( baseAddress [ offset ] != antipattern ) { return ( ( datum * ) & baseAddress [ offset ] ) ; } } return ( NULL ) ; }
Function:    memTestDevice()
Function : memTestDevice ()
/*
     * Fill memory with a known pattern.
     */ /*
     * Check each location and invert it for the second pass.
     */ /*
     * Check each location for the inverted pattern and zero it.
     */