This commit was manufactured by cvs2svn to create tag 'FreeBSD-release/1.1'.
[unix-history] / sys / i386 / isa / if_ed.c
index eccee0f..ffda077 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Device driver for National Semiconductor DS8390 based ethernet
+ * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
  *   adapters. By David Greenman, 29-April-1993
  *
  * Copyright (C) 1993, David Greenman. This software may be used, modified,
  *   adapters. By David Greenman, 29-April-1993
  *
  * Copyright (C) 1993, David Greenman. This software may be used, modified,
@@ -9,70 +9,16 @@
  *   of this software, nor does the author assume any responsibility
  *   for damages incurred with its use.
  *
  *   of this software, nor does the author assume any responsibility
  *   for damages incurred with its use.
  *
- * Currently supports the Western Digital/SMC 8003 and 8013 series
- *   and the 3Com 3c503
+ * Currently supports the Western Digital/SMC 8003 and 8013 series,
+ *   the SMC Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000,
+ *   and a variety of similar clones.
+ *
  */
 
 /*
  */
 
 /*
- * $Id: if_ed.c,v 1.29 93/09/12 04:43:31 davidg Exp Locker: davidg $
+ * $Id: if_ed.c,v 1.33.2.1 1994/03/07 02:02:34 rgrimes Exp $
  */
 
  */
 
-/*
- * Modification history
- *
- * Revision 1.29  93/09/12  04:43:31  davidg
- * cleaned-up probe routine to make it easier to add future board types
- * 
- * Revision 1.28  93/09/11  19:17:56  davidg
- * rewrote interrupt code; leaner and meaner.
- * 
- * Revision 1.27  93/09/10  19:15:09  davidg
- * changed probe/attach so that the type code is printed if the board
- * type isn't unknown
- * 
- * Revision 1.26  93/09/09  02:12:08  davidg
- * cleaned up header comments a little
- * 
- * Revision 1.25  93/09/08  23:04:25  davidg
- * fixed problem where 3c503 boards lock up if the cable is 
- * disconnected at boot time. Added printing of irq number if
- * the kernel config and board don't match
- * 
- * Revision 1.24  93/09/07  12:08:36  davidg
- * ED_FLAGS_NO_DOUBLE_BUFFERING was being checked against wrong variable
- * 
- * Revision 1.23  93/09/07  10:32:53  davidg
- * split wd and 3Com probe code into seperate routines
- * 
- * Revision 1.22  93/09/06  20:28:22  davidg
- * change references to LAAR to use shadow/prototype rather than the
- * real thing because 8013EBT asic regs are write-only.
- * 
- * Revision 1.21  93/08/25  20:38:02  davidg
- * added recognition for WD8013WC (10BaseT) card type
- * 
- * Revision 1.20  93/08/14  20:07:35  davidg
- * one more stab at getting the 8013EBT working
- * 
- * Revision 1.19  93/08/02  02:57:53  davidg
- * Fixed problem where some rev 8013EBT boards want the DCR_LS flag
- * set in order to work in 16bit mode. Also improves performance on
- * all types of boards.
- *
- *...(part of log nuked for brevity)
- * 
- * Revision 1.12  93/07/07  06:27:44  davidg
- * moved call to bpfattach to after this drivers attach printf -
- * improves readability of startup messages.
- * 
- *...(part of log nuked for brevity)
- * 
- * Revision 1.1  93/06/14  22:21:24  davidg
- * Beta release of device driver for SMC/WD80x3 and 3C503 ethernet boards.
- * 
- * 
- */
 #include "ed.h"
 #if    NED > 0
 /* bpfilter included here in case it is needed in future net includes */
 #include "ed.h"
 #if    NED > 0
 /* bpfilter included here in case it is needed in future net includes */
@@ -89,7 +35,6 @@
 #include "net/if.h"
 #include "net/if_dl.h"
 #include "net/if_types.h"
 #include "net/if.h"
 #include "net/if_dl.h"
 #include "net/if_types.h"
-#include "net/netisr.h"
 
 #ifdef INET
 #include "netinet/in.h"
 
 #ifdef INET
 #include "netinet/in.h"
@@ -139,39 +84,55 @@ struct     ed_softc {
  *     being write-only. It's sort of a prototype/shadow of the real thing.
  */
        u_char  wd_laar_proto;
  *     being write-only. It's sort of a prototype/shadow of the real thing.
  */
        u_char  wd_laar_proto;
-
-       u_char  isa16bit;       /* width of access to card mem 0=8 or 1=16 */
-
-       caddr_t smem_start;     /* shared memory start address */
-       caddr_t smem_end;       /* shared memory end address */
-       u_long  smem_size;      /* total shared memory size */
-       caddr_t smem_ring;      /* start of RX ring-buffer (in smem) */
+       u_char  isa16bit;       /* width of access to card 0=8 or 1=16 */
+       int     is790;          /* set by the probe code if the card is 790 based */
 
        caddr_t bpf;            /* BPF "magic cookie" */
 
        caddr_t bpf;            /* BPF "magic cookie" */
+       caddr_t mem_start;      /* NIC memory start address */
+       caddr_t mem_end;        /* NIC memory end address */
+       u_long  mem_size;       /* total NIC memory size */
+       caddr_t mem_ring;       /* start of RX ring-buffer (in NIC mem) */
 
 
+       u_char  mem_shared;     /* NIC memory is shared with host */
        u_char  xmit_busy;      /* transmitter is busy */
        u_char  xmit_busy;      /* transmitter is busy */
-       u_char  data_buffered;  /* data has been buffered in interface memory */
-       u_char  txb_cnt;        /* Number of transmit buffers */
-       u_char  txb_next;       /* Pointer to next buffer ready to xmit */
-       u_short txb_next_len;   /* next xmit buffer length */
-       u_char  tx_page_start;  /* first page of TX buffer area */
+       u_char  txb_cnt;        /* number of transmit buffers */
+       u_char  txb_inuse;      /* number of TX buffers currently in-use*/
 
 
+       u_char  txb_new;        /* pointer to where new buffer will be added */
+       u_char  txb_next_tx;    /* pointer to next buffer ready to xmit */
+       u_short txb_len[8];     /* buffered xmit buffer lengths */
+       u_char  tx_page_start;  /* first page of TX buffer area */
        u_char  rec_page_start; /* first page of RX ring-buffer */
        u_char  rec_page_stop;  /* last page of RX ring-buffer */
        u_char  next_packet;    /* pointer to next unread RX packet */
 } ed_softc[NED];
 
        u_char  rec_page_start; /* first page of RX ring-buffer */
        u_char  rec_page_stop;  /* last page of RX ring-buffer */
        u_char  next_packet;    /* pointer to next unread RX packet */
 } ed_softc[NED];
 
-int    ed_attach(), ed_init(), edintr(), ed_ioctl(), ed_probe(),
-       ed_start(), ed_reset(), ed_watchdog();
+int    ed_attach(struct isa_device *);
+void   ed_init(int);
+void   edintr(int);
+int    ed_ioctl(struct ifnet *, int, caddr_t);
+int    ed_probe(struct isa_device *);
+void   ed_start(struct ifnet *);
+void   ed_reset(int, int);
+void   ed_watchdog(int);
 
 
-static void ed_stop();
+static void ed_get_packet(struct ed_softc *, char *, int /*u_short*/);
+static void ed_stop(int);
 
 static inline void ed_rint();
 static inline void ed_xmit();
 static inline char *ed_ring_copy();
 
 
 static inline void ed_rint();
 static inline void ed_xmit();
 static inline char *ed_ring_copy();
 
+void ed_pio_readmem(), ed_pio_writemem();
+u_short ed_pio_write_mbufs();
+
 extern int ether_output();
 
 extern int ether_output();
 
+struct trailer_header {
+       u_short ether_type;
+       u_short ether_residual;
+};
+
 struct isa_driver eddriver = {
        ed_probe,
        ed_attach,
 struct isa_driver eddriver = {
        ed_probe,
        ed_attach,
@@ -192,6 +153,19 @@ static unsigned short ed_intr_mask[] = {
        IRQ4
 };
        
        IRQ4
 };
        
+/*
+ * Interrupt conversion table for 585/790 Combo
+ */
+static unsigned short ed_790_intr_mask[] = {
+       0,
+       IRQ9,
+       IRQ3,
+       IRQ5,
+       IRQ7,
+       IRQ10,
+       IRQ11,
+       IRQ15
+};
 #define        ETHER_MIN_LEN   64
 #define ETHER_MAX_LEN  1518
 #define        ETHER_ADDR_LEN  6
 #define        ETHER_MIN_LEN   64
 #define ETHER_MAX_LEN  1518
 #define        ETHER_ADDR_LEN  6
@@ -218,8 +192,50 @@ ed_probe(isa_dev)
 
        if (nports = ed_probe_3Com(isa_dev))
                return (nports);
 
        if (nports = ed_probe_3Com(isa_dev))
                return (nports);
+
+       if (nports = ed_probe_Novell(isa_dev))
+               return (nports);
+
+       return(0);
 }
 
 }
 
+/*
+ * Generic probe routine for testing for the existance of a DS8390.
+ *     Must be called after the NIC has just been reset. This routine
+ *     works by looking at certain register values that are gauranteed
+ *     to be initialized a certain way after power-up or reset. Seems
+ *     not to currently work on the 83C690.
+ *
+ * Specifically:
+ *
+ *     Register                        reset bits      set bits
+ *     Command Register (CR)           TXP, STA        RD2, STP
+ *     Interrupt Status (ISR)                          RST
+ *     Interrupt Mask (IMR)            All bits
+ *     Data Control (DCR)                              LAS
+ *     Transmit Config. (TCR)          LB1, LB0
+ *
+ * We only look at the CR and ISR registers, however, because looking at
+ *     the others would require changing register pages (which would be
+ *     intrusive if this isn't an 8390).
+ *
+ * Return 1 if 8390 was found, 0 if not. 
+ */
+
+int
+ed_probe_generic8390(sc)
+       struct ed_softc *sc;
+{
+       if ((inb(sc->nic_addr + ED_P0_CR) &
+           (ED_CR_RD2|ED_CR_TXP|ED_CR_STA|ED_CR_STP)) !=
+           (ED_CR_RD2|ED_CR_STP))
+               return (0);
+       if ((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RST) != ED_ISR_RST)
+               return (0);
+
+       return(1);
+}
+       
 /*
  * Probe and vendor-specific initialization routine for SMC/WD80x3 boards
  */
 /*
  * Probe and vendor-specific initialization routine for SMC/WD80x3 boards
  */
@@ -234,58 +250,81 @@ ed_probe_WD80x3(isa_dev)
 
        sc->asic_addr = isa_dev->id_iobase;
        sc->nic_addr = sc->asic_addr + ED_WD_NIC_OFFSET;
 
        sc->asic_addr = isa_dev->id_iobase;
        sc->nic_addr = sc->asic_addr + ED_WD_NIC_OFFSET;
+       sc->is790 = 0;
 
 
+#ifdef TOSH_ETHER
+       outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_POW);
+       DELAY(10000);
+#endif
        /*
         * Attempt to do a checksum over the station address PROM.
         *      If it fails, it's probably not a SMC/WD board. There
         *      is a problem with this, though: some clone WD boards
         *      don't pass the checksum test. Danpex boards for one.
        /*
         * Attempt to do a checksum over the station address PROM.
         *      If it fails, it's probably not a SMC/WD board. There
         *      is a problem with this, though: some clone WD boards
         *      don't pass the checksum test. Danpex boards for one.
-        *      XXX - We need to do additional checking for this case.
         */
        for (sum = 0, i = 0; i < 8; ++i)
                sum += inb(sc->asic_addr + ED_WD_PROM + i);
         */
        for (sum = 0, i = 0; i < 8; ++i)
                sum += inb(sc->asic_addr + ED_WD_PROM + i);
