fix to silo and bk bug
[unix-history] / usr / src / sys / vax / uba / dz.c
index 854a1a0..82f40aa 100644 (file)
@@ -1,13 +1,13 @@
-/*     dz.c    4.15    %G%     */
+/*     dz.c    4.29    81/08/31        */
 
 #include "dz.h"
 
 #include "dz.h"
-#if NDZ11 > 0
-#define        DELAY(i)        { register int j = i; while (--j > 0); }
+#if NDZ > 0
 /*
  *  DZ-11 Driver
  *
  * This driver mimics dh.c; see it for explanation of common code.
  */
 /*
  *  DZ-11 Driver
  *
  * This driver mimics dh.c; see it for explanation of common code.
  */
+#include "bk.h"
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/tty.h"
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/tty.h"
@@ -17,7 +17,7 @@
 #include "../h/pte.h"
 #include "../h/buf.h"
 #include "../h/vm.h"
 #include "../h/pte.h"
 #include "../h/buf.h"
 #include "../h/vm.h"
-#include "../h/uba.h"
+#include "../h/ubavar.h"
 #include "../h/conf.h"
 #include "../h/pdma.h"
 #include "../h/bk.h"
 #include "../h/conf.h"
 #include "../h/pdma.h"
 #include "../h/bk.h"
  * Driver information for auto-configuration stuff.
  */
 int    dzprobe(), dzattach(), dzrint();
  * Driver information for auto-configuration stuff.
  */
 int    dzprobe(), dzattach(), dzrint();
-struct uba_dinfo *dzinfo[NDZ11];
+struct uba_device *dzinfo[NDZ];
 u_short        dzstd[] = { 0 };
 struct uba_driver dzdriver =
        { dzprobe, 0, dzattach, 0, dzstd, "dz", dzinfo };
 
 u_short        dzstd[] = { 0 };
 struct uba_driver dzdriver =
        { dzprobe, 0, dzattach, 0, dzstd, "dz", dzinfo };
 
-#define        NDZ     (NDZ11*8)
+#define        NDZLINE         (NDZ*8)
  
 /*
  * Registers and bits
  
 /*
  * Registers and bits
@@ -57,7 +57,7 @@ struct        uba_driver dzdriver =
 #define        DZ_RIE  0100            /* Receiver Interrupt Enable */
 #define        DZ_SAE  010000          /* Silo Alarm Enable */
 #define        DZ_TIE  040000          /* Transmit Interrupt Enable */
 #define        DZ_RIE  0100            /* Receiver Interrupt Enable */
 #define        DZ_SAE  010000          /* Silo Alarm Enable */
 #define        DZ_TIE  040000          /* Transmit Interrupt Enable */
-#define        DZ_IEN  (DZ_MSE+DZ_RIE+DZ_TIE+DZ_SAE)
+#define        DZ_IEN  (DZ_MSE|DZ_RIE|DZ_TIE|DZ_SAE)
 
 /* Flags for modem-control */
 #define        DZ_ON   1
 
 /* Flags for modem-control */
 #define        DZ_ON   1
@@ -65,8 +65,8 @@ struct        uba_driver dzdriver =
  
 int    dzstart(), dzxint(), dzdma();
 int    ttrstrt();
  
 int    dzstart(), dzxint(), dzdma();
 int    ttrstrt();
