make 3com kludge conditional
[unix-history] / usr / src / sys / vax / if / if_acc.c
index 3eb9750..c22671f 100644 (file)
@@ -1,4 +1,4 @@
-/*     if_acc.c        4.9     82/03/13        */
+/*     if_acc.c        4.15    82/04/20        */
 
 #include "acc.h"
 #ifdef NACC > 0
 
 #include "acc.h"
 #ifdef NACC > 0
@@ -84,6 +84,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);
 }
 
@@ -111,7 +114,7 @@ COUNT(ACCATTACH);
        ip->ic_init = accinit;
        ip->ic_start = accstart;
 #ifdef notdef
        ip->ic_init = accinit;
        ip->ic_start = accstart;
 #ifdef notdef
-       sc->acc_ifuba.ifu_flags = UBA_NEEDBDP;
+       sc->acc_ifuba.ifu_flags = UBA_NEEDBDP | UBA_CANTWAIT;
 #endif
 }
 
 #endif
 }
 
@@ -147,7 +150,7 @@ 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) {
 
 COUNT(ACCINIT);
        if (unit >= NACC || (ui = accinfo[unit]) == 0 || ui->ui_alive == 0) {
@@ -163,7 +166,7 @@ COUNT(ACCINIT);
         * would asssume we handle it on input and output.
         */
        if (if_ubainit(&sc->acc_ifuba, ui->ui_ubanum, 0,
         * would asssume we handle it on input and output.
         */
        if (if_ubainit(&sc->acc_ifuba, ui->ui_ubanum, 0,
-            (int)btoc(IMP_MTU)) == 0) {
+            (int)btoc(IMPMTU)) == 0) {
                printf("acc%d: can't initialize\n", unit);
                goto down;
        }
                printf("acc%d: can't initialize\n", unit);
                goto down;
        }
@@ -173,49 +176,42 @@ 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->icsr = 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 */
        addr->icsr = IN_MRDY | IN_WEN;          /* close the relay */
-       DELAY(5000);
+       DELAY(10000);
        /* YECH!!! */
        /* YECH!!! */
-       x = 500;
-       while (x-- > 0) {
+       for (i = 0; i < 500; i++) {
                if ((addr->icsr & IN_HRDY) ||
                    (addr->icsr & (IN_RMR | IN_IMPBSY)) == 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;
+                       goto ok;
+               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);
+down:
+       ui->ui_alive = 0;
+       return (0);
 
 
+ok:
        /*
         * 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;
-       return (0);
 }
 
 /*
 }
 
 /*
@@ -325,8 +321,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;
@@ -359,7 +355,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;
 }