fix comment, Name server is two words
[unix-history] / usr / src / sys / vax / stand / ut.c
index c72172d..e05d8a1 100644 (file)
@@ -1,36 +1,45 @@
-/*     ut.c    4.1     81/12/01        */
+/*
+ * Copyright (c) 1982 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)ut.c        6.2 (Berkeley) %G%
+ */
 
 /*
  * SI Model 9700 -- emulates TU45 on the UNIBUS
  */
 
 /*
  * SI Model 9700 -- emulates TU45 on the UNIBUS
  */
+#include "../machine/pte.h"
 
 #include "../h/param.h"
 #include "../h/inode.h"
 
 #include "../h/param.h"
 #include "../h/inode.h"
-#include "../h/pte.h"
-#include "../h/ubareg.h"
+#include "../h/fs.h"
+
+#include "../vaxuba/ubareg.h"
+#include "../vaxuba/utreg.h"
+
 #include "saio.h"
 #include "savax.h"
 
 #include "saio.h"
 #include "savax.h"
 
-#include "../h/utreg.h"
+#define        MASKREG(reg)    ((reg)&0xffff)
 
 u_short        utstd[] = { 0172440 };          /* non-standard */
 
 utopen(io)
        register struct iob *io;
 {
 
 u_short        utstd[] = { 0172440 };          /* non-standard */
 
 utopen(io)
        register struct iob *io;
 {
-       register skip;
+       int skip;
 
        utstrategy(io, UT_REW);
        skip = io->i_boff;
 
        utstrategy(io, UT_REW);
        skip = io->i_boff;
-       while (skip--) {
-               io->i_cc = 0;
-               utstrategy(io, UT_SFORW);
-       }
+       while (skip-- > 0)
+               utstrategy(io, UT_SFORWF);
 }
 
 utclose(io)
        register struct iob *io;
 {
 }
 
 utclose(io)
        register struct iob *io;
 {
+
        utstrategy(io, UT_REW);
 }
 
        utstrategy(io, UT_REW);
 }
 
@@ -43,7 +52,7 @@ utstrategy(io, func)
        register int errcnt;
        register struct utdevice *addr =
            (struct utdevice *)ubamem(io->i_unit, utstd[0]);
        register int errcnt;
        register struct utdevice *addr =
            (struct utdevice *)ubamem(io->i_unit, utstd[0]);
-       int info;
+       int info, resid;
        u_short dens;
 
        dens = (io->i_unit&07) | PDP11FMT | UT_PE;
        u_short dens;
 
        dens = (io->i_unit&07) | PDP11FMT | UT_PE;
@@ -70,16 +79,16 @@ retry:
        word = addr->utds;
        if (word&(UTDS_EOT|UTDS_TM)) {
                addr->utcs1 = UT_CLEAR | UT_GO;
        word = addr->utds;
        if (word&(UTDS_EOT|UTDS_TM)) {
                addr->utcs1 = UT_CLEAR | UT_GO;
-               return(0);
+               goto done;
        }
        if ((word&UTDS_ERR) || (addr->utcs1&UT_TRE)) {
                if (errcnt == 0)
                        printf("tj error: cs1=%b er=%b cs2=%b ds=%b",
        }
        if ((word&UTDS_ERR) || (addr->utcs1&UT_TRE)) {
                if (errcnt == 0)
                        printf("tj error: cs1=%b er=%b cs2=%b ds=%b",
-                               addr->utcs1, UT_BITS, addr->uter, UTER_BITS,
-                               addr->utcs2, UTCS2_BITS, word, UTDS_BITS);
+                         addr->utcs1, UT_BITS, addr->uter, UTER_BITS,
+                         addr->utcs2, UTCS2_BITS, word, UTDS_BITS);
                if (errcnt == 10) {
                        printf("\n");
                if (errcnt == 10) {
                        printf("\n");
-                       return(-1);
+                       return (-1);
                }
                errcnt++;
                if (addr->utcs1&UT_TRE)
                }
                errcnt++;
                if (addr->utcs1&UT_TRE)
@@ -95,7 +104,14 @@ retry:
        }
        if (errcnt)
                printf(" recovered by retry\n");
        }
        if (errcnt)
                printf(" recovered by retry\n");
-       return ((-addr->utfc) & 0xffff);
+done:
+       if (func == READ) {
+               resid = 0;
+               if (io->i_cc > MASKREG(addr->utfc))
+                       resid = io->i_cc - MASKREG(addr->utfc);
+       } else
+               resid = MASKREG(-addr->utfc);
+       return (io->i_cc - resid);
 }
 
 utquiet(addr)
 }
 
 utquiet(addr)