Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/acpi Reorganize the main file: add several missing p...



details:   https://anonhg.NetBSD.org/src/rev/82a9d77990ad
branches:  trunk
changeset: 753964:82a9d77990ad
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Wed Apr 14 17:12:14 2010 +0000

description:
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@.

diffstat:

 sys/dev/acpi/acpi.c         |  1220 ++++++++++++++----------------------------
 sys/dev/acpi/acpi_util.c    |   339 +++++++++++
 sys/dev/acpi/acpi_util.h    |    86 +++
 sys/dev/acpi/acpi_wakedev.c |    75 ++-
 sys/dev/acpi/acpivar.h      |    28 +-
 sys/dev/acpi/files.acpi     |    11 +-
 6 files changed, 931 insertions(+), 828 deletions(-)

diffs (truncated from 2021 to 300 lines):

diff -r 1ff1505986b1 -r 82a9d77990ad sys/dev/acpi/acpi.c
--- a/sys/dev/acpi/acpi.c       Wed Apr 14 16:30:50 2010 +0000
+++ b/sys/dev/acpi/acpi.c       Wed Apr 14 17:12:14 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi.c,v 1.168 2010/04/14 06:10:32 jruoho Exp $        */
+/*     $NetBSD: acpi.c,v 1.169 2010/04/14 17:12:14 jruoho Exp $        */
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -64,13 +64,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-/*
- * Autoconfiguration support for the Intel ACPI Component Architecture
- * ACPI reference implementation.
- */
-
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.168 2010/04/14 06:10:32 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.169 2010/04/14 17:12:14 jruoho Exp $");
 
 #include "opt_acpi.h"
 #include "opt_pcifixup.h"
@@ -94,8 +89,8 @@
 #include <dev/acpi/acpidevs_data.h>
 #endif
 
-#define _COMPONENT          ACPI_BUS_COMPONENT
-ACPI_MODULE_NAME            ("acpi")
+#define _COMPONENT     ACPI_BUS_COMPONENT
+ACPI_MODULE_NAME       ("acpi")
 
 #if defined(ACPI_PCI_FIXUP)
 #error The option ACPI_PCI_FIXUP has been obsoleted by PCI_INTR_FIXUP_DISABLED.  Please adjust your kernel configuration file.
@@ -121,27 +116,6 @@
 
 static ACPI_TABLE_DESC acpi_initial_tables[128];
 
-static int     acpi_match(device_t, cfdata_t, void *);
-static void    acpi_attach(device_t, device_t, void *);
-static void    acpi_childdet(device_t, device_t);
-static int     acpi_detach(device_t, int);
-
-static int     acpi_rescan(device_t, const char *, const int *);
-static void    acpi_rescan1(struct acpi_softc *, const char *, const int *);
-static void    acpi_rescan_nodes(struct acpi_softc *);
-static void    acpi_rescan_capabilities(struct acpi_softc *);
-
-static int     acpi_print(void *aux, const char *);
-
-static int     sysctl_hw_acpi_fixedstats(SYSCTLFN_ARGS);
-static int     sysctl_hw_acpi_sleepstate(SYSCTLFN_ARGS);
-static int     sysctl_hw_acpi_sleepstates(SYSCTLFN_ARGS);
-
-extern struct cfdriver acpi_cd;
-
-CFATTACH_DECL2_NEW(acpi, sizeof(struct acpi_softc),
-    acpi_match, acpi_attach, acpi_detach, NULL, acpi_rescan, acpi_childdet);
-
 /*
  * This is a flag we set when the ACPI subsystem is active.  Machine
  * dependent code may wish to skip other steps (such as attaching
@@ -177,13 +151,30 @@
        NULL
 };
 
-/*
- * Prototypes.
- */
+static int             acpi_match(device_t, cfdata_t, void *);
+static int             acpi_submatch(device_t, cfdata_t, const int *, void *);
+static void            acpi_attach(device_t, device_t, void *);
+static int             acpi_detach(device_t, int);
+static void            acpi_childdet(device_t, device_t);
+static bool            acpi_suspend(device_t, const pmf_qual_t *);
+static bool            acpi_resume(device_t, const pmf_qual_t *);
+
 static void            acpi_build_tree(struct acpi_softc *);
 static ACPI_STATUS     acpi_make_devnode(ACPI_HANDLE, uint32_t,
                                          void *, void **);
 
+#ifdef ACPI_ACTIVATE_DEV
+static void            acpi_activate_device(ACPI_HANDLE, ACPI_DEVICE_INFO **);
+static ACPI_STATUS     acpi_allocate_resources(ACPI_HANDLE);
+#endif
+
+static int             acpi_rescan(device_t, const char *, const int *);
+static void            acpi_rescan1(struct acpi_softc *,
+                                    const char *, const int *);
+static void            acpi_rescan_nodes(struct acpi_softc *);
+static void            acpi_rescan_capabilities(struct acpi_softc *);
+static int             acpi_print(void *aux, const char *);
+
 static void            acpi_register_fixed_button(struct acpi_softc *, int);
 static void            acpi_deregister_fixed_button(struct acpi_softc *, int);
 static uint32_t                acpi_fixed_button_handler(void *);
@@ -191,36 +182,35 @@
 
 static void            acpi_sleep_init(struct acpi_softc *);
 
+static int             sysctl_hw_acpi_fixedstats(SYSCTLFN_ARGS);
+static int             sysctl_hw_acpi_sleepstate(SYSCTLFN_ARGS);
+static int             sysctl_hw_acpi_sleepstates(SYSCTLFN_ARGS);
+
 static ACPI_TABLE_HEADER *acpi_map_rsdt(void);
 static void            acpi_unmap_rsdt(ACPI_TABLE_HEADER *);
 
