Deleted Added
sdiff udiff text old ( 252576 ) new ( 261790 )
full compact
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 $");
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/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);
99#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
118 DEVMETHOD(bus_release_resource, bus_generic_release_resource),
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
274static 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;
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
392 /*
393 * 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 }
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);
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);
565 return (pcib_host_res_adjust(&sc->ap_host_res, child, type, r, start,
566 end));
567}
568#endif