Source-Changes-HG archive

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

[src/trunk]: src Extract ACPIVERBOSE into a kernel module. The module can be...



details:   https://anonhg.NetBSD.org/src/rev/f9d9a1bd90d4
branches:  trunk
changeset: 755299:f9d9a1bd90d4
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Mon May 31 20:32:28 2010 +0000

description:
Extract ACPIVERBOSE into a kernel module.  The module can be builtin
by defining 'options ACPIVERBOSE' in the kernel config file (no change
from current behavior), or it can be loaded at boot time on those
architectures that support the boot loader's "load" command.

ACPIVERBOSE also includes code to dump acpi/wmi data.

diffstat:

 distrib/sets/lists/modules/md.amd64 |    4 +-
 distrib/sets/lists/modules/md.i386  |    4 +-
 distrib/sets/lists/modules/md.ia64  |    3 +
 sys/dev/acpi/acpi.c                 |  140 ++++++++------------------
 sys/dev/acpi/acpi_verbose.c         |  185 ++++++++++++++++++++++++++++++++++++
 sys/dev/acpi/acpivar.h              |   12 ++-
 sys/dev/acpi/files.acpi             |    3 +-
 sys/dev/acpi/wmi/files.wmi          |    3 +-
 sys/dev/acpi/wmi/wmi_acpi.c         |  101 +-------------------
 sys/dev/acpi/wmi/wmi_acpivar.h      |   69 +++++++++++++-
 sys/dev/acpi/wmi/wmi_dump.c         |   64 ++++++++++++
 sys/modules/Makefile                |    8 +-
 sys/modules/acpiverbose/Makefile    |   13 ++
 13 files changed, 407 insertions(+), 202 deletions(-)

diffs (truncated from 834 to 300 lines):

diff -r 7dc130d9bdf8 -r f9d9a1bd90d4 distrib/sets/lists/modules/md.amd64
--- a/distrib/sets/lists/modules/md.amd64       Mon May 31 20:19:33 2010 +0000
+++ b/distrib/sets/lists/modules/md.amd64       Mon May 31 20:32:28 2010 +0000
@@ -1,4 +1,6 @@
-# $NetBSD: md.amd64,v 1.2 2010/04/09 13:49:12 ahoka Exp $
+# $NetBSD: md.amd64,v 1.3 2010/05/31 20:32:28 pgoyette Exp $
+./@MODULEDIR@/acpiverbose                      base-kernel-modules     kmod
+./@MODULEDIR@/acpiverbose/acpiverbose.kmod     base-kernel-modules     kmod
 ./@MODULEDIR@/azalia                           base-kernel-modules     kmod
 ./@MODULEDIR@/azalia/azalia.kmod               base-kernel-modules     kmod
 ./@MODULEDIR@/compat_linux                     base-kernel-modules     kmod
diff -r 7dc130d9bdf8 -r f9d9a1bd90d4 distrib/sets/lists/modules/md.i386
--- a/distrib/sets/lists/modules/md.i386        Mon May 31 20:19:33 2010 +0000
+++ b/distrib/sets/lists/modules/md.i386        Mon May 31 20:32:28 2010 +0000
@@ -1,4 +1,6 @@
-# $NetBSD: md.i386,v 1.3 2010/04/09 13:49:12 ahoka Exp $
+# $NetBSD: md.i386,v 1.4 2010/05/31 20:32:28 pgoyette Exp $
+./@MODULEDIR@/acpiverbose                      base-kernel-modules     kmod
+./@MODULEDIR@/acpiverbose/acpiverbose.kmod     base-kernel-modules     kmod
 ./@MODULEDIR@/azalia                           base-kernel-modules     kmod
 ./@MODULEDIR@/azalia/azalia.kmod               base-kernel-modules     kmod
 ./@MODULEDIR@/compat_freebsd                   base-kernel-modules     kmod
