From 457bd2b661dd94c268b2a7a365aace7b1826d492 Mon Sep 17 00:00:00 2001 From: Magliano Andrea Date: Tue, 1 Mar 2011 10:03:14 +0100 Subject: [PATCH] Some minor changes * use AcpiUpdateAllGpes() (from FreeBSD 8.0) * ACPI_THREAD_ID type is no longer configurable * sync AcpiOsReadPciConfiguration with FreeBSD 8.0 (and simplify bitmasking) * because of AcpiOsDerivePciId() API removal, acpi_bus_number() is no longer needed --- sys/dev/acpica5/Osd/OsdHardware.c | 95 ++++--------------------------- sys/dev/acpica5/acdragonfly.h | 14 +---- sys/dev/acpica5/acpi.c | 10 +++- 3 files changed, 22 insertions(+), 97 deletions(-) diff --git a/sys/dev/acpica5/Osd/OsdHardware.c b/sys/dev/acpica5/Osd/OsdHardware.c index d727c40943..cecd6da287 100644 --- a/sys/dev/acpica5/Osd/OsdHardware.c +++ b/sys/dev/acpica5/Osd/OsdHardware.c @@ -111,31 +111,18 @@ ACPI_STATUS AcpiOsReadPciConfiguration(ACPI_PCI_ID *PciId, UINT32 Register, UINT64 *Value, UINT32 Width) { - u_int32_t byte_width = Width / 8; - u_int32_t val; + int bytes = Width / 8; + + if (Width == 64) + return (AE_SUPPORT); if (!pci_cfgregopen()) return (AE_NOT_EXIST); - val = pci_cfgregread(PciId->Bus, PciId->Device, PciId->Function, Register, - byte_width); - switch (Width) { - case 8: - *(u_int8_t *)Value = val & 0xff; - break; - case 16: - *(u_int16_t *)Value = val & 0xffff; - break; - case 32: - *(u_int32_t *)Value = val & 0xffffffff; - break; - case 64: - *(u_int64_t *)Value = val; - default: - /* debug trap goes here */ - break; - } - + *(UINT64 *)Value = pci_cfgregread(PciId->Bus, PciId->Device, + PciId->Function, Register, bytes); + *Value &= (1 << (bytes * 8)) - 1; + return (AE_OK); } @@ -144,74 +131,14 @@ ACPI_STATUS AcpiOsWritePciConfiguration(ACPI_PCI_ID *PciId, UINT32 Register, UINT64 Value, UINT32 Width) { - u_int32_t byte_width = Width / 8; + if (Width == 64) + return (AE_SUPPORT); if (!pci_cfgregopen()) return (AE_NOT_EXIST); pci_cfgregwrite(PciId->Bus, PciId->Device, PciId->Function, Register, - (u_int32_t) Value, byte_width); /* XXX casting */ + (u_int32_t) Value, Width / 8); /* XXX casting */ return (AE_OK); } - -/* XXX should use acpivar.h but too many include dependencies */ -extern ACPI_STATUS acpi_GetInteger(ACPI_HANDLE handle, char *path, int - *number); - -/* - * Depth-first recursive case for finding the bus, given the slot/function. - */ -static int -acpi_bus_number(ACPI_HANDLE root, ACPI_HANDLE curr, ACPI_PCI_ID *PciId) -{ - ACPI_HANDLE parent; - ACPI_STATUS status; - ACPI_OBJECT_TYPE type; - UINT32 adr; - int bus, slot, func, class, subclass, header; - - /* Try to get the _BBN object of the root, otherwise assume it is 0. */ - bus = 0; - if (root == curr) { - status = acpi_GetInteger(root, "_BBN", &bus); - if (ACPI_FAILURE(status) && bootverbose) - kprintf("acpi_bus_number: root bus has no _BBN, assuming 0\n"); - return (bus); - } - status = AcpiGetParent(curr, &parent); - if (ACPI_FAILURE(status)) - return (bus); - - /* First, recurse up the tree until we find the host bus. */ - bus = acpi_bus_number(root, parent, PciId); - - /* Validate parent bus device type. */ - if (ACPI_FAILURE(AcpiGetType(parent, &type)) || type != ACPI_TYPE_DEVICE) { - kprintf("acpi_bus_number: not a device, type %d\n", type); - return (bus); - } - - /* Get the parent's slot and function. */ - status = acpi_GetInteger(parent, "_ADR", &adr); - if (ACPI_FAILURE(status)) { - kprintf("acpi_bus_number: can't get _ADR\n"); - return (bus); - } - slot = ACPI_HIWORD(adr); - func = ACPI_LOWORD(adr); - - /* Is this a PCI-PCI or Cardbus-PCI bridge? */ - class = pci_cfgregread(bus, slot, func, PCIR_CLASS, 1); - if (class != PCIC_BRIDGE) - return (bus); - subclass = pci_cfgregread(bus, slot, func, PCIR_SUBCLASS, 1); - - /* Find the header type, masking off the multifunction bit. */ - header = pci_cfgregread(bus, slot, func, PCIR_HDRTYPE, 1) & PCIM_HDRTYPE; - if (header == PCIM_HDRTYPE_BRIDGE && subclass == PCIS_BRIDGE_PCI) - bus = pci_cfgregread(bus, slot, func, PCIR_SECBUS_1, 1); - if (header == PCIM_HDRTYPE_CARDBUS && subclass == PCIS_BRIDGE_CARDBUS) - bus = pci_cfgregread(bus, slot, func, PCIR_SECBUS_2, 1); - return (bus); -} diff --git a/sys/dev/acpica5/acdragonfly.h b/sys/dev/acpica5/acdragonfly.h index 53ee5909c3..5d28ae8858 100644 --- a/sys/dev/acpica5/acdragonfly.h +++ b/sys/dev/acpica5/acdragonfly.h @@ -143,16 +143,6 @@ #include #include -#ifdef foo -/* - * Use acpica-unix default ACPI_THREAD_ID, which is ACPI_SIZE_T; - * too much code in acpica assumes that ACPI_THREAD_ID has integer - * type... - */ -#include -#define ACPI_THREAD_ID thread_t -#endif - #ifdef DEBUGGER_THREADING #undef DEBUGGER_THREADING #endif /* DEBUGGER_THREADING */ @@ -176,13 +166,13 @@ struct acpicache; #else /* _KERNEL */ +#define ACPI_CAST_PTHREAD_T(pthread) ((ACPI_THREAD_ID) ACPI_TO_INTEGER (pthread)) + /* Not building kernel code, so use libc */ #define ACPI_USE_STANDARD_HEADERS #define ACPI_FLUSH_CPU_CACHE() #include -#define ACPI_THREAD_ID pthread_t - #define __cli() #define __sti() diff --git a/sys/dev/acpica5/acpi.c b/sys/dev/acpica5/acpi.c index 223d29654e..50a7868810 100644 --- a/sys/dev/acpica5/acpi.c +++ b/sys/dev/acpica5/acpi.c @@ -651,6 +651,15 @@ acpi_attach(device_t dev) if (!acpi_disabled("bus")) acpi_probe_children(dev); + /* Update all GPEs and enable runtime GPEs. */ + status = AcpiUpdateAllGpes(); + if (ACPI_FAILURE(status)) + device_printf(dev, "Could not update all GPEs: %s\n", + AcpiFormatException(status)); + + /* Allow sleep request after a while. */ + /* timeout(acpi_sleep_enable, sc, hz * ACPI_MINIMUM_AWAKETIME); */ + error = 0; out: @@ -2319,7 +2328,6 @@ acpi_AckSleepState(struct apm_clone_data *clone, int error) static void acpi_sleep_enable(void *arg) { - ((struct acpi_softc *)arg)->acpi_sleep_disabled = 0; } -- 2.41.0