start up cleanly
[unix-history] / usr / src / sys / vax / if / if_dmc.c
index e2e3c69..a2b5bf4 100644 (file)
@@ -1,4 +1,4 @@
-/*     if_dmc.c        4.12    82/04/16        */
+/*     if_dmc.c        4.18    82/10/09        */
 
 #include "dmc.h"
 #if NDMC > 0
 
 #include "dmc.h"
 #if NDMC > 0
@@ -24,13 +24,11 @@ int dmcdebug = 1;
 #include "../h/cpu.h"
 #include "../h/mtpr.h"
 #include "../h/vmmac.h"
 #include "../h/cpu.h"
 #include "../h/mtpr.h"
 #include "../h/vmmac.h"
-#include "../net/in.h"
-#include "../net/in_systm.h"
+#include "../netinet/in.h"
+#include "../netinet/in_systm.h"
 #include "../net/if.h"
 #include "../net/if.h"
-#include "../net/if_uba.h"
-#include "../net/if_dmc.h"
-#include "../net/ip.h"
-#include "../net/ip_var.h"
+#include "../vaxif/if_uba.h"
+#include "../vaxif/if_dmc.h"
 #include "../net/route.h"
 #include <errno.h>
 
 #include "../net/route.h"
 #include <errno.h>
 
@@ -44,7 +42,7 @@ struct        uba_driver dmcdriver =
        { dmcprobe, 0, dmcattach, 0, dmcstd, "dmc", dmcinfo };
 
 #define        DMC_AF  0xff            /* 8 bits of address type in ui_flags */
        { dmcprobe, 0, dmcattach, 0, dmcstd, "dmc", dmcinfo };
 
 #define        DMC_AF  0xff            /* 8 bits of address type in ui_flags */
-#define        DMC_NET 0xff00          /* 8 bits of net number in ui_flags */
+#define        DMC_NET 0xffffff00      /* 24 bits of net number in ui_flags */
 
 /*
  * DMC software status per interface.
 
 /*
  * DMC software status per interface.
@@ -85,7 +83,6 @@ dmcprobe(reg)
        register struct dmcdevice *addr = (struct dmcdevice *)reg;
        register int i;
 
        register struct dmcdevice *addr = (struct dmcdevice *)reg;
        register int i;
 
-COUNT(DMCPROBE);
 #ifdef lint
        br = 0; cvec = br; br = cvec;
        dmcrint(0); dmcxint(0);
 #ifdef lint
        br = 0; cvec = br; br = cvec;
        dmcrint(0); dmcxint(0);
@@ -101,7 +98,9 @@ COUNT(DMCPROBE);
        addr->bsel1 = DMC_MCLR;
        for (i = 100000; i && (addr->bsel1 & DMC_RUN) == 0; i--)
                ;
        addr->bsel1 = DMC_MCLR;
        for (i = 100000; i && (addr->bsel1 & DMC_RUN) == 0; i--)
                ;
-       br = 0x16;              /* temporary ec hack */
+#ifdef ECHACK
+       br = 0x16;
+#endif
        return (1);
 }
 
        return (1);
 }
 
@@ -116,19 +115,19 @@ dmcattach(ui)
        register struct dmc_softc *sc = &dmc_softc[ui->ui_unit];
        register struct sockaddr_in *sin;
 
        register struct dmc_softc *sc = &dmc_softc[ui->ui_unit];
        register struct sockaddr_in *sin;
 
-COUNT(DMCATTACH);
        sc->sc_if.if_unit = ui->ui_unit;
        sc->sc_if.if_name = "dmc";
        sc->sc_if.if_mtu = DMCMTU;
        sc->sc_if.if_net = (ui->ui_flags & DMC_NET) >> 8;
        sc->sc_if.if_host[0] = 17;      /* random number */
        sin = (struct sockaddr_in *)&sc->sc_if.if_addr;
        sc->sc_if.if_unit = ui->ui_unit;
        sc->sc_if.if_name = "dmc";
        sc->sc_if.if_mtu = DMCMTU;
        sc->sc_if.if_net = (ui->ui_flags & DMC_NET) >> 8;
        sc->sc_if.if_host[0] = 17;      /* random number */
        sin = (struct sockaddr_in *)&sc->sc_if.if_addr;
