summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorsommerfeld <sommerfeld@NetBSD.org>2002-03-24 03:32:14 +0000
committersommerfeld <sommerfeld@NetBSD.org>2002-03-24 03:32:14 +0000
commit44ede71657bd9e4133cc171dcf30b4e6aa2e4dd0 (patch)
tree838ee655e2a6de1c8c25a7327f4bb5f7f83ce913 /sys/dev
parent48d8c5fdd99f8067030ce40389e4deb76226d999 (diff)
Add acpi_eval_struct, to evaluate a complex data structure.
#if 0-out a half-fixed acpi_eval_string() and #if 0 the only call to it. (Previous code referenced an uninitialized local variable and couldn't have possibly worked).
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/acpi/acpi.c51
-rw-r--r--sys/dev/acpi/acpivar.h3
2 files changed, 47 insertions, 7 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index 4319266a5f3..81ea248b6f9 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi.c,v 1.6 2002/01/12 16:43:53 tsutsui Exp $ */
+/* $NetBSD: acpi.c,v 1.7 2002/03/24 03:32:14 sommerfeld Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.6 2002/01/12 16:43:53 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.7 2002/03/24 03:32:14 sommerfeld Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -478,15 +478,19 @@ int
acpi_print(void *aux, const char *pnp)
{
struct acpi_attach_args *aa = aux;
+#if 0
char *str;
+#endif
if (pnp) {
printf("%s ", aa->aa_node->ad_devinfo.HardwareId);
+#if 0 /* Not until we fix acpi_eval_string */
if (acpi_eval_string(aa->aa_node->ad_handle,
"_STR", &str) == AE_OK) {
printf("[%s] ", str);
AcpiOsFree(str);
}
+#endif
printf("at %s", pnp);
}
@@ -607,17 +611,19 @@ acpi_eval_integer(ACPI_HANDLE handle, char *path, int *valp)
return (rv);
}
+#if 0
/*
* acpi_eval_string:
*
- * Evaluage a (Unicode) string object.
+ * Evaluate a (Unicode) string object.
+ * XXX current API may leak memory, so don't use this.
*/
ACPI_STATUS
acpi_eval_string(ACPI_HANDLE handle, char *path, char **stringp)
{
ACPI_STATUS rv;
ACPI_BUFFER buf;
- ACPI_OBJECT param;
+ ACPI_OBJECT *param;
if (handle == NULL)
handle = ACPI_ROOT_OBJECT;
@@ -634,9 +640,11 @@ acpi_eval_string(ACPI_HANDLE handle, char *path, char **stringp)
return (AE_NO_MEMORY);
rv = AcpiEvaluateObject(handle, path, NULL, &buf);
+ param = (ACPI_OBJECT *)buf.Pointer;
if (rv == AE_OK) {
- if (param.Type == ACPI_TYPE_STRING) {
- *stringp = buf.Pointer;
+ if (param->Type == ACPI_TYPE_STRING) {
+ /* XXX may leak buf.Pointer!! */
+ *stringp = param->String.Pointer;
return (AE_OK);
}
rv = AE_TYPE;
@@ -645,6 +653,37 @@ acpi_eval_string(ACPI_HANDLE handle, char *path, char **stringp)
AcpiOsFree(buf.Pointer);
return (rv);
}
+#endif
+
+
+/*
+ * acpi_eval_struct:
+ *
+ * Evaluate a more complex structure. Caller must free buf.Pointer.
+ */
+ACPI_STATUS
+acpi_eval_struct(ACPI_HANDLE handle, char *path, ACPI_BUFFER *bufp)
+{
+ ACPI_STATUS rv;
+
+ if (handle == NULL)
+ handle = ACPI_ROOT_OBJECT;
+
+ bufp->Pointer = NULL;
+ bufp->Length = 0;
+
+ rv = AcpiEvaluateObject(handle, path, NULL, bufp);
+ if (rv != AE_BUFFER_OVERFLOW)
+ return (rv);
+
+ bufp->Pointer = AcpiOsAllocate(bufp->Length);
+ if (bufp->Pointer == NULL)
+ return (AE_NO_MEMORY);
+
+ rv = AcpiEvaluateObject(handle, path, NULL, bufp);
+
+ return (rv);
+}
/*
* acpi_get:
diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h
index 657f9810b2a..0e461885bf9 100644
--- a/sys/dev/acpi/acpivar.h
+++ b/sys/dev/acpi/acpivar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: acpivar.h,v 1.3 2001/09/29 18:13:48 thorpej Exp $ */
+/* $NetBSD: acpivar.h,v 1.4 2002/03/24 03:32:14 sommerfeld Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -246,6 +246,7 @@ int acpi_probe(void);
ACPI_STATUS acpi_eval_integer(ACPI_HANDLE, char *, int *);
ACPI_STATUS acpi_eval_string(ACPI_HANDLE, char *, char **);
+ACPI_STATUS acpi_eval_struct(ACPI_HANDLE, char *, ACPI_BUFFER *);
ACPI_STATUS acpi_get(ACPI_HANDLE, ACPI_BUFFER *,
ACPI_STATUS (*)(ACPI_HANDLE, ACPI_BUFFER *));