Reorganize the main file: add several missing prototypes, move the functions
around so that they appear in their logical order and place, etc. In addition, split the utility functions to a separate file. No functional change. Ok jmcneill@.
This commit is contained in:
parent
31fe2769cc
commit
0c88d0e418
1220
sys/dev/acpi/acpi.c
1220
sys/dev/acpi/acpi.c
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,339 @@
|
|||
/* $NetBSD: acpi_util.c,v 1.1 2010/04/14 17:12:14 jruoho Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Charles M. Hannum of By Noon Software, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2001, 2003 Wasabi Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed for the NetBSD Project by
|
||||
* Wasabi Systems, Inc.
|
||||
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.1 2010/04/14 17:12:14 jruoho Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <dev/acpi/acpireg.h>
|
||||
#include <dev/acpi/acpivar.h>
|
||||
|
||||
#define _COMPONENT ACPI_BUS_COMPONENT
|
||||
ACPI_MODULE_NAME ("acpi_util")
|
||||
|
||||
/*
|
||||
* acpi_eval_integer:
|
||||
*
|
||||
* Evaluate an integer object.
|
||||
*/
|
||||
ACPI_STATUS
|
||||
acpi_eval_integer(ACPI_HANDLE handle, const char *path, ACPI_INTEGER *valp)
|
||||
{
|
||||
ACPI_OBJECT obj;
|
||||
ACPI_BUFFER buf;
|
||||
ACPI_STATUS rv;
|
||||
|
||||
if (handle == NULL)
|
||||
handle = ACPI_ROOT_OBJECT;
|
||||
|
||||
buf.Pointer = &obj;
|
||||
buf.Length = sizeof(obj);
|
||||
|
||||
rv = AcpiEvaluateObject(handle, path, NULL, &buf);
|
||||
|
||||
if (ACPI_FAILURE(rv))
|
||||
return rv;
|
||||
|
||||
if (obj.Type != ACPI_TYPE_INTEGER)
|
||||
return AE_TYPE;
|
||||
|
||||
if (valp != NULL)
|
||||
*valp = obj.Integer.Value;
|
||||
|
||||
return AE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* acpi_eval_set_integer:
|
||||
*
|
||||
* Evaluate an integer object with a single integer input parameter.
|
||||
*/
|
||||
ACPI_STATUS
|
||||
acpi_eval_set_integer(ACPI_HANDLE handle, const char *path, ACPI_INTEGER val)
|
||||
{
|
||||
ACPI_OBJECT_LIST arg;
|
||||
ACPI_OBJECT obj;
|
||||
|
||||
if (handle == NULL)
|
||||
handle = ACPI_ROOT_OBJECT;
|
||||
|
||||
obj.Type = ACPI_TYPE_INTEGER;
|
||||
obj.Integer.Value = val;
|
||||
|
||||
arg.Count = 1;
|
||||
arg.Pointer = &obj;
|
||||
|
||||
return AcpiEvaluateObject(handle, path, &arg, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* acpi_eval_string:
|
||||
*
|
||||
* Evaluate a (Unicode) string object.
|
||||
*/
|
||||
ACPI_STATUS
|
||||
acpi_eval_string(ACPI_HANDLE handle, const char *path, char **stringp)
|
||||
{
|
||||
ACPI_OBJECT *obj;
|
||||
ACPI_BUFFER buf;
|
||||
ACPI_STATUS rv;
|
||||
|
||||
rv = acpi_eval_struct(handle, path, &buf);
|
||||
|
||||
if (ACPI_FAILURE(rv))
|
||||
return rv;
|
||||
|
||||
obj = buf.Pointer;
|
||||
|
||||
if (obj->Type != ACPI_TYPE_STRING) {
|
||||
rv = AE_TYPE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (obj->String.Length == 0) {
|
||||
rv = AE_BAD_DATA;
|
||||
goto out;
|
||||
}
|
||||
|
||||
*stringp = ACPI_ALLOCATE(obj->String.Length + 1);
|
||||
|
||||
if (*stringp == NULL) {
|
||||
rv = AE_NO_MEMORY;
|
||||
goto out;
|
||||
}
|
||||
|
||||
(void)memcpy(*stringp, obj->String.Pointer, obj->String.Length);
|
||||
|
||||
(*stringp)[obj->String.Length] = '\0';
|
||||
|
||||
out:
|
||||
ACPI_FREE(buf.Pointer);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* acpi_eval_struct:
|
||||
*
|
||||
* Evaluate a more complex structure.
|
||||
* Caller must free buf.Pointer by ACPI_FREE().
|
||||
*/
|
||||
ACPI_STATUS
|
||||
acpi_eval_struct(ACPI_HANDLE handle, const char *path, ACPI_BUFFER *buf)
|
||||
{
|
||||
|
||||
if (handle == NULL)
|
||||
handle = ACPI_ROOT_OBJECT;
|
||||
|
||||
buf->Pointer = NULL;
|
||||
buf->Length = ACPI_ALLOCATE_LOCAL_BUFFER;
|
||||
|
||||
return AcpiEvaluateObject(handle, path, NULL, buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
* Iterate over all objects in a package, and pass them all
|
||||
* to a function. If the called function returns non-AE_OK,
|
||||
* the iteration is stopped and that value is returned.
|
||||
*/
|
||||
ACPI_STATUS
|
||||
acpi_foreach_package_object(ACPI_OBJECT *pkg,
|
||||
ACPI_STATUS (*func)(ACPI_OBJECT *, void *), void *arg)
|
||||
{
|
||||
ACPI_STATUS rv = AE_OK;
|
||||
uint32_t i;
|
||||
|
||||
if (pkg == NULL || pkg->Type != ACPI_TYPE_PACKAGE)
|
||||
return AE_BAD_PARAMETER;
|
||||
|
||||
for (i = 0; i < pkg->Package.Count; i++) {
|
||||
|
||||
rv = (*func)(&pkg->Package.Elements[i], arg);
|
||||
|
||||
if (ACPI_FAILURE(rv))
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* acpi_get:
|
||||
*
|
||||
* Fetch data info the specified (empty) ACPI buffer.
|
||||
* Caller must free buf.Pointer by ACPI_FREE().
|
||||
*/
|
||||
ACPI_STATUS
|
||||
acpi_get(ACPI_HANDLE handle, ACPI_BUFFER *buf,
|
||||
ACPI_STATUS (*getit)(ACPI_HANDLE, ACPI_BUFFER *))
|
||||
{
|
||||
|
||||
buf->Pointer = NULL;
|
||||
buf->Length = ACPI_ALLOCATE_LOCAL_BUFFER;
|
||||
|
||||
return (*getit)(handle, buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* acpi_name:
|
||||
*
|
||||
* Return a complete pathname from a handle.
|
||||
*
|
||||
* Note that the function uses static data storage;
|
||||
* if the data is needed for future use, it should be
|
||||
* copied before any subsequent calls overwrite it.
|
||||
*/
|
||||
const char *
|
||||
acpi_name(ACPI_HANDLE handle)
|
||||
{
|
||||
static char name[80];
|
||||
ACPI_BUFFER buf;
|
||||
ACPI_STATUS rv;
|
||||
|
||||
buf.Pointer = name;
|
||||
buf.Length = sizeof(name);
|
||||
|
||||
rv = AcpiGetName(handle, ACPI_FULL_PATHNAME, &buf);
|
||||
|
||||
if (ACPI_FAILURE(rv))
|
||||
return "UNKNOWN";
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
/*
|
||||
* acpi_match_hid:
|
||||
*
|
||||
* Match given ids against _HID and _CIDs.
|
||||
*/
|
||||
int
|
||||
acpi_match_hid(ACPI_DEVICE_INFO *ad, const char * const *ids)
|
||||
{
|
||||
uint32_t i, n;
|
||||
char *id;
|
||||
|
||||
while (*ids) {
|
||||
|
||||
if ((ad->Valid & ACPI_VALID_HID) != 0) {
|
||||
|
||||
if (pmatch(ad->HardwareId.String, *ids, NULL) == 2)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((ad->Valid & ACPI_VALID_CID) != 0) {
|
||||
|
||||
n = ad->CompatibleIdList.Count;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
|
||||
id = ad->CompatibleIdList.Ids[i].String;
|
||||
|
||||
if (pmatch(id, *ids, NULL) == 2)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
ids++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
/* $NetBSD: acpi_util.h,v 1.1 2010/04/14 17:12:14 jruoho Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Charles M. Hannum of By Noon Software, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2001, 2003 Wasabi Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed for the NetBSD Project by
|
||||
* Wasabi Systems, Inc.
|
||||
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_DEV_ACPI_ACPI_UTIL_H
|
||||
#define _SYS_DEV_ACPI_ACPI_UTIL_H
|
||||
|
||||
ACPI_STATUS acpi_eval_integer(ACPI_HANDLE, const char *, ACPI_INTEGER *);
|
||||
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 *);
|
||||
ACPI_STATUS acpi_get(ACPI_HANDLE, ACPI_BUFFER *,
|
||||
ACPI_STATUS (*)(ACPI_HANDLE, ACPI_BUFFER *));
|
||||
|
||||
const char* acpi_name(ACPI_HANDLE);
|
||||
|
||||
int acpi_match_hid(ACPI_DEVICE_INFO *, const char * const *);
|
||||
|
||||
#endif /* !_SYS_DEV_ACPI_ACPI_UTIL_H */
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: acpi_wakedev.c,v 1.9 2010/04/12 12:14:26 jruoho Exp $ */
|
||||
/* $NetBSD: acpi_wakedev.c,v 1.10 2010/04/14 17:12:14 jruoho Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 Jared D. McNeill <jmcneill@invisible.ca>
|
||||
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_wakedev.c,v 1.9 2010/04/12 12:14:26 jruoho Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: acpi_wakedev.c,v 1.10 2010/04/14 17:12:14 jruoho Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/device.h>
|
||||
|
@ -52,6 +52,8 @@ static const char * const acpi_wakedev_default[] = {
|
|||
static const struct sysctlnode *rnode = NULL;
|
||||
|
||||
static void acpi_wakedev_prepare(struct acpi_devnode *, int, int);
|
||||
static void acpi_wakedev_gpe(ACPI_HANDLE, bool);
|
||||
|
||||
|
||||
SYSCTL_SETUP(sysctl_acpi_wakedev_setup, "sysctl hw.acpi.wake subtree setup")
|
||||
{
|
||||
|
@ -135,11 +137,11 @@ acpi_wakedev_commit(struct acpi_softc *sc, int state)
|
|||
continue;
|
||||
|
||||
if (ad->ad_wake == 0)
|
||||
acpi_clear_wake_gpe(ad->ad_handle);
|
||||
acpi_wakedev_gpe(ad->ad_handle, false);
|
||||
else {
|
||||
aprint_debug_dev(ad->ad_parent,
|
||||
"set wake GPE for %s\n", ad->ad_name);
|
||||
acpi_set_wake_gpe(ad->ad_handle);
|
||||
acpi_wakedev_gpe(ad->ad_handle, true);
|
||||
}
|
||||
|
||||
acpi_wakedev_prepare(ad, ad->ad_wake, state);
|
||||
|
@ -198,3 +200,68 @@ fail:
|
|||
aprint_error_dev(ad->ad_parent, "failed to evaluate wake "
|
||||
"control method: %s\n", AcpiFormatException(rv));
|
||||
}
|
||||
|
||||
static void
|
||||
acpi_wakedev_gpe(ACPI_HANDLE handle, bool enable)
|
||||
{
|
||||
ACPI_OBJECT *elm, *obj;
|
||||
ACPI_INTEGER val;
|
||||
ACPI_BUFFER buf;
|
||||
ACPI_STATUS rv;
|
||||
|
||||
rv = acpi_eval_struct(handle, METHOD_NAME__PRW, &buf);
|
||||
|
||||
if (ACPI_FAILURE(rv))
|
||||
return;
|
||||
|
||||
obj = buf.Pointer;
|
||||
|
||||
if (obj->Type != ACPI_TYPE_PACKAGE || obj->Package.Count < 2)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* As noted in ACPI 3.0 (section 7.2.10), the _PRW object is
|
||||
* a package in which the first element is either an integer
|
||||
* or again a package. In the latter case the package inside
|
||||
* the package element has two elements, a reference handle
|
||||
* and the GPE number.
|
||||
*/
|
||||
elm = &obj->Package.Elements[0];
|
||||
|
||||
switch (elm->Type) {
|
||||
|
||||
case ACPI_TYPE_INTEGER:
|
||||
val = elm->Integer.Value;
|
||||
break;
|
||||
|
||||
case ACPI_TYPE_PACKAGE:
|
||||
|
||||
if (elm->Package.Count < 2)
|
||||
goto out;
|
||||
|
||||
if (elm->Package.Elements[0].Type != ACPI_TYPE_LOCAL_REFERENCE)
|
||||
goto out;
|
||||
|
||||
if (elm->Package.Elements[1].Type != ACPI_TYPE_INTEGER)
|
||||
goto out;
|
||||
|
||||
val = elm->Package.Elements[1].Integer.Value;
|
||||
break;
|
||||
|
||||
default:
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set or unset a GPE as both runtime and wake.
|
||||
*/
|
||||
if (enable != true)
|
||||
(void)AcpiDisableGpe(NULL, val, ACPI_NOT_ISR);
|
||||
else {
|
||||
(void)AcpiSetGpeType(NULL, val, ACPI_GPE_TYPE_WAKE_RUN);
|
||||
(void)AcpiEnableGpe(NULL, val, ACPI_NOT_ISR);
|
||||
}
|
||||
|
||||
out:
|
||||
ACPI_FREE(buf.Pointer);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: acpivar.h,v 1.46 2010/04/12 18:55:27 jruoho Exp $ */
|
||||
/* $NetBSD: acpivar.h,v 1.47 2010/04/14 17:12:14 jruoho Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2001 Wasabi Systems, Inc.
|
||||
|
@ -49,6 +49,7 @@
|
|||
#include <dev/isa/isavar.h>
|
||||
|
||||
#include <dev/acpi/acpica.h>
|
||||
#include <dev/acpi/acpi_util.h>
|
||||
|
||||
#include <dev/sysmon/sysmonvar.h>
|
||||
|
||||
|
@ -241,25 +242,10 @@ extern int acpi_active;
|
|||
|
||||
extern const struct acpi_resource_parse_ops acpi_resource_parse_ops_default;
|
||||
|
||||
int acpi_check(device_t, const char *);
|
||||
int acpi_probe(void);
|
||||
int acpi_check(device_t, const char *);
|
||||
|
||||
ACPI_PHYSICAL_ADDRESS acpi_OsGetRootPointer(void);
|
||||
int acpi_match_hid(ACPI_DEVICE_INFO *, const char * const *);
|
||||
void acpi_set_wake_gpe(ACPI_HANDLE);
|
||||
void acpi_clear_wake_gpe(ACPI_HANDLE);
|
||||
|
||||
ACPI_STATUS acpi_eval_integer(ACPI_HANDLE, const char *, ACPI_INTEGER *);
|
||||
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 *);
|
||||
ACPI_STATUS acpi_get(ACPI_HANDLE, ACPI_BUFFER *,
|
||||
ACPI_STATUS (*)(ACPI_HANDLE, ACPI_BUFFER *));
|
||||
const char* acpi_name(ACPI_HANDLE);
|
||||
|
||||
ACPI_STATUS acpi_resource_parse(device_t, ACPI_HANDLE, const char *,
|
||||
void *, const struct acpi_resource_parse_ops *);
|
||||
|
@ -284,12 +270,12 @@ struct acpi_irq *acpi_res_irq(struct acpi_resources *, int);
|
|||
struct acpi_drq *acpi_res_drq(struct acpi_resources *, int);
|
||||
|
||||
/*
|
||||
* power state transition
|
||||
* Sleep state transition.
|
||||
*/
|
||||
ACPI_STATUS acpi_enter_sleep_state(struct acpi_softc *, int);
|
||||
ACPI_STATUS acpi_enter_sleep_state(struct acpi_softc *, int);
|
||||
|
||||
/*
|
||||
* quirk handling
|
||||
* Quirk handling.
|
||||
*/
|
||||
struct acpi_quirk {
|
||||
const char *aq_tabletype; /* what type of table (FADT, DSDT, etc) */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.acpi,v 1.72 2010/04/11 22:42:30 jakllsch Exp $
|
||||
# $NetBSD: files.acpi,v 1.73 2010/04/14 17:12:14 jruoho Exp $
|
||||
|
||||
include "dev/acpi/acpica/files.acpica"
|
||||
|
||||
|
@ -14,16 +14,17 @@ device acpi: acpica, acpiapmbus, acpinodebus, acpiecdtbus, sysmon_power, sysmon_
|
|||
attach acpi at acpibus
|
||||
file dev/acpi/acpi.c acpi
|
||||
file dev/acpi/acpi_debug.c acpi
|
||||
file dev/acpi/acpi_resource.c acpi
|
||||
file dev/acpi/acpi_powerres.c acpi
|
||||
file dev/acpi/acpi_madt.c acpi
|
||||
file dev/acpi/acpi_pci.c acpi
|
||||
file dev/acpi/acpi_pci_link.c acpi
|
||||
file dev/acpi/acpi_powerres.c acpi
|
||||
file dev/acpi/acpi_quirks.c acpi
|
||||
file dev/acpi/acpi_timer.c acpi
|
||||
file dev/acpi/acpi_wakedev.c acpi
|
||||
file dev/acpi/acpi_resource.c acpi
|
||||
file dev/acpi/acpi_srat.c acpi
|
||||
file dev/acpi/acpi_slit.c acpi
|
||||
file dev/acpi/acpi_timer.c acpi
|
||||
file dev/acpi/acpi_util.c acpi
|
||||
file dev/acpi/acpi_wakedev.c acpi
|
||||
|
||||
# ACPI/apm emulation.
|
||||
attach apm at acpiapmbus with acpiapm: sysmon_envsys
|
||||
|
|
Loading…
Reference in New Issue