typo
[unix-history] / usr / src / sys / vax / uba / dh.c
index 857271c..05c1900 100644 (file)
@@ -1,9 +1,9 @@
 /*
 /*
- * Copyright (c) 1982 Regents of the University of California.
+ * Copyright (c) 1982, 1986 Regents of the University of California.
  * 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.
  *
- *     @(#)dh.c        6.9 (Berkeley) %G%
+ *     @(#)dh.c        7.5 (Berkeley) %G%
  */
 
 #include "dh.h"
  */
 
 #include "dh.h"
@@ -55,7 +55,7 @@ struct        uba_driver dmdriver =
        { dmprobe, 0, dmattach, 0, dmstd, "dm", dminfo };
 
 #ifndef        PORTSELECTOR
        { dmprobe, 0, dmattach, 0, dmstd, "dm", dminfo };
 
 #ifndef        PORTSELECTOR
-#define        ISPEED  B300
+#define        ISPEED  B9600
 #define        IFLAGS  (EVENP|ODDP|ECHO)
 #else
 #define        ISPEED  B4800
 #define        IFLAGS  (EVENP|ODDP|ECHO)
 #else
 #define        ISPEED  B4800
@@ -82,12 +82,14 @@ static short timerstarted;
 int    dhstart(), ttrstrt();
 
 /*
 int    dhstart(), ttrstrt();
 
 /*
- * The clist space is mapped by the driver onto each UNIBUS.
+ * The clist space is mapped by one terminal driver onto each UNIBUS.
+ * The identity of the board which allocated resources is recorded,
+ * so the process may be repeated after UNIBUS resets.
  * The UBACVT macro converts a clist space address for unibus uban
  * into an i/o space address for the DMA routine.
  */
  * The UBACVT macro converts a clist space address for unibus uban
  * into an i/o space address for the DMA routine.
  */
-int    dh_ubinfo[NUBA];                /* info about allocated unibus map */
-int    cbase[NUBA];                    /* base address in unibus map */
+int    dh_uballoc[NUBA];       /* which dh (if any) allocated unibus map */
+int    cbase[NUBA];            /* base address of clists in unibus map */
 #define        UBACVT(x, uban)         (cbase[uban] + ((x)-(char *)cfree))
 
 /*
 #define        UBACVT(x, uban)         (cbase[uban] + ((x)-(char *)cfree))
 
 /*
@@ -134,6 +136,8 @@ dhattach(ui)
 {
 
        dhsoftCAR[ui->ui_unit] = ui->ui_flags;
 {
 
        dhsoftCAR[ui->ui_unit] = ui->ui_flags;
+       cbase[ui->ui_ubanum] = -1;
+       dh_uballoc[ui->ui_unit] = -1;
 }
 
 /*
 }
 
 /*
@@ -194,12 +198,10 @@ dhopen(dev, flag)
         * block uba resets which can clear the state.
         */
        s = spl5();
         * block uba resets which can clear the state.
         */
        s = spl5();
