Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add PCI version of Aironet, not tested at all.



details:   https://anonhg.NetBSD.org/src/rev/befdc9db9123
branches:  trunk
changeset: 500581:befdc9db9123
user:      onoe <onoe%NetBSD.org@localhost>
date:      Thu Dec 14 04:11:25 2000 +0000

description:
Add PCI version of Aironet, not tested at all.
ISA/ISApnp version won't come since I don't know about isa...

diffstat:

 sys/arch/i386/conf/GENERIC    |    5 +-
 sys/dev/ic/an.c               |   10 +-
 sys/dev/ic/anvar.h            |    4 +-
 sys/dev/pci/files.pci         |    6 +-
 sys/dev/pci/if_an_pci.c       |  185 ++++++++++++++++++++++++++++++++++++++++++
 sys/dev/pcmcia/if_an_pcmcia.c |   19 ++--
 6 files changed, 209 insertions(+), 20 deletions(-)

diffs (truncated from 351 to 300 lines):

diff -r 461a1421aa91 -r befdc9db9123 sys/arch/i386/conf/GENERIC
--- a/sys/arch/i386/conf/GENERIC        Thu Dec 14 04:06:05 2000 +0000
+++ b/sys/arch/i386/conf/GENERIC        Thu Dec 14 04:11:25 2000 +0000
@@ -1,11 +1,11 @@
-#      $NetBSD: GENERIC,v 1.382 2000/12/11 23:16:51 onoe Exp $
+#      $NetBSD: GENERIC,v 1.383 2000/12/14 04:11:26 onoe Exp $
 #
 #      GENERIC -- everything that's currently supported
 #
 
 include "arch/i386/conf/std.i386"
 
-#ident                 "GENERIC-$Revision: 1.382 $"
+#ident                 "GENERIC-$Revision: 1.383 $"
 
 maxusers       32              # estimated number of users
 
@@ -542,6 +542,7 @@
 # Network Interfaces
 
 # PCI network interfaces
+an*    at pci? dev ? function ?        # Aironet PC4500/PC4800 (802.11)
 de*    at pci? dev ? function ?        # DEC 21x4x-based Ethernet
 en*    at pci? dev ? function ?        # ENI/Adaptec ATM
 ep*    at pci? dev ? function ?        # 3Com 3c59x
diff -r 461a1421aa91 -r befdc9db9123 sys/dev/ic/an.c
--- a/sys/dev/ic/an.c   Thu Dec 14 04:06:05 2000 +0000
+++ b/sys/dev/ic/an.c   Thu Dec 14 04:11:25 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: an.c,v 1.6 2000/12/13 20:21:10 onoe Exp $      */
+/*     $NetBSD: an.c,v 1.7 2000/12/14 04:11:26 onoe Exp $      */
 /*
  * Copyright (c) 1997, 1998, 1999
  *     Bill Paul <wpaul%ctr.columbia.edu@localhost>.  All rights reserved.
@@ -195,16 +195,16 @@
        an_reset(sc);
 
        if (an_cmd(sc, AN_CMD_READCFG, 0))
-               return(0);
+               return ENXIO;
 
        if (an_read_record(sc, (struct an_ltv_gen *)&ssid))
-               return(0);
+               return ENXIO;
 
        /* See if the ssid matches what we expect ... but doesn't have to */
        if (strcmp(ssid.an_ssid1, AN_DEF_SSID))
-               return(0);
+               return ENXIO;
        
-       return(AN_IOSIZ);
+       return 0;
 }
 
 int an_attach(sc)
