acpi_pcib_acpi.c (252576) | acpi_pcib_acpi.c (261790) |
---|---|
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: --- 12 unchanged lines hidden (view full) --- 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 28#include <sys/cdefs.h> | 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: --- 12 unchanged lines hidden (view full) --- 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 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/dev/acpica/acpi_pcib_acpi.c 252576 2013-07-03 17:26:05Z jhb $"); | 29__FBSDID("$FreeBSD: head/sys/dev/acpica/acpi_pcib_acpi.c 261790 2014-02-12 04:30:37Z jhb $"); |
30 31#include "opt_acpi.h" 32#include <sys/param.h> 33#include <sys/bus.h> 34#include <sys/kernel.h> 35#include <sys/limits.h> 36#include <sys/malloc.h> 37#include <sys/module.h> 38#include <sys/rman.h> 39#include <sys/sysctl.h> 40 41#include <contrib/dev/acpica/include/acpi.h> 42#include <contrib/dev/acpica/include/accommon.h> 43 44#include <dev/acpica/acpivar.h> 45 46#include <machine/pci_cfgreg.h> | 30 31#include "opt_acpi.h" 32#include <sys/param.h> 33#include <sys/bus.h> 34#include <sys/kernel.h> 35#include <sys/limits.h> 36#include <sys/malloc.h> 37#include <sys/module.h> 38#include <sys/rman.h> 39#include <sys/sysctl.h> 40 41#include <contrib/dev/acpica/include/acpi.h> 42#include <contrib/dev/acpica/include/accommon.h> 43 44#include <dev/acpica/acpivar.h> 45 46#include <machine/pci_cfgreg.h> |
47#include <dev/pci/pcireg.h> |
|
47#include <dev/pci/pcivar.h> 48#include <dev/pci/pcib_private.h> 49#include "pcib_if.h" 50 51#include <dev/acpica/acpi_pcibvar.h> 52 53/* Hooks for the ACPI CA debugging infrastructure. */ 54#define _COMPONENT ACPI_BUS --- 36 unchanged lines hidden (view full) --- 91static struct resource *acpi_pcib_acpi_alloc_resource(device_t dev, 92 device_t child, int type, int *rid, 93 u_long start, u_long end, u_long count, 94 u_int flags); 95#ifdef NEW_PCIB 96static int acpi_pcib_acpi_adjust_resource(device_t dev, 97 device_t child, int type, struct resource *r, 98 u_long start, u_long end); | 48#include <dev/pci/pcivar.h> 49#include <dev/pci/pcib_private.h> 50#include "pcib_if.h" 51 52#include <dev/acpica/acpi_pcibvar.h> 53 54/* Hooks for the ACPI CA debugging infrastructure. */ 55#define _COMPONENT ACPI_BUS --- 36 unchanged lines hidden (view full) --- 92static struct resource *acpi_pcib_acpi_alloc_resource(device_t dev, 93 device_t child, int type, int *rid, 94 u_long start, u_long end, u_long count, 95 u_int flags); 96#ifdef NEW_PCIB 97static int acpi_pcib_acpi_adjust_resource(device_t dev, 98 device_t child, int type, struct resource *r, 99 u_long start, u_long end); |
100#ifdef PCI_RES_BUS 101static int acpi_pcib_acpi_release_resource(device_t dev, 102 device_t child, int type, int rid, 103 struct resource *r); |
|
99#endif | 104#endif |
105#endif |
|
100 101static device_method_t acpi_pcib_acpi_methods[] = { 102 /* Device interface */ 103 DEVMETHOD(device_probe, acpi_pcib_acpi_probe), 104 DEVMETHOD(device_attach, acpi_pcib_acpi_attach), 105 DEVMETHOD(device_shutdown, bus_generic_shutdown), 106 DEVMETHOD(device_suspend, bus_generic_suspend), 107 DEVMETHOD(device_resume, bus_generic_resume), 108 109 /* Bus interface */ 110 DEVMETHOD(bus_read_ivar, acpi_pcib_read_ivar), 111 DEVMETHOD(bus_write_ivar, acpi_pcib_write_ivar), 112 DEVMETHOD(bus_alloc_resource, acpi_pcib_acpi_alloc_resource), 113#ifdef NEW_PCIB 114 DEVMETHOD(bus_adjust_resource, acpi_pcib_acpi_adjust_resource), 115#else 116 DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), 117#endif | 106 107static device_method_t acpi_pcib_acpi_methods[] = { 108 /* Device interface */ 109 DEVMETHOD(device_probe, acpi_pcib_acpi_probe), 110 DEVMETHOD(device_attach, acpi_pcib_acpi_attach), 111 DEVMETHOD(device_shutdown, bus_generic_shutdown), 112 DEVMETHOD(device_suspend, bus_generic_suspend), 113 DEVMETHOD(device_resume, bus_generic_resume), 114 115 /* Bus interface */ 116 DEVMETHOD(bus_read_ivar, acpi_pcib_read_ivar), 117 DEVMETHOD(bus_write_ivar, acpi_pcib_write_ivar), 118 DEVMETHOD(bus_alloc_resource, acpi_pcib_acpi_alloc_resource), 119#ifdef NEW_PCIB 120 DEVMETHOD(bus_adjust_resource, acpi_pcib_acpi_adjust_resource), 121#else 122 DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), 123#endif |
124#if defined(NEW_PCIB) && defined(PCI_RES_BUS) 125 DEVMETHOD(bus_release_resource, acpi_pcib_acpi_release_resource), 126#else |
|
118 DEVMETHOD(bus_release_resource, bus_generic_release_resource), | 127 DEVMETHOD(bus_release_resource, bus_generic_release_resource), |
128#endif |
|
119 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 120 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 121 DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), 122 DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), 123 124 /* pcib interface */ 125 DEVMETHOD(pcib_maxslots, pcib_maxslots), 126 DEVMETHOD(pcib_read_config, acpi_pcib_read_config), --- 139 unchanged lines hidden (view full) --- 266 break; 267 default: 268 break; 269 } 270 return (AE_OK); 271} 272#endif 273 | 129 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 130 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 131 DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), 132 DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), 133 134 /* pcib interface */ 135 DEVMETHOD(pcib_maxslots, pcib_maxslots), 136 DEVMETHOD(pcib_read_config, acpi_pcib_read_config), --- 139 unchanged lines hidden (view full) --- 276 break; 277 default: 278 break; 279 } 280 return (AE_OK); 281} 282#endif 283 |
284#if defined(NEW_PCIB) && defined(PCI_RES_BUS) |
|
274static int | 285static int |
286first_decoded_bus(struct acpi_hpcib_softc *sc, u_long *startp) 287{ 288 struct resource_list_entry *rle; 289 290 rle = resource_list_find(&sc->ap_host_res.hr_rl, PCI_RES_BUS, 0); 291 if (rle == NULL) 292 return (ENXIO); 293 *startp = rle->start; 294 return (0); 295} 296#endif 297 298static int |
|
275acpi_pcib_acpi_attach(device_t dev) 276{ 277 struct acpi_hpcib_softc *sc; 278 ACPI_STATUS status; 279 static int bus0_seen = 0; 280 u_int slot, func, busok; | 299acpi_pcib_acpi_attach(device_t dev) 300{ 301 struct acpi_hpcib_softc *sc; 302 ACPI_STATUS status; 303 static int bus0_seen = 0; 304 u_int slot, func, busok; |
305#if defined(NEW_PCIB) && defined(PCI_RES_BUS) 306 struct resource *bus_res; 307 u_long start; 308 int rid; 309#endif |
|
281 uint8_t busno; 282 283 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); 284 285 sc = device_get_softc(dev); 286 sc->ap_dev = dev; 287 sc->ap_handle = acpi_get_handle(dev); 288 --- 95 unchanged lines hidden (view full) --- 384 device_printf(dev, "couldn't read bus number from cfg space\n"); 385 else { 386 sc->ap_bus = busno; 387 busok = 1; 388 } 389 } 390 } 391 | 310 uint8_t busno; 311 312 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); 313 314 sc = device_get_softc(dev); 315 sc->ap_dev = dev; 316 sc->ap_handle = acpi_get_handle(dev); 317 --- 95 unchanged lines hidden (view full) --- 413 device_printf(dev, "couldn't read bus number from cfg space\n"); 414 else { 415 sc->ap_bus = busno; 416 busok = 1; 417 } 418 } 419 } 420 |
421#if defined(NEW_PCIB) && defined(PCI_RES_BUS) |
|
392 /* 393 * If nothing else worked, hope that ACPI at least lays out the | 422 /* 423 * If nothing else worked, hope that ACPI at least lays out the |
424 * Host-PCI bridges in order and that as a result the next free 425 * bus number is our bus number. 426 */ 427 if (busok == 0) { 428 /* 429 * If we have a region of bus numbers, use the first 430 * number for our bus. 431 */ 432 if (first_decoded_bus(sc, &start) == 0) 433 sc->ap_bus = start; 434 else { 435 rid = 0; 436 bus_res = pci_domain_alloc_bus(sc->ap_segment, dev, &rid, 0, 437 PCI_BUSMAX, 1, 0); 438 if (bus_res == NULL) { 439 device_printf(dev, 440 "could not allocate bus number\n"); 441 pcib_host_res_free(dev, &sc->ap_host_res); 442 return (ENXIO); 443 } 444 sc->ap_bus = rman_get_start(bus_res); 445 pci_domain_release_bus(sc->ap_segment, dev, rid, bus_res); 446 } 447 } else { 448#ifdef INVARIANTS 449 if (first_decoded_bus(sc, &start) == 0) 450 KASSERT(start == sc->ap_bus, ("bus number mismatch")); 451#endif 452 } 453#else 454 /* 455 * If nothing else worked, hope that ACPI at least lays out the |
|
394 * host-PCI bridges in order and that as a result our unit number 395 * is actually our bus number. There are several reasons this 396 * might not be true. 397 */ 398 if (busok == 0) { 399 sc->ap_bus = device_get_unit(dev); 400 device_printf(dev, "trying bus number %d\n", sc->ap_bus); 401 } | 456 * host-PCI bridges in order and that as a result our unit number 457 * is actually our bus number. There are several reasons this 458 * might not be true. 459 */ 460 if (busok == 0) { 461 sc->ap_bus = device_get_unit(dev); 462 device_printf(dev, "trying bus number %d\n", sc->ap_bus); 463 } |
464#endif |
|
402 403 /* If this is bus 0 on segment 0, note that it has been seen already. */ 404 if (sc->ap_segment == 0 && sc->ap_bus == 0) 405 bus0_seen = 1; 406 407 return (acpi_pcib_attach(dev, &sc->ap_prt, sc->ap_bus)); 408} 409 --- 119 unchanged lines hidden (view full) --- 529#endif 530 531#if defined(__i386__) || defined(__amd64__) 532 start = hostb_alloc_start(type, start, end, count); 533#endif 534 535#ifdef NEW_PCIB 536 sc = device_get_softc(dev); | 465 466 /* If this is bus 0 on segment 0, note that it has been seen already. */ 467 if (sc->ap_segment == 0 && sc->ap_bus == 0) 468 bus0_seen = 1; 469 470 return (acpi_pcib_attach(dev, &sc->ap_prt, sc->ap_bus)); 471} 472 --- 119 unchanged lines hidden (view full) --- 592#endif 593 594#if defined(__i386__) || defined(__amd64__) 595 start = hostb_alloc_start(type, start, end, count); 596#endif 597 598#ifdef NEW_PCIB 599 sc = device_get_softc(dev); |
600#ifdef PCI_RES_BUS 601 if (type == PCI_RES_BUS) 602 return (pci_domain_alloc_bus(sc->ap_segment, child, rid, start, end, 603 count, flags)); 604#endif |
|
537 res = pcib_host_res_alloc(&sc->ap_host_res, child, type, rid, start, end, 538 count, flags); 539 540 /* 541 * XXX: If this is a request for a specific range, assume it is 542 * correct and pass it up to the parent. What we probably want to 543 * do long-term is explicitly trust any firmware-configured 544 * resources during the initial bus scan on boot and then disable --- 12 unchanged lines hidden (view full) --- 557#ifdef NEW_PCIB 558int 559acpi_pcib_acpi_adjust_resource(device_t dev, device_t child, int type, 560 struct resource *r, u_long start, u_long end) 561{ 562 struct acpi_hpcib_softc *sc; 563 564 sc = device_get_softc(dev); | 605 res = pcib_host_res_alloc(&sc->ap_host_res, child, type, rid, start, end, 606 count, flags); 607 608 /* 609 * XXX: If this is a request for a specific range, assume it is 610 * correct and pass it up to the parent. What we probably want to 611 * do long-term is explicitly trust any firmware-configured 612 * resources during the initial bus scan on boot and then disable --- 12 unchanged lines hidden (view full) --- 625#ifdef NEW_PCIB 626int 627acpi_pcib_acpi_adjust_resource(device_t dev, device_t child, int type, 628 struct resource *r, u_long start, u_long end) 629{ 630 struct acpi_hpcib_softc *sc; 631 632 sc = device_get_softc(dev); |
633#ifdef PCI_RES_BUS 634 if (type == PCI_RES_BUS) 635 return (pci_domain_adjust_bus(sc->ap_segment, child, r, start, 636 end)); 637#endif |
|
565 return (pcib_host_res_adjust(&sc->ap_host_res, child, type, r, start, 566 end)); 567} | 638 return (pcib_host_res_adjust(&sc->ap_host_res, child, type, r, start, 639 end)); 640} |
641 642#ifdef PCI_RES_BUS 643int 644acpi_pcib_acpi_release_resource(device_t dev, device_t child, int type, int rid, 645 struct resource *r) 646{ 647 struct acpi_hpcib_softc *sc; 648 649 sc = device_get_softc(dev); 650 if (type == PCI_RES_BUS) 651 return (pci_domain_release_bus(sc->ap_segment, child, rid, r)); 652 return (bus_generic_release_resource(dev, child, type, rid, r)); 653} |
|
568#endif | 654#endif |
655#endif |
|