misc pre-mba changes (non-recursive printf, futz, resuba, %uXX...)
[unix-history] / usr / src / sys / vax / uba / dz.c
index 48704d7..ecc78df 100644 (file)
@@ -1,5 +1,7 @@
-/*     dz.c    3.15    %G%     */
+/*     dz.c    4.8     %G%     */
 
 
+#include "dz.h"
+#if NDZ11 > 0
 /*
  *  DZ-11 Driver
  */
 /*
  *  DZ-11 Driver
  */
@@ -15,6 +17,7 @@
 #include "../h/pdma.h"
 #include "../h/bk.h"
 #include "../h/file.h"
 #include "../h/pdma.h"
 #include "../h/bk.h"
 #include "../h/file.h"
+#include "../h/mx.h"
 
 /*
  * When running dz's using only SAE (silo alarm) on input
 
 /*
  * When running dz's using only SAE (silo alarm) on input
  */
 #define        spl5    spl6
  
  */
 #define        spl5    spl6
  
-#define DZADDR  (UBA0_DEV + 0160100)
-#ifdef DISTRIB
-#define        NDZ11   1
-#else
-#define NDZ11  3
-#endif
 #define NDZ    (NDZ11*8)
  
 #define BITS7  020
 #define NDZ    (NDZ11*8)
  
 #define BITS7  020
@@ -63,7 +60,6 @@ int   ttrstrt();
 struct tty dz_tty[NDZ];
 int    dz_cnt = { NDZ };
 int    dzact;
 struct tty dz_tty[NDZ];
 int    dz_cnt = { NDZ };
 int    dzact;
