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/snc/if_snc_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) 1995, David Greenman
    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 unmodified, this list of conditions, and the following
   10  *    disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  *
   15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   25  * SUCH DAMAGE.
   26  *
   27  * $FreeBSD: releng/5.0/sys/dev/snc/if_snc_pccard.c 68054 2000-10-31 08:22:26Z phk $
   28  */
   29 
   30 /*
   31  *      National Semiconductor  DP8393X SONIC Driver
   32  *
   33  *      This is the PC-Card attachment on FreeBSD
   34  *              written by Motomichi Matsuzaki <mzaki@e-mail.ne.jp> and
   35  *                         Hiroshi Yamashita <bluemoon@msj.biglobe.ne.jp>
   36  */
   37 
   38 #include <sys/param.h>
   39 #include <sys/systm.h>
   40 #include <sys/socket.h>
   41 #include <sys/kernel.h>
   42 
   43 #include <sys/module.h>
   44 #include <sys/bus.h>
   45 #include <machine/bus.h>
   46 
   47 #include <net/if.h>
   48 #include <net/if_arp.h>
   49 #include <net/if_media.h>
   50 
   51 
   52 #include <dev/snc/dp83932var.h>
   53 #include <dev/snc/if_sncvar.h>
   54 #include <dev/snc/if_sncreg.h>
   55 
   56 /*
   57  *      PC-Card (PCMCIA) specific code.
   58  */
   59 static int      snc_pccard_probe(device_t);
   60 static int      snc_pccard_attach(device_t);
   61 static int      snc_pccard_detach(device_t);
   62 
   63 
   64 static device_method_t snc_pccard_methods[] = {
   65         /* Device interface */
   66         DEVMETHOD(device_probe,         snc_pccard_probe),
   67         DEVMETHOD(device_attach,        snc_pccard_attach),
   68         DEVMETHOD(device_detach,        snc_pccard_detach),
   69 
   70         { 0, 0 }
   71 };
   72 
   73 static driver_t snc_pccard_driver = {
   74         "snc",
   75         snc_pccard_methods,
   76         sizeof(struct snc_softc)
   77 };
   78 
   79 DRIVER_MODULE(if_snc, pccard, snc_pccard_driver, snc_devclass, 0, 0);
   80 
   81 /*
   82  *      snc_pccard_detach - unload the driver and clear the table.
   83  *      XXX TODO:
   84  *      This is usually called when the card is ejected, but
   85  *      can be caused by a modunload of a controller driver.
   86  *      The idea is to reset the driver's view of the device
   87  *      and ensure that any driver entry points such as
   88  *      read and write do not hang.
   89  */
   90 static int
   91 snc_pccard_detach(device_t dev)
   92 {
   93         struct snc_softc *sc = device_get_softc(dev);
   94         struct ifnet *ifp = &sc->sc_if;
   95 
   96         if (sc->gone) {
   97                 device_printf(dev, "already unloaded\n");
   98                 return (0);
   99         }
  100         sncshutdown(sc);
  101         ifp->if_flags &= ~IFF_RUNNING;
  102         if_detach(ifp);
  103         sc->gone = 1;
  104         bus_teardown_intr(dev, sc->irq, sc->irq_handle);
  105         snc_release_resources(dev);
  106         return (0);
  107 }
  108 
  109 /* 
  110  * Probe framework for pccards.  Replicates the standard framework,
  111  * minus the pccard driver registration and ignores the ether address
  112  * supplied (from the CIS), relying on the probe to find it instead.
  113  */
  114 static int
  115 snc_pccard_probe(device_t dev)
  116 {
  117         int     error;
  118 
  119         error = snc_alloc_port(dev, 0);
  120         error = max(error, snc_alloc_memory(dev, 0));
  121         error = max(error, snc_alloc_irq(dev, 0, 0));
  122 
  123         if (!error && !snc_probe(dev, SNEC_TYPE_PNP))
  124                 error = ENOENT;
  125 
  126         snc_release_resources(dev);
  127         return (error);
  128 }
  129 
  130 static int
  131 snc_pccard_attach(device_t dev)
  132 {
  133         struct snc_softc *sc = device_get_softc(dev);
  134         int error;
  135         
  136         bzero(sc, sizeof(struct snc_softc));
  137 
  138         snc_alloc_port(dev, 0);
  139         snc_alloc_memory(dev, 0);
  140         snc_alloc_irq(dev, 0, 0);
  141                 
  142         error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET,
  143                                sncintr, sc, &sc->irq_handle);
  144         if (error) {
  145                 printf("snc_isa_attach: bus_setup_intr() failed\n");
  146                 snc_release_resources(dev);
  147                 return (error);
  148         }              
  149 
  150         /* This interface is always enabled. */
  151         sc->sc_enabled = 1;
  152 
  153         /* pccard_get_ether(dev, ether_addr); */
  154 
  155         return snc_attach(dev);
  156 } 

Cache object: febff4cc85bea2e0499c04be9b69759e


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