-       sin->sa_family = AF_INET;
+       sin->sin_family = AF_INET;
        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;
        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_ifuba.ifuba_flags = UBA_NEEDBDP | UBA_CANTWAIT;
+       /* 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);
 }
 
        if_attach(&sc->sc_if);
 }
 
@@ -141,7 +140,6 @@ dmcreset(unit, uban)
 {
        register struct uba_device *ui;
 
 {
        register struct uba_device *ui;
 
-COUNT(DMCRESET);
        if (unit >= NDMC || (ui = dmcinfo[unit]) == 0 || ui->ui_alive == 0 ||
            ui->ui_ubanum != uban)
                return;
        if (unit >= NDMC || (ui = dmcinfo[unit]) == 0 || ui->ui_alive == 0 ||
            ui->ui_ubanum != uban)
                return;
@@ -160,7 +158,6 @@ dmcinit(unit)
        register struct dmcdevice *addr;
        int base;
 
        register struct dmcdevice *addr;
        int base;
 
-COUNT(DMCINIT);
        printd("dmcinit\n");
        if ((sc->sc_flag&DMCBMAPPED) == 0) {
                sc->sc_ubinfo = uballoc(ui->ui_ubanum,
        printd("dmcinit\n");
        if ((sc->sc_flag&DMCBMAPPED) == 0) {
                sc->sc_ubinfo = uballoc(ui->ui_ubanum,
@@ -185,8 +182,7 @@ COUNT(DMCINIT);
        sc->sc_if.if_flags |= IFF_UP;
        /* set up routing table entry */
        if ((sc->sc_if.if_flags & IFF_ROUTE) == 0) {
        sc->sc_if.if_flags |= IFF_UP;
        /* set up routing table entry */
        if ((sc->sc_if.if_flags & IFF_ROUTE) == 0) {
-               rtinit(&sc->sc_if.if_addr, &sc->sc_if.if_addr,
-                       RTF_DIRECT|RTF_HOST|RTF_UP);
+               rtinit(&sc->sc_if.if_addr, &sc->sc_if.if_addr, RTF_HOST|RTF_UP);
                sc->sc_if.if_flags |= IFF_ROUTE;
        }
 }
                sc->sc_if.if_flags |= IFF_ROUTE;
        }
 }
@@ -205,7 +201,6 @@ dmcstart(dev)
        int addr, len;
        struct mbuf *m;
 
        int addr, len;
        struct mbuf *m;
 
-COUNT(DMCSTART);
        printd("dmcstart\n");
        /*
         * Dequeue a request and map it to the UNIBUS.
        printd("dmcstart\n");
        /*
         * Dequeue a request and map it to the UNIBUS.
@@ -220,7 +215,7 @@ COUNT(DMCSTART);
         * Have request mapped to UNIBUS for transmission.
         * Purge any stale data from this BDP and start the output.
         */
         * Have request mapped to UNIBUS for transmission.
         * Purge any stale data from this BDP and start the output.
         */
-       if (sc->sc_ifuba.ifuba_flags & UBA_NEEDBDP)
+       if (sc->sc_ifuba.ifu_flags & UBA_NEEDBDP)
                UBAPURGE(sc->sc_ifuba.ifu_uba, sc->sc_ifuba.ifu_w.ifrw_bdp);
        addr = sc->sc_ifuba.ifu_w.ifrw_info & 0x3ffff;
        printd("  len %d, addr 0x%x, ", len, addr);
                UBAPURGE(sc->sc_ifuba.ifu_uba, sc->sc_ifuba.ifu_w.ifrw_bdp);
        addr = sc->sc_ifuba.ifu_w.ifrw_info & 0x3ffff;
        printd("  len %d, addr 0x%x, ", len, addr);
@@ -239,7 +234,6 @@ dmcload(sc, type, w0, w1)
        register struct dmcdevice *addr;
        register int unit, sps, n;
 
        register struct dmcdevice *addr;
        register int unit, sps, n;
 
