Lines Matching +full:pci +full:- +full:domain

1 /*-
47 #include <dev/pci/pcireg.h>
48 #include <dev/pci/pcivar.h>
49 #include <dev/pci/pcib_private.h>
65 int ap_segment; /* PCI domain */
66 int ap_bus; /* bios-assigned bus number */
67 int ap_addr; /* device/func of PCI-Host bridge */
161 root = (devinfo->Flags & ACPI_PCI_ROOT_BRIDGE) != 0;
166 device_set_desc(dev, "ACPI Host-PCI bridge");
179 switch (res->Type) {
187 if (res->Data.Address.ProducerConsumer != ACPI_PRODUCER)
189 switch (res->Type) {
191 min = res->Data.Address16.Address.Minimum;
192 max = res->Data.Address16.Address.Maximum;
193 length = res->Data.Address16.Address.AddressLength;
196 min = res->Data.Address32.Address.Minimum;
197 max = res->Data.Address32.Address.Maximum;
198 length = res->Data.Address32.Address.AddressLength;
201 min = res->Data.Address64.Address.Minimum;
202 max = res->Data.Address64.Address.Maximum;
203 length = res->Data.Address64.Address.AddressLength;
206 KASSERT(res->Type ==
209 min = res->Data.ExtAddress64.Address.Minimum;
210 max = res->Data.ExtAddress64.Address.Maximum;
211 length = res->Data.ExtAddress64.Address.AddressLength;
216 if (min + length - 1 != max &&
217 (res->Data.Address.MinAddressFixed != ACPI_ADDRESS_FIXED ||
218 res->Data.Address.MaxAddressFixed != ACPI_ADDRESS_FIXED))
221 switch (res->Data.Address.ResourceType) {
224 if (res->Type != ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64) {
225 if (res->Data.Address.Info.Mem.Caching ==
245 if (min + length - 1 != max)
246 device_printf(sc->ap_dev,
248 (uintmax_t)(max - min + 1), (uintmax_t)length);
251 device_printf(sc->ap_dev,
252 "Ignoring %d range above 4GB (%#jx-%#jx)\n",
257 device_printf(sc->ap_dev,
258 "Truncating end of %d range above 4GB (%#jx-%#jx)\n",
263 error = pcib_host_res_decodes(&sc->ap_host_res, type, min, max,
266 panic("Failed to manage %d range (%#jx-%#jx): %d",
281 rle = resource_list_find(&sc->ap_host_res.hr_rl, PCI_RES_BUS, 0);
284 *startp = rle->start;
285 *endp = rle->end;
299 int error, domain;
305 sc->ap_dev = dev;
306 sc->ap_handle = acpi_get_handle(dev);
314 acpi_pcib_osc(dev, &sc->ap_osc_ctl, 0);
320 status = acpi_GetInteger(sc->ap_handle, "_SEG", &sc->ap_segment);
323 device_printf(dev, "could not evaluate _SEG - %s\n",
328 sc->ap_segment = 0;
333 * PCI-Host bridge device from _ADR. Assume we don't have one if
336 status = acpi_GetInteger(sc->ap_handle, "_ADR", &sc->ap_addr);
339 device_printf(dev, "could not evaluate _ADR - %s\n",
341 sc->ap_addr = -1;
348 if (pcib_host_res_init(sc->ap_dev, &sc->ap_host_res) != 0)
351 status = AcpiWalkResources(sc->ap_handle, "_CRS",
354 device_printf(sc->ap_dev, "failed to parse resources: %s\n",
367 * default PCI configuration space handlers can deal with this bus,
369 * XXX invoke _REG on this for the PCI config space address space?
370 * XXX It seems many BIOS's with multiple Host-PCI bridges do not set
372 * if _BBN is zero and PCI bus 0 already exists, we try to read our
374 * We only do this for domain/segment 0 in the hopes that this is
375 * only needed for old single-domain machines.
377 status = acpi_GetInteger(sc->ap_handle, "_BBN", &sc->ap_bus);
380 device_printf(dev, "could not evaluate _BBN - %s\n",
385 sc->ap_bus = 0;
390 * If this is segment 0, the bus is zero, and PCI bus 0 already
391 * exists, read the bus number via PCI config space.
394 if (sc->ap_segment == 0 && sc->ap_bus == 0 && bus0_seen) {
396 if (sc->ap_addr != -1) {
398 slot = ACPI_ADR_PCI_SLOT(sc->ap_addr);
399 func = ACPI_ADR_PCI_FUNC(sc->ap_addr);
406 sc->ap_bus = busno;
414 * Host-PCI bridges in order and that as a result the next free
423 sc->ap_bus = start;
426 bus_res = pci_domain_alloc_bus(sc->ap_segment, dev, &rid, 0,
431 pcib_host_res_free(dev, &sc->ap_host_res);
434 sc->ap_bus = rman_get_start(bus_res);
435 pci_domain_release_bus(sc->ap_segment, dev, bus_res);
443 if (sc->ap_bus != start) {
447 "(%ju - %ju).\n",
448 sc->ap_bus, (uintmax_t)start, (uintmax_t)end);
452 sc->ap_bus = start;
458 if (sc->ap_segment == 0 && sc->ap_bus == 0)
461 acpi_pcib_fetch_prt(dev, &sc->ap_prt);
466 BUS_SPACE_MAXSIZE, 0, NULL, NULL, &sc->ap_dma_tag);
469 error = bus_get_domain(dev, &domain);
471 error = bus_dma_tag_set_domain(sc->ap_dma_tag, domain);
472 /* Don't fail to attach if the domain can't be queried or set. */
476 if (device_add_child(dev, "pci", -1) == NULL) {
477 bus_dma_tag_destroy(sc->ap_dma_tag);
478 sc->ap_dma_tag = NULL;
486 device_printf(device_get_parent(dev), "couldn't attach pci bus\n");
487 pcib_host_res_free(dev, &sc->ap_host_res);
492 * Support for standard PCI bridge ivars.
501 *result = sc->ap_segment;
504 *result = sc->ap_bus;
507 *result = (uintptr_t)sc->ap_handle;
510 *result = (uintptr_t)sc->ap_flags;
525 sc->ap_bus = value;
528 sc->ap_handle = (ACPI_HANDLE)value;
531 sc->ap_flags = (int)value;
543 return (pci_cfgregread(sc->ap_segment, bus, slot, func, reg, bytes));
552 pci_cfgregwrite(sc->ap_segment, bus, slot, func, reg, data, bytes);
560 return (acpi_pcib_route_interrupt(pcib, dev, pin, &sc->ap_prt));
597 if (sc->ap_addr == -1)
600 hostb = pci_find_dbsf(sc->ap_segment, 0, ACPI_ADR_PCI_SLOT(sc->ap_addr),
601 ACPI_ADR_PCI_FUNC(sc->ap_addr));
620 return (pci_domain_alloc_bus(sc->ap_segment, child, rid, start, end,
622 res = pcib_host_res_alloc(&sc->ap_host_res, child, type, rid, start, end,
628 * do long-term is explicitly trust any firmware-configured
632 if (res == NULL && start + count - 1 == end)
646 return (pci_domain_adjust_bus(sc->ap_segment, child, r, start,
648 return (pcib_host_res_adjust(&sc->ap_host_res, child, r, start, end));
659 return (pci_domain_release_bus(sc->ap_segment, child, r));
671 return (pci_domain_activate_bus(sc->ap_segment, child, r));
683 return (pci_domain_deactivate_bus(sc->ap_segment, child, r));
706 return (acpi_pcib_osc(pcib, &sc->ap_osc_ctl, osc_ctl));
716 return (sc->ap_dma_tag);