diff -r 461a1421aa91 -r befdc9db9123 sys/dev/ic/anvar.h
--- a/sys/dev/ic/anvar.h        Thu Dec 14 04:06:05 2000 +0000
+++ b/sys/dev/ic/anvar.h        Thu Dec 14 04:11:25 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: anvar.h,v 1.2 2000/12/12 05:11:15 onoe Exp $   */
+/*     $NetBSD: anvar.h,v 1.3 2000/12/14 04:11:26 onoe Exp $   */
 /*
  * Copyright (c) 1997, 1998, 1999
  *     Bill Paul <wpaul%ctr.columbia.edu@localhost>.  All rights reserved.
@@ -146,8 +146,6 @@
        int                     sc_enabled;
        struct ifmedia          sc_media;
 
-       void*   irq_handle;     /* handle for irq handler */
-
        bus_space_handle_t      an_bhandle;
        bus_space_tag_t         an_btag;
        struct an_ltv_genconfig an_config;
diff -r 461a1421aa91 -r befdc9db9123 sys/dev/pci/files.pci
--- a/sys/dev/pci/files.pci     Thu Dec 14 04:06:05 2000 +0000
+++ b/sys/dev/pci/files.pci     Thu Dec 14 04:11:25 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.pci,v 1.111 2000/11/28 05:12:29 thorpej Exp $
+#      $NetBSD: files.pci,v 1.112 2000/12/14 04:11:25 onoe Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -379,3 +379,7 @@
 device hifn {}
 attach hifn at pci
 file   dev/pci/hifn7751.c              hifn
