delete unneeded header files
[unix-history] / usr / src / sys / vax / stand / mt.c
index 0fed529..6da16b9 100644 (file)
@@ -3,18 +3,16 @@
  * 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        7.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 "param.h"
 
 #include "param.h"
-#include "inode.h"
-#include "fs.h"
 
 #include "../vaxmba/mtreg.h"
 #include "../vaxmba/mbareg.h"
 
 #include "../vaxmba/mtreg.h"
 #include "../vaxmba/mbareg.h"
@@ -30,31 +28,30 @@ 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);
-       register int i;
-
-       if (mbainit(UNITTOMBA(io->i_unit)) == 0)
-               return (ENXIO);
-       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;
-       printf("not a tape\n");
-       return (ENXIO);
-found:
+                       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);
        }
@@ -64,7 +61,6 @@ found:
 mtclose(io)
        register struct iob *io;
 {
 mtclose(io)
        register struct iob *io;
 {
-
        mtstrategy(io, MT_REW);
 }
 
        mtstrategy(io, MT_REW);
 }
 
@@ -73,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) {
@@ -89,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)
                        ;
@@ -130,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)