Introduce acpi_eval_reference_handle() --

an utility function to evaluate reference handles from package elements.

ok jmcneill@, pgoyette@
This commit is contained in:
jruoho 2010-01-18 18:06:31 +00:00
parent 431bb6c50c
commit 81e1657ee2
2 changed files with 36 additions and 3 deletions

View File

@ -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 <sys/cdefs.h>
__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:
*

View File

@ -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 *);