diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 1bfd01be8fd7..68d36768fc89 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi.c,v 1.145 2010/01/18 17:34:37 jruoho Exp $ */ +/* $NetBSD: acpi.c,v 1.146 2010/01/18 18:06:31 jruoho Exp $ */ /*- * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.145 2010/01/18 17:34:37 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.146 2010/01/18 18:06:31 jruoho Exp $"); #include "opt_acpi.h" #include "opt_pcifixup.h" @@ -1250,6 +1250,38 @@ acpi_eval_struct(ACPI_HANDLE handle, const char *path, ACPI_BUFFER *bufp) return rv; } +/* + * acpi_eval_reference_handle: + * + * Evaluate a reference handle from an element in a package. + */ +ACPI_STATUS +acpi_eval_reference_handle(ACPI_OBJECT *elm, ACPI_HANDLE *handle) +{ + + if (elm == NULL || handle == NULL) + return AE_BAD_PARAMETER; + + switch (elm->Type) { + + case ACPI_TYPE_ANY: + case ACPI_TYPE_LOCAL_REFERENCE: + + if (elm->Reference.Handle == NULL) + return AE_NULL_ENTRY; + + *handle = elm->Reference.Handle; + + return AE_OK; + + case ACPI_TYPE_STRING: + return AcpiGetHandle(NULL, elm->String.Pointer, handle); + + default: + return AE_TYPE; + } +} + /* * acpi_foreach_package_object: * diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h index 266daada957f..4d124c32fe29 100644 --- a/sys/dev/acpi/acpivar.h +++ b/sys/dev/acpi/acpivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: acpivar.h,v 1.38 2009/11/29 21:32:50 cegger Exp $ */ +/* $NetBSD: acpivar.h,v 1.39 2010/01/18 18:06:31 jruoho Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -271,6 +271,7 @@ ACPI_STATUS acpi_eval_set_integer(ACPI_HANDLE handle, const char *path, ACPI_INTEGER arg); ACPI_STATUS acpi_eval_string(ACPI_HANDLE, const char *, char **); ACPI_STATUS acpi_eval_struct(ACPI_HANDLE, const char *, ACPI_BUFFER *); +ACPI_STATUS acpi_eval_reference_handle(ACPI_OBJECT *, ACPI_HANDLE *); ACPI_STATUS acpi_foreach_package_object(ACPI_OBJECT *, ACPI_STATUS (*)(ACPI_OBJECT *, void *), void *);