fix includes
[unix-history] / usr / src / sys / vax / if / if_acc.c
index ca3d556..7df524c 100644 (file)
@@ -1,4 +1,4 @@
-/*     if_acc.c        4.6     82/02/25        */
+/*     if_acc.c        4.20    82/10/09        */
 
 #include "acc.h"
 #ifdef NACC > 0
 
 #include "acc.h"
 #ifdef NACC > 0
 #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 "../net/if.h"
 #include "../net/if.h"
-#include "../net/if_acc.h"
-#include "../net/if_imp.h"
-#include "../net/if_uba.h"
+#include "../vaxif/if_acc.h"
+#include "../netimp/if_imp.h"
+#include "../vaxif/if_uba.h"
 
 int     accprobe(), accattach(), accrint(), accxint();
 struct  uba_device *accinfo[NACC];
 
 int     accprobe(), accattach(), accrint(), accxint();
 struct  uba_device *accinfo[NACC];
@@ -71,7 +69,6 @@ accprobe(reg)
        register int br, cvec;          /* r11, r10 value-result */
        register struct accdevice *addr = (struct accdevice *)reg;
 
        register int br, cvec;          /* r11, r10 value-result */
        register struct accdevice *addr = (struct accdevice *)reg;
 
-COUNT(ACCPROBE);
 #ifdef lint
        br = 0; cvec = br; br = cvec;
        accrint(0); accxint(0);
 #ifdef lint
        br = 0; cvec = br; br = cvec;
        accrint(0); accxint(0);
@@ -84,6 +81,9 @@ COUNT(ACCPROBE);
        addr->ocsr = 0;
        if (cvec && cvec != 0x200)      /* transmit -> receive */
                cvec -= 4;
        addr->ocsr = 0;
        if (cvec && cvec != 0x200)      /* transmit -> receive */
                cvec -= 4;
+#ifdef ECHACK
+       br = 0x16;
+#endif
        return (1);
 }
 
        return (1);
 }
 
@@ -102,7 +102,6 @@ accattach(ui)
                struct  impcb ifimp_impcb;
        } *ifimp;
 
                struct  impcb ifimp_impcb;
        } *ifimp;
 
-COUNT(ACCATTACH);
        if ((ifimp = (struct ifimpcb *)impattach(ui)) == 0)
                panic("accattach");
        sc->acc_if = &ifimp->ifimp_if;
        if ((ifimp = (struct ifimpcb *)impattach(ui)) == 0)
                panic("accattach");
        sc->acc_if = &ifimp->ifimp_if;
@@ -110,8 +109,9 @@ COUNT(ACCATTACH);
        sc->acc_ic = ip;
        ip->ic_init = accinit;
        ip->ic_start = accstart;
        sc->acc_ic = ip;
        ip->ic_init = accinit;
        ip->ic_start = accstart;
+       sc->acc_ifuba.ifu_flags = UBA_CANTWAIT;
 #ifdef notdef
 #ifdef notdef
-       sc->acc_ifuba.ifu_flags = UBA_NEEDBDP;
+       sc->acc_ifuba.ifu_flags |= UBA_NEEDBDP;
 #endif
 }
 
 #endif
 }
 
@@ -125,7 +125,6 @@ accreset(unit, uban)
        register struct uba_device *ui;
        struct acc_softc *sc;
 
        register struct uba_device *ui;
        struct acc_softc *sc;
 
-COUNT(ACCRESET);
        if (unit >= NACC || (ui = accinfo[unit]) == 0 || ui->ui_alive == 0 ||
            ui->ui_ubanum != uban)
                return;
        if (unit >= NACC || (ui = accinfo[unit]) == 0 || ui->ui_alive == 0 ||
            ui->ui_ubanum != uban)
                return;
@@ -147,9 +146,8 @@ accinit(unit)
        register struct acc_softc *sc;
        register struct uba_device *ui;
        register struct accdevice *addr;
        register struct acc_softc *sc;
        register struct uba_device *ui;
        register struct accdevice *addr;
