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/hfa/hfa_pci.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) 2002 Matthew N. Dodd <winter@jurai.net>
    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 
   28 #include <sys/cdefs.h>
   29 __FBSDID("$FreeBSD$");
   30 
   31 /*
   32  *
   33  * ===================================
   34  * HARP  |  Host ATM Research Platform
   35  * ===================================
   36  *
   37  *
   38  * This Host ATM Research Platform ("HARP") file (the "Software") is
   39  * made available by Network Computing Services, Inc. ("NetworkCS")
   40  * "AS IS".  NetworkCS does not provide maintenance, improvements or
   41  * support of any kind.
   42  *
   43  * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
   44  * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
   45  * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
   46  * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
   47  * In no event shall NetworkCS be responsible for any damages, including
   48  * but not limited to consequential damages, arising from or relating to
   49  * any use of the Software or related support.
   50  *
   51  * Copyright 1994-1998 Network Computing Services, Inc.
   52  *
   53  * Copies of this Software may be made, however, the above copyright
   54  * notice must be reproduced on all copies.
   55  *
   56  */
   57 
   58 #include <sys/param.h>
   59 #include <sys/systm.h>
   60 #include <sys/socket.h>
   61 #include <sys/socketvar.h>
   62 #include <sys/kernel.h>
   63 #include <sys/lock.h>
   64 #include <sys/malloc.h>
   65 #include <sys/socket.h>
   66 #include <sys/sysctl.h>
   67 
   68 #include <sys/bus.h>
   69 #include <sys/conf.h>
   70 
   71 #include <sys/module.h>
   72 #include <machine/bus_memio.h>
   73 #include <machine/bus.h>
   74 #include <machine/resource.h>
   75 #include <sys/rman.h> 
   76 
   77 #include <net/if.h>
   78 #include <netatm/port.h>
   79 #include <netatm/queue.h>
   80 #include <netatm/atm.h>
   81 #include <netatm/atm_sys.h>
   82 #include <netatm/atm_sap.h>
   83 #include <netatm/atm_cm.h>
   84 #include <netatm/atm_if.h>
   85 #include <netatm/atm_stack.h>
   86 #include <netatm/atm_pcb.h>
   87 #include <netatm/atm_var.h>
   88 
   89 #include <dev/pci/pcireg.h>
   90 #include <dev/pci/pcivar.h>
   91 
   92 #include <dev/hfa/fore.h>
   93 #include <dev/hfa/fore_aali.h>
   94 #include <dev/hfa/fore_slave.h>
   95 #include <dev/hfa/fore_stats.h>
   96 #include <dev/hfa/fore_var.h>
   97 #include <dev/hfa/fore_include.h>
   98 
   99 #include <dev/hfa/hfa_freebsd.h>
  100 
  101 static int hfa_pci_probe(device_t);
  102 static int hfa_pci_attach(device_t);
  103 
  104 #define FORE_PCA200EPC_ID       0x0300
  105 
  106 static int
  107 hfa_pci_probe (dev)
  108         device_t dev;
  109 {
  110         if ((pci_get_vendor(dev) == FORE_VENDOR_ID) &&
  111             (pci_get_device(dev) == FORE_PCA200EPC_ID)) {
  112                 device_set_desc(dev, "FORE Systems PCA-200EPC ATM");
  113                 return (0);
  114         }
  115 
  116         return (ENXIO);
  117 }
  118 
  119 static int
  120 hfa_pci_attach (dev)
  121         device_t dev;
  122 {
  123         struct hfa_softc *sc;
  124         Fore_unit *fup;
  125         u_int32_t command;
  126         vm_offset_t va;
  127         int error;
  128 
  129         sc = device_get_softc(dev);
  130         fup = &sc->fup;
  131         error = 0;
  132 
  133         pci_enable_busmaster(dev);
  134 
  135         sc->mem_rid = PCA200E_PCI_MEMBASE;
  136         sc->mem_type = SYS_RES_MEMORY;
  137         sc->irq_rid = 0;
  138 
  139         error = hfa_alloc(dev);
  140         if (error) {
  141                 device_printf(dev, "hfa_alloc() failed.\n");
  142                 goto fail;
  143         }
  144 
  145         va = (vm_offset_t) rman_get_virtual(sc->mem);
  146 
  147         fup->fu_ram = (Fore_mem *)va;
  148         fup->fu_ramsize = PCA200E_RAM_SIZE;
  149         fup->fu_mon = (Mon960 *)(fup->fu_ram + MON960_BASE);
  150         fup->fu_ctlreg = (Fore_reg *)(va + PCA200E_HCR_OFFSET);
  151         fup->fu_imask = (Fore_reg *)(va + PCA200E_IMASK_OFFSET);
  152         fup->fu_psr = (Fore_reg *)(va + PCA200E_PSR_OFFSET);
  153 
  154         /*
  155          * Convert Endianess of Slave RAM accesses
  156          */
  157         command = pci_read_config(dev, PCA200E_PCI_MCTL, 4);
  158         command |= PCA200E_MCTL_SWAP;
  159         pci_write_config(dev, PCA200E_PCI_MCTL, command, 4);
  160 
  161         /*
  162          * Map interrupt in
  163          */
  164         error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET,
  165                                     hfa_intr, sc, &sc->irq_ih);
  166         if (error) {
  167                 device_printf(dev, "Interrupt handler setup failed.\n");
  168                 goto fail;
  169         }
  170 
  171         fup->fu_config.ac_bustype = BUS_PCI;
  172         fup->fu_config.ac_busslot = (pci_get_bus(dev) << 8)| pci_get_slot(dev);
  173 
  174         switch (pci_get_device(dev)) {
  175         case FORE_PCA200EPC_ID:
  176                 fup->fu_config.ac_device = DEV_FORE_PCA200E;
  177                 break;
  178         default:
  179                 fup->fu_config.ac_device = DEV_UNKNOWN;
  180                 break;
  181         }
  182 
  183         error = hfa_attach(dev);
  184         if (error) {
  185                 device_printf(dev, "hfa_attach() failed.\n");
  186                 goto fail;
  187         }
  188 
  189         return (0);
  190 
  191 fail:
  192         hfa_detach(dev);
  193 
  194         return (error);
  195 }
  196 
  197 static device_method_t hfa_pci_methods[] = {
  198         DEVMETHOD(device_probe,         hfa_pci_probe),
  199         DEVMETHOD(device_attach,        hfa_pci_attach),
  200 
  201         DEVMETHOD(device_detach,        hfa_detach),
  202 
  203         { 0, 0 }
  204 };
  205 
  206 static driver_t hfa_pci_driver = {
  207         "hfa",
  208         hfa_pci_methods,
  209         sizeof(struct hfa_softc)
  210 };
  211 
  212 DRIVER_MODULE(hfa, pci, hfa_pci_driver, hfa_devclass, 0, 0);
  213 MODULE_DEPEND(hfa, hfa, 1, 1, 1);
  214 MODULE_DEPEND(hfa, pci, 1, 1, 1);

Cache object: e29f08ee8028ccf8a224367f8779731b


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