package/boot/uboot-oxnas/src/board/ox820/ox820.c
/* copied from board/evb64260/sdram_init.c */
/*
 * Check memory range for valid RAM. A simple memory test determines
 * the actually available RAM size between addresses `base' and
 * `base + maxsize'. Some (not all) hardware errors are detected:
 * - short between address lines
 * - short between data lines
 */
copied from board/evb64260/sdram_init.c
Check memory range for valid RAM. A simple memory test determines
the actually available RAM size between addresses `base' and
`base + maxsize'. Some (not all) hardware errors are detected:
- short between address lines
- short between data lines
copied from board / evb64260 / sdram_init . c Check memory range for valid RAM . A simple memory test determines the actually available RAM size between addresses ` base ' and ` base + maxsize ' . Some ( not all ) hardware errors are detected : - short between address lines - short between data lines
static long int dram_size (long int *base, long int maxsize)
{
	volatile long int *addr, *b = base;
	long int cnt, val, save1, save2;
#define STARTVAL (CONFIG_MIN_SDRAM_SIZE / 2)	/* start test at half size */
	for (cnt = STARTVAL / sizeof (long); cnt < maxsize / sizeof (long);
	     cnt <<= 1) {
		addr = base + cnt;	
		save1 = *addr;	
		save2 = *b;	
		*addr = cnt;	
		*b = 0;		
		if ((*b) != 0) {
			*addr = save1;	
			*b = save2;	
			return (0);
		}
		val = *addr;	
		*addr = save1;
		*b = save2;
		if (val != cnt) {
			if (cnt == STARTVAL / sizeof (long))
				cnt = 0;
			return (cnt * sizeof (long));
		}
	}
	return maxsize;
}
static long int dram_size ( long int * base , long int maxsize ) { volatile long int * addr , * b = base ; long int cnt , val , save1 , save2 ; #define STARTVAL  (CONFIG_MIN_SDRAM_SIZE / 2)	/* start test at half size */ for ( cnt = STARTVAL / sizeof ( long ) ; cnt < maxsize / sizeof ( long ) ; cnt <<= 1 ) { addr = base + cnt ; save1 = * addr ; save2 = * b ; * addr = cnt ; * b = 0 ; if ( ( * b ) != 0 ) { * addr = save1 ; * b = save2 ; return ( 0 ) ; } val = * addr ; * addr = save1 ; * b = save2 ; if ( val != cnt ) { if ( cnt == STARTVAL / sizeof ( long ) ) cnt = 0 ; return ( cnt * sizeof ( long ) ) ; } } return maxsize ; }
copied from board/evb64260/sdram_init.c
 Check memory range for valid RAM.
copied from board / evb64260 / sdram_init . c Check memory range for valid RAM .
/* pointer arith! */ /* save contents of addr */ /* save contents of base */ /* write cnt to addr */ /* put null at base */ /* check at base address */ /* restore *addr */ /* restore *b */ /* read *addr */ /* fix boundary condition.. STARTVAL means zero */