Latest fixes from Nesheim@cornell
[unix-history] / usr / src / sys / vax / if / if_acc.c
index 08b8fb5..8adb258 100644 (file)
@@ -1,30 +1,36 @@
-/*     if_acc.c        4.16    82/06/14        */
+/*
+ * Copyright (c) 1982 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)if_acc.c    6.5 (Berkeley) %G%
+ */
 
 #include "acc.h"
 
 #include "acc.h"
-#ifdef NACC > 0
+#if NACC > 0
 
 /*
  * ACC LH/DH ARPAnet IMP interface driver.
  */
 
 /*
  * ACC LH/DH ARPAnet IMP interface driver.
  */
+#include "../machine/pte.h"
+
+#include "param.h"
+#include "systm.h"
+#include "mbuf.h"
+#include "buf.h"
+#include "protosw.h"
+#include "socket.h"
+#include "vmmac.h"
 
 
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/mbuf.h"
-#include "../h/pte.h"
-#include "../h/buf.h"
-#include "../h/protosw.h"
-#include "../h/socket.h"
-#include "../h/ubareg.h"
-#include "../h/ubavar.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 "../netimp/if_imp.h"
+
+#include "../vax/cpu.h"
+#include "../vax/mtpr.h"
+#include "if_accreg.h"
+#include "if_uba.h"
+#include "../vaxuba/ubareg.h"
+#include "../vaxuba/ubavar.h"
 
 int     accprobe(), accattach(), accrint(), accxint();
 struct  uba_device *accinfo[NACC];
 
 int     accprobe(), accattach(), accrint(), accxint();
 struct  uba_device *accinfo[NACC];
@@ -61,10 +67,6 @@ struct       acc_softc {
        char    acc_flush;              /* flush remainder of message */
 } acc_softc[NACC];
 
        char    acc_flush;              /* flush remainder of message */
 } acc_softc[NACC];
 
-#define        NACCDEBUG       10000
-char   accdebug[NACCDEBUG];
-int    accdebugx;
-
 /*
  * Reset the IMP and cause a transmitter interrupt by
  * performing a null DMA.
 /*
  * Reset the IMP and cause a transmitter interrupt by
  * performing a null DMA.
@@ -75,7 +77,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);
@@ -85,13 +86,9 @@ COUNT(ACCPROBE);
        addr->ocsr = OUT_BBACK; DELAY(5000);
        addr->owc = 0;
        addr->ocsr = ACC_IE | ACC_GO; DELAY(5000);
        addr->ocsr = OUT_BBACK; DELAY(5000);
        addr->owc = 0;
        addr->ocsr = ACC_IE | ACC_GO; DELAY(5000);
-       addr->icsr = ACC_RESET; DELAY(5000);
-       addr->ocsr = ACC_RESET; DELAY(5000);
+       addr->ocsr = 0;
        if (cvec && cvec != 0x200)      /* transmit -> receive */
                cvec -= 4;
        if (cvec && cvec != 0x200)      /* transmit -> receive */
                cvec -= 4;
-#ifdef ECHACK
-       br = 0x16;
-#endif
        return (1);
 }
 
        return (1);
 }
 
@@ -110,8 +107,7 @@ accattach(ui)
                struct  impcb ifimp_impcb;
        } *ifimp;
 
                struct  impcb ifimp_impcb;
        } *ifimp;
 
-COUNT(ACCATTACH);
-       if ((ifimp = (struct ifimpcb *)impattach(ui)) == 0)
+       if ((ifimp = (struct ifimpcb *)impattach(ui, accreset)) == 0)
                panic("accattach");
        sc->acc_if = &ifimp->ifimp_if;
        ip = &ifimp->ifimp_impcb;
                panic("accattach");
        sc->acc_if = &ifimp->ifimp_if;
        ip = &ifimp->ifimp_impcb;
@@ -134,12 +130,12 @@ 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;
        printf(" acc%d", unit);
        sc = &acc_softc[unit];
        if (unit >= NACC || (ui = accinfo[unit]) == 0 || ui->ui_alive == 0 ||
            ui->ui_ubanum != uban)
                return;
        printf(" acc%d", unit);
        sc = &acc_softc[unit];
+       sc->acc_if->if_flags &= ~IFF_RUNNING;
        /* must go through IMP to allow it to set state */
        (*sc->acc_if->if_init)(unit);
 }
        /* must go through IMP to allow it to set state */
        (*sc->acc_if->if_init)(unit);
 }
@@ -156,9 +152,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 info, i;
+       int info;
 
 
-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);
@@ -177,6 +172,7 @@ COUNT(ACCINIT);
                ui->ui_alive = 0;
                return (0);
        }
                ui->ui_alive = 0;
                return (0);
        }
+       sc->acc_if->if_flags |= IFF_RUNNING;
        addr = (struct accdevice *)ui->ui_addr;
 
        /*
        addr = (struct accdevice *)ui->ui_addr;
 
        /*
@@ -197,7 +193,6 @@ COUNT(ACCINIT);
         * the NOOPs it throws at us).
         * Note: IMPMTU includes the leader.
         */
         * the NOOPs it throws at us).
         * Note: IMPMTU includes the leader.
         */
-       acctrace("init", addr->icsr);
        info = sc->acc_ifuba.ifu_r.ifrw_info;
        addr->iba = (u_short)info;
        addr->iwc = -(IMPMTU >> 1);
        info = sc->acc_ifuba.ifu_r.ifrw_info;
        addr->iba = (u_short)info;
        addr->iwc = -(IMPMTU >> 1);
@@ -243,8 +238,6 @@ accstart(dev)
        struct mbuf *m;
        u_short cmd;
 
        struct mbuf *m;
        u_short cmd;
 
