* Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
* @(#)mt.c 7.5 (Berkeley) %G%
* Made to work reliably by by Jeffrey R. Schwab (Purdue)
#include "../vaxmba/mtreg.h"
#include "../vaxmba/mbareg.h"
#define MASKREG(reg) ((reg)&0xffff)
register struct mtdevice
*mtaddr
;
if (mbainit(io
->i_adapt
) == 0)
mtaddr
= (struct mtdevice
*)mbadrv(io
->i_adapt
, io
->i_ctlr
);
printf("mt: not a tape\n");
if (mttypes
[i
] == (mtaddr
->mtdt
&MBDT_TYPE
))
while ((mtaddr
->mtid
& MTID_RDY
) == 0);
/* clear any attention bits present on open */
mtaddr
->mtas
= mtaddr
->mtas
;
for (skip
= io
->i_part
; skip
--;) {
mtstrategy(io
, MT_SFORWF
);
register int errcnt
, s
, ic
;
register struct mtdevice
*mtaddr
;
mtaddr
= (struct mtdevice
*)mbadrv(io
->i_adapt
, io
->i_ctlr
);
mba
= mbamba(io
->i_adapt
);
/* code to trap for attention up prior to start of command */
if ((mtaddr
->mtas
& 0xffff) != 0) {
printf("mt unexpected attention er=%x - continuing\n",
mtaddr
->mtas
= mtaddr
->mtas
;
if (func
== READ
|| func
== WRITE
) {
mtaddr
->mtca
= 1<<2; /* 1 record */
mbastart(io
, io
->i_ctlr
, func
);
/* wait for mba to go idle and read result status */
while((mba
->mba_sr
& MBSR_DTBUSY
) != 0)
ic
= mtaddr
->mter
& MTER_INTCODE
;
mtaddr
->mtncs
[0] = (-io
->i_cc
<< 8)|func
|MT_GO
;
ic
= mtaddr
->mtner
& MTER_INTCODE
;
mtaddr
->mtas
= mtaddr
->mtas
; /* clear attention */
/* make sure a record was read */
if ((mtaddr
->mtca
& (1 << 2)) != 0) {
printf("mt record count not decremented - retrying\n");
printf("mt hard error: er=%x\n",
while ((mtaddr
->mtid
& MTID_RDY
) == 0)
printf("mt error: er=%x\n", MASKREG(mtaddr
->mter
));
printf("mt: unrecovered error\n");
printf("mt: recovered by retry\n");
return (io
->i_cc
); /* NO PARTIAL RECORD READS!!! */