-       if (dh_ubinfo[ui->ui_ubanum] == 0) {
-               /* 512+ is a kludge to try to get around a hardware problem */
-               dh_ubinfo[ui->ui_ubanum] =
-                   uballoc(ui->ui_ubanum, (caddr_t)cfree,
-                       512+nclist*sizeof(struct cblock), 0);
-               cbase[ui->ui_ubanum] = dh_ubinfo[ui->ui_ubanum]&0x3ffff;
+       if (cbase[ui->ui_ubanum] == -1) {
+               dh_uballoc[ui->ui_ubanum] = dh;
+               cbase[ui->ui_ubanum] = UBAI_ADDR(uballoc(ui->ui_ubanum,
+                   (caddr_t)cfree, nclist*sizeof(struct cblock), 0));
        }
        if (timerstarted == 0) {
                timerstarted++;
        }
        if (timerstarted == 0) {
                timerstarted++;
@@ -212,19 +214,21 @@ dhopen(dev, flag)
        }
        splx(s);
        /*
        }
        splx(s);
        /*
-        * If this is first open, initialze tty state to default.
+        * If this is first open, initialize tty state to default.
         */
        if ((tp->t_state&TS_ISOPEN) == 0) {
                ttychars(tp);
 #ifndef PORTSELECTOR
                if (tp->t_ispeed == 0) {
         */
        if ((tp->t_state&TS_ISOPEN) == 0) {
                ttychars(tp);
 #ifndef PORTSELECTOR
                if (tp->t_ispeed == 0) {
-#endif
+#else
+                       tp->t_state |= TS_HUPCLS;
+#endif PORTSELECTOR
                        tp->t_ispeed = ISPEED;
                        tp->t_ospeed = ISPEED;
                        tp->t_flags = IFLAGS;
 #ifndef PORTSELECTOR
                }
                        tp->t_ispeed = ISPEED;
                        tp->t_ospeed = ISPEED;
                        tp->t_flags = IFLAGS;
 #ifndef PORTSELECTOR
                }
-#endif
+#endif PORTSELECTOR
                dhparam(unit);
        }
        /*
                dhparam(unit);
        }
        /*
@@ -297,20 +301,19 @@ dhrint(dh)
        while ((c = addr->dhrcr) < 0) {
                tp = tp0 + ((c>>8)&0xf);
                dhchars[dh]++;
        while ((c = addr->dhrcr) < 0) {
                tp = tp0 + ((c>>8)&0xf);
                dhchars[dh]++;
-#ifndef PORTSELECTOR
                if ((tp->t_state&TS_ISOPEN)==0) {
                if ((tp->t_state&TS_ISOPEN)==0) {
-#else
-               if ((tp->t_state&(TS_ISOPEN|TS_WOPEN))==0) {
+                       wakeup((caddr_t)&tp->t_rawq);
+#ifdef PORTSELECTOR
+                       if ((tp->t_state&TS_WOPEN) == 0)
 #endif
 #endif
-                       wakeup((caddr_t)tp);
-                       continue;
+                               continue;
                }
                if (c & DH_PE)
                        if ((tp->t_flags&(EVENP|ODDP))==EVENP
                         || (tp->t_flags&(EVENP|ODDP))==ODDP )
                                continue;
                if ((c & DH_DO) && overrun == 0) {
                }
                if (c & DH_PE)
                        if ((tp->t_flags&(EVENP|ODDP))==EVENP
                         || (tp->t_flags&(EVENP|ODDP))==ODDP )
                                continue;
                if ((c & DH_DO) && overrun == 0) {
-                       log(KERN_RECOV, "dh%d: silo overflow\n", dh);
+                       log(LOG_WARNING, "dh%d: silo overflow\n", dh);
                        overrun = 1;
                }
                if (c & DH_FE)
                        overrun = 1;
                }
                if (c & DH_FE)
@@ -402,12 +405,13 @@ dhparam(unit)
        if ((tp->t_ispeed)==0) {
                tp->t_state |= TS_HUPCLS;
                dmctl(unit, DML_OFF, DMSET);
        if ((tp->t_ispeed)==0) {
                tp->t_state |= TS_HUPCLS;
                dmctl(unit, DML_OFF, DMSET);
+               splx(s);
                return;
        }
        lpar = ((tp->t_ospeed)<<10) | ((tp->t_ispeed)<<6);
        if ((tp->t_ispeed) == B134)
                lpar |= BITS6|PENABLE|HDUPLX;
                return;
        }
        lpar = ((tp->t_ospeed)<<10) | ((tp->t_ispeed)<<6);
        if ((tp->t_ispeed) == B134)
                lpar |= BITS6|PENABLE|HDUPLX;
-       else if (tp->t_flags & (RAW|LITOUT))
+       else if (tp->t_flags & (RAW|LITOUT|PASS8))
                lpar |= BITS8;
        else
                lpar |= BITS7|PENABLE;
                lpar |= BITS8;
        else
                lpar |= BITS7|PENABLE;
@@ -597,17 +601,24 @@ dhreset(uban)
        register struct uba_device *ui;
        int i;
 
        register struct uba_device *ui;
        int i;
 
-       if (dh_ubinfo[uban] == 0)
-               return;
-       dh_ubinfo[uban] = uballoc(uban, (caddr_t)cfree,
-           512+nclist*sizeof (struct cblock), 0);
-       cbase[uban] = dh_ubinfo[uban]&0x3ffff;
        dh = 0;
        for (dh = 0; dh < NDH; dh++) {
                ui = dhinfo[dh];
                if (ui == 0 || ui->ui_alive == 0 || ui->ui_ubanum != uban)
                        continue;
                printf(" dh%d", dh);
        dh = 0;
        for (dh = 0; dh < NDH; dh++) {
                ui = dhinfo[dh];
                if (ui == 0 || ui->ui_alive == 0 || ui->ui_ubanum != uban)
                        continue;
                printf(" dh%d", dh);
+               if (dh_uballoc[uban] == dh) {
+                       int info;
+
+                       info = uballoc(uban, (caddr_t)cfree,
+                           nclist * sizeof(struct cblock), UBA_CANTWAIT);
+                       if (info)
+                               cbase[uban] = UBAI_ADDR(info);
+                       else {
+                               printf(" [can't get uba map]");
+                               cbase[uban] = -1;
+                       }
+               }
                ((struct dhdevice *)ui->ui_addr)->un.dhcsr |= DH_IE;
                ((struct dhdevice *)ui->ui_addr)->dhsilo = 0;
                unit = dh * 16;
                ((struct dhdevice *)ui->ui_addr)->un.dhcsr |= DH_IE;
                ((struct dhdevice *)ui->ui_addr)->dhsilo = 0;
                unit = dh * 16;
@@ -690,16 +701,19 @@ dmopen(dev)
        }
        addr = (struct dmdevice *)ui->ui_addr;
        s = spl5();
        }
        addr = (struct dmdevice *)ui->ui_addr;
        s = spl5();
-       addr->dmcsr &= ~DM_SE;
-       while (addr->dmcsr & DM_BUSY)
-               ;
-       addr->dmcsr = unit;
-       addr->dmlstat = DML_ON;
-       if ((addr->dmlstat&DML_CAR) || (dhsoftCAR[dm]&(1<<unit)))
-               tp->t_state |= TS_CARR_ON;
-       addr->dmcsr = DM_IE|DM_SE;
-       while ((tp->t_state&TS_CARR_ON)==0)
+       for (;;) {
+               addr->dmcsr &= ~DM_SE;
+               while (addr->dmcsr & DM_BUSY)
+                       ;
+               addr->dmcsr = unit;
+               addr->dmlstat = DML_ON;
+               if ((addr->dmlstat & DML_CAR) || (dhsoftCAR[dm] & (1 << unit)))
+                       tp->t_state |= TS_CARR_ON;
+               addr->dmcsr = DM_IE|DM_SE;
+               if (tp->t_state & TS_CARR_ON)
+                       break;
                sleep((caddr_t)&tp->t_rawq, TTIPRI);
                sleep((caddr_t)&tp->t_rawq, TTIPRI);
+       }
        splx(s);
 }
 
        splx(s);
 }
 
@@ -759,30 +773,11 @@ dmintr(dm)
                if (addr->dmcsr&DM_CF) {
                        unit = addr->dmcsr & 0xf;
                        tp = &dh11[(dm << 4) + unit];
                if (addr->dmcsr&DM_CF) {
                        unit = addr->dmcsr & 0xf;
                        tp = &dh11[(dm << 4) + unit];
-                       wakeup((caddr_t)&tp->t_rawq);
-                       if ((tp->t_state&TS_WOPEN) == 0 &&
-                           (tp->t_flags & MDMBUF)) {
-                               if (addr->dmlstat & DML_CAR) {
-                                       tp->t_state &= ~TS_TTSTOP;
-                                       ttstart(tp);
-                               } else if ((tp->t_state&TS_TTSTOP) == 0) {
-                                       tp->t_state |= TS_TTSTOP;
-                                       dhstop(tp, 0);
-                               }
-                       } else if ((addr->dmlstat & DML_CAR)==0) {
-                               if ((tp->t_state & TS_CARR_ON) &&
-                                   (tp->t_flags & NOHANG) == 0 &&
-                                   (dhsoftCAR[dm] & (1<<unit)) == 0) {
-                                       if (tp->t_state & TS_ISOPEN) {
-                                               gsignal(tp->t_pgrp, SIGHUP);
-                                               gsignal(tp->t_pgrp, SIGCONT);
-                                               addr->dmlstat = 0;
-                                               ttyflush(tp, FREAD|FWRITE);
-                                       }
-                                       tp->t_state &= ~TS_CARR_ON;
-                               }
-                       } else
-                               tp->t_state |= TS_CARR_ON;
+                       if (addr->dmlstat & DML_CAR)
+                               (void)(*linesw[tp->t_line].l_modem)(tp, 1);
+                       else if ((dhsoftCAR[dm] & (1<<unit)) == 0 &&
+                           (*linesw[tp->t_line].l_modem)(tp, 0) == 0)
+                               addr->dmlstat = 0;
                }
                addr->dmcsr = DM_IE|DM_SE;
        }
                }
                addr->dmcsr = DM_IE|DM_SE;
        }