-struct tty dz_tty[NDZ];
-int    dz_cnt = { NDZ };
+struct tty dz_tty[NDZLINE];
+int    dz_cnt = { NDZLINE };
 int    dzact;
 
 struct device {
 int    dzact;
 
 struct device {
@@ -82,8 +82,8 @@ struct device {
 /*
  * Software copy of dzbrk since it isn't readable
  */
 /*
  * Software copy of dzbrk since it isn't readable
  */
-char   dz_brk[NDZ11];
-char   dzsoftCAR[NDZ11];
+char   dz_brk[NDZ];
+char   dzsoftCAR[NDZ];
 
 /*
  * The dz doesn't interrupt on carrier transitions, so
 
 /*
  * The dz doesn't interrupt on carrier transitions, so
@@ -94,7 +94,7 @@ char  dz_timer;               /* timer started? */
 /*
  * Pdma structures for fast output code
  */
 /*
  * Pdma structures for fast output code
  */
-struct pdma dzpdma[NDZ];
+struct pdma dzpdma[NDZLINE];
 
 char   dz_speeds[] =
        { 0,020,021,022,023,024,0,025,026,027,030,032,034,036,0,0 };
 
 char   dz_speeds[] =
        { 0,020,021,022,023,024,0,025,026,027,030,032,034,036,0,0 };
@@ -106,7 +106,7 @@ dzprobe(reg)
        register struct device *dzaddr = (struct device *)reg;
 
 #ifdef lint
        register struct device *dzaddr = (struct device *)reg;
 
 #ifdef lint
-       br = 0; br = cvec; cvec = br;
+       br = 0; cvec = br; br = cvec;
 #endif
        dzaddr->dzcsr = DZ_TIE|DZ_MSE;
        dzaddr->dztcr = 1;              /* enable any line */
 #endif
        dzaddr->dzcsr = DZ_TIE|DZ_MSE;
        dzaddr->dztcr = 1;              /* enable any line */
@@ -118,11 +118,12 @@ dzprobe(reg)
 }
 
 dzattach(ui)
 }
 
 dzattach(ui)
-       register struct uba_dinfo *ui;
+       register struct uba_device *ui;
 {
        register struct pdma *pdp = &dzpdma[ui->ui_unit*8];
        register struct tty *tp = &dz_tty[ui->ui_unit*8];
        register int cntr;
 {
        register struct pdma *pdp = &dzpdma[ui->ui_unit*8];
        register struct tty *tp = &dz_tty[ui->ui_unit*8];
        register int cntr;
+       extern dzscan();
 
        for (cntr = 0; cntr < 8; cntr++) {
                pdp->p_addr = (struct device *)ui->ui_addr;
 
        for (cntr = 0; cntr < 8; cntr++) {
                pdp->p_addr = (struct device *)ui->ui_addr;
@@ -131,7 +132,10 @@ dzattach(ui)
                pdp++, tp++;
        }
        dzsoftCAR[ui->ui_unit] = ui->ui_flags;
                pdp++, tp++;
        }
        dzsoftCAR[ui->ui_unit] = ui->ui_flags;
-       return (1);
+       if (dz_timer == 0) {
+               dz_timer++;
+               timeout(dzscan, (caddr_t)0, hz);
+       }
 }
 
 /*ARGSUSED*/
 }
 
 /*ARGSUSED*/
@@ -140,17 +144,12 @@ dzopen(dev, flag)
 {
        register struct tty *tp;
        register int unit;
 {
        register struct tty *tp;
        register int unit;
-       extern dzscan();
  
        unit = minor(dev);
        if (unit >= dz_cnt || dzpdma[unit].p_addr == 0) {
                u.u_error = ENXIO;
                return;
        }
  
        unit = minor(dev);
        if (unit >= dz_cnt || dzpdma[unit].p_addr == 0) {
                u.u_error = ENXIO;
                return;
        }
-       if (dz_timer == 0) {
-               dz_timer++;
-               timeout(dzscan, (caddr_t)0, HZ);
-       }
        tp = &dz_tty[unit];
        tp->t_addr = (caddr_t)&dzpdma[unit];
        tp->t_oproc = dzstart;
        tp = &dz_tty[unit];
        tp->t_addr = (caddr_t)&dzpdma[unit];
        tp->t_oproc = dzstart;
@@ -222,6 +221,7 @@ dzrint(dz)
        register struct device *dzaddr;
        register struct tty *tp0;
        register int unit;
        register struct device *dzaddr;
        register struct tty *tp0;
        register int unit;
+       int overrun = 0;
  
        if ((dzact & (1<<dz)) == 0)
                return;
  
        if ((dzact & (1<<dz)) == 0)
                return;
@@ -241,16 +241,20 @@ dzrint(dz)
                                c = 0;
                        else
                                c = tun.t_intrc;
                                c = 0;
                        else
                                c = tun.t_intrc;
-               if (c&DZ_DO)
-                       printf("o");
+               if (c&DZ_DO && overrun == 0) {
+                       printf("dz%d: silo overflow\n", dz);
+                       overrun = 1;
+               }
                if (c&DZ_PE)    
                        if (((tp->t_flags & (EVENP|ODDP)) == EVENP)
                          || ((tp->t_flags & (EVENP|ODDP)) == ODDP))
                                continue;
                if (c&DZ_PE)    
                        if (((tp->t_flags & (EVENP|ODDP)) == EVENP)
                          || ((tp->t_flags & (EVENP|ODDP)) == ODDP))
                                continue;
+#if NBK > 0
                if (tp->t_line == NETLDISC) {
                        c &= 0177;
                        BKINPUT(c, tp);
                } else
                if (tp->t_line == NETLDISC) {
                        c &= 0177;
                        BKINPUT(c, tp);
                } else
+#endif
                        (*linesw[tp->t_line].l_rint)(c, tp);
        }
 }
                        (*linesw[tp->t_line].l_rint)(c, tp);
        }
 }
