new version which doesn't get hung up
[unix-history] / usr / src / sys / vax / uba / dh.c
index 65fb2f2..a37208b 100644 (file)
@@ -1,11 +1,12 @@
-/*     dh.c    4.17    81/02/18        */
+/*     dh.c    4.26    81/02/27        */
 
 #include "dh.h"
 
 #include "dh.h"
-#if NDH11 > 0
+#if NDH > 0
 #define        DELAY(i)        { register int j = i; while (--j > 0); }
 /*
  * DH-11/DM-11 driver
  */
 #define        DELAY(i)        { register int j = i; while (--j > 0); }
 /*
  * DH-11/DM-11 driver
  */
+#include "bk.h"
 #include "../h/param.h"
 #include "../h/conf.h"
 #include "../h/dir.h"
 #include "../h/param.h"
 #include "../h/conf.h"
 #include "../h/dir.h"
@@ -14,6 +15,7 @@
 #include "../h/map.h"
 #include "../h/pte.h"
 #include "../h/buf.h"
 #include "../h/map.h"
 #include "../h/pte.h"
 #include "../h/buf.h"
+#include "../h/vm.h"
 #include "../h/uba.h"
 #include "../h/bk.h"
 #include "../h/clist.h"
 #include "../h/uba.h"
 #include "../h/bk.h"
 #include "../h/clist.h"
  * Definition of the driver for the auto-configuration program.
  * There is one definition for the dh and one for the dm.
  */
  * Definition of the driver for the auto-configuration program.
  * There is one definition for the dh and one for the dm.
  */
-int    dhcntrlr(), dhslave(), dhrint(), dhxint();
-struct uba_dinfo *dhinfo[NDH11];
+int    dhprobe(), dhattach(), dhrint(), dhxint();
+struct uba_dinfo *dhinfo[NDH];
 u_short        dhstd[] = { 0 };
 struct uba_driver dhdriver =
 u_short        dhstd[] = { 0 };
 struct uba_driver dhdriver =
-       { dhcntrlr, dhslave, 0, 0, dhstd, "dh11", dhinfo };
+       { dhprobe, 0, dhattach, 0, dhstd, "dh", dhinfo };
 
 
-int    dmcntrlr(), dmslave(), dmintr();
-struct uba_dinfo *dminfo[NDH11];
+int    dmprobe(), dmattach(), dmintr();
+struct uba_dinfo *dminfo[NDH];
 u_short        dmstd[] = { 0 };
 struct uba_driver dmdriver =
 u_short        dmstd[] = { 0 };
 struct uba_driver dmdriver =