-COUNT(ACCSTART);
-       acctrace("start", sc->acc_ic->ic_oactive);
        if (sc->acc_ic->ic_oactive)
                goto restart;
        
        if (sc->acc_ic->ic_oactive)
                goto restart;
        
@@ -255,7 +248,6 @@ COUNT(ACCSTART);
         */
        IF_DEQUEUE(&sc->acc_if->if_snd, m);
        if (m == 0) {
         */
        IF_DEQUEUE(&sc->acc_if->if_snd, m);
        if (m == 0) {
-               acctrace("q empty", 0);
                sc->acc_ic->ic_oactive = 0;
                return;
        }
                sc->acc_ic->ic_oactive = 0;
                return;
        }
@@ -284,23 +276,20 @@ 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);
-       acctrace("xint", sc->acc_ic->ic_oactive);
        addr = (struct accdevice *)accinfo[unit]->ui_addr;
        if (sc->acc_ic->ic_oactive == 0) {
                printf("acc%d: stray xmit interrupt, csr=%b\n", unit,
                        addr->ocsr, ACC_OUTBITS);
        addr = (struct accdevice *)accinfo[unit]->ui_addr;
        if (sc->acc_ic->ic_oactive == 0) {
                printf("acc%d: stray xmit interrupt, csr=%b\n", unit,
                        addr->ocsr, ACC_OUTBITS);
-               addr->ocsr  = ACC_RESET; 
                return;
        }
                return;
        }
-       acctrace("ocsr", addr->ocsr);
        sc->acc_if->if_opackets++;
        sc->acc_ic->ic_oactive = 0;
        sc->acc_if->if_opackets++;
        sc->acc_ic->ic_oactive = 0;
-       if (addr->ocsr & (ACC_ERR|OUT_TMR)) {
+       if (addr->ocsr & ACC_ERR) {
                printf("acc%d: output error, ocsr=%b, icsr=%b\n", unit,
                        addr->ocsr, ACC_OUTBITS, addr->icsr, ACC_INBITS);
                sc->acc_if->if_oerrors++;
                printf("acc%d: output error, ocsr=%b, icsr=%b\n", unit,
                        addr->ocsr, ACC_OUTBITS, addr->icsr, ACC_INBITS);
                sc->acc_if->if_oerrors++;
@@ -317,19 +306,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;
        struct mbuf *m;
        int len, info;
 
 {
        register struct acc_softc *sc = &acc_softc[unit];
        register struct accdevice *addr;
        struct mbuf *m;
        int len, info;
 
-COUNT(ACCRINT);
        addr = (struct accdevice *)accinfo[unit]->ui_addr;
        addr = (struct accdevice *)accinfo[unit]->ui_addr;
-       if ((addr->icsr & ACC_RDY) == 0) {
-               printf("acc%d: stray input interrupt\n", unit);
-               accinputreset(addr, unit);
-               goto setup;
-       }
        sc->acc_if->if_ipackets++;
 
        /*
        sc->acc_if->if_ipackets++;
 
        /*
@@ -337,24 +321,19 @@ 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);
-       acctrace("rint", addr->icsr);
-       if (addr->icsr & (ACC_ERR|IN_RMR)) {
-               printf("acc%d: input error, icsr=%b, ocsr=%b\n", unit,
-                   addr->icsr, ACC_INBITS, addr->ocsr, ACC_OUTBITS);
+       if (addr->icsr & ACC_ERR) {
+               printf("acc%d: input error, csr=%b\n", unit,
+                   addr->icsr, ACC_INBITS);
                sc->acc_if->if_ierrors++;
                sc->acc_if->if_ierrors++;
-               if (addr->icsr & IN_RMR)
-                       accinputreset(addr, unit);
                sc->acc_flush = 1;
        }
 
                sc->acc_flush = 1;
        }
 
-       acctrace("flush", sc->acc_flush);
        if (sc->acc_flush) {
                if (addr->icsr & IN_EOM)
                        sc->acc_flush = 0;
                goto setup;
        }
        len = IMPMTU + (addr->iwc << 1);
        if (sc->acc_flush) {
                if (addr->icsr & IN_EOM)
                        sc->acc_flush = 0;
                goto setup;
        }
        len = IMPMTU + (addr->iwc << 1);
-       acctrace("length", len);
        if (len < 0 || len > IMPMTU) {
                printf("acc%d: bad length=%d\n", len);
                sc->acc_if->if_ierrors++;
        if (len < 0 || len > IMPMTU) {
                printf("acc%d: bad length=%d\n", len);
                sc->acc_if->if_ierrors++;
@@ -380,7 +359,6 @@ COUNT(ACCRINT);
                m = sc->acc_iq;
                sc->acc_iq = 0;
        }
                m = sc->acc_iq;
                sc->acc_iq = 0;
        }
-       acctrace("impinput", 0);
        impinput(unit, m);
 
 setup:
        impinput(unit, m);
 
 setup:
@@ -393,27 +371,4 @@ setup:
        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;
 }
-
-int    accprintf = 0;
-
-acctrace(cmd, value)
-       char *cmd;
-       int value;
-{
-       register int i;
-       register char *p = (char *)&value;
-
-       if (accprintf)
-               printf("%s: %x", cmd, value);
-       do {
-               if (accdebugx >= NACCDEBUG)
-                       accdebugx = 0;
-               accdebug[accdebugx++] = *cmd;
-       } while (*cmd++);
-       for (i = 0; i < sizeof (int); i++) {
-               if (accdebugx >= NACCDEBUG)
-                       accdebugx = 0;
-               accdebug[accdebugx++] = *p++;
-       }
-}
 #endif
 #endif