@@ -363,7 +367,7 @@ dzstart(tp)
        }
        if (tp->t_outq.c_cc == 0)
                goto out;
        }
        if (tp->t_outq.c_cc == 0)
                goto out;
-       if (tp->t_flags&RAW)
+       if (tp->t_flags&RAW || tp->t_local&LLITOUT)
                cc = ndqb(&tp->t_outq, 0);
        else {
                cc = ndqb(&tp->t_outq, 0200);
                cc = ndqb(&tp->t_outq, 0);
        else {
                cc = ndqb(&tp->t_outq, 0200);
@@ -425,6 +429,8 @@ dzscan()
  
        for (i = 0; i < dz_cnt ; i++) {
                dzaddr = dzpdma[i].p_addr;
  
        for (i = 0; i < dz_cnt ; i++) {
                dzaddr = dzpdma[i].p_addr;
+               if (dzaddr == 0)
+                       continue;
                tp = &dz_tty[i];
                bit = 1<<(i&07);
                if ((dzsoftCAR[i>>3]&bit) || (dzaddr->dzmsr&bit)) {
                tp = &dz_tty[i];
                bit = 1<<(i&07);
                if ((dzsoftCAR[i>>3]&bit) || (dzaddr->dzmsr&bit)) {
@@ -447,14 +453,14 @@ dzscan()
                        }
                }
        }
                        }
                }
        }
-       timeout(dzscan, (caddr_t)0, 2*HZ);
+       timeout(dzscan, (caddr_t)0, 2*hz);
 }
 
 dztimer()
 {
        int dz;
 
 }
 
 dztimer()
 {
        int dz;
 
-       for (dz = 0; dz < NDZ11; dz++)
+       for (dz = 0; dz < NDZ; dz++)
                dzrint(dz);
 }
 
                dzrint(dz);
 }
 
@@ -467,17 +473,14 @@ dzreset(uban)
 {
        register int unit;
        register struct tty *tp;
 {
        register int unit;
        register struct tty *tp;
-       register struct uba_dinfo *ui;
-       int any = 0;
+       register struct uba_device *ui;
 
 
-       for (unit = 0; unit < NDZ; unit++) {
+       for (unit = 0; unit < NDZLINE; unit++) {
                ui = dzinfo[unit >> 3];
                if (ui == 0 || ui->ui_ubanum != uban || ui->ui_alive == 0)
                        continue;
                ui = dzinfo[unit >> 3];
                if (ui == 0 || ui->ui_ubanum != uban || ui->ui_alive == 0)
                        continue;
-               if (any == 0) {
-                       printf(" dz");
-                       any++;
-               }
+               if (unit%8 == 0)
+                       printf(" dz%d", unit>>3);
                tp = &dz_tty[unit];
                if (tp->t_state & (ISOPEN|WOPEN)) {
                        dzparam(unit);
                tp = &dz_tty[unit];
                if (tp->t_state & (ISOPEN|WOPEN)) {
                        dzparam(unit);