+
+# Aironet PC4500/PC4800
+attach an at pci with an_pci
+file   dev/pci/if_an_pci.c             an_pci
diff -r 461a1421aa91 -r befdc9db9123 sys/dev/pci/if_an_pci.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pci/if_an_pci.c   Thu Dec 14 04:11:25 2000 +0000
@@ -0,0 +1,185 @@
+/*     $NetBSD: if_an_pci.c,v 1.1 2000/12/14 04:11:25 onoe Exp $       */
+
+/*
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Atsushi Onoe.
+ *
+ * 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.
+ */
+
+/*
+ * PCI bus front-end for the Aironet PC4500/PC4800 Wireless LAN Adapter.
+ * Unlike WaveLAN, this adapter attached as PCI device using a PLX 9050
+ * PCI to "dumb bus" bridge chip.
+ */
+
+#include "opt_inet.h"
+#include "opt_ns.h"
+#include "bpfilter.h"
+
+#ifdef INET
+#define        ANCACHE         /* XXX: should be defined elsewhere */
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h> 
+#include <sys/mbuf.h>   
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/errno.h>
+#include <sys/device.h>
+#include <sys/callout.h>
+
+#include <machine/endian.h>
+ 
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_media.h>
+#include <net/if_ether.h>
+
+#if NBPFILTER > 0 
+#include <net/bpf.h>
+#endif 
+
+#ifdef INET
+#include <netinet/in.h> 
+#include <netinet/if_inarp.h>
+#endif
+
+#ifdef NS
+#include <netns/ns.h>
+#include <netns/ns_if.h>
+#endif
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+
+#include <dev/ic/anreg.h>
+#include <dev/ic/anvar.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcidevs.h>
+
+#define        AN_PCI_PLX_IOBA         0x14    /* i/o base for PLX chip */
+#define        AN_PCI_IOBA             0x18    /* i/o base */
+
+struct an_pci_softc {
+       struct an_softc sc_an;          /* real "an" softc */
+
+       /* PCI-specific goo. */
+       void    *sc_ih;                 /* interrupt handle */
+};
+
+int    an_pci_match __P((struct device *, struct cfdata *, void *));
+void   an_pci_attach __P((struct device *, struct device *, void *));
+
+struct cfattach an_pci_ca = {
+       sizeof(struct an_pci_softc), an_pci_match, an_pci_attach,
+};
+
+const struct an_pci_product {
+       u_int32_t       app_vendor;     /* PCI vendor ID */
+       u_int32_t       app_product;    /* PCI product ID */
+} an_pci_products[] = {
+       { PCI_VENDOR_AIRONET,           PCI_PRODUCT_AIRONET_PC4xxx },
+       { PCI_VENDOR_AIRONET,           PCI_PRODUCT_AIRONET_PC4500 },
+       { PCI_VENDOR_AIRONET,           PCI_PRODUCT_AIRONET_PC4800 },
+       { 0,                            0                          }
+};
+
+int
+an_pci_match(struct device *parent, struct cfdata *match, void *aux)
+{
+       struct pci_attach_args *pa = aux;
+       const struct an_pci_product *app;
+
+       for (app = an_pci_products; app->app_vendor != 0; app++) {
+               if (PCI_VENDOR(pa->pa_id) == app->app_vendor &&
+                   PCI_PRODUCT(pa->pa_id) == app->app_product)
+                       return 1;
+       }
+       return 0;
+}
+
+void
+an_pci_attach(struct device *parent, struct device *self, void *aux)
+{
+        struct pci_attach_args *pa = (struct pci_attach_args *)aux;
+       struct an_pci_softc *psc = (struct an_pci_softc *) self;
+       struct an_softc *sc = &psc->sc_an;
+        char devinfo[256];
+       char const *intrstr;
+       pci_intr_handle_t ih;
+       u_int32_t csr;
+
+        pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
+        printf(": %s\n", devinfo);
+
+        /* Map I/O registers */
+        if (pci_mapreg_map(pa, AN_PCI_IOBA, PCI_MAPREG_TYPE_IO, 0,
+           &sc->an_btag, &sc->an_bhandle, NULL, NULL) != 0) {
+                printf("%s: unable to map registers\n", self->dv_xname);
+                return;
+        }
+
+        /* Enable the device. */
+        csr = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
+        pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
+                       csr | PCI_COMMAND_MASTER_ENABLE);
+
+       /* Map and establish the interrupt. */
+       if (pci_intr_map(pa->pa_pc, pa->pa_intrtag, pa->pa_intrpin,
+           pa->pa_intrline, &ih)) {
+               printf("%s: unable to map interrupt\n", self->dv_xname);
+               return;
+       }
+       intrstr = pci_intr_string(pa->pa_pc, ih);
+       psc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_NET, an_intr, sc);
+       if (psc->sc_ih == NULL) {
+               printf("%s: unable to establish interrupt", self->dv_xname);
+               if (intrstr != NULL)
+                       printf(" at %s", intrstr);
+               printf("\n");
+               return;
+       }
+       printf("%s: interrupting at %s\n", self->dv_xname, intrstr);
+       sc->sc_enabled = 1;
+
+       if (an_attach(sc) != 0) {
+               printf("%s: failed to attach controller\n", self->dv_xname);
+               pci_intr_disestablish(pa->pa_pc, psc->sc_ih);
+               bus_space_unmap(sc->an_btag, sc->an_bhandle, AN_IOSIZ);
+       }
+}
diff -r 461a1421aa91 -r befdc9db9123 sys/dev/pcmcia/if_an_pcmcia.c
--- a/sys/dev/pcmcia/if_an_pcmcia.c     Thu Dec 14 04:06:05 2000 +0000
+++ b/sys/dev/pcmcia/if_an_pcmcia.c     Thu Dec 14 04:11:25 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_an_pcmcia.c,v 1.4 2000/12/12 05:34:02 onoe Exp $ */
+/* $NetBSD: if_an_pcmcia.c,v 1.5 2000/12/14 04:11:26 onoe Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -98,12 +98,13 @@
 static void an_pcmcia_powerhook __P((int, void *));
 
 struct an_pcmcia_softc {
-       struct an_softc sc_an;          /* real "an" softc */
+       struct an_softc sc_an;                  /* real "an" softc */
 
        /* PCMCIA-specific goo */
        struct pcmcia_io_handle sc_pcioh;       /* PCMCIA i/o space info */
        int sc_io_window;                       /* our i/o window */
        struct pcmcia_function *sc_pf;          /* our PCMCIA function */
+       void *sc_ih;                            /* interrupt handle */



Home | Main Index | Thread Index | Old Index