support for display drivers as console
[unix-history] / usr / src / sys / vax / stand / tmscp.c
index d51680d..da514cb 100644 (file)
@@ -1,5 +1,5 @@
 
 
-/*     @(#)tmscp.c     1.1 (Berkeley) %G% */
+/*     @(#)tmscp.c     7.3 (Berkeley) %G% */
 
 /****************************************************************
  *                                                              *
 
 /****************************************************************
  *                                                              *
@@ -43,14 +43,13 @@ static char *sccsid = "@(#)tmscp.c  1.5     (ULTRIX)        4/18/86";
  * ------------------------------------------------------------------------
  */
  
  * ------------------------------------------------------------------------
  */
  
-#include "../machine/pte.h"
-#include "../h/param.h"
-#include "../h/gnode.h"
-#include "../h/devio.h"
+#include "param.h"
+#include "inode.h"
+#include "fs.h"
+
+#include "../vax/pte.h"
+
 #include "savax.h"
 #include "savax.h"
 #include "saio.h"
  
 /*
 #include "saio.h"
  
 /*
@@ -66,7 +65,8 @@ static char *sccsid = "@(#)tmscp.c    1.5     (ULTRIX)        4/18/86";
 #include "../vaxuba/ubareg.h"
 #include "../vax/tmscp.h"
  
 #include "../vaxuba/ubareg.h"
 #include "../vax/tmscp.h"
  
-u_short tmscpstd[] = { 0174500 };
+#define        MAXCTLR         1               /* all addresses must be specified */
+u_short tmscpstd[MAXCTLR] = { 0174500 };
  
 struct iob     ctmscpbuf;
  
  
 struct iob     ctmscpbuf;
  
@@ -76,7 +76,7 @@ struct tmscp {
        struct tmscpca  tmscp_ca;
        struct mscp     tmscp_rsp;
        struct mscp     tmscp_cmd;
        struct tmscpca  tmscp_ca;
        struct mscp     tmscp_rsp;
        struct mscp     tmscp_cmd;
-       } tmscp;
+} tmscp;
  
 struct tmscp *tmscp_ubaddr;            /* Unibus address of tmscp structure */
  
  
 struct tmscp *tmscp_ubaddr;            /* Unibus address of tmscp structure */
  
@@ -85,7 +85,6 @@ struct mscp *tmscpcmd();
 int tmscp_offline = 1;         /* Flag to prevent multiple STCON */
 int tms_offline[4] = {1,1,1,1}; /* Flag to prevent multiple ONLIN */
  
 int tmscp_offline = 1;         /* Flag to prevent multiple STCON */
 int tms_offline[4] = {1,1,1,1}; /* Flag to prevent multiple ONLIN */
  
 /*
  * Open a tmscp device. Initialize the controller and set the unit online.
  */
 /*
  * Open a tmscp device. Initialize the controller and set the unit online.
  */
@@ -95,48 +94,44 @@ tmscpopen(io)
        register struct mscp *mp;
        int i;
  
        register struct mscp *mp;
        int i;
  
+       if ((u_int)io->i_ctlr >= MAXCTLR)
+               return (ECTLR);
        /*
         * Have the tmscp controller characteristics already been set up
         * (STCON)?
         */
        /*
         * Have the tmscp controller characteristics already been set up
         * (STCON)?
         */