-       
-       if (sum != ED_WD_ROM_CHECKSUM_TOTAL)
-               return(0);
-       
-       sc->vendor = ED_VENDOR_WD_SMC;
-       sc->type = inb(sc->asic_addr + ED_WD_CARD_ID);
+
+       if (sum != ED_WD_ROM_CHECKSUM_TOTAL) {
+               /*
+                * Checksum is invalid. This often happens with cheap
+                *      WD8003E clones.  In this case, the checksum byte
+                *      (the eighth byte) seems to always be zero.
+                */
+               if (inb(sc->asic_addr + ED_WD_CARD_ID) != ED_TYPE_WD8003E ||
+                   inb(sc->asic_addr + ED_WD_PROM + 7) != 0)
+                       return(0);
+       }
 
        /* reset card to force it into a known state. */
 
        /* reset card to force it into a known state. */
+#ifdef TOSH_ETHER
+       outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_RST | ED_WD_MSR_POW);
+#else
        outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_RST);
        outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_RST);
+#endif
        DELAY(100);
        outb(sc->asic_addr + ED_WD_MSR, inb(sc->asic_addr + ED_WD_MSR) & ~ED_WD_MSR_RST);
        /* wait in the case this card is reading it's EEROM */
        DELAY(5000);
 
        DELAY(100);
        outb(sc->asic_addr + ED_WD_MSR, inb(sc->asic_addr + ED_WD_MSR) & ~ED_WD_MSR_RST);
        /* wait in the case this card is reading it's EEROM */
        DELAY(5000);
 
+       sc->vendor = ED_VENDOR_WD_SMC;
+       sc->type = inb(sc->asic_addr + ED_WD_CARD_ID);
+
        /*
         * Set initial values for width/size.
         */
        /*
         * Set initial values for width/size.
         */
+       memsize = 8192;
+       isa16bit = 0;
        switch (sc->type) {
        case ED_TYPE_WD8003S:
                sc->type_str = "WD8003S";
        switch (sc->type) {
        case ED_TYPE_WD8003S:
                sc->type_str = "WD8003S";
-               memsize = 8192;
-               isa16bit = 0;
                break;
        case ED_TYPE_WD8003E:
                sc->type_str = "WD8003E";
                break;
        case ED_TYPE_WD8003E:
                sc->type_str = "WD8003E";
-               memsize = 8192;
-               isa16bit = 0;
+               break;
+       case ED_TYPE_WD8003EB:
+               sc->type_str = "WD8003EB";
+               break;
+       case ED_TYPE_WD8003W:
+               sc->type_str = "WD8003W";
                break;
        case ED_TYPE_WD8013EBT:
                sc->type_str = "WD8013EBT";
                memsize = 16384;
                isa16bit = 1;
                break;
                break;
        case ED_TYPE_WD8013EBT:
                sc->type_str = "WD8013EBT";
                memsize = 16384;
                isa16bit = 1;
                break;
+       case ED_TYPE_WD8013W:
+               sc->type_str = "WD8013W";
+               memsize = 16384;
+               isa16bit = 1;
+               break;
        case ED_TYPE_WD8013EP:          /* also WD8003EP */
                if (inb(sc->asic_addr + ED_WD_ICR)
        case ED_TYPE_WD8013EP:          /* also WD8003EP */
                if (inb(sc->asic_addr + ED_WD_ICR)
-                       & ED_WD_ICR_16BIT) {
+                   & ED_WD_ICR_16BIT) {
                        isa16bit = 1;
                        memsize = 16384;
                        sc->type_str = "WD8013EP";
                } else {
                        isa16bit = 1;
                        memsize = 16384;
                        sc->type_str = "WD8013EP";
                } else {
-                       isa16bit = 0;
-                       memsize = 8192;
                        sc->type_str = "WD8003EP";
                }
                break;
                        sc->type_str = "WD8003EP";
                }
                break;
@@ -304,10 +343,32 @@ ed_probe_WD80x3(isa_dev)
                memsize = 16384;
                isa16bit = 1;
                break;
                memsize = 16384;
                isa16bit = 1;
                break;
+       case ED_TYPE_SMC8216C:
+               sc->type_str = "SMC8216/SMC8216C";
+               memsize = 16384;
+               isa16bit = 1;
+               sc->is790 = 1;
+               break;
+       case ED_TYPE_SMC8216T:
+               sc->type_str = "SMC8216T";
+               memsize = 16384;
+               isa16bit = 1;
+               sc->is790 = 1;
+               break;
+#ifdef TOSH_ETHER
+       case ED_TYPE_TOSHIBA1:
+               sc->type_str = "Toshiba1";
+               memsize = 32768;
+               isa16bit = 1;
+               break;
+       case ED_TYPE_TOSHIBA4:
+               sc->type_str = "Toshiba4";
+               memsize = 32768;
+               isa16bit = 1;
+               break;
+#endif
        default:
                sc->type_str = "";
        default:
                sc->type_str = "";
-               memsize = 8192;
-               isa16bit = 0;
                break;
        }
        /*
                break;
        }
        /*
@@ -315,19 +376,17 @@ ed_probe_WD80x3(isa_dev)
         *      found in the ICR.
         */
        if (isa16bit && (sc->type != ED_TYPE_WD8013EBT)
         *      found in the ICR.
         */
        if (isa16bit && (sc->type != ED_TYPE_WD8013EBT)
-               && ((inb(sc->asic_addr + ED_WD_ICR) & ED_WD_ICR_16BIT) == 0)) {
+#ifdef TOSH_ETHER
+           && (sc->type != ED_TYPE_TOSHIBA1) && (sc->type != ED_TYPE_TOSHIBA4)
+#endif
+           && ((inb(sc->asic_addr + ED_WD_ICR) & ED_WD_ICR_16BIT) == 0)) {
                isa16bit = 0;
                memsize = 8192;
        }
                isa16bit = 0;
                memsize = 8192;
        }
-#if 0 /* This has caused more problems than it's worth */
-       if (inb(sc->asic_addr + ED_WD_ICR) & ED_WD_ICR_MSZ) {
-               memsize = 32768;
-       }
-#endif
 
 #if ED_DEBUG
 
 #if ED_DEBUG
-       printf("type=%s isa16bit=%d memsize=%d id_msize=%d\n",
-               sc->type_str,isa16bit,memsize,isa_dev->id_msize);
+       printf("type = %x type_str=%s isa16bit=%d memsize=%d id_msize=%d\n",
+               sc->type,sc->type_str,isa16bit,memsize,isa_dev->id_msize);
        for (i=0; i<8; i++)
                printf("%x -> %x\n", i, inb(sc->asic_addr + i));
 #endif
        for (i=0; i<8; i++)
                printf("%x -> %x\n", i, inb(sc->asic_addr + i));
 #endif
@@ -350,19 +409,20 @@ ed_probe_WD80x3(isa_dev)
         *      XXX - we could also check the IO address register. But why
         *              bother...if we get past this, it *has* to be correct.
         */
         *      XXX - we could also check the IO address register. But why
         *              bother...if we get past this, it *has* to be correct.
         */
-       if (sc->type & ED_WD_SOFTCONFIG) {
+       if ((sc->type & ED_WD_SOFTCONFIG) && (!sc->is790)) {
                /*
                 * Assemble together the encoded interrupt number.
                 */
                iptr = (inb(isa_dev->id_iobase + ED_WD_ICR) & ED_WD_ICR_IR2) |
                /*
                 * Assemble together the encoded interrupt number.
                 */
                iptr = (inb(isa_dev->id_iobase + ED_WD_ICR) & ED_WD_ICR_IR2) |
-                       ((inb(isa_dev->id_iobase + ED_WD_IRR) &
-                               (ED_WD_IRR_IR0 | ED_WD_IRR_IR1)) >> 5);
+                           ((inb(isa_dev->id_iobase + ED_WD_IRR) &
+                           (ED_WD_IRR_IR0 | ED_WD_IRR_IR1)) >> 5);
                /*
                 * Translate it using translation table, and check for correctness.
                 */
                if (ed_intr_mask[iptr] != isa_dev->id_irq) {
                        printf("ed%d: kernel configured irq %d doesn't match board configured irq %d\n",
                /*
                 * Translate it using translation table, and check for correctness.
                 */
                if (ed_intr_mask[iptr] != isa_dev->id_irq) {
                        printf("ed%d: kernel configured irq %d doesn't match board configured irq %d\n",
-                               isa_dev->id_unit, ffs(isa_dev->id_irq) - 1, ffs(ed_intr_mask[iptr]) - 1);
+                           isa_dev->id_unit, ffs(isa_dev->id_irq) - 1,
+                           ffs(ed_intr_mask[iptr]) - 1);
                        return(0);
                }
                /*
                        return(0);
                }
                /*
@@ -371,24 +431,63 @@ ed_probe_WD80x3(isa_dev)
                outb(isa_dev->id_iobase + ED_WD_IRR,
                        inb(isa_dev->id_iobase + ED_WD_IRR) | ED_WD_IRR_IEN);
        }
                outb(isa_dev->id_iobase + ED_WD_IRR,
                        inb(isa_dev->id_iobase + ED_WD_IRR) | ED_WD_IRR_IEN);
        }
+       if (sc->is790) {
+               outb(isa_dev->id_iobase + ED_WD790_HWR,
+                   inb(isa_dev->id_iobase + ED_WD790_HWR) | ED_WD790_HWR_SWH);
+               iptr = (((inb(isa_dev->id_iobase + ED_WD790_GCR) & ED_WD790_GCR_IR2) >> 4) |
+                           (inb(isa_dev->id_iobase + ED_WD790_GCR) &
+                           (ED_WD790_GCR_IR1|ED_WD790_GCR_IR0)) >> 2);
+               outb(isa_dev->id_iobase + ED_WD790_HWR,
+                   inb(isa_dev->id_iobase + ED_WD790_HWR) & ~ED_WD790_HWR_SWH);
+
+               if (ed_790_intr_mask[iptr] != isa_dev->id_irq) {
+                       printf("ed%d: kernel configured irq %d doesn't match board configured irq %d %d\n",
+                           isa_dev->id_unit, ffs(isa_dev->id_irq) - 1,
+                           ffs(ed_790_intr_mask[iptr]) - 1, iptr);
+                       return 0;
+               }
+               /*
+                * Enable interrupts.
+                */
+               outb(isa_dev->id_iobase + ED_WD790_ICR,
+                   inb(isa_dev->id_iobase + ED_WD790_ICR) | ED_WD790_ICR_EIL);
+       }
 
        sc->isa16bit = isa16bit;
 
        sc->isa16bit = isa16bit;
-       sc->smem_start = (caddr_t)isa_dev->id_maddr;
+
+#ifdef notyet /* XXX - I'm not sure if PIO mode is even possible on WD/SMC boards */
+       /*
+        * The following allows the WD/SMC boards to be used in Programmed I/O
+        *      mode - without mapping the NIC memory shared. ...Not the prefered
+        *      way, but it might be the only way.
+        */
+       if (isa_dev->id_flags & ED_FLAGS_FORCE_PIO) {
+               sc->mem_shared = 0;
+               isa_dev->id_maddr = 0;
+       } else {
+               sc->mem_shared = 1;
+       }
+#else
+       sc->mem_shared = 1;
+#endif
+       isa_dev->id_msize = memsize;
+
+       sc->mem_start = (caddr_t)isa_dev->id_maddr;
 
        /*
         * allocate one xmit buffer if < 16k, two buffers otherwise
         */
 
        /*
         * allocate one xmit buffer if < 16k, two buffers otherwise
         */
-       if ((memsize < 16384) || (isa_dev->id_flags & ED_FLAGS_NO_DOUBLE_BUFFERING)) {
-               sc->smem_ring = sc->smem_start + (ED_PAGE_SIZE * ED_TXBUF_SIZE);
+       if ((memsize < 16384) || (isa_dev->id_flags & ED_FLAGS_NO_MULTI_BUFFERING)) {
+               sc->mem_ring = sc->mem_start + (ED_PAGE_SIZE * ED_TXBUF_SIZE);
                sc->txb_cnt = 1;
                sc->rec_page_start = ED_TXBUF_SIZE;
        } else {
                sc->txb_cnt = 1;
                sc->rec_page_start = ED_TXBUF_SIZE;
        } else {
-               sc->smem_ring = sc->smem_start + (ED_PAGE_SIZE * ED_TXBUF_SIZE * 2);
+               sc->mem_ring = sc->mem_start + (ED_PAGE_SIZE * ED_TXBUF_SIZE * 2);
                sc->txb_cnt = 2;
                sc->rec_page_start = ED_TXBUF_SIZE * 2;
        }
                sc->txb_cnt = 2;
                sc->rec_page_start = ED_TXBUF_SIZE * 2;
        }
-       sc->smem_size = memsize;
-       sc->smem_end = sc->smem_start + memsize;
+       sc->mem_size = memsize;
+       sc->mem_end = sc->mem_start + memsize;
        sc->rec_page_stop = memsize / ED_PAGE_SIZE;
        sc->tx_page_start = ED_WD_PAGE_OFFSET;
 
        sc->rec_page_stop = memsize / ED_PAGE_SIZE;
        sc->tx_page_start = ED_WD_PAGE_OFFSET;
 
@@ -398,65 +497,97 @@ ed_probe_WD80x3(isa_dev)
        for (i = 0; i < ETHER_ADDR_LEN; ++i)
                sc->arpcom.ac_enaddr[i] = inb(sc->asic_addr + ED_WD_PROM + i);
 
        for (i = 0; i < ETHER_ADDR_LEN; ++i)
                sc->arpcom.ac_enaddr[i] = inb(sc->asic_addr + ED_WD_PROM + i);
 
-       /*
-        * Set address and enable interface shared memory.
-        */
-        outb(sc->asic_addr + ED_WD_MSR, ((kvtop(sc->smem_start) >> 13) &
-               ED_WD_MSR_ADDR) | ED_WD_MSR_MENB);
+       if (sc->mem_shared) {
+               /*
+                * Set address and enable interface shared memory.
+                */
+               if(!sc->is790) {
+#ifdef TOSH_ETHER
+                       outb(sc->asic_addr + ED_WD_MSR + 1, ((kvtop(sc->mem_start) >> 8) & 0xe0) | 4);
+                       outb(sc->asic_addr + ED_WD_MSR + 2, ((kvtop(sc->mem_start) >> 16) & 0x0f));
+                       outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_MENB | ED_WD_MSR_POW);
+
+#else
+                       outb(sc->asic_addr + ED_WD_MSR, ((kvtop(sc->mem_start) >> 13) &
+                               ED_WD_MSR_ADDR) | ED_WD_MSR_MENB);
+#endif
+               } else {
+                       outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_MENB);
+                       outb(sc->asic_addr + 0x04, (inb(sc->asic_addr + 0x04) | 0x80));
+                       outb(sc->asic_addr + 0x0b, ((kvtop(sc->mem_start) >> 13) & 0x0f) |
+                            ((kvtop(sc->mem_start) >> 11) & 0x40) | 
+                            (inb(sc->asic_addr + 0x0b) & 0xb0));
+                       outb(sc->asic_addr + 0x04, (inb(sc->asic_addr + 0x04) & ~0x80));
+               }
 
 
-       /*
-        * Set upper address bits and 8/16 bit access to shared memory
-        */
-       if ((sc->type & ED_WD_SOFTCONFIG) || (sc->type == ED_TYPE_WD8013EBT)) {
+               /*
+                * Set upper address bits and 8/16 bit access to shared memory
+                */
                if (isa16bit) {
                if (isa16bit) {
-                       outb(sc->asic_addr + ED_WD_LAAR, (sc->wd_laar_proto =
-                               ED_WD_LAAR_L16EN | ED_WD_LAAR_M16EN |
-                               ((kvtop(sc->smem_start) >> 19) & ED_WD_LAAR_ADDRHI)));
-               } else {
-                       outb(sc->asic_addr + ED_WD_LAAR, (sc->wd_laar_proto =
-                       ((kvtop(sc->smem_start) >> 19) & ED_WD_LAAR_ADDRHI)));
+                       if (sc->is790) {
+                               sc->wd_laar_proto = inb(sc->asic_addr + ED_WD_LAAR);
+                               outb(sc->asic_addr + ED_WD_LAAR, ED_WD_LAAR_M16EN);
+                               (void) inb(0x84);
+                       } else {
+                               outb(sc->asic_addr + ED_WD_LAAR, (sc->wd_laar_proto =
+                                    ED_WD_LAAR_L16EN | ED_WD_LAAR_M16EN |
+                                    ((kvtop(sc->mem_start) >> 19) & ED_WD_LAAR_ADDRHI)));
+                       }
+               } else  {
+                       if ((sc->type & ED_WD_SOFTCONFIG) ||
+#ifdef TOSH_ETHER
+                           (sc->type == ED_TYPE_TOSHIBA1) || (sc->type == ED_TYPE_TOSHIBA4) ||
+#endif
+                           (sc->type == ED_TYPE_WD8013EBT) && (!sc->is790)) {
+                               outb(sc->asic_addr + ED_WD_LAAR, (sc->wd_laar_proto =
+                                    ((kvtop(sc->mem_start) >> 19) & ED_WD_LAAR_ADDRHI)));
+                       }
                }
                }
-       }
 
 
-       /*
-        * Now zero memory and verify that it is clear
-        */
-       bzero(sc->smem_start, memsize);
+               /*
+                * Now zero memory and verify that it is clear
+                */
+               bzero(sc->mem_start, memsize);
 
 
-       for (i = 0; i < memsize; ++i)
-               if (sc->smem_start[i]) {
-                       printf("ed%d: failed to clear shared memory at %x - check configuration\n",
-                               isa_dev->id_unit, sc->smem_start + i);
+               for (i = 0; i < memsize; ++i)
+                       if (sc->mem_start[i]) {
+                               printf("ed%d: failed to clear shared memory at %x - check configuration\n",
+                                       isa_dev->id_unit, kvtop(sc->mem_start + i));
 
 
-                       /*
-                        * Disable 16 bit access to shared memory
-                        */
-                       if (isa16bit)
-                               outb(sc->asic_addr + ED_WD_LAAR, (sc->wd_laar_proto &=
-                                       ~ED_WD_LAAR_M16EN));
+                               /*
+                                * Disable 16 bit access to shared memory
+                                */
+                               if (isa16bit) {
+                                       outb(sc->asic_addr + ED_WD_LAAR, (sc->wd_laar_proto &=
+                                            ~ED_WD_LAAR_M16EN));
+                                       (void) inb(0x84);
+                               }
 
 
-                       return(0);
-               }
+                               return(0);
+                       }
        
        
-       /*
-        * Disable 16bit access to shared memory - we leave it disabled so
-        *      that 1) machines reboot properly when the board is set
-        *      16 bit mode and there are conflicting 8bit devices/ROMS
-        *      in the same 128k address space as this boards shared
-        *      memory. and 2) so that other 8 bit devices with shared
-        *      memory can be used in this 128k region, too.
-        */
-       if (isa16bit)
-               outb(sc->asic_addr + ED_WD_LAAR, (sc->wd_laar_proto &=
-                       ~ED_WD_LAAR_M16EN));
+               /*
+                * Disable 16bit access to shared memory - we leave it disabled so
+                *      that 1) machines reboot properly when the board is set
+                *      16 bit mode and there are conflicting 8bit devices/ROMS
+                *      in the same 128k address space as this boards shared
+                *      memory. and 2) so that other 8 bit devices with shared
+                *      memory can be used in this 128k region, too.
+                */
+               if (isa16bit) {
+                       outb(sc->asic_addr + ED_WD_LAAR, (sc->wd_laar_proto &=
+                            ~ED_WD_LAAR_M16EN));
+                       (void) inb(0x84);
+               }
+       }
 
 
-       isa_dev->id_msize = memsize;
        return (ED_WD_IO_PORTS);
 }
 
 /*
  * Probe and vendor-specific initialization routine for 3Com 3c503 boards
  */
        return (ED_WD_IO_PORTS);
 }
 
 /*
  * Probe and vendor-specific initialization routine for 3Com 3c503 boards
  */