-       { dmcntrlr, dmslave, 0, 0, dmstd, "dm11", dminfo };
+       { dmprobe, 0, dmattach, 0, dmstd, "dm", dminfo };
 
 struct dhdevice
 {
 
 struct dhdevice
 {
@@ -117,10 +119,11 @@ struct dmdevice
 /*
  * Local variables for the driver
  */
 /*
  * Local variables for the driver
  */
-short  dhsar[NDH11];                   /* software copy of last bar */
+short  dhsar[NDH];                     /* software copy of last bar */
+short  dhsoftCAR[NDH];
 
 
-struct tty dh11[NDH11*16];
-int    ndh11   = NDH11*16;
+struct tty dh11[NDH*16];
+int    ndh11   = NDH*16;
 int    dhact;                          /* mask of active dh's */
 int    dhstart(), ttrstrt();
 
 int    dhact;                          /* mask of active dh's */
 int    dhstart(), ttrstrt();
 
@@ -138,14 +141,20 @@ int       cbase[MAXNUBA];                 /* base address in unibus map */
  * Set to transmit at 9600 baud, and cause a transmitter interrupt.
  */
 /*ARGSUSED*/
  * Set to transmit at 9600 baud, and cause a transmitter interrupt.
  */
 /*ARGSUSED*/
-dhcntrlr(ui, reg)
-       struct uba_dinfo *ui;
+dhprobe(reg)
        caddr_t reg;
 {
        register int br, cvec;          /* these are ``value-result'' */
        register struct dhdevice *dhaddr = (struct dhdevice *)reg;
        caddr_t reg;
 {
        register int br, cvec;          /* these are ``value-result'' */
        register struct dhdevice *dhaddr = (struct dhdevice *)reg;
-       int i;
 
 
+#ifdef lint
+       br = 0; cvec = br; br = cvec;
+#endif
+#ifndef notdef
+       dhaddr->un.dhcsr = DH_RIE|DH_MM|DH_RI;
+       DELAY(5);
+       dhaddr->un.dhcsr = 0;
+#else
        dhaddr->un.dhcsr = DH_TIE;
        DELAY(5);
        dhaddr->dhlpr = (B9600 << 10) | (B9600 << 6) | BITS7|PENABLE;
        dhaddr->un.dhcsr = DH_TIE;
        DELAY(5);
        dhaddr->dhlpr = (B9600 << 10) | (B9600 << 6) | BITS7|PENABLE;
@@ -156,39 +165,41 @@ dhcntrlr(ui, reg)
        dhaddr->un.dhcsr = 0;
        if (cvec && cvec != 0x200)
                cvec -= 4;              /* transmit -> receive */
        dhaddr->un.dhcsr = 0;
        if (cvec && cvec != 0x200)
                cvec -= 4;              /* transmit -> receive */
+#endif
        return (1);
 }
 
 /*
        return (1);
 }
 
 /*
- * Routine called to init slave tables.
+ * Routine called to attach a dh.
  */
  */
-dhslave(ui, reg, slaveno)
+dhattach(ui)
        struct uba_dinfo *ui;
        struct uba_dinfo *ui;
-       caddr_t reg;
 {
 
 {
 
-       /* no tables to set up */
+       dhsoftCAR[ui->ui_unit] = ui->ui_flags;
 }
 
 /*
  * Configuration routine to cause a dm to interrupt.
  */
 }
 
 /*
  * Configuration routine to cause a dm to interrupt.
  */
-dmcntrlr(um, addr)
-       struct uba_minfo *um;
-       caddr_t addr;
+dmprobe(reg)
+       caddr_t reg;
 {
        register int br, vec;                   /* value-result */
 {
        register int br, vec;                   /* value-result */
-       register struct dmdevice *dmaddr = (struct dmdevice *)addr;
+       register struct dmdevice *dmaddr = (struct dmdevice *)reg;
 
 
+#ifdef lint
+       br = 0; cvec = br; br = cvec;
+#endif
        dmaddr->dmcsr = DM_DONE|DM_IE;
        DELAY(20);
        dmaddr->dmcsr = 0;
        dmaddr->dmcsr = DM_DONE|DM_IE;
        DELAY(20);
        dmaddr->dmcsr = 0;
+       return (1);
 }
 
 }
 
-dmslave(ui, addr, slave)
+/*ARGSUSED*/
+dmattach(ui)
        struct uba_dinfo *ui;
        struct uba_dinfo *ui;
-       caddr_t addr;
-       int slave;
 {
 
        /* no local state to set up */
 {
 
        /* no local state to set up */
@@ -211,7 +222,7 @@ dhopen(dev, flag)
 
        unit = minor(dev);
        dh = unit >> 4;
 
        unit = minor(dev);
        dh = unit >> 4;
-       if (unit >= NDH11*16 || (ui = dhinfo[dh])== 0 || ui->ui_alive == 0) {
+       if (unit >= NDH*16 || (ui = dhinfo[dh])== 0 || ui->ui_alive == 0) {
                u.u_error = ENXIO;
                return;
        }
                u.u_error = ENXIO;
                return;
        }
@@ -234,12 +245,11 @@ dhopen(dev, flag)
                /* 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+ 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);
+                       512+nclist*sizeof(struct cblock), 0);
                cbase[ui->ui_ubanum] = dh_ubinfo[ui->ui_ubanum]&0x3ffff;
        }
        if ((dhact&(1<<dh)) == 0) {
                addr->un.dhcsr |= DH_IE;
                cbase[ui->ui_ubanum] = dh_ubinfo[ui->ui_ubanum]&0x3ffff;
        }
        if ((dhact&(1<<dh)) == 0) {
                addr->un.dhcsr |= DH_IE;
-               DELAY(5);
                dhact |= (1<<dh);
                addr->dhsilo = 16;
        }
                dhact |= (1<<dh);
                addr->dhsilo = 16;
        }
@@ -312,7 +322,6 @@ dhrint(dh)
        register struct dhdevice *addr;
        register struct tty *tp0;
        register struct uba_dinfo *ui;
        register struct dhdevice *addr;
        register struct tty *tp0;
        register struct uba_dinfo *ui;
-       int s;
 
        ui = dhinfo[dh];
        if (ui == 0 || ui->ui_alive == 0)
 
        ui = dhinfo[dh];
        if (ui == 0 || ui->ui_alive == 0)
@@ -345,10 +354,12 @@ dhrint(dh)
                                c = 0;
                        else
                                c = tun.t_intrc;
                                c = 0;
                        else
                                c = tun.t_intrc;
+#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);
        }
 }
@@ -441,13 +452,11 @@ dhxint(dh)
        short ttybit, bar, *sbar;
        register struct uba_dinfo *ui;
        register int unit;
        short ttybit, bar, *sbar;
        register struct uba_dinfo *ui;
        register int unit;
-       int s;
-       u_short cnt;
+       u_short cntr;
 
        ui = dhinfo[dh];
        addr = (struct dhdevice *)ui->ui_addr;
        if (addr->un.dhcsr & DH_NXM) {
 
        ui = dhinfo[dh];
        addr = (struct dhdevice *)ui->ui_addr;
        if (addr->un.dhcsr & DH_NXM) {
-               DELAY(5);
                addr->un.dhcsr |= DH_CNI;
                printf("dh%d NXM\n", dh);
        }
                addr->un.dhcsr |= DH_CNI;
                printf("dh%d NXM\n", dh);
        }
@@ -465,14 +474,13 @@ dhxint(dh)
                                tp->t_state &= ~FLUSH;
                        else {
                                addr->un.dhcsrl = (unit&017)|DH_IE;
                                tp->t_state &= ~FLUSH;
                        else {
                                addr->un.dhcsrl = (unit&017)|DH_IE;
-                               DELAY(5);
                                /*
                                 * Do arithmetic in a short to make up
                                 * for lost 16&17 bits.
                                 */
                                /*
                                 * Do arithmetic in a short to make up
                                 * for lost 16&17 bits.
                                 */
-                               cnt = addr->dhcar -
+                               cntr = addr->dhcar -
                                    UBACVT(tp->t_outq.c_cf, ui->ui_ubanum);
                                    UBACVT(tp->t_outq.c_cf, ui->ui_ubanum);
-                               ndflush(&tp->t_outq, cnt);
+                               ndflush(&tp->t_outq, cntr);
                        }
                        if (tp->t_line)
                                (*linesw[tp->t_line].l_start)(tp);
                        }
                        if (tp->t_line)
                                (*linesw[tp->t_line].l_start)(tp);
@@ -544,7 +552,6 @@ dhstart(tp)
        if (nch) {
                car = UBACVT(tp->t_outq.c_cf, dhinfo[dh]->ui_ubanum);
                addr->un.dhcsrl = unit|((car>>12)&0x30)|DH_IE;
        if (nch) {
                car = UBACVT(tp->t_outq.c_cf, dhinfo[dh]->ui_ubanum);
                addr->un.dhcsrl = unit|((car>>12)&0x30)|DH_IE;
-               DELAY(5);
                unit = 1 << unit;
                dhsar[dh] |= unit;
                addr->dhcar = car;
                unit = 1 << unit;
                dhsar[dh] |= unit;
                addr->dhcar = car;
@@ -580,7 +587,6 @@ dhstop(tp, flag)
                 */
                unit = minor(tp->t_dev);
                addr->un.dhcsrl = (unit&017) | DH_IE;
                 */
                unit = minor(tp->t_dev);
                addr->un.dhcsrl = (unit&017) | DH_IE;
-               DELAY(5);
                if ((tp->t_state&TTSTOP)==0)
                        tp->t_state |= FLUSH;
                addr->dhbcr = -1;
                if ((tp->t_state&TTSTOP)==0)
                        tp->t_state |= FLUSH;
                addr->dhbcr = -1;
@@ -606,15 +612,14 @@ dhreset(uban)
        printf(" dh");
        ubarelse(uban, &dh_ubinfo[uban]);
        dh_ubinfo[uban] = uballoc(uban, (caddr_t)cfree,
        printf(" dh");
        ubarelse(uban, &dh_ubinfo[uban]);
        dh_ubinfo[uban] = uballoc(uban, (caddr_t)cfree,
-           512+NCLIST*sizeof (struct cblock), 0);
+           512+nclist*sizeof (struct cblock), 0);
        cbase[uban] = dh_ubinfo[uban]&0x3ffff;
        dh = 0;
        cbase[uban] = dh_ubinfo[uban]&0x3ffff;
        dh = 0;
-       for (dh = 0; dh < NDH11; dh++) {
+       for (dh = 0; dh < NDH; dh++) {
                ui = dhinfo[dh];
                if (ui == 0 || ui->ui_alive == 0 || ui->ui_ubanum != uban)
                        continue;
                ((struct dhdevice *)ui->ui_addr)->un.dhcsr |= DH_IE;
                ui = dhinfo[dh];
                if (ui == 0 || ui->ui_alive == 0 || ui->ui_ubanum != uban)
                        continue;
                ((struct dhdevice *)ui->ui_addr)->un.dhcsr |= DH_IE;
-               DELAY(5);
                ((struct dhdevice *)ui->ui_addr)->dhsilo = 16;
                unit = dh * 16;
                for (i = 0; i < 16; i++) {
                ((struct dhdevice *)ui->ui_addr)->dhsilo = 16;
                unit = dh * 16;
                for (i = 0; i < 16; i++) {
@@ -639,7 +644,7 @@ dhtimer()
 {
        register int dh;
 
 {
        register int dh;
 
-       for (dh = 0; dh < NDH11; dh++)
+       for (dh = 0; dh < NDH; dh++)
                dhrint(dh);
 }
 
                dhrint(dh);
 }
 
@@ -658,7 +663,9 @@ dmopen(dev)
        unit = minor(dev);
        dm = unit >> 4;
        tp = &dh11[unit];
        unit = minor(dev);
        dm = unit >> 4;
        tp = &dh11[unit];
-       if (dm >= NDH11 || (ui = dminfo[dm]) == 0 || ui->ui_alive == 0) {
+       unit &= 0xf;
+       if (dm >= NDH || (ui = dminfo[dm]) == 0 || ui->ui_alive == 0 ||
+           (dhsoftCAR[dm]&(1<<unit))) {
                tp->t_state |= CARR_ON;
                return;
        }
                tp->t_state |= CARR_ON;
                return;
        }
@@ -667,7 +674,7 @@ dmopen(dev)
        addr->dmcsr &= ~DM_SE;
        while (addr->dmcsr & DM_BUSY)
                ;
        addr->dmcsr &= ~DM_SE;
        while (addr->dmcsr & DM_BUSY)
                ;
-       addr->dmcsr = unit & 0xf;
+       addr->dmcsr = unit;
        addr->dmlstat = DML_ON;
        if (addr->dmlstat&DML_CAR)
                tp->t_state |= CARR_ON;
        addr->dmlstat = DML_ON;
        if (addr->dmlstat&DML_CAR)
                tp->t_state |= CARR_ON;
@@ -754,3 +761,4 @@ dmintr(dm)
                addr->dmcsr = DH_IE|DM_SE;
        }
 }
                addr->dmcsr = DH_IE|DM_SE;
        }
 }
+#endif