-COUNT(DMCLOAD);
        printd("dmcload: 0x%x 0x%x 0x%x\n", type, w0, w1);
        unit = sc - dmc_softc;
        addr = (struct dmcdevice *)dmcinfo[unit]->ui_addr;
        printd("dmcload: 0x%x 0x%x 0x%x\n", type, w0, w1);
        unit = sc - dmc_softc;
        addr = (struct dmcdevice *)dmcinfo[unit]->ui_addr;
@@ -266,22 +260,13 @@ dmcrint(unit)
        register struct dmc_softc *sc;
        register struct dmcdevice *addr;
        register int n;
        register struct dmc_softc *sc;
        register struct dmcdevice *addr;
        register int n;
-       int w0, w1; /* DEBUG */
 
 
-COUNT(DMCRINT);
        addr = (struct dmcdevice *)dmcinfo[unit]->ui_addr;
        sc = &dmc_softc[unit];
        while (addr->bsel0&DMC_RDYI) {
        addr = (struct dmcdevice *)dmcinfo[unit]->ui_addr;
        sc = &dmc_softc[unit];
        while (addr->bsel0&DMC_RDYI) {
-               w0 = getw(&sc->sc_que); /* DEBUG */
-               addr->sel4 = w0; /* DEBUG */
-               w1 = getw(&sc->sc_que); /* DEBUG */
-               addr->sel6 = w1; /* DEBUG */
-               /* DEBUG
                addr->sel4 = getw(&sc->sc_que);
                addr->sel6 = getw(&sc->sc_que);
                addr->sel4 = getw(&sc->sc_que);
                addr->sel6 = getw(&sc->sc_que);
-               DEBUG */
                addr->bsel0 &= ~(DMC_IEI|DMC_RQI);
                addr->bsel0 &= ~(DMC_IEI|DMC_RQI);
-               printd("  w0 0x%x, w1 0x%x\n", w0, w1);
                while (addr->bsel0&DMC_RDYI)
                        ;
                if (sc->sc_que.c_cc == 0)
                while (addr->bsel0&DMC_RDYI)
                        ;
                if (sc->sc_que.c_cc == 0)
@@ -311,7 +296,6 @@ dmcxint(unit)
        register struct ifqueue *inq;
        int arg, cmd, len;
 
        register struct ifqueue *inq;
        int arg, cmd, len;
 
-COUNT(DMCXINT);
        addr = (struct dmcdevice *)ui->ui_addr;
        arg = addr->sel6;
        cmd = addr->bsel2&7;
        addr = (struct dmcdevice *)ui->ui_addr;
        arg = addr->sel6;
        cmd = addr->bsel2&7;
@@ -327,7 +311,7 @@ COUNT(DMCXINT);
                 * higher-level input routine.
                 */
                sc->sc_if.if_ipackets++;
                 * higher-level input routine.
                 */
                sc->sc_if.if_ipackets++;
-               if (sc->sc_ifuba.ifuba_flags & UBA_NEEDBDP)
+               if (sc->sc_ifuba.ifu_flags & UBA_NEEDBDP)
                        UBAPURGE(sc->sc_ifuba.ifu_uba,
                                sc->sc_ifuba.ifu_r.ifrw_bdp);
                len = arg & DMC_CCOUNT;
                        UBAPURGE(sc->sc_ifuba.ifu_uba,
                                sc->sc_ifuba.ifu_r.ifrw_bdp);
                len = arg & DMC_CCOUNT;
@@ -409,7 +393,6 @@ dmcoutput(ifp, m, dst)
        struct uba_device *ui = dmcinfo[ifp->if_unit];
        int s;
 
        struct uba_device *ui = dmcinfo[ifp->if_unit];
        int s;
 
-COUNT(DMCOUTPUT);
        printd("dmcoutput\n");
        if (dst->sa_family != (ui->ui_flags & DMC_AF)) {
                printf("dmc%d: af%d not supported\n", ifp->if_unit, pf);
        printd("dmcoutput\n");
        if (dst->sa_family != (ui->ui_flags & DMC_AF)) {
                printf("dmc%d: af%d not supported\n", ifp->if_unit, pf);