+int
 ed_probe_3Com(isa_dev)
        struct isa_device *isa_dev;
 {
 ed_probe_3Com(isa_dev)
        struct isa_device *isa_dev;
 {
@@ -534,10 +665,6 @@ ed_probe_3Com(isa_dev)
                return(0);
        }
 
                return(0);
        }
 
-       sc->vendor = ED_VENDOR_3COM;
-       sc->type_str = "3c503";
-
-       memsize = 8192;
 
        /*
         * Reset NIC and ASIC. Enable on-board transceiver throughout reset
 
        /*
         * Reset NIC and ASIC. Enable on-board transceiver throughout reset
@@ -560,7 +687,18 @@ ed_probe_3Com(isa_dev)
        /*
         * Wait a bit for the NIC to recover from the reset
         */
        /*
         * Wait a bit for the NIC to recover from the reset
         */
-       DELAY(50);
+       DELAY(5000);
+
+       sc->vendor = ED_VENDOR_3COM;
+       sc->type_str = "3c503";
+
+       sc->mem_shared = 1;
+
+       /*
+        * Hmmm...a 16bit 3Com board has 16k of memory, but only an 8k
+        *      window to it.
+        */
+       memsize = 8192;
 
        /*
         * Get station address from on-board ROM
 
        /*
         * Get station address from on-board ROM
@@ -615,16 +753,39 @@ ed_probe_3Com(isa_dev)
         */
         outb(sc->nic_addr + ED_P2_CR, ED_CR_RD2|ED_CR_STP);
 
         */
         outb(sc->nic_addr + ED_P2_CR, ED_CR_RD2|ED_CR_STP);
 
-       sc->txb_cnt = 1;
-
-       sc->tx_page_start = ED_3COM_PAGE_OFFSET;
-       sc->rec_page_start = ED_TXBUF_SIZE + ED_3COM_PAGE_OFFSET;
-       sc->rec_page_stop = memsize / ED_PAGE_SIZE + ED_3COM_PAGE_OFFSET;
-
-       sc->smem_start = (caddr_t)isa_dev->id_maddr;
-       sc->smem_size = memsize;
-       sc->smem_end = sc->smem_start + memsize;
-       sc->smem_ring = sc->smem_start + (ED_PAGE_SIZE * ED_TXBUF_SIZE);
+       sc->mem_start = (caddr_t)isa_dev->id_maddr;
+       sc->mem_size = memsize;
+       sc->mem_end = sc->mem_start + memsize;
+
+       /*
+        * We have an entire 8k window to put the transmit buffers on the
+        *      16bit boards. But since the 16bit 3c503's shared memory
+        *      is only fast enough to overlap the loading of one full-size
+        *      packet, trying to load more than 2 buffers can actually
+        *      leave the transmitter idle during the load. So 2 seems
+        *      the best value. (Although a mix of variable-sized packets
+        *      might change this assumption. Nonetheless, we optimize for
+        *      linear transfers of same-size packets.)
+        */
+       if (isa16bit) {
+               if (isa_dev->id_flags & ED_FLAGS_NO_MULTI_BUFFERING)
+                       sc->txb_cnt = 1;
+               else
+                       sc->txb_cnt = 2;
+
+               sc->tx_page_start = ED_3COM_TX_PAGE_OFFSET_16BIT;
+               sc->rec_page_start = ED_3COM_RX_PAGE_OFFSET_16BIT;
+               sc->rec_page_stop = memsize / ED_PAGE_SIZE +
+                       ED_3COM_RX_PAGE_OFFSET_16BIT;
+               sc->mem_ring = sc->mem_start;
+       } else {
+               sc->txb_cnt = 1;
+               sc->tx_page_start = ED_3COM_TX_PAGE_OFFSET_8BIT;
+               sc->rec_page_start = ED_TXBUF_SIZE + ED_3COM_TX_PAGE_OFFSET_8BIT;
+               sc->rec_page_stop = memsize / ED_PAGE_SIZE +
+                       ED_3COM_TX_PAGE_OFFSET_8BIT;
+               sc->mem_ring = sc->mem_start + (ED_PAGE_SIZE * ED_TXBUF_SIZE);
+       }
 
        sc->isa16bit = isa16bit;
 
 
        sc->isa16bit = isa16bit;
 
