fixed partition table for 9300's
[unix-history] / usr / src / sys / vax / mba / mt.c
index f7d2c5a..2ea9546 100644 (file)
@@ -1,4 +1,4 @@
-/*     mt.c    4.9     82/09/12        */
+/*     mt.c    4.15    82/12/17        */
 
 #include "mu.h"
 #if NMT > 0
 
 #include "mu.h"
 #if NMT > 0
@@ -12,6 +12,8 @@
  *     add odd byte count kludge from VMS driver
  *     write dump routine
  */
  *     add odd byte count kludge from VMS driver
  *     write dump routine
  */
+#include "../machine/pte.h"
+
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/buf.h"
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/buf.h"
 #include "../h/file.h"
 #include "../h/user.h"
 #include "../h/map.h"
 #include "../h/file.h"
 #include "../h/user.h"
 #include "../h/map.h"
-#include "../h/pte.h"
-#include "../h/mbareg.h"
-#include "../h/mbavar.h"
 #include "../h/ioctl.h"
 #include "../h/mtio.h"
 #include "../h/cmap.h"
 #include "../h/ioctl.h"
 #include "../h/mtio.h"
 #include "../h/cmap.h"
-#include "../h/cpu.h"
 #include "../h/uio.h"
 
 #include "../h/uio.h"
 
-#include "../h/mtreg.h"
+#include "../vax/cpu.h"
+#include "../vaxmba/mbareg.h"
+#include "../vaxmba/mbavar.h"
+#include "../vaxmba/mtreg.h"
 
 struct buf     rmtbuf[NMT];
 struct buf     cmtbuf[NMT];
 
 struct buf     rmtbuf[NMT];
 struct buf     cmtbuf[NMT];
@@ -78,9 +79,7 @@ char  mtds_bits[] = MTDS_BITS;
 mtattach(mi)
        struct mba_device *mi;
 {
 mtattach(mi)
        struct mba_device *mi;
 {
-#ifdef lint
-       mtread(0, 0); mtwrite(0); mtioctl(0, 0, 0, 0);
-#endif
+
 }
 
 mtslave(mi, ms, sn)
 }
 
 mtslave(mi, ms, sn)
@@ -119,35 +118,31 @@ mtopen(dev, flag)
 
        muunit = MUUNIT(dev);
        if (muunit >= NMU || (sc = &mu_softc[muunit])->sc_openf ||
 
        muunit = MUUNIT(dev);
        if (muunit >= NMU || (sc = &mu_softc[muunit])->sc_openf ||
-           (mi = mtinfo[MTUNIT(dev)]) == 0 || mi->mi_alive == 0) {
-               u.u_error = ENXIO;
-               return;
-       }
+           (mi = mtinfo[MTUNIT(dev)]) == 0 || mi->mi_alive == 0)
+               return (ENXIO);
        olddens = sc->sc_dens;
        dens = sc->sc_dens = (minor(dev)&H_6250BPI) ? MT_GCR : 0;
        mtcommand(dev, MT_SENSE, 1);
        sc->sc_dens = olddens;
        if ((sc->sc_dsreg & MTDS_ONL) == 0) {
                uprintf("mu%d: not online\n", muunit);
        olddens = sc->sc_dens;
        dens = sc->sc_dens = (minor(dev)&H_6250BPI) ? MT_GCR : 0;
        mtcommand(dev, MT_SENSE, 1);
        sc->sc_dens = olddens;
        if ((sc->sc_dsreg & MTDS_ONL) == 0) {
                uprintf("mu%d: not online\n", muunit);
-               u.u_error = EIO;
-               return;
+               return (EIO);
        }
        if ((flag&FWRITE) && (sc->sc_dsreg&MTDS_FPT)) {
                uprintf("mu%d: no write ring\n", muunit);
        }
        if ((flag&FWRITE) && (sc->sc_dsreg&MTDS_FPT)) {
                uprintf("mu%d: no write ring\n", muunit);
-               u.u_error = EIO;
-               return;
+               return (EIO);
        }
        if ((sc->sc_dsreg & MTDS_BOT) == 0 && (flag&FWRITE) &&
            dens != sc->sc_dens) {
                uprintf("mu%d: can't change density in mid-tape\n", muunit);
        }
        if ((sc->sc_dsreg & MTDS_BOT) == 0 && (flag&FWRITE) &&
            dens != sc->sc_dens) {
                uprintf("mu%d: can't change density in mid-tape\n", muunit);
-               u.u_error = EIO;
-               return;
+               return (EIO);
        }
        sc->sc_openf = 1;
        sc->sc_blkno = (daddr_t)0;
        sc->sc_nxrec = INF;
        sc->sc_flags = 0;
        sc->sc_dens = dens;
        }
        sc->sc_openf = 1;
        sc->sc_blkno = (daddr_t)0;
        sc->sc_nxrec = INF;
        sc->sc_flags = 0;
        sc->sc_dens = dens;
