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).
This commit is contained in:
parent
48d8c5fdd9
commit
44ede71657
|
@ -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:
|
||||
|
|
|
@ -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 *));
|
||||
|
|
Loading…
Reference in New Issue