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
This commit is contained in:
jhb 2016-04-22 17:51:19 +00:00
parent 7b42937a43
commit da15c11c31
4 changed files with 28 additions and 13 deletions

View File

@ -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);
}
/*

View File

@ -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]);

View File

@ -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;
}
}

View File

@ -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);