@@ -658,7 +819,7 @@ ed_probe_3Com(isa_dev)
        }
 
        /*
        }
 
        /*
-        * Initialize GA configuration register. Set bank and enable smem.
+        * Initialize GA configuration register. Set bank and enable shared mem.
         */
        outb(sc->asic_addr + ED_3COM_GACFR, ED_3COM_GACFR_RSEL |
                ED_3COM_GACFR_MBS0);
         */
        outb(sc->asic_addr + ED_3COM_GACFR, ED_3COM_GACFR_RSEL |
                ED_3COM_GACFR_MBS0);
@@ -676,18 +837,161 @@ ed_probe_3Com(isa_dev)
        /*
         * Zero memory and verify that it is clear
         */
        /*
         * Zero memory and verify that it is clear
         */
-       bzero(sc->smem_start, memsize);
+       bzero(sc->mem_start, memsize);
 
        for (i = 0; i < memsize; ++i)
 
        for (i = 0; i < memsize; ++i)
-               if (sc->smem_start[i]) {
+               if (sc->mem_start[i]) {
                        printf("ed%d: failed to clear shared memory at %x - check configuration\n",
                        printf("ed%d: failed to clear shared memory at %x - check configuration\n",
-                               isa_dev->id_unit, sc->smem_start + i);
+                               isa_dev->id_unit, kvtop(sc->mem_start + i));
                        return(0);
                }
 
        isa_dev->id_msize = memsize;
        return(ED_3COM_IO_PORTS);
 }
                        return(0);
                }
 
        isa_dev->id_msize = memsize;
        return(ED_3COM_IO_PORTS);
 }
+
+/*
+ * Probe and vendor-specific initialization routine for NE1000/2000 boards
+ */
+int
+ed_probe_Novell(isa_dev)
+       struct isa_device *isa_dev;
+{
+       struct ed_softc *sc = &ed_softc[isa_dev->id_unit];
+       u_int memsize, n;
+       u_char romdata[16], isa16bit = 0, tmp;
+       static char test_pattern[32] = "THIS is A memory TEST pattern";
+       char test_buffer[32];
+
+       sc->asic_addr = isa_dev->id_iobase + ED_NOVELL_ASIC_OFFSET;
+       sc->nic_addr = isa_dev->id_iobase + ED_NOVELL_NIC_OFFSET;
+
+       /* XXX - do Novell-specific probe here */
+
+       /* Reset the board */
+       tmp = inb(sc->asic_addr + ED_NOVELL_RESET);
+
+       /*
+        * I don't know if this is necessary; probably cruft leftover from
+        *      Clarkson packet driver code. Doesn't do a thing on the boards
+        *      I've tested. -DG [note that a outb(0x84, 0) seems to work
+        *      here, and is non-invasive...but some boards don't seem to reset
+        *      and I don't have complete documentation on what the 'right'
+        *      thing to do is...so we do the invasive thing for now. Yuck.]
+        */
+       outb(sc->asic_addr + ED_NOVELL_RESET, tmp);
+       DELAY(5000);
+
+       /*
+        * This is needed because some NE clones apparently don't reset the
+        *      NIC properly (or the NIC chip doesn't reset fully on power-up)
+        * XXX - this makes the probe invasive! ...Done against my better
+        *      judgement. -DLG
+        */
+       outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STP);
+
+       DELAY(5000);
+
+       /* Make sure that we really have an 8390 based board */
+       if (!ed_probe_generic8390(sc))
+               return(0);
+
+       sc->vendor = ED_VENDOR_NOVELL;
+       sc->mem_shared = 0;
+       isa_dev->id_maddr = 0;
+
+       /*
+        * Test the ability to read and write to the NIC memory. This has
+        * the side affect of determining if this is an NE1000 or an NE2000.
+        */
+
+       /*
+        * This prevents packets from being stored in the NIC memory when
+        *      the readmem routine turns on the start bit in the CR.
+        */
+       outb(sc->nic_addr + ED_P0_RCR, ED_RCR_MON);
+
+       /* Temporarily initialize DCR for byte operations */
+       outb(sc->nic_addr + ED_P0_DCR, ED_DCR_FT1|ED_DCR_LS);
+
+       outb(sc->nic_addr + ED_P0_PSTART, 8192 / ED_PAGE_SIZE);
+       outb(sc->nic_addr + ED_P0_PSTOP, 16384 / ED_PAGE_SIZE);
+
+       sc->isa16bit = 0;
+
+       /*
+        * Write a test pattern in byte mode. If this fails, then there
+        *      probably isn't any memory at 8k - which likely means
+        *      that the board is an NE2000.
+        */
+       ed_pio_writemem(sc, test_pattern, 8192, sizeof(test_pattern));
+       ed_pio_readmem(sc, 8192, test_buffer, sizeof(test_pattern));
+
+       if (bcmp(test_pattern, test_buffer, sizeof(test_pattern))) {
+               /* not an NE1000 - try NE2000 */
+
+               outb(sc->nic_addr + ED_P0_DCR, ED_DCR_WTS|ED_DCR_FT1|ED_DCR_LS);
+               outb(sc->nic_addr + ED_P0_PSTART, 16384 / ED_PAGE_SIZE);
+               outb(sc->nic_addr + ED_P0_PSTOP, 32768 / ED_PAGE_SIZE);
+
+               sc->isa16bit = 1;
+               /*
+                * Write a test pattern in word mode. If this also fails, then
+                *      we don't know what this board is.
+                */
+               ed_pio_writemem(sc, test_pattern, 16384, sizeof(test_pattern));
+               ed_pio_readmem(sc, 16384, test_buffer, sizeof(test_pattern));
+
+               if (bcmp(test_pattern, test_buffer, sizeof(test_pattern)))
+                       return(0); /* not an NE2000 either */
+
+               sc->type = ED_TYPE_NE2000;
+               sc->type_str = "NE2000";
+       } else {
+               sc->type = ED_TYPE_NE1000;
+               sc->type_str = "NE1000";
+       }
+       
+       /* 8k of memory plus an additional 8k if 16bit */
+       memsize = 8192 + sc->isa16bit * 8192;
+
+#if 0 /* probably not useful - NE boards only come two ways */
+       /* allow kernel config file overrides */
+       if (isa_dev->id_msize)
+               memsize = isa_dev->id_msize;
+#endif
+
+       sc->mem_size = memsize;
+
+       /* NIC memory doesn't start at zero on an NE board */
+       /* The start address is tied to the bus width */
+       sc->mem_start = (char *) 8192 + sc->isa16bit * 8192;
+       sc->mem_end = sc->mem_start + memsize;
+       sc->tx_page_start = memsize / ED_PAGE_SIZE;
+
+       /*
+        * Use one xmit buffer if < 16k, two buffers otherwise (if not told
+        *      otherwise).
+        */
+       if ((memsize < 16384) || (isa_dev->id_flags & ED_FLAGS_NO_MULTI_BUFFERING))
+               sc->txb_cnt = 1;
+       else
+               sc->txb_cnt = 2;
+
+       sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE;
+       sc->rec_page_stop = sc->tx_page_start + memsize / ED_PAGE_SIZE;
+
+       sc->mem_ring = sc->mem_start + sc->txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE;
+
+       ed_pio_readmem(sc, 0, romdata, 16);
+       for (n = 0; n < ETHER_ADDR_LEN; n++)
+               sc->arpcom.ac_enaddr[n] = romdata[n*(sc->isa16bit+1)];
+
+       /* clear any pending interrupts that might have occurred above */
+       outb(sc->nic_addr + ED_P0_ISR, 0xff);
+
+       return(ED_NOVELL_IO_PORTS);
+}
  
 /*
  * Install interface into kernel networking data structures
  
 /*
  * Install interface into kernel networking data structures
@@ -724,8 +1028,8 @@ ed_attach(isa_dev)
         *      for AUI operation), based on compile-time config option.
         */
        if (isa_dev->id_flags & ED_FLAGS_DISABLE_TRANCEIVER)
         *      for AUI operation), based on compile-time config option.
         */
        if (isa_dev->id_flags & ED_FLAGS_DISABLE_TRANCEIVER)
-               ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS
-                       | IFF_ALTPHYS);
+               ifp->if_flags =
+                   (IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_ALTPHYS);
        else
                ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS);
 
        else
                ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS);
 
@@ -771,7 +1075,7 @@ ed_attach(isa_dev)
        printf("%s ",sc->isa16bit ? "(16 bit)" : "(8 bit)");
 
        printf("%s\n", ((sc->vendor == ED_VENDOR_3COM) &&
        printf("%s ",sc->isa16bit ? "(16 bit)" : "(8 bit)");
 
        printf("%s\n", ((sc->vendor == ED_VENDOR_3COM) &&
-               (ifp->if_flags & IFF_ALTPHYS)) ? "tranceiver disabled" : "");
+               (ifp->if_flags & IFF_ALTPHYS)) ? " tranceiver disabled" : "");
 
        /*
         * If BPF is in the kernel, call the attach for it
 
        /*
         * If BPF is in the kernel, call the attach for it
@@ -779,19 +1083,20 @@ ed_attach(isa_dev)
 #if NBPFILTER > 0
        bpfattach(&sc->bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
 #endif
 #if NBPFILTER > 0
        bpfattach(&sc->bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
 #endif
-
+       return 1;
 }
  
 /*
  * Reset interface.
  */
 }
  
 /*
  * Reset interface.
  */
-int
-ed_reset(unit)
+void
+ed_reset(unit, uban)
        int unit;
        int unit;
+       int uban;               /* XXX */
 {
        int s;
 
 {
        int s;
 
-       s = splnet();
+       s = splimp();
 
        /*
         * Stop interface and re-initialize.
 
        /*
         * Stop interface and re-initialize.
@@ -815,8 +1120,11 @@ ed_stop(unit)
        /*
         * Stop everything on the interface, and select page 0 registers.
         */
        /*
         * Stop everything on the interface, and select page 0 registers.
         */
-       outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STP);
-
+       if (sc->is790) {
+               outb(sc->nic_addr + ED_P0_CR, ED_CR_STP);
+       } else {
+               outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STP);
+       }
        /*
         * Wait for interface to enter stopped state, but limit # of checks
         *      to 'n' (about 5ms). It shouldn't even take 5us on modern
        /*
         * Wait for interface to enter stopped state, but limit # of checks
         *      to 'n' (about 5ms). It shouldn't even take 5us on modern
@@ -830,18 +1138,22 @@ ed_stop(unit)
  * Device timeout/watchdog routine. Entered if the device neglects to
  *     generate an interrupt after a transmit has been started on it.
  */
  * Device timeout/watchdog routine. Entered if the device neglects to
  *     generate an interrupt after a transmit has been started on it.
  */
