/*--- EDIT # 0010	21 Sept 1982   11:14:38	DB1:[21,7]FXT.C;17  */
/*--- PREVIOUS EDIT	21 Sept 1982   10:58:34	DB1:[21,7]FXT.C;16  */
/* FXT.C -- TEST THE FX: DEVICE */
#include <stdio.h>
#include <cx.h>
#include <qiofun.h>

int buf[2048];
int xxx[2048];
char fxnam[2];

#define NBLKS (1024+1)		/* number of blocks to check */

main()
{
   int wrd;
   int i;
   int blk;
   int devpar[6];

   if (alun(1, 054106, 0) != IS_SUC)
      printf("alun failed\n");

   for (blk = 0; blk <= NBLKS; blk++) {	/* write & read each block */
      for (i = 0; i < 2048; i++) {
	 buf[i] = (blk << 9) + i*2;
      }
      buf[0] = blk;
      devpar[0] = buf;	/* buffer addr */
      devpar[1] = 512;	/* byte count */
      devpar[2] = 0;
      devpar[3] = 0;
      devpar[4] = 0;		/* disk block #*/
      devpar[5] = 0;
      devpar[4] = blk;
      qiow(IO_WLB, 1, 1, NULL, NULL, devpar);	/* write it */

      devpar[0] = xxx;
      for (i = 0; i < 2048; i++) {
	 xxx[i] = -1;
      }
      qiow(IO_RLB, 1, 1, NULL, NULL, devpar); /* read it back */

      for (i = 0; i < devpar[1]/2; i++) {
	 if (buf[i] != xxx[i]) {
	    printf(" mismatch: blk %0o word %0o\n", blk, 2*i);
	    break;
	 }
      }
   }
}
