2000-10-28 06:59:48 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2000 Michael Smith
|
|
|
|
* Copyright (c) 2000 BSDi
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
2003-08-24 17:55:58 +00:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2000-10-28 06:59:48 +00:00
|
|
|
#include "opt_acpi.h"
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/bus.h>
|
2001-07-05 07:20:51 +00:00
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/kernel.h>
|
2000-10-28 06:59:48 +00:00
|
|
|
|
|
|
|
#include "acpi.h"
|
|
|
|
|
|
|
|
#include <dev/acpica/acpivar.h>
|
2002-08-26 18:30:27 +00:00
|
|
|
#include <dev/acpica/acpi_pcibvar.h>
|
2000-10-28 06:59:48 +00:00
|
|
|
|
|
|
|
#include <machine/pci_cfgreg.h>
|
2003-08-22 06:06:16 +00:00
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
#include <dev/pci/pcib_private.h>
|
2000-10-28 06:59:48 +00:00
|
|
|
#include "pcib_if.h"
|
|
|
|
|
2000-12-08 09:16:20 +00:00
|
|
|
/*
|
|
|
|
* Hooks for the ACPI CA debugging infrastructure
|
|
|
|
*/
|
2001-06-29 20:32:29 +00:00
|
|
|
#define _COMPONENT ACPI_BUS
|
2002-02-23 05:27:49 +00:00
|
|
|
ACPI_MODULE_NAME("PCI")
|
2000-12-08 09:16:20 +00:00
|
|
|
|
2002-08-26 18:30:27 +00:00
|
|
|
int
|
|
|
|
acpi_pcib_attach(device_t dev, ACPI_BUFFER *prt, int busno)
|
2000-10-28 06:59:48 +00:00
|
|
|
{
|
|
|
|
device_t child;
|
|
|
|
ACPI_STATUS status;
|
2000-12-08 09:16:20 +00:00
|
|
|
|
2002-05-19 06:16:47 +00:00
|
|
|
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
2000-10-28 06:59:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't attach if we're not really there.
|
|
|
|
*
|
2002-08-26 18:30:27 +00:00
|
|
|
* XXX: This isn't entirely correct since we may be a PCI bus
|
2000-10-28 06:59:48 +00:00
|
|
|
* on a hot-plug docking station, etc.
|
|
|
|
*/
|
|
|
|
if (!acpi_DeviceIsPresent(dev))
|
2000-12-08 09:16:20 +00:00
|
|
|
return_VALUE(ENXIO);
|
2000-10-28 06:59:48 +00:00
|
|
|
|
2001-07-05 07:20:51 +00:00
|
|
|
/*
|
2002-02-23 05:27:49 +00:00
|
|
|
* Get the PCI interrupt routing table for this bus.
|
2001-07-05 07:20:51 +00:00
|
|
|
*/
|
2002-08-26 18:30:27 +00:00
|
|
|
prt->Length = ACPI_ALLOCATE_BUFFER;
|
|
|
|
status = AcpiGetIrqRoutingTable(acpi_get_handle(dev), prt);
|
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
/* This is not an error, but it may reduce functionality. */
|
2002-10-04 00:32:09 +00:00
|
|
|
device_printf(dev,
|
|
|
|
"could not get PCI interrupt routing table for %s - %s\n",
|
|
|
|
acpi_name(acpi_get_handle(dev)), AcpiFormatException(status));
|
2001-07-05 07:20:51 +00:00
|
|
|
|
2000-12-01 10:18:57 +00:00
|
|
|
/*
|
|
|
|
* Attach the PCI bus proper.
|
2000-10-28 06:59:48 +00:00
|
|
|
*/
|
2002-08-26 18:30:27 +00:00
|
|
|
if ((child = device_add_child(dev, "pci", busno)) == NULL) {
|
2002-10-29 19:08:55 +00:00
|
|
|
device_printf(device_get_parent(dev), "couldn't attach pci bus\n");
|
2000-12-08 09:16:20 +00:00
|
|
|
return_VALUE(ENXIO);
|
2000-10-28 06:59:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-12-02 01:14:14 +00:00
|
|
|
* Now go scan the bus.
|
2000-10-28 06:59:48 +00:00
|
|
|
*/
|
2002-10-05 02:01:05 +00:00
|
|
|
acpi_pci_link_config(dev, prt, busno);
|
2002-08-26 18:30:27 +00:00
|
|
|
return_VALUE(bus_generic_attach(dev));
|
2000-10-28 06:59:48 +00:00
|
|
|
}
|
|
|
|
|
2002-10-05 02:01:05 +00:00
|
|
|
int
|
|
|
|
acpi_pcib_resume(device_t dev, ACPI_BUFFER *prt, int busno)
|
|
|
|
{
|
|
|
|
acpi_pci_link_resume(dev, prt, busno);
|
|
|
|
return (bus_generic_resume(dev));
|
|
|
|
}
|
|
|
|
|
2001-07-05 07:20:51 +00:00
|
|
|
/*
|
|
|
|
* Route an interrupt for a child of the bridge.
|
|
|
|
*
|
|
|
|
* XXX clean up error messages
|
|
|
|
*
|
|
|
|
* XXX this function is somewhat bulky
|
|
|
|
*/
|
2002-08-26 18:30:27 +00:00
|
|
|
int
|
|
|
|
acpi_pcib_route_interrupt(device_t pcib, device_t dev, int pin,
|
|
|
|
ACPI_BUFFER *prtbuf)
|
2000-10-28 06:59:48 +00:00
|
|
|
{
|
2002-02-23 05:27:49 +00:00
|
|
|
ACPI_PCI_ROUTING_TABLE *prt;
|
2001-07-05 07:20:51 +00:00
|
|
|
ACPI_HANDLE lnkdev;
|
2003-12-18 03:25:22 +00:00
|
|
|
ACPI_BUFFER crsbuf, prsbuf, buf;
|
2001-07-30 09:01:18 +00:00
|
|
|
ACPI_RESOURCE *crsres, *prsres, resbuf;
|
2003-12-18 03:25:22 +00:00
|
|
|
ACPI_DEVICE_INFO *devinfo;
|
2001-07-05 07:20:51 +00:00
|
|
|
ACPI_STATUS status;
|
2003-11-14 21:36:09 +00:00
|
|
|
UINT32 NumberOfInterrupts;
|
|
|
|
UINT32 *Interrupts;
|
2001-07-05 07:20:51 +00:00
|
|
|
u_int8_t *prtp;
|
|
|
|
int interrupt;
|
|
|
|
int i;
|
2001-08-26 22:50:15 +00:00
|
|
|
|
2002-05-19 06:16:47 +00:00
|
|
|
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
2001-07-05 07:20:51 +00:00
|
|
|
|
2003-12-18 17:04:11 +00:00
|
|
|
buf.Pointer = NULL;
|
|
|
|
crsbuf.Pointer = NULL;
|
|
|
|
prsbuf.Pointer = NULL;
|
2001-07-05 07:20:51 +00:00
|
|
|
interrupt = 255;
|
|
|
|
|
|
|
|
/* ACPI numbers pins 0-3, not 1-4 like the BIOS */
|
|
|
|
pin--;
|
|
|
|
|
2002-08-26 18:30:27 +00:00
|
|
|
prtp = prtbuf->Pointer;
|
2001-07-05 07:20:51 +00:00
|
|
|
if (prtp == NULL) /* didn't get routing table */
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* scan the table looking for this device */
|
|
|
|
for (;;) {
|
2002-02-23 05:27:49 +00:00
|
|
|
prt = (ACPI_PCI_ROUTING_TABLE *)prtp;
|
2001-07-05 07:20:51 +00:00
|
|
|
|
|
|
|
if (prt->Length == 0) /* end of table */
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compare the slot number (high word of Address) and pin number
|
|
|
|
* (note that ACPI uses 0 for INTA) to check for a match.
|
|
|
|
*
|
|
|
|
* Note that the low word of the Address field (function number)
|
|
|
|
* is required by the specification to be 0xffff. We don't risk
|
|
|
|
* checking it here.
|
|
|
|
*/
|
|
|
|
if ((((prt->Address & 0xffff0000) >> 16) == pci_get_slot(dev)) &&
|
|
|
|
(prt->Pin == pin)) {
|
2001-10-07 18:25:43 +00:00
|
|
|
if (bootverbose)
|
2002-08-26 18:30:27 +00:00
|
|
|
device_printf(pcib, "matched entry for %d.%d.INT%c (source %s)\n",
|
2001-10-07 18:25:43 +00:00
|
|
|
pci_get_bus(dev), pci_get_slot(dev), 'A' + pin, prt->Source);
|
2001-07-05 07:20:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* skip to next entry */
|
|
|
|
prtp += prt->Length;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If source is empty/NULL, the source index is the global IRQ number.
|
|
|
|
*/
|
|
|
|
if ((prt->Source == NULL) || (prt->Source[0] == '\0')) {
|
2001-10-07 18:25:43 +00:00
|
|
|
if (bootverbose)
|
2002-08-26 18:30:27 +00:00
|
|
|
device_printf(pcib, "device is hardwired to IRQ %d\n",
|
|
|
|
prt->SourceIndex);
|
2001-07-05 07:20:51 +00:00
|
|
|
interrupt = prt->SourceIndex;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We have to find the source device (PCI interrupt link device)
|
|
|
|
*/
|
|
|
|
if (ACPI_FAILURE(AcpiGetHandle(ACPI_ROOT_OBJECT, prt->Source, &lnkdev))) {
|
2002-08-26 18:30:27 +00:00
|
|
|
device_printf(pcib, "couldn't find PCI interrupt link device %s\n",
|
|
|
|
prt->Source);
|
2001-07-05 07:20:51 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Verify that this is a PCI link device, and that it's present.
|
|
|
|
*/
|
2003-12-18 03:25:22 +00:00
|
|
|
buf.Length = ACPI_ALLOCATE_BUFFER;
|
2003-07-13 22:57:16 +00:00
|
|
|
if (ACPI_FAILURE(AcpiGetObjectInfo(lnkdev, &buf))) {
|
2002-08-26 18:30:27 +00:00
|
|
|
device_printf(pcib, "couldn't validate PCI interrupt link device %s\n",
|
|
|
|
prt->Source);
|
2001-07-05 07:20:51 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2003-12-18 03:25:22 +00:00
|
|
|
devinfo = (ACPI_DEVICE_INFO *)buf.Pointer;
|
|
|
|
if ((devinfo->Valid & ACPI_VALID_HID) == 0 ||
|
|
|
|
strcmp("PNP0C0F", devinfo->HardwareId.Value) != 0) {
|
|
|
|
|
2002-08-26 18:30:27 +00:00
|
|
|
device_printf(pcib, "PCI interrupt link device %s has wrong _HID (%s)\n",
|
2003-12-18 03:25:22 +00:00
|
|
|
prt->Source, devinfo->HardwareId.Value);
|
2001-07-05 07:20:51 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2003-12-18 03:25:22 +00:00
|
|
|
if ((devinfo->Valid & ACPI_VALID_STA) != 0 &&
|
|
|
|
(devinfo->CurrentStatus & 0x9) != 0x9) {
|
|
|
|
|
2002-08-26 15:12:47 +00:00
|
|
|
device_printf(pcib, "PCI interrupt link device %s not present\n",
|
2001-10-04 23:21:09 +00:00
|
|
|
prt->Source);
|
2001-07-05 07:20:51 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the current and possible resources for the interrupt link device.
|
|
|
|
*/
|
2002-02-23 05:27:49 +00:00
|
|
|
crsbuf.Length = ACPI_ALLOCATE_BUFFER;
|
|
|
|
if (ACPI_FAILURE(status = AcpiGetCurrentResources(lnkdev, &crsbuf))) {
|
2002-08-26 18:30:27 +00:00
|
|
|
device_printf(pcib, "couldn't get PCI interrupt link device _CRS data - %s\n",
|
2001-07-21 10:24:37 +00:00
|
|
|
AcpiFormatException(status));
|
2001-07-05 07:20:51 +00:00
|
|
|
goto out; /* this is fatal */
|
|
|
|
}
|
2002-02-23 05:27:49 +00:00
|
|
|
prsbuf.Length = ACPI_ALLOCATE_BUFFER;
|
2002-03-21 02:02:31 +00:00
|
|
|
if (ACPI_FAILURE(status = AcpiGetPossibleResources(lnkdev, &prsbuf))) {
|
2002-08-26 18:30:27 +00:00
|
|
|
device_printf(pcib, "couldn't get PCI interrupt link device _PRS data - %s\n",
|
2001-07-21 10:24:37 +00:00
|
|
|
AcpiFormatException(status));
|
2001-07-05 07:20:51 +00:00
|
|
|
/* this is not fatal, since it may be hardwired */
|
|
|
|
}
|
2002-10-04 00:33:46 +00:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "got %ld bytes for %s._CRS\n",
|
|
|
|
(long)crsbuf.Length, acpi_name(lnkdev)));
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "got %ld bytes for %s._PRS\n",
|
|
|
|
(long)prsbuf.Length, acpi_name(lnkdev)));
|
2001-07-05 07:20:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The interrupt may already be routed, so check _CRS first. We don't check the
|
|
|
|
* 'decoding' bit in the _STA result, since there's nothing in the spec that
|
|
|
|
* mandates it be set, however some BIOS' will set it if the decode is active.
|
|
|
|
*
|
|
|
|
* The Source Index points to the particular resource entry we're interested in.
|
|
|
|
*/
|
2001-07-30 09:01:18 +00:00
|
|
|
if (ACPI_FAILURE(acpi_FindIndexedResource(&crsbuf, prt->SourceIndex, &crsres))) {
|
2002-08-26 18:30:27 +00:00
|
|
|
device_printf(pcib, "_CRS buffer corrupt, cannot route interrupt\n");
|
2001-07-05 07:20:51 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* type-check the resource we've got */
|
2003-11-14 21:36:09 +00:00
|
|
|
if (crsres->Id != ACPI_RSTYPE_IRQ && crsres->Id != ACPI_RSTYPE_EXT_IRQ) {
|
2002-08-26 18:30:27 +00:00
|
|
|
device_printf(pcib, "_CRS resource entry has unsupported type %d\n",
|
|
|
|
crsres->Id);
|
2001-07-05 07:20:51 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2003-11-14 21:36:09 +00:00
|
|
|
/* set variables based on resource type */
|
|
|
|
if (crsres->Id == ACPI_RSTYPE_IRQ) {
|
|
|
|
NumberOfInterrupts = crsres->Data.Irq.NumberOfInterrupts;
|
|
|
|
Interrupts = crsres->Data.Irq.Interrupts;
|
|
|
|
} else {
|
|
|
|
NumberOfInterrupts = crsres->Data.ExtendedIrq.NumberOfInterrupts;
|
|
|
|
Interrupts = crsres->Data.ExtendedIrq.Interrupts;
|
|
|
|
}
|
|
|
|
|
2001-07-05 07:20:51 +00:00
|
|
|
/* if there's more than one interrupt, we are confused */
|
2003-11-14 21:36:09 +00:00
|
|
|
if (NumberOfInterrupts > 1) {
|
2002-08-26 18:30:27 +00:00
|
|
|
device_printf(pcib, "device has too many interrupts (%d)\n",
|
2003-11-14 21:36:09 +00:00
|
|
|
NumberOfInterrupts);
|
2001-07-05 07:20:51 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If there's only one interrupt, and it's not zero, then we're already routed.
|
|
|
|
*
|
|
|
|
* Note that we could also check the 'decoding' bit in _STA, but can't depend on
|
|
|
|
* it since it's not part of the spec.
|
|
|
|
*
|
|
|
|
* XXX check ASL examples to see if this is an acceptable set of tests
|
|
|
|
*/
|
2003-11-14 21:36:09 +00:00
|
|
|
if ((NumberOfInterrupts == 1) && (Interrupts[0] != 0)) {
|
2002-09-05 17:08:35 +00:00
|
|
|
device_printf(pcib, "slot %d INT%c is routed to irq %d\n",
|
2003-11-14 21:36:09 +00:00
|
|
|
pci_get_slot(dev), 'A' + pin, Interrupts[0]);
|
|
|
|
interrupt = Interrupts[0];
|
2001-07-05 07:20:51 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There isn't an interrupt, so we have to look at _PRS to get one.
|
2004-03-20 20:47:08 +00:00
|
|
|
* Get the set of allowed interrupts from the _PRS resource indexed
|
|
|
|
* by SourceIndex.
|
2001-07-05 07:20:51 +00:00
|
|
|
*/
|
|
|
|
if (prsbuf.Pointer == NULL) {
|
2004-03-20 20:47:08 +00:00
|
|
|
device_printf(pcib, "no routed irq and no _PRS on irq link device\n");
|
2001-07-05 07:20:51 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2004-03-18 02:33:58 +00:00
|
|
|
/*
|
|
|
|
* Search through the _PRS resources, looking for an IRQ or extended
|
|
|
|
* IRQ resource. Skip dependent function resources for now. In the
|
|
|
|
* future, we might use these for priority but this is good enough for
|
|
|
|
* now until BIOS vendors actually mean something by using them.
|
|
|
|
*/
|
2004-03-20 20:47:08 +00:00
|
|
|
prsres = NULL;
|
|
|
|
for (i = prt->SourceIndex; prsres == NULL; i++) {
|
2004-03-18 02:33:58 +00:00
|
|
|
if (ACPI_FAILURE(acpi_FindIndexedResource(&prsbuf, i, &prsres))) {
|
|
|
|
device_printf(pcib, "_PRS lacks IRQ resource, routing failed\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
switch (prsres->Id) {
|
|
|
|
case ACPI_RSTYPE_IRQ:
|
2004-03-20 20:47:08 +00:00
|
|
|
NumberOfInterrupts = prsres->Data.Irq.NumberOfInterrupts;
|
|
|
|
Interrupts = prsres->Data.Irq.Interrupts;
|
|
|
|
break;
|
2004-03-18 02:33:58 +00:00
|
|
|
case ACPI_RSTYPE_EXT_IRQ:
|
2004-03-20 20:47:08 +00:00
|
|
|
NumberOfInterrupts = prsres->Data.ExtendedIrq.NumberOfInterrupts;
|
|
|
|
Interrupts = prsres->Data.ExtendedIrq.Interrupts;
|
2004-03-18 02:33:58 +00:00
|
|
|
break;
|
|
|
|
case ACPI_RSTYPE_START_DPF:
|
2004-03-20 20:47:08 +00:00
|
|
|
prsres = NULL;
|
2004-03-18 02:33:58 +00:00
|
|
|
continue;
|
|
|
|
default:
|
|
|
|
device_printf(pcib, "_PRS has invalid type %d\n", prsres->Id);
|
|
|
|
goto out;
|
|
|
|
}
|
2001-07-05 07:20:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* there has to be at least one interrupt available */
|
2003-11-14 21:36:09 +00:00
|
|
|
if (NumberOfInterrupts < 1) {
|
2002-08-26 18:30:27 +00:00
|
|
|
device_printf(pcib, "device has no interrupts\n");
|
2001-07-05 07:20:51 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2004-03-20 20:47:08 +00:00
|
|
|
* Pick an interrupt to use. Note that a more scientific approach than
|
|
|
|
* just taking the first one available would be desirable.
|
2001-07-05 07:20:51 +00:00
|
|
|
*
|
2004-03-20 20:47:08 +00:00
|
|
|
* The PCI BIOS $PIR table offers "preferred PCI interrupts", but ACPI
|
|
|
|
* doesn't seem to offer a similar mechanism, so picking a "good"
|
|
|
|
* interrupt here is a difficult task.
|
2001-07-05 07:20:51 +00:00
|
|
|
*
|
2004-03-20 20:47:08 +00:00
|
|
|
* Build a resource buffer and pass it to AcpiSetCurrentResources to
|
|
|
|
* route the new interrupt.
|
2001-07-05 07:20:51 +00:00
|
|
|
*/
|
2002-08-26 18:30:27 +00:00
|
|
|
device_printf(pcib, "possible interrupts:");
|
2003-11-14 21:36:09 +00:00
|
|
|
for (i = 0; i < NumberOfInterrupts; i++)
|
|
|
|
printf(" %d", Interrupts[i]);
|
2001-07-05 07:20:51 +00:00
|
|
|
printf("\n");
|
2001-07-30 09:01:18 +00:00
|
|
|
|
|
|
|
if (crsbuf.Pointer != NULL) /* should never happen */
|
|
|
|
AcpiOsFree(crsbuf.Pointer);
|
|
|
|
crsbuf.Pointer = NULL;
|
2003-11-14 21:36:09 +00:00
|
|
|
if (prsres->Id == ACPI_RSTYPE_IRQ) {
|
|
|
|
resbuf.Id = ACPI_RSTYPE_IRQ;
|
|
|
|
resbuf.Length = ACPI_SIZEOF_RESOURCE(ACPI_RESOURCE_IRQ);
|
|
|
|
resbuf.Data.Irq = prsres->Data.Irq; /* structure copy other fields */
|
|
|
|
resbuf.Data.Irq.NumberOfInterrupts = 1;
|
|
|
|
resbuf.Data.Irq.Interrupts[0] = Interrupts[0]; /* just take first... */
|
|
|
|
} else {
|
|
|
|
resbuf.Id = ACPI_RSTYPE_EXT_IRQ;
|
|
|
|
resbuf.Length = ACPI_SIZEOF_RESOURCE(ACPI_RESOURCE_IRQ);
|
|
|
|
resbuf.Data.ExtendedIrq = prsres->Data.ExtendedIrq; /* structure copy other fields */
|
|
|
|
resbuf.Data.ExtendedIrq.NumberOfInterrupts = 1;
|
|
|
|
resbuf.Data.ExtendedIrq.Interrupts[0] = Interrupts[0]; /* just take first... */
|
|
|
|
}
|
2001-07-30 09:01:18 +00:00
|
|
|
if (ACPI_FAILURE(status = acpi_AppendBufferResource(&crsbuf, &resbuf))) {
|
2002-09-05 17:08:35 +00:00
|
|
|
device_printf(pcib, "couldn't route interrupt %d via %s, interrupt resource build failed - %s\n",
|
2003-11-14 21:36:09 +00:00
|
|
|
Interrupts[0], acpi_name(lnkdev), AcpiFormatException(status));
|
2001-07-30 09:01:18 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2001-08-03 08:38:49 +00:00
|
|
|
if (ACPI_FAILURE(status = AcpiSetCurrentResources(lnkdev, &crsbuf))) {
|
2002-08-26 18:30:27 +00:00
|
|
|
device_printf(pcib, "couldn't route interrupt %d via %s - %s\n",
|
2003-11-14 21:36:09 +00:00
|
|
|
Interrupts[0], acpi_name(lnkdev), AcpiFormatException(status));
|
2001-07-05 07:20:51 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* successful, return the interrupt we just routed */
|
2002-09-05 17:08:35 +00:00
|
|
|
device_printf(pcib, "slot %d INT%c routed to irq %d via %s\n",
|
2003-11-14 21:36:09 +00:00
|
|
|
pci_get_slot(dev), 'A' + pin, Interrupts[0], acpi_name(lnkdev));
|
|
|
|
interrupt = Interrupts[0];
|
2001-07-05 07:20:51 +00:00
|
|
|
|
|
|
|
out:
|
|
|
|
if (crsbuf.Pointer != NULL)
|
|
|
|
AcpiOsFree(crsbuf.Pointer);
|
|
|
|
if (prsbuf.Pointer != NULL)
|
|
|
|
AcpiOsFree(prsbuf.Pointer);
|
2003-12-18 03:25:22 +00:00
|
|
|
if (buf.Pointer != NULL)
|
|
|
|
AcpiOsFree(buf.Pointer);
|
2001-07-05 07:20:51 +00:00
|
|
|
|
|
|
|
/* XXX APIC_IO interrupt mapping? */
|
2001-08-26 22:50:15 +00:00
|
|
|
return_VALUE(interrupt);
|
2000-10-28 06:59:48 +00:00
|
|
|
}
|