-int
+void
 ed_watchdog(unit)
        int unit;
 {
 ed_watchdog(unit)
        int unit;
 {
+       struct ed_softc *sc = &ed_softc[unit];
+
        log(LOG_ERR, "ed%d: device timeout\n", unit);
        log(LOG_ERR, "ed%d: device timeout\n", unit);
+       ++sc->arpcom.ac_if.if_oerrors;
 
 
-       ed_reset(unit);
+       ed_reset(unit, 0);
 }
 
 /*
  * Initialize device. 
  */
 }
 
 /*
  * Initialize device. 
  */
+void
 ed_init(unit)
        int unit;
 {
 ed_init(unit)
        int unit;
 {
@@ -859,14 +1171,15 @@ ed_init(unit)
         *      This init procedure is "mandatory"...don't change what or when
         *      things happen.
         */
         *      This init procedure is "mandatory"...don't change what or when
         *      things happen.
         */
-       s = splnet();
+       s = splimp();
 
        /* reset transmitter flags */
 
        /* reset transmitter flags */
-       sc->data_buffered = 0;
        sc->xmit_busy = 0;
        sc->arpcom.ac_if.if_timer = 0;
 
        sc->xmit_busy = 0;
        sc->arpcom.ac_if.if_timer = 0;
 
-       sc->txb_next = 0;
+       sc->txb_inuse = 0;
+       sc->txb_new = 0;
+       sc->txb_next_tx = 0;
 
        /* This variable is used below - don't move this assignment */
        sc->next_packet = sc->rec_page_start + 1;
 
        /* This variable is used below - don't move this assignment */
        sc->next_packet = sc->rec_page_start + 1;
@@ -874,8 +1187,11 @@ ed_init(unit)
        /*
         * Set interface for page 0, Remote DMA complete, Stopped
         */
        /*
         * Set interface for page 0, Remote DMA complete, Stopped
         */
-       outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STP);
-
+       if (sc->is790) {
+               outb(sc->nic_addr + ED_P0_CR, ED_CR_STP);
+       } else {
+               outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STP);
+       }
        if (sc->isa16bit) {
                /*
                 * Set FIFO threshold to 8, No auto-init Remote DMA,
        if (sc->isa16bit) {
                /*
                 * Set FIFO threshold to 8, No auto-init Remote DMA,
@@ -910,6 +1226,9 @@ ed_init(unit)
         */
        outb(sc->nic_addr + ED_P0_TPSR, sc->tx_page_start);
        outb(sc->nic_addr + ED_P0_PSTART, sc->rec_page_start);
         */
        outb(sc->nic_addr + ED_P0_TPSR, sc->tx_page_start);
        outb(sc->nic_addr + ED_P0_PSTART, sc->rec_page_start);
+       /* Set lower bits of byte addressable framing to 0 */
+       if (sc->is790)
+               outb(sc->nic_addr + 0x09, 0);
 
        /*
         * Initialize Receiver (ring-buffer) Page Stop and Boundry
 
        /*
         * Initialize Receiver (ring-buffer) Page Stop and Boundry
@@ -930,13 +1249,16 @@ ed_init(unit)
         * Counter overflow and Remote DMA complete are *not* enabled.
         */
        outb(sc->nic_addr + ED_P0_IMR,
         * Counter overflow and Remote DMA complete are *not* enabled.
         */
        outb(sc->nic_addr + ED_P0_IMR,
-               ED_IMR_PRXE|ED_IMR_PTXE|ED_IMR_RXEE|ED_IMR_TXEE|ED_IMR_OVWE);
+           ED_IMR_PRXE|ED_IMR_PTXE|ED_IMR_RXEE|ED_IMR_TXEE|ED_IMR_OVWE);
 
        /*
         * Program Command Register for page 1
         */
 
        /*
         * Program Command Register for page 1
         */
-       outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_1|ED_CR_RD2|ED_CR_STP);
-
+       if (sc->is790) {
+               outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_1|ED_CR_STP);
+       } else {
+               outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_1|ED_CR_RD2|ED_CR_STP);
+       }
        /*
         * Copy out our station address
         */
        /*
         * Copy out our station address
         */
@@ -961,8 +1283,11 @@ ed_init(unit)
         * Set Command Register for page 0, Remote DMA complete,
         *      and interface Start.
         */
         * Set Command Register for page 0, Remote DMA complete,
         *      and interface Start.
         */
-       outb(sc->nic_addr + ED_P1_CR, ED_CR_RD2|ED_CR_STA);
-
+       if (sc->is790) {
+               outb(sc->nic_addr + ED_P1_CR, ED_CR_STA);
+       } else {
+               outb(sc->nic_addr + ED_P1_CR, ED_CR_RD2|ED_CR_STA);
+       }
        /*
         * Take interface out of loopback
         */
        /*
         * Take interface out of loopback
         */
@@ -1001,40 +1326,46 @@ static inline void ed_xmit(ifp)
        struct ifnet *ifp;
 {
        struct ed_softc *sc = &ed_softc[ifp->if_unit];
        struct ifnet *ifp;
 {
        struct ed_softc *sc = &ed_softc[ifp->if_unit];
-       u_short len = sc->txb_next_len;
+       unsigned short len;
+
+       len = sc->txb_len[sc->txb_next_tx];
 
        /*
         * Set NIC for page 0 register access
         */
 
        /*
         * Set NIC for page 0 register access
         */
-       outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA);
-
+       if (sc->is790) {
+               outb(sc->nic_addr + ED_P0_CR, ED_CR_STA);
+       } else {
+               outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA);
+       }
        /*
         * Set TX buffer start page
         */
        outb(sc->nic_addr + ED_P0_TPSR, sc->tx_page_start +
        /*
         * Set TX buffer start page
         */
        outb(sc->nic_addr + ED_P0_TPSR, sc->tx_page_start +
-               sc->txb_next * ED_TXBUF_SIZE);
+               sc->txb_next_tx * ED_TXBUF_SIZE);
 
        /*
         * Set TX length
         */
 
        /*
         * Set TX length
         */
-       outb(sc->nic_addr + ED_P0_TBCR0, len & 0xff);
+       outb(sc->nic_addr + ED_P0_TBCR0, len);
        outb(sc->nic_addr + ED_P0_TBCR1, len >> 8);
 
        /*
         * Set page 0, Remote DMA complete, Transmit Packet, and *Start*
         */
        outb(sc->nic_addr + ED_P0_TBCR1, len >> 8);
 
        /*
         * Set page 0, Remote DMA complete, Transmit Packet, and *Start*
         */
-       outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_TXP|ED_CR_STA);
-
+       if (sc->is790) {
+               outb(sc->nic_addr + ED_P0_CR, ED_CR_TXP | ED_CR_STA);
+       } else {
+               outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_TXP|ED_CR_STA);
+       }
        sc->xmit_busy = 1;
        sc->xmit_busy = 1;
-       sc->data_buffered = 0;
        
        /*
        
        /*
-        * Switch buffers if we are doing double-buffered transmits
+        * Point to next transmit buffer slot and wrap if necessary.
         */
         */
-       if ((sc->txb_next == 0) && (sc->txb_cnt > 1)) 
-               sc->txb_next = 1;
-       else
-               sc->txb_next = 0;
+       sc->txb_next_tx++;
+       if (sc->txb_next_tx == sc->txb_cnt)
+               sc->txb_next_tx = 0;
 
        /*
         * Set a timer just in case we never hear from the board again
 
        /*
         * Set a timer just in case we never hear from the board again
@@ -1045,13 +1376,13 @@ static inline void ed_xmit(ifp)
 /*
  * Start output on interface.
  * We make two assumptions here:
 /*
  * Start output on interface.
  * We make two assumptions here:
- *  1) that the current priority is set to splnet _before_ this code
+ *  1) that the current priority is set to splimp _before_ this code
  *     is called *and* is returned to the appropriate priority after
  *     return
  *  2) that the IFF_OACTIVE flag is checked before this code is called
  *     (i.e. that the output part of the interface is idle)
  */
  *     is called *and* is returned to the appropriate priority after
  *     return
  *  2) that the IFF_OACTIVE flag is checked before this code is called
  *     (i.e. that the output part of the interface is idle)
  */
