add ioctl's + errno; fix chk to work with new stuff
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Fri, 31 Dec 1982 07:31:07 +0000 (23:31 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Fri, 31 Dec 1982 07:31:07 +0000 (23:31 -0800)
SCCS-vsn: sys/vax/stand/Makefile 4.18
SCCS-vsn: sys/vax/stand/conf.c 4.15
SCCS-vsn: sys/stand.att/saio.h 4.7
SCCS-vsn: sys/stand.att/sys.c 4.8
SCCS-vsn: sys/vax/stand/up.c 4.2

usr/src/sys/stand.att/saio.h
usr/src/sys/stand.att/sys.c
usr/src/sys/vax/stand/Makefile
usr/src/sys/vax/stand/conf.c
usr/src/sys/vax/stand/up.c

index 42dffb1..9822363 100644 (file)
@@ -1,4 +1,4 @@
-/*     saio.h  4.6     %G%     */
+/*     saio.h  4.7     %G%     */
 
 /*
  * header file for standalone package
 
 /*
  * header file for standalone package
@@ -10,7 +10,7 @@
  * and a buffer.
  */
 struct iob {
  * and a buffer.
  */
 struct iob {
-       char    i_flgs;
+       int     i_flgs;
        struct  inode i_ino;
        int     i_unit;
        daddr_t i_boff;
        struct  inode i_ino;
        int     i_unit;
        daddr_t i_boff;
@@ -19,6 +19,9 @@ struct        iob {
        daddr_t i_bn;
        char    *i_ma;
        int     i_cc;
        daddr_t i_bn;
        char    *i_ma;
        int     i_cc;
+       int     i_error;
+       int     i_errcnt;
+       int     i_active;
        char    i_buf[MAXBSIZE];
        union {
                struct fs ui_fs;
        char    i_buf[MAXBSIZE];
        union {
                struct fs ui_fs;
@@ -27,10 +30,18 @@ struct      iob {
 };
 #define i_fs i_un.ui_fs
 
 };
 #define i_fs i_un.ui_fs
 
-#define F_READ 01
-#define F_WRITE        02
-#define F_ALLOC        04
-#define F_FILE 010
+#define F_READ         0x1     /* file opened for reading */
+#define F_WRITE                0x2     /* file opened for writing */
+#define F_ALLOC                0x4     /* buffer allocated */
+#define F_FILE         0x8     /* file instead of device */
+/* io types */
+#define        F_RDDATA        0x0100  /* read data */
+#define        F_WRDATA        0x0200  /* write data */
+#define F_HDR          0x0400  /* include header on next i/o */
+#define F_CHECK                0x0800  /* perform check of data read/write */
+#define F_HCHECK       0x1000  /* perform check of header and data */
+
+#define        F_TYPEMASK      0xff00
 
 /*
  * dev switch
 
 /*
  * dev switch
@@ -40,6 +51,7 @@ struct devsw {
        int     (*dv_strategy)();
        int     (*dv_open)();
        int     (*dv_close)();
        int     (*dv_strategy)();
        int     (*dv_open)();
        int     (*dv_close)();
+       int     (*dv_ioctl)();
 };
 
 struct devsw devsw[];
 };
 
 struct devsw devsw[];
@@ -62,3 +74,24 @@ struct       iob iob[NFILES];
 #define        PHYSMBA0        0x20010000
 #define        PHYSMBA1        0x20012000
 #define        PHYSUMEM        0x2013e000
 #define        PHYSMBA0        0x20010000
 #define        PHYSMBA1        0x20012000
 #define        PHYSUMEM        0x2013e000
+
+extern int errno;      /* just like unix */
+
+/* error codes */
+#define        EBADF   1       /* bad file descriptor */
+#define        EOFFSET 2       /* relative seek not supported */
+#define        EDEV    3       /* improper device specification on open */
+#define        ENXIO   4       /* unknown device specified */
+#define        EUNIT   5       /* improper unit specification */
+#define        ESRCH   6       /* directory search for file failed */
+#define        EIO     7       /* generic error */
+#define ECMD   10      /* undefined driver command */
+#define EBSE   11      /* bad sector error */
+#define EWCK   12      /* write check error */
+#define EHER   13      /* hard error */
+#define EECC   14      /* severe ecc error, sector recorded as bad*/
+
+/* ioctl's -- for disks just now */
+#define        SAIOHDR (('d'<<8)|1)    /* next i/o includes header */
+#define        SAIOCHECK       (('d'<<8)|2)    /* next i/o checks data */
+#define        SAIOHCHECK      (('d'<<8)|3)    /* next i/o checks header & data */
index f855a73..f5ffa89 100644 (file)
@@ -1,4 +1,4 @@
-/*     sys.c   4.7     82/12/22        */
+/*     sys.c   4.8     82/12/30        */
 
 #include "../h/param.h"
 #include "../h/inode.h"
 
 #include "../h/param.h"
 #include "../h/inode.h"
@@ -14,7 +14,7 @@ struct dirstuff {
 };
 
 static
 };
 
 static
-openi(n,io)
+openi(n, io)
        register struct iob *io;
 {
        register struct dinode *dp;
        register struct iob *io;
 {
        register struct dinode *dp;
@@ -39,7 +39,7 @@ find(path, file)
 
        if (path==NULL || *path=='\0') {
                printf("null path\n");
 
        if (path==NULL || *path=='\0') {
                printf("null path\n");
-               return(0);
+               return (0);
        }
 
        openi((ino_t) ROOTINO, file);
        }
 
        openi((ino_t) ROOTINO, file);
@@ -61,10 +61,10 @@ find(path, file)
                        continue;
                } else {
                        printf("%s not found\n",path);
                        continue;
                } else {
                        printf("%s not found\n",path);
-                       return(0);
+                       return (0);
                }
        }
                }
        }
-       return(n);
+       return (n);
 }
 
 static daddr_t
 }
 
 static daddr_t
