void * pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level, int (*func)(void *), void *arg, char *what) { int pin, irq; struct pic *pic; pic = &i8259_pic; pin = irq = ih; #if NIOAPIC > 0 if (ih & APIC_INT_VIA_APIC) { pic = (struct pic *)ioapic_find(APIC_IRQ_APIC(ih)); if (pic == NULL) { printf("pci_intr_establish: bad ioapic %d\n", APIC_IRQ_APIC(ih)); return NULL; } pin = APIC_IRQ_PIN(ih); irq = APIC_IRQ_LEGACY_IRQ(ih); if (irq < 0 || irq >= NUM_LEGACY_IRQS) irq = -1; } #endif return intr_establish(irq, pic, pin, IST_LEVEL, level, func, arg, what); }
void * pci_intr_establish_xname(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level, int (*func)(void *), void *arg, const char *xname) { int pin, irq; struct pic *pic; #if NIOAPIC > 0 struct ioapic_softc *ioapic; #endif bool mpsafe; pci_chipset_tag_t ipc; for (ipc = pc; ipc != NULL; ipc = ipc->pc_super) { if ((ipc->pc_present & PCI_OVERRIDE_INTR_ESTABLISH) == 0) continue; return (*ipc->pc_ov->ov_intr_establish)(ipc->pc_ctx, pc, ih, level, func, arg); } if (INT_VIA_MSI(ih)) { if (MSI_INT_IS_MSIX(ih)) return x86_pci_msix_establish(pc, ih, level, func, arg, xname); else return x86_pci_msi_establish(pc, ih, level, func, arg, xname); } pic = &i8259_pic; pin = irq = APIC_IRQ_LEGACY_IRQ(ih); mpsafe = ((ih & MPSAFE_MASK) != 0); #if NIOAPIC > 0 if (ih & APIC_INT_VIA_APIC) { ioapic = ioapic_find(APIC_IRQ_APIC(ih)); if (ioapic == NULL) { aprint_normal("pci_intr_establish: bad ioapic %d\n", APIC_IRQ_APIC(ih)); return NULL; } pic = &ioapic->sc_pic; pin = APIC_IRQ_PIN(ih); irq = APIC_IRQ_LEGACY_IRQ(ih); if (irq < 0 || irq >= NUM_LEGACY_IRQS) irq = -1; } #endif return intr_establish_xname(irq, pic, pin, IST_LEVEL, level, func, arg, mpsafe, xname); }
void * pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level, int (*func)(void *), void *arg, const char *what) { int pin, irq; int bus, dev; pcitag_t tag = ih.tag; struct pic *pic; if (ih.line & APIC_INT_VIA_MSG) { return intr_establish(-1, &msi_pic, tag, IST_PULSE, level, func, arg, what); } pci_decompose_tag(pc, ih.tag, &bus, &dev, NULL); #if NACPIPRT > 0 acpiprt_route_interrupt(bus, dev, ih.pin); #endif pic = &i8259_pic; pin = irq = ih.line; #if NIOAPIC > 0 if (ih.line & APIC_INT_VIA_APIC) { pic = (struct pic *)ioapic_find(APIC_IRQ_APIC(ih.line)); if (pic == NULL) { printf("pci_intr_establish: bad ioapic %d\n", APIC_IRQ_APIC(ih.line)); return NULL; } pin = APIC_IRQ_PIN(ih.line); irq = APIC_IRQ_LEGACY_IRQ(ih.line); if (irq < 0 || irq >= NUM_LEGACY_IRQS) irq = -1; } #endif return intr_establish(irq, pic, pin, IST_LEVEL, level, func, arg, what); }
void * pci_intr_establish(pci_chipset_tag_t pcitag, pci_intr_handle_t intrh, int level, int (*func)(void *), void *arg) { char evname[16]; #if NIOAPIC > 0 struct ioapic_softc *pic; if (intrh.pirq & APIC_INT_VIA_APIC) { pic = ioapic_find(APIC_IRQ_APIC(intrh.pirq)); if (pic == NULL) { printf("pci_intr_establish: bad ioapic %d\n", APIC_IRQ_APIC(intrh.pirq)); return NULL; } snprintf(evname, sizeof(evname), "%s pin %d", device_xname(pic->sc_dev), APIC_IRQ_PIN(intrh.pirq)); } else #endif snprintf(evname, sizeof(evname), "irq%d", intrh.pirq); return (void *)pirq_establish(intrh.pirq & 0xff, intrh.evtch, func, arg, level, evname); }
const char *pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih) { static char buf[64]; #if NIOAPIC > 0 struct ioapic_softc *pic; if (ih.pirq & APIC_INT_VIA_APIC) { pic = ioapic_find(APIC_IRQ_APIC(ih.pirq)); if (pic == NULL) { printf("pci_intr_string: bad ioapic %d\n", APIC_IRQ_APIC(ih.pirq)); return NULL; } snprintf(buf, 64, "%s pin %d, event channel %d", device_xname(pic->sc_dev), APIC_IRQ_PIN(ih.pirq), ih.evtch); return buf; } #endif snprintf(buf, 64, "irq %d, event channel %d", ih.pirq, ih.evtch); return buf; }
void * isa_intr_establish(isa_chipset_tag_t ic, int irq, int type, int level, int (*ih_fun)(void *), void *ih_arg) { struct pic *pic; int pin; #if NIOAPIC > 0 int mpih; struct ioapic_softc *ioapic; #endif pin = irq; pic = &i8259_pic; #if NIOAPIC > 0 if (mp_busses != NULL) { if (intr_find_mpmapping(mp_isa_bus, irq, &mpih) == 0 || intr_find_mpmapping(mp_eisa_bus, irq, &mpih) == 0) { if (!APIC_IRQ_ISLEGACY(mpih)) { pin = APIC_IRQ_PIN(mpih); ioapic = ioapic_find(APIC_IRQ_APIC(mpih)); if (ioapic == NULL) { printf("isa_intr_establish: " "unknown apic %d\n", APIC_IRQ_APIC(mpih)); return NULL; } pic = &ioapic->sc_pic; } } else printf("isa_intr_establish: no MP mapping found\n"); } #endif return intr_establish(irq, pic, pin, type, level, ih_fun, ih_arg, false); }
const char * pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih) { static char irqstr[64]; int line = ih.line & APIC_INT_LINE_MASK; if (line == 0 || line >= ICU_LEN || line == 2) panic("pci_intr_string: bogus handle 0x%x", line); #if NIOAPIC > 0 if (ih.line & APIC_INT_VIA_APIC) { snprintf(irqstr, sizeof irqstr, "apic %d int %d (irq %d)", APIC_IRQ_APIC(ih.line), APIC_IRQ_PIN(ih.line), line); return (irqstr); } #endif snprintf(irqstr, sizeof irqstr, "irq %d", line); return (irqstr); }
const char * eisa_intr_string(eisa_chipset_tag_t ec, eisa_intr_handle_t ih) { static char irqstr[64]; if (ih == 0 || (ih & 0xff) >= ICU_LEN || ih == 2) panic("eisa_intr_string: bogus handle 0x%x", ih); #if NIOAPIC > 0 if (ih & APIC_INT_VIA_APIC) { snprintf(irqstr, sizeof irqstr, "apic %d int %d (irq %d)", APIC_IRQ_APIC(ih), APIC_IRQ_PIN(ih), ih & 0xff); return (irqstr); } #endif snprintf(irqstr, sizeof irqstr, "irq %d", ih); return (irqstr); }
const char * pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih) { static char irqstr[64]; if (ih.line == 0) panic("pci_intr_string: bogus handle 0x%x", ih.line); if (ih.line & APIC_INT_VIA_MSG) return ("msi"); #if NIOAPIC > 0 if (ih.line & APIC_INT_VIA_APIC) snprintf(irqstr, sizeof(irqstr), "apic %d int %d", APIC_IRQ_APIC(ih.line), APIC_IRQ_PIN(ih.line)); else snprintf(irqstr, sizeof(irqstr), "irq %d", pci_intr_line(pc, ih)); #else snprintf(irqstr, sizeof(irqstr), "irq %d", pci_intr_line(pc, ih)); #endif return (irqstr); }
const char * pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih) { static char irqstr[64]; if (ih == 0) panic("pci_intr_string: bogus handle 0x%x", ih); #if NIOAPIC > 0 if (ih & APIC_INT_VIA_APIC) snprintf(irqstr, sizeof(irqstr), "apic %d int %d (irq %d)", APIC_IRQ_APIC(ih), APIC_IRQ_PIN(ih), ih&0xff); else snprintf(irqstr, sizeof(irqstr), "irq %d", ih&0xff); #else snprintf(irqstr, sizeof(irqstr), "irq %d", ih&0xff); #endif return (irqstr); }