-int
+void
 ed_start(ifp)
        struct ifnet *ifp;
 {
 ed_start(ifp)
        struct ifnet *ifp;
 {
@@ -1062,39 +1393,34 @@ ed_start(ifp)
 
 outloop:
        /*
 
 outloop:
        /*
-        * See if there is room to send more data (i.e. one or both of the
-        *      buffers is empty).
+        * First, see if there are buffered packets and an idle
+        *      transmitter - should never happen at this point.
         */
         */
-       if (sc->data_buffered)
-               if (sc->xmit_busy) {
-                       /*
-                        * No room. Indicate this to the outside world
-                        *      and exit.
-                        */
-                       ifp->if_flags |= IFF_OACTIVE;
-                       return;
-               } else {
-                       /*
-                        * Data is buffered, but we're not transmitting, so
-                        *      start the xmit on the buffered data.
-                        * Note that ed_xmit() resets the data_buffered flag
-                        *      before returning.
-                        */
-                       ed_xmit(ifp);
-               }
+       if (sc->txb_inuse && (sc->xmit_busy == 0)) {
+               printf("ed: packets buffers, but transmitter idle\n");
+               ed_xmit(ifp);
+       }
+
+       /*
+        * See if there is room to put another packet in the buffer.
+        */
+       if (sc->txb_inuse == sc->txb_cnt) {
+               /*
+                * No room. Indicate this to the outside world
+                *      and exit.
+                */
+               ifp->if_flags |= IFF_OACTIVE;
+               return;
+       }
 
        IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m);
        if (m == 0) {
        /*
 
        IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m);
        if (m == 0) {
        /*
-        * The following isn't pretty; we are using the !OACTIVE flag to
-        * indicate to the outside world that we can accept an additional
-        * packet rather than that the transmitter is _actually_
-        * active. Indeed, the transmitter may be active, but if we haven't
-        * filled the secondary buffer with data then we still want to
-        * accept more.
-        * Note that it isn't necessary to test the data_buffered flag -
-        * we wouldn't have tried to de-queue the packet in the first place
-        * if it was set.
+        * We are using the !OACTIVE flag to indicate to the outside
+        * world that we can accept an additional packet rather than
+        * that the transmitter is _actually_ active. Indeed, the
+        * transmitter may be active, but if we haven't filled all
+        * the buffers with data then we still want to accept more.
         */
                ifp->if_flags &= ~IFF_OACTIVE;
                return;
         */
                ifp->if_flags &= ~IFF_OACTIVE;
                return;
@@ -1103,39 +1429,88 @@ outloop:
        /*
         * Copy the mbuf chain into the transmit buffer
         */
        /*
         * Copy the mbuf chain into the transmit buffer
         */
-       /*
-        * Enable 16bit access to shared memory on WD/SMC boards
-        *      Don't update wd_laar_proto because we want to restore the
-        *      previous state (because an arp reply in the input code
-        *      may cause a call-back to ed_start)
-        * XXX - the call-back to 'start' is a bug, IMHO.
-        */
-       if (sc->isa16bit && (sc->vendor == ED_VENDOR_WD_SMC)) {
-               outb(sc->asic_addr + ED_WD_LAAR,
-                       (sc->wd_laar_proto | ED_WD_LAAR_M16EN));
-       }
 
 
-       buffer = sc->smem_start + (sc->txb_next * ED_TXBUF_SIZE * ED_PAGE_SIZE);
-       len = 0;
-       for (m0 = m; m != 0; m = m->m_next) {
-               bcopy(mtod(m, caddr_t), buffer, m->m_len);
-               buffer += m->m_len;
-                       len += m->m_len;
-       }
+       m0 = m;
 
 
-       /*
-        * Restore previous shared mem access type
-        */
-       if (sc->isa16bit && (sc->vendor == ED_VENDOR_WD_SMC))
-               outb(sc->asic_addr + ED_WD_LAAR, sc->wd_laar_proto);
+       /* txb_new points to next open buffer slot */
+       buffer = sc->mem_start + (sc->txb_new * ED_TXBUF_SIZE * ED_PAGE_SIZE);
 
 
-       sc->txb_next_len = MAX(len, ETHER_MIN_LEN);
+       if (sc->mem_shared) {
+               /*
+                * Special case setup for 16 bit boards...
+                */
+               if (sc->isa16bit) {
+                       switch (sc->vendor) {
+                       /*
+                        * For 16bit 3Com boards (which have 16k of memory),
+                        *      we have the xmit buffers in a different page
+                        *      of memory ('page 0') - so change pages.
+                        */
+                       case ED_VENDOR_3COM:
+                               outb(sc->asic_addr + ED_3COM_GACFR,
+                                   ED_3COM_GACFR_RSEL);
+                               break;
+                       /*
+                        * Enable 16bit access to shared memory on WD/SMC boards
+                        *      Don't update wd_laar_proto because we want to restore the
+                        *      previous state (because an arp reply in the input code
+                        *      may cause a call-back to ed_start)
+                        * XXX - the call-back to 'start' is a bug, IMHO.
+                        */
+                       case ED_VENDOR_WD_SMC: {
+                               outb(sc->asic_addr + ED_WD_LAAR,
+                                   (sc->wd_laar_proto | ED_WD_LAAR_M16EN));
+                               (void) inb(0x84);
+                               if (sc->is790) {
+                                       outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_MENB);
+                                       (void) inb(0x84);
+                               }
+                               (void) inb(0x84);
+                               break;
+                           }
+                       }
+               }
+
+               for (len = 0; m != 0; m = m->m_next) {
+                       bcopy(mtod(m, caddr_t), buffer, m->m_len);
+                       buffer += m->m_len;
+                       len += m->m_len;
+               }
 
 
-       if (sc->txb_cnt > 1)
                /*
                /*
-                * only set 'buffered' flag if doing multiple buffers
+                * Restore previous shared memory access
                 */
                 */
-               sc->data_buffered = 1;
+               if (sc->isa16bit) {
+                       switch (sc->vendor) {
+                       case ED_VENDOR_3COM:
+                               outb(sc->asic_addr + ED_3COM_GACFR,
+                                   ED_3COM_GACFR_RSEL | ED_3COM_GACFR_MBS0);
+                               break;
+                       case ED_VENDOR_WD_SMC: {
+                               outb(sc->asic_addr + ED_WD_LAAR, sc->wd_laar_proto);
+                               (void) inb(0x84);
+                               if (sc->is790) {
+                                       outb(sc->asic_addr + ED_WD_MSR, 0x00);
+                                       (void) inb(0x84);
+                               }
+                               break;
+                           }
+                       }
+               }
+       } else {
+               len = ed_pio_write_mbufs(sc, m, buffer);
+       }
+               
+       sc->txb_len[sc->txb_new] = MAX(len, ETHER_MIN_LEN);
+
+       sc->txb_inuse++;
+
+       /*
+        * Point to next buffer slot and wrap if necessary.
+        */
+       sc->txb_new++;
+       if (sc->txb_new == sc->txb_cnt)
+               sc->txb_new = 0;
 
        if (sc->xmit_busy == 0)
                ed_xmit(ifp);
 
        if (sc->xmit_busy == 0)
                ed_xmit(ifp);
@@ -1152,10 +1527,7 @@ outloop:
                u_short etype;
                int off, datasize, resid;
                struct ether_header *eh;
                u_short etype;
                int off, datasize, resid;
                struct ether_header *eh;
-               struct trailer_header {
-                       u_short ether_type;
-                       u_short ether_residual;
-               } trailer_header;
+               struct trailer_header trailer_header;
                char ether_packet[ETHER_MAX_LEN];
                char *ep;
 
                char ether_packet[ETHER_MAX_LEN];
                char *ep;
 
@@ -1189,17 +1561,17 @@ outloop:
 
                        /* copy trailer_header into a data structure */
                        m_copydata(m0, off, sizeof(struct trailer_header),
 
                        /* copy trailer_header into a data structure */
                        m_copydata(m0, off, sizeof(struct trailer_header),
-                               &trailer_header.ether_type);
+                                  (caddr_t)&trailer_header.ether_type);
 
                        /* copy residual data */
                        m_copydata(m0, off+sizeof(struct trailer_header),
 
                        /* copy residual data */
                        m_copydata(m0, off+sizeof(struct trailer_header),
-                               resid = ntohs(trailer_header.ether_residual) -
-                               sizeof(struct trailer_header), ep);
+                                  resid = ntohs(trailer_header.ether_residual) -
+                                  sizeof(struct trailer_header), ep);
                        ep += resid;
 
                        /* copy data */
                        m_copydata(m0, sizeof(struct ether_header),
                        ep += resid;
 
                        /* copy data */
                        m_copydata(m0, sizeof(struct ether_header),
-                               datasize, ep);
+                                  datasize, ep);
                        ep += datasize;
 
                        /* restore original ether packet type */
                        ep += datasize;
 
                        /* restore original ether packet type */
@@ -1214,15 +1586,9 @@ outloop:
        m_freem(m0);
 
        /*
        m_freem(m0);
 
        /*
-        * If we are doing double-buffering, a buffer might be free to
-        *      fill with another packet, so loop back to the top.
+        * Loop back to the top to possibly buffer more packets
         */
         */
-       if (sc->txb_cnt > 1)
-               goto outloop;
-       else {
-               ifp->if_flags |= IFF_OACTIVE;
-               return;
-       }
+       goto outloop;
 }
  
 /*
 }
  
 /*
@@ -1235,13 +1601,17 @@ ed_rint(unit)
        register struct ed_softc *sc = &ed_softc[unit];
        u_char boundry, current;
        u_short len;
        register struct ed_softc *sc = &ed_softc[unit];
        u_char boundry, current;
        u_short len;
-       struct ed_ring *packet_ptr;
+       struct ed_ring packet_hdr;
+       char *packet_ptr;
 
        /*
         * Set NIC to page 1 registers to get 'current' pointer
         */
 
        /*
         * Set NIC to page 1 registers to get 'current' pointer
         */
-       outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_1|ED_CR_RD2|ED_CR_STA);
-
+       if (sc->is790) {
+               outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_1|ED_CR_STA);
+       } else {
+               outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_1|ED_CR_RD2|ED_CR_STA);
+       }
        /*
         * 'sc->next_packet' is the logical beginning of the ring-buffer - i.e.
         *      it points to where new data has been buffered. The 'CURR'
        /*
         * 'sc->next_packet' is the logical beginning of the ring-buffer - i.e.
         *      it points to where new data has been buffered. The 'CURR'
@@ -1252,22 +1622,25 @@ ed_rint(unit)
         */
        while (sc->next_packet != inb(sc->nic_addr + ED_P1_CURR)) {
 
         */
        while (sc->next_packet != inb(sc->nic_addr + ED_P1_CURR)) {
 
-               /* get pointer to this buffer header structure */
-               packet_ptr = (struct ed_ring *)(sc->smem_ring +
-                        (sc->next_packet - sc->rec_page_start) * ED_PAGE_SIZE);
+               /* get pointer to this buffer's header structure */
+               packet_ptr = sc->mem_ring +
+                   (sc->next_packet - sc->rec_page_start) * ED_PAGE_SIZE;
 
                /*
                 * The byte count includes the FCS - Frame Check Sequence (a
                 *      32 bit CRC).
                 */
 
                /*
                 * The byte count includes the FCS - Frame Check Sequence (a
                 *      32 bit CRC).
                 */
-               len = packet_ptr->count;
+               if (sc->mem_shared)
+                       packet_hdr = *(struct ed_ring *)packet_ptr;
+               else
+                       ed_pio_readmem(sc, packet_ptr, (char *) &packet_hdr,
+                          sizeof(packet_hdr));
+               len = packet_hdr.count;
                if ((len >= ETHER_MIN_LEN) && (len <= ETHER_MAX_LEN)) {
                        /*
                         * Go get packet. len - 4 removes CRC from length.
                if ((len >= ETHER_MIN_LEN) && (len <= ETHER_MAX_LEN)) {
                        /*
                         * Go get packet. len - 4 removes CRC from length.
-                        * (packet_ptr + 1) points to data just after the packet ring
-                        *      header (+4 bytes)
                         */
                         */
-                       ed_get_packet(sc, (caddr_t)(packet_ptr + 1), len - 4);
+                       ed_get_packet(sc, packet_ptr + 4, len - 4);
                        ++sc->arpcom.ac_if.if_ipackets;
                } else {
                        /*
                        ++sc->arpcom.ac_if.if_ipackets;
                } else {
                        /*
@@ -1276,16 +1649,17 @@ ed_rint(unit)
                         *      high load - the byte order of the length gets switched.
                         */
                        log(LOG_ERR,
                         *      high load - the byte order of the length gets switched.
                         */
                        log(LOG_ERR,
-                               "ed%d: shared memory corrupt - invalid packet length %d\n",
-                               unit, len);
-                       ed_reset(unit);
+                           "ed%d: NIC memory corrupt - invalid packet length %d\n",
+                           unit, len);
+                       ++sc->arpcom.ac_if.if_ierrors;
+                       ed_reset(unit, 0);
                        return;
                }
 
                /*
                 * Update next packet pointer
                 */
                        return;
                }
 
                /*
                 * Update next packet pointer
                 */
-               sc->next_packet = packet_ptr->next_packet;
+               sc->next_packet = packet_hdr.next_packet;
 
                /*
                 * Update NIC boundry pointer - being careful to keep it
 
                /*
                 * Update NIC boundry pointer - being careful to keep it
@@ -1298,22 +1672,29 @@ ed_rint(unit)
                /*
                 * Set NIC to page 0 registers to update boundry register
                 */
                /*
                 * Set NIC to page 0 registers to update boundry register
                 */
-               outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA);
-
+               if (sc->is790) {
+                       outb(sc->nic_addr + ED_P0_CR, ED_CR_STA);
+               } else {
+                       outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA);
+               }
                outb(sc->nic_addr + ED_P0_BNRY, boundry);
 
                /*
                 * Set NIC to page 1 registers before looping to top (prepare to
                 *      get 'CURR' current pointer)
                 */
                outb(sc->nic_addr + ED_P0_BNRY, boundry);
 
                /*
                 * Set NIC to page 1 registers before looping to top (prepare to
                 *      get 'CURR' current pointer)
                 */
-               outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_1|ED_CR_RD2|ED_CR_STA);
+               if (sc->is790) {
+                       outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_1|ED_CR_STA);
+               } else {
+                       outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_1|ED_CR_RD2|ED_CR_STA);
+               }
        }
 }
 
 /*
  * Ethernet interface interrupt processor
  */
        }
 }
 
 /*
  * Ethernet interface interrupt processor
  */
-int
+void
 edintr(unit)
        int unit;
 {
 edintr(unit)
        int unit;
 {
@@ -1323,8 +1704,11 @@ edintr(unit)
        /*
         * Set NIC to page 0 registers
         */
        /*
         * Set NIC to page 0 registers
         */
-       outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA);
-
+       if (sc->is790) {
+               outb(sc->nic_addr + ED_P0_CR, ED_CR_STA);
+       } else {
+               outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA);
+       }
        /*
         * loop until there are no more new interrupts
         */
        /*
         * loop until there are no more new interrupts
         */
