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
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD: releng/10.3/sys/dev/acpica/acpi_pcib_acpi.c 281687 2015-04-18 08:01:12Z jkim $");
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>
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
56 ACPI_MODULE_NAME("PCI_ACPI")
57
58 struct acpi_hpcib_softc {
59 device_t ap_dev;
60 ACPI_HANDLE ap_handle;
61 int ap_flags;
62
63 int ap_segment; /* PCI domain */
64 int ap_bus; /* bios-assigned bus number */
65 int ap_addr; /* device/func of PCI-Host bridge */
66
67 ACPI_BUFFER ap_prt; /* interrupt routing table */
68 #ifdef NEW_PCIB
69 struct pcib_host_resources ap_host_res;
70 #endif
71 };
72
73 static int acpi_pcib_acpi_probe(device_t bus);
74 static int acpi_pcib_acpi_attach(device_t bus);
75 static int acpi_pcib_read_ivar(device_t dev, device_t child,
76 int which, uintptr_t *result);
77 static int acpi_pcib_write_ivar(device_t dev, device_t child,
78 int which, uintptr_t value);
79 static uint32_t acpi_pcib_read_config(device_t dev, u_int bus,
80 u_int slot, u_int func, u_int reg, int bytes);
81 static void acpi_pcib_write_config(device_t dev, u_int bus,
82 u_int slot, u_int func, u_int reg, uint32_t data,
83 int bytes);
84 static int acpi_pcib_acpi_route_interrupt(device_t pcib,
85 device_t dev, int pin);
86 static int acpi_pcib_alloc_msi(device_t pcib, device_t dev,
87 int count, int maxcount, int *irqs);
88 static int acpi_pcib_map_msi(device_t pcib, device_t dev,
89 int irq, uint64_t *addr, uint32_t *data);
90 static int acpi_pcib_alloc_msix(device_t pcib, device_t dev,
91 int *irq);
92 static 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
97 static 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
101 static int acpi_pcib_acpi_release_resource(device_t dev,
102 device_t child, int type, int rid,
103 struct resource *r);
104 #endif
105 #endif
106
107 static 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
127 DEVMETHOD(bus_release_resource, bus_generic_release_resource),
128 #endif
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),
137 DEVMETHOD(pcib_write_config, acpi_pcib_write_config),
138 DEVMETHOD(pcib_route_interrupt, acpi_pcib_acpi_route_interrupt),
139 DEVMETHOD(pcib_alloc_msi, acpi_pcib_alloc_msi),
140 DEVMETHOD(pcib_release_msi, pcib_release_msi),
141 DEVMETHOD(pcib_alloc_msix, acpi_pcib_alloc_msix),
142 DEVMETHOD(pcib_release_msix, pcib_release_msix),
143 DEVMETHOD(pcib_map_msi, acpi_pcib_map_msi),
144 DEVMETHOD(pcib_power_for_sleep, acpi_pcib_power_for_sleep),
145
146 DEVMETHOD_END
147 };
148
149 static devclass_t pcib_devclass;
150
151 DEFINE_CLASS_0(pcib, acpi_pcib_acpi_driver, acpi_pcib_acpi_methods,
152 sizeof(struct acpi_hpcib_softc));
153 DRIVER_MODULE(acpi_pcib, acpi, acpi_pcib_acpi_driver, pcib_devclass, 0, 0);
154 MODULE_DEPEND(acpi_pcib, acpi, 1, 1, 1);
155
156 static int
157 acpi_pcib_acpi_probe(device_t dev)
158 {
159 ACPI_DEVICE_INFO *devinfo;
160 ACPI_HANDLE h;
161 int root;
162
163 if (acpi_disabled("pcib") || (h = acpi_get_handle(dev)) == NULL ||
164 ACPI_FAILURE(AcpiGetObjectInfo(h, &devinfo)))
165 return (ENXIO);
166 root = (devinfo->Flags & ACPI_PCI_ROOT_BRIDGE) != 0;
167 AcpiOsFree(devinfo);
168 if (!root || pci_cfgregopen() == 0)
169 return (ENXIO);
170
171 device_set_desc(dev, "ACPI Host-PCI bridge");
172 return (0);
173 }
174
175 #ifdef NEW_PCIB
176 static ACPI_STATUS
177 acpi_pcib_producer_handler(ACPI_RESOURCE *res, void *context)
178 {
179 struct acpi_hpcib_softc *sc;
180 UINT64 length, min, max;
181 u_int flags;
182 int error, type;
183
184 sc = context;
185 switch (res->Type) {
186 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
187 case ACPI_RESOURCE_TYPE_END_DEPENDENT:
188 panic("host bridge has depenedent resources");
189 case ACPI_RESOURCE_TYPE_ADDRESS16:
190 case ACPI_RESOURCE_TYPE_ADDRESS32:
191 case ACPI_RESOURCE_TYPE_ADDRESS64:
192 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
193 if (res->Data.Address.ProducerConsumer != ACPI_PRODUCER)
194 break;
195 switch (res->Type) {
196 case ACPI_RESOURCE_TYPE_ADDRESS16:
197 min = res->Data.Address16.Address.Minimum;
198 max = res->Data.Address16.Address.Maximum;
199 length = res->Data.Address16.Address.AddressLength;
200 break;
201 case ACPI_RESOURCE_TYPE_ADDRESS32:
202 min = res->Data.Address32.Address.Minimum;
203 max = res->Data.Address32.Address.Maximum;
204 length = res->Data.Address32.Address.AddressLength;
205 break;
206 case ACPI_RESOURCE_TYPE_ADDRESS64:
207 min = res->Data.Address64.Address.Minimum;
208 max = res->Data.Address64.Address.Maximum;
209 length = res->Data.Address64.Address.AddressLength;
210 break;
211 default:
212 KASSERT(res->Type ==
213 ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64,
214 ("should never happen"));
215 min = res->Data.ExtAddress64.Address.Minimum;
216 max = res->Data.ExtAddress64.Address.Maximum;
217 length = res->Data.ExtAddress64.Address.AddressLength;
218 break;
219 }
220 if (length == 0)
221 break;
222 if (min + length - 1 != max &&
223 (res->Data.Address.MinAddressFixed != ACPI_ADDRESS_FIXED ||
224 res->Data.Address.MaxAddressFixed != ACPI_ADDRESS_FIXED))
225 break;
226 flags = 0;
227 switch (res->Data.Address.ResourceType) {
228 case ACPI_MEMORY_RANGE:
229 type = SYS_RES_MEMORY;
230 if (res->Type != ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64) {
231 if (res->Data.Address.Info.Mem.Caching ==
232 ACPI_PREFETCHABLE_MEMORY)
233 flags |= RF_PREFETCHABLE;
234 } else {
235 /*
236 * XXX: Parse prefetch flag out of
237 * TypeSpecific.
238 */
239 }
240 break;
241 case ACPI_IO_RANGE:
242 type = SYS_RES_IOPORT;
243 break;
244 #ifdef PCI_RES_BUS
245 case ACPI_BUS_NUMBER_RANGE:
246 type = PCI_RES_BUS;
247 break;
248 #endif
249 default:
250 return (AE_OK);
251 }
252
253 if (min + length - 1 != max)
254 device_printf(sc->ap_dev,
255 "Length mismatch for %d range: %jx vs %jx\n", type,
256 (uintmax_t)(max - min + 1), (uintmax_t)length);
257 #ifdef __i386__
258 if (min > ULONG_MAX) {
259 device_printf(sc->ap_dev,
260 "Ignoring %d range above 4GB (%#jx-%#jx)\n",
261 type, (uintmax_t)min, (uintmax_t)max);
262 break;
263 }
264 if (max > ULONG_MAX) {
265 device_printf(sc->ap_dev,
266 "Truncating end of %d range above 4GB (%#jx-%#jx)\n",
267 type, (uintmax_t)min, (uintmax_t)max);
268 max = ULONG_MAX;
269 }
270 #endif
271 error = pcib_host_res_decodes(&sc->ap_host_res, type, min, max,
272 flags);
273 if (error)
274 panic("Failed to manage %d range (%#jx-%#jx): %d",
275 type, (uintmax_t)min, (uintmax_t)max, error);
276 break;
277 default:
278 break;
279 }
280 return (AE_OK);
281 }
282 #endif
283
284 #if defined(NEW_PCIB) && defined(PCI_RES_BUS)
285 static int
286 first_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
298 static int
299 acpi_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
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
318 /*
319 * Don't attach if we're not really there.
320 */
321 if (!acpi_DeviceIsPresent(dev))
322 return (ENXIO);
323
324 /*
325 * Get our segment number by evaluating _SEG.
326 * It's OK for this to not exist.
327 */
328 status = acpi_GetInteger(sc->ap_handle, "_SEG", &sc->ap_segment);
329 if (ACPI_FAILURE(status)) {
330 if (status != AE_NOT_FOUND) {
331 device_printf(dev, "could not evaluate _SEG - %s\n",
332 AcpiFormatException(status));
333 return_VALUE (ENXIO);
334 }
335 /* If it's not found, assume 0. */
336 sc->ap_segment = 0;
337 }
338
339 /*
340 * Get the address (device and function) of the associated
341 * PCI-Host bridge device from _ADR. Assume we don't have one if
342 * it doesn't exist.
343 */
344 status = acpi_GetInteger(sc->ap_handle, "_ADR", &sc->ap_addr);
345 if (ACPI_FAILURE(status)) {
346 device_printf(dev, "could not evaluate _ADR - %s\n",
347 AcpiFormatException(status));
348 sc->ap_addr = -1;
349 }
350
351 #ifdef NEW_PCIB
352 /*
353 * Determine which address ranges this bridge decodes and setup
354 * resource managers for those ranges.
355 */
356 if (pcib_host_res_init(sc->ap_dev, &sc->ap_host_res) != 0)
357 panic("failed to init hostb resources");
358 if (!acpi_disabled("hostres")) {
359 status = AcpiWalkResources(sc->ap_handle, "_CRS",
360 acpi_pcib_producer_handler, sc);
361 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
362 device_printf(sc->ap_dev, "failed to parse resources: %s\n",
363 AcpiFormatException(status));
364 }
365 #endif
366
367 /*
368 * Get our base bus number by evaluating _BBN.
369 * If this doesn't work, we assume we're bus number 0.
370 *
371 * XXX note that it may also not exist in the case where we are
372 * meant to use a private configuration space mechanism for this bus,
373 * so we should dig out our resources and check to see if we have
374 * anything like that. How do we do this?
375 * XXX If we have the requisite information, and if we don't think the
376 * default PCI configuration space handlers can deal with this bus,
377 * we should attach our own handler.
378 * XXX invoke _REG on this for the PCI config space address space?
379 * XXX It seems many BIOS's with multiple Host-PCI bridges do not set
380 * _BBN correctly. They set _BBN to zero for all bridges. Thus,
381 * if _BBN is zero and PCI bus 0 already exists, we try to read our
382 * bus number from the configuration registers at address _ADR.
383 * We only do this for domain/segment 0 in the hopes that this is
384 * only needed for old single-domain machines.
385 */
386 status = acpi_GetInteger(sc->ap_handle, "_BBN", &sc->ap_bus);
387 if (ACPI_FAILURE(status)) {
388 if (status != AE_NOT_FOUND) {
389 device_printf(dev, "could not evaluate _BBN - %s\n",
390 AcpiFormatException(status));
391 return (ENXIO);
392 } else {
393 /* If it's not found, assume 0. */
394 sc->ap_bus = 0;
395 }
396 }
397
398 /*
399 * If this is segment 0, the bus is zero, and PCI bus 0 already
400 * exists, read the bus number via PCI config space.
401 */
402 busok = 1;
403 if (sc->ap_segment == 0 && sc->ap_bus == 0 && bus0_seen) {
404 busok = 0;
405 if (sc->ap_addr != -1) {
406 /* XXX: We assume bus 0. */
407 slot = ACPI_ADR_PCI_SLOT(sc->ap_addr);
408 func = ACPI_ADR_PCI_FUNC(sc->ap_addr);
409 if (bootverbose)
410 device_printf(dev, "reading config registers from 0:%d:%d\n",
411 slot, func);
412 if (host_pcib_get_busno(pci_cfgregread, 0, slot, func, &busno) == 0)
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)
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
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
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
473 /*
474 * Support for standard PCI bridge ivars.
475 */
476 static int
477 acpi_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
478 {
479 struct acpi_hpcib_softc *sc = device_get_softc(dev);
480
481 switch (which) {
482 case PCIB_IVAR_DOMAIN:
483 *result = sc->ap_segment;
484 return (0);
485 case PCIB_IVAR_BUS:
486 *result = sc->ap_bus;
487 return (0);
488 case ACPI_IVAR_HANDLE:
489 *result = (uintptr_t)sc->ap_handle;
490 return (0);
491 case ACPI_IVAR_FLAGS:
492 *result = (uintptr_t)sc->ap_flags;
493 return (0);
494 }
495 return (ENOENT);
496 }
497
498 static int
499 acpi_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
500 {
501 struct acpi_hpcib_softc *sc = device_get_softc(dev);
502
503 switch (which) {
504 case PCIB_IVAR_DOMAIN:
505 return (EINVAL);
506 case PCIB_IVAR_BUS:
507 sc->ap_bus = value;
508 return (0);
509 case ACPI_IVAR_HANDLE:
510 sc->ap_handle = (ACPI_HANDLE)value;
511 return (0);
512 case ACPI_IVAR_FLAGS:
513 sc->ap_flags = (int)value;
514 return (0);
515 }
516 return (ENOENT);
517 }
518
519 static uint32_t
520 acpi_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func,
521 u_int reg, int bytes)
522 {
523 return (pci_cfgregread(bus, slot, func, reg, bytes));
524 }
525
526 static void
527 acpi_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func,
528 u_int reg, uint32_t data, int bytes)
529 {
530 pci_cfgregwrite(bus, slot, func, reg, data, bytes);
531 }
532
533 static int
534 acpi_pcib_acpi_route_interrupt(device_t pcib, device_t dev, int pin)
535 {
536 struct acpi_hpcib_softc *sc = device_get_softc(pcib);
537
538 return (acpi_pcib_route_interrupt(pcib, dev, pin, &sc->ap_prt));
539 }
540
541 static int
542 acpi_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount,
543 int *irqs)
544 {
545 device_t bus;
546
547 bus = device_get_parent(pcib);
548 return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount,
549 irqs));
550 }
551
552 static int
553 acpi_pcib_alloc_msix(device_t pcib, device_t dev, int *irq)
554 {
555 device_t bus;
556
557 bus = device_get_parent(pcib);
558 return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq));
559 }
560
561 static int
562 acpi_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr,
563 uint32_t *data)
564 {
565 struct acpi_hpcib_softc *sc;
566 device_t bus, hostb;
567 int error;
568
569 bus = device_get_parent(pcib);
570 error = PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data);
571 if (error)
572 return (error);
573
574 sc = device_get_softc(pcib);
575 if (sc->ap_addr == -1)
576 return (0);
577 /* XXX: Assumes all bridges are on bus 0. */
578 hostb = pci_find_dbsf(sc->ap_segment, 0, ACPI_ADR_PCI_SLOT(sc->ap_addr),
579 ACPI_ADR_PCI_FUNC(sc->ap_addr));
580 if (hostb != NULL)
581 pci_ht_map_msi(hostb, *addr);
582 return (0);
583 }
584
585 struct resource *
586 acpi_pcib_acpi_alloc_resource(device_t dev, device_t child, int type, int *rid,
587 u_long start, u_long end, u_long count, u_int flags)
588 {
589 #ifdef NEW_PCIB
590 struct acpi_hpcib_softc *sc;
591 struct resource *res;
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
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
613 * this after that.
614 */
615 if (res == NULL && start + count - 1 == end)
616 res = bus_generic_alloc_resource(dev, child, type, rid, start, end,
617 count, flags);
618 return (res);
619 #else
620 return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
621 count, flags));
622 #endif
623 }
624
625 #ifdef NEW_PCIB
626 int
627 acpi_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
638 return (pcib_host_res_adjust(&sc->ap_host_res, child, type, r, start,
639 end));
640 }
641
642 #ifdef PCI_RES_BUS
643 int
644 acpi_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 }
654 #endif
655 #endif
Cache object: 3a3273112a5fde316a1864cc8c02d974
|