Source-Changes-HG archive

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

[src/trunk]: src/sys Clean up <dev/acpi/acpireg.h>. While documenting the con...



details:   https://anonhg.NetBSD.org/src/rev/5adfca9084e8
branches:  trunk
changeset: 754306:5adfca9084e8
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Tue Apr 27 05:34:14 2010 +0000

description:
Clean up <dev/acpi/acpireg.h>. While documenting the control methods is an
admirable goal, it is pretty much mission impossible; the specifications are
nearly thousand pages each and the amount of methods is counted in hundreds.

In addition, use ACPICA's native constants from <actypes.h> when possible.
Also move ACPI_STA_OK from "mpacpi.c" to <dev/acpi/acpireg.h> to simplify
the evaluation of device status.

diffstat:

 sys/arch/x86/x86/mpacpi.c |    6 +-
 sys/dev/acpi/acpi.c       |   50 +++------
 sys/dev/acpi/acpi_power.c |    7 +-
 sys/dev/acpi/acpireg.h    |  241 ++-------------------------------------------
 4 files changed, 36 insertions(+), 268 deletions(-)

diffs (truncated from 486 to 300 lines):

diff -r fba499116a40 -r 5adfca9084e8 sys/arch/x86/x86/mpacpi.c
--- a/sys/arch/x86/x86/mpacpi.c Tue Apr 27 05:27:59 2010 +0000
+++ b/sys/arch/x86/x86/mpacpi.c Tue Apr 27 05:34:14 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mpacpi.c,v 1.86 2010/04/14 19:32:35 jruoho Exp $       */
+/*     $NetBSD: mpacpi.c,v 1.87 2010/04/27 05:34:14 jruoho Exp $       */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.86 2010/04/14 19:32:35 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.87 2010/04/27 05:34:14 jruoho Exp $");
 
 #include "acpica.h"
 #include "opt_acpi.h"
@@ -84,8 +84,6 @@
 
 #include "locators.h"
 
-#define ACPI_STA_OK (ACPI_STA_DEV_PRESENT|ACPI_STA_DEV_ENABLED|ACPI_STA_DEV_OK)
-
 /* XXX room for PCI-to-PCI bus */
 #define BUS_BUFFER (16)
 
diff -r fba499116a40 -r 5adfca9084e8 sys/dev/acpi/acpi.c
--- a/sys/dev/acpi/acpi.c       Tue Apr 27 05:27:59 2010 +0000
+++ b/sys/dev/acpi/acpi.c       Tue Apr 27 05:34:14 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi.c,v 1.192 2010/04/26 04:31:09 jruoho Exp $        */
+/*     $NetBSD: acpi.c,v 1.193 2010/04/27 05:34:14 jruoho Exp $        */
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.192 2010/04/26 04:31:09 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.193 2010/04/27 05:34:14 jruoho Exp $");
 
 #include "opt_acpi.h"
 #include "opt_pcifixup.h"
@@ -725,13 +725,10 @@
 }
 
 #ifdef ACPI_ACTIVATE_DEV
-
-#define ACPI_DEV_VALID (ACPI_VALID_STA | ACPI_VALID_HID)
-#define ACPI_DEV_STATUS        (ACPI_STA_DEV_PRESENT | ACPI_STA_DEV_ENABLED)
-
 static void
 acpi_activate_device(ACPI_HANDLE handle, ACPI_DEVICE_INFO **di)
 {
+       static const int valid = ACPI_VALID_STA | ACPI_VALID_HID;
        ACPI_DEVICE_INFO *newdi;
        ACPI_STATUS rv;
        uint32_t old;
@@ -740,12 +737,13 @@
         * If the device is valid and present,
         * but not enabled, try to activate it.
         */
-       if (((*di)->Valid & ACPI_DEV_VALID) != ACPI_DEV_VALID)
+       if (((*di)->Valid & valid) != valid)
                return;
 
        old = (*di)->CurrentStatus;
 
-       if ((old & ACPI_DEV_STATUS) != ACPI_STA_DEV_PRESENT)
+       if ((old & (ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED)) !=
+           ACPI_STA_DEVICE_PRESENT)
                return;
 
        rv = acpi_allocate_resources(handle);
@@ -880,10 +878,6 @@
 out:
        return rv;
 }
