The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/vx/if_vx_eisa.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (C) 1996 Naoki Hamada <nao@tom-yam.or.jp>
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  * 3. Neither the name of the author nor the names of any co-contributors
   14  *    may be used to endorse or promote products derived from this software
   15  *    without specific prior written permission.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  */
   30 
   31 #include <sys/cdefs.h>
   32 __FBSDID("$FreeBSD$");
   33 
   34 #include <sys/param.h>
   35 #include <sys/systm.h>
   36 #include <sys/kernel.h>
   37 #include <sys/socket.h>
   38 #include <sys/module.h>
   39 #include <sys/bus.h>
   40 
   41 #include <machine/bus.h>
   42 #include <machine/resource.h>
   43 #include <sys/rman.h>
   44 
   45 #include <net/ethernet.h>
   46 #include <net/if.h>
   47 #include <net/if_arp.h>
   48 
   49 #include <dev/eisa/eisaconf.h>
   50 
   51 #include <dev/vx/if_vxreg.h>
   52 #include <dev/vx/if_vxvar.h>
   53 
   54 #define EISA_DEVICE_ID_3COM_3C592       0x506d5920
   55 #define EISA_DEVICE_ID_3COM_3C597_TX    0x506d5970
   56 #define EISA_DEVICE_ID_3COM_3C597_T4    0x506d5971
   57 #define EISA_DEVICE_ID_3COM_3C597_MII   0x506d5972
   58 
   59 
   60 #define VX_EISA_SLOT_OFFSET             0x0c80
   61 #define VX_EISA_IOSIZE                  0x000a
   62 #define VX_RESOURCE_CONFIG              0x0008
   63 
   64 
   65 static const char *vx_match(eisa_id_t type);
   66 
   67 static const char *
   68 vx_match(eisa_id_t type)
   69 {
   70         switch (type) {
   71         case EISA_DEVICE_ID_3COM_3C592:
   72                 return "3Com 3C592 Network Adapter";
   73         case EISA_DEVICE_ID_3COM_3C597_TX:
   74                 return "3Com 3C597-TX Network Adapter";
   75         case EISA_DEVICE_ID_3COM_3C597_T4:
   76                 return "3Com 3C597-T4 Network Adapter";
   77         case EISA_DEVICE_ID_3COM_3C597_MII:
   78                 return "3Com 3C597-MII Network Adapter";
   79         default:
   80                 break;
   81         }
   82         return (NULL);
   83 }
   84 
   85 static int
   86 vx_eisa_probe(device_t dev)
   87 {
   88         const char *desc;
   89         u_long iobase;
   90         u_long port;
   91 
   92         desc = vx_match(eisa_get_id(dev));
   93         if (!desc)
   94                 return (ENXIO);
   95         device_set_desc(dev, desc);
   96 
   97         port = eisa_get_slot(dev) * EISA_SLOT_SIZE;
   98         iobase = port + VX_EISA_SLOT_OFFSET;
   99 
  100         eisa_add_iospace(dev, iobase, VX_EISA_IOSIZE, RESVADDR_NONE);
  101         eisa_add_iospace(dev, port, VX_IOSIZE, RESVADDR_NONE);
  102 
  103         /* Set irq */
  104         eisa_add_intr(dev, inw(iobase + VX_RESOURCE_CONFIG) >> 12,
  105             EISA_TRIGGER_EDGE);
  106 
  107         return (0);
  108 }
  109 
  110 static int
  111 vx_eisa_attach(device_t dev)
  112 {
  113         struct vx_softc *sc;
  114         struct resource *io = 0;
  115         struct resource *eisa_io = 0;
  116         struct resource *irq = 0;
  117         int rid;
  118 
  119         /*
  120          * The addresses are sorted in increasing order
  121          * so we know the port to pass to the core ep
  122          * driver comes first.
  123          */
  124         rid = 0;
  125         io = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
  126         if (!io) {
  127                 device_printf(dev, "No I/O space?!\n");
  128                 goto bad;
  129         }
  130         rid = 1;
  131         eisa_io = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
  132         if (!eisa_io) {
  133                 device_printf(dev, "No I/O space?!\n");
  134                 goto bad;
  135         }
  136         sc = device_get_softc(dev);
  137 
  138         sc->vx_res = io;
  139         sc->vx_bst = rman_get_bustag(io);
  140         sc->vx_bsh = rman_get_bushandle(io);
  141 
  142         rid = 0;
  143         irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
  144         if (!irq) {
  145                 device_printf(dev, "No irq?!\n");
  146                 goto bad;
  147         }
  148         sc->vx_irq = irq;
  149 
  150         /* Now the registers are availible through the lower ioport */
  151 
  152         if (vx_attach(dev) == 0)
  153                 goto bad;
  154 
  155         if (bus_setup_intr(dev, irq, INTR_TYPE_NET | INTR_MPSAFE, NULL,
  156                   vx_intr, sc, &sc->vx_intrhand))
  157                 goto bad_mtx;
  158 
  159         return (0);
  160 
  161 bad_mtx:
  162         mtx_destroy(&sc->vx_mtx);
  163         ether_ifdetach(sc->vx_ifp);
  164         if_free(sc->vx_ifp);
  165 bad:
  166         if (io)
  167                 bus_release_resource(dev, SYS_RES_IOPORT, 0, io);
  168         if (eisa_io)
  169                 bus_release_resource(dev, SYS_RES_IOPORT, 0, eisa_io);
  170         if (irq)
  171                 bus_release_resource(dev, SYS_RES_IRQ, 0, irq);
  172         return (ENXIO);
  173 }
  174 
  175 static device_method_t vx_eisa_methods[] = {
  176         /* Device interface */
  177         DEVMETHOD(device_probe, vx_eisa_probe),
  178         DEVMETHOD(device_attach, vx_eisa_attach),
  179 
  180         {0, 0}
  181 };
  182 
  183 static driver_t vx_eisa_driver = {
  184         "vx",
  185         vx_eisa_methods,
  186         sizeof(struct vx_softc)
  187 };
  188 
  189 static devclass_t vx_devclass;
  190 
  191 DRIVER_MODULE(vx, eisa, vx_eisa_driver, vx_devclass, 0, 0);

Cache object: dca28f40ff2bd1bacae3370abb8d55ff


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.