ioctls
[unix-history] / usr / src / sys / vax / if / if_dmc.c
index 1f71e39..f3705fa 100644 (file)
@@ -1,20 +1,22 @@
-/*     if_dmc.c        4.19    82/10/10        */
+/*     if_dmc.c        4.26    83/05/27        */
 
 #include "dmc.h"
 #if NDMC > 0
 #define printd if(dmcdebug)printf
 
 #include "dmc.h"
 #if NDMC > 0
 #define printd if(dmcdebug)printf
-int dmcdebug = 1;
+int dmcdebug = 0;
 /*
  * DMC11 device driver, internet version
  *
  * TODO
  *     allow more than one outstanding read or write.
 /*
  * DMC11 device driver, internet version
  *
  * TODO
  *     allow more than one outstanding read or write.
+ *
+ * UNTESTED WITH 4.1C
  */
  */
+#include "../machine/pte.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/mbuf.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/mbuf.h"
-#include "../h/pte.h"
 #include "../h/buf.h"
 #include "../h/tty.h"
 #include "../h/protosw.h"
 #include "../h/buf.h"
 #include "../h/tty.h"
 #include "../h/protosw.h"
@@ -23,6 +25,7 @@ int dmcdebug = 1;
 #include <errno.h>
 
 #include "../net/if.h"
 #include <errno.h>
 
 #include "../net/if.h"
+#include "../net/netisr.h"
 #include "../net/route.h"
 #include "../netinet/in.h"
 #include "../netinet/in_systm.h"
 #include "../net/route.h"
 #include "../netinet/in.h"
 #include "../netinet/in_systm.h"
@@ -34,6 +37,10 @@ int dmcdebug = 1;
 #include "../vaxuba/ubareg.h"
 #include "../vaxuba/ubavar.h"
 
 #include "../vaxuba/ubareg.h"
 #include "../vaxuba/ubavar.h"
 
+#ifndef DMC_USEMAINT
+#define        DMC_USEMAINT    1       /* use maintenance mode */
+#endif
+
 /*
  * Driver information for auto-configuration stuff.
  */
 /*
  * Driver information for auto-configuration stuff.
  */
@@ -127,7 +134,7 @@ dmcattach(ui)
        sin->sin_addr = if_makeaddr(sc->sc_if.if_net, sc->sc_if.if_host[0]);
        sc->sc_if.if_init = dmcinit;
        sc->sc_if.if_output = dmcoutput;
        sin->sin_addr = if_makeaddr(sc->sc_if.if_net, sc->sc_if.if_host[0]);
        sc->sc_if.if_init = dmcinit;
        sc->sc_if.if_output = dmcoutput;
-       sc->sc_if.if_ubareset = dmcreset;
+       sc->sc_if.if_reset = dmcreset;
        /* DON'T KNOW IF THIS WILL WORK WITH A BDP AT HIGH SPEEDS */
        sc->sc_ifuba.ifu_flags = UBA_NEEDBDP | UBA_CANTWAIT;
        if_attach(&sc->sc_if);
        /* DON'T KNOW IF THIS WILL WORK WITH A BDP AT HIGH SPEEDS */
        sc->sc_ifuba.ifu_flags = UBA_NEEDBDP | UBA_CANTWAIT;
        if_attach(&sc->sc_if);
@@ -177,7 +184,7 @@ dmcinit(unit)
        base = sc->sc_ubinfo & 0x3ffff;
        printd("  base 0x%x\n", base);
        dmcload(sc, DMC_BASEI, base, (base>>2)&DMC_XMEM);
        base = sc->sc_ubinfo & 0x3ffff;
        printd("  base 0x%x\n", base);
        dmcload(sc, DMC_BASEI, base, (base>>2)&DMC_XMEM);
-       dmcload(sc, DMC_CNTLI, 0, 0);
+       dmcload(sc, DMC_CNTLI, 0, DMC_USEMAINT ? DMC_MAINT : 0);
        base = sc->sc_ifuba.ifu_r.ifrw_info & 0x3ffff;
        dmcload(sc, DMC_READ, base, ((base>>2)&DMC_XMEM)|DMCMTU);
        printd("  first read queued, addr 0x%x\n", base);
        base = sc->sc_ifuba.ifu_r.ifrw_info & 0x3ffff;
        dmcload(sc, DMC_READ, base, ((base>>2)&DMC_XMEM)|DMCMTU);
        printd("  first read queued, addr 0x%x\n", base);