-       int x, info;
+       int info, i;
 
 
-COUNT(ACCINIT);
        if (unit >= NACC || (ui = accinfo[unit]) == 0 || ui->ui_alive == 0) {
                printf("acc%d: not alive\n", unit);
                return (0);
        if (unit >= NACC || (ui = accinfo[unit]) == 0 || ui->ui_alive == 0) {
                printf("acc%d: not alive\n", unit);
                return (0);
@@ -162,9 +160,11 @@ COUNT(ACCINIT);
         * sizeof(struct imp_leader), then the if_ routines
         * would asssume we handle it on input and output.
         */
         * sizeof(struct imp_leader), then the if_ routines
         * would asssume we handle it on input and output.
         */
-       if (if_ubainit(&sc->acc_ifuba, ui->ui_ubanum, 0, btoc(IMP_MTU)) == 0) {
+       if (if_ubainit(&sc->acc_ifuba, ui->ui_ubanum, 0,
+            (int)btoc(IMPMTU)) == 0) {
                printf("acc%d: can't initialize\n", unit);
                printf("acc%d: can't initialize\n", unit);
-               goto down;
+               ui->ui_alive = 0;
+               return (0);
        }
        addr = (struct accdevice *)ui->ui_addr;
 
        }
        addr = (struct accdevice *)ui->ui_addr;
 
@@ -172,48 +172,50 @@ COUNT(ACCINIT);
         * Reset the imp interface;
         * the delays are pure guesswork.
         */
         * Reset the imp interface;
         * the delays are pure guesswork.
         */
-       x = spl5();
-       addr->icsr = ACC_RESET; DELAY(5000);
         addr->ocsr = ACC_RESET; DELAY(5000);
         addr->ocsr = ACC_RESET; DELAY(5000);
-       addr->ocsr = OUT_BBACK; DELAY(1000);    /* reset host master ready */
+       addr->ocsr = OUT_BBACK; DELAY(5000);    /* reset host master ready */
        addr->ocsr = 0;
        addr->ocsr = 0;
-       splx(x);
-       addr->icsr = IN_MRDY | IN_WEN;          /* close the relay */
-       DELAY(5000);
-       /* YECH!!! */
-       x = 500;
-       while (x-- > 0) {
-               if ((addr->icsr & IN_HRDY) ||
-                   (addr->icsr & (IN_RMR | IN_IMPBSY) == 0))
-                       break;
-               addr->icsr = IN_MRDY | IN_WEN;
-               DELAY(5000);                    /* keep turning IN_RMR off */
-       }
-       if (x <= 0) {
-               printf("acc%d: imp doesn't respond, icsr=%b\n", unit,
-                       addr->icsr, ACC_INBITS);
-               goto down;
+       if (accinputreset(addr, unit) == 0) {
+               ui->ui_alive = 0;
+               return (0);
        }
 
        /*
         * Put up a read.  We can't restart any outstanding writes
         * until we're back in synch with the IMP (i.e. we've flushed
         * the NOOPs it throws at us).
        }
 
        /*
         * Put up a read.  We can't restart any outstanding writes
         * until we're back in synch with the IMP (i.e. we've flushed
         * the NOOPs it throws at us).
-        * Note: IMP_MTU includes the leader.
+        * Note: IMPMTU includes the leader.
         */
         */
-       x = spl5();
        info = sc->acc_ifuba.ifu_r.ifrw_info;
        addr->iba = (u_short)info;
        info = sc->acc_ifuba.ifu_r.ifrw_info;
        addr->iba = (u_short)info;
-       addr->iwc = -(IMP_MTU >> 1);
+       addr->iwc = -(IMPMTU >> 1);
 #ifdef LOOPBACK
        addr->ocsr |= OUT_BBACK;
 #endif
        addr->icsr = 
                IN_MRDY | ACC_IE | IN_WEN | ((info & 0x30000) >> 12) | ACC_GO;
 #ifdef LOOPBACK
        addr->ocsr |= OUT_BBACK;
 #endif
        addr->icsr = 
                IN_MRDY | ACC_IE | IN_WEN | ((info & 0x30000) >> 12) | ACC_GO;
-       splx(x);
        return (1);
        return (1);
-down:
-       ui->ui_alive = 0;
+}
+
+accinputreset(addr, unit)
+       register struct accdevice *addr;
+       register int unit;
+{
+       register int i;
+
+       addr->icsr = ACC_RESET; DELAY(5000);
+       addr->icsr = IN_MRDY | IN_WEN;          /* close the relay */
+       DELAY(10000);
+       /* YECH!!! */
+       for (i = 0; i < 500; i++) {
+               if ((addr->icsr & IN_HRDY) ||
+                   (addr->icsr & (IN_RMR | IN_IMPBSY)) == 0)
+                       return (1);
+               addr->icsr = IN_MRDY | IN_WEN; DELAY(10000);
+               /* keep turning IN_RMR off */
+       }
+       printf("acc%d: imp doesn't respond, icsr=%b\n", unit,
+               addr->icsr, ACC_INBITS);
        return (0);
 }
 
        return (0);
 }
 
@@ -229,7 +231,6 @@ accstart(dev)
        struct mbuf *m;
        u_short cmd;
 
        struct mbuf *m;
        u_short cmd;
 
-COUNT(ACCSTART);
        if (sc->acc_ic->ic_oactive)
                goto restart;
        
        if (sc->acc_ic->ic_oactive)
                goto restart;
        
@@ -268,21 +269,22 @@ restart:
  * Output interrupt handler.
  */
 accxint(unit)
  * Output interrupt handler.
  */
 accxint(unit)
+       int unit;
 {
        register struct acc_softc *sc = &acc_softc[unit];
        register struct accdevice *addr;
 
 {
        register struct acc_softc *sc = &acc_softc[unit];
        register struct accdevice *addr;
 
-COUNT(ACCXINT);
+       addr = (struct accdevice *)accinfo[unit]->ui_addr;
        if (sc->acc_ic->ic_oactive == 0) {
        if (sc->acc_ic->ic_oactive == 0) {
-               printf("acc%d: stray xmit interrupt\n", unit);
+               printf("acc%d: stray xmit interrupt, csr=%b\n", unit,
+                       addr->ocsr, ACC_OUTBITS);
                return;
        }
                return;
        }
-       addr = (struct accdevice *)accinfo[unit]->ui_addr;
        sc->acc_if->if_opackets++;
        sc->acc_ic->ic_oactive = 0;
        if (addr->ocsr & ACC_ERR) {
        sc->acc_if->if_opackets++;
        sc->acc_ic->ic_oactive = 0;
        if (addr->ocsr & ACC_ERR) {
-               printf("acc%d: output error, csr=%b\n", unit,
-                       addr->ocsr, ACC_OUTBITS);
+               printf("acc%d: output error, ocsr=%b, icsr=%b\n", unit,
+                       addr->ocsr, ACC_OUTBITS, addr->icsr, ACC_INBITS);
                sc->acc_if->if_oerrors++;
        }
        if (sc->acc_ifuba.ifu_xtofree) {
                sc->acc_if->if_oerrors++;
        }
        if (sc->acc_ifuba.ifu_xtofree) {
@@ -297,14 +299,14 @@ COUNT(ACCXINT);
  * Input interrupt handler
  */
 accrint(unit)
  * Input interrupt handler
  */
 accrint(unit)
+       int unit;
 {
        register struct acc_softc *sc = &acc_softc[unit];
        register struct accdevice *addr;
 {
        register struct acc_softc *sc = &acc_softc[unit];
        register struct accdevice *addr;
-       register struct ifqueue *inq;
        struct mbuf *m;
        int len, info;
 
        struct mbuf *m;
        int len, info;
 
-COUNT(ACCRINT);
+       addr = (struct accdevice *)accinfo[unit]->ui_addr;
        sc->acc_if->if_ipackets++;
 
        /*
        sc->acc_if->if_ipackets++;
 
        /*
@@ -312,7 +314,6 @@ COUNT(ACCRINT);
         */
        if (sc->acc_ifuba.ifu_flags & UBA_NEEDBDP)
                UBAPURGE(sc->acc_ifuba.ifu_uba, sc->acc_ifuba.ifu_r.ifrw_bdp);
         */
        if (sc->acc_ifuba.ifu_flags & UBA_NEEDBDP)
                UBAPURGE(sc->acc_ifuba.ifu_uba, sc->acc_ifuba.ifu_r.ifrw_bdp);
-       addr = (struct accdevice *)accinfo[unit]->ui_addr;
        if (addr->icsr & ACC_ERR) {
                printf("acc%d: input error, csr=%b\n", unit,
                    addr->icsr, ACC_INBITS);
        if (addr->icsr & ACC_ERR) {
                printf("acc%d: input error, csr=%b\n", unit,
                    addr->icsr, ACC_INBITS);
@@ -325,8 +326,8 @@ COUNT(ACCRINT);
                        sc->acc_flush = 0;
                goto setup;
        }
                        sc->acc_flush = 0;
                goto setup;
        }
-       len = IMP_MTU + (addr->iwc << 1);
-       if (len < 0 || len > IMP_MTU) {
+       len = IMPMTU + (addr->iwc << 1);
+       if (len < 0 || len > IMPMTU) {
                printf("acc%d: bad length=%d\n", len);
                sc->acc_if->if_ierrors++;
                goto setup;
                printf("acc%d: bad length=%d\n", len);
                sc->acc_if->if_ierrors++;
                goto setup;
@@ -346,10 +347,6 @@ COUNT(ACCRINT);
                        sc->acc_iq = m;
                goto setup;
        }
                        sc->acc_iq = m;
                goto setup;
        }
-#ifdef notdef
-       /* adjust message length for padding. */
-       m->m_len -= 2;
-#endif
        if (sc->acc_iq) {
                m_cat(sc->acc_iq, m);
                m = sc->acc_iq;
        if (sc->acc_iq) {
                m_cat(sc->acc_iq, m);
                m = sc->acc_iq;
@@ -363,7 +360,7 @@ setup:
         */
        info = sc->acc_ifuba.ifu_r.ifrw_info;
        addr->iba = (u_short)info;
         */
        info = sc->acc_ifuba.ifu_r.ifrw_info;
        addr->iba = (u_short)info;
-       addr->iwc = -(IMP_MTU >> 1);
+       addr->iwc = -(IMPMTU >> 1);
        addr->icsr =
                IN_MRDY | ACC_IE | IN_WEN | ((info & 0x30000) >> 12) | ACC_GO;
 }
        addr->icsr =
                IN_MRDY | ACC_IE | IN_WEN | ((info & 0x30000) >> 12) | ACC_GO;
 }