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/netif/sn/if_sn_pccard.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 1999 M. Warner Losh <imp@village.org> 
    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  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   24  *
   25  * $FreeBSD: src/sys/dev/sn/if_sn_pccard.c,v 1.3.2.2 2001/01/25 19:40:27 imp Exp $
   26  */
   27 
   28 /*
   29  * Modifications for Megahertz X-Jack Ethernet Card (XJ-10BT)
   30  * 
   31  * Copyright (c) 1996 by Tatsumi Hosokawa <hosokawa@jp.FreeBSD.org>
   32  *                       BSD-nomads, Tokyo, Japan.
   33  */
   34 
   35 #include <sys/param.h>
   36 #include <sys/systm.h>
   37 #include <sys/kernel.h>
   38 #include <sys/socket.h>
   39 #include <sys/module.h>
   40 #include <sys/bus.h>
   41 #include <sys/rman.h>
   42  
   43 #include <net/ethernet.h> 
   44 #include <net/if.h> 
   45 #include <net/if_arp.h>
   46 #include <net/if_media.h>
   47 
   48 #include <machine/clock.h>
   49 
   50 #include "if_snreg.h"
   51 #include "if_snvar.h"
   52 #include <bus/pccard/pccardvar.h>
   53 
   54 #include "card_if.h"
   55 #include "pccarddevs.h"
   56 
   57 static const struct pccard_product sn_pccard_products[] = {
   58         PCMCIA_CARD(DSPSI, XJACK, 0),
   59         PCMCIA_CARD(NEWMEDIA, BASICS, 0),
   60 #if 0
   61         PCMCIA_CARD(SMC, 8020BT, 0),
   62 #endif
   63         { NULL }
   64 };
   65 
   66 static int
   67 sn_pccard_match(device_t dev)
   68 {
   69         const struct pccard_product *pp;
   70 
   71         if ((pp = pccard_product_lookup(dev, sn_pccard_products,
   72             sizeof(sn_pccard_products[0]), NULL)) != NULL) {
   73                 if (pp->pp_name != NULL)
   74                         device_set_desc(dev, pp->pp_name);
   75                 return 0;
   76         }
   77         return EIO;
   78 }
   79 
   80 /*
   81  * Initialize the device - called from Slot manager.
   82  */
   83 static int
   84 sn_pccard_probe(device_t dev)
   85 {
   86         return (sn_probe(dev, 1));
   87 }
   88 
   89 static int
   90 sn_pccard_attach(device_t dev)
   91 {
   92         struct sn_softc *sc = device_get_softc(dev);
   93         int i;
   94         uint8_t sum;
   95         const uint8_t *ether_addr;
   96 
   97         sc->pccard_enaddr = 0;
   98         ether_addr = pccard_get_ether(dev);
   99         for (i = 0, sum = 0; i < ETHER_ADDR_LEN; i++)
  100                 sum |= ether_addr[i];
  101         if (sum) {
  102                 sc->pccard_enaddr = 1;
  103                 bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
  104         }
  105 
  106         return (sn_attach(dev));
  107 }
  108 
  109 static int
  110 sn_pccard_detach(device_t dev)
  111 {
  112         struct sn_softc *sc = device_get_softc(dev);
  113         struct ifnet *ifp = &sc->arpcom.ac_if;
  114 
  115         lwkt_serialize_enter(ifp->if_serializer);
  116         ifp->if_flags &= ~IFF_RUNNING;
  117         bus_teardown_intr(dev, sc->irq_res, sc->intrhand);
  118         lwkt_serialize_enter(ifp->if_serializer);
  119 
  120         ether_ifdetach(&sc->arpcom.ac_if);
  121         sn_deactivate(dev);
  122 
  123         return 0;
  124 }
  125 
  126 static device_method_t sn_pccard_methods[] = {
  127         /* Device interface */
  128         DEVMETHOD(device_probe,         pccard_compat_probe),
  129         DEVMETHOD(device_attach,        pccard_compat_attach),
  130         DEVMETHOD(device_detach,        sn_pccard_detach),
  131 
  132         /* Card interface */
  133         DEVMETHOD(card_compat_match,    sn_pccard_match),
  134         DEVMETHOD(card_compat_probe,    sn_pccard_probe),
  135         DEVMETHOD(card_compat_attach,   sn_pccard_attach),
  136 
  137         DEVMETHOD_END
  138 };
  139 
  140 static driver_t sn_pccard_driver = {
  141         "sn",
  142         sn_pccard_methods,
  143         sizeof(struct sn_softc),
  144 };
  145 
  146 extern devclass_t sn_devclass;
  147 
  148 DRIVER_MODULE(if_sn, pccard, sn_pccard_driver, sn_devclass, NULL, NULL);

Cache object: ebf7a6aa7f3f0bbea9fc73c736d94783


[ 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.