+       return (0);
 }
 
 mtclose(dev, flag)
 }
 
 mtclose(dev, flag)
@@ -518,8 +513,8 @@ mtioctl(dev, cmd, data, flag)
        switch (cmd) {
 
        case MTIOCTOP:  /* tape operation */
        switch (cmd) {
 
        case MTIOCTOP:  /* tape operation */
-               mtop = (struct mtop *)mtop;
-               switch(mtop->mt_op) {
+               mtop = (struct mtop *)data;
+               switch (mtop->mt_op) {
 
                case MTWEOF:
                        callcount = mtop->mt_count;
 
                case MTWEOF:
                        callcount = mtop->mt_count;
@@ -542,13 +537,10 @@ mtioctl(dev, cmd, data, flag)
                        break;
 
                default:
                        break;
 
                default:
-                       u.u_error = ENXIO;
-                       return;
-               }
-               if (callcount <= 0 || fcount <= 0) {
-                       u.u_error = ENXIO;
-                       return;
+                       return (ENXIO);
                }
                }
+               if (callcount <= 0 || fcount <= 0)
+                       return (EINVAL);
                op = mtops[mtop->mt_op];
                if (op == MT_WTM)
                        op |= sc->sc_dens;
                op = mtops[mtop->mt_op];
                if (op == MT_WTM)
                        op |= sc->sc_dens;
@@ -561,15 +553,12 @@ mtioctl(dev, cmd, data, flag)
                                fcount -= n;
                        } while (fcount);
                        if ((mtop->mt_op == MTFSR || mtop->mt_op == MTBSR) &&
                                fcount -= n;
                        } while (fcount);
                        if ((mtop->mt_op == MTFSR || mtop->mt_op == MTBSR) &&
-                           bp->b_resid) {
-                               u.u_error = EIO;
-                               break;
-                       }
+                           bp->b_resid)
+                               return (EIO);
                        if (bp->b_flags&B_ERROR)
                                break;
                }
                        if (bp->b_flags&B_ERROR)
                                break;
                }
-               geterror(bp);
-               return;
+               return (geterror(bp));
 
        case MTIOCGET:
                mtget = (struct mtget *)data;
 
        case MTIOCGET:
                mtget = (struct mtget *)data;
@@ -578,11 +567,12 @@ mtioctl(dev, cmd, data, flag)
                mtcommand(dev, MT_SENSE, 1);    /* update drive status */
                mtget->mt_dsreg = sc->sc_dsreg;
                mtget->mt_type = MT_ISMT;
                mtcommand(dev, MT_SENSE, 1);    /* update drive status */
                mtget->mt_dsreg = sc->sc_dsreg;
                mtget->mt_type = MT_ISMT;
-               return;
+               break;
 
        default:
 
        default:
-               u.u_error = ENXIO;
+               return (ENXIO);
        }
        }
+       return (0);
 }
 
 #define        DBSIZE  20
 }
 
 #define        DBSIZE  20
@@ -591,7 +581,6 @@ mtdump()
 {
        register struct mba_device *mi;
        register struct mba_regs *mp;
 {
        register struct mba_device *mi;
        register struct mba_regs *mp;
-       register struct mtdevice *mtaddr;
        int blk, num;
        int start;
 
        int blk, num;
        int start;
 
@@ -604,7 +593,7 @@ mtdump()
        mp = phys(mi->mi_hd, struct mba_hd *)->mh_physmba;
        mp->mba_cr = MBCR_IE;
 #if lint
        mp = phys(mi->mi_hd, struct mba_hd *)->mh_physmba;
        mp->mba_cr = MBCR_IE;
 #if lint
-       blk = blk; num = num; start = start;
+       blk = 0; num = blk; start = num; blk = start;
        return (0);
 #endif
 #ifdef notyet
        return (0);
 #endif
 #ifdef notyet