Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/acpi Properly evaluate the _PRW object in case we ha...



details:   https://anonhg.NetBSD.org/src/rev/1727a8e7b2ab
branches:  trunk
changeset: 750724:1727a8e7b2ab
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Tue Jan 12 12:21:04 2010 +0000

description:
Properly evaluate the _PRW object in case we have a package inside a
package.

ok jmcneill@

diffstat:

 sys/dev/acpi/acpi.c |  60 ++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 46 insertions(+), 14 deletions(-)

diffs (92 lines):

diff -r dbe13c9c455b -r 1727a8e7b2ab sys/dev/acpi/acpi.c
--- a/sys/dev/acpi/acpi.c       Tue Jan 12 10:13:32 2010 +0000
+++ b/sys/dev/acpi/acpi.c       Tue Jan 12 12:21:04 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi.c,v 1.143 2010/01/09 15:43:12 jruoho Exp $        */
+/*     $NetBSD: acpi.c,v 1.144 2010/01/12 12:21:04 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.143 2010/01/09 15:43:12 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.144 2010/01/12 12:21:04 jruoho Exp $");
 
 #include "opt_acpi.h"
 #include "opt_pcifixup.h"
@@ -1333,29 +1333,61 @@
 static void
 acpi_wake_gpe_helper(ACPI_HANDLE handle, bool enable)
 {
+       ACPI_OBJECT *elm, *obj;
+       ACPI_INTEGER val;
        ACPI_BUFFER buf;
        ACPI_STATUS rv;
-       ACPI_OBJECT *p, *elt;
 
        rv = acpi_eval_struct(handle, METHOD_NAME__PRW, &buf);
+
        if (ACPI_FAILURE(rv))
-               return;                 /* just ignore */
+               return;
+
+       obj = buf.Pointer;
+
+       if (obj->Type != ACPI_TYPE_PACKAGE || obj->Package.Count < 2)
+               goto out;
 
-       p = buf.Pointer;
-       if (p->Type != ACPI_TYPE_PACKAGE || p->Package.Count < 2)
-               goto out;               /* just ignore */
+       /*
+        * 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];
 
-       elt = p->Package.Elements;
+       switch (elm->Type) {
+
+       case ACPI_TYPE_INTEGER:
+               val = elm->Integer.Value;
+               break;
 
-       /* TBD: package support */
+       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;
+       }
+
        if (enable) {
-               AcpiSetGpeType(NULL, elt[0].Integer.Value,
-                   ACPI_GPE_TYPE_WAKE_RUN);
-               AcpiEnableGpe(NULL, elt[0].Integer.Value, ACPI_NOT_ISR);
+               (void)AcpiSetGpeType(NULL, val, ACPI_GPE_TYPE_WAKE_RUN);
+               (void)AcpiEnableGpe(NULL, val, ACPI_NOT_ISR);
        } else
-               AcpiDisableGpe(NULL, elt[0].Integer.Value, ACPI_NOT_ISR);
+               (void)AcpiDisableGpe(NULL, val, ACPI_NOT_ISR);
 
- out:
+out:
        ACPI_FREE(buf.Pointer);
 }
 



Home | Main Index | Thread Index | Old Index