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/acpica/acpi_pcib_pci.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) 2000 Michael Smith
    3  * Copyright (c) 2000 BSDi
    4  * All rights reserved.
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following 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: src/sys/dev/acpica/acpi_pcib_pci.c,v 1.17.8.1 2009/04/15 03:14:26 kensmith Exp $
   28  */
   29 
   30 #include "opt_acpi.h"
   31 
   32 #include <sys/param.h>
   33 #include <sys/bus.h>
   34 #include <sys/kernel.h>
   35 #include <sys/malloc.h>
   36 #include <sys/module.h>
   37 #include <sys/rman.h>
   38 
   39 #include "acpi.h"
   40 #include <dev/acpica/acpivar.h>
   41 #include <dev/acpica/acpi_pcibvar.h>
   42 
   43 #include <bus/pci/pcivar.h>
   44 #include <bus/pci/pcireg.h>
   45 #include <bus/pci/pcib_private.h>
   46 #include "pcib_if.h"
   47 
   48 /* Hooks for the ACPI CA debugging infrastructure. */
   49 #define _COMPONENT      ACPI_BUS
   50 ACPI_MODULE_NAME("PCI_PCI")
   51 
   52 struct acpi_pcib_softc {
   53     struct pcib_softc   ap_pcibsc;
   54     ACPI_HANDLE         ap_handle;
   55     ACPI_BUFFER         ap_prt;         /* interrupt routing table */
   56 };
   57 
   58 struct acpi_pcib_lookup_info {
   59     UINT32              address;
   60     ACPI_HANDLE         handle;
   61 };
   62 
   63 static int              acpi_pcib_pci_probe(device_t bus);
   64 static int              acpi_pcib_pci_attach(device_t bus);
   65 static int              acpi_pcib_pci_resume(device_t bus);
   66 static int              acpi_pcib_read_ivar(device_t dev, device_t child,
   67                             int which, uintptr_t *result);
   68 static int              acpi_pcib_pci_route_interrupt(device_t pcib,
   69                             device_t dev, int pin);
   70 
   71 static device_method_t acpi_pcib_pci_methods[] = {
   72     /* Device interface */
   73     DEVMETHOD(device_probe,             acpi_pcib_pci_probe),
   74     DEVMETHOD(device_attach,            acpi_pcib_pci_attach),
   75     DEVMETHOD(device_resume,            acpi_pcib_pci_resume),
   76 
   77     /* Bus interface */
   78     DEVMETHOD(bus_read_ivar,            acpi_pcib_read_ivar),
   79 
   80     /* pcib interface */
   81     DEVMETHOD(pcib_route_interrupt,     acpi_pcib_pci_route_interrupt),
   82 
   83     DEVMETHOD_END
   84 };
   85 
   86 static devclass_t pcib_devclass;
   87 
   88 DEFINE_CLASS_1(pcib, acpi_pcib_pci_driver, acpi_pcib_pci_methods,
   89     sizeof(struct acpi_pcib_softc), pcib_driver);
   90 DRIVER_MODULE(acpi_pcib, pci, acpi_pcib_pci_driver, pcib_devclass, NULL, NULL);
   91 MODULE_DEPEND(acpi_pcib, acpi, 1, 1, 1);
   92 
   93 static int
   94 acpi_pcib_pci_probe(device_t dev)
   95 {
   96     int error;
   97 
   98     if (pci_get_class(dev) != PCIC_BRIDGE ||
   99         pci_get_subclass(dev) != PCIS_BRIDGE_PCI ||
  100         acpi_disabled("pci"))
  101         return (ENXIO);
  102 
  103     error = acpi_pcib_probe(dev);
  104     if (error)
  105         return (error);
  106 
  107     device_set_desc(dev, "ACPI PCI-PCI bridge");
  108     return (-100);
  109 }
  110 
  111 static int
  112 acpi_pcib_pci_attach(device_t dev)
  113 {
  114     struct acpi_pcib_softc *sc;
  115 
  116     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
  117 
  118     pcib_attach_common(dev);
  119     sc = device_get_softc(dev);
  120     sc->ap_handle = acpi_get_handle(dev);
  121     return (acpi_pcib_attach(dev, &sc->ap_prt, sc->ap_pcibsc.secbus));
  122 }
  123 
  124 static int
  125 acpi_pcib_pci_resume(device_t dev)
  126 {
  127     return (acpi_pcib_resume(dev));
  128 }
  129 
  130 static int
  131 acpi_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
  132 {
  133     struct acpi_pcib_softc *sc = device_get_softc(dev);
  134 
  135     switch (which) {
  136     case ACPI_IVAR_HANDLE:
  137         *result = (uintptr_t)sc->ap_handle;
  138         return (0);
  139     }
  140     return (pcib_read_ivar(dev, child, which, result));
  141 }
  142 
  143 static int
  144 acpi_pcib_pci_route_interrupt(device_t pcib, device_t dev, int pin)
  145 {
  146     struct acpi_pcib_softc *sc = device_get_softc(pcib);
  147 
  148     /*
  149      * If we don't have a _PRT, fall back to the swizzle method
  150      * for routing interrupts.
  151      */
  152     if (sc->ap_prt.Pointer == NULL) {
  153         device_printf(pcib, "No _PRT found, routing with pci\n");
  154         return (pcib_route_interrupt(pcib, dev, pin));
  155     } else {
  156         return (acpi_pcib_route_interrupt(pcib, dev, pin, &sc->ap_prt));
  157     }
  158 }

Cache object: 26618e1705446f1bfe6ca6107971ae48


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