@@ -1343,7 +1727,7 @@ edintr(unit)
                 *      some conditions.
                 */
                if (isr & (ED_ISR_PTX|ED_ISR_TXE)) {
                 *      some conditions.
                 */
                if (isr & (ED_ISR_PTX|ED_ISR_TXE)) {
-                       u_char collisions = inb(sc->nic_addr + ED_P0_NCR);
+                       u_char collisions = inb(sc->nic_addr + ED_P0_NCR) & 0x0f;
 
                        /*
                         * Check for transmit error. If a TX completed with an
 
                        /*
                         * Check for transmit error. If a TX completed with an
@@ -1354,13 +1738,14 @@ edintr(unit)
                         * course, with UDP we're screwed, but this is expected
                         * when a network is heavily loaded.
                         */
                         * course, with UDP we're screwed, but this is expected
                         * when a network is heavily loaded.
                         */
+                       (void) inb(sc->nic_addr + ED_P0_TSR);
                        if (isr & ED_ISR_TXE) {
 
                                /*
                                 * Excessive collisions (16)
                                 */
                                if ((inb(sc->nic_addr + ED_P0_TSR) & ED_TSR_ABT)
                        if (isr & ED_ISR_TXE) {
 
                                /*
                                 * Excessive collisions (16)
                                 */
                                if ((inb(sc->nic_addr + ED_P0_TSR) & ED_TSR_ABT)
-                                       && (collisions == 0)) {
+                                   && (collisions == 0)) {
                                        /*
                                         *    When collisions total 16, the
                                         * P0_NCR will indicate 0, and the
                                        /*
                                         *    When collisions total 16, the
                                         * P0_NCR will indicate 0, and the
@@ -1399,10 +1784,13 @@ edintr(unit)
                        sc->arpcom.ac_if.if_collisions += collisions;
 
                        /*
                        sc->arpcom.ac_if.if_collisions += collisions;
 
                        /*
+                        * Decrement buffer in-use count if not zero (can only
+                        *      be zero if a transmitter interrupt occured while
+                        *      not actually transmitting).
                         * If data is ready to transmit, start it transmitting,
                         *      otherwise defer until after handling receiver
                         */
                         * If data is ready to transmit, start it transmitting,
                         *      otherwise defer until after handling receiver
                         */
-                       if (sc->data_buffered)
+                       if (sc->txb_inuse && --sc->txb_inuse)
                                ed_xmit(&sc->arpcom.ac_if);
                }
 
                                ed_xmit(&sc->arpcom.ac_if);
                }
 
@@ -1421,13 +1809,15 @@ edintr(unit)
                     */
                        if (isr & ED_ISR_OVW) {
                                ++sc->arpcom.ac_if.if_ierrors;
                     */
                        if (isr & ED_ISR_OVW) {
                                ++sc->arpcom.ac_if.if_ierrors;
+#ifdef DIAGNOSTIC
                                log(LOG_WARNING,
                                        "ed%d: warning - receiver ring buffer overrun\n",
                                        unit);
                                log(LOG_WARNING,
                                        "ed%d: warning - receiver ring buffer overrun\n",
                                        unit);
+#endif
                                /*
                                 * Stop/reset/re-init NIC
                                 */
                                /*
                                 * Stop/reset/re-init NIC
                                 */
-                               ed_reset(unit);
+                               ed_reset(unit, 0);
                        } else {
 
                            /*
                        } else {
 
                            /*
@@ -1455,11 +1845,17 @@ edintr(unit)
                                 *      on WD/SMC boards.
                                 */
                                if (sc->isa16bit &&
                                 *      on WD/SMC boards.
                                 */
                                if (sc->isa16bit &&
-                                       (sc->vendor == ED_VENDOR_WD_SMC)) {
+                                   (sc->vendor == ED_VENDOR_WD_SMC)) {
 
                                        outb(sc->asic_addr + ED_WD_LAAR,
 
                                        outb(sc->asic_addr + ED_WD_LAAR,
-                                               (sc->wd_laar_proto |=
-                                                ED_WD_LAAR_M16EN));
+                                            (sc->wd_laar_proto |=
+                                            ED_WD_LAAR_M16EN));
+                                       (void) inb(0x84);
+                                       if (sc->is790) {
+                                               outb(sc->asic_addr + ED_WD_MSR,
+                                                   ED_WD_MSR_MENB);
+                                               (void) inb(0x84);
+                                       }
                                }
 
                                ed_rint (unit);
                                }
 
                                ed_rint (unit);
@@ -1469,8 +1865,13 @@ edintr(unit)
                                        (sc->vendor == ED_VENDOR_WD_SMC)) {
 
                                        outb(sc->asic_addr + ED_WD_LAAR,
                                        (sc->vendor == ED_VENDOR_WD_SMC)) {
 
                                        outb(sc->asic_addr + ED_WD_LAAR,
-                                               (sc->wd_laar_proto &=
-                                                ~ED_WD_LAAR_M16EN));
+                                            (sc->wd_laar_proto &=
+                                            ~ED_WD_LAAR_M16EN));
+                                       (void) inb(0x84);
+                                       if (sc->is790) {
+                                               outb(sc->asic_addr + ED_WD_MSR, 0x00);
+                                               (void) inb(0x84);
+                                       }
                                }
                        }
                }
                                }
                        }
                }
@@ -1490,8 +1891,11 @@ edintr(unit)
                 *      in the transmit routine, is *okay* - it is 'edge'
                 *      triggered from low to high)
                 */
                 *      in the transmit routine, is *okay* - it is 'edge'
                 *      triggered from low to high)
                 */
-               outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA);
-
+               if (sc->is790) {
+                       outb(sc->nic_addr + ED_P0_CR, ED_CR_STA);
+               } else {
+                       outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA);
+               }
                /*
                 * If the Network Talley Counters overflow, read them to
                 *      reset them. It appears that old 8390's won't
                /*
                 * If the Network Talley Counters overflow, read them to
                 *      reset them. It appears that old 8390's won't
@@ -1521,7 +1925,7 @@ ed_ioctl(ifp, command, data)
        struct ifreq *ifr = (struct ifreq *)data;
        int s, error = 0;
 
        struct ifreq *ifr = (struct ifreq *)data;
        int s, error = 0;
 
-       s = splnet();
+       s = splimp();
 
        switch (command) {
 
 
        switch (command) {
 
@@ -1538,8 +1942,7 @@ ed_ioctl(ifp, command, data)
                         * conflict exists, a message is sent to the
                         * console.
                         */
                         * conflict exists, a message is sent to the
                         * console.
                         */
-                       ((struct arpcom *)ifp)->ac_ipaddr =
-                               IA_SIN(ifa)->sin_addr;
+                       ((struct arpcom *)ifp)->ac_ipaddr = IA_SIN(ifa)->sin_addr;
                        arpwhohas((struct arpcom *)ifp, &IA_SIN(ifa)->sin_addr);
                        break;
 #endif
                        arpwhohas((struct arpcom *)ifp, &IA_SIN(ifa)->sin_addr);
                        break;
 #endif
@@ -1559,8 +1962,8 @@ ed_ioctl(ifp, command, data)
                                 * 
                                 */
                                bcopy((caddr_t)ina->x_host.c_host,
                                 * 
                                 */
                                bcopy((caddr_t)ina->x_host.c_host,
-                                   (caddr_t)sc->arpcom.ac_enaddr,
-                                       sizeof(sc->arpcom.ac_enaddr));
+                                     (caddr_t)sc->arpcom.ac_enaddr,
+                                     sizeof(sc->arpcom.ac_enaddr));
                        }
                        /*
                         * Set new address
                        }
                        /*
                         * Set new address
@@ -1575,6 +1978,15 @@ ed_ioctl(ifp, command, data)
                }
                break;
 
                }
                break;
 
+       case SIOCGIFADDR:
+               {
+                       struct sockaddr *sa;
+                       sa = (struct sockaddr *)&ifr->ifr_data;
+                       bcopy((caddr_t)sc->arpcom.ac_enaddr,
+                           (caddr_t) sa->sa_data, ETHER_ADDR_LEN);
+               }
+               break;
+
        case SIOCSIFFLAGS:
                /*
                 * If interface is marked down and it is running, then stop it
        case SIOCSIFFLAGS:
                /*
                 * If interface is marked down and it is running, then stop it
@@ -1601,7 +2013,7 @@ ed_ioctl(ifp, command, data)
                         *              this was done in ed_init().
                         */
                        outb(sc->nic_addr + ED_P0_RCR,
                         *              this was done in ed_init().
                         */
                        outb(sc->nic_addr + ED_P0_RCR,
-                               ED_RCR_PRO|ED_RCR_AM|ED_RCR_AB);
+                            ED_RCR_PRO|ED_RCR_AM|ED_RCR_AB);
                } else {
                        /*
                         * XXX - for multicasts to work, we would need to
                } else {
                        /*
                         * XXX - for multicasts to work, we would need to
@@ -1638,29 +2050,27 @@ ed_ioctl(ifp, command, data)
  *     from an address, taking into account ring-wrap.
  */
 #define        ringoffset(sc, start, off, type) \
  *     from an address, taking into account ring-wrap.
  */
 #define        ringoffset(sc, start, off, type) \
-       ((type)( ((caddr_t)(start)+(off) >= (sc)->smem_end) ? \
-               (((caddr_t)(start)+(off))) - (sc)->smem_end \
-               + (sc)->smem_ring: \
+       ((type)( ((caddr_t)(start)+(off) >= (sc)->mem_end) ? \
+               (((caddr_t)(start)+(off))) - (sc)->mem_end \
+               + (sc)->mem_ring: \
                ((caddr_t)(start)+(off)) ))
 
 /*
  * Retreive packet from shared memory and send to the next level up via
  *     ether_input(). If there is a BPF listener, give a copy to BPF, too.
  */
                ((caddr_t)(start)+(off)) ))
 
 /*
  * Retreive packet from shared memory and send to the next level up via
  *     ether_input(). If there is a BPF listener, give a copy to BPF, too.
  */
+static void
 ed_get_packet(sc, buf, len)
        struct ed_softc *sc;
        char *buf;
        u_short len;
 {
        struct ether_header *eh;
 ed_get_packet(sc, buf, len)
        struct ed_softc *sc;
        char *buf;
        u_short len;
 {
        struct ether_header *eh;
-       struct mbuf *m, *head, *ed_ring_to_mbuf();
+       struct mbuf *m, *head = 0, *ed_ring_to_mbuf();
        u_short off;
        int resid;
        u_short etype;
        u_short off;
        int resid;
        u_short etype;
-       struct trailer_header {
-               u_short trail_type;
-               u_short trail_residual;
-       } trailer_header;
+       struct trailer_header trailer_header;
 
        /* Allocate a header mbuf */
        MGETHDR(m, M_DONTWAIT, MT_DATA);
 
        /* Allocate a header mbuf */
        MGETHDR(m, M_DONTWAIT, MT_DATA);
@@ -1671,8 +2081,6 @@ ed_get_packet(sc, buf, len)
        m->m_len = 0;
        head = m;
 
        m->m_len = 0;
        head = m;
 
-       eh = (struct ether_header *)buf;
-
        /* The following sillines is to make NFS happy */
 #define EROUND ((sizeof(struct ether_header) + 3) & ~3)
 #define EOFF   (EROUND - sizeof(struct ether_header))
        /* The following sillines is to make NFS happy */
 #define EROUND ((sizeof(struct ether_header) + 3) & ~3)
 #define EOFF   (EROUND - sizeof(struct ether_header))
@@ -1682,7 +2090,13 @@ ed_get_packet(sc, buf, len)
         * the ether header in the header mbuf
         */
        head->m_data += EOFF;
         * the ether header in the header mbuf
         */
        head->m_data += EOFF;
-       bcopy(buf, mtod(head, caddr_t), sizeof(struct ether_header));
+       eh = mtod(head, struct ether_header *);
+
+       if (sc->mem_shared)
+               bcopy(buf, mtod(head, caddr_t), sizeof(struct ether_header));
+       else
+               ed_pio_readmem(sc, buf, mtod(head, caddr_t),
+                              sizeof(struct ether_header));
        buf += sizeof(struct ether_header);
        head->m_len += sizeof(struct ether_header);
        len -= sizeof(struct ether_header);
        buf += sizeof(struct ether_header);
        head->m_len += sizeof(struct ether_header);
        len -= sizeof(struct ether_header);
@@ -1704,15 +2118,31 @@ ed_get_packet(sc, buf, len)
                if ((off + sizeof(struct trailer_header)) > len)
                        goto bad;       /* insanity */
 
                if ((off + sizeof(struct trailer_header)) > len)
                        goto bad;       /* insanity */
 
-               eh->ether_type = *ringoffset(sc, buf, off, u_short *);
-               resid = ntohs(*ringoffset(sc, buf, off+2, u_short *));
+               /*
+                * If we have shared memory, we can get info directly from the
+                *      stored packet, otherwise we must get a local copy
+                *      of the trailer header using PIO.
+                */
+               if (sc->mem_shared) {
+                       eh->ether_type = *ringoffset(sc, buf, off, u_short *);
+                       resid = ntohs(*ringoffset(sc, buf, off+2, u_short *));
+               } else {
+                       struct trailer_header trailer_header;
+                       ed_pio_readmem(sc,
+                                      ringoffset(sc, buf, off, caddr_t),
+                                      (char *) &trailer_header,
+                                      sizeof(trailer_header));
+                       eh->ether_type = trailer_header.ether_type;
+                       resid = trailer_header.ether_residual;
+               }
 
                if ((off + resid) > len) goto bad;      /* insanity */
 
                resid -= sizeof(struct trailer_header);
                if (resid < 0) goto bad;        /* insanity */
 
 
                if ((off + resid) > len) goto bad;      /* insanity */
 
                resid -= sizeof(struct trailer_header);
                if (resid < 0) goto bad;        /* insanity */
 
-               m = ed_ring_to_mbuf(sc, ringoffset(sc, buf, off+4, char *), head, resid);
+               m = ed_ring_to_mbuf(sc, ringoffset(sc, buf, off+4, char *),
+                                   head, resid);
                if (m == 0) goto bad;
 
                len = off;
                if (m == 0) goto bad;
 
                len = off;
@@ -1742,13 +2172,13 @@ ed_get_packet(sc, buf, len)
                 * XXX This test does not support multicasts.
                 */
                if ((sc->arpcom.ac_if.if_flags & IFF_PROMISC) &&
                 * XXX This test does not support multicasts.
                 */
                if ((sc->arpcom.ac_if.if_flags & IFF_PROMISC) &&
-                       bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
-                               sizeof(eh->ether_dhost)) != 0 &&
-                       bcmp(eh->ether_dhost, etherbroadcastaddr,
-                               sizeof(eh->ether_dhost)) != 0) {
+                   bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
+                        sizeof(eh->ether_dhost)) != 0 &&
+                   bcmp(eh->ether_dhost, etherbroadcastaddr,
+                        sizeof(eh->ether_dhost)) != 0) {
 
 
-                       m_freem(head);
-                       return;
+                               m_freem(head);
+                               return;
                }
        }
 #endif
                }
        }
 #endif
