|
|
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, iob5, cmd_done;
extern struct tpb tpb;
extern struct ccb ccblk;
struct tpblk *tblk;
long tm_ex1er,tm_ex2er,tm_ex3er,tm_bsiz;
short erase, unit;
tm_ex()
{
writes("\n\n\t** Tape Test **\n\n");
tm_ex1er=tm_ex2er=tm_ex3er=0;
if ( !(tm_bsiz = tape_op(CONFIG,0,0))) return;
writes("Tape master internal buffer size ");
writed(tm_bsiz); writes(" bytes\n");
gunit: writes("\nEnter tape unit number [0 - 3]: "); unit = gethex();
if (unit > 3) {
writes(" invalid unit number");
goto gunit; }
if (unit == 0x01 || unit == 0x02) unit = ~unit & 0x03;
writes("\n\n\tErase Records test \n"); /* output subtest header */
tm_ex1(&iob0);
writes("\n\n\tWrite/Read/Compare test\n"); /* output subtest header */
tm_ex2(&iob5);
writes("\n\n\tMemory Contention test\n"); /* output subtest header */
tblk = (struct tpblk *)&tpb;
tm_ex3(&iob0, &iob2, &iob4);
if (!tm_ex1er && !tm_ex2er && !tm_ex3er) writes("\nTape passed..\n");
else writes("\nTape failed..\n");
}
/*
(1) rewind tape
(2) erase records test
(3) rewind tape
(4) attempt to read 1 block of data, should get hard error 0x87 ;
blank tape where data expected error
*/
tm_ex1(dumbuf)
char *dumbuf;
{ int rtn_cnt;
tm_rew(); /* rewind tape */
tm_erase(); /* erase 1024 records */
tm_rew(); /* rewind tape */
erase = 1;
writes("\nChecking for blank tape...");
if(rtn_cnt=tape_op(READ_BU,dumbuf,1024)== -1) {
writes("...TM1 exercise read error"); }
else {
writes("error...tape was not blank");
tm_ex1er = 1; }
erase = 0;
}
/*
(1) write 1 block of data
(2) repeat for each data pattern
(3) rewind tape
(4) read 1 block of data
(5) check against pattern
(6) repeat step (4), (5) 9 more times
*/
tm_ex2(Sysbuf)
char *Sysbuf;
{ register long ix, iy, rtn_cnt;
unsigned char pattern;
static unsigned testcase[] = { 0x00,
0xff,
0xa5,
0x5a,
0x55,
0xaa,
0x0f,
0xf0,
0x33,
0xcc };
tm_rew(); /* rewind tape */
/*
Write 10 blocks of data
*/
for(ix=0; ix<10; ix++) {
pattern = testcase[ix];
writes("\nWriting block "); writeh(ix);
writes(", data pattern is "); writeh(pattern);
for (iy=0;iy<tm_bsiz;iy++) Sysbuf[iy] = pattern;
if ((rtn_cnt=tape_op(WRIT_BU,Sysbuf,tm_bsiz)) == -1)
{ tm_ex2er = 1;
ex_err("...TM2 exercise write error"); }
if (rtn_cnt != tm_bsiz) { tm_ex2er = 1; tm_cerr(rtn_cnt); }
}
tm_rew(); /* rewind tape */
/*
Read and compare 10 blocks of data
*/
for(ix=0; ix<10; ix++) {
pattern = testcase[ix];
writes("\nRead and Compare block "); writeh(ix);
writes(", data pattern is "); writeh(pattern);
for (iy=0;iy<tm_bsiz;iy++) Sysbuf[iy] = 0; /* clear buffer */
if ((rtn_cnt=tape_op(READ_BU,Sysbuf,tm_bsiz)) == -1)
{ tm_ex2er = 1;
writes("...TM2 exercise read error"); }
else {
if (rtn_cnt != tm_bsiz) { tm_ex2er=1;tm_cerr(rtn_cnt);}
for (iy=0;iy<tm_bsiz;iy++) {
if (Sysbuf[iy] != pattern) {
writes("\n...Block "); writeh(ix);
writes(" compare error, expected ");
writeh(pattern); writes(" , actual ");
writeh(Sysbuf[iy]);
tm_ex2er = 1;
break; }
}
}
}
}
/*
This test tries to 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_ex3(srcbuf, tdest, sdest)
char *srcbuf, *tdest, *sdest;
{ register long ix, *lptr;
tm_ex3er= 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_ex3er = 1;
}
if (srcbuf[ix] != sdest[ix]) {
writes("\nBlockmv system error, expected ");
writeh(srcbuf[ix]&0xff);
writes(" , actual "); writeh(sdest[ix]&0xff);
writes(" , address "); writeh(&sdest[ix]);
tm_ex3er = 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("\n...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("\n...sent_tm gate closed");
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);
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.