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/x86/x86/mptable_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) 2003 John Baldwin <jhb@FreeBSD.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  * 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  * Host to PCI and PCI to PCI bridge drivers that use the MP Table to route
   32  * interrupts from PCI devices to I/O APICs.
   33  */
   34 
   35 #include <sys/cdefs.h>
   36 __FBSDID("$FreeBSD$");
   37 
   38 #include <sys/param.h>
   39 #include <sys/systm.h>
   40 #include <sys/bus.h>
   41 #include <sys/kernel.h>
   42 #include <sys/module.h>
   43 #include <sys/rman.h>
   44 
   45 #include <dev/pci/pcireg.h>
   46 #include <dev/pci/pcivar.h>
   47 #include <dev/pci/pcib_private.h>
   48 #include <machine/legacyvar.h>
   49 #include <machine/mptable.h>
   50 #include <machine/pci_cfgreg.h>
   51 
   52 #include "pcib_if.h"
   53 
   54 /* Host to PCI bridge driver. */
   55 
   56 static int
   57 mptable_hostb_probe(device_t dev)
   58 {
   59 
   60         if (pci_cfgregopen() == 0)
   61                 return (ENXIO);
   62         if (mptable_pci_probe_table(pcib_get_bus(dev)) != 0)
   63                 return (ENXIO);
   64         device_set_desc(dev, "MPTable Host-PCI bridge");
   65         return (0);
   66 }
   67 
   68 static int
   69 mptable_hostb_attach(device_t dev)
   70 {
   71 
   72         device_add_child(dev, "pci", pcib_get_bus(dev));
   73         return (bus_generic_attach(dev));
   74 }
   75 
   76 /* Pass MSI requests up to the nexus. */
   77 static int
   78 mptable_hostb_alloc_msi(device_t pcib, device_t dev, int count, int maxcount,
   79     int *irqs)
   80 {
   81         device_t bus;
   82 
   83         bus = device_get_parent(pcib);
   84         return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount,
   85             irqs));
   86 }
   87 
   88 static int
   89 mptable_hostb_alloc_msix(device_t pcib, device_t dev, int *irq)
   90 {
   91         device_t bus;
   92 
   93         bus = device_get_parent(pcib);
   94         return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq));
   95 }
   96 
   97 static device_method_t mptable_hostb_methods[] = {
   98         /* Device interface */
   99         DEVMETHOD(device_probe,         mptable_hostb_probe),
  100         DEVMETHOD(device_attach,        mptable_hostb_attach),
  101         DEVMETHOD(device_shutdown,      bus_generic_shutdown),
  102         DEVMETHOD(device_suspend,       bus_generic_suspend),
  103         DEVMETHOD(device_resume,        bus_generic_resume),
  104 
  105         /* Bus interface */
  106         DEVMETHOD(bus_read_ivar,        legacy_pcib_read_ivar),
  107         DEVMETHOD(bus_write_ivar,       legacy_pcib_write_ivar),
  108         DEVMETHOD(bus_alloc_resource,   legacy_pcib_alloc_resource),
  109         DEVMETHOD(bus_adjust_resource,  bus_generic_adjust_resource),
  110         DEVMETHOD(bus_release_resource, bus_generic_release_resource),
  111         DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
  112         DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
  113         DEVMETHOD(bus_setup_intr,       bus_generic_setup_intr),
  114         DEVMETHOD(bus_teardown_intr,    bus_generic_teardown_intr),
  115 
  116         /* pcib interface */
  117         DEVMETHOD(pcib_maxslots,        legacy_pcib_maxslots),
  118         DEVMETHOD(pcib_read_config,     legacy_pcib_read_config),
  119         DEVMETHOD(pcib_write_config,    legacy_pcib_write_config),
  120         DEVMETHOD(pcib_route_interrupt, mptable_pci_route_interrupt),
  121         DEVMETHOD(pcib_alloc_msi,       mptable_hostb_alloc_msi),
  122         DEVMETHOD(pcib_release_msi,     pcib_release_msi),
  123         DEVMETHOD(pcib_alloc_msix,      mptable_hostb_alloc_msix),
  124         DEVMETHOD(pcib_release_msix,    pcib_release_msix),
  125         DEVMETHOD(pcib_map_msi,         legacy_pcib_map_msi),
  126 
  127         DEVMETHOD_END
  128 };
  129 
  130 static devclass_t hostb_devclass;
  131 
  132 DEFINE_CLASS_0(pcib, mptable_hostb_driver, mptable_hostb_methods, 1);
  133 DRIVER_MODULE(mptable_pcib, legacy, mptable_hostb_driver, hostb_devclass, 0, 0);
  134 
  135 /* PCI to PCI bridge driver. */
  136 
  137 static int
  138 mptable_pcib_probe(device_t dev)
  139 {
  140         int bus;
  141 
  142         if ((pci_get_class(dev) != PCIC_BRIDGE) ||
  143             (pci_get_subclass(dev) != PCIS_BRIDGE_PCI))
  144                 return (ENXIO);
  145         bus = pci_read_config(dev, PCIR_SECBUS_1, 1);
  146         if (bus == 0)
  147                 return (ENXIO);
  148         if (mptable_pci_probe_table(bus) != 0)
  149                 return (ENXIO);
  150         device_set_desc(dev, "MPTable PCI-PCI bridge");
  151         return (-1000);
  152 }
  153 
  154 static device_method_t mptable_pcib_pci_methods[] = {
  155         /* Device interface */
  156         DEVMETHOD(device_probe,         mptable_pcib_probe),
  157         DEVMETHOD(device_attach,        pcib_attach),
  158         DEVMETHOD(device_shutdown,      bus_generic_shutdown),
  159         DEVMETHOD(device_suspend,       bus_generic_suspend),
  160         DEVMETHOD(device_resume,        bus_generic_resume),
  161 
  162         /* Bus interface */
  163         DEVMETHOD(bus_print_child,      bus_generic_print_child),
  164         DEVMETHOD(bus_read_ivar,        pcib_read_ivar),
  165         DEVMETHOD(bus_write_ivar,       pcib_write_ivar),
  166         DEVMETHOD(bus_alloc_resource,   pcib_alloc_resource),
  167         DEVMETHOD(bus_release_resource, bus_generic_release_resource),
  168         DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
  169         DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
  170         DEVMETHOD(bus_setup_intr,       bus_generic_setup_intr),
  171         DEVMETHOD(bus_teardown_intr,    bus_generic_teardown_intr),
  172 
  173         /* pcib interface */
  174         DEVMETHOD(pcib_maxslots,        pcib_maxslots),
  175         DEVMETHOD(pcib_read_config,     pcib_read_config),
  176         DEVMETHOD(pcib_write_config,    pcib_write_config),
  177         DEVMETHOD(pcib_route_interrupt, mptable_pci_route_interrupt),
  178         DEVMETHOD(pcib_alloc_msi,       pcib_alloc_msi),
  179         DEVMETHOD(pcib_release_msi,     pcib_release_msi),
  180         DEVMETHOD(pcib_alloc_msix,      pcib_alloc_msix),
  181         DEVMETHOD(pcib_release_msix,    pcib_release_msix),
  182         DEVMETHOD(pcib_map_msi,         pcib_map_msi),
  183 
  184         {0, 0}
  185 };
  186 
  187 static devclass_t pcib_devclass;
  188 
  189 DEFINE_CLASS_0(pcib, mptable_pcib_driver, mptable_pcib_pci_methods,
  190     sizeof(struct pcib_softc));
  191 DRIVER_MODULE(mptable_pcib, pci, mptable_pcib_driver, pcib_devclass, 0, 0);

Cache object: 5054bbf319a5c5e63f1f0be2f692609b


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