diff -r 7dc130d9bdf8 -r f9d9a1bd90d4 distrib/sets/lists/modules/md.ia64
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/sets/lists/modules/md.ia64        Mon May 31 20:32:28 2010 +0000
@@ -0,0 +1,3 @@
+# $NetBSD: md.ia64,v 1.1 2010/05/31 20:32:28 pgoyette Exp $
+./@MODULEDIR@/acpiverbose                      base-kernel-modules     kmod
+./@MODULEDIR@/acpiverbose/acpiverbose.kmod     base-kernel-modules     kmod
diff -r 7dc130d9bdf8 -r f9d9a1bd90d4 sys/dev/acpi/acpi.c
--- a/sys/dev/acpi/acpi.c       Mon May 31 20:19:33 2010 +0000
+++ b/sys/dev/acpi/acpi.c       Mon May 31 20:32:28 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi.c,v 1.196 2010/05/23 22:05:54 christos Exp $      */
+/*     $NetBSD: acpi.c,v 1.197 2010/05/31 20:32:29 pgoyette 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.196 2010/05/23 22:05:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.197 2010/05/31 20:32:29 pgoyette Exp $");
 
 #include "opt_acpi.h"
 #include "opt_pcifixup.h"
@@ -74,6 +74,7 @@
 #include <sys/device.h>
 #include <sys/kernel.h>
 #include <sys/malloc.h>
+#include <sys/module.h>
 #include <sys/mutex.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
@@ -86,10 +87,6 @@
 #include <dev/acpi/acpi_timer.h>
 #include <dev/acpi/acpi_wakedev.h>
 
-#ifdef ACPIVERBOSE
-#include <dev/acpi/acpidevs_data.h>
-#endif
-
 #define _COMPONENT     ACPI_BUS_COMPONENT
 ACPI_MODULE_NAME       ("acpi")
 
@@ -186,11 +183,6 @@
 static void            acpi_rescan_capabilities(struct acpi_softc *);
 static int             acpi_print(void *aux, const char *);
 
-#ifdef ACPIVERBOSE
-static void            acpi_print_devnodes(struct acpi_softc *);
-static void            acpi_print_tree(struct acpi_devnode *, uint32_t);
-#endif
-
 static void            acpi_notify_handler(ACPI_HANDLE, uint32_t, void *);
 
 static void            acpi_register_fixed_button(struct acpi_softc *, int);
@@ -210,6 +202,41 @@
 
 extern struct cfdriver acpi_cd;
 
+/* Handle routine vectors and loading for acpiverbose module */
+void acpi_verbose_ctl(bool load);
+void acpi_null(void);
+
+void (*acpi_print_devnodes)(struct acpi_softc *) = (void *)acpi_null;
+void (*acpi_print_tree)(struct acpi_devnode *, uint32_t) = (void *)acpi_null;
+void (*acpi_print_dev)(const char *) = (void *)acpi_null;
+void (*acpi_wmidump)(void *) = (void *)acpi_null;
+
+/* acpiverbose support */
+void
+acpi_null(void)
+{
+       /* Nothing to do */
+}
+
+void
+acpi_verbose_ctl(bool load)
+{
+       static int loaded = 0;
+  
+       if (load) { 
+               if (loaded++ == 0)
+                       if (module_load("acpiverbose", MODCTL_LOAD_FORCE,
+                                       NULL, MODULE_CLASS_MISC) != 0)
+                               loaded = 0;
+               return;
+       }
+       if (loaded == 0) 
+               return;
+       if (--loaded == 0)
+               module_unload("acpiverbose");
+}  
+
+
 CFATTACH_DECL2_NEW(acpi, sizeof(struct acpi_softc),
     acpi_match, acpi_attach, acpi_detach, NULL, acpi_rescan, acpi_childdet);
 
@@ -374,6 +401,8 @@
        if (acpi_softc != NULL)
                panic("%s: already attached", __func__);
 
+       acpi_verbose_ctl(true);
+
        rsdt = acpi_map_rsdt();
 
        if (rsdt == NULL)
@@ -538,6 +567,8 @@
 
        acpi_softc = NULL;
 
+       acpi_verbose_ctl(false);
+
        return 0;
 }
 
@@ -623,11 +654,8 @@
 
        (void)acpi_pcidev_scan(sc->sc_root);
 
-#ifdef ACPIVERBOSE
        acpi_print_devnodes(sc);
-       aprint_normal("\n");
        acpi_print_tree(sc->sc_root, 0);
-#endif
 }
 
 static ACPI_STATUS