-static bool            acpi_suspend(device_t, const pmf_qual_t *);
-static bool            acpi_resume(device_t, const pmf_qual_t *);
+extern struct cfdriver acpi_cd;
 
-#ifdef ACPI_ACTIVATE_DEV
-static void            acpi_activate_device(ACPI_HANDLE, ACPI_DEVICE_INFO **);
-static ACPI_STATUS     acpi_allocate_resources(ACPI_HANDLE);
-#endif
+CFATTACH_DECL2_NEW(acpi, sizeof(struct acpi_softc),
+    acpi_match, acpi_attach, acpi_detach, NULL, acpi_rescan, acpi_childdet);
 
 /*
- * acpi_probe:
+ * Probe for ACPI support.
  *
- *     Probe for ACPI support.  This is called by the
- *     machine-dependent ACPI front-end.  All of the
- *     actual work is done by ACPICA.
- *
- *     NOTE: This is not an autoconfiguration interface function.
+ * This is called by the machine-dependent ACPI front-end.
+ * Note: this is not an autoconfiguration interface function.
  */
 int
 acpi_probe(void)
 {
-       static int beenhere;
        ACPI_TABLE_HEADER *rsdt;
        ACPI_STATUS rv;
+       static int once;
 
-       if (beenhere != 0)
-               panic("acpi_probe: ACPI has already been probed");
-       beenhere = 1;
+       if (once != 0)
+               panic("%s: already probed", __func__);
+
+       once = 1;
 
        mutex_init(&acpi_interrupt_list_mtx, MUTEX_DEFAULT, IPL_NONE);
 
@@ -297,7 +287,9 @@
        acpi_unmap_rsdt(rsdt);
 
 #if notyet
-       /* Install the default address space handlers. */
+       /*
+        * Install the default address space handlers.
+        */
        rv = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT,
            ACPI_ADR_SPACE_SYSTEM_MEMORY, ACPI_DEFAULT_HANDLER, NULL, NULL);
        if (ACPI_FAILURE(rv)) {
@@ -334,7 +326,21 @@
        /*
         * Looks like we have ACPI!
         */
+       return 1;
+}
 
+int
+acpi_check(device_t parent, const char *ifattr)
+{
+       return (config_search_ia(acpi_submatch, parent, ifattr, NULL) != NULL);
+}
+
+static int
+acpi_match(device_t parent, cfdata_t match, void *aux)
+{
+       /*
+        * XXX: Nada; MD code has called acpi_probe().
+        */
        return 1;
 }
 
@@ -344,82 +350,10 @@
        struct cfattach *ca;
 
        ca = config_cfattach_lookup(cf->cf_name, cf->cf_atname);
+
        return (ca == &acpi_ca);
 }
 
-int
-acpi_check(device_t parent, const char *ifattr)
-{
-       return (config_search_ia(acpi_submatch, parent, ifattr, NULL) != NULL);
-}
-
-ACPI_PHYSICAL_ADDRESS
-acpi_OsGetRootPointer(void)
-{
-       ACPI_PHYSICAL_ADDRESS PhysicalAddress;
-
-       /*
-        * IA-32: Use AcpiFindRootPointer() to locate the RSDP.
-        *
-        * IA-64: Use the EFI.
-        *
-        * We let MD code handle this since there are multiple
-        * ways to do it.
-        */
-
-       PhysicalAddress = acpi_md_OsGetRootPointer();
-
-       if (acpi_root_pointer == 0)
-               acpi_root_pointer = PhysicalAddress;
-
-       return PhysicalAddress;
-}
-
-/*
- * acpi_match:
- *
- *     Autoconfiguration `match' routine.
- */
-static int
-acpi_match(device_t parent, cfdata_t match, void *aux)
-{
-       /*
-        * XXX Check other locators?  Hard to know -- machine
-        * dependent code has already checked for the presence
-        * of ACPI by calling acpi_probe(), so I suppose we
-        * don't really have to do anything else.
-        */
-       return 1;
-}
-
-/* Remove references to child devices.
- *
- * XXX Need to reclaim any resources?
- */
-static void
-acpi_childdet(device_t self, device_t child)
-{
-       struct acpi_softc *sc = device_private(self);
-       struct acpi_devnode *ad;
-
-       if (sc->sc_apmbus == child)
-               sc->sc_apmbus = NULL;
-
-       SIMPLEQ_FOREACH(ad, &sc->sc_devnodes, ad_list) {
-
-               if (ad->ad_device == child)
-                       ad->ad_device = NULL;
-       }
-}
-
-/*
- * acpi_attach:
- *
- *     Autoconfiguration `attach' routine.  Finish initializing
- *     ACPICA (some initialization was done in acpi_probe(),
- *     which was required to check for the presence of ACPI),
- *     and enable the ACPI subsystem.
- */
 static void
 acpi_attach(device_t parent, device_t self, void *aux)
 {
@@ -625,17 +559,40 @@
        return 0;
 }
 
+/*
+ * XXX: Need to reclaim any resources? Yes.
+ */
+static void
+acpi_childdet(device_t self, device_t child)
+{
+       struct acpi_softc *sc = device_private(self);
+       struct acpi_devnode *ad;
+
+       if (sc->sc_apmbus == child)
+               sc->sc_apmbus = NULL;
+
+       SIMPLEQ_FOREACH(ad, &sc->sc_devnodes, ad_list) {
+
+               if (ad->ad_device == child)
+                       ad->ad_device = NULL;
+       }
+}
+
 static bool
 acpi_suspend(device_t dv, const pmf_qual_t *qual)
 {
+
        acpi_suspended = 1;
+
        return true;
 }
 
 static bool
 acpi_resume(device_t dv, const pmf_qual_t *qual)



Home | Main Index | Thread Index | Old Index