Author: wulf Date: Sat Oct 31 19:47:34 2020 New Revision: 367231 URL: https://svnweb.freebsd.org/changeset/base/367231
Log: acpi: Tweak _DSM method evaluation helpers. - Use ACPI style for _DSM evaluation helper parameter types. - Constify UUID parameter. - Increase size of returned DSM function bitmap by acpi_DSMQuery() up to 64 items. Old limit of 8 functions is not sufficient for JEDEC JESD245 NVDIMMs. - Add new acpi_EvaluateDSMTyped() helper which performs additional return value type check as compared with acpi_EvaluateDSM(). - Reimplement acpi_EvaluateDSM() on top of the acpi_EvaluateDSMTyped() call. Reviewed by: scottph, manu Differential Revision: https://reviews.freebsd.org/D26602 Modified: head/sys/dev/acpica/acpi.c head/sys/dev/acpica/acpivar.h Modified: head/sys/dev/acpica/acpi.c ============================================================================== --- head/sys/dev/acpica/acpi.c Sat Oct 31 19:30:23 2020 (r367230) +++ head/sys/dev/acpica/acpi.c Sat Oct 31 19:47:34 2020 (r367231) @@ -2632,8 +2632,8 @@ acpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOU return (AE_OK); } -UINT8 -acpi_DSMQuery(ACPI_HANDLE h, uint8_t *uuid, int revision) +UINT64 +acpi_DSMQuery(ACPI_HANDLE h, const uint8_t *uuid, int revision) { /* * ACPI spec 9.1.1 defines this. @@ -2645,7 +2645,8 @@ acpi_DSMQuery(ACPI_HANDLE h, uint8_t *uuid, int revisi */ ACPI_BUFFER buf; ACPI_OBJECT *obj; - UINT8 ret = 0; + UINT64 ret = 0; + int i; if (!ACPI_SUCCESS(acpi_EvaluateDSM(h, uuid, revision, 0, NULL, &buf))) { ACPI_INFO(("Failed to enumerate DSM functions\n")); @@ -2663,12 +2664,13 @@ acpi_DSMQuery(ACPI_HANDLE h, uint8_t *uuid, int revisi */ switch (obj->Type) { case ACPI_TYPE_BUFFER: - ret = *(uint8_t *)obj->Buffer.Pointer; + for (i = 0; i < MIN(obj->Buffer.Length, sizeof(ret)); i++) + ret |= (((uint64_t)obj->Buffer.Pointer[i]) << (i * 8)); break; case ACPI_TYPE_INTEGER: ACPI_BIOS_WARNING((AE_INFO, "Possibly buggy BIOS with ACPI_TYPE_INTEGER for function enumeration\n")); - ret = obj->Integer.Value & 0xFF; + ret = obj->Integer.Value; break; default: ACPI_WARNING((AE_INFO, "Unexpected return type %u\n", obj->Type)); @@ -2684,9 +2686,18 @@ acpi_DSMQuery(ACPI_HANDLE h, uint8_t *uuid, int revisi * check the type of the returned object. */ ACPI_STATUS -acpi_EvaluateDSM(ACPI_HANDLE handle, uint8_t *uuid, int revision, - uint64_t function, union acpi_object *package, ACPI_BUFFER *out_buf) +acpi_EvaluateDSM(ACPI_HANDLE handle, const uint8_t *uuid, int revision, + UINT64 function, ACPI_OBJECT *package, ACPI_BUFFER *out_buf) { + return (acpi_EvaluateDSMTyped(handle, uuid, revision, function, + package, out_buf, ACPI_TYPE_ANY)); +} + +ACPI_STATUS +acpi_EvaluateDSMTyped(ACPI_HANDLE handle, const uint8_t *uuid, int revision, + UINT64 function, ACPI_OBJECT *package, ACPI_BUFFER *out_buf, + ACPI_OBJECT_TYPE type) +{ ACPI_OBJECT arg[4]; ACPI_OBJECT_LIST arglist; ACPI_BUFFER buf; @@ -2697,7 +2708,7 @@ acpi_EvaluateDSM(ACPI_HANDLE handle, uint8_t *uuid, in arg[0].Type = ACPI_TYPE_BUFFER; arg[0].Buffer.Length = ACPI_UUID_LENGTH; - arg[0].Buffer.Pointer = uuid; + arg[0].Buffer.Pointer = __DECONST(uint8_t *, uuid); arg[1].Type = ACPI_TYPE_INTEGER; arg[1].Integer.Value = revision; arg[2].Type = ACPI_TYPE_INTEGER; @@ -2714,7 +2725,7 @@ acpi_EvaluateDSM(ACPI_HANDLE handle, uint8_t *uuid, in arglist.Count = 4; buf.Pointer = NULL; buf.Length = ACPI_ALLOCATE_BUFFER; - status = AcpiEvaluateObject(handle, "_DSM", &arglist, &buf); + status = AcpiEvaluateObjectTyped(handle, "_DSM", &arglist, &buf, type); if (ACPI_FAILURE(status)) return (status); Modified: head/sys/dev/acpica/acpivar.h ============================================================================== --- head/sys/dev/acpica/acpivar.h Sat Oct 31 19:30:23 2020 (r367230) +++ head/sys/dev/acpica/acpivar.h Sat Oct 31 19:47:34 2020 (r367231) @@ -349,10 +349,15 @@ ACPI_STATUS acpi_FindIndexedResource(ACPI_BUFFER *buf, ACPI_RESOURCE **resp); ACPI_STATUS acpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOURCE *res); -UINT8 acpi_DSMQuery(ACPI_HANDLE h, uint8_t *uuid, int revision); -ACPI_STATUS acpi_EvaluateDSM(ACPI_HANDLE handle, uint8_t *uuid, - int revision, uint64_t function, union acpi_object *package, +UINT64 acpi_DSMQuery(ACPI_HANDLE h, const uint8_t *uuid, + int revision); +ACPI_STATUS acpi_EvaluateDSM(ACPI_HANDLE handle, const uint8_t *uuid, + int revision, UINT64 function, ACPI_OBJECT *package, ACPI_BUFFER *out_buf); +ACPI_STATUS acpi_EvaluateDSMTyped(ACPI_HANDLE handle, + const uint8_t *uuid, int revision, UINT64 function, + ACPI_OBJECT *package, ACPI_BUFFER *out_buf, + ACPI_OBJECT_TYPE type); ACPI_STATUS acpi_EvaluateOSC(ACPI_HANDLE handle, uint8_t *uuid, int revision, int count, uint32_t *caps_in, uint32_t *caps_out, bool query); _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"