* Copyright (c) 1982 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
* @(#)mt.c 6.2 (Berkeley) %G%
* Made to work reliably by by Jeffrey R. Schwab (Purdue)
#include "../machine/pte.h"
#include "../vaxmba/mtreg.h"
#include "../vaxmba/mbareg.h"
#define MASKREG(reg) ((reg)&0xffff)
register struct mtdevice
*mtaddr
=
(struct mtdevice
*)mbadrv(io
->i_unit
);
for (i
= 0; mttypes
[i
]; i
++)
if (mttypes
[i
] == (mtaddr
->mtdt
&MBDT_TYPE
))
mbainit(UNITTOMBA(io
->i_unit
));
while ((mtaddr
->mtid
& MTID_RDY
) == 0)
/* clear any attention bits present on open */
mtaddr
->mtas
= mtaddr
->mtas
;
mtstrategy(io
, MT_SFORWF
);
register int errcnt
, s
, ic
;
register struct mtdevice
*mtaddr
=
(struct mtdevice
*)mbadrv(io
->i_unit
);
struct mba_regs
*mba
= mbamba(io
->i_unit
);
/* 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 */
/* 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!!! */