summaryrefslogtreecommitdiffstats
path: root/sys/dev/acpica/acpi.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-09-06 23:16:55 +0000
committerjhb <jhb@FreeBSD.org>2001-09-06 23:16:55 +0000
commit17996018560278416fdbba05ad40a0ac92c56224 (patch)
tree7b221f7c476d80cace85ba01ff28e9843bb694ad /sys/dev/acpica/acpi.c
parent72aad7aa5404b1d03f64c352edc661af322a3bec (diff)
downloadFreeBSD-src-17996018560278416fdbba05ad40a0ac92c56224.zip
FreeBSD-src-17996018560278416fdbba05ad40a0ac92c56224.tar.gz
Add a hack to acpi_EvaluateInteger() to handle the case of a method
returning a Buffer that contains an Integer rather an an Integer directly. Submitted by: msmith Approved by: msmith
Diffstat (limited to 'sys/dev/acpica/acpi.c')
-rw-r--r--sys/dev/acpica/acpi.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 9c6540a..a65b4d54 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -991,12 +991,18 @@ acpi_EvaluateInteger(ACPI_HANDLE handle, char *path, int *number)
{
ACPI_STATUS error;
ACPI_BUFFER buf;
- ACPI_OBJECT param;
+ ACPI_OBJECT param, *p;
+ int i;
ACPI_ASSERTLOCK;
if (handle == NULL)
handle = ACPI_ROOT_OBJECT;
+
+ /*
+ * Assume that what we've been pointed at is an Integer object, or
+ * a method that will return an Integer.
+ */
buf.Pointer = &param;
buf.Length = sizeof(param);
if ((error = AcpiEvaluateObject(handle, path, NULL, &buf)) == AE_OK) {
@@ -1006,6 +1012,36 @@ acpi_EvaluateInteger(ACPI_HANDLE handle, char *path, int *number)
error = AE_TYPE;
}
}
+
+ /*
+ * In some applications, a method that's expected to return an Integer
+ * may instead return a Buffer (probably to simplify some internal
+ * arithmetic). We'll try to fetch whatever it is, and if it's a Buffer,
+ * convert it into an Integer as best we can.
+ *
+ * This is a hack.
+ */
+ if (error == AE_BUFFER_OVERFLOW) {
+ if ((buf.Pointer = AcpiOsCallocate(buf.Length)) == NULL) {
+ error = AE_NO_MEMORY;
+ } else {
+ if ((error = AcpiEvaluateObject(handle, path, NULL, &buf)) == AE_OK) {
+ p = (ACPI_OBJECT *)buf.Pointer;
+ if (p->Type != ACPI_TYPE_BUFFER) {
+ error = AE_TYPE;
+ } else {
+ if (p->Buffer.Length > sizeof(int)) {
+ error = AE_BAD_DATA;
+ } else {
+ *number = 0;
+ for (i = 0; i < p->Buffer.Length; i++)
+ *number += (*(p->Buffer.Pointer + i) << (i * 8));
+ }
+ }
+ }
+ }
+ AcpiOsFree(buf.Pointer);
+ }
return(error);
}
OpenPOWER on IntegriCloud