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/fdc/fdc_pccard.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) 2004-2005 M. Warner Losh.
    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 AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  */
   26 
   27 #include <sys/cdefs.h>
   28 __FBSDID("$FreeBSD: src/sys/dev/fdc/fdc_pccard.c,v 1.8.2.2 2005/01/30 00:59:41 imp Exp $");
   29 
   30 #include <sys/param.h>
   31 #include <sys/bio.h>
   32 #include <sys/bus.h>
   33 #include <sys/kernel.h>
   34 #include <sys/lock.h>
   35 #include <sys/module.h>
   36 #include <sys/mutex.h>
   37 #include <sys/rman.h>
   38 #include <sys/systm.h>
   39 #include <machine/bus.h>
   40 
   41 #include <machine/bus.h>
   42 
   43 #include <dev/fdc/fdcvar.h>
   44 #include <dev/pccard/pccardvar.h>
   45 #include "pccarddevs.h"
   46 
   47 static int fdc_pccard_probe(device_t);
   48 static int fdc_pccard_attach(device_t);
   49 
   50 static const struct pccard_product fdc_pccard_products[] = {
   51         PCMCIA_CARD(YEDATA, EXTERNAL_FDD, 0),
   52 };
   53         
   54 static int
   55 fdc_pccard_alloc_resources(device_t dev, struct fdc_data *fdc)
   56 {
   57         fdc->rid_ioport = 0;
   58         fdc->res_ioport = bus_alloc_resource(dev, SYS_RES_IOPORT,
   59             &fdc->rid_ioport, 0ul, ~0ul, 1, RF_ACTIVE);
   60         if (fdc->res_ioport == NULL) {
   61                 device_printf(dev, "cannot alloc I/O port range\n");
   62                 return (ENXIO);
   63         }
   64         fdc->portt = rman_get_bustag(fdc->res_ioport);
   65         fdc->porth = rman_get_bushandle(fdc->res_ioport);
   66         fdc->stst = fdc->portt;
   67         fdc->stsh = fdc->porth;
   68         fdc->sts_off = 0;
   69         fdc->ctlt = fdc->portt;
   70         fdc->ctlh = fdc->porth;
   71         fdc->ctl_off = 7;
   72 
   73         fdc->rid_irq = 0;
   74         fdc->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &fdc->rid_irq,
   75             RF_ACTIVE | RF_SHAREABLE);
   76         if (fdc->res_irq == NULL) {
   77                 device_printf(dev, "cannot reserve interrupt line\n");
   78                 return (ENXIO);
   79         }
   80         return (0);
   81 }
   82 
   83 static int
   84 fdc_pccard_probe(device_t dev)
   85 {
   86         const struct pccard_product *pp;
   87 
   88         if ((pp = pccard_product_lookup(dev, fdc_pccard_products,
   89             sizeof(fdc_pccard_products[0]), NULL)) != NULL) {
   90                 device_set_desc(dev, "PC Card Floppy");
   91                 return (0);
   92         }
   93         return (ENXIO);
   94 }
   95 
   96 static int
   97 fdc_pccard_attach(device_t dev)
   98 {
   99         int error;
  100         struct  fdc_data *fdc;
  101         device_t child;
  102 
  103         fdc = device_get_softc(dev);
  104         fdc->flags = FDC_NODMA;
  105         fdc->fdct = FDC_NE765;
  106         error = fdc_pccard_alloc_resources(dev, fdc);
  107         if (error == 0)
  108                 error = fdc_attach(dev);
  109         if (error == 0) {
  110                 child = fdc_add_child(dev, "fd", -1);
  111                 device_set_flags(child, 0x24);
  112                 error = bus_generic_attach(dev);
  113         }
  114         if (error)
  115                 fdc_release_resources(fdc);
  116         return (error);
  117 }
  118 
  119 static device_method_t fdc_pccard_methods[] = {
  120         /* Device interface */
  121         DEVMETHOD(device_probe,         fdc_pccard_probe),
  122         DEVMETHOD(device_attach,        fdc_pccard_attach),
  123         DEVMETHOD(device_detach,        fdc_detach),
  124         DEVMETHOD(device_shutdown,      bus_generic_shutdown),
  125         DEVMETHOD(device_suspend,       bus_generic_suspend),
  126         DEVMETHOD(device_resume,        bus_generic_resume),
  127 
  128         /* Bus interface */
  129         DEVMETHOD(bus_print_child,      fdc_print_child),
  130         DEVMETHOD(bus_read_ivar,        fdc_read_ivar),
  131         DEVMETHOD(bus_write_ivar,       fdc_write_ivar),
  132         /* Our children never use any other bus interface methods. */
  133 
  134         { 0, 0 }
  135 };
  136 
  137 static driver_t fdc_pccard_driver = {
  138         "fdc",
  139         fdc_pccard_methods,
  140         sizeof(struct fdc_data)
  141 };
  142 
  143 DRIVER_MODULE(fdc, pccard, fdc_pccard_driver, fdc_devclass, 0, 0);

Cache object: 2c1a9d4db88c6e0bc2fc5f0f1a995c72


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