@@ -198,7 +205,6 @@ dmcstart(dev)
        dev_t dev;
 {
        int unit = minor(dev);
        dev_t dev;
 {
        int unit = minor(dev);
-       struct uba_device *ui = dmcinfo[unit];
        register struct dmc_softc *sc = &dmc_softc[unit];
        int addr, len;
        struct mbuf *m;
        register struct dmc_softc *sc = &dmc_softc[unit];
        int addr, len;
        struct mbuf *m;
@@ -272,7 +278,7 @@ dmcrint(unit)
                while (addr->bsel0&DMC_RDYI)
                        ;
                if (sc->sc_que.c_cc == 0)
                while (addr->bsel0&DMC_RDYI)
                        ;
                if (sc->sc_que.c_cc == 0)
-                       return;
+                       goto out;
                addr->bsel0 = getc(&sc->sc_que);
                n = RDYSCAN;
                while (n-- && (addr->bsel0&DMC_RDYI) == 0)
                addr->bsel0 = getc(&sc->sc_que);
                n = RDYSCAN;
                while (n-- && (addr->bsel0&DMC_RDYI) == 0)
@@ -280,6 +286,8 @@ dmcrint(unit)
        }
        if (sc->sc_que.c_cc)
                addr->bsel0 |= DMC_IEI;
        }
        if (sc->sc_que.c_cc)
                addr->bsel0 |= DMC_IEI;
+out:
+       dmcxint(unit);
 }
 
 /*
 }
 
 /*
@@ -296,15 +304,18 @@ dmcxint(unit)
        struct dmcdevice *addr;
        struct mbuf *m;
        register struct ifqueue *inq;
        struct dmcdevice *addr;
        struct mbuf *m;
        register struct ifqueue *inq;
-       int arg, cmd, len;
+       int arg, arg2, cmd, len;
 
        addr = (struct dmcdevice *)ui->ui_addr;
 
        addr = (struct dmcdevice *)ui->ui_addr;
+       cmd = addr->bsel2 & 0xff;
+       if ((cmd & DMC_RDYO) == 0)
+               return;
+       arg2 = addr->sel4;
        arg = addr->sel6;
        arg = addr->sel6;
-       cmd = addr->bsel2&7;
        addr->bsel2 &= ~DMC_RDYO;
        sc = &dmc_softc[unit];
        printd("dmcxint\n");
        addr->bsel2 &= ~DMC_RDYO;
        sc = &dmc_softc[unit];
        printd("dmcxint\n");
-       switch (cmd) {
+       switch (cmd & 07) {
 
        case DMC_OUR:
                /*
 
        case DMC_OUR:
                /*
@@ -336,7 +347,7 @@ dmcxint(unit)
                        goto setup;
                if (IF_QFULL(inq)) {
                        IF_DROP(inq);
                        goto setup;
                if (IF_QFULL(inq)) {
                        IF_DROP(inq);
-                       (void) m_freem(m);
+                       m_freem(m);
                } else
                        IF_ENQUEUE(inq, m);
 
                } else
                        IF_ENQUEUE(inq, m);
 
@@ -356,7 +367,7 @@ setup:
                sc->sc_if.if_opackets++;
                sc->sc_oactive = 0;
                if (sc->sc_ifuba.ifu_xtofree) {
                sc->sc_if.if_opackets++;
                sc->sc_oactive = 0;
                if (sc->sc_ifuba.ifu_xtofree) {
-                       (void) m_freem(sc->sc_ifuba.ifu_xtofree);
+                       m_freem(sc->sc_ifuba.ifu_xtofree);
                        sc->sc_ifuba.ifu_xtofree = 0;
                }
                if (sc->sc_if.if_snd.ifq_head == 0)
                        sc->sc_ifuba.ifu_xtofree = 0;
                }
                if (sc->sc_if.if_snd.ifq_head == 0)
@@ -397,7 +408,8 @@ dmcoutput(ifp, m, dst)
 
        printd("dmcoutput\n");
        if (dst->sa_family != (ui->ui_flags & DMC_AF)) {
 
        printd("dmcoutput\n");
        if (dst->sa_family != (ui->ui_flags & DMC_AF)) {
-               printf("dmc%d: af%d not supported\n", ifp->if_unit, pf);
+               printf("dmc%d: af%d not supported\n", ifp->if_unit,
+                       dst->sa_family);
                m_freem(m);
                return (EAFNOSUPPORT);
        }
                m_freem(m);
                return (EAFNOSUPPORT);
        }