FreeBSD/sys/dev/acpica/acpi_pcib.c
/*
 * Route an interrupt for a child of the bridge.
 */
Route an interrupt for a child of the bridge.
Route an interrupt for a child of the bridge .
int
acpi_pcib_route_interrupt(device_t pcib, device_t dev, int pin,
    ACPI_BUFFER *prtbuf)
{
    ACPI_PCI_ROUTING_TABLE *prt;
    struct prt_lookup_request pr;
    ACPI_HANDLE lnkdev;
    int interrupt;
    ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
    interrupt = PCI_INVALID_IRQ;
    pin--;
    ACPI_SERIAL_BEGIN(pcib);
    pr.pr_entry = NULL;
    pr.pr_pin = pin;
    pr.pr_slot = pci_get_slot(dev);
    prt_walk_table(prtbuf, prt_lookup_device, &pr);
    if (pr.pr_entry == NULL) {
	device_printf(pcib, "no PRT entry for %d.%d.INT%c\n", pci_get_bus(dev),
	    pci_get_slot(dev), 'A' + pin);
	goto out;
    }
    prt = pr.pr_entry;
    if (bootverbose) {
	device_printf(pcib, "matched entry for %d.%d.INT%c",
	    pci_get_bus(dev), pci_get_slot(dev), 'A' + pin);
	if (prt->Source[0] != '\0')
		printf(" (src %s:%u)", prt->Source, prt->SourceIndex);
	printf("\n");
    }
    if (prt->Source[0] == '\0' || prt->SourceIndex != 0) {
	if (bootverbose)
	    device_printf(pcib, "slot %d INT%c hardwired to IRQ %d\n",
		pci_get_slot(dev), 'A' + pin, prt->SourceIndex);
	if (prt->SourceIndex) {
	    interrupt = prt->SourceIndex;
	    BUS_CONFIG_INTR(dev, interrupt, INTR_TRIGGER_LEVEL,
		INTR_POLARITY_LOW);
	} else
	    device_printf(pcib, "error: invalid hard-wired IRQ of 0\n");
	goto out;
    }
    if (ACPI_FAILURE(AcpiGetHandle(ACPI_ROOT_OBJECT, prt->Source, &lnkdev))) {
	device_printf(pcib, "couldn't find PCI interrupt link device %s\n",
	    prt->Source);
	goto out;
    }
    interrupt = acpi_pci_link_route_interrupt(acpi_get_device(lnkdev),
	prt->SourceIndex);
    if (bootverbose && PCI_INTERRUPT_VALID(interrupt))
	device_printf(pcib, "slot %d INT%c routed to irq %d via %s\n",
	    pci_get_slot(dev), 'A' + pin, interrupt, acpi_name(lnkdev));
out:
    ACPI_SERIAL_END(pcib);
    return_VALUE(interrupt);
}
int acpi_pcib_route_interrupt ( device_t pcib , device_t dev , int pin , ACPI_BUFFER * prtbuf ) { ACPI_PCI_ROUTING_TABLE * prt ; struct prt_lookup_request pr ; ACPI_HANDLE lnkdev ; int interrupt ; ACPI_FUNCTION_TRACE ( ( char * ) ( uintptr_t ) __func__ ) ; interrupt = PCI_INVALID_IRQ ; pin -- ; ACPI_SERIAL_BEGIN ( pcib ) ; pr . pr_entry = NULL ; pr . pr_pin = pin ; pr . pr_slot = pci_get_slot ( dev ) ; prt_walk_table ( prtbuf , prt_lookup_device , & pr ) ; if ( pr . pr_entry == NULL ) { device_printf ( pcib , " \n " , pci_get_bus ( dev ) , pci_get_slot ( dev ) , ' ' + pin ) ; goto out ; } prt = pr . pr_entry ; if ( bootverbose ) { device_printf ( pcib , " " , pci_get_bus ( dev ) , pci_get_slot ( dev ) , ' ' + pin ) ; if ( prt -> Source [ 0 ] != ' \0 ' ) printf ( " " , prt -> Source , prt -> SourceIndex ) ; printf ( " \n " ) ; } if ( prt -> Source [ 0 ] == ' \0 ' || prt -> SourceIndex != 0 ) { if ( bootverbose ) device_printf ( pcib , " \n " , pci_get_slot ( dev ) , ' ' + pin , prt -> SourceIndex ) ; if ( prt -> SourceIndex ) { interrupt = prt -> SourceIndex ; BUS_CONFIG_INTR ( dev , interrupt , INTR_TRIGGER_LEVEL , INTR_POLARITY_LOW ) ; } else device_printf ( pcib , " \n " ) ; goto out ; } if ( ACPI_FAILURE ( AcpiGetHandle ( ACPI_ROOT_OBJECT , prt -> Source , & lnkdev ) ) ) { device_printf ( pcib , " \n " , prt -> Source ) ; goto out ; } interrupt = acpi_pci_link_route_interrupt ( acpi_get_device ( lnkdev ) , prt -> SourceIndex ) ; if ( bootverbose && PCI_INTERRUPT_VALID ( interrupt ) ) device_printf ( pcib , " \n " , pci_get_slot ( dev ) , ' ' + pin , interrupt , acpi_name ( lnkdev ) ) ; out : ACPI_SERIAL_END ( pcib ) ; return_VALUE ( interrupt ) ; }
Route an interrupt for a child of the bridge.
Route an interrupt for a child of the bridge .
/* ACPI numbers pins 0-3, not 1-4 like the BIOS. */ /* Search for a matching entry in the routing table. */ /*
     * If source is empty/NULL, the source index is a global IRQ number
     * and it's hard-wired so we're done.
     *
     * XXX: If the source index is non-zero, ignore the source device and
     * assume that this is a hard-wired entry.
     */ /*
     * We have to find the source device (PCI interrupt link device).
     */