@@ -79,7 +79,7 @@ sbmap(io, bn)
        ip = &io->i_ino;
        if (bn < 0) {
                printf("bn negative\n");
        ip = &io->i_ino;
        if (bn < 0) {
                printf("bn negative\n");
-               return((daddr_t)0);
+               return ((daddr_t)0);
        }
 
        /*
        }
 
        /*
@@ -87,7 +87,7 @@ sbmap(io, bn)
         */
        if(bn < NDADDR) {
                nb = ip->i_db[bn];
         */
        if(bn < NDADDR) {
                nb = ip->i_db[bn];
-               return(nb);
+               return (nb);
        }
 
        /*
        }
 
        /*
@@ -113,7 +113,7 @@ sbmap(io, bn)
        nb = ip->i_ib[NIADDR - j];
        if (nb == 0) {
                printf("bn void %D\n",bn);
        nb = ip->i_ib[NIADDR - j];
        if (nb == 0) {
                printf("bn void %D\n",bn);
-               return((daddr_t)0);
+               return ((daddr_t)0);
        }
 
        /*
        }
 
        /*
@@ -133,10 +133,10 @@ sbmap(io, bn)
                nb = bap[i];
                if(nb == 0) {
                        printf("bn void %D\n",bn);
                nb = bap[i];
                if(nb == 0) {
                        printf("bn void %D\n",bn);
-                       return((daddr_t)0);
+                       return ((daddr_t)0);
                }
        }
                }
        }
-       return(nb);
+       return (nb);
 }
 
 static ino_t
 }
 
 static ino_t
@@ -150,15 +150,15 @@ dlook(s, io)
        int len;
 
        if (s == NULL || *s == '\0')
        int len;
 
        if (s == NULL || *s == '\0')
-               return(0);
+               return (0);
        ip = &io->i_ino;
        if ((ip->i_mode&IFMT) != IFDIR) {
                printf("not a directory\n");
        ip = &io->i_ino;
        if ((ip->i_mode&IFMT) != IFDIR) {
                printf("not a directory\n");
-               return(0);
+               return (0);
        }
        if (ip->i_size == 0) {
                printf("zero length directory\n");
        }
        if (ip->i_size == 0) {
                printf("zero length directory\n");
-               return(0);
+               return (0);
        }
        len = strlen(s);
        dirp.loc = 0;
        }
        len = strlen(s);
        dirp.loc = 0;
@@ -167,9 +167,9 @@ dlook(s, io)
                if(dp->d_ino == 0)
                        continue;
                if (dp->d_namlen == len && !strcmp(s, dp->d_name))
                if(dp->d_ino == 0)
                        continue;
                if (dp->d_namlen == len && !strcmp(s, dp->d_name))
-                       return(dp->d_ino);
+                       return (dp->d_ino);
        }
        }
-       return(0);
+       return (0);
 }
 
 /*
 }
 
 /*
@@ -208,28 +208,30 @@ readdir(dirp)
 }
 
 lseek(fdesc, addr, ptr)
 }
 
 lseek(fdesc, addr, ptr)
-       int     fdesc;
-       off_t   addr;
-       int     ptr;
+       int fdesc, ptr;
+       off_t addr;
 {
        register struct iob *io;
 
        if (ptr != 0) {
                printf("Seek not from beginning of file\n");
 {
        register struct iob *io;
 
        if (ptr != 0) {
                printf("Seek not from beginning of file\n");
-               return(-1);
+               errno = EOFFSET;
+               return (-1);
        }
        fdesc -= 3;
        if (fdesc < 0 || fdesc >= NFILES ||
        }
        fdesc -= 3;
        if (fdesc < 0 || fdesc >= NFILES ||
-           ((io = &iob[fdesc])->i_flgs & F_ALLOC) == 0)
-               return(-1);
+           ((io = &iob[fdesc])->i_flgs & F_ALLOC) == 0) {
+               errno = EBADF;
+               return (-1);
+       }
        io->i_offset = addr;
        io->i_bn = addr / DEV_BSIZE;
        io->i_cc = 0;
        io->i_offset = addr;
        io->i_bn = addr / DEV_BSIZE;
        io->i_cc = 0;
-       return(0);
+       return (0);
 }
 
 getc(fdesc)
 }
 
 getc(fdesc)
-       int     fdesc;
+       int fdesc;
 {
        register struct iob *io;
        register struct fs *fs;
 {
        register struct iob *io;
        register struct fs *fs;
@@ -238,11 +240,13 @@ getc(fdesc)
 
 
        if (fdesc >= 0 && fdesc <= 2)
 
 
        if (fdesc >= 0 && fdesc <= 2)
-               return(getchar());
+               return (getchar());
        fdesc -= 3;
        if (fdesc < 0 || fdesc >= NFILES ||
        fdesc -= 3;
        if (fdesc < 0 || fdesc >= NFILES ||
-           ((io = &iob[fdesc])->i_flgs&F_ALLOC) == 0)
-               return(-1);
+           ((io = &iob[fdesc])->i_flgs&F_ALLOC) == 0) {
+               errno = EBADF;
+               return (-1);
+       }
        p = io->i_ma;
        if (io->i_cc <= 0) {
                if ((io->i_flgs & F_FILE) != 0) {
        p = io->i_ma;
        if (io->i_cc <= 0) {
                if ((io->i_flgs & F_FILE) != 0) {
@@ -273,12 +277,12 @@ getc(fdesc)
        io->i_offset++;
        c = (unsigned)*p++;
        io->i_ma = p;
        io->i_offset++;
        c = (unsigned)*p++;
        io->i_ma = p;
-       return(c);
+       return (c);
 }
 
 /* does this port?
 getw(fdesc)
 }
 
 /* does this port?
 getw(fdesc)
-       int     fdesc;
+       int fdesc;
 {
        register w,i;
        register char *cp;
 {
        register w,i;
        register char *cp;
@@ -288,96 +292,109 @@ getw(fdesc)
                w = getc(fdesc);
                if (w < 0) {
                        if (i == 0)
                w = getc(fdesc);
                if (w < 0) {
                        if (i == 0)
-                               return(-1);
+                               return (-1);
                        else
                        else
-                               return(val);
+                               return (val);
                }
                *cp++ = w;
        }
                }
                *cp++ = w;
        }
-       return(val);
+       return (val);
 }
 */
 }
 */
+int    errno;
 
 read(fdesc, buf, count)
 
 read(fdesc, buf, count)
-       int     fdesc;
-       char    *buf;
-       int     count;
+       int fdesc, count;
+       char *buf;
 {
        register i;
        register struct iob *file;
 
 {
        register i;
        register struct iob *file;
 
+       errno = 0;
        if (fdesc >= 0 & fdesc <= 2) {
                i = count;
                do {
                        *buf = getchar();
                } while (--i && *buf++ != '\n');
        if (fdesc >= 0 & fdesc <= 2) {
                i = count;
                do {
                        *buf = getchar();
                } while (--i && *buf++ != '\n');
-               return(count - i);
+               return (count - i);
        }
        fdesc -= 3;
        if (fdesc < 0 || fdesc >= NFILES ||
        }
        fdesc -= 3;
        if (fdesc < 0 || fdesc >= NFILES ||
-           ((file = &iob[fdesc])->i_flgs&F_ALLOC) == 0)
-               return(-1);
-       if ((file->i_flgs&F_READ) == 0)
-               return(-1);
+           ((file = &iob[fdesc])->i_flgs&F_ALLOC) == 0) {
+               errno = EBADF;
+               return (-1);
+       }
+       if ((file->i_flgs&F_READ) == 0) {
+               errno = EBADF;
+               return (-1);
+       }
        if ((file->i_flgs & F_FILE) == 0) {
                file->i_cc = count;
                file->i_ma = buf;
                file->i_bn = file->i_boff + (file->i_offset / DEV_BSIZE);
                i = devread(file);
                file->i_offset += count;
        if ((file->i_flgs & F_FILE) == 0) {
                file->i_cc = count;
                file->i_ma = buf;
                file->i_bn = file->i_boff + (file->i_offset / DEV_BSIZE);
                i = devread(file);
                file->i_offset += count;
-               return(i);
+               if (i < 0)
+                       errno = file->i_error;
+               return (i);
        } else {
                if (file->i_offset+count > file->i_ino.i_size)
                        count = file->i_ino.i_size - file->i_offset;
                if ((i = count) <= 0)
        } else {
                if (file->i_offset+count > file->i_ino.i_size)
                        count = file->i_ino.i_size - file->i_offset;
                if ((i = count) <= 0)
-                       return(0);
+                       return (0);
                do {
                        *buf++ = getc(fdesc+3);
                } while (--i);
                do {
                        *buf++ = getc(fdesc+3);
                } while (--i);
-               return(count);
+               return (count);
        }
 }
 
 write(fdesc, buf, count)
        }
 }
 
 write(fdesc, buf, count)
-       int     fdesc;
-       char    *buf;
-       int     count;
+       int fdesc, count;
+       char *buf;
 {
        register i;
        register struct iob *file;
 
 {
        register i;
        register struct iob *file;
 
+       errno = 0;
        if (fdesc >= 0 && fdesc <= 2) {
                i = count;
                while (i--)
                        putchar(*buf++);
        if (fdesc >= 0 && fdesc <= 2) {
                i = count;
                while (i--)
                        putchar(*buf++);
-               return(count);
+               return (count);
        }
        fdesc -= 3;
        if (fdesc < 0 || fdesc >= NFILES ||
        }
        fdesc -= 3;
        if (fdesc < 0 || fdesc >= NFILES ||
-           ((file = &iob[fdesc])->i_flgs&F_ALLOC) == 0)
-               return(-1);
-       if ((file->i_flgs&F_WRITE) == 0)
-               return(-1);
+           ((file = &iob[fdesc])->i_flgs&F_ALLOC) == 0) {
+               errno = EBADF;
+               return (-1);
+       }
+       if ((file->i_flgs&F_WRITE) == 0) {
+               errno = EBADF;
+               return (-1);
+       }
        file->i_cc = count;
        file->i_ma = buf;
        file->i_bn = file->i_boff + (file->i_offset / DEV_BSIZE);
        i = devwrite(file);
        file->i_offset += count;
        file->i_cc = count;
        file->i_ma = buf;
        file->i_bn = file->i_boff + (file->i_offset / DEV_BSIZE);
        i = devwrite(file);
        file->i_offset += count;
-       return(i);
+       if (i < 0)
+               errno = file->i_error;
+       return (i);
 }
 
 int    openfirst = 1;
 
 open(str, how)
        char *str;
 }
 
 int    openfirst = 1;
 
 open(str, how)
        char *str;
-       int     how;
+       int how;
 {
        register char *cp;
        int i;
        register struct iob *file;
        register struct devsw *dp;
 {
        register char *cp;
        int i;
        register struct iob *file;
        register struct devsw *dp;
-       int     fdesc;
-       long    atol();
+       int fdesc;
+       long atol();
 
        if (openfirst) {
                for (i = 0; i < NFILES; i++)
 
        if (openfirst) {
                for (i = 0; i < NFILES; i++)
@@ -397,7 +414,8 @@ gotfile:
        if (*cp != '(') {
                printf("Bad device\n");
                file->i_flgs = 0;
        if (*cp != '(') {
                printf("Bad device\n");
                file->i_flgs = 0;
-               return(-1);
+               errno = EDEV;
+               return (-1);
        }
        *cp++ = '\0';
        for (dp = devsw; dp->dv_name; dp++) {
        }
        *cp++ = '\0';
        for (dp = devsw; dp->dv_name; dp++) {
@@ -406,7 +424,8 @@ gotfile:
        }
        printf("Unknown device\n");
        file->i_flgs = 0;
        }
        printf("Unknown device\n");
        file->i_flgs = 0;
-       return(-1);
+       errno = ENXIO;
+       return (-1);
 gotdev:
        *(cp-1) = '(';
        file->i_ino.i_dev = dp-devsw;
 gotdev:
        *(cp-1) = '(';
        file->i_ino.i_dev = dp-devsw;
@@ -416,13 +435,15 @@ gotdev:
        if (file->i_unit < 0 || file->i_unit > 31) {
                printf("Bad unit specifier\n");
                file->i_flgs = 0;
        if (file->i_unit < 0 || file->i_unit > 31) {
                printf("Bad unit specifier\n");
                file->i_flgs = 0;
-               return(-1);
+               errno = EUNIT;
+               return (-1);
        }
        if (*cp++ != ',') {
 badoff:
                printf("Missing offset specification\n");
                file->i_flgs = 0;
        }
        if (*cp++ != ',') {
 badoff:
                printf("Missing offset specification\n");
                file->i_flgs = 0;
-               return(-1);
+               errno = EOFFSET;
+               return (-1);
        }
        file->i_boff = atol(cp);
        for (;;) {
        }
        file->i_boff = atol(cp);
        for (;;) {
@@ -437,7 +458,7 @@ badoff:
                file->i_flgs |= how+1;
                file->i_cc = 0;
                file->i_offset = 0;
                file->i_flgs |= how+1;
                file->i_cc = 0;
                file->i_offset = 0;
-               return(fdesc+3);
+               return (fdesc+3);
        }
        file->i_ma = (char *)(&file->i_fs);
        file->i_cc = SBSIZE;
        }
        file->i_ma = (char *)(&file->i_fs);
        file->i_cc = SBSIZE;
@@ -446,33 +467,72 @@ badoff:
        devread(file);
        if ((i = find(cp, file)) == 0) {
                file->i_flgs = 0;
        devread(file);
        if ((i = find(cp, file)) == 0) {
                file->i_flgs = 0;
-               return(-1);
+               errno = ESRCH;
+               return (-1);
        }
        if (how != 0) {
                printf("Can't write files yet.. Sorry\n");
                file->i_flgs = 0;
        }
        if (how != 0) {
                printf("Can't write files yet.. Sorry\n");
                file->i_flgs = 0;
-               return(-1);
+               errno = EIO;
+               return (-1);
        }
        openi(i, file);
        file->i_offset = 0;
        file->i_cc = 0;
        file->i_flgs |= F_FILE | (how+1);
        }
        openi(i, file);
        file->i_offset = 0;
        file->i_cc = 0;
        file->i_flgs |= F_FILE | (how+1);
-       return(fdesc+3);
+       return (fdesc+3);
 }
 
 close(fdesc)
 }
 
 close(fdesc)
-       int     fdesc;
+       int fdesc;
 {
        struct iob *file;
 
        fdesc -= 3;
        if (fdesc < 0 || fdesc >= NFILES ||
 {
        struct iob *file;
 
        fdesc -= 3;
        if (fdesc < 0 || fdesc >= NFILES ||
-           ((file = &iob[fdesc])->i_flgs&F_ALLOC) == 0)
-               return(-1);
+           ((file = &iob[fdesc])->i_flgs&F_ALLOC) == 0) {
+               errno = EBADF;
+               return (-1);
+       }
        if ((file->i_flgs&F_FILE) == 0)
                devclose(file);
        file->i_flgs = 0;
        if ((file->i_flgs&F_FILE) == 0)
                devclose(file);
        file->i_flgs = 0;
-       return(0);
+       return (0);
+}
+
+ioctl(fdesc, cmd, arg)
+       int fdesc, cmd;
+       char *arg;
+{
+       register struct iob *file;
+       int error = 0;
+
+       if (fdesc < 0 || fdesc >= NFILES ||
+           ((file = &iob[fdesc])->i_flgs&F_ALLOC) == 0) {
+               errno = EBADF;
+               return (-1);
+       }
+       switch (cmd) {
+
+       case SAIOHDR:
+               file->i_flgs |= F_HDR;
+               break;
+
+       case SAIOCHECK:
+               file->i_flgs |= F_CHECK;
+               break;
+
+       case SAIOHCHECK:
+               file->i_flgs |= F_HCHECK;
+               break;
+
+       default:
+               error = devioctl(file, cmd, arg);
+               break;
+       }
+       if (error < 0)
+               errno = file->i_error;
+       return (error);
 }
 
 exit()
 }
 
 exit()
@@ -481,7 +541,7 @@ exit()
 }
 
 _stop(s)
 }
 
 _stop(s)
-       char    *s;
+       char *s;
 {
        int i;
 
 {
        int i;
 
index d236fc2..486e2bb 100644 (file)
@@ -1,4 +1,4 @@
-#      Makefile        4.17    82/12/19
+#      Makefile        4.18    82/12/30
 
 DESTDIR=/
 CFLAGS=        -O -DSTANDALONE ${COPTS} 
 
 DESTDIR=/
 CFLAGS=        -O -DSTANDALONE ${COPTS} 
@@ -6,11 +6,15 @@ COPTS=        -DVAX780 -DVAX750 -DVAX730
 RELOC= 70000
 SRCS=  sys.c conf.c prf.c machdep.c \
        autoconf.c hp.c ht.c idc.c mba.c mt.c rk.c tm.c ts.c \
 RELOC= 70000
 SRCS=  sys.c conf.c prf.c machdep.c \
        autoconf.c hp.c ht.c idc.c mba.c mt.c rk.c tm.c ts.c \
-       up.c uba.c uda.c ut.c
+       up.c uba.c uda.c ut.c \
+       drtest.c upchk.c up.new.c
 DRIVERS=autoconf.o hp.o ht.o idc.o mba.o mt.o rk.o tm.o ts.o \
        up.o uba.o uda.o ut.o
 DRIVERS=autoconf.o hp.o ht.o idc.o mba.o mt.o rk.o tm.o ts.o \
        up.o uba.o uda.o ut.o
+NEWDRIVERS=hp.new.o up.new.o
 
 
-ALL=   /usr/lib/libsa.a srt0.o boot tpboot copy tpcopy boothp boothk bootup
+ALL=   /usr/lib/libsa.a srt0.o boot tpboot copy tpcopy \
+       boothp boothk bootup \
+       updrtest hpdrtest upchk hpchk
 
 all: ${ALL}
 
 
 all: ${ALL}
 
@@ -18,7 +22,7 @@ all: ${ALL}
        ar crv /usr/lib/libsa.a $?
        ranlib /usr/lib/libsa.a
 
        ar crv /usr/lib/libsa.a $?
        ranlib /usr/lib/libsa.a
 
-${DRIVERS}: savax.h
+${NEWDRIVERS} ${DRIVERS}: savax.h
        cc -c -S ${COPTS} $*.c
        /lib/c2 -i $*.s | as -o $*.o
        rm $*.s
        cc -c -S ${COPTS} $*.c
        /lib/c2 -i $*.s | as -o $*.o
        rm $*.s
@@ -67,6 +71,26 @@ bootconf.o: ../h/fs.h saio.h ../vaxmba/mbareg.h
 copy:  copy.o srt0.o conf.o /usr/lib/libsa.a
        ld -N -o copy srt0.o copy.o conf.o -lsa -lc
 
 copy:  copy.o srt0.o conf.o /usr/lib/libsa.a
        ld -N -o copy srt0.o copy.o conf.o -lsa -lc
 
+# eventually we'll merge hpchk and upchk into one program
+#chk:  chk.o srt0.o conf.o hp.new.o up.new.o /usr/lib/libsa.a
+#      ld -N -o chk srt0.o chk.o conf.o hp.new.o up.new.o -lsa -lc
+#
+hpchk: chk.o srt0.o confhp.o hp.new.o /usr/lib/libsa.a
+       ld -N -o hpchk srt0.o chk.o confhp.o hp.new.o -lsa -lc
+
+upchk: chk.o srt0.o confup.o up.new.o /usr/lib/libsa.a
+       ld -N -o upchk srt0.o chk.o confup.o up.new.o -lsa -lc
+
+# eventually we'll merge hpdrtest and updrtest into one program
+#drtest:drtest.o srt0.o conf.o hp.new.o up.new.o /usr/lib/libsa.a
+#      ld -N -o drtest srt0.o drtest.o conf.o hp.new.o up.new.o -lsa -lc
+#
+updrtest: drtest.o srt0.o confup.o up.new.o /usr/lib/libsa.a
+       ld -N -o updrtest srt0.o drtest.o confup.o up.new.o -lsa -lc
+
+hpdrtest: drtest.o srt0.o confhp.o hp.new.o /usr/lib/libsa.a
+       ld -N -o hpdrtest srt0.o drtest.o confhp.o hp.new.o -lsa -lc
+
 # bootstrap from ether
 
 ### not yet, rosin, not yet ###
 # bootstrap from ether
 
 ### not yet, rosin, not yet ###
index 01928f5..6e1f1e5 100644 (file)
@@ -1,4 +1,4 @@
-/*     conf.c  4.14    82/12/17        */
+/*     conf.c  4.15    82/12/30        */
 
 #include "../machine/pte.h"
 
 
 #include "../machine/pte.h"
 
 devread(io)
        register struct iob *io;
 {
 devread(io)
        register struct iob *io;
 {
+       int error;
 
 
-       return( (*devsw[io->i_ino.i_dev].dv_strategy)(io, READ) );
+       io->i_flgs |= F_RDDATA;
+       error = (*devsw[io->i_ino.i_dev].dv_strategy)(io, READ);
+       io->i_flgs &= ~F_TYPEMASK;
+       return (error);
 }
 
 devwrite(io)
        register struct iob *io;
 {
 }
 
 devwrite(io)
        register struct iob *io;
 {
+       int error;
 
 
-       return( (*devsw[io->i_ino.i_dev].dv_strategy)(io, WRITE) );
+       io->i_flgs |= F_WRDATA;
+       error = (*devsw[io->i_ino.i_dev].dv_strategy)(io, WRITE);
+       io->i_flgs &= ~F_TYPEMASK;
+       return (error);
 }
 
 devopen(io)
 }
 
 devopen(io)
@@ -38,20 +46,41 @@ devclose(io)
        (*devsw[io->i_ino.i_dev].dv_close)(io);
 }
 
        (*devsw[io->i_ino.i_dev].dv_close)(io);
 }
 
-nullsys()
+devioctl(io, cmd, arg)
+       register struct iob *io;
+       int cmd;
+       caddr_t arg;
+{
+
+       return ((*devsw[io->i_ino.i_dev].dv_ioctl)(io, cmd, arg));
+}
+
+/*ARGSUSED*/
+nullsys(io)
+       struct iob *io;
 {
 
        ;
 }
 
 {
 
        ;
 }
 
-int    nullsys();
+/*ARGSUSED*/
+nullioctl(io, cmd, arg)
+       struct iob *io;
+       int cmd;
+       caddr_t arg;
+{
+
+       return (ECMD);
+}
+
+int    nullsys(), nullioctl();
 #if defined(VAX780) || defined(VAX750)
 #if defined(VAX780) || defined(VAX750)
-int    hpstrategy(), hpopen();
+int    hpstrategy(), hpopen(), hpioctl();
 #endif
 #endif
-int    upstrategy(), upopen();
-int    rkstrategy(), rkopen();
-int    udstrategy(), udopen();
-int    idcstrategy(), idcopen();
+int    upstrategy(), upopen(), upioctl();
+int    rkstrategy(), rkopen(), rkioctl();
+int    udstrategy(), udopen(), udioctl();
+int    idcstrategy(), idcopen(), idcioctl();
 #ifndef BOOT
 int    tmstrategy(), tmopen(), tmclose();
 int    tsstrategy(), tsopen(), tsclose();
 #ifndef BOOT
 int    tmstrategy(), tmopen(), tmclose();
 int    tsstrategy(), tsopen(), tsclose();
@@ -64,20 +93,22 @@ int utstrategy(), utopen(), utclose();
 
 struct devsw devsw[] = {
 #if defined(VAX780) || defined(VAX750)
 
 struct devsw devsw[] = {
 #if defined(VAX780) || defined(VAX750)
-       "hp",   hpstrategy,     hpopen,         nullsys,
+       { "hp", hpstrategy,     hpopen,         nullsys,        hpioctl },
+#endif
+       { "up", upstrategy,     upopen,         nullsys,        upioctl },
+       { "hk", rkstrategy,     rkopen,         nullsys,        rkioctl },
+       { "ra", udstrategy,     udopen,         nullsys,        udioctl },
+#if defined(VAX730)
+       { "rb", idcstrategy,    idcopen,        nullsys,        idcioctl },
 #endif
 #endif
-       "up",   upstrategy,     upopen,         nullsys,
-       "hk",   rkstrategy,     rkopen,         nullsys,
-       "ra",   udstrategy,     udopen,         nullsys,
-       "rb",   idcstrategy,    idcopen,        nullsys,
 #ifndef BOOT
 #ifndef BOOT
-       "ts",   tsstrategy,     tsopen,         tsclose,
+       { "ts", tsstrategy,     tsopen,         tsclose,        nullioctl },
 #if defined(VAX780) || defined(VAX750)
 #if defined(VAX780) || defined(VAX750)
-       "ht",   htstrategy,     htopen,         htclose,
-       "mt",   mtstrategy,     mtopen,         mtclose,
+       { "ht", htstrategy,     htopen,         htclose,        nullioctl },
+       { "mt", mtstrategy,     mtopen,         mtclose,        nullioctl },
 #endif
 #endif
-       "tm",   tmstrategy,     tmopen,         tmclose,
-       "ut",   utstrategy,     utopen,         utclose,
+       { "tm", tmstrategy,     tmopen,         tmclose,        nullioctl },
+       { "ut", utstrategy,     utopen,         utclose,        nullioctl },
 #endif
 #endif
-       0,0,0,0
+       { 0, 0, 0, 0, 0 },
 };
 };
index 8a646de..8bb264c 100644 (file)
@@ -1,5 +1,11 @@
-/*     up.c    4.1     82/12/26        */
+/*     up.c    4.2     82/12/30        */
 
 
+/*
+ * UNIBUS peripheral standalone driver
+ * with ECC correction and bad block forwarding.
+ * Also supports header operation and write
+ * check for data and/or header.
+ */
 #include "../h/param.h" 
 #include "../h/inode.h"
 #include "../h/fs.h"
 #include "../h/param.h" 
 #include "../h/inode.h"
 #include "../h/fs.h"
 #include "../vaxuba/upreg.h"
 #include "../vaxuba/ubareg.h"
 
 #include "../vaxuba/upreg.h"
 #include "../vaxuba/ubareg.h"
 
-#include "nsaio.h"
+#include "saio.h"
 #include "savax.h"
 
 #include "savax.h"
 
-#define updevctl(io, func)  (up_ctl[io->i_unit] = func)
-
-struct  dkbad upbad[MAXNUBA*8];                /* bad block pointers */
 u_short        ubastd[] = { 0776700 };
 u_short        ubastd[] = { 0776700 };
+
 char   up_gottype[MAXNUBA*8] = { 0 };
 char   up_type[MAXNUBA*8] = { 0 };
 char   up_gottype[MAXNUBA*8] = { 0 };
 char   up_type[MAXNUBA*8] = { 0 };
-char   up_ctl[MAXNUBA*8]  = { 0 };
 short  up_off[] = { 0, 27, 68, -1, -1, -1, -1, 82 };
 short  fj_off[] = { 0, 50, 0, -1, -1, -1, -1, 155 };
 /* this is called upam instead of am because hp.c has a similar array */
 short  upam_off[] = { 0, 32, 0, 668, 723, 778, 668, 98 };
 short  up_off[] = { 0, 27, 68, -1, -1, -1, -1, 82 };
 short  fj_off[] = { 0, 50, 0, -1, -1, -1, -1, 155 };
 /* this is called upam instead of am because hp.c has a similar array */
 short  upam_off[] = { 0, 32, 0, 668, 723, 778, 668, 98 };
+
+#define        NUPTYPES        3
+
 struct upst {
        short nsect;
        short ntrak;
        short nspc;
        short ncyl;
        short *off;
 struct upst {
        short nsect;
        short ntrak;
        short nspc;
        short ncyl;
        short *off;
-} upst[] = {
-/*  sectors,   surfaces,sect/cyl,cylind,               */
-       32,     19,     32*19,  823,    up_off,
-       32,     10,     32*10,  823,    fj_off,
-       32,     16,     32*16,  1024,   upam_off,
+} upst[NUPTYPES] = {
+       32,     19,     32*19,  823,    up_off,         /* 9300/equiv */
+       32,     10,     32*10,  823,    fj_off,         /* Fuji 160 */
+       32,     16,     32*16,  1024,   upam_off,       /* Capricorn */
 };
 };
+
 u_char up_offset[16] = {
        UPOF_P400, UPOF_M400, UPOF_P400, UPOF_M400,
        UPOF_P800, UPOF_M800, UPOF_P800, UPOF_M800, 
 u_char up_offset[16] = {
        UPOF_P400, UPOF_M400, UPOF_P400, UPOF_M400,
        UPOF_P800, UPOF_M800, UPOF_P800, UPOF_M800, 
@@ -43,54 +49,66 @@ u_char      up_offset[16] = {
        0, 0, 0, 0
 };
 
        0, 0, 0, 0
 };
 
+struct  dkbad upbad[MAXNUBA*8];                /* bad sector table */
+
 upopen(io)
        register struct iob *io;
 {
 upopen(io)
        register struct iob *io;
 {
-       register struct updevice *upaddr =
-           (struct updevice *)ubamem(io->i_unit, ubastd[0]);
+       register struct updevice *upaddr;
        register struct upst *st;
        register struct upst *st;
-       struct iob tio;
-       int i = 0;
 
 
+       if (io->i_boff < 0 || io->i_boff > 7 || st->off[io->i_boff] == -1)
+               _stop("up bad unit");
+       upaddr = (struct updevice *)ubamem(io->i_unit, ubastd[0]);
        while ((upaddr->upcs1 & UP_DVA) == 0) /* infinite wait */
                ;
        st = &upst[up_type[io->i_unit]];
        if (up_gottype[io->i_unit] == 0) {
        while ((upaddr->upcs1 & UP_DVA) == 0) /* infinite wait */
                ;
        st = &upst[up_type[io->i_unit]];
        if (up_gottype[io->i_unit] == 0) {
+               register int i;
+               struct iob tio;
+
                upaddr->uphr = UPHR_MAXTRAK;
                upaddr->uphr = UPHR_MAXTRAK;
-               if (upaddr->uphr == 9)
-                       up_type[io->i_unit] = 1;        /* fuji kludge */
-               else if (upaddr->uphr == 15)
-                       up_type[io->i_unit] = 2;        /* capricorn kludge */
+               for (st = upst; st < &upst[NUPTYPES]; st++)
+                       if (upaddr->uphr == st->ntrak - 1) {
+                               up_type[io->i_unit] = st - upst;
+                               break;
+                       }
+               if (st == &upst[NUPTYPES]) {
+                       printf("up%d: uphr=%x\n", upaddr->uphr);
+                       _stop("unknown drive type");
+               }
                upaddr->upcs2 = UPCS2_CLR;
 #ifdef DEBUG
                printf("Unittype=%d\n",up_type[io->i_unit]);
 #endif
                upaddr->upcs2 = UPCS2_CLR;
 #ifdef DEBUG
                printf("Unittype=%d\n",up_type[io->i_unit]);
 #endif
-               st = &upst[up_type[io->i_unit]];
 
 
-       /* read in bad block ptrs */
-               tio = *io;              /* copy the contents of the io structure
-                                        * to tio for use during the bb pointer
-                                        * read operation */
-               tio.i_bn = (st->nspc * st->ncyl - st->nsect);
+               /*
+                * Read in the bad sector table:
+                *      copy the contents of the io structure
+                *      to tio for use during the bb pointer
+                *      read operation.
+                */
+               tio = *io;
+               tio.i_bn = st->nspc * st->ncyl - st->nsect;
                tio.i_ma = (char *)&upbad[tio.i_unit];
                tio.i_ma = (char *)&upbad[tio.i_unit];
-               tio.i_cc = sizeof(upbad);
-               for (i=0; i<5; i++) {
-                       if (upstrategy(&tio, READ) == sizeof(upbad)) break;
+               tio.i_cc = sizeof (upbad);
+               tio.i_flgs |= F_RDDATA;
+               for (i = 0; i < 5; i++) {
+                       if (upstrategy(&tio, READ) == sizeof (upbad))
+                               break;
                        tio.i_bn += 2;
                }
                if (i == 5) {
                        tio.i_bn += 2;
                }
                if (i == 5) {
-                       printf("Unable to read bad block ptrs\n");
-                       for (i=0; i<126; i++) {
+                       printf("Unable to read bad sector table\n");
+                       for (i = 0; i < 126; i++) {
                                upbad[io->i_unit].bt_bad[i].bt_cyl = -1;
                                upbad[io->i_unit].bt_bad[i].bt_trksec = -1;
                        }
                }       
                up_gottype[io->i_unit] = 1;
        }
                                upbad[io->i_unit].bt_bad[i].bt_cyl = -1;
                                upbad[io->i_unit].bt_bad[i].bt_trksec = -1;
                        }
                }       
                up_gottype[io->i_unit] = 1;
        }
-       if (io->i_boff < 0 || io->i_boff > 7 || st->off[io->i_boff] == -1)
-               _stop("up bad unit");
        io->i_boff = st->off[io->i_boff] * st->nspc;
        io->i_boff = st->off[io->i_boff] * st->nspc;
-       updevctl(io, NORMAL);
+       io->i_flgs &= ~F_TYPEMASK;
 }
 
 upstrategy(io, func)
 }
 
 upstrategy(io, func)
@@ -103,10 +121,10 @@ upstrategy(io, func)
            (struct updevice *)ubamem(io->i_unit, ubastd[0]);
        register struct upst *st = &upst[up_type[io->i_unit]];
 
            (struct updevice *)ubamem(io->i_unit, ubastd[0]);
        register struct upst *st = &upst[up_type[io->i_unit]];
 
-       if (func == READ) 
-               io->i_flgs |= IO_READ;
-       else
-               io->i_flgs |= IO_WRITE;
+       if (func != READ && func != WRITE) {
+               io->i_error = ECMD;
+               return (-1);
+       }
        unit = io->i_unit;
        io->i_errcnt = 0;
        recal = 3;
        unit = io->i_unit;
        io->i_errcnt = 0;
        recal = 3;
@@ -123,7 +141,8 @@ upstrategy(io, func)
        upaddr->upba = info;
 readmore: 
        bn = io->i_bn + btop(io->i_cc + upaddr->upwc*sizeof(short));
        upaddr->upba = info;
 readmore: 
        bn = io->i_bn + btop(io->i_cc + upaddr->upwc*sizeof(short));
-       while((upaddr->upds & UPDS_DRY) == 0) ;
+       while((upaddr->upds & UPDS_DRY) == 0)
+               ;
        if (upstart(io, bn) != 0) 
                return (-1);
        do {
        if (upstart(io, bn) != 0) 
                return (-1);
        do {
@@ -140,18 +159,17 @@ readmore:
                        UPER1_BITS, upaddr->uper2, UPER2_BITS,-upaddr->upwc);
 #endif
        waitdry = 0;
                        UPER1_BITS, upaddr->uper2, UPER2_BITS,-upaddr->upwc);
 #endif
        waitdry = 0;
-       while ((upaddr->upds & UPDS_DRY) == 0) {
-               if (++waitdry > 512)
-                       break;
-       }
+       while ((upaddr->upds & UPDS_DRY) == 0 && ++waitdry < 512)
+               DELAY(5);
        if (++io->i_errcnt > 27) {
                /*
                 * After 28 retries (16 without offset, and
                 * 12 with offset positioning) give up.
                 */
        if (++io->i_errcnt > 27) {
                /*
                 * After 28 retries (16 without offset, and
                 * 12 with offset positioning) give up.
                 */
-               io->i_error = IOERR_HER;
+               io->i_error = EHER;
 hard:
 hard:
-               if (upaddr->upcs2 & UPCS2_WCE) io->i_error=IOERR_WCK;
+               if (upaddr->upcs2 & UPCS2_WCE)
+                       io->i_error = EWCK;
                bn = io->i_bn + btop(io->i_cc + upaddr->upwc*sizeof(short));
                cn = bn/st->nspc;
                sn = bn%st->nspc;
                bn = io->i_bn + btop(io->i_cc + upaddr->upwc*sizeof(short));
                cn = bn/st->nspc;
                sn = bn%st->nspc;
@@ -165,19 +183,19 @@ hard:
                return (io->i_cc + upaddr->upwc*sizeof(short));
        } else 
                if (upaddr->uper1&UPER1_WLE) {
                return (io->i_cc + upaddr->upwc*sizeof(short));
        } else 
                if (upaddr->uper1&UPER1_WLE) {
-               /*
-                * Give up on write locked devices
-                * immediately.
-                */
-               printf("up%d: write locked\n", unit);
-               return(-1);
+                       /*
+                        * Give up on write locked devices
+                        * immediately.
+                        */
+                       printf("up%d: write locked\n", unit);
+                       return(-1);
                }
 #ifndef NOBADSECT
        else if (upaddr->uper2 & UPER2_BSE) {
                if (upecc( io, BSE)) 
                        goto success;
                else {
                }
 #ifndef NOBADSECT
        else if (upaddr->uper2 & UPER2_BSE) {
                if (upecc( io, BSE)) 
                        goto success;
                else {
-                       io->i_error = IOERR_BSE;
+                       io->i_error = EBSE;
                        goto hard;
                }
        }
                        goto hard;
                }
        }
@@ -189,11 +207,10 @@ hard:
                 * Otherwise fall through and retry the transfer
                 */
                if ((upaddr->uper1&(UPER1_DCK|UPER1_ECH))==UPER1_DCK) {
                 * Otherwise fall through and retry the transfer
                 */
                if ((upaddr->uper1&(UPER1_DCK|UPER1_ECH))==UPER1_DCK) {
-                       upecc( io, ECC);
+                       upecc(io, ECC);
                        goto success;
                        goto success;
-               } else {
+               } else
                        io->i_active = 0; /* force retry */
                        io->i_active = 0; /* force retry */
-               }
        }
        /*
         * Clear drive error and, every eight attempts,
        }
        /*
         * Clear drive error and, every eight attempts,
@@ -220,6 +237,7 @@ hard:
                upaddr->updc = cn;
                upaddr->upcs1 = UP_SEEK|UP_GO;
                goto nextrecal;
                upaddr->updc = cn;
                upaddr->upcs1 = UP_SEEK|UP_GO;
                goto nextrecal;
+
        case 2:
                if (io->i_errcnt < 16 || (func & READ) == 0)
                        goto donerecal;
        case 2:
                if (io->i_errcnt < 16 || (func & READ) == 0)
                        goto donerecal;
@@ -229,6 +247,7 @@ hard:
                recal++;
                io->i_active = 1;
                goto readmore;
                recal++;
                io->i_active = 1;
                goto readmore;
+
        donerecal:
        case 3:
                recal = 0;
        donerecal:
        case 3:
                recal = 0;
@@ -246,16 +265,15 @@ hard:
                if (io->i_errcnt >= 16) {
                        upaddr->upof = UPOF_FMT22;
                        upaddr->upcs1 = UP_RTC|UP_GO;
                if (io->i_errcnt >= 16) {
                        upaddr->upof = UPOF_FMT22;
                        upaddr->upcs1 = UP_RTC|UP_GO;
-                       while (!upaddr->upds & UPDS_DRY) /* removed PIP test*/
+                       while ((upaddr->upds&UPDS_DRY) == 0)
                                DELAY(25);
                }
                goto readmore;
        }
 success:
        io->i_active = 1;
                                DELAY(25);
                }
                goto readmore;
        }
 success:
        io->i_active = 1;
