summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormdodd <mdodd@FreeBSD.org>1999-10-01 05:24:27 +0000
committermdodd <mdodd@FreeBSD.org>1999-10-01 05:24:27 +0000
commite123ea963c6e909702e748715f7c3a74b5a62a20 (patch)
tree73691cf9bffefb4657701441d1950f85f28ba635
parent59dde7eac28dcc567b030f8ca04c984fac198912 (diff)
downloadFreeBSD-src-e123ea963c6e909702e748715f7c3a74b5a62a20.zip
FreeBSD-src-e123ea963c6e909702e748715f7c3a74b5a62a20.tar.gz
Turn off and remove the 'old' if_ep ISA/EISA/PCCARD driver.
Turn on the 'new' if_ep driver which supports: ISA 3c509 MCA 3c529 EISA 3c579 PCCARD 3c589 I think all we're missing is support for the VME bus and S-100 bus Etherlink III cards. The new code has been tested by a number of people and all the important bits work. I've not been able to test the EISA code but will do so once my hardware arrives. Since I've changed nothing in the EISA code I suspect it will perform the same manner as before. Future changes involve whacking the ISA and PCCARD front ends to use newbus and to convert the driver to bus_space and make it use ifmedia. This is the first working network driver that supports MCA bus devices btw. Enjoy.
-rw-r--r--sys/conf/files9
-rw-r--r--sys/conf/files.i3862
-rw-r--r--sys/i386/conf/files.i3862
-rw-r--r--sys/i386/eisa/3c5x9.c309
-rw-r--r--sys/i386/isa/if_ep.c1387
-rw-r--r--sys/i386/isa/if_epreg.h471
-rw-r--r--sys/i386/isa/wd.c18
7 files changed, 25 insertions, 2173 deletions
diff --git a/sys/conf/files b/sys/conf/files
index 0bee687..4d54338 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -94,11 +94,17 @@ dev/aic7xxx/aic7xxx.c optional ahc \
dependency "aic7xxx_{reg,seq}.h"
dev/aic7xxx/93cx6.c optional ahc
dev/buslogic/bt.c optional bt
+dev/buslogic/bt_mca.c optional bt mca
dev/ccd/ccd.c optional ccd
#dev/dpt/dpt_control.c optional dpt
dev/dpt/dpt_scsi.c optional dpt
dev/ed/if_ed_pci.c optional ed pci
dev/en/midway.c optional en
+dev/ep/if_ep.c optional ep
+dev/ep/if_ep_isa.c optional ep isa
+dev/ep/if_ep_eisa.c optional ep eisa
+dev/ep/if_ep_mca.c optional ep mca
+dev/ep/if_ep_pccard.c optional ep card
dev/hea/eni.c optional hea
dev/hea/eni_buffer.c optional hea
dev/hea/eni_globals.c optional hea
@@ -125,6 +131,7 @@ dev/ida/ida.c optional ida
dev/ida/ida_disk.c optional id
dev/isp/isp_freebsd.c optional isp
dev/isp/isp.c optional isp
+dev/mca/mca_bus.c optional mca
dev/md/md.c optional md
dev/mii/mii.c optional miibus
dev/mii/mii_physubr.c optional miibus
@@ -794,5 +801,3 @@ dev/pcm/isa/sb.c optional pcm isa
dev/pcm/pci/es1370.c optional pcm pci
dev/pcm/pci/t4dwave.c optional pcm pci
#dev/pcm/pci/aureal.c optional pcm pci
-dev/mca/mca_bus.c optional mca
-dev/buslogic/bt_mca.c optional bt mca
diff --git a/sys/conf/files.i386 b/sys/conf/files.i386
index 6ab836e..c6e2b69 100644
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
@@ -110,7 +110,6 @@ gnu/i386/isa/dgb.c optional dgb
gnu/i386/isa/dgm.c optional dgm
gnu/i386/isa/sound/awe_wave.c optional awe
i386/apm/apm.c optional apm
-i386/eisa/3c5x9.c optional ep
i386/eisa/adv_eisa.c optional adv
i386/eisa/ahb.c optional ahb
i386/eisa/ahc_eisa.c optional eisa ahc \
@@ -199,7 +198,6 @@ i386/isa/if_ar.c optional ar
i386/isa/if_cs.c optional cs
i386/isa/if_cx.c optional cx
i386/isa/if_el.c optional el
-i386/isa/if_ep.c optional ep
i386/isa/if_ex.c optional ex
i386/isa/if_fe.c optional fe
i386/isa/if_ie.c optional ie
diff --git a/sys/i386/conf/files.i386 b/sys/i386/conf/files.i386
index 6ab836e..c6e2b69 100644
--- a/sys/i386/conf/files.i386
+++ b/sys/i386/conf/files.i386
@@ -110,7 +110,6 @@ gnu/i386/isa/dgb.c optional dgb
gnu/i386/isa/dgm.c optional dgm
gnu/i386/isa/sound/awe_wave.c optional awe
i386/apm/apm.c optional apm
-i386/eisa/3c5x9.c optional ep
i386/eisa/adv_eisa.c optional adv
i386/eisa/ahb.c optional ahb
i386/eisa/ahc_eisa.c optional eisa ahc \
@@ -199,7 +198,6 @@ i386/isa/if_ar.c optional ar
i386/isa/if_cs.c optional cs
i386/isa/if_cx.c optional cx
i386/isa/if_el.c optional el
-i386/isa/if_ep.c optional ep
i386/isa/if_ex.c optional ex
i386/isa/if_fe.c optional fe
i386/isa/if_ie.c optional ie
diff --git a/sys/i386/eisa/3c5x9.c b/sys/i386/eisa/3c5x9.c
deleted file mode 100644
index 663409d..0000000
--- a/sys/i386/eisa/3c5x9.c
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * Product specific probe and attach routines for:
- * 3COM 3C579 and 3C509(in eisa config mode) ethernet controllers
- *
- * Copyright (c) 1996 Justin T. Gibbs
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice immediately at the beginning of the file, without modification,
- * this list of conditions, and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Absolutely no warranty of function or purpose is made by the author
- * Justin T. Gibbs.
- * 4. Modifications may be freely made to this file if the above conditions
- * are met.
- *
- * $FreeBSD$
- */
-
-#include "eisa.h"
-#if NEISA > 0
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/socket.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-
-#include <machine/clock.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/rman.h>
-
-#include <net/if.h>
-
-#include <netinet/in.h>
-#include <netinet/if_ether.h>
-
-#include <i386/isa/if_epreg.h>
-#include <i386/eisa/eisaconf.h>
-
-#define EISA_DEVICE_ID_3COM_3C509_TP 0x506d5090
-#define EISA_DEVICE_ID_3COM_3C509_BNC 0x506d5091
-#define EISA_DEVICE_ID_3COM_3C579_TP 0x506d5092
-#define EISA_DEVICE_ID_3COM_3C579_BNC 0x506d5093
-#define EISA_DEVICE_ID_3COM_3C509_COMBO 0x506d5094
-#define EISA_DEVICE_ID_3COM_3C509_TPO 0x506d5095
-
-#define EP_EISA_SLOT_OFFSET 0x0c80
-#define EP_EISA_IOSIZE 0x000a
-
-#define EISA_IOCONF 0x0008
-#define IRQ_CHANNEL 0xf000
-#define INT_3 0x3000
-#define INT_5 0x5000
-#define INT_7 0x7000
-#define INT_9 0x9000
-#define INT_10 0xa000
-#define INT_11 0xb000
-#define INT_12 0xc000
-#define INT_15 0xf000
-#define EISA_BPROM_MEDIA_CONF 0x0006
-#define TRANS_TYPE 0xc000
-#define TRANS_TP 0x0000
-#define TRANS_AUI 0x4000
-#define TRANS_BNC 0xc000
-
-static const char *ep_match __P((eisa_id_t type));
-
-static const char*
-ep_match(eisa_id_t type)
-{
- switch(type) {
- case EISA_DEVICE_ID_3COM_3C509_TP:
- return "3Com 3C509-TP Network Adapter";
- break;
- case EISA_DEVICE_ID_3COM_3C509_BNC:
- return "3Com 3C509-BNC Network Adapter";
- break;
- case EISA_DEVICE_ID_3COM_3C579_TP:
- return "3Com 3C579-TP EISA Network Adapter";
- break;
- case EISA_DEVICE_ID_3COM_3C579_BNC:
- return "3Com 3C579-BNC EISA Network Adapter";
- break;
- case EISA_DEVICE_ID_3COM_3C509_COMBO:
- return "3Com 3C509-Combo Network Adapter";
- break;
- case EISA_DEVICE_ID_3COM_3C509_TPO:
- return "3Com 3C509-TPO Network Adapter";
- break;
- default:
- break;
- }
- return (NULL);
-}
-
-static int
-ep_eisa_probe(device_t dev)
-{
- const char *desc;
- u_long iobase;
- u_short conf;
- u_long port;
- int irq;
-
- desc = ep_match(eisa_get_id(dev));
- if (!desc)
- return (ENXIO);
- device_set_desc(dev, desc);
-
- port = (eisa_get_slot(dev) * EISA_SLOT_SIZE);
- iobase = port + EP_EISA_SLOT_OFFSET;
-
- /* We must be in EISA configuration mode */
- if ((inw(iobase + EP_W0_ADDRESS_CFG) & 0x1f) != 0x1f)
- return ENXIO;
-
- eisa_add_iospace(dev, iobase, EP_EISA_IOSIZE, RESVADDR_NONE);
- eisa_add_iospace(dev, port, EP_IOSIZE, RESVADDR_NONE);
-
- conf = inw(iobase + EISA_IOCONF);
- /* Determine our IRQ */
- switch (conf & IRQ_CHANNEL) {
- case INT_3:
- irq = 3;
- break;
- case INT_5:
- irq = 5;
- break;
- case INT_7:
- irq = 7;
- break;
- case INT_9:
- irq = 9;
- break;
- case INT_10:
- irq = 10;
- break;
- case INT_11:
- irq = 11;
- break;
- case INT_12:
- irq = 12;
- break;
- case INT_15:
- irq = 15;
- break;
- default:
- /* Disabled */
- printf("ep: 3COM Network Adapter at "
- "slot %d has its IRQ disabled. "
- "Probe failed.\n",
- eisa_get_slot(dev));
- return ENXIO;
- }
- eisa_add_intr(dev, irq, EISA_TRIGGER_EDGE);
-
- return 0;
-}
-
-static int
-ep_eisa_attach(device_t dev)
-{
- struct ep_softc *sc;
- struct ep_board *epb;
- struct resource *io = 0;
- struct resource *eisa_io = 0;
- struct resource *irq = 0;
- int unit = device_get_unit(dev);
- u_char level_intr;
- int i, rid, shared;
- void *ih;
-
- /*
- * The addresses are sorted in increasing order
- * so we know the port to pass to the core ep
- * driver comes first.
- */
- rid = 0;
- io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- 0, ~0, 1, RF_ACTIVE);
- if (!io) {
- device_printf(dev, "No I/O space?!\n");
- goto bad;
- }
-
- rid = 1;
- eisa_io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- 0, ~0, 1, RF_ACTIVE);
- if (!eisa_io) {
- device_printf(dev, "No I/O space?!\n");
- goto bad;
- }
-
- epb = &ep_board[ep_boards];
-
- epb->epb_addr = rman_get_start(io);
- epb->epb_used = 1;
-
- if(!(sc = ep_alloc(unit, epb)))
- goto bad;
-
- ep_boards++;
-
- sc->stat = 0;
- level_intr = FALSE;
- switch(eisa_get_id(dev)) {
- case EISA_DEVICE_ID_3COM_3C509_TP:
- sc->ep_connectors = UTP|AUI;
- break;
- case EISA_DEVICE_ID_3COM_3C509_BNC:
- sc->ep_connectors = BNC|AUI;
- break;
- case EISA_DEVICE_ID_3COM_3C579_TP:
- sc->ep_connectors = UTP|AUI;
- sc->stat = F_ACCESS_32_BITS;
- level_intr = TRUE;
- break;
- case EISA_DEVICE_ID_3COM_3C579_BNC:
- sc->ep_connectors = BNC|AUI;
- sc->stat = F_ACCESS_32_BITS;
- level_intr = TRUE;
- break;
- case EISA_DEVICE_ID_3COM_3C509_COMBO:
- sc->ep_connectors = UTP|BNC|AUI;
- break;
- case EISA_DEVICE_ID_3COM_3C509_TPO:
- sc->ep_connectors = UTP;
- break;
- default:
- break;
- }
- /*
- * Set the eisa config selected media type
- */
- sc->ep_connector = inw(rman_get_start(eisa_io) + EISA_BPROM_MEDIA_CONF)
- >> ACF_CONNECTOR_BITS;
-
- shared = level_intr ? RF_SHAREABLE : 0;
- rid = 0;
- irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
- 0, ~0, 1, shared | RF_ACTIVE);
- if (!irq) {
- device_printf(dev, "No irq?!\n");
- goto bad;
- }
-
- /* Reset and Enable the card */
- outb(rman_get_start(eisa_io) + EP_W0_CONFIG_CTRL, W0_P4_CMD_RESET_ADAPTER);
- DELAY(1000); /* we must wait at least 1 ms */
- outb(rman_get_start(eisa_io) + EP_W0_CONFIG_CTRL, W0_P4_CMD_ENABLE_ADAPTER);
-
- /* Now the registers are availible through the lower ioport */
-
- /*
- * Retrieve our ethernet address
- */
- GO_WINDOW(0);
- for(i = 0; i < 3; i++)
- sc->epb->eth_addr[i] = get_e(sc, i);
-
- /* Even we get irq number from board, we should tell him..
- Otherwise we never get a H/W interrupt anymore...*/
- if ( rman_get_start(irq) == 9 )
- rman_get_start(irq) = 2;
- SET_IRQ(rman_get_start(eisa_io), rman_get_start(irq));
-
- ep_attach(sc);
-
- bus_setup_intr(dev, irq, INTR_TYPE_NET, ep_intr, sc, &ih);
-
- return 0;
-
- bad:
- if (io)
- bus_release_resource(dev, SYS_RES_IOPORT, 0, io);
- if (eisa_io)
- bus_release_resource(dev, SYS_RES_IOPORT, 0, eisa_io);
- if (irq)
- bus_release_resource(dev, SYS_RES_IRQ, 0, irq);
- return -1;
-}
-
-static device_method_t ep_eisa_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, ep_eisa_probe),
- DEVMETHOD(device_attach, ep_eisa_attach),
-
- { 0, 0 }
-};
-
-static driver_t ep_eisa_driver = {
- "ep",
- ep_eisa_methods,
- 1, /* unused */
-};
-
-static devclass_t ep_devclass;
-
-DRIVER_MODULE(ep, eisa, ep_eisa_driver, ep_devclass, 0, 0);
-
-#endif /* NEISA > 0 */
diff --git a/sys/i386/isa/if_ep.c b/sys/i386/isa/if_ep.c
deleted file mode 100644
index 4ee050d..0000000
--- a/sys/i386/isa/if_ep.c
+++ /dev/null
@@ -1,1387 +0,0 @@
-/*
- * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Herb Peyerl.
- * 4. The name of Herb Peyerl may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * if_ep.c,v 1.19 1995/01/24 20:53:45 davidg Exp
- */
-
-/*
- * Modified from the FreeBSD 1.1.5.1 version by:
- * Andres Vega Garcia
- * INRIA - Sophia Antipolis, France
- * avega@sophia.inria.fr
- */
-
-/*
- * $FreeBSD$
- *
- * Promiscuous mode added and interrupt logic slightly changed
- * to reduce the number of adapter failures. Transceiver select
- * logic changed to use value from EEPROM. Autoconfiguration
- * features added.
- * Done by:
- * Serge Babkin
- * Chelindbank (Chelyabinsk, Russia)
- * babkin@hq.icb.chel.su
- */
-
-/*
- * Pccard support for 3C589 by:
- * HAMADA Naoki
- * nao@tom-yam.or.jp
- */
-
-#include "ep.h"
-#if NEP > 0
-
-#include "opt_inet.h"
-#include "opt_ipx.h"
-
-#include <sys/param.h>
-#if defined(__FreeBSD__)
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#endif
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#if defined(__NetBSD__)
-#include <sys/select.h>
-#endif
-
-#include <net/ethernet.h>
-#include <net/if.h>
-
-#include <netinet/in.h>
-#include <netinet/if_ether.h>
-
-#include <net/bpf.h>
-
-#if defined(__FreeBSD__)
-#include <machine/clock.h>
-#endif
-
-#include <i386/isa/isa_device.h>
-#include <i386/isa/if_epreg.h>
-#include <i386/isa/elink.h>
-
-/* DELAY_MULTIPLE: How much to boost "base" delays, except
- * for the inter-bit delays in get_eeprom_data. A cyrix Media GX needed this.
- */
-#define DELAY_MULTIPLE 10
-#define BIT_DELAY_MULTIPLE 10
-
-/* Exported variables */
-u_long ep_unit;
-int ep_boards;
-struct ep_board ep_board[EP_MAX_BOARDS + 1];
-
-static int eeprom_rdy __P((struct ep_softc *sc));
-
-static int ep_isa_probe __P((struct isa_device *));
-static struct ep_board * ep_look_for_board_at __P((struct isa_device *is));
-static int ep_isa_attach __P((struct isa_device *));
-static int epioctl __P((struct ifnet * ifp, u_long, caddr_t));
-
-static void epinit __P((void *));
-static ointhand2_t epintr;
-static void epread __P((struct ep_softc *));
-void epreset __P((int));
-static void epstart __P((struct ifnet *));
-static void epstop __P((struct ep_softc *));
-static void epwatchdog __P((struct ifnet *));
-
-#if 0
-static int send_ID_sequence __P((int));
-#endif
-static int get_eeprom_data __P((int, int));
-
-static struct ep_softc* ep_softc[NEP];
-static int ep_current_tag = EP_LAST_TAG + 1;
-static char *ep_conn_type[] = {"UTP", "AUI", "???", "BNC"};
-
-#define ep_ftst(f) (sc->stat&(f))
-#define ep_fset(f) (sc->stat|=(f))
-#define ep_frst(f) (sc->stat&=~(f))
-
-struct isa_driver epdriver = {
- ep_isa_probe,
- ep_isa_attach,
- "ep",
- 0
-};
-
-#include "card.h"
-
-#if NCARD > 0
-#include <sys/select.h>
-#include <sys/module.h>
-#include <pccard/cardinfo.h>
-#include <pccard/slot.h>
-
-/*
- * PC-Card (PCMCIA) specific code.
- */
-static int ep_pccard_init __P((struct pccard_devinfo *));
-static int ep_pccard_attach __P((struct pccard_devinfo *));
-static void ep_unload __P((struct pccard_devinfo *));
-static int card_intr __P((struct pccard_devinfo *));
-static int ep_pccard_identify (struct ep_board *epb, int unit);
-
-PCCARD_MODULE(ep, ep_pccard_init, ep_unload, card_intr, 0, net_imask);
-
-/*
- * Initialize the device - called from Slot manager.
- */
-static int
-ep_pccard_init(devi)
- struct pccard_devinfo *devi;
-{
- struct isa_device *is = &devi->isahd;
- struct ep_softc *sc = ep_softc[is->id_unit];
- struct ep_board *epb;
- int i;
-
- epb = &ep_board[is->id_unit];
-
- if (sc == 0) {
- if ((sc = ep_alloc(is->id_unit, epb)) == 0) {
- return (ENXIO);
- }
- ep_unit++;
- }
-
- /* get_e() requires these. */
- sc->ep_io_addr = is->id_iobase;
- sc->unit = is->id_unit;
- epb->epb_addr = is->id_iobase;
- epb->epb_used = 1;
-
- /*
- * XXX - Certain (newer?) 3Com cards need epb->cmd_off == 2. Sadly,
- * you need to have a correct cmd_off in order to identify the card.
- * So we have to hit it with both and cross our virtual fingers. There's
- * got to be a better way to do this. jyoung@accessus.net 09/11/1999
- */
-
- epb->cmd_off = 0;
- epb->prod_id = get_e(sc, EEPROM_PROD_ID);
- if (!ep_pccard_identify(epb, is->id_unit)) {
- if (bootverbose) printf("ep%d: Pass 1 of 2 detection failed (nonfatal)\n", is->id_unit);
- epb->cmd_off = 2;
- epb->prod_id = get_e(sc, EEPROM_PROD_ID);
- if (!ep_pccard_identify(epb, is->id_unit)) {
- if (bootverbose) printf("ep%d: Pass 2 of 2 detection failed (fatal!)\n", is->id_unit);
- printf("ep%d: Unit failed to come ready or product ID unknown! (id 0x%x)\n", is->id_unit, epb->prod_id);
- return (ENXIO);
- }
- }
-
- epb->res_cfg = get_e(sc, EEPROM_RESOURCE_CFG);
- for (i = 0; i < 3; i++)
- sc->epb->eth_addr[i] = get_e(sc, EEPROM_NODE_ADDR_0 + i);
-
- if (ep_pccard_attach(devi) == 0)
- return (ENXIO);
-
- sc->arpcom.ac_if.if_snd.ifq_maxlen = ifqmaxlen;
- return (0);
-}
-
-static int
-ep_pccard_identify(epb, unit)
- struct ep_board *epb;
- int unit;
-{
- /* Determine device type and associated MII capabilities */
- switch (epb->prod_id) {
- case 0x6055: /* 3C556 */
- if (bootverbose) printf("ep%d: 3Com 3C556\n", unit);
- epb->mii_trans = 1;
- return (1);
- break; /* NOTREACHED */
- case 0x4057: /* 3C574 */
- if (bootverbose) printf("ep%d: 3Com 3C574\n", unit);
- epb->mii_trans = 1;
- return (1);
- break; /* NOTREACHED */
- case 0x4b57: /* 3C574B */
- if (bootverbose) printf("ep%d: 3Com 3C574B, Megahertz 3CCFE574BT or Fast Etherlink 3C574-TX\n", unit);
- epb->mii_trans = 1;
- return (1);
- break; /* NOTREACHED */
- case 0x9058: /* 3C589 */
- if (bootverbose) printf("ep%d: 3Com Etherlink III 3C589[B/C/D]\n", unit);
- epb->mii_trans = 0;
- return (1);
- break; /* NOTREACHED */
- }
- return (0);
-}
-
-static int
-ep_pccard_attach(devi)
- struct pccard_devinfo *devi;
-{
- struct isa_device *is = &devi->isahd;
- struct ep_softc *sc = ep_softc[is->id_unit];
- u_short config;
-
- sc->ep_connectors = 0;
- config = inw(IS_BASE + EP_W0_CONFIG_CTRL);
- if (config & IS_BNC) {
- sc->ep_connectors |= BNC;
- }
- if (config & IS_UTP) {
- sc->ep_connectors |= UTP;
- }
- if (!(sc->ep_connectors & 7))
- /* (Apparently) non-fatal */
- if(bootverbose) printf("ep%d: No connectors or MII.\n", is->id_unit);
-
- sc->ep_connector = inw(BASE + EP_W0_ADDRESS_CFG) >> ACF_CONNECTOR_BITS;
-
- /* ROM size = 0, ROM base = 0 */
- /* For now, ignore AUTO SELECT feature of 3C589B and later. */
- outw(BASE + EP_W0_ADDRESS_CFG, get_e(sc, EEPROM_ADDR_CFG) & 0xc000);
-
- /* Fake IRQ must be 3 */
- outw(BASE + EP_W0_RESOURCE_CFG, (sc->epb->res_cfg & 0x0fff) | 0x3000);
-
- outw(BASE + EP_W0_PRODUCT_ID, sc->epb->prod_id);
-
- if (sc->epb->mii_trans) {
- /*
- * turn on the MII transciever
- */
- GO_WINDOW(3);
- outw(BASE + EP_W3_OPTIONS, 0x8040);
- DELAY(1000);
- outw(BASE + EP_W3_OPTIONS, 0xc040);
- outw(BASE + EP_COMMAND, RX_RESET);
- outw(BASE + EP_COMMAND, TX_RESET);
- while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
- DELAY(1000);
- outw(BASE + EP_W3_OPTIONS, 0x8040);
- }
-
- ep_attach(sc);
-
- return 1;
-}
-
-static void
-ep_unload(devi)
- struct pccard_devinfo *devi;
-{
- struct ep_softc *sc = ep_softc[devi->isahd.id_unit];
-
- if (sc->gone) {
- printf("ep%d: already unloaded\n", devi->isahd.id_unit);
- return;
- }
- sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING;
- sc->gone = 1;
- printf("ep%d: unload\n", devi->isahd.id_unit);
-}
-
-/*
- * card_intr - Shared interrupt called from
- * front end of PC-Card handler.
- */
-static int
-card_intr(devi)
- struct pccard_devinfo *devi;
-{
- epintr(devi->isahd.id_unit);
- return(1);
-}
-#endif /* NCARD > 0 */
-
-static int
-eeprom_rdy(sc)
- struct ep_softc *sc;
-{
- int i;
-
- for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++)
- continue;
- if (i >= MAX_EEPROMBUSY) {
- printf("ep%d: eeprom failed to come ready.\n", sc->unit);
- return (0);
- }
- return (1);
-}
-
-static struct ep_board *
-ep_look_for_board_at(is)
- struct isa_device *is;
-{
- int data, i, j, id_port = ELINK_ID_PORT;
- int count = 0;
-
- if (ep_current_tag == (EP_LAST_TAG + 1)) {
- /* Come here just one time */
-
- ep_current_tag--;
-
- /* Look for the ISA boards. Init and leave them actived */
- outb(id_port, 0);
- outb(id_port, 0);
-
- elink_idseq(0xCF);
-
- elink_reset();
- DELAY(DELAY_MULTIPLE * 10000);
- for (i = 0; i < EP_MAX_BOARDS; i++) {
- outb(id_port, 0);
- outb(id_port, 0);
- elink_idseq(0xCF);
-
- data = get_eeprom_data(id_port, EEPROM_MFG_ID);
- if (data != MFG_ID)
- break;
-
- /* resolve contention using the Ethernet address */
-
- for (j = 0; j < 3; j++)
- get_eeprom_data(id_port, j);
-
- /* and save this address for later use */
-
- for (j = 0; j < 3; j++)
- ep_board[ep_boards].eth_addr[j] = get_eeprom_data(id_port, j);
-
- ep_board[ep_boards].res_cfg =
- get_eeprom_data(id_port, EEPROM_RESOURCE_CFG);
-
- ep_board[ep_boards].prod_id =
- get_eeprom_data(id_port, EEPROM_PROD_ID);
-
- ep_board[ep_boards].epb_used = 0;
-#ifdef PC98
- ep_board[ep_boards].epb_addr =
- (get_eeprom_data(id_port, EEPROM_ADDR_CFG) & 0x1f) * 0x100 + 0x40d0;
-#else
- ep_board[ep_boards].epb_addr =
- (get_eeprom_data(id_port, EEPROM_ADDR_CFG) & 0x1f) * 0x10 + 0x200;
-
- if (ep_board[ep_boards].epb_addr > 0x3E0)
- /* Board in EISA configuration mode */
- continue;
-#endif /* PC98 */
-
- outb(id_port, ep_current_tag); /* tags board */
- outb(id_port, ACTIVATE_ADAPTER_TO_CONFIG);
- ep_boards++;
- count++;
- ep_current_tag--;
- }
-
- ep_board[ep_boards].epb_addr = 0;
- if (count) {
- printf("%d 3C5x9 board(s) on ISA found at", count);
- for (j = 0; ep_board[j].epb_addr; j++)
- if (ep_board[j].epb_addr <= 0x3E0)
- printf(" 0x%x", ep_board[j].epb_addr);
- printf("\n");
- }
- }
-
- /* we have two cases:
- *
- * 1. Device was configured with 'port ?'
- * In this case we search for the first unused card in list
- *
- * 2. Device was configured with 'port xxx'
- * In this case we search for the unused card with that address
- *
- */
-
- if (IS_BASE == -1) { /* port? */
- for (i = 0; ep_board[i].epb_addr && ep_board[i].epb_used; i++)
- ;
- if (ep_board[i].epb_addr == 0)
- return 0;
-
- IS_BASE = ep_board[i].epb_addr;
- ep_board[i].epb_used = 1;
-
- return &ep_board[i];
- } else {
- for (i = 0;
- ep_board[i].epb_addr && ep_board[i].epb_addr != IS_BASE;
- i++)
- ;
-
- if (ep_board[i].epb_used || ep_board[i].epb_addr != IS_BASE)
- return 0;
-
- if (inw(IS_BASE + EP_W0_EEPROM_COMMAND) & EEPROM_TST_MODE) {
- printf("ep%d: 3c5x9 at 0x%x in PnP mode. Disable PnP mode!\n",
- is->id_unit, IS_BASE);
- }
- ep_board[i].epb_used = 1;
-
- return &ep_board[i];
- }
-}
-
-/*
- * get_e: gets a 16 bits word from the EEPROM. we must have set the window
- * before
- */
-u_int16_t
-get_e(sc, offset)
- struct ep_softc *sc;
- int offset;
-{
- if (!eeprom_rdy(sc))
- return (0xffff);
- outw(BASE + EP_W0_EEPROM_COMMAND, (EEPROM_CMD_RD << sc->epb->cmd_off) | offset);
- if (!eeprom_rdy(sc))
- return (0xffff);
- return (inw(BASE + EP_W0_EEPROM_DATA));
-}
-
-struct ep_softc *
-ep_alloc(unit, epb)
- int unit;
- struct ep_board *epb;
-{
- struct ep_softc *sc;
-
- if (unit >= NEP) {
- printf("ep: unit number (%d) too high\n", unit);
- return NULL;
- }
-
- /*
- * Allocate a storage area for us
- */
- if (ep_softc[unit]) {
- printf("ep%d: unit number already allocated to another "
- "adaptor\n", unit);
- return NULL;
- }
-
- sc = malloc(sizeof(struct ep_softc), M_DEVBUF, M_NOWAIT);
- if (!sc) {
- printf("ep%d: cannot malloc!\n", unit);
- return NULL;
- }
- bzero(sc, sizeof(struct ep_softc));
- ep_softc[unit] = sc;
- sc->unit = unit;
- sc->ep_io_addr = epb->epb_addr;
- sc->epb = epb;
-
- return(sc);
-}
-
-void
-ep_free(sc)
- struct ep_softc *sc;
-{
- ep_softc[sc->unit] = NULL;
- free(sc, M_DEVBUF);
- return;
-}
-
-int
-ep_isa_probe(is)
- struct isa_device *is;
-{
- struct ep_softc *sc;
- struct ep_board *epb;
- u_short k;
-
- if ((epb = ep_look_for_board_at(is)) == 0)
- return (0);
-
- /*
- * Allocate a storage area for us
- */
- sc = ep_alloc(ep_unit, epb);
- if (!sc)
- return (0);
-
- is->id_unit = ep_unit++;
-
- /*
- * The iobase was found and MFG_ID was 0x6d50. PROD_ID should be
- * 0x9[0-f]50 (IBM-PC)
- * 0x9[0-f]5[0-f] (PC-98)
- */
- GO_WINDOW(0);
- k = sc->epb->prod_id;
-#ifdef PC98
- if ((k & 0xf0f0) != (PROD_ID & 0xf0f0)) {
-#else
- if ((k & 0xf0ff) != (PROD_ID & 0xf0ff)) {
-#endif
- printf("ep_isa_probe: ignoring model %04x\n", k);
- ep_free(sc);
- return (0);
- }
-
- k = sc->epb->res_cfg;
-
- k >>= 12;
-
- /* Now we have two cases again:
- *
- * 1. Device was configured with 'irq?'
- * In this case we use irq read from the board
- *
- * 2. Device was configured with 'irq xxx'
- * In this case we set up the board to use specified interrupt
- *
- */
-
- if (is->id_irq == 0) { /* irq? */
- is->id_irq = 1 << ((k == 2) ? 9 : k);
- }
-
- sc->stat = 0; /* 16 bit access */
-
- /* By now, the adapter is already activated */
-
- return (EP_IOSIZE); /* 16 bytes of I/O space used. */
-}
-
-static int
-ep_isa_attach(is)
- struct isa_device *is;
-{
- struct ep_softc *sc = ep_softc[is->id_unit];
- u_short config;
- int irq;
-
- is->id_ointr = epintr;
- sc->ep_connectors = 0;
- config = inw(IS_BASE + EP_W0_CONFIG_CTRL);
- if (config & IS_AUI) {
- sc->ep_connectors |= AUI;
- }
- if (config & IS_BNC) {
- sc->ep_connectors |= BNC;
- }
- if (config & IS_UTP) {
- sc->ep_connectors |= UTP;
- }
- if (!(sc->ep_connectors & 7))
- printf("no connectors!");
- sc->ep_connector = inw(BASE + EP_W0_ADDRESS_CFG) >> ACF_CONNECTOR_BITS;
- /*
- * Write IRQ value to board
- */
-
- irq = ffs(is->id_irq) - 1;
- if (irq == -1) {
- printf(" invalid irq... cannot attach\n");
- return 0;
- }
-
- GO_WINDOW(0);
- SET_IRQ(BASE, irq);
-
- ep_attach(sc);
- return 1;
-}
-
-int
-ep_attach(sc)
- struct ep_softc *sc;
-{
- struct ifnet *ifp = &sc->arpcom.ac_if;
- u_short *p;
- int i;
- int attached;
-
- sc->gone = 0;
- attached = (ifp->if_softc != 0);
-
- printf("ep%d: ", sc->unit);
- /*
- * Current media type
- */
- if (sc->ep_connectors & AUI) {
- printf("aui");
- if (sc->ep_connectors & ~AUI)
- printf("/");
- }
- if (sc->ep_connectors & UTP) {
- printf("utp");
- if (sc->ep_connectors & BNC)
- printf("/");
- }
- if (sc->ep_connectors & BNC) {
- printf("bnc");
- }
-
- printf("[*%s*]", ep_conn_type[sc->ep_connector]);
-
- /*
- * Setup the station address
- */
- p = (u_short *) & sc->arpcom.ac_enaddr;
- GO_WINDOW(2);
- for (i = 0; i < 3; i++) {
- p[i] = htons(sc->epb->eth_addr[i]);
- outw(BASE + EP_W2_ADDR_0 + (i * 2), ntohs(p[i]));
- }
- printf(" address %6D\n", sc->arpcom.ac_enaddr, ":");
-
- ifp->if_softc = sc;
- ifp->if_unit = sc->unit;
- ifp->if_name = "ep";
- ifp->if_mtu = ETHERMTU;
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_output = ether_output;
- ifp->if_start = epstart;
- ifp->if_ioctl = epioctl;
- ifp->if_watchdog = epwatchdog;
- ifp->if_init = epinit;
-
- if (!attached) {
- if_attach(ifp);
- ether_ifattach(ifp);
- }
-
-#ifdef EP_LOCAL_STATS
- sc->rx_no_first = sc->rx_no_mbuf =
- sc->rx_bpf_disc = sc->rx_overrunf = sc->rx_overrunl =
- sc->tx_underrun = 0;
-#endif
- ep_fset(F_RX_FIRST);
- sc->top = sc->mcur = 0;
-
- if (!attached) {
- bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
- }
- return 0;
-}
-
-
-/*
- * The order in here seems important. Otherwise we may not receive
- * interrupts. ?!
- */
-static void
-epinit(xsc)
- void *xsc;
-{
- struct ep_softc *sc = xsc;
- register struct ifnet *ifp = &sc->arpcom.ac_if;
- int s, i, j;
-
- if (sc->gone)
- return;
-
- /*
- if (ifp->if_addrlist == (struct ifaddr *) 0)
- return;
- */
-
- s = splimp();
- while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
-
- GO_WINDOW(0);
- outw(BASE + EP_COMMAND, STOP_TRANSCEIVER);
- GO_WINDOW(4);
- outw(BASE + EP_W4_MEDIA_TYPE, DISABLE_UTP);
- GO_WINDOW(0);
-
- /* Disable the card */
- outw(BASE + EP_W0_CONFIG_CTRL, 0);
-
- /* Enable the card */
- outw(BASE + EP_W0_CONFIG_CTRL, ENABLE_DRQ_IRQ);
-
- GO_WINDOW(2);
-
- /* Reload the ether_addr. */
- for (i = 0; i < 6; i++)
- outb(BASE + EP_W2_ADDR_0 + i, sc->arpcom.ac_enaddr[i]);
-
- outw(BASE + EP_COMMAND, RX_RESET);
- outw(BASE + EP_COMMAND, TX_RESET);
- while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
-
- /* Window 1 is operating window */
- GO_WINDOW(1);
- for (i = 0; i < 31; i++)
- inb(BASE + EP_W1_TX_STATUS);
-
- /* get rid of stray intr's */
- outw(BASE + EP_COMMAND, ACK_INTR | 0xff);
-
- outw(BASE + EP_COMMAND, SET_RD_0_MASK | S_5_INTS);
-
- outw(BASE + EP_COMMAND, SET_INTR_MASK | S_5_INTS);
-
- if (ifp->if_flags & IFF_PROMISC)
- outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
- FIL_GROUP | FIL_BRDCST | FIL_ALL);
- else
- outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
- FIL_GROUP | FIL_BRDCST);
-
- /*
- * S.B.
- *
- * Now behavior was slightly changed:
- *
- * if any of flags link[0-2] is used and its connector is
- * physically present the following connectors are used:
- *
- * link0 - AUI * highest precedence
- * link1 - BNC
- * link2 - UTP * lowest precedence
- *
- * If none of them is specified then
- * connector specified in the EEPROM is used
- * (if present on card or AUI if not).
- *
- */
-
- /* Set the xcvr. */
- if (ifp->if_flags & IFF_LINK0 && sc->ep_connectors & AUI) {
- i = ACF_CONNECTOR_AUI;
- } else if (ifp->if_flags & IFF_LINK1 && sc->ep_connectors & BNC) {
- i = ACF_CONNECTOR_BNC;
- } else if (ifp->if_flags & IFF_LINK2 && sc->ep_connectors & UTP) {
- i = ACF_CONNECTOR_UTP;
- } else {
- i = sc->ep_connector;
- }
- GO_WINDOW(0);
- j = inw(BASE + EP_W0_ADDRESS_CFG) & 0x3fff;
- outw(BASE + EP_W0_ADDRESS_CFG, j | (i << ACF_CONNECTOR_BITS));
-
- switch(i) {
- case ACF_CONNECTOR_UTP:
- if (sc->ep_connectors & UTP) {
- GO_WINDOW(4);
- outw(BASE + EP_W4_MEDIA_TYPE, ENABLE_UTP);
- }
- break;
- case ACF_CONNECTOR_BNC:
- if (sc->ep_connectors & BNC) {
- outw(BASE + EP_COMMAND, START_TRANSCEIVER);
- DELAY(DELAY_MULTIPLE * 1000);
- }
- break;
- case ACF_CONNECTOR_AUI:
- /* nothing to do */
- break;
- default:
- printf("ep%d: strange connector type in EEPROM: assuming AUI\n",
- sc->unit);
- break;
- }
-
- outw(BASE + EP_COMMAND, RX_ENABLE);
- outw(BASE + EP_COMMAND, TX_ENABLE);
-
- ifp->if_flags |= IFF_RUNNING;
- ifp->if_flags &= ~IFF_OACTIVE; /* just in case */
-
-#ifdef EP_LOCAL_STATS
- sc->rx_no_first = sc->rx_no_mbuf =
- sc->rx_bpf_disc = sc->rx_overrunf = sc->rx_overrunl =
- sc->tx_underrun = 0;
-#endif
- ep_fset(F_RX_FIRST);
- if (sc->top) {
- m_freem(sc->top);
- sc->top = sc->mcur = 0;
- }
- outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH);
- outw(BASE + EP_COMMAND, SET_TX_START_THRESH | 16);
-
- /*
- * Store up a bunch of mbuf's for use later. (MAX_MBS). First we free up
- * any that we had in case we're being called from intr or somewhere
- * else.
- */
-
- GO_WINDOW(1);
- epstart(ifp);
-
- splx(s);
-}
-
-static const char padmap[] = {0, 3, 2, 1};
-
-static void
-epstart(ifp)
- struct ifnet *ifp;
-{
- register struct ep_softc *sc = ifp->if_softc;
- register u_int len;
- register struct mbuf *m;
- struct mbuf *top;
- int s, pad;
-
- if (sc->gone) {
- return;
- }
-
- s = splimp();
- while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
- if (ifp->if_flags & IFF_OACTIVE) {
- splx(s);
- return;
- }
-startagain:
- /* Sneak a peek at the next packet */
- m = ifp->if_snd.ifq_head;
- if (m == 0) {
- splx(s);
- return;
- }
- for (len = 0, top = m; m; m = m->m_next)
- len += m->m_len;
-
- pad = padmap[len & 3];
-
- /*
- * The 3c509 automatically pads short packets to minimum ethernet length,
- * but we drop packets that are too large. Perhaps we should truncate
- * them instead?
- */
- if (len + pad > ETHER_MAX_LEN) {
- /* packet is obviously too large: toss it */
- ++ifp->if_oerrors;
- IF_DEQUEUE(&ifp->if_snd, m);
- m_freem(m);
- goto readcheck;
- }
- if (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) {
- /* no room in FIFO */
- outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | (len + pad + 4));
- /* make sure */
- if (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) {
- ifp->if_flags |= IFF_OACTIVE;
- splx(s);
- return;
- }
- }
- IF_DEQUEUE(&ifp->if_snd, m);
-
- outw(BASE + EP_W1_TX_PIO_WR_1, len);
- outw(BASE + EP_W1_TX_PIO_WR_1, 0x0); /* Second dword meaningless */
-
- for (top = m; m != 0; m = m->m_next)
- if (ep_ftst(F_ACCESS_32_BITS)) {
- outsl(BASE + EP_W1_TX_PIO_WR_1, mtod(m, caddr_t),
- m->m_len / 4);
- if (m->m_len & 3)
- outsb(BASE + EP_W1_TX_PIO_WR_1,
- mtod(m, caddr_t) + (m->m_len & (~3)),
- m->m_len & 3);
- } else {
- outsw(BASE + EP_W1_TX_PIO_WR_1, mtod(m, caddr_t), m->m_len / 2);
- if (m->m_len & 1)
- outb(BASE + EP_W1_TX_PIO_WR_1,
- *(mtod(m, caddr_t) + m->m_len - 1));
- }
-
- while (pad--)
- outb(BASE + EP_W1_TX_PIO_WR_1, 0); /* Padding */
-
- if (ifp->if_bpf) {
- bpf_mtap(ifp, top);
- }
-
- ifp->if_timer = 2;
- ifp->if_opackets++;
- m_freem(top);
-
- /*
- * Is another packet coming in? We don't want to overflow the tiny RX
- * fifo.
- */
-readcheck:
- if (inw(BASE + EP_W1_RX_STATUS) & RX_BYTES_MASK) {
- /*
- * we check if we have packets left, in that case we prepare to come
- * back later
- */
- if (ifp->if_snd.ifq_head) {
- outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | 8);
- }
- splx(s);
- return;
- }
- goto startagain;
-}
-
-static void
-epintr(unit)
- int unit;
-{
- register struct ep_softc *sc = ep_softc[unit];
-
- if (sc->gone) {
- return;
- }
-
- ep_intr(sc);
-}
-
-void
-ep_intr(arg)
- void *arg;
-{
- struct ep_softc *sc;
- register int status;
- struct ifnet *ifp;
- int x;
-
- x = splbio();
-
- sc = (struct ep_softc *)arg;
-
- ifp = &sc->arpcom.ac_if;
-
- outw(BASE + EP_COMMAND, SET_INTR_MASK); /* disable all Ints */
-
-rescan:
-
- while ((status = inw(BASE + EP_STATUS)) & S_5_INTS) {
-
- /* first acknowledge all interrupt sources */
- outw(BASE + EP_COMMAND, ACK_INTR | (status & S_MASK));
-
- if (status & (S_RX_COMPLETE | S_RX_EARLY)) {
- epread(sc);
- continue;
- }
- if (status & S_TX_AVAIL) {
- /* we need ACK */
- ifp->if_timer = 0;
- ifp->if_flags &= ~IFF_OACTIVE;
- GO_WINDOW(1);
- inw(BASE + EP_W1_FREE_TX);
- epstart(ifp);
- }
- if (status & S_CARD_FAILURE) {
- ifp->if_timer = 0;
-#ifdef EP_LOCAL_STATS
- printf("\nep%d:\n\tStatus: %x\n", sc->unit, status);
- GO_WINDOW(4);
- printf("\tFIFO Diagnostic: %x\n", inw(BASE + EP_W4_FIFO_DIAG));
- printf("\tStat: %x\n", sc->stat);
- printf("\tIpackets=%d, Opackets=%d\n",
- ifp->if_ipackets, ifp->if_opackets);
- printf("\tNOF=%d, NOMB=%d, BPFD=%d, RXOF=%d, RXOL=%d, TXU=%d\n",
- sc->rx_no_first, sc->rx_no_mbuf, sc->rx_bpf_disc, sc->rx_overrunf,
- sc->rx_overrunl, sc->tx_underrun);
-#else
-
-#ifdef DIAGNOSTIC
- printf("ep%d: Status: %x (input buffer overflow)\n", sc->unit, status);
-#else
- ++ifp->if_ierrors;
-#endif
-
-#endif
- epinit(sc);
- splx(x);
- return;
- }
- if (status & S_TX_COMPLETE) {
- ifp->if_timer = 0;
- /* we need ACK. we do it at the end */
- /*
- * We need to read TX_STATUS until we get a 0 status in order to
- * turn off the interrupt flag.
- */
- while ((status = inb(BASE + EP_W1_TX_STATUS)) & TXS_COMPLETE) {
- if (status & TXS_SUCCES_INTR_REQ);
- else if (status & (TXS_UNDERRUN | TXS_JABBER | TXS_MAX_COLLISION)) {
- outw(BASE + EP_COMMAND, TX_RESET);
- if (status & TXS_UNDERRUN) {
-#ifdef EP_LOCAL_STATS
- sc->tx_underrun++;
-#endif
- } else {
- if (status & TXS_JABBER);
- else /* TXS_MAX_COLLISION - we shouldn't get here */
- ++ifp->if_collisions;
- }
- ++ifp->if_oerrors;
- outw(BASE + EP_COMMAND, TX_ENABLE);
- /*
- * To have a tx_avail_int but giving the chance to the
- * Reception
- */
- if (ifp->if_snd.ifq_head) {
- outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | 8);
- }
- }
- outb(BASE + EP_W1_TX_STATUS, 0x0); /* pops up the next
- * status */
- } /* while */
- ifp->if_flags &= ~IFF_OACTIVE;
- GO_WINDOW(1);
- inw(BASE + EP_W1_FREE_TX);
- epstart(ifp);
- } /* end TX_COMPLETE */
- }
-
- outw(BASE + EP_COMMAND, C_INTR_LATCH); /* ACK int Latch */
-
- if ((status = inw(BASE + EP_STATUS)) & S_5_INTS)
- goto rescan;
-
- /* re-enable Ints */
- outw(BASE + EP_COMMAND, SET_INTR_MASK | S_5_INTS);
-
- splx(x);
-}
-
-static void
-epread(sc)
- register struct ep_softc *sc;
-{
- struct ether_header *eh;
- struct mbuf *top, *mcur, *m;
- struct ifnet *ifp;
- int lenthisone;
-
- short rx_fifo2, status;
- register short rx_fifo;
-
- ifp = &sc->arpcom.ac_if;
- status = inw(BASE + EP_W1_RX_STATUS);
-
-read_again:
-
- if (status & ERR_RX) {
- ++ifp->if_ierrors;
- if (status & ERR_RX_OVERRUN) {
- /*
- * we can think the rx latency is actually greather than we
- * expect
- */
-#ifdef EP_LOCAL_STATS
- if (ep_ftst(F_RX_FIRST))
- sc->rx_overrunf++;
- else
- sc->rx_overrunl++;
-#endif
- }
- goto out;
- }
- rx_fifo = rx_fifo2 = status & RX_BYTES_MASK;
-
- if (ep_ftst(F_RX_FIRST)) {
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (!m)
- goto out;
- if (rx_fifo >= MINCLSIZE)
- MCLGET(m, M_DONTWAIT);
- sc->top = sc->mcur = top = m;
-#define EROUND ((sizeof(struct ether_header) + 3) & ~3)
-#define EOFF (EROUND - sizeof(struct ether_header))
- top->m_data += EOFF;
-
- /* Read what should be the header. */
- insw(BASE + EP_W1_RX_PIO_RD_1,
- mtod(top, caddr_t), sizeof(struct ether_header) / 2);
- top->m_len = sizeof(struct ether_header);
- rx_fifo -= sizeof(struct ether_header);
- sc->cur_len = rx_fifo2;
- } else {
- /* come here if we didn't have a complete packet last time */
- top = sc->top;
- m = sc->mcur;
- sc->cur_len += rx_fifo2;
- }
-
- /* Reads what is left in the RX FIFO */
- while (rx_fifo > 0) {
- lenthisone = min(rx_fifo, M_TRAILINGSPACE(m));
- if (lenthisone == 0) { /* no room in this one */
- mcur = m;
- MGET(m, M_DONTWAIT, MT_DATA);
- if (!m)
- goto out;
- if (rx_fifo >= MINCLSIZE)
- MCLGET(m, M_DONTWAIT);
- m->m_len = 0;
- mcur->m_next = m;
- lenthisone = min(rx_fifo, M_TRAILINGSPACE(m));
- }
- if (ep_ftst(F_ACCESS_32_BITS)) { /* default for EISA configured cards*/
- insl(BASE + EP_W1_RX_PIO_RD_1, mtod(m, caddr_t) + m->m_len,
- lenthisone / 4);
- m->m_len += (lenthisone & ~3);
- if (lenthisone & 3)
- insb(BASE + EP_W1_RX_PIO_RD_1,
- mtod(m, caddr_t) + m->m_len,
- lenthisone & 3);
- m->m_len += (lenthisone & 3);
- } else {
- insw(BASE + EP_W1_RX_PIO_RD_1, mtod(m, caddr_t) + m->m_len,
- lenthisone / 2);
- m->m_len += lenthisone;
- if (lenthisone & 1)
- *(mtod(m, caddr_t) + m->m_len - 1) = inb(BASE + EP_W1_RX_PIO_RD_1);
- }
- rx_fifo -= lenthisone;
- }
-
- if (status & ERR_RX_INCOMPLETE) { /* we haven't received the complete
- * packet */
- sc->mcur = m;
-#ifdef EP_LOCAL_STATS
- sc->rx_no_first++; /* to know how often we come here */
-#endif
- ep_frst(F_RX_FIRST);
- if (!((status = inw(BASE + EP_W1_RX_STATUS)) & ERR_RX_INCOMPLETE)) {
- /* we see if by now, the packet has completly arrived */
- goto read_again;
- }
- outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_NEXT_EARLY_THRESH);
- return;
- }
- outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
- ++ifp->if_ipackets;
- ep_fset(F_RX_FIRST);
- top->m_pkthdr.rcvif = &sc->arpcom.ac_if;
- top->m_pkthdr.len = sc->cur_len;
-
- if (ifp->if_bpf) {
- bpf_mtap(ifp, top);
-
- /*
- * Note that the interface cannot be in promiscuous mode if there are
- * no BPF listeners. And if we are in promiscuous mode, we have to
- * check if this packet is really ours.
- */
- eh = mtod(top, struct ether_header *);
- if ((ifp->if_flags & IFF_PROMISC) &&
- (eh->ether_dhost[0] & 1) == 0 &&
- bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
- sizeof(eh->ether_dhost)) != 0 &&
- bcmp(eh->ether_dhost, etherbroadcastaddr,
- sizeof(eh->ether_dhost)) != 0) {
- if (sc->top) {
- m_freem(sc->top);
- sc->top = 0;
- }
- ep_fset(F_RX_FIRST);
-#ifdef EP_LOCAL_STATS
- sc->rx_bpf_disc++;
-#endif
- while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
- outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH);
- return;
- }
- }
-
- eh = mtod(top, struct ether_header *);
- m_adj(top, sizeof(struct ether_header));
- ether_input(ifp, eh, top);
- sc->top = 0;
- while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
- outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH);
- return;
-
-out:
- outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
- if (sc->top) {
- m_freem(sc->top);
- sc->top = 0;
-#ifdef EP_LOCAL_STATS
- sc->rx_no_mbuf++;
-#endif
- }
- ep_fset(F_RX_FIRST);
- while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
- outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH);
-}
-
-/*
- * Look familiar?
- */
-static int
-epioctl(ifp, cmd, data)
- register struct ifnet *ifp;
- u_long cmd;
- caddr_t data;
-{
- struct ep_softc *sc = ifp->if_softc;
- int s, error = 0;
-
- s = splimp();
-
- switch (cmd) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, cmd, data);
- break;
-
- case SIOCSIFFLAGS:
-
- if ((ifp->if_flags & IFF_UP) == 0 && ifp->if_flags & IFF_RUNNING) {
- ifp->if_flags &= ~IFF_RUNNING;
- epstop(sc);
- break;
- } else {
- /* reinitialize card on any parameter change */
- epinit(sc);
- break;
- }
-
- /* NOTREACHED */
- break;
-#ifdef notdef
- case SIOCGHWADDR:
- bcopy((caddr_t) sc->sc_addr, (caddr_t) & ifr->ifr_data,
- sizeof(sc->sc_addr));
- break;
-#endif
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- /*
- * The Etherlink III has no programmable multicast
- * filter. We always initialize the card to be
- * promiscuous to multicast, since we're always a
- * member of the ALL-SYSTEMS group, so there's no
- * need to process SIOC*MULTI requests.
- */
- error = 0;
- break;
- default:
- error = EINVAL;
- }
-
- splx(s);
-
- return (error);
-}
-
-static void
-epwatchdog(ifp)
- struct ifnet *ifp;
-{
- struct ep_softc *sc = ifp->if_softc;
-
- /*
- printf("ep: watchdog\n");
-
- log(LOG_ERR, "ep%d: watchdog\n", ifp->if_unit);
- ifp->if_oerrors++;
- */
-
- if (sc->gone) {
- return;
- }
-
- ifp->if_flags &= ~IFF_OACTIVE;
- epstart(ifp);
- ep_intr(ifp->if_softc);
-}
-
-static void
-epstop(sc)
- struct ep_softc *sc;
-{
- if (sc->gone) {
- return;
- }
-
- outw(BASE + EP_COMMAND, RX_DISABLE);
- outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
- while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
- outw(BASE + EP_COMMAND, TX_DISABLE);
- outw(BASE + EP_COMMAND, STOP_TRANSCEIVER);
- outw(BASE + EP_COMMAND, RX_RESET);
- outw(BASE + EP_COMMAND, TX_RESET);
- while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
- outw(BASE + EP_COMMAND, C_INTR_LATCH);
- outw(BASE + EP_COMMAND, SET_RD_0_MASK);
- outw(BASE + EP_COMMAND, SET_INTR_MASK);
- outw(BASE + EP_COMMAND, SET_RX_FILTER);
-}
-
-
-#if 0
-static int
-send_ID_sequence(port)
- int port;
-{
- int cx, al;
-
- for (al = 0xff, cx = 0; cx < 255; cx++) {
- outb(port, al);
- al <<= 1;
- if (al & 0x100)
- al ^= 0xcf;
- }
- return (1);
-}
-#endif
-
-
-/*
- * We get eeprom data from the id_port given an offset into the eeprom.
- * Basically; after the ID_sequence is sent to all of the cards; they enter
- * the ID_CMD state where they will accept command requests. 0x80-0xbf loads
- * the eeprom data. We then read the port 16 times and with every read; the
- * cards check for contention (ie: if one card writes a 0 bit and another
- * writes a 1 bit then the host sees a 0. At the end of the cycle; each card
- * compares the data on the bus; if there is a difference then that card goes
- * into ID_WAIT state again). In the meantime; one bit of data is returned in
- * the AX register which is conveniently returned to us by inb(). Hence; we
- * read 16 times getting one bit of data with each read.
- */
-
-static int
-get_eeprom_data(id_port, offset)
- int id_port;
- int offset;
-{
- int i, data = 0;
- outb(id_port, 0x80 + offset);
- for (i = 0; i < 16; i++) {
- DELAY(BIT_DELAY_MULTIPLE * 1000);
- data = (data << 1) | (inw(id_port) & 1);
- }
- return (data);
-}
-
-#endif /* NEP > 0 */
diff --git a/sys/i386/isa/if_epreg.h b/sys/i386/isa/if_epreg.h
deleted file mode 100644
index 08ff37b..0000000
--- a/sys/i386/isa/if_epreg.h
+++ /dev/null
@@ -1,471 +0,0 @@
-/*
- * Copyright (c) 1993 Herb Peyerl (hpeyerl@novatel.ca) All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer. 2. The name
- * of the author may not be used to endorse or promote products derived from
- * this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * if_epreg.h,v 1.4 1994/11/13 10:12:37 gibbs Exp Modified by:
- *
- October 2, 1994
-
- Modified by: Andres Vega Garcia
-
- INRIA - Sophia Antipolis, France
- e-mail: avega@sophia.inria.fr
- finger: avega@pax.inria.fr
-
- */
-/*
- * $FreeBSD$
- *
- * Promiscuous mode added and interrupt logic slightly changed
- * to reduce the number of adapter failures. Transceiver select
- * logic changed to use value from EEPROM. Autoconfiguration
- * features added.
- * Done by:
- * Serge Babkin
- * Chelindbank (Chelyabinsk, Russia)
- * babkin@hq.icb.chel.su
- */
-
-/*
- * Pccard support for 3C589 by:
- * HAMADA Naoki
- * nao@tom-yam.or.jp
- */
-
-/*
- * Ethernet software status per interface.
- */
-struct ep_softc {
- struct arpcom arpcom; /* Ethernet common part */
- int ep_io_addr; /* i/o bus address */
- struct mbuf *top, *mcur;
- short cur_len;
- u_short ep_connectors; /* Connectors on this card. */
- u_char ep_connector; /* Configured connector. */
- int stat; /* some flags */
- int gone; /* adapter is not present (for PCCARD) */
-#define F_RX_FIRST 0x1
-#define F_PROMISC 0x8
-
-#define F_ACCESS_32_BITS 0x100
-
- struct ep_board *epb;
-
- int unit;
-
-#ifdef EP_LOCAL_STATS
- short tx_underrun;
- short rx_no_first;
- short rx_no_mbuf;
- short rx_bpf_disc;
- short rx_overrunf;
- short rx_overrunl;
-#endif
-};
-
-struct ep_board {
- int epb_addr; /* address of this board */
- char epb_used; /* was this entry already used for configuring ? */
- /* data from EEPROM for later use */
- u_short eth_addr[3]; /* Ethernet address */
- u_short prod_id; /* product ID */
- int cmd_off; /* command offset (bit shift) */
- int mii_trans; /* activate MII transiever */
- u_short res_cfg; /* resource configuration */
-};
-
-
-/*
- * Some global constants
- */
-#define TX_INIT_RATE 16
-#define TX_INIT_MAX_RATE 64
-#define RX_INIT_LATENCY 64
-#define RX_INIT_EARLY_THRESH 208 /* not less than MINCLSIZE */
-#define RX_NEXT_EARLY_THRESH 500
-
-#define EEPROMSIZE 0x40
-#define MAX_EEPROMBUSY 1000
-#define EP_LAST_TAG 0xd7
-#define EP_MAX_BOARDS 16
-/*
- * This `ID' port is a mere hack. There's currently no chance to register
- * it with config's idea of the ports that are in use.
- *
- * "After the automatic configuration is completed, the IDS is in its initial
- * state (ID-WAIT), and it monitors all write access to I/O port 01x0h, where
- * 'x' is any hex digit. If a zero is written to any one of these ports, then
- * that address is remembered and becomes the ID port. A second zero written
- * to that port resets the ID sequence to its initial state. The IDS watches
- * for the ID sequence to be written to the ID port."
- *
- * We prefer 0x110 over 0x100 so to not conflict with the Plaque&Pray
- * ports.
- */
-#define EP_ID_PORT 0x110
-#define EP_IOSIZE 16 /* 16 bytes of I/O space used. */
-
-/*
- * some macros to acces long named fields
- */
-#define IS_BASE (is->id_iobase)
-#define BASE (sc->ep_io_addr)
-
-/*
- * Commands to read/write EEPROM trough EEPROM command register (Window 0,
- * Offset 0xa)
- */
-#define EEPROM_CMD_RD 0x0080 /* Read: Address required (5 bits) */
-#define EEPROM_CMD_WR 0x0040 /* Write: Address required (5 bits) */
-#define EEPROM_CMD_ERASE 0x00c0 /* Erase: Address required (5 bits) */
-#define EEPROM_CMD_EWEN 0x0030 /* Erase/Write Enable: No data required */
-
-#define EEPROM_BUSY (1<<15)
-#define EEPROM_TST_MODE (1<<14)
-
-/*
- * Some short functions, worth to let them be a macro
- */
-#define is_eeprom_busy(b) (inw((b)+EP_W0_EEPROM_COMMAND)&EEPROM_BUSY)
-#define GO_WINDOW(x) outw(BASE+EP_COMMAND, WINDOW_SELECT|(x))
-
-/**************************************************************************
- * *
- * These define the EEPROM data structure. They are used in the probe
- * function to verify the existence of the adapter after having sent
- * the ID_Sequence.
- *
- * There are others but only the ones we use are defined here.
- *
- **************************************************************************/
-
-#define EEPROM_NODE_ADDR_0 0x0 /* Word */
-#define EEPROM_NODE_ADDR_1 0x1 /* Word */
-#define EEPROM_NODE_ADDR_2 0x2 /* Word */
-#define EEPROM_PROD_ID 0x3 /* 0x9[0-f]50 */
-#define EEPROM_MFG_ID 0x7 /* 0x6d50 */
-#define EEPROM_ADDR_CFG 0x8 /* Base addr */
-#define EEPROM_RESOURCE_CFG 0x9 /* IRQ. Bits 12-15 */
-
-/**************************************************************************
- * *
- * These are the registers for the 3Com 3c509 and their bit patterns when *
- * applicable. They have been taken out the the "EtherLink III Parallel *
- * Tasking EISA and ISA Technical Reference" "Beta Draft 10/30/92" manual *
- * from 3com. *
- * *
- **************************************************************************/
-
-#define EP_COMMAND 0x0e /* Write. BASE+0x0e is always a
- * command reg. */
-#define EP_STATUS 0x0e /* Read. BASE+0x0e is always status
- * reg. */
-#define EP_WINDOW 0x0f /* Read. BASE+0x0f is always window
- * reg. */
-/*
- * Window 0 registers. Setup.
- */
-/* Write */
-#define EP_W0_EEPROM_DATA 0x0c
-#define EP_W0_EEPROM_COMMAND 0x0a
-#define EP_W0_RESOURCE_CFG 0x08
-#define EP_W0_ADDRESS_CFG 0x06
-#define EP_W0_CONFIG_CTRL 0x04
-/* Read */
-#define EP_W0_PRODUCT_ID 0x02
-#define EP_W0_MFG_ID 0x00
-
-/*
- * Window 1 registers. Operating Set.
- */
-/* Write */
-#define EP_W1_TX_PIO_WR_2 0x02
-#define EP_W1_TX_PIO_WR_1 0x00
-/* Read */
-#define EP_W1_FREE_TX 0x0c
-#define EP_W1_TX_STATUS 0x0b /* byte */
-#define EP_W1_TIMER 0x0a /* byte */
-#define EP_W1_RX_STATUS 0x08
-#define EP_W1_RX_PIO_RD_2 0x02
-#define EP_W1_RX_PIO_RD_1 0x00
-
-/*
- * Window 2 registers. Station Address Setup/Read
- */
-/* Read/Write */
-#define EP_W2_ADDR_5 0x05
-#define EP_W2_ADDR_4 0x04
-#define EP_W2_ADDR_3 0x03
-#define EP_W2_ADDR_2 0x02
-#define EP_W2_ADDR_1 0x01
-#define EP_W2_ADDR_0 0x00
-
-/*
- * Window 3 registers. FIFO Management.
- */
-/* Read */
-#define EP_W3_FREE_TX 0x0c
-#define EP_W3_FREE_RX 0x0a
-#define EP_W3_OPTIONS 0x08
-
-/*
- * Window 4 registers. Diagnostics.
- */
-/* Read/Write */
-#define EP_W4_MEDIA_TYPE 0x0a
-#define EP_W4_CTRLR_STATUS 0x08
-#define EP_W4_NET_DIAG 0x06
-#define EP_W4_FIFO_DIAG 0x04
-#define EP_W4_HOST_DIAG 0x02
-#define EP_W4_TX_DIAG 0x00
-
-/*
- * Window 5 Registers. Results and Internal status.
- */
-/* Read */
-#define EP_W5_READ_0_MASK 0x0c
-#define EP_W5_INTR_MASK 0x0a
-#define EP_W5_RX_FILTER 0x08
-#define EP_W5_RX_EARLY_THRESH 0x06
-#define EP_W5_TX_AVAIL_THRESH 0x02
-#define EP_W5_TX_START_THRESH 0x00
-
-/*
- * Window 6 registers. Statistics.
- */
-/* Read/Write */
-#define TX_TOTAL_OK 0x0c
-#define RX_TOTAL_OK 0x0a
-#define TX_DEFERRALS 0x08
-#define RX_FRAMES_OK 0x07
-#define TX_FRAMES_OK 0x06
-#define RX_OVERRUNS 0x05
-#define TX_COLLISIONS 0x04
-#define TX_AFTER_1_COLLISION 0x03
-#define TX_AFTER_X_COLLISIONS 0x02
-#define TX_NO_SQE 0x01
-#define TX_CD_LOST 0x00
-
-/****************************************
- *
- * Register definitions.
- *
- ****************************************/
-
-/*
- * Command register. All windows.
- *
- * 16 bit register.
- * 15-11: 5-bit code for command to be executed.
- * 10-0: 11-bit arg if any. For commands with no args;
- * this can be set to anything.
- */
-#define GLOBAL_RESET (u_short) 0x0000 /* Wait at least 1ms
- * after issuing */
-#define WINDOW_SELECT (u_short) (0x1<<11)
-#define START_TRANSCEIVER (u_short) (0x2<<11) /* Read ADDR_CFG reg to
- * determine whether
- * this is needed. If
- * so; wait 800 uSec
- * before using trans-
- * ceiver. */
-#define RX_DISABLE (u_short) (0x3<<11) /* state disabled on
- * power-up */
-#define RX_ENABLE (u_short) (0x4<<11)
-#define RX_RESET (u_short) (0x5<<11)
-#define RX_DISCARD_TOP_PACK (u_short) (0x8<<11)
-#define TX_ENABLE (u_short) (0x9<<11)
-#define TX_DISABLE (u_short) (0xa<<11)
-#define TX_RESET (u_short) (0xb<<11)
-#define REQ_INTR (u_short) (0xc<<11)
-#define SET_INTR_MASK (u_short) (0xe<<11)
-#define SET_RD_0_MASK (u_short) (0xf<<11)
-#define SET_RX_FILTER (u_short) (0x10<<11)
-#define FIL_INDIVIDUAL (u_short) (0x1)
-#define FIL_GROUP (u_short) (0x2)
-#define FIL_BRDCST (u_short) (0x4)
-#define FIL_ALL (u_short) (0x8)
-#define SET_RX_EARLY_THRESH (u_short) (0x11<<11)
-#define SET_TX_AVAIL_THRESH (u_short) (0x12<<11)
-#define SET_TX_START_THRESH (u_short) (0x13<<11)
-#define STATS_ENABLE (u_short) (0x15<<11)
-#define STATS_DISABLE (u_short) (0x16<<11)
-#define STOP_TRANSCEIVER (u_short) (0x17<<11)
-/*
- * The following C_* acknowledge the various interrupts. Some of them don't
- * do anything. See the manual.
- */
-#define ACK_INTR (u_short) (0x6800)
-#define C_INTR_LATCH (u_short) (ACK_INTR|0x1)
-#define C_CARD_FAILURE (u_short) (ACK_INTR|0x2)
-#define C_TX_COMPLETE (u_short) (ACK_INTR|0x4)
-#define C_TX_AVAIL (u_short) (ACK_INTR|0x8)
-#define C_RX_COMPLETE (u_short) (ACK_INTR|0x10)
-#define C_RX_EARLY (u_short) (ACK_INTR|0x20)
-#define C_INT_RQD (u_short) (ACK_INTR|0x40)
-#define C_UPD_STATS (u_short) (ACK_INTR|0x80)
-#define C_MASK (u_short) 0xFF /* mask of C_* */
-
-/*
- * Status register. All windows.
- *
- * 15-13: Window number(0-7).
- * 12: Command_in_progress.
- * 11: reserved.
- * 10: reserved.
- * 9: reserved.
- * 8: reserved.
- * 7: Update Statistics.
- * 6: Interrupt Requested.
- * 5: RX Early.
- * 4: RX Complete.
- * 3: TX Available.
- * 2: TX Complete.
- * 1: Adapter Failure.
- * 0: Interrupt Latch.
- */
-#define S_INTR_LATCH (u_short) (0x1)
-#define S_CARD_FAILURE (u_short) (0x2)
-#define S_TX_COMPLETE (u_short) (0x4)
-#define S_TX_AVAIL (u_short) (0x8)
-#define S_RX_COMPLETE (u_short) (0x10)
-#define S_RX_EARLY (u_short) (0x20)
-#define S_INT_RQD (u_short) (0x40)
-#define S_UPD_STATS (u_short) (0x80)
-#define S_MASK (u_short) 0xFF /* mask of S_* */
-#define S_5_INTS (S_CARD_FAILURE|S_TX_COMPLETE|\
- S_TX_AVAIL|S_RX_COMPLETE|S_RX_EARLY)
-#define S_COMMAND_IN_PROGRESS (u_short) (0x1000)
-
-/* Address Config. Register.
- * Window 0/Port 06
- */
-
-#define ACF_CONNECTOR_BITS 14
-#define ACF_CONNECTOR_UTP 0
-#define ACF_CONNECTOR_AUI 1
-#define ACF_CONNECTOR_BNC 3
-
-/* Resource configuration register.
- * Window 0/Port 08
- *
- */
-
-#define SET_IRQ(base,irq) outw((base) + EP_W0_RESOURCE_CFG, \
- ((inw((base) + EP_W0_RESOURCE_CFG) & 0x0fff) | \
- ((u_short)(irq)<<12)) ) /* set IRQ i */
-
-/*
- * FIFO Registers.
- * RX Status. Window 1/Port 08
- *
- * 15: Incomplete or FIFO empty.
- * 14: 1: Error in RX Packet 0: Incomplete or no error.
- * 13-11: Type of error.
- * 1000 = Overrun.
- * 1011 = Run Packet Error.
- * 1100 = Alignment Error.
- * 1101 = CRC Error.
- * 1001 = Oversize Packet Error (>1514 bytes)
- * 0010 = Dribble Bits.
- * (all other error codes, no errors.)
- *
- * 10-0: RX Bytes (0-1514)
- */
-#define ERR_RX_INCOMPLETE (u_short) (0x1<<15)
-#define ERR_RX (u_short) (0x1<<14)
-#define ERR_RX_OVERRUN (u_short) (0x8<<11)
-#define ERR_RX_RUN_PKT (u_short) (0xb<<11)
-#define ERR_RX_ALIGN (u_short) (0xc<<11)
-#define ERR_RX_CRC (u_short) (0xd<<11)
-#define ERR_RX_OVERSIZE (u_short) (0x9<<11)
-#define ERR_RX_DRIBBLE (u_short) (0x2<<11)
-
-/*
- * FIFO Registers.
- * TX Status. Window 1/Port 0B
- *
- * Reports the transmit status of a completed transmission. Writing this
- * register pops the transmit completion stack.
- *
- * Window 1/Port 0x0b.
- *
- * 7: Complete
- * 6: Interrupt on successful transmission requested.
- * 5: Jabber Error (TP Only, TX Reset required. )
- * 4: Underrun (TX Reset required. )
- * 3: Maximum Collisions.
- * 2: TX Status Overflow.
- * 1-0: Undefined.
- *
- */
-#define TXS_COMPLETE 0x80
-#define TXS_SUCCES_INTR_REQ 0x40
-#define TXS_JABBER 0x20
-#define TXS_UNDERRUN 0x10
-#define TXS_MAX_COLLISION 0x8
-#define TXS_STATUS_OVERFLOW 0x4
-
-/*
- * Configuration control register.
- * Window 0/Port 04
- */
-/* Read */
-#define IS_AUI (1<<13)
-#define IS_BNC (1<<12)
-#define IS_UTP (1<<9)
-/* Write */
-#define ENABLE_DRQ_IRQ 0x0001
-#define W0_P4_CMD_RESET_ADAPTER 0x4
-#define W0_P4_CMD_ENABLE_ADAPTER 0x1
-/*
- * Media type and status.
- * Window 4/Port 0A
- */
-#define ENABLE_UTP 0xc0
-#define DISABLE_UTP 0x0
-
-/*
- * Misc defines for various things.
- */
-#define ACTIVATE_ADAPTER_TO_CONFIG 0xff /* to the id_port */
-#define MFG_ID 0x6d50 /* in EEPROM and W0 ADDR_CONFIG */
-#define PROD_ID 0x9150
-
-#define AUI 0x1
-#define BNC 0x2
-#define UTP 0x4
-
-#define RX_BYTES_MASK (u_short) (0x07ff)
-
-extern struct ep_board ep_board[];
-extern int ep_boards;
-extern u_long ep_unit;
-extern struct ep_softc *ep_alloc __P((int unit, struct ep_board *epb));
-extern void ep_free __P((struct ep_softc *sc));
-extern void ep_intr __P((void *sc));
-extern int ep_attach __P((struct ep_softc *sc));
-
-extern u_int16_t get_e __P((struct ep_softc *sc, int offset));
-
-/*
- * Config flags
- */
-#define EP_FLAGS_100TX 0x1
diff --git a/sys/i386/isa/wd.c b/sys/i386/isa/wd.c
index 1e90fcb..c254781 100644
--- a/sys/i386/isa/wd.c
+++ b/sys/i386/isa/wd.c
@@ -71,6 +71,7 @@
#include <sys/dkbad.h>
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/sysctl.h>
#include <sys/conf.h>
#include <sys/bus.h>
#include <sys/disklabel.h>
@@ -258,6 +259,12 @@ static int atapictrlr;
static int eide_quirks;
+static char wd_ident[NWD][62] = { NULL, NULL, NULL, NULL };
+SYSCTL_STRING(_hw, OID_AUTO, wd0_ident, CTLFLAG_RD, wd_ident[0], 0, "");
+SYSCTL_STRING(_hw, OID_AUTO, wd1_ident, CTLFLAG_RD, wd_ident[1], 0, "");
+SYSCTL_STRING(_hw, OID_AUTO, wd2_ident, CTLFLAG_RD, wd_ident[2], 0, "");
+SYSCTL_STRING(_hw, OID_AUTO, wd3_ident, CTLFLAG_RD, wd_ident[3], 0, "");
+
/*
* Here we use the pci-subsystem to find out, whether there is
* a cmd640b-chip attached on this pci-bus. This public routine
@@ -459,6 +466,13 @@ wdattach(struct isa_device *dvp)
((dvp->id_flags) >> (16 * unit));
if (wdgetctlr(du) == 0) {
+
+ bzero(wd_ident[lunit], sizeof(wd_ident[lunit]);
+ snprintf(wd_ident[lunit], sizeof(wd_ident[lunit]),
+ "%s %s",
+ du->dk_params.wdp_model,
+ du->dk_params.wdp_serial);
+
/*
* Print out description of drive.
* wdp_model may not be null terminated.
@@ -478,6 +492,10 @@ wdattach(struct isa_device *dvp)
if (du->cfg_flags & WDOPT_SLEEPHACK)
printf(", sleep-hack");
printf("\n");
+ if (bootverbose) {
+ printf("wd%d: Serial Number %s\n", lunit,
+ du->dk_params.wdp_serial);
+ }
if (du->dk_params.wdp_heads == 0)
printf("wd%d: size unknown, using %s values\n",
lunit, du->dk_dd.d_secperunit > 17
OpenPOWER on IntegriCloud