-       if (tmscp_offline)
-               {
+       if (tmscp_offline) {
                if (tmscpaddr == 0)
                if (tmscpaddr == 0)
-                       tmscpaddr = (struct tmscpdevice *)ubamem(io->i_unit, tmscpstd[0]);
-               if (tmscp_ubaddr == 0)
-                       {
+                       tmscpaddr = (struct tmscpdevice *)ubamem(io->i_adapt, tmscpstd[0]);
+               if (tmscp_ubaddr == 0) {
                        ctmscpbuf.i_unit = io->i_unit;
                        ctmscpbuf.i_ma = (caddr_t)&tmscp;
                        ctmscpbuf.i_cc = sizeof(tmscp);
                        tmscp_ubaddr = (struct tmscp *)ubasetup(&ctmscpbuf, 2);
                        ctmscpbuf.i_unit = io->i_unit;
                        ctmscpbuf.i_ma = (caddr_t)&tmscp;
                        ctmscpbuf.i_cc = sizeof(tmscp);
                        tmscp_ubaddr = (struct tmscp *)ubasetup(&ctmscpbuf, 2);
-                       }
+               }
                /*
                 * Initialize the tmscp device and wait for the 4 steps
                 * to complete.
                 */
                tmscpaddr->tmscpip = 0;
                /*
                 * Initialize the tmscp device and wait for the 4 steps
                 * to complete.
                 */
                tmscpaddr->tmscpip = 0;
-               while ((tmscpaddr->tmscpsa & TMSCP_STEP1) == 0)
-                       ;
+               while ((tmscpaddr->tmscpsa & TMSCP_STEP1) == 0);
                tmscpaddr->tmscpsa =TMSCP_ERR|(NCMDL2<<11)|(NRSPL2<<8);
  
                tmscpaddr->tmscpsa =TMSCP_ERR|(NCMDL2<<11)|(NRSPL2<<8);
  
-               while ((tmscpaddr->tmscpsa & TMSCP_STEP2) == 0)
-                       ;
+               while ((tmscpaddr->tmscpsa & TMSCP_STEP2) == 0);
 #              define STEP1MASK 0174377
 #              define STEP1GOOD (TMSCP_STEP2|TMSCP_IE|(NCMDL2<<3)|NRSPL2)
                if ((tmscpaddr->tmscpsa&STEP1MASK) != STEP1GOOD)
                        printf("tmscpopen: step 1 not successful sa=%o\n",tmscpaddr->tmscpsa&0xffff);
                tmscpaddr->tmscpsa = (short)&tmscp_ubaddr->tmscp_ca.ca_ringbase;
  
 #              define STEP1MASK 0174377
 #              define STEP1GOOD (TMSCP_STEP2|TMSCP_IE|(NCMDL2<<3)|NRSPL2)
                if ((tmscpaddr->tmscpsa&STEP1MASK) != STEP1GOOD)
                        printf("tmscpopen: step 1 not successful sa=%o\n",tmscpaddr->tmscpsa&0xffff);
                tmscpaddr->tmscpsa = (short)&tmscp_ubaddr->tmscp_ca.ca_ringbase;
  
-               while ((tmscpaddr->tmscpsa & TMSCP_STEP3) == 0)
-                       ;
+               while ((tmscpaddr->tmscpsa & TMSCP_STEP3) == 0);
 #              define STEP2MASK 0174377
 #              define STEP2GOOD (TMSCP_STEP3)
                if ((tmscpaddr->tmscpsa&STEP2MASK) != STEP2GOOD)
                        printf("tmscpopen: step 2 not successful sa=%o\n",tmscpaddr->tmscpsa&0xffff);
                tmscpaddr->tmscpsa = (short)(((int)&tmscp_ubaddr->tmscp_ca.ca_ringbase) >> 16);
  
 #              define STEP2MASK 0174377
 #              define STEP2GOOD (TMSCP_STEP3)
                if ((tmscpaddr->tmscpsa&STEP2MASK) != STEP2GOOD)
                        printf("tmscpopen: step 2 not successful sa=%o\n",tmscpaddr->tmscpsa&0xffff);
                tmscpaddr->tmscpsa = (short)(((int)&tmscp_ubaddr->tmscp_ca.ca_ringbase) >> 16);
  
-               while ((tmscpaddr->tmscpsa & TMSCP_STEP4) == 0)
-                       ;
+               while ((tmscpaddr->tmscpsa & TMSCP_STEP4) == 0);
 #              define STEP3MASK 0174000
 #              define STEP3GOOD TMSCP_STEP4
                if ((tmscpaddr->tmscpsa&STEP3MASK) != STEP3GOOD)
 #              define STEP3MASK 0174000
 #              define STEP3GOOD TMSCP_STEP4
                if ((tmscpaddr->tmscpsa&STEP3MASK) != STEP3GOOD)
@@ -153,50 +148,49 @@ tmscpopen(io)
                tmscp.tmscp_ca.ca_rspdsc[0] = (long)&tmscp_ubaddr->tmscp_rsp.mscp_cmdref;
                tmscp.tmscp_rsp.mscp_dscptr = tmscp.tmscp_ca.ca_rspdsc;
                tmscp.tmscp_cmd.mscp_cntflgs = 0;
                tmscp.tmscp_ca.ca_rspdsc[0] = (long)&tmscp_ubaddr->tmscp_rsp.mscp_cmdref;
                tmscp.tmscp_rsp.mscp_dscptr = tmscp.tmscp_ca.ca_rspdsc;
                tmscp.tmscp_cmd.mscp_cntflgs = 0;
-               if (tmscpcmd(M_OP_STCON, 0) == 0)
-                       {
-                       _stop("tms: open error, STCON");
-                       return;
-                       }
-               tmscp_offline = 0;
+               if (tmscpcmd(M_OP_STCON, 0) == 0) {
+                       printf("tms: open error, STCON\n");
+                       return (EIO);
                }
                }
+               tmscp_offline = 0;
+       }
        tmscp.tmscp_cmd.mscp_unit = io->i_unit&03;
        /* 
         * Has this unit been issued an ONLIN?
         */
        tmscp.tmscp_cmd.mscp_unit = io->i_unit&03;
        /* 
         * Has this unit been issued an ONLIN?
         */