-       if (upaddr->upwc != 0) {
+       if (upaddr->upwc != 0)
                goto readmore;
                goto readmore;
-       }
        /*
         * Release unibus 
         */
        /*
         * Release unibus 
         */
@@ -269,7 +287,7 @@ success:
  * the transfer may be going to an odd memory address base and/or
  * across a page boundary.
  */
  * the transfer may be going to an odd memory address base and/or
  * across a page boundary.
  */
-upecc( io, flag)
+upecc(io, flag)
        register struct iob *io;
        int flag;
 {
        register struct iob *io;
        int flag;
 {
@@ -318,7 +336,7 @@ upecc( io, flag)
                 */
                while (i < 512 && (int)ptob(npf)+i < io->i_cc && bit > -11) {
                        /*
                 */
                while (i < 512 && (int)ptob(npf)+i < io->i_cc && bit > -11) {
                        /*
-                        * addr = vax base addr + ( number of sectors transferred
+                        * addr = vax base addr + (number of sectors transferred
                         *        before the error sector times the sector size)
                         *        + byte number
                         */
                         *        before the error sector times the sector size)
                         *        + byte number
                         */
@@ -354,10 +372,11 @@ upecc( io, flag)
                * controller registers in a normal fashion. 
                * The ub-address need not be changed.
                */
                * controller registers in a normal fashion. 
                * The ub-address need not be changed.
                */
-               while ( up->upcs1 & UP_RDY == 0) 
+               while (up->upcs1 & UP_RDY == 0) 
                        ;
                up->upcs1 = UP_TRE|UP_DCLR|UP_GO;
                        ;
                up->upcs1 = UP_TRE|UP_DCLR|UP_GO;
-               if (upstart(io, bbn) != 0) return (0);
+               if (upstart(io, bbn) != 0)
+                       return (0);
                io->i_errcnt = 0;
                do {
                        DELAY(25);
                io->i_errcnt = 0;
                do {
                        DELAY(25);
@@ -367,20 +386,17 @@ upecc( io, flag)
                        return (0);
                }
        }
                        return (0);
                }
        }
-       if (twc != 0) {
+       if (twc != 0)
                up->upwc = twc;
                up->upwc = twc;
-       }
        return (1);
 }
 
 #ifndef NOBADSECT
        return (1);
 }
 
 #ifndef NOBADSECT
