delete unneeded header files
[unix-history] / usr / src / sys / vax / stand / mt.c
index a7f7894..6da16b9 100644 (file)
@@ -1,20 +1,18 @@
 /*
 /*
- * Copyright (c) 1982 Regents of the University of California.
+ * 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.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)mt.c        6.2 (Berkeley) %G%
+ *     @(#)mt.c        7.5 (Berkeley) %G%
  */
 
 /*
  * TM78/TU78 tape driver
  * Made to work reliably by by Jeffrey R. Schwab (Purdue)
  */
  */
 
 /*
  * TM78/TU78 tape driver
  * Made to work reliably by by Jeffrey R. Schwab (Purdue)
  */
-#include "../machine/pte.h"
+#include "machine/pte.h"
 
 
-#include "../h/param.h"
-#include "../h/inode.h"
-#include "../h/fs.h"
+#include "param.h"
 
 #include "../vaxmba/mtreg.h"
 #include "../vaxmba/mbareg.h"
 
 #include "../vaxmba/mtreg.h"
 #include "../vaxmba/mbareg.h"
@@ -30,38 +28,39 @@ short       mttypes[] =
 mtopen(io)
        register struct iob *io;
 {
 mtopen(io)
        register struct iob *io;
 {
-       register int skip;
-       register struct mtdevice *mtaddr =
-               (struct mtdevice *)mbadrv(io->i_unit);
-       int i;
-
-       for (i = 0; mttypes[i]; i++)
+       register struct mtdevice *mtaddr;
+       register int i, skip;
+
+       if (mbainit(io->i_adapt) == 0)
+               return (EADAPT);
+       mtaddr = (struct mtdevice *)mbadrv(io->i_adapt, io->i_ctlr);
+       for (i = 0;; i++) {
+               if (!mttypes[i]) {
+                       printf("mt: not a tape\n");
+                       return (ENXIO);
+               }
                if (mttypes[i] == (mtaddr->mtdt&MBDT_TYPE))
                if (mttypes[i] == (mtaddr->mtdt&MBDT_TYPE))
-                       goto found;
-       _stop("not a tape\n");
-found:
-       mbainit(UNITTOMBA(io->i_unit));
+                       break;
+       }
        mtaddr->mtid = MTID_CLR;
        DELAY(250);
        mtaddr->mtid = MTID_CLR;
        DELAY(250);
-       while ((mtaddr->mtid & MTID_RDY) == 0)
-               ;
+       while ((mtaddr->mtid & MTID_RDY) == 0);
 
        /* clear any attention bits present on open */
        i = mtaddr->mtner;
        mtaddr->mtas = mtaddr->mtas;
 
        mtstrategy(io, MT_REW);
 
        /* clear any attention bits present on open */
        i = mtaddr->mtner;
        mtaddr->mtas = mtaddr->mtas;
 
        mtstrategy(io, MT_REW);
-       skip = io->i_boff;
-       while (skip--) {
+       for (skip = io->i_part; skip--;) {
                io->i_cc = -1;
                mtstrategy(io, MT_SFORWF);
        }
                io->i_cc = -1;
                mtstrategy(io, MT_SFORWF);
        }
+       return (0);
 }
 
 mtclose(io)
        register struct iob *io;
 {
 }
 
 mtclose(io)
        register struct iob *io;
 {
-
        mtstrategy(io, MT_REW);
 }
 
        mtstrategy(io, MT_REW);
 }
 
@@ -70,11 +69,12 @@ mtstrategy(io, func)
        int func;
 {
        register int errcnt, s, ic;
        int func;
 {
        register int errcnt, s, ic;
-       register struct mtdevice *mtaddr =
-           (struct mtdevice *)mbadrv(io->i_unit);
-       struct mba_regs *mba = mbamba(io->i_unit);
+       register struct mtdevice *mtaddr;
+       struct mba_regs *mba;
 
        errcnt = 0;
 
        errcnt = 0;
+       mtaddr = (struct mtdevice *)mbadrv(io->i_adapt, io->i_ctlr);
+       mba = mbamba(io->i_adapt);
 retry:
        /* code to trap for attention up prior to start of command */
        if ((mtaddr->mtas & 0xffff) != 0) {
 retry:
        /* code to trap for attention up prior to start of command */
        if ((mtaddr->mtas & 0xffff) != 0) {
@@ -86,7 +86,7 @@ retry:
        if (func == READ || func == WRITE) {
                mtaddr->mtca = 1<<2;    /* 1 record */
                mtaddr->mtbc = io->i_cc;
        if (func == READ || func == WRITE) {
                mtaddr->mtca = 1<<2;    /* 1 record */
                mtaddr->mtbc = io->i_cc;
-               mbastart(io, func);
+               mbastart(io, io->i_ctlr, func);
                /* wait for mba to go idle and read result status */
                while((mba->mba_sr & MBSR_DTBUSY) != 0)
                        ;
                /* wait for mba to go idle and read result status */
                while((mba->mba_sr & MBSR_DTBUSY) != 0)
                        ;
@@ -127,11 +127,10 @@ retry:
 
        case MTER_RETRY:
                printf("mt error: er=%x\n", MASKREG(mtaddr->mter));
 
        case MTER_RETRY:
                printf("mt error: er=%x\n", MASKREG(mtaddr->mter));
-               if (errcnt == 10) {
+               if (errcnt++ == 10) {
                        printf("mt: unrecovered error\n");
                        return (-1);
                }
                        printf("mt: unrecovered error\n");
                        return (-1);
                }
-               errcnt++;
                goto retry;
        }
        if (errcnt)
                goto retry;
        }
        if (errcnt)