@@ -1775,6 +2205,195 @@ bad:    if (head)
  * Supporting routines
  */
 
  * Supporting routines
  */
 
+/*
+ * Given a NIC memory source address and a host memory destination
+ *     address, copy 'amount' from NIC to host using Programmed I/O.
+ *     The 'amount' is rounded up to a word - okay as long as mbufs
+ *             are word sized.
+ *     This routine is currently Novell-specific.
+ */
+void
+ed_pio_readmem(sc,src,dst,amount)
+       struct  ed_softc *sc;
+       unsigned short src;
+       unsigned char *dst;
+       unsigned short amount;
+{
+       unsigned short tmp_amount;
+
+       /* select page 0 registers */
+       outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA);
+
+       /* round up to a word */
+       tmp_amount = amount;
+       if (amount & 1) ++amount;
+
+       /* set up DMA byte count */
+       outb(sc->nic_addr + ED_P0_RBCR0, amount);
+       outb(sc->nic_addr + ED_P0_RBCR1, amount>>8);
+
+       /* set up source address in NIC mem */
+       outb(sc->nic_addr + ED_P0_RSAR0, src);
+       outb(sc->nic_addr + ED_P0_RSAR1, src>>8);
+
+       outb(sc->nic_addr + ED_P0_CR, ED_CR_RD0 | ED_CR_STA);
+
+       if (sc->isa16bit) {
+               insw(sc->asic_addr + ED_NOVELL_DATA, dst, amount/2);
+       } else
+               insb(sc->asic_addr + ED_NOVELL_DATA, dst, amount);
+
+}
+
+/*
+ * Stripped down routine for writing a linear buffer to NIC memory.
+ *     Only used in the probe routine to test the memory. 'len' must
+ *     be even.
+ */
+void
+ed_pio_writemem(sc,src,dst,len)
+       struct ed_softc *sc;
+       char *src;
+       unsigned short dst;
+       unsigned short len;
+{
+       int maxwait=100; /* about 120us */
+
+       /* select page 0 registers */
+       outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA);
+
+       /* reset remote DMA complete flag */
+       outb(sc->nic_addr + ED_P0_ISR, ED_ISR_RDC);
+
+       /* set up DMA byte count */
+       outb(sc->nic_addr + ED_P0_RBCR0, len);
+       outb(sc->nic_addr + ED_P0_RBCR1, len>>8);
+
+       /* set up destination address in NIC mem */
+       outb(sc->nic_addr + ED_P0_RSAR0, dst);
+       outb(sc->nic_addr + ED_P0_RSAR1, dst>>8);
+
+       /* set remote DMA write */
+       outb(sc->nic_addr + ED_P0_CR, ED_CR_RD1 | ED_CR_STA);
+
+       if (sc->isa16bit)
+               outsw(sc->asic_addr + ED_NOVELL_DATA, src, len/2);
+       else
+               outsb(sc->asic_addr + ED_NOVELL_DATA, src, len);
+       /*
+        * Wait for remote DMA complete. This is necessary because on the
+        *      transmit side, data is handled internally by the NIC in bursts
+        *      and we can't start another remote DMA until this one completes.
+        *      Not waiting causes really bad things to happen - like the NIC
+        *      irrecoverably jamming the ISA bus.
+        */
+       while (((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait);
+}
+
+/*
+ * Write an mbuf chain to the destination NIC memory address using
+ *     programmed I/O.
+ */
+u_short
+ed_pio_write_mbufs(sc,m,dst)
+       struct ed_softc *sc;
+       struct mbuf *m;
+       unsigned short dst;
+{
+       unsigned short len, mb_offset;
+       struct mbuf *mp;
+       unsigned char residual[2];
+       int maxwait=100; /* about 120us */
+
+       /* First, count up the total number of bytes to copy */
+       for (len = 0, mp = m; mp; mp = mp->m_next)
+               len += mp->m_len;
+       
+       /* select page 0 registers */
+       outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA);
+
+       /* reset remote DMA complete flag */
+       outb(sc->nic_addr + ED_P0_ISR, ED_ISR_RDC);
+
+       /* set up DMA byte count */
+       outb(sc->nic_addr + ED_P0_RBCR0, len);
+       outb(sc->nic_addr + ED_P0_RBCR1, len>>8);
+
+       /* set up destination address in NIC mem */
+       outb(sc->nic_addr + ED_P0_RSAR0, dst);
+       outb(sc->nic_addr + ED_P0_RSAR1, dst>>8);
+
+       /* set remote DMA write */
+       outb(sc->nic_addr + ED_P0_CR, ED_CR_RD1 | ED_CR_STA);
+
+       mb_offset = 0;
+       /*
+        * Transfer the mbuf chain to the NIC memory.
+        * The following code isn't too pretty. The problem is that we can only
+        *      transfer words to the board, and if an mbuf has an odd number
+        *      of bytes in it, this is a problem. It's not a simple matter of
+        *      just removing a byte from the next mbuf (adjusting data++ and
+        *      len--) because this will hose-over the mbuf chain which might
+        *      be needed later for BPF. Instead, we maintain an offset
+        *      (mb_offset) which let's us skip over the first byte in the
+        *      following mbuf.
+        */
+       while (m) {
+               if (m->m_len - mb_offset) {
+                       if (sc->isa16bit) {
+                               if ((m->m_len - mb_offset) > 1)
+                                       outsw(sc->asic_addr + ED_NOVELL_DATA,
+                                             mtod(m, caddr_t) + mb_offset,
+                                             (m->m_len - mb_offset) / 2);
+
+                               /*
+                                * if odd number of bytes, get the odd byte from
+                                * the next mbuf with data
+                                */
+                               if ((m->m_len - mb_offset) & 1) {
+                                       /* first the last byte in current mbuf */
+                                       residual[0] = *(mtod(m, caddr_t) +
+                                               m->m_len - 1);
+                                       
+                                       /* advance past any empty mbufs */
+                                       while (m->m_next && (m->m_next->m_len == 0))
+                                               m = m->m_next;
+
+                                       if (m->m_next) {
+                                               /* remove first byte in next mbuf */
+                                               residual[1] = *(mtod(m->m_next, caddr_t));
+                                               mb_offset = 1;
+                                       }
+
+                                       outw(sc->asic_addr + ED_NOVELL_DATA,
+                                            *((unsigned short *) residual));
+                               } else
+                                       mb_offset = 0;
+                       } else
+                               outsb(sc->asic_addr + ED_NOVELL_DATA, m->m_data, m->m_len);
+
+               }
+               m = m->m_next;
+       }
+
+       /*
+        * Wait for remote DMA complete. This is necessary because on the
+        *      transmit side, data is handled internally by the NIC in bursts
+        *      and we can't start another remote DMA until this one completes.
+        *      Not waiting causes really bad things to happen - like the NIC
+        *      irrecoverably jamming the ISA bus.
+        */
+       while (((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait);
+
+       if (!maxwait) {
+               log(LOG_WARNING, "ed%d: remote transmit DMA failed to complete\n",
+                   sc->arpcom.ac_if.if_unit);
+               ed_reset(sc->arpcom.ac_if.if_unit, 0);
+       }
+
+       return(len);
+}
+       
 /*
  * Given a source and destination address, copy 'amount' of a packet from
  *     the ring buffer into a linear destination buffer. Takes into account
 /*
  * Given a source and destination address, copy 'amount' of a packet from
  *     the ring buffer into a linear destination buffer. Takes into account
@@ -1790,15 +2409,24 @@ ed_ring_copy(sc,src,dst,amount)
        u_short tmp_amount;
 
        /* does copy wrap to lower addr in ring buffer? */
        u_short tmp_amount;
 
        /* does copy wrap to lower addr in ring buffer? */
-       if (src + amount > sc->smem_end) {
-               tmp_amount = sc->smem_end - src;
-               bcopy(src,dst,tmp_amount); /* copy amount up to end of smem */
+       if (src + amount > sc->mem_end) {
+               tmp_amount = sc->mem_end - src;
+
+               /* copy amount up to end of NIC memory */
+               if (sc->mem_shared)
+                       bcopy(src,dst,tmp_amount);
+               else
+                       ed_pio_readmem(sc,src,dst,tmp_amount);
+
                amount -= tmp_amount;
                amount -= tmp_amount;
-               src = sc->smem_ring;
+               src = sc->mem_ring;
                dst += tmp_amount;
        }
 
                dst += tmp_amount;
        }
 
-       bcopy(src, dst, amount);
+       if (sc->mem_shared)
+               bcopy(src, dst, amount);
+       else
+               ed_pio_readmem(sc, src, dst, amount);
 
        return(src + amount);
 }
 
        return(src + amount);
 }