diff --git a/sys/dev/isa/files.isa b/sys/dev/isa/files.isa index c6264a43f2d1..101d001024a8 100644 --- a/sys/dev/isa/files.isa +++ b/sys/dev/isa/files.isa @@ -1,4 +1,4 @@ -# $NetBSD: files.isa,v 1.39 1997/10/14 15:50:22 is Exp $ +# $NetBSD: files.isa,v 1.40 1997/10/14 23:01:16 thorpej Exp $ # # Config file and device description for machine-independent ISA code. # Included by ports that need it. Requires that the SCSI files be @@ -143,7 +143,7 @@ define elink file dev/isa/elink.c elink # National Semiconductor DS8390/WD83C690-based boards -# (WD/SMC 80x3 family, SMC Ultra [8216], 3Com 3C503, NE[12]000, and clones) +# (WD/SMC 80x3 family, SMC Ultra [8216], 3Com 3C503) device ed: ether, ifnet, arp attach ed at isa file dev/isa/if_ed.c ed @@ -203,6 +203,10 @@ file dev/isa/if_le_isa.c le_isa attach lc at isa with lc_isa file dev/isa/if_lc_isa.c lc +# Novell NE1000, NE2000, and clones +attach ne at isa with ne_isa +file dev/isa/if_ne_isa.c ne_isa + # # ISA Sound hardware # diff --git a/sys/dev/isa/if_ne_isa.c b/sys/dev/isa/if_ne_isa.c new file mode 100644 index 000000000000..300f98b0dca6 --- /dev/null +++ b/sys/dev/isa/if_ne_isa.c @@ -0,0 +1,221 @@ +/* $NetBSD: if_ne_isa.c,v 1.2 1997/10/14 23:01:10 thorpej Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center. + * + * 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 the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``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 FOUNDATION OR CONTRIBUTORS + * 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. + */ + +#include "bpfilter.h" + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/mbuf.h> +#include <sys/socket.h> +#include <sys/ioctl.h> +#include <sys/errno.h> +#include <sys/syslog.h> +#include <sys/select.h> +#include <sys/device.h> + +#include <net/if.h> +#include <net/if_dl.h> +#include <net/if_ether.h> +#include <net/if_media.h> + +#ifdef INET +#include <netinet/in.h> +#include <netinet/in_systm.h> +#include <netinet/in_var.h> +#include <netinet/ip.h> +#include <netinet/if_inarp.h> +#endif + +#ifdef NS +#include <netns/ns.h> +#include <netns/ns_if.h> +#endif + +#if NBPFILTER > 0 +#include <net/bpf.h> +#include <net/bpfdesc.h> +#endif + +#include <machine/intr.h> +#include <machine/bus.h> + +#include <dev/ic/dp8390reg.h> +#include <dev/ic/dp8390var.h> + +#include <dev/ic/ne2000reg.h> +#include <dev/ic/ne2000var.h> + +#include <dev/isa/isavar.h> + +#ifdef __BROKEN_INDIRECT_CONFIG +int ne_isa_match __P((struct device *, void *, void *)); +#else +int ne_isa_match __P((struct device *, struct cfdata *, void *)); +#endif +void ne_isa_attach __P((struct device *, struct device *, void *)); + +struct ne_isa_softc { + struct ne2000_softc sc_ne2000; /* real "ne2000" softc */ + + /* ISA-specific goo. */ + void *sc_ih; /* interrupt cookie */ +}; + +struct cfattach ne_isa_ca = { + sizeof(struct ne_isa_softc), ne_isa_match, ne_isa_attach +}; + +int +ne_isa_match(parent, match, aux) + struct device *parent; +#ifdef __BROKEN_INDIRECT_CONFIG + void *match; +#else + struct cfdata *match; +#endif + void *aux; +{ + struct isa_attach_args *ia = aux; + bus_space_tag_t nict = ia->ia_iot; + bus_space_handle_t nich; + bus_space_tag_t asict; + bus_space_handle_t asich; + int rv = 0; + + /* Disallow wildcarded values. */ + if (ia->ia_irq == -1) + return (0); + if (ia->ia_iobase == -1) + return (0); + + /* Make sure this is a valid NE[12]000 i/o address. */ + if ((ia->ia_iobase & 0x1f) != 0) + return (0); + + /* Map i/o space. */ + if (bus_space_map(nict, ia->ia_iobase, NE2000_NPORTS, 0, &nich)) + return (0); + + asict = nict; + if (bus_space_subregion(nict, nich, NE2000_ASIC_OFFSET, + NE2000_ASIC_NPORTS, &asich)) + goto out; + + /* Look for an NE2000-compatible card. */ + rv = ne2000_detect(nict, nich, asict, asich); + + if (rv) + ia->ia_iosize = NE2000_NPORTS; + + out: + bus_space_unmap(nict, nich, NE2000_NPORTS); + return (rv); +} + +void +ne_isa_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct ne_isa_softc *isc = (struct ne_isa_softc *)self; + struct ne2000_softc *nsc = &isc->sc_ne2000; + struct dp8390_softc *dsc = &nsc->sc_dp8390; + struct isa_attach_args *ia = aux; + bus_space_tag_t nict = ia->ia_iot; + bus_space_handle_t nich; + bus_space_tag_t asict = nict; + bus_space_handle_t asich; + const char *typestr; + + printf("\n"); + + /* Map i/o space. */ + if (bus_space_map(nict, ia->ia_iobase, NE2000_NPORTS, 0, &nich)) { + printf("%s: can't map i/o space\n", dsc->sc_dev.dv_xname); + return; + } + + if (bus_space_subregion(nict, nich, NE2000_ASIC_OFFSET, + NE2000_ASIC_NPORTS, &asich)) { + printf("%s: can't subregion i/o space\n", dsc->sc_dev.dv_xname); + return; + } + + dsc->sc_regt = nict; + dsc->sc_regh = nich; + + nsc->sc_asict = asict; + nsc->sc_asich = asich; + + /* + * Detect it again, so we can print some information about the + * interface. + */ + switch (ne2000_detect(nict, nich, asict, asich)) { + case NE2000_TYPE_NE1000: + typestr = "NE1000"; + break; + + case NE2000_TYPE_NE2000: + typestr = "NE2000"; + break; + + default: + printf("%s: where did the card go?!\n", dsc->sc_dev.dv_xname); + return; + } + + printf("%s: %s Ethernet\n", dsc->sc_dev.dv_xname, typestr); + + /* This interface is always enabled. */ + dsc->sc_enabled = 1; + + /* + * Do generic NE2000 attach. This will read the station address + * from the EEPROM. + */ + ne2000_attach(nsc, NULL); + + /* Establish the interrupt handler. */ + isc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE, + IPL_NET, dp8390_intr, dsc); + if (isc->sc_ih == NULL) + printf("%s: couldn't establish interrupt handler\n", + dsc->sc_dev.dv_xname); +}