1 /* $NetBSD: if_an_isapnp.c,v 1.1 2000/12/17 20:34:40 thorpej Exp $ */ 2 3 /*- 4 * Copyright (c) 2000 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jason R. Thorpe. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 /* 40 * ISAPnP bus front-end for the Aironet ISA4500/ISA4800 Wireless LAN Adapter. 41 * Unlike WaveLAN, this adapter is attached as an ISA device using an address 42 * decoder hack. 43 */ 44 45 #include "opt_inet.h" 46 #include "opt_ns.h" 47 #include "bpfilter.h" 48 49 #ifdef INET 50 #define ANCACHE /* XXX: should be defined elsewhere */ 51 #endif 52 53 #include <sys/param.h> 54 #include <sys/systm.h> 55 #include <sys/mbuf.h> 56 #include <sys/malloc.h> 57 #include <sys/kernel.h> 58 #include <sys/socket.h> 59 #include <sys/ioctl.h> 60 #include <sys/errno.h> 61 #include <sys/device.h> 62 #include <sys/callout.h> 63 64 #include <net/if.h> 65 #include <net/if_dl.h> 66 #include <net/if_media.h> 67 #include <net/if_ether.h> 68 69 #if NBPFILTER > 0 70 #include <net/bpf.h> 71 #endif 72 73 #ifdef INET 74 #include <netinet/in.h> 75 #include <netinet/if_inarp.h> 76 #endif 77 78 #ifdef NS 79 #include <netns/ns.h> 80 #include <netns/ns_if.h> 81 #endif 82 83 #include <machine/bus.h> 84 #include <machine/intr.h> 85 86 #include <dev/ic/anreg.h> 87 #include <dev/ic/anvar.h> 88 89 #include <dev/isa/isavar.h> 90 91 #include <dev/isapnp/isapnpreg.h> 92 #include <dev/isapnp/isapnpvar.h> 93 #include <dev/isapnp/isapnpdevs.h> 94 95 int an_isapnp_match(struct device *, struct cfdata *, void *); 96 void an_isapnp_attach(struct device *, struct device *, void *); 97 98 struct an_isapnp_softc { 99 struct an_softc sc_an; /* real "an" softc */ 100 101 /* ISA-specific goo. */ 102 void *sc_ih; /* interrupt cookie */ 103 }; 104 105 struct cfattach an_isapnp_ca = { 106 sizeof(struct an_isapnp_softc), an_isapnp_match, an_isapnp_attach 107 }; 108 109 int 110 an_isapnp_match(struct device *parent, struct cfdata *match, void *aux) 111 { 112 int pri, variant; 113 114 pri = isapnp_devmatch(aux, &isapnp_an_devinfo, &variant); 115 if (pri && variant > 0) 116 pri = 0; 117 return (pri); 118 } 119 120 void 121 an_isapnp_attach(struct device *parent, struct device *self, void *aux) 122 { 123 struct an_isapnp_softc *isc = (void *) self; 124 struct an_softc *sc = &isc->sc_an; 125 struct isapnp_attach_args *ipa = aux; 126 127 printf("\n"); 128 129 if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) { 130 printf("%s: can't configure isapnp resources\n", 131 sc->an_dev.dv_xname); 132 return; 133 } 134 135 sc->an_btag = ipa->ipa_iot; 136 sc->an_bhandle = ipa->ipa_io[0].h; 137 138 printf("%s: %s %s\n", sc->an_dev.dv_xname, ipa->ipa_devident, 139 ipa->ipa_devclass); 140 141 /* This interface is always enabled. */ 142 sc->sc_enabled = 1; 143 144 /* Establish the interrupt handler. */ 145 isc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num, 146 ipa->ipa_irq[0].type, IPL_NET, an_intr, sc); 147 if (isc->sc_ih == NULL) 148 printf("%s: couldn't establish interrupt handler\n", 149 sc->an_dev.dv_xname); 150 151 if (an_attach(sc) != 0) { 152 printf("%s: failed to attach controller\n", 153 sc->an_dev.dv_xname); 154 isa_intr_disestablish(ipa->ipa_ic, isc->sc_ih); 155 isc->sc_ih = NULL; 156 } 157 } 158