Lines Matching defs:pci_link
56 struct pci_link {
57 TAILQ_ENTRY(pci_link) pl_links;
66 struct pci_link **pci_link_ptr;
85 static int pci_pir_choose_irq(struct pci_link *pci_link, int irqmask);
89 static struct pci_link *pci_pir_find_link(uint8_t link_id);
96 static int pci_pir_valid_irq(struct pci_link *pci_link, int irq);
104 static TAILQ_HEAD(, pci_link) pci_links;
170 * Find the pci_link structure for a given link ID.
172 static struct pci_link *
175 struct pci_link *pci_link;
177 TAILQ_FOREACH(pci_link, &pci_links, pl_links) {
178 if (pci_link->pl_id == link_id)
179 return (pci_link);
204 pci_pir_valid_irq(struct pci_link *pci_link, int irq)
209 return (pci_link->pl_irqmask & (1 << irq));
237 struct pci_link *pci_link;
239 pci_link = pci_pir_find_link(intpin->link);
240 if (pci_link != NULL) {
241 pci_link->pl_references++;
242 if (intpin->irqs != pci_link->pl_irqmask) {
248 pci_link->pl_id);
249 pci_link->pl_irqmask &= intpin->irqs;
252 pci_link = malloc(sizeof(struct pci_link), M_PIR, M_WAITOK);
253 pci_link->pl_id = intpin->link;
254 pci_link->pl_irqmask = intpin->irqs;
255 pci_link->pl_irq = PCI_INVALID_IRQ;
256 pci_link->pl_references = 1;
257 pci_link->pl_routed = 0;
258 TAILQ_INSERT_TAIL(&pci_links, pci_link, pl_links);
313 struct pci_link *pci_link;
317 pci_link = pci_pir_find_link(intpin->link);
319 if (irq == PCI_INVALID_IRQ || irq == pci_link->pl_irq)
327 pci_link->pl_id);
335 if (pci_link->pl_irq == PCI_INVALID_IRQ) {
336 if (!pci_pir_valid_irq(pci_link, irq))
340 pci_link->pl_id);
341 pci_link->pl_irq = irq;
342 pci_link->pl_routed = 1;
355 if (!pci_pir_valid_irq(pci_link, irq)) {
359 pci_link->pl_id);
360 } else if (!pci_pir_valid_irq(pci_link, pci_link->pl_irq)) {
364 pci_link->pl_id, pci_link->pl_irq);
365 pci_link->pl_irq = irq;
366 pci_link->pl_routed = 1;
371 pci_link->pl_id, pci_link->pl_irq);
384 struct pci_link *pci_link;
417 TAILQ_FOREACH(pci_link, &pci_links, pl_links) {
419 "hw.pci.link.%#x.irq", pci_link->pl_id);
425 !pci_pir_valid_irq(pci_link, irq) && bootverbose)
428 irq, pci_link->pl_id);
429 pci_link->pl_routed = 0;
430 pci_link->pl_irq = irq;
442 TAILQ_FOREACH(pci_link, &pci_links, pl_links) {
443 if (!PCI_INTERRUPT_VALID(pci_link->pl_irq))
445 pir_bios_irqs |= 1 << pci_link->pl_irq;
446 pir_interrupt_weight[pci_link->pl_irq] +=
447 pci_link->pl_references;
492 struct pci_link *pci_link;
499 pci_link = NULL;
503 lookup.pci_link_ptr = &pci_link;
505 if (pci_link == NULL) {
520 if (!PCI_INTERRUPT_VALID(pci_link->pl_irq)) {
521 if (pci_link->pl_irqmask != 0 && powerof2(pci_link->pl_irqmask))
522 irq = ffs(pci_link->pl_irqmask) - 1;
524 irq = pci_pir_choose_irq(pci_link,
527 irq = pci_pir_choose_irq(pci_link, pir_bios_irqs);
529 irq = pci_pir_choose_irq(pci_link,
538 pci_link->pl_irq = irq;
542 if (!pci_link->pl_routed) {
544 pci_link->pl_irq);
547 if (error && !powerof2(pci_link->pl_irqmask)) {
551 pci_link->pl_routed = 1;
555 BUS_CONFIG_INTR(pir_device, pci_link->pl_irq,
560 pin - 1 + 'A', pci_link->pl_irq);
561 return (pci_link->pl_irq);
569 pci_pir_choose_irq(struct pci_link *pci_link, int irqmask)
574 realmask = pci_link->pl_irqmask & irqmask;
589 pci_link->pl_id);
622 struct pci_link *pci_link;
625 TAILQ_FOREACH(pci_link, &pci_links, pl_links) {
626 printf("%#4x %3d %c %3d ", pci_link->pl_id,
627 pci_link->pl_irq, pci_link->pl_routed ? 'Y' : 'N',
628 pci_link->pl_references);
629 pci_print_irqmask(pci_link->pl_irqmask);
696 struct pci_link *pci_link;
700 TAILQ_FOREACH(pci_link, &pci_links, pl_links) {
701 if (!PCI_INTERRUPT_VALID(pci_link->pl_irq)) {
702 KASSERT(!pci_link->pl_routed,
704 pci_link->pl_id));
707 if (pci_link->pl_routed) {
709 pd.link = pci_link->pl_id;
713 pci_link->pl_id));
718 pci_link->pl_id, pci_link->pl_irq);
720 pci_link->pl_irq);
724 pci_link->pl_id);