/* fills the memblock of <size> bytes from <startaddr> with "random" pattern  */
void RAM_MemTest_WriteRandomPattern(unsigned long startaddr, unsigned long size, unsigned long *pat)
/* fills the memblock of <size> bytes from <startaddr> with "random" pattern  */
void RAM_MemTest_WriteRandomPattern(unsigned long startaddr, unsigned long size, unsigned long *pat)
{
	unsigned long i, p;
	p = *pat;
	for (i = 0; i < (size / 4); i++) {
		*(unsigned long *) (startaddr + i * 4) = p;
		if ((p % 2) > 0) {
			p ^= i;
			p >>= 1;
			p |= 0x80000000;
		} else {
			p ^= ~i;
			p >>= 1;
		}
	}
	*pat = p;
}