Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / isapnp / if_an_isapnp.c
blobe8eacd245f83d91186cffa3b21cc36e115db0649
1 /* $NetBSD: if_an_isapnp.c,v 1.21 2008/07/04 04:53:41 cegger Exp $ */
3 /*-
4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * ISAPnP bus front-end for the Aironet ISA4500/ISA4800 Wireless LAN Adapter.
34 * Unlike WaveLAN, this adapter is attached as an ISA device using an address
35 * decoder hack.
38 #include <sys/cdefs.h>
39 __KERNEL_RCSID(0, "$NetBSD: if_an_isapnp.c,v 1.21 2008/07/04 04:53:41 cegger Exp $");
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/mbuf.h>
44 #include <sys/malloc.h>
45 #include <sys/kernel.h>
46 #include <sys/socket.h>
47 #include <sys/ioctl.h>
48 #include <sys/errno.h>
49 #include <sys/device.h>
50 #include <sys/callout.h>
52 #include <net/if.h>
53 #include <net/if_dl.h>
54 #include <net/if_media.h>
55 #include <net/if_ether.h>
57 #include <net80211/ieee80211_netbsd.h>
58 #include <net80211/ieee80211_var.h>
60 #include <sys/bus.h>
61 #include <sys/intr.h>
63 #include <dev/ic/anreg.h>
64 #include <dev/ic/anvar.h>
66 #include <dev/isa/isavar.h>
68 #include <dev/isapnp/isapnpreg.h>
69 #include <dev/isapnp/isapnpvar.h>
70 #include <dev/isapnp/isapnpdevs.h>
72 int an_isapnp_match(device_t, cfdata_t, void *);
73 void an_isapnp_attach(device_t, device_t, void *);
75 struct an_isapnp_softc {
76 struct an_softc sc_an; /* real "an" softc */
78 /* ISA-specific goo. */
79 void *sc_ih; /* interrupt cookie */
82 CFATTACH_DECL_NEW(an_isapnp, sizeof(struct an_isapnp_softc),
83 an_isapnp_match, an_isapnp_attach, NULL, NULL);
85 int
86 an_isapnp_match(device_t parent, cfdata_t match, void *aux)
88 int pri, variant;
90 pri = isapnp_devmatch(aux, &isapnp_an_devinfo, &variant);
91 if (pri && variant > 0)
92 pri = 0;
93 return (pri);
96 void
97 an_isapnp_attach(device_t parent, device_t self, void *aux)
99 struct an_isapnp_softc *isc = device_private(self);
100 struct an_softc *sc = &isc->sc_an;
101 struct isapnp_attach_args *ipa = aux;
103 printf("\n");
105 if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
106 aprint_error_dev(self, "can't configure isapnp resources\n");
107 return;
110 sc->sc_dev = self;
111 sc->sc_iot = ipa->ipa_iot;
112 sc->sc_ioh = ipa->ipa_io[0].h;
114 printf("%s: %s %s\n", device_xname(self), ipa->ipa_devident,
115 ipa->ipa_devclass);
117 /* This interface is always enabled. */
118 sc->sc_enabled = 1;
120 /* Establish the interrupt handler. */
121 isc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
122 ipa->ipa_irq[0].type, IPL_NET, an_intr, sc);
123 if (isc->sc_ih == NULL) {
124 aprint_error_dev(self, "couldn't establish interrupt handler\n");
125 return;
128 if (an_attach(sc) != 0) {
129 aprint_error_dev(self, "failed to attach controller\n");
130 isa_intr_disestablish(ipa->ipa_ic, isc->sc_ih);
131 isc->sc_ih = NULL;