-       if (tms_offline[tmscp.tmscp_cmd.mscp_unit])
-               {
-               if ((mp = tmscpcmd(M_OP_ONLIN, 0)) == 0)
-                       {
-                       _stop("tms: open error, ONLIN");
-                       return;
-                       }
-               tms_offline[tmscp.tmscp_cmd.mscp_unit] = 0;
+       if (tms_offline[tmscp.tmscp_cmd.mscp_unit]) {
+               if ((mp = tmscpcmd(M_OP_ONLIN, 0)) == 0) {
+                       _stop("tms: open error, ONLIN\n");
+                       return (EIO);
                }
                }
-       if (io->i_boff < 0 || io->i_boff > 3)
-               _stop("tms: bad offset");
-       else if (io->i_boff > 0)
+               tms_offline[tmscp.tmscp_cmd.mscp_unit] = 0;
+       }
+       /*
+        * This makes no sense, but I could be wrong... KB
+        *
+        *      if ((u_int)io->i_part > 3)
+        *              return (EPART);
+        */
+       if (io->i_part) {
                /*
                 * Skip forward the appropriate number of files on the tape.
                 */
                /*
                 * Skip forward the appropriate number of files on the tape.
                 */
-               {
-               tmscp.tmscp_cmd.mscp_tmkcnt = io->i_boff;
-               tmscpcmd(M_OP_REPOS, 0);
+               tmscp.tmscp_cmd.mscp_tmkcnt = io->i_part;
+               (void)tmscpcmd(M_OP_REPOS, 0);
                tmscp.tmscp_cmd.mscp_tmkcnt = 0;
                tmscp.tmscp_cmd.mscp_tmkcnt = 0;
-               }
+       }
+       return (0);
 }
  
 }
  
 /*
  * Close the device (rewind it to BOT)
  */
 tmscpclose(io)
        register struct iob *io;
 {
 /*
  * Close the device (rewind it to BOT)
  */
 tmscpclose(io)
        register struct iob *io;
 {
-       tmscpcmd(M_OP_REPOS, M_MD_REWND);
+       (void)tmscpcmd(M_OP_REPOS, M_MD_REWND);
 }
  
 }
  
 /*
  * Set up tmscp command packet.  Cause the controller to poll to pick up
  * the command.
 /*
  * Set up tmscp command packet.  Cause the controller to poll to pick up
  * the command.
@@ -216,13 +210,11 @@ tmscpcmd(op,mod)
        tmscp.tmscp_ca.ca_rspdsc[0] |= TMSCP_OWN;       /* | TMSCP_INT */
  
        i = tmscpaddr->tmscpip;
        tmscp.tmscp_ca.ca_rspdsc[0] |= TMSCP_OWN;       /* | TMSCP_INT */
  
        i = tmscpaddr->tmscpip;