-
 /*
  * Search the bad sector table looking for
  * the specified sector.  Return index if found.
  * Return -1 if not found.
  */
 /*
  * Search the bad sector table looking for
  * the specified sector.  Return index if found.
  * Return -1 if not found.
  */
-
 isbad(bt, st, blno)
        register struct dkbad *bt;
        register struct upst *st;
 isbad(bt, st, blno)
        register struct dkbad *bt;
        register struct upst *st;
@@ -394,7 +410,8 @@ isbad(bt, st, blno)
        sec %= st->nsect;
        blk = ((long)(blno/st->nspc) << 16) + (trk << 8) + sec;
        for (i = 0; i < 126; i++) {
        sec %= st->nsect;
        blk = ((long)(blno/st->nspc) << 16) + (trk << 8) + sec;
        for (i = 0; i < 126; i++) {
-               bblk = ((long)bt->bt_bad[i].bt_cyl << 16) + bt->bt_bad[i].bt_trksec;
+               bblk = ((long)bt->bt_bad[i].bt_cyl << 16) +
+                       bt->bt_bad[i].bt_trksec;
                if (blk == bblk)
                        return (i);
                if (blk < bblk || bblk < 0)
                if (blk == bblk)
                        return (i);
                if (blk < bblk || bblk < 0)
@@ -405,11 +422,11 @@ isbad(bt, st, blno)
 #endif
 
 upstart(io, bn)
 #endif
 
 upstart(io, bn)
-register struct iob *io;
-daddr_t bn;
+       register struct iob *io;
+       daddr_t bn;
 {
        register struct updevice *upaddr = 
 {
        register struct updevice *upaddr = 
-                       (struct updevice *)ubamem(io->i_unit, ubastd[0]);
+               (struct updevice *)ubamem(io->i_unit, ubastd[0]);
        register struct upst *st = &upst[up_type[io->i_unit]];
        int sn, tn;
 
        register struct upst *st = &upst[up_type[io->i_unit]];
        int sn, tn;
 
@@ -418,33 +435,48 @@ daddr_t bn;
        sn %= st->nsect;
        upaddr->updc = bn/st->nspc;
        upaddr->upda = (tn << 8) + sn;
        sn %= st->nsect;
        upaddr->updc = bn/st->nspc;
        upaddr->upda = (tn << 8) + sn;
-       switch (up_ctl[io->i_unit]) {
-       case NORMAL:
-               if (io->i_flgs & IO_READ)
-                       upaddr->upcs1 = UP_RCOM|UP_GO;
-               else
-                       upaddr->upcs1 = UP_WCOM|UP_GO;
+       switch (io->i_flgs&F_TYPEMASK) {
+
+       case F_RDDATA:
+               upaddr->upcs1 = UP_RCOM|UP_GO;
+               break;
+
+       case F_WRDATA:
+               upaddr->upcs1 = UP_WCOM|UP_GO;
                break;
                break;
-       case HDRIO:     
-               if (io->i_flgs & IO_READ)       
-                       upaddr->upcs1 = UP_RHDR|UP_GO;
-               else
-                       upaddr->upcs1 = UP_WHDR|UP_GO;
+
+       case F_HDR|F_RDDATA:    
+               upaddr->upcs1 = UP_RHDR|UP_GO;
+               break;
+
+       case F_HDR|F_WRDATA:
+               upaddr->upcs1 = UP_WHDR|UP_GO;
                break;
                break;
-       case WCHECK:
-               /* don't care if read or write, write check is writecheck
-                * anyhow  */
+
+       case F_CHECK|F_WRDATA:
+       case F_CHECK|F_RDDATA:
                upaddr->upcs1 = UP_WCDATA|UP_GO;
                break;
                upaddr->upcs1 = UP_WCDATA|UP_GO;
                break;
-       case WHCHECK:
-               /* don't care if read or write, write check is writecheck
-                * anyhow  */
+
+       case F_HCHECK|F_WRDATA:
+       case F_HCHECK|F_RDDATA:
                upaddr->upcs1 = UP_WCHDR|UP_GO;
                break;
                upaddr->upcs1 = UP_WCHDR|UP_GO;
                break;
+
        default:
        default:
-               io->i_error = IOERR_CMD;
-               return(1);
+               io->i_error = ECMD;
+               io->i_flgs &= ~F_TYPEMASK;
+               return (1);
        }
        }
-       return(0) ;
+       return (0);
 }
 
 }
 
+/*ARGSUSED*/
+upioctl(io, cmd, arg)
+       struct iob *io;
+       int cmd;
+       caddr_t arg;
+{
+
+       return (ECMD);
+}