File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / d / ioex / tm_ex.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:24:19 2019 UTC (6 years, 11 months ago) by root
Branches: bsd, MAIN
CVS tags: v12b, v121, HEAD
Power 6/32 Unix version 1.2b


#include "cy.h"
#include "cyconf.h"
#define NBPG	1024
asm(".set NBPG,1024");

extern long iob0, iob2, iob4, cmd_done;
extern struct tpb tpb;
extern struct ccb ccblk;
struct tpblk *tblk;

long tm_err;

tm_ex()
{
	register long tm_bsiz;

	writes("\n\t** Tape test **\n");
	tm_err = 0;
	if ( !(tm_bsiz = tape_op(CONFIG,0,0))) return;
	writes("Tape master internal buffer size ");
	writed(tm_bsiz); writes(" bytes\n");

	tm_rew(); 		/* rewind tape */
	tm_ex1(&iob0);

	tblk = (struct tpblk *)&tpb;
	tm_ex2(&iob0, &iob2, &iob4);

	if (!tm_err) writes("\nTape passed..\n");
		else writes("\nTape failed..\n");

}


/*	(1) write 1 block of data with pattern '1' : 1024 bytes
	(2) repeat 5 times for '2' '3' '4' '5'
	(3) rewind tape
	(4) read 1 block of data : 1024 bytes
	(5) check against pattern
	(6) repeat step (4), (5) 5 times
*/
tm_ex1(Sysbuf)
char *Sysbuf;
{	register long ix, iy, rtn_cnt;
	char pat;

	/* Write 5 block of data */
	pat = '1';
	writec('\n');
	for(ix=0; ix<5; ix++, pat++) {
		for (iy=0;iy<TM_BSIZE;iy++) Sysbuf[iy] = pat;  /* Set pattern */
		if ((rtn_cnt=tape_op(WRIT_TA,Sysbuf,TM_BSIZE)) == -1) 
			{ tm_err = 1;
			ex_err("TM1 exercise write error\n"); }
			
		if (rtn_cnt != TM_BSIZE) { tm_err = 1; tm_cerr(rtn_cnt); }
		}

	tm_rew(); 		/* rewind tape */

	/* Read and check 5 block of data */
	pat = '1';
	for(ix=0; ix<5; ix++) {
		for (iy=0;iy<TM_BSIZE;iy++) Sysbuf[iy] = 0;  /* clear pattern */
		if ((rtn_cnt=tape_op(READ_TA,Sysbuf,TM_BSIZE)) == -1) 
			{ tm_err = 1;
			writes("TM1 exercise read error\n"); }
		   else {
			if (rtn_cnt != TM_BSIZE) { tm_err=1; tm_cerr(rtn_cnt);}
			for (iy=0;iy<TM_BSIZE;iy++) {
				if (Sysbuf[iy] != pat)  {
				   writes("\nBlock "); writec(ix+'0');
				   writes("  compare error, expected ");
				   writec(pat); writes(" , actual ");
				   writec(Sysbuf[iy]);
				   tm_err = 1;
				   break; }
				}
			}
		pat++;
		}
}



/*	This test tries by create memory contention between Tahoe
	and the tape master by the following actions :
		(1) Sent a command to Tape master to move 2 blocks
		    of data in Tahoe memory to buffer X, X+1
		(2) use movblk instruction to move the same 2 blocks
		    to buffer Y, Y+1 and keep doing this until cmd_done
		    (indicate tape master done with command)
		(3) compare buffer X, X+1 with Y, Y+1.
*/
tm_ex2(srcbuf, tdest, sdest)
char *srcbuf, *tdest, *sdest;
{	register long ix, *lptr;

	tm_err = 0;
	lptr = (long *)srcbuf; 		/* Write pattern to source buffers */
	for (ix=0; ix<((NBPG*2)/4); ix++) *lptr++ = ix; 
	lptr = (long *)tdest;
	for (ix=0; ix<((NBPG*4)/4); ix++) *lptr++ = 0;  /* Clear destination */

	tblk_mv(srcbuf,tdest,NBPG*2);	/* Set up Tpb to move 2 blocks */
	memcon(srcbuf,sdest);

	for (ix=0; ix<(NBPG*2); ix++) {
		if (srcbuf[ix] != tdest[ix]) {
			writes("\nBlockmv tape error, expected ");
			writeh(srcbuf[ix]&0xff);
			writes(" , actual "); writeh(tdest[ix]&0xff);
			writes(" , address "); writeh(&tdest[ix]);
			tm_err = 1;
			}
		if (srcbuf[ix] != sdest[ix]) {
			writes("\nBlockmv Tahoe error, expected ");
			writeh(srcbuf[ix]&0xff);
			writes(" , actual "); writeh(sdest[ix]&0xff);
			writes(" , address "); writeh(&sdest[ix]);
			tm_err = 1;
			}
		}
}



/*	Routine to set up Tape parameter block
	for move block operation.
*/
tblk_mv(src,dest,bcnt)
char *src, *dest;
long bcnt;
{	char *cptr;

	tblk->cmd = BLOCK_M;			/* Command */
	tblk->control[1] = 0;	
	tblk->control[0] = 0x2a;     /* src=dst=16 bits,completion interrupt */
	cptr = (char *)&tblk->count;		/* Set byte count */
	*cptr++ = (char)(bcnt & 0xff);
	*cptr = (char)((bcnt & 0xff00)>>8);	

	/* Set source and destination buffer address */
	set_pointer(src,(char *)tblk->source);
	set_pointer(dest,(char *)tblk->dest);

	tblk->mask = 0;				/* Clear mask/stat */
	tblk->intr[0] = tblk->intr[1] = 0;
	tblk->table[0] = tblk->table[1] = 0;
	tblk->throttle = 0;
}

ex_err(msg)
char *msg;
{
	writes(msg);
}

tm_cerr(cnt)
long cnt;
{
	writes("Cy return count error "); writeh(cnt); writec('\n');
}


/*	Routine to create memory contention
	return -1 if error
*/
memcon(src,sdest)
char *src, *sdest;
{	register long *r12, cntr, rtn_cnt, ix;

	while (g_open()==0)			/* Is gate open ? */
		{ tm_init();
		error("sent_tm gate closed\n");
		return(-1);
		}
	cmd_done = 0;
	ccblk.gate = (char)GATE_CLOSED;		/* Close gate */
	cy_attn();				/* Execute command */
	cntr = RETRY;
	while (!cmd_done) {	/* Wait for tape to complete */
		asm("movl 4(fp),r0");		/* Source */
		asm("movl 8(fp),r1");		/* Destination */
		asm("movl $NBPG*2,r2");		/* Count */
		asm("movblk");			/* Move it */
		}
	if (cmd_done == 2) return(-1); 	/* Command has error */	
	return(0);
}


unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.