@@ -1049,21 +1077,9 @@
                                }
                                ACPI_FREE(buf.Pointer);
                        }
-#ifdef ACPIVERBOSE
-                       else {
-                               int i;
+                       else
+                               acpi_print_dev(pnpstr);
 
-                               for (i = 0; i < __arraycount(acpi_knowndevs);
-                                   i++) {
-                                       if (strcmp(acpi_knowndevs[i].pnp,
-                                           pnpstr) == 0) {
-                                               aprint_normal("[%s] ",
-                                                   acpi_knowndevs[i].str);
-                                       }
-                               }
-                       }
-
-#endif
                        aprint_normal("at %s", pnp);
                } else if (aa->aa_node->ad_devinfo->Type != ACPI_TYPE_DEVICE) {
                        aprint_normal("%s (ACPI Object Type '%s' "
@@ -1092,74 +1108,6 @@
        return UNCONF;
 }
 
-#ifdef ACPIVERBOSE
-static void
-acpi_print_devnodes(struct acpi_softc *sc)
-{
-       struct acpi_devnode *ad;
-       ACPI_DEVICE_INFO *di;
-
-       SIMPLEQ_FOREACH(ad, &sc->ad_head, ad_list) {
-
-               di = ad->ad_devinfo;
-               aprint_normal_dev(sc->sc_dev, "%-5s ", ad->ad_name);
-
-               aprint_normal("HID %-10s ",
-                   ((di->Valid & ACPI_VALID_HID) != 0) ?
-                   di->HardwareId.String: "-");
-
-               aprint_normal("UID %-4s ",
-                   ((di->Valid & ACPI_VALID_UID) != 0) ?
-                   di->UniqueId.String : "-");
-
-               if ((di->Valid & ACPI_VALID_STA) != 0)
-                       aprint_normal("STA 0x%08X ", di->CurrentStatus);
-               else
-                       aprint_normal("STA %10s ", "-");
-
-               if ((di->Valid & ACPI_VALID_ADR) != 0)
-                       aprint_normal("ADR 0x%016" PRIX64"", di->Address);
-               else
-                       aprint_normal("ADR -");
-
-               aprint_normal("\n");
-       }
-}
-
-static void
-acpi_print_tree(struct acpi_devnode *ad, uint32_t level)
-{
-       struct acpi_devnode *child;
-       uint32_t i;
-
-       for (i = 0; i < level; i++)
-               aprint_normal("    ");
-
-       aprint_normal("%-5s [%02u] [%c%c] ", ad->ad_name, ad->ad_type,
-           ((ad->ad_flags & ACPI_DEVICE_POWER)  != 0) ? 'P' : ' ',
-           ((ad->ad_flags & ACPI_DEVICE_WAKEUP) != 0) ? 'W' : ' ');
-
-       if (ad->ad_pciinfo != NULL) {
-
-               aprint_normal("(PCI) @ 0x%02X:0x%02X:0x%02X:0x%02X ",
-                   ad->ad_pciinfo->ap_segment, ad->ad_pciinfo->ap_bus,
-                   ad->ad_pciinfo->ap_device, ad->ad_pciinfo->ap_function);
-
-               if ((ad->ad_devinfo->Flags & ACPI_PCI_ROOT_BRIDGE) != 0)
-                       aprint_normal("[R] ");
-
-               if (ad->ad_pciinfo->ap_bridge != false)
-                       aprint_normal("[B] -> 0x%02X",
-                           ad->ad_pciinfo->ap_downbus);
-       }
-
-       aprint_normal("\n");
-
-       SIMPLEQ_FOREACH(child, &ad->ad_child_head, ad_child_list)
-           acpi_print_tree(child, level + 1);
-}
-#endif
-
 /*
  * Notify.
  */
diff -r 7dc130d9bdf8 -r f9d9a1bd90d4 sys/dev/acpi/acpi_verbose.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/acpi/acpi_verbose.c       Mon May 31 20:32:28 2010 +0000
@@ -0,0 +1,185 @@
+/*     $NetBSD: acpi_verbose.c,v 1.1 2010/05/31 20:32:29 pgoyette 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:



Home | Main Index | Thread Index | Old Index