/* Simple ramtester; ats@offog.org
   This is unlikely to find non-trivial problems, but it'll identify
   dead SIMMs etc.
*/

#include <stdio.h>
#include <malloc.h>

/* Size of RAM in megs to check */
#define RAMSIZE 64

#define CELLSIZE 512
#define NUMCELLS RAMSIZE*1024/CELLSIZE

int main(int argc, char **argv) {
  int i,j,k,l,v;
  unsigned char *m[NUMCELLS];
  
  for(i=0;i<NUMCELLS;i++) {
    printf("\nmalloced %dK at %08x\n", CELLSIZE, m[i]=malloc(CELLSIZE*1024));
    printf("checking: ");
    fflush(stdout);
    l=0;
    for(j=0;j<CELLSIZE;j++) {
      printf(".");
      fflush(stdout);
      for(k=0;k<1024;k++) {
	for(v=0;v<255;v+=255) {
		*(m[i]+l)=v;
		if (*(m[i]+l)!=v) exit(20);
	}
	l++;
      }
    }
  }
  printf("<hit return>\n");
  getchar();
}