-
-#undef ACPI_DEV_VALID
-#undef ACPI_DEV_STATUS
-
 #endif /* ACPI_ACTIVATE_DEV */
 
 /*
@@ -916,6 +910,7 @@
 {
        struct acpi_attach_args aa;
        struct acpi_devnode *ad;
+       ACPI_DEVICE_INFO *di;
 
        SIMPLEQ_FOREACH(ad, &sc->ad_head, ad_list) {
 
@@ -929,21 +924,18 @@
                if (acpi_is_scope(ad) != false)
                        continue;
 
+               di = ad->ad_devinfo;
+
                /*
                 * We only attach devices which are present, enabled, and
                 * functioning properly. However, if a device is enabled,
                 * it is decoding resources and we should claim these,
                 * if possible. This requires changes to bus_space(9).
                 */
-               if (ad->ad_devinfo->Type == ACPI_TYPE_DEVICE) {
+               if (di->Type == ACPI_TYPE_DEVICE) {
 
-                       if ((ad->ad_devinfo->Valid & ACPI_VALID_STA) ==
-                           ACPI_VALID_STA &&
-                           (ad->ad_devinfo->CurrentStatus &
-                            (ACPI_STA_DEV_PRESENT|ACPI_STA_DEV_ENABLED|
-                             ACPI_STA_DEV_OK)) !=
-                           (ACPI_STA_DEV_PRESENT|ACPI_STA_DEV_ENABLED|
-                            ACPI_STA_DEV_OK))
+                       if ((di->Valid & ACPI_VALID_STA) != 0 &&
+                           (di->CurrentStatus & ACPI_STA_OK) != ACPI_STA_OK)
                                continue;
                }
 
@@ -952,20 +944,20 @@
                 * thermal zones and power resources do not
                 * have a valid HID, only evaluate devices.
                 */
-               if (ad->ad_devinfo->Type == ACPI_TYPE_DEVICE &&
-                   (ad->ad_devinfo->Valid & ACPI_VALID_HID) == 0)
+               if (di->Type == ACPI_TYPE_DEVICE &&
+                  (di->Valid & ACPI_VALID_HID) == 0)
                        continue;
 
                /*
                 * Handled internally.
                 */
-               if (ad->ad_devinfo->Type == ACPI_TYPE_PROCESSOR)
+               if (di->Type == ACPI_TYPE_PROCESSOR)
                        continue;
 
                /*
                 * Ditto, but bind power resources.
                 */
-               if (ad->ad_devinfo->Type == ACPI_TYPE_POWER) {
+               if (di->Type == ACPI_TYPE_POWER) {
                        acpi_power_res_add(ad);
                        continue;
                }
@@ -973,7 +965,7 @@
                /*
                 * Skip ignored HIDs.
                 */
-               if (acpi_match_hid(ad->ad_devinfo, acpi_ignored_ids))
+               if (acpi_match_hid(di, acpi_ignored_ids))
                        continue;
 
                aa.aa_node = ad;
@@ -988,9 +980,6 @@
        }
 }
 