-int    dzinit;
 
 struct device {
        short   dzcsr;
 
 struct device {
        short   dzcsr;
@@ -83,7 +79,7 @@ struct pdma dzpdma[] = {
        (struct device *)(DZADDR), NULL, NULL, (int)&dz_tty[5], dzxint,
        (struct device *)(DZADDR), NULL, NULL, (int)&dz_tty[6], dzxint,
        (struct device *)(DZADDR), NULL, NULL, (int)&dz_tty[7], dzxint,
        (struct device *)(DZADDR), NULL, NULL, (int)&dz_tty[5], dzxint,
        (struct device *)(DZADDR), NULL, NULL, (int)&dz_tty[6], dzxint,
        (struct device *)(DZADDR), NULL, NULL, (int)&dz_tty[7], dzxint,
-#if NDZ >= 2
+#if NDZ11 >= 2
        (struct device *)(DZADDR+010), NULL, NULL, (int)&dz_tty[8], dzxint,
        (struct device *)(DZADDR+010), NULL, NULL, (int)&dz_tty[9], dzxint,
        (struct device *)(DZADDR+010), NULL, NULL, (int)&dz_tty[10], dzxint,
        (struct device *)(DZADDR+010), NULL, NULL, (int)&dz_tty[8], dzxint,
        (struct device *)(DZADDR+010), NULL, NULL, (int)&dz_tty[9], dzxint,
        (struct device *)(DZADDR+010), NULL, NULL, (int)&dz_tty[10], dzxint,
@@ -93,7 +89,7 @@ struct pdma dzpdma[] = {
        (struct device *)(DZADDR+010), NULL, NULL, (int)&dz_tty[14], dzxint,
        (struct device *)(DZADDR+010), NULL, NULL, (int)&dz_tty[15], dzxint,
 #endif
        (struct device *)(DZADDR+010), NULL, NULL, (int)&dz_tty[14], dzxint,
        (struct device *)(DZADDR+010), NULL, NULL, (int)&dz_tty[15], dzxint,
 #endif
-#if NDZ >= 3
+#if NDZ11 >= 3
        (struct device *)(DZADDR+020), NULL, NULL, (int)&dz_tty[16], dzxint,
        (struct device *)(DZADDR+020), NULL, NULL, (int)&dz_tty[17], dzxint,
        (struct device *)(DZADDR+020), NULL, NULL, (int)&dz_tty[18], dzxint,
        (struct device *)(DZADDR+020), NULL, NULL, (int)&dz_tty[16], dzxint,
        (struct device *)(DZADDR+020), NULL, NULL, (int)&dz_tty[17], dzxint,
        (struct device *)(DZADDR+020), NULL, NULL, (int)&dz_tty[18], dzxint,
@@ -103,7 +99,7 @@ struct pdma dzpdma[] = {
        (struct device *)(DZADDR+020), NULL, NULL, (int)&dz_tty[22], dzxint,
        (struct device *)(DZADDR+020), NULL, NULL, (int)&dz_tty[23], dzxint,
 #endif
        (struct device *)(DZADDR+020), NULL, NULL, (int)&dz_tty[22], dzxint,
        (struct device *)(DZADDR+020), NULL, NULL, (int)&dz_tty[23], dzxint,
 #endif
-#if NDZ >= 4
+#if NDZ11 >= 4
        (struct device *)(DZADDR+030), NULL, NULL, (int)&dz_tty[24], dzxint,
        (struct device *)(DZADDR+030), NULL, NULL, (int)&dz_tty[25], dzxint,
        (struct device *)(DZADDR+030), NULL, NULL, (int)&dz_tty[26], dzxint,
        (struct device *)(DZADDR+030), NULL, NULL, (int)&dz_tty[24], dzxint,
        (struct device *)(DZADDR+030), NULL, NULL, (int)&dz_tty[25], dzxint,
        (struct device *)(DZADDR+030), NULL, NULL, (int)&dz_tty[26], dzxint,
@@ -119,6 +115,7 @@ char        dz_speeds[] = {
        0, 020 , 021 , 022 , 023 , 024 , 0, 025,
        026 , 027 , 030 , 032 , 034 , 036 , 0 , 0,
 };
        0, 020 , 021 , 022 , 023 , 024 , 0, 025,
        026 , 027 , 030 , 032 , 034 , 036 , 0 , 0,
 };
+char dz_brk[NDZ11];
  
 /*ARGSUSED*/
 dzopen(d, flag)
  
 /*ARGSUSED*/
 dzopen(d, flag)
@@ -169,6 +166,12 @@ dzclose(d)
        dev = minor(d);
        tp = &dz_tty[dev];
        (*linesw[tp->t_line].l_close)(tp);
        dev = minor(d);
        tp = &dz_tty[dev];
        (*linesw[tp->t_line].l_close)(tp);
+       /*
+        * Turn the break bit off in case it was left on by a TIOCSBRK
+        * but not turned off by TIOCCBRK
+        */
+       ((struct pdma *)(tp->t_addr))->p_addr->dzbrk =
+               (dz_brk[minor(dev)>>3] &= ~(1 << (dev&07)));
        if (tp->t_state & HUPCLS)
                dzmodem(dev, OFF);
        ttyclose(tp);
        if (tp->t_state & HUPCLS)
                dzmodem(dev, OFF);
        ttyclose(tp);
@@ -247,13 +250,12 @@ caddr_t addr;
 dev_t dev;
 {
        register struct tty *tp;
 dev_t dev;
 {
        register struct tty *tp;
-       static char dz_brk[NDZ11];
  
        tp = &dz_tty[minor(dev)];
        cmd = (*linesw[tp->t_line].l_ioctl)(tp, cmd, addr);
        if (cmd == 0)
                return;
  
        tp = &dz_tty[minor(dev)];
        cmd = (*linesw[tp->t_line].l_ioctl)(tp, cmd, addr);
        if (cmd == 0)
                return;
-       if (ttioctl(cmd, tp, addr, dev, flag)) {
+       if (ttioctl(tp, cmd, addr, flag)) {
                if (cmd==TIOCSETP || cmd==TIOCSETN)
                        dzparam(minor(dev));
        } else switch(cmd) {
                if (cmd==TIOCSETP || cmd==TIOCSETN)
                        dzparam(minor(dev));
        } else switch(cmd) {
@@ -292,7 +294,7 @@ dzparam(dev)
        }
        lpr = (dz_speeds[tp->t_ispeed]<<8) | (dev & 07);
 #ifndef IIASA
        }
        lpr = (dz_speeds[tp->t_ispeed]<<8) | (dev & 07);
 #ifndef IIASA
-       if (tp->t_flags & RAW)
+       if ((tp->t_local&LLITOUT) || (tp->t_flags&RAW))
                lpr |= BITS8;
        else
                lpr |= (BITS7|PENABLE);
                lpr |= BITS8;
        else
                lpr |= (BITS7|PENABLE);
@@ -348,7 +350,7 @@ register struct tty *tp;
        sps = spl5();
        if (tp->t_state & (TIMEOUT|BUSY|TTSTOP))
                goto out;
        sps = spl5();
        if (tp->t_state & (TIMEOUT|BUSY|TTSTOP))
                goto out;
-       if (tp->t_outq.c_cc <= TTLOWAT && tp->t_state&ASLEEP) {
+       if (tp->t_state&ASLEEP && tp->t_outq.c_cc <= TTLOWAT(tp)) {
                tp->t_state &= ~ASLEEP;
                if (tp->t_chan)
                        mcstart(tp->t_chan, (caddr_t)&tp->t_outq);
                tp->t_state &= ~ASLEEP;
                if (tp->t_chan)
                        mcstart(tp->t_chan, (caddr_t)&tp->t_outq);
@@ -472,3 +474,4 @@ dzreset()
        }
        dztimer();
 }
        }
        dztimer();
 }
+#endif