-       for (;;)
-               {
-               if (tmscpaddr->tmscpsa & TMSCP_ERR)
-                       {
+       for (;;) {
+               if (tmscpaddr->tmscpsa & TMSCP_ERR) {
                        printf("tmscpcmd: Fatal error sa=%o\n", tmscpaddr->tmscpsa & 0xffff);
                        return(0);
                        printf("tmscpcmd: Fatal error sa=%o\n", tmscpaddr->tmscpsa & 0xffff);
                        return(0);
-                       }
+               }
  
                if (tmscp.tmscp_ca.ca_cmdint)
                        tmscp.tmscp_ca.ca_cmdint = 0;
  
                if (tmscp.tmscp_ca.ca_cmdint)
                        tmscp.tmscp_ca.ca_cmdint = 0;
@@ -231,31 +223,29 @@ tmscpcmd(op,mod)
                 * interrupt field in the communications area. Some
                 * devices (early TU81's) only clear the ownership field
                 * in the Response Descriptor.
                 * interrupt field in the communications area. Some
                 * devices (early TU81's) only clear the ownership field
                 * in the Response Descriptor.
+                *
+                *
+                *      if (tmscp.tmscp_ca.ca_rspint)
+                *              break;
                 */
                 */
-/*
-               if (tmscp.tmscp_ca.ca_rspint)
-                       break;
-*/
                if (!(tmscp.tmscp_ca.ca_rspdsc[0] & (TMSCP_OWN)))
                        break;
                if (!(tmscp.tmscp_ca.ca_rspdsc[0] & (TMSCP_OWN)))
                        break;
-               }
+       }
        tmscp.tmscp_ca.ca_rspint = 0;
        mp = &tmscp.tmscp_rsp;
        if (mp->mscp_opcode != (op|M_OP_END) ||
        tmscp.tmscp_ca.ca_rspint = 0;
        mp = &tmscp.tmscp_rsp;
        if (mp->mscp_opcode != (op|M_OP_END) ||
-          (mp->mscp_status&M_ST_MASK) != M_ST_SUCC)
-               {
-               /* Detect hitting tape mark.  This signifies the end of the
+          (mp->mscp_status&M_ST_MASK) != M_ST_SUCC) {
+               /*
+                * Detect hitting tape mark.  This signifies the end of the
                 * tape mini-root file.  We don't want to return an error
                 * condition to the strategy routine.
                 */
                 * tape mini-root file.  We don't want to return an error
                 * condition to the strategy routine.
                 */
-               if ((mp->mscp_status & M_ST_MASK) == M_ST_TAPEM)
-                       return(mp);
-               return(0);
-               }
+               if ((mp->mscp_status & M_ST_MASK) != M_ST_TAPEM)
+                       return(0);
+       }
        return(mp);
 }
  
        return(mp);
 }
  
 /*
  * Set up to do reads and writes; call tmscpcmd to issue the cmd.
  */
 /*
  * Set up to do reads and writes; call tmscpcmd to issue the cmd.
  */
@@ -272,12 +262,11 @@ tmscpstrategy(io, func)
        mp->mscp_unit = io->i_unit&03;
        mp->mscp_bytecnt = io->i_cc;
        mp->mscp_buffer = (ubinfo & 0x3fffff) | (((ubinfo>>28)&0xf)<<24);
        mp->mscp_unit = io->i_unit&03;
        mp->mscp_bytecnt = io->i_cc;
        mp->mscp_buffer = (ubinfo & 0x3fffff) | (((ubinfo>>28)&0xf)<<24);
-       if ((mp = tmscpcmd(func == READ ? M_OP_READ : M_OP_WRITE, 0)) == 0)
-               {
+       if ((mp = tmscpcmd(func == READ ? M_OP_READ : M_OP_WRITE, 0)) == 0) {
                ubafree(io, ubinfo);
                printf("tms: I/O error\n");
                return(-1);
                ubafree(io, ubinfo);
                printf("tms: I/O error\n");
                return(-1);
-               }
+       }
        ubafree(io, ubinfo);
        /*
         * Detect hitting tape mark so we do it gracefully and return a
        ubafree(io, ubinfo);
        /*
         * Detect hitting tape mark so we do it gracefully and return a
@@ -288,12 +277,3 @@ tmscpstrategy(io, func)
                return(0);
        return(io->i_cc);
 }
                return(0);
        return(io->i_cc);
 }
-/*ARGSUSED*/
-tmscpioctl(io, cmd, arg)
-       struct iob *io;
-       int cmd;
-       caddr_t arg;
-{
-       return (ECMD);
-}