-#define ACPI_STA_DEV_VALID      \
-       (ACPI_STA_DEV_PRESENT | ACPI_STA_DEV_ENABLED | ACPI_STA_DEV_OK)
-
 static void
 acpi_rescan_capabilities(struct acpi_softc *sc)
 {
@@ -1007,8 +996,7 @@
                        continue;
 
                if ((di->Valid & ACPI_VALID_STA) != 0 &&
-                   (di->CurrentStatus & ACPI_STA_DEV_VALID) !=
-                    ACPI_STA_DEV_VALID)
+                   (di->CurrentStatus & ACPI_STA_OK) != ACPI_STA_OK)
                        continue;
 
                /*
@@ -1036,8 +1024,6 @@
        }
 }
 
-#undef ACPI_STA_DEV_VALID
-
 static int
 acpi_print(void *aux, const char *pnp)
 {
diff -r fba499116a40 -r 5adfca9084e8 sys/dev/acpi/acpi_power.c
--- a/sys/dev/acpi/acpi_power.c Tue Apr 27 05:27:59 2010 +0000
+++ b/sys/dev/acpi/acpi_power.c Tue Apr 27 05:34:14 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_power.c,v 1.10 2010/04/26 13:38:42 jruoho Exp $ */
+/* $NetBSD: acpi_power.c,v 1.11 2010/04/27 05:34:14 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_power.c,v 1.10 2010/04/26 13:38:42 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_power.c,v 1.11 2010/04/27 05:34:14 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -70,6 +70,9 @@
 #define _COMPONENT                     ACPI_BUS_COMPONENT
 ACPI_MODULE_NAME                       ("acpi_power")
 
+#define        ACPI_STA_POW_OFF                0x00
+#define        ACPI_STA_POW_ON                 0x01
+
 /*
  * References.
  */
diff -r fba499116a40 -r 5adfca9084e8 sys/dev/acpi/acpireg.h
--- a/sys/dev/acpi/acpireg.h    Tue Apr 27 05:27:59 2010 +0000
+++ b/sys/dev/acpi/acpireg.h    Tue Apr 27 05:34:14 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpireg.h,v 1.7 2010/03/05 08:30:48 jruoho Exp $       */
+/*     $NetBSD: acpireg.h,v 1.8 2010/04/27 05:34:14 jruoho Exp $       */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -39,14 +39,11 @@
 #define _SYS_DEV_ACPI_ACPIREG_H
 
 /*
- * This file defines various ACPI event messages, etc.
+ * XXX: Use the native types from <actypes.h>.
+ *
+ *     Move the device-specific constants to
+ *     the device-specific files.
  */
-
-/*
- * 5.6.3: Device Object Notifications
- */
-
-/* Device Object Notification Types */
 #define        ACPI_NOTIFY_BusCheck            0x00
 #define        ACPI_NOTIFY_DeviceCheck         0x01
 #define        ACPI_NOTIFY_DeviceWake          0x02
@@ -83,238 +80,22 @@
 #define        ACPI_NOTIFY_CStatesChanged              0x81
 
 /*
- * 6: Configuration
- *
- * 6.1: Device Identification Objects
- *
- *     _ADR    Object that evaluates to a device's address on
- *             its parent bus.
- *
- *     _CID    Object that evaluates to a device's Plug and Play
- *             compatible ID list.
- *
- *     _DDN    Object that associates a logical software name
- *             (for example, COM1) with a device.
- *
- *     _HID    Object that evaluates to a device's Plug and Play
- *             hardware ID.
- *
- *     _SUN    Objcet that evaluates to the slot-unique ID number
- *             for a slot.
- *
- *     _STR    Object that contains a Unicode identifier for a device.
- *
- *     _UID    Object that specifies a device's unique persistent ID,
- *             or a control method that generates it.
+ * A common device status mask.
  */
+#define ACPI_STA_OK            (ACPI_STA_DEVICE_PRESENT        |       \
+                                ACPI_STA_DEVICE_ENABLED        |       \
+                                ACPI_STA_DEVICE_FUNCTIONING)
 
 /*
- * 6.1.1: _ADR (Address)
- *
- *     EISA            EISA slot numnber 0-f
- *
- *     Floppy Bus      Drive select values used for programming
- *                     the floppy controller to access the
- *                     specified INT13 unit number.  The _ADR
- *                     objects should be sorted based on drive
- *                     select encoding from 0-3.
- *
- *     IDE controller  0 - primary channel, 1 - secondary channel
- *
- *     IDE channel     0 - master drive, 1 - slave drive
- *
- *     PCI             High word - Device #, Low word - Function #
- *                     0xffff == all functions on a device
- *
- *     PCMCIA          Socket #; 0 == first socket
- *
- *     PC Card         Socket #; 0 == first socket
- *
- *     SMBus           Lowest slave address
- *
- *     USB Root Hub    Only one child of the host controller, must
- *                     have an _ADR of 0.



Home | Main Index | Thread Index | Old Index