summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2004-09-22 15:46:16 +0000
committerjhb <jhb@FreeBSD.org>2004-09-22 15:46:16 +0000
commitcf1b8fbca5432f624ea9a8b572cc5ba250278fa5 (patch)
tree5929701468e47aab4540fb10f7ae335e5bd17547 /sys
parent39563036071c35de79aa935b7bdfc209277f3afb (diff)
downloadFreeBSD-src-cf1b8fbca5432f624ea9a8b572cc5ba250278fa5.zip
FreeBSD-src-cf1b8fbca5432f624ea9a8b572cc5ba250278fa5.tar.gz
Add a couple of macros to extract the PCI slot (device) and function from
an ACPI _ADR value and use that rather than inlining the same shifts and masks everywhere.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/acpica/acpi_pci.c4
-rw-r--r--sys/dev/acpica/acpi_pci_link.c6
-rw-r--r--sys/dev/acpica/acpi_pcib_acpi.c4
-rw-r--r--sys/dev/acpica/acpivar.h4
4 files changed, 11 insertions, 7 deletions
diff --git a/sys/dev/acpica/acpi_pci.c b/sys/dev/acpica/acpi_pci.c
index dcc87b4..a3856e1 100644
--- a/sys/dev/acpica/acpi_pci.c
+++ b/sys/dev/acpica/acpi_pci.c
@@ -280,8 +280,8 @@ acpi_pci_save_handle(ACPI_HANDLE handle, UINT32 level, void *context,
if (ACPI_FAILURE(acpi_GetInteger(handle, "_ADR", &address)))
return_ACPI_STATUS (AE_OK);
- slot = address >> 16;
- func = address & 0xffff;
+ slot = ACPI_ADR_PCI_SLOT(address);
+ func = ACPI_ADR_PCI_FUNC(address);
if (device_get_children((device_t)context, &devlist, &devcount) != 0)
return_ACPI_STATUS (AE_OK);
for (i = 0; i < devcount; i++) {
diff --git a/sys/dev/acpica/acpi_pci_link.c b/sys/dev/acpica/acpi_pci_link.c
index 79ba4f8..cc8ec7b 100644
--- a/sys/dev/acpica/acpi_pci_link.c
+++ b/sys/dev/acpica/acpi_pci_link.c
@@ -151,7 +151,7 @@ acpi_pci_link_entry_dump(struct acpi_prt_entry *entry)
}
printf(" %d.%d.%d\n", entry->busno,
- (int)((entry->prt.Address & 0xffff0000) >> 16),
+ (int)(ACPI_ADR_PCI_SLOT(entry->prt.Address)),
(int)entry->prt.Pin);
}
@@ -981,7 +981,7 @@ acpi_pci_link_config(device_t dev, ACPI_BUFFER *prtbuf, int busno)
snprintf(prthint, sizeof(prthint),
"hw.acpi.pci.link.%d.%d.%d.irq", entry->busno,
- (int)((entry->prt.Address & 0xffff0000) >> 16),
+ (int)(ACPI_ADR_PCI_SLOT(entry->prt.Address)),
(int)entry->prt.Pin);
if (getenv_int(prthint, &irq) == 0)
@@ -1069,7 +1069,7 @@ acpi_pci_find_prt(device_t pcibdev, device_t dev, int pin)
TAILQ_FOREACH(entry, &acpi_prt_entries, links) {
prt = &entry->prt;
if (entry->busno == pci_get_bus(dev) &&
- (prt->Address & 0xffff0000) >> 16 == pci_get_slot(dev) &&
+ ACPI_ADR_PCI_SLOT(prt->Address) == pci_get_slot(dev) &&
prt->Pin == pin)
break;
}
diff --git a/sys/dev/acpica/acpi_pcib_acpi.c b/sys/dev/acpica/acpi_pcib_acpi.c
index d37db32..350bb89 100644
--- a/sys/dev/acpica/acpi_pcib_acpi.c
+++ b/sys/dev/acpica/acpi_pcib_acpi.c
@@ -188,8 +188,8 @@ acpi_pcib_acpi_attach(device_t dev)
device_printf(dev, "couldn't find _ADR\n");
} else {
/* XXX: We assume bus 0. */
- slot = addr >> 16;
- func = addr & 0xffff;
+ slot = ACPI_ADR_PCI_SLOT(addr);
+ func = ACPI_ADR_PCI_FUNC(addr);
if (bootverbose)
device_printf(dev, "reading config registers from 0:%d:%d\n",
slot, func);
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
index 811c3ed..3722160 100644
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -98,6 +98,10 @@ struct acpi_prw_data {
/* Flags for each device defined in the AML namespace. */
#define ACPI_FLAG_WAKE_ENABLED 0x1
+/* Macros for extracting parts of a PCI address from an _ADR value. */
+#define ACPI_ADR_PCI_SLOT(adr) (((adr) & 0xffff0000) >> 16)
+#define ACPI_ADR_PCI_FUNC(adr) ((adr) & 0xffff)
+
/*
* Entry points to ACPI from above are global functions defined in this
* file, sysctls, and I/O on the control device. Entry points from below
OpenPOWER on IntegriCloud