Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F141217926
D17121.id47920.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D17121.id47920.diff
View Options
Index: sys/dev/acpica/acpi.c
===================================================================
--- sys/dev/acpica/acpi.c
+++ sys/dev/acpica/acpi.c
@@ -2570,6 +2570,104 @@
return (AE_OK);
}
+UINT8
+acpi_DSMQuery(ACPI_HANDLE handle, uint8_t *uuid, int revision)
+{
+ /*
+ * ACPI spec 9.14.1 defines this.
+ *
+ * "Arg2: Function Index Represents a specific function whose meaning is
+ * specific to the UUID and Revision ID. Function indices should start
+ * with 1. Function number zero is a query function (see the special
+ * return code defined below)."
+ *
+ * XXX: Shouldn't be necessary to zero out buf as the ACPI spec
+ * guarantees to return something for the bits we're caring about.
+ */
+ ACPI_BUFFER buf = {0};
+ ACPI_OBJECT *obj;
+ UINT8 ret = 0;
+
+ if (!ACPI_SUCCESS(acpi_EvaluateDSM(handle, uuid, revision, 0, &buf))) {
+ ACPI_INFO(("Failed to enumerate DSM functions\n"));
+ return 0;
+ }
+
+ obj = (ACPI_OBJECT *)buf.Pointer;
+ KASSERT(obj, ("Object not allowed to be NULL\n"));
+
+ /*
+ * From ACPI 6.2 spec 9.1.1:
+ * If Function Index = 0, a Buffer containing a function index bitfield.
+ * Otherwise, the return value and type depends on the UUID and revision
+ * ID (see below).
+ */
+ switch (obj->Type) {
+ case ACPI_TYPE_BUFFER:
+ ret = *(uint8_t *)obj->Buffer.Pointer;
+ 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;
+ break;
+ default:
+ ACPI_WARNING((AE_INFO, "Unexpected return type %u\n", obj->Type));
+ };
+
+ AcpiOsFree(obj);
+ return ret;
+}
+
+ACPI_STATUS
+acpi_EvaluateDSM(ACPI_HANDLE handle, uint8_t *uuid, int revision,
+ uint64_t function, ACPI_BUFFER *out_buf)
+{
+ ACPI_OBJECT arg[4];
+ ACPI_OBJECT_LIST arglist;
+ ACPI_BUFFER buf;
+ ACPI_STATUS status;
+
+ arg[0].Type = ACPI_TYPE_BUFFER;
+ arg[0].Buffer.Length = ACPI_UUID_LENGTH;
+ arg[0].Buffer.Pointer = uuid;
+ arg[1].Type = ACPI_TYPE_INTEGER;
+ arg[1].Integer.Value = revision;
+ arg[2].Type = ACPI_TYPE_INTEGER;
+ arg[2].Integer.Value = function;
+ arg[3].Type = ACPI_TYPE_PACKAGE;
+ arg[3].Package.Count = 0;
+ arg[3].Package.Elements = NULL;
+
+ /*
+ * XXX DSM may return multiple types depending on the function. It is
+ * therefore unsafe to used the typed evaluation.
+ */
+ arglist.Pointer = arg;
+ arglist.Count = 4;
+ buf.Pointer = NULL;
+ buf.Length = ACPI_ALLOCATE_BUFFER;
+ status = AcpiEvaluateObject(handle, "_DSM", &arglist, &buf);
+ if (ACPI_FAILURE(status))
+ return (status);
+
+ KASSERT(ACPI_SUCCESS(status), ("Unexpected status"));
+
+ if (!out_buf)
+ return status;
+
+ if (buf.Length < sizeof(*out_buf)) {
+ AcpiOsFree(buf.Pointer);
+ ACPI_WARNING((AE_INFO,
+ "Unsupported buffer size returned %lu\n", buf.Length));
+ return AE_BUFFER_OVERFLOW;
+ }
+
+ *out_buf = buf;
+
+ return status;
+}
+
ACPI_STATUS
acpi_EvaluateOSC(ACPI_HANDLE handle, uint8_t *uuid, int revision, int count,
uint32_t *caps_in, uint32_t *caps_out, bool query)
Index: sys/dev/acpica/acpivar.h
===================================================================
--- sys/dev/acpica/acpivar.h
+++ sys/dev/acpica/acpivar.h
@@ -349,6 +349,9 @@
ACPI_RESOURCE **resp);
ACPI_STATUS acpi_AppendBufferResource(ACPI_BUFFER *buf,
ACPI_RESOURCE *res);
+UINT8 acpi_DSMQuery(ACPI_HANDLE handle, uint8_t *uuid, int revision);
+ACPI_STATUS acpi_EvaluateDSM(ACPI_HANDLE handle, uint8_t *uuid,
+ int revision, uint64_t function, ACPI_BUFFER *out_buf);
ACPI_STATUS acpi_EvaluateOSC(ACPI_HANDLE handle, uint8_t *uuid,
int revision, int count, uint32_t *caps_in,
uint32_t *caps_out, bool query);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 3, 1:23 PM (15 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27472083
Default Alt Text
D17121.id47920.diff (3 KB)
Attached To
Mode
D17121: Summary: acpi: Add an interface to obtain DSM information
Attached
Detach File
Event Timeline
Log In to Comment