Lines Matching defs:link
52 ACPI_SERIAL_DECL(pci_link, "ACPI PCI link");
58 * An ACPI PCI link device may contain multiple links. Each link has its
59 * own ACPI resource. _PRT entries specify which link is being used via
88 struct link;
93 struct link *pl_links;
97 struct link {
209 struct link *link;
238 link = &req->sc->pl_links[req->link_index];
239 link->l_res_index = req->res_index;
240 link->l_crs_type = res->Type;
247 * when the link hasn't been programmed.
251 link->l_irq = res->Data.Irq.Interrupts[0];
253 link->l_irq = res->Data.ExtendedIrq.Interrupts[0];
256 * An IRQ of zero means that the link isn't routed.
258 if (link->l_irq == 0)
259 link->l_irq = PCI_INVALID_IRQ;
275 struct link *link;
314 link = &req->sc->pl_links[req->link_index];
315 if (link->l_res_index == -1) {
318 link->l_res_index = req->res_index;
327 tmp = &link->l_prs_template;
339 link->l_num_irqs =
344 link->l_num_irqs = res->Data.Irq.InterruptCount;
347 if (link->l_num_irqs == 0)
352 * valid IRQs are ISA IRQs, then mark this link as
355 link->l_isa_irq = TRUE;
356 link->l_irqs = malloc(sizeof(int) * link->l_num_irqs,
358 for (i = 0; i < link->l_num_irqs; i++) {
360 link->l_irqs[i] = ext_irqs[i];
362 link->l_isa_irq = FALSE;
364 link->l_irqs[i] = irqs[i];
366 link->l_isa_irq = FALSE;
374 if (!req->sc->pl_crs_bad && !link->l_isa_irq &&
375 link->l_crs_type == ACPI_RESOURCE_TYPE_IRQ)
391 link_valid_irq(struct link *link, int irq)
402 for (i = 0; i < link->l_num_irqs; i++)
403 if (link->l_irqs[i] == irq)
410 if (link->l_isa_irq && AcpiGbl_FADT.SciInterrupt == irq &&
421 struct link *link;
432 link = &sc->pl_links[i];
434 link->l_irq, link->l_routed ? 'Y' : 'N',
435 link->l_references);
436 if (link->l_num_irqs == 0)
438 else for (j = 0; j < link->l_num_irqs; j++)
439 printf(" %d", link->l_irqs[j]);
459 * a link array to allocate. On some systems, _CRS is broken,
485 sc->pl_links = malloc(sizeof(struct link) * sc->pl_num_links,
546 * Try to disable this link. If successful, set the current IRQ to
547 * zero and flags to indicate this link is not routed. If we can't
614 * Find the link structure that corresponds to the resource index passed in
617 static struct link *
635 struct link *link;
652 link = acpi_pci_link_lookup(dev, index);
653 if (link == NULL) {
658 link->l_references++;
659 if (link->l_routed)
660 pci_link_interrupt_weights[link->l_irq]++;
664 * (8259As). Thus, if this link is routed via an ISA IRQ, go
665 * look to see if the BIOS routed an IRQ for this link at the
667 * this link and add that IRQ to our list of known-good IRQs.
668 * This provides a good work-around for link devices whose _CRS
673 * If this link is not routed via an ISA IRQ (because we are using
677 if (!link->l_isa_irq) {
690 if (!link_valid_irq(link, bios_irq)) {
693 } else if (!PCI_INTERRUPT_VALID(link->l_bios_irq)) {
694 link->l_bios_irq = bios_irq;
697 if (bios_irq != link->l_initial_irq &&
698 PCI_INTERRUPT_VALID(link->l_initial_irq))
701 bios_irq, link->l_initial_irq);
702 } else if (bios_irq != link->l_bios_irq)
706 link->l_bios_irq);
715 struct link *link;
733 /* Fill in IRQ resources via link structures. */
734 link = sc->pl_links;
764 if (PCI_INTERRUPT_VALID(link->l_irq)) {
765 KASSERT(link->l_irq < NUM_ISA_INTERRUPTS,
767 __func__, link->l_irq));
768 res->Data.Irq.Interrupts[0] = link->l_irq;
771 link++;
777 if (PCI_INTERRUPT_VALID(link->l_irq))
779 link->l_irq;
782 link++;
801 struct link *link;
806 link = sc->pl_links;
809 /* Add a new IRQ resource from each link. */
810 link = &sc->pl_links[i];
811 if (link->l_prs_template.Type == ACPI_RESOURCE_TYPE_IRQ) {
814 bcopy(&link->l_prs_template, &newres,
817 if (PCI_INTERRUPT_VALID(link->l_irq)) {
818 KASSERT(link->l_irq < NUM_ISA_INTERRUPTS,
820 __func__, link->l_irq));
821 newres.Data.Irq.Interrupts[0] = link->l_irq;
827 bcopy(&link->l_prs_template, &newres,
830 if (PCI_INTERRUPT_VALID(link->l_irq))
832 link->l_irq;
858 struct link *link;
881 link = sc->pl_links;
895 * weights if this link has a valid IRQ and was
898 if (!link->l_routed &&
899 PCI_INTERRUPT_VALID(link->l_irq)) {
900 link->l_routed = TRUE;
902 pci_link_interrupt_weights[link->l_irq] +=
903 link->l_references;
905 link++;
925 * If all of our links are routed, then restore the link via _SRS,
926 * otherwise, disable the link via _DIS.
948 * Pick an IRQ to use for this unrouted link.
951 acpi_pci_link_choose_irq(device_t dev, struct link *link)
957 KASSERT(!link->l_routed, ("%s: link already routed", __func__));
958 KASSERT(!PCI_INTERRUPT_VALID(link->l_irq),
959 ("%s: link already has an IRQ", __func__));
965 "hw.pci.link.%s.%d.irq", link_name, link->l_res_index);
967 if (!link_valid_irq(link, i))
974 "hw.pci.link.%s.irq", link_name);
976 if (!link_valid_irq(link, i))
986 * says it routed over what _CRS says the link thinks is routed.
988 if (PCI_INTERRUPT_VALID(link->l_bios_irq))
989 return (link->l_bios_irq);
995 if (PCI_INTERRUPT_VALID(link->l_initial_irq))
996 return (link->l_initial_irq);
1005 for (i = 0; i < link->l_num_irqs; i++) {
1006 pos_irq = link->l_irqs[i];
1021 if (link->l_isa_irq) {
1042 struct link *link;
1048 link = acpi_pci_link_lookup(dev, index);
1049 if (link == NULL)
1053 * If this link device is already routed to an interrupt, just return
1056 if (link->l_routed) {
1057 KASSERT(PCI_INTERRUPT_VALID(link->l_irq),
1058 ("%s: link is routed but has an invalid IRQ", __func__));
1060 return (link->l_irq);
1064 if (!PCI_INTERRUPT_VALID(link->l_irq)) {
1065 link->l_irq = acpi_pci_link_choose_irq(dev, link);
1071 if (PCI_INTERRUPT_VALID(link->l_irq)) {
1073 if (!link->l_routed)
1074 link->l_irq = PCI_INVALID_IRQ;
1079 return (link->l_irq);