diff options
author | jhb <jhb@FreeBSD.org> | 2016-04-22 17:51:19 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2016-04-22 17:51:19 +0000 |
commit | da15c11c3103598c772b1bbb4daf72d65af13e0c (patch) | |
tree | a09764e2f6940c58d517ee2603898467d5f69d64 | |
parent | 7b42937a43db7453fba7437832b129f02273f6c5 (diff) | |
download | FreeBSD-src-da15c11c3103598c772b1bbb4daf72d65af13e0c.zip FreeBSD-src-da15c11c3103598c772b1bbb4daf72d65af13e0c.tar.gz |
Optionally return the output capabilities list from _OSC.
Both of the callers were expecting the input cap_set to be modified.
This fixes them to request cap_set to be updated with the returned buffer.
Reviewed by: jkim
Differential Revision: https://reviews.freebsd.org/D6040
-rw-r--r-- | sys/dev/acpica/acpi.c | 28 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_cpu.c | 4 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_pcib_acpi.c | 6 | ||||
-rw-r--r-- | sys/dev/acpica/acpivar.h | 3 |
4 files changed, 28 insertions, 13 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 285d9bb..84468e5 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -2482,10 +2482,12 @@ acpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOURCE *res) ACPI_STATUS acpi_EvaluateOSC(ACPI_HANDLE handle, uint8_t *uuid, int revision, int count, - uint32_t *caps) + uint32_t *caps_in, uint32_t *caps_out, bool query) { - ACPI_OBJECT arg[4]; + ACPI_OBJECT arg[4], *ret; ACPI_OBJECT_LIST arglist; + ACPI_BUFFER buf; + ACPI_STATUS status; arglist.Pointer = arg; arglist.Count = 4; @@ -2497,9 +2499,25 @@ acpi_EvaluateOSC(ACPI_HANDLE handle, uint8_t *uuid, int revision, int count, arg[2].Type = ACPI_TYPE_INTEGER; arg[2].Integer.Value = count; arg[3].Type = ACPI_TYPE_BUFFER; - arg[3].Buffer.Length = count * sizeof(*caps); - arg[3].Buffer.Pointer = (uint8_t *)caps; - return (AcpiEvaluateObject(handle, "_OSC", &arglist, NULL)); + arg[3].Buffer.Length = count * sizeof(*caps_in); + arg[3].Buffer.Pointer = (uint8_t *)caps_in; + caps_in[0] = query ? 1 : 0; + buf.Pointer = NULL; + buf.Length = ACPI_ALLOCATE_BUFFER; + status = AcpiEvaluateObjectTyped(handle, "_OSC", &arglist, &buf, + ACPI_TYPE_BUFFER); + if (ACPI_FAILURE(status)) + return (status); + if (caps_out != NULL) { + ret = buf.Pointer; + if (ret->Buffer.Length != count * sizeof(*caps_out)) { + AcpiOsFree(buf.Pointer); + return (AE_BUFFER_OVERFLOW); + } + bcopy(ret->Buffer.Pointer, caps_out, ret->Buffer.Length); + } + AcpiOsFree(buf.Pointer); + return (status); } /* diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index 8adacec..625cd54 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -388,9 +388,9 @@ acpi_cpu_attach(device_t dev) * Intel Processor Vendor-Specific ACPI Interface Specification. */ if (sc->cpu_features) { - cap_set[0] = 0; cap_set[1] = sc->cpu_features; - status = acpi_EvaluateOSC(sc->cpu_handle, cpu_oscuuid, 1, 2, cap_set); + status = acpi_EvaluateOSC(sc->cpu_handle, cpu_oscuuid, 1, 2, cap_set, + cap_set, false); if (ACPI_SUCCESS(status)) { if (cap_set[0] != 0) device_printf(dev, "_OSC returned status %#x\n", cap_set[0]); diff --git a/sys/dev/acpica/acpi_pcib_acpi.c b/sys/dev/acpica/acpi_pcib_acpi.c index cd51e79..f31bab7 100644 --- a/sys/dev/acpica/acpi_pcib_acpi.c +++ b/sys/dev/acpica/acpi_pcib_acpi.c @@ -306,9 +306,6 @@ acpi_pcib_osc(struct acpi_hpcib_softc *sc) 0x96, 0x57, 0x74, 0x41, 0xc0, 0x3d, 0xd7, 0x66 }; - /* Query Support Flag */ - cap_set[0] = 0; - /* Support Field: Extended PCI Config Space, MSI */ cap_set[1] = 0x11; @@ -316,7 +313,7 @@ acpi_pcib_osc(struct acpi_hpcib_softc *sc) cap_set[2] = 0; status = acpi_EvaluateOSC(sc->ap_handle, pci_host_bridge_uuid, 1, - nitems(cap_set), cap_set); + nitems(cap_set), cap_set, cap_set, false); if (ACPI_FAILURE(status)) { if (status == AE_NOT_FOUND) return; @@ -328,7 +325,6 @@ acpi_pcib_osc(struct acpi_hpcib_softc *sc) if (cap_set[0] != 0) { device_printf(sc->ap_dev, "_OSC returned error %#x\n", cap_set[0]); - return; } } diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index 6a31aea..dd1ceeb 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -336,7 +336,8 @@ ACPI_STATUS acpi_FindIndexedResource(ACPI_BUFFER *buf, int index, ACPI_STATUS acpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOURCE *res); ACPI_STATUS acpi_EvaluateOSC(ACPI_HANDLE handle, uint8_t *uuid, - int revision, int count, uint32_t *caps); + int revision, int count, uint32_t *caps_in, + uint32_t *caps_out, bool query); ACPI_STATUS acpi_OverrideInterruptLevel(UINT32 InterruptNumber); ACPI_STATUS acpi_SetIntrModel(int model); int acpi_ReqSleepState(struct acpi_softc *sc, int state); |