Source-Changes-HG archive

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

[src/trunk]: src/sys Provide MD wrappers for match and attach.



details:   https://anonhg.NetBSD.org/src/rev/f77fee8c1993
branches:  trunk
changeset: 762769:f77fee8c1993
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Sun Feb 27 18:32:53 2011 +0000

description:
Provide MD wrappers for match and attach.

diffstat:

 sys/arch/x86/acpi/acpi_cpu_md.c |  24 +++++++++++-
 sys/dev/acpi/acpi_cpu.c         |  22 +++++++----
 sys/dev/acpi/acpi_cpu.h         |  79 +++++++++++++++++++++-------------------
 3 files changed, 77 insertions(+), 48 deletions(-)

diffs (208 lines):

diff -r 374179f176a9 -r f77fee8c1993 sys/arch/x86/acpi/acpi_cpu_md.c
--- a/sys/arch/x86/acpi/acpi_cpu_md.c   Sun Feb 27 18:10:25 2011 +0000
+++ b/sys/arch/x86/acpi/acpi_cpu_md.c   Sun Feb 27 18:32:53 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_md.c,v 1.47 2011/02/27 17:27:28 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_md.c,v 1.48 2011/02/27 18:32:54 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -27,10 +27,11 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.47 2011/02/27 17:27:28 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.48 2011/02/27 18:32:54 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
+#include <sys/device.h>
 #include <sys/kcore.h>
 #include <sys/sysctl.h>
 #include <sys/xcall.h>
@@ -118,6 +119,25 @@
 static bool acpicpu_pstate_status = false;
 static struct sysctllog *acpicpu_log = NULL;
 
+struct cpu_info *
+acpicpu_md_match(device_t parent, cfdata_t match, void *aux)
+{
+       struct cpufeature_attach_args *cfaa = aux;
+
+       if (strcmp(cfaa->name, "frequency") != 0)
+               return NULL;
+
+       return cfaa->ci;
+}
+
+struct cpu_info *
+acpicpu_md_attach(device_t parent, device_t self, void *aux)
+{
+       struct cpufeature_attach_args *cfaa = aux;
+
+       return cfaa->ci;
+}
+
 uint32_t
 acpicpu_md_cap(void)
 {
diff -r 374179f176a9 -r f77fee8c1993 sys/dev/acpi/acpi_cpu.c
--- a/sys/dev/acpi/acpi_cpu.c   Sun Feb 27 18:10:25 2011 +0000
+++ b/sys/dev/acpi/acpi_cpu.c   Sun Feb 27 18:32:53 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu.c,v 1.30 2011/02/27 17:10:33 jruoho Exp $ */
+/* $NetBSD: acpi_cpu.c,v 1.31 2011/02/27 18:32:53 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.30 2011/02/27 17:10:33 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.31 2011/02/27 18:32:53 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -85,26 +85,32 @@
 static int
 acpicpu_match(device_t parent, cfdata_t match, void *aux)
 {
-       struct cpufeature_attach_args *cfaa = aux;
+       struct cpu_info *ci;
 
        if (acpi_softc == NULL)
                return 0;
 
-       if (strcmp(cfaa->name, "frequency") != 0)
+       ci = acpicpu_md_match(parent, match, aux);
+
+       if (ci == NULL)
                return 0;
 
-       return acpicpu_find(cfaa->ci, NULL);
+       return acpicpu_find(ci, NULL);
 }
 
 static void
 acpicpu_attach(device_t parent, device_t self, void *aux)
 {
        struct acpicpu_softc *sc = device_private(self);
-       struct cpufeature_attach_args *cfaa = aux;
-       struct cpu_info *ci = cfaa->ci;
+       struct cpu_info *ci;
        cpuid_t id;
        int rv;
 
+       ci = acpicpu_md_attach(parent, self, aux);
+
+       if (ci == NULL)
+               return;
+
        sc->sc_ci = ci;
        sc->sc_dev = self;
        sc->sc_cold = true;
@@ -409,7 +415,7 @@
        if (ptr != NULL)
                *ptr = ad;
 
-       return 10;              /* Beat est(4) and powernow(4). */
+       return 10;
 }
 
 static uint32_t
diff -r 374179f176a9 -r f77fee8c1993 sys/dev/acpi/acpi_cpu.h
--- a/sys/dev/acpi/acpi_cpu.h   Sun Feb 27 18:10:25 2011 +0000
+++ b/sys/dev/acpi/acpi_cpu.h   Sun Feb 27 18:32:53 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu.h,v 1.33 2011/02/25 20:59:37 jruoho Exp $ */
+/* $NetBSD: acpi_cpu.h,v 1.34 2011/02/27 18:32:53 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -230,45 +230,48 @@
        bool                     sc_cold;
 };
 
-void           acpicpu_cstate_attach(device_t);
-int            acpicpu_cstate_detach(device_t);
-void           acpicpu_cstate_start(device_t);
-bool           acpicpu_cstate_suspend(device_t);
-bool           acpicpu_cstate_resume(device_t);
-void           acpicpu_cstate_callback(void *);
-void           acpicpu_cstate_idle(void);
+void            acpicpu_cstate_attach(device_t);
+int             acpicpu_cstate_detach(device_t);
+void            acpicpu_cstate_start(device_t);
+bool            acpicpu_cstate_suspend(device_t);
+bool            acpicpu_cstate_resume(device_t);
+void            acpicpu_cstate_callback(void *);
+void            acpicpu_cstate_idle(void);
 
-void           acpicpu_pstate_attach(device_t);
-int            acpicpu_pstate_detach(device_t);
-void           acpicpu_pstate_start(device_t);
-bool           acpicpu_pstate_suspend(device_t);
-bool           acpicpu_pstate_resume(device_t);
-void           acpicpu_pstate_callback(void *);
-int            acpicpu_pstate_get(struct acpicpu_softc *, uint32_t *);
-int            acpicpu_pstate_set(struct acpicpu_softc *, uint32_t);
+void            acpicpu_pstate_attach(device_t);
+int             acpicpu_pstate_detach(device_t);
+void            acpicpu_pstate_start(device_t);
+bool            acpicpu_pstate_suspend(device_t);
+bool            acpicpu_pstate_resume(device_t);
+void            acpicpu_pstate_callback(void *);
+int             acpicpu_pstate_get(struct acpicpu_softc *, uint32_t *);
+int             acpicpu_pstate_set(struct acpicpu_softc *, uint32_t);
 
-void           acpicpu_tstate_attach(device_t);
-int            acpicpu_tstate_detach(device_t);
-void           acpicpu_tstate_start(device_t);
-bool           acpicpu_tstate_suspend(device_t);
-bool           acpicpu_tstate_resume(device_t);
-void           acpicpu_tstate_callback(void *);
-int            acpicpu_tstate_get(struct acpicpu_softc *, uint32_t *);
-int            acpicpu_tstate_set(struct acpicpu_softc *, uint32_t);
+void            acpicpu_tstate_attach(device_t);
+int             acpicpu_tstate_detach(device_t);
+void            acpicpu_tstate_start(device_t);
+bool            acpicpu_tstate_suspend(device_t);
+bool            acpicpu_tstate_resume(device_t);
+void            acpicpu_tstate_callback(void *);
+int             acpicpu_tstate_get(struct acpicpu_softc *, uint32_t *);
+int             acpicpu_tstate_set(struct acpicpu_softc *, uint32_t);
+
+struct cpu_info *acpicpu_md_match(device_t, cfdata_t, void *);
+struct cpu_info *acpicpu_md_attach(device_t, device_t, void *);
 
-uint32_t       acpicpu_md_cap(void);
-uint32_t       acpicpu_md_flags(void);
-void           acpicpu_md_quirk_c1e(void);
-int            acpicpu_md_cstate_start(struct acpicpu_softc *);
-int            acpicpu_md_cstate_stop(void);
-void           acpicpu_md_cstate_enter(int, int);
-int            acpicpu_md_pstate_start(struct acpicpu_softc *);
-int            acpicpu_md_pstate_stop(void);
-int            acpicpu_md_pstate_pss(struct acpicpu_softc *);
-uint8_t                acpicpu_md_pstate_percent(struct acpicpu_softc *);
-int            acpicpu_md_pstate_get(struct acpicpu_softc *, uint32_t *);
-int            acpicpu_md_pstate_set(struct acpicpu_pstate *);
-int            acpicpu_md_tstate_get(struct acpicpu_softc *, uint32_t *);
-int            acpicpu_md_tstate_set(struct acpicpu_tstate *);
+uint32_t        acpicpu_md_cap(void);
+uint32_t        acpicpu_md_flags(void);
+void            acpicpu_md_quirk_c1e(void);
+int             acpicpu_md_cstate_start(struct acpicpu_softc *);
+int             acpicpu_md_cstate_stop(void);
+void            acpicpu_md_cstate_enter(int, int);
+int             acpicpu_md_pstate_start(struct acpicpu_softc *);
+int             acpicpu_md_pstate_stop(void);
+int             acpicpu_md_pstate_pss(struct acpicpu_softc *);
+uint8_t                 acpicpu_md_pstate_percent(struct acpicpu_softc *);
+int             acpicpu_md_pstate_get(struct acpicpu_softc *, uint32_t *);
+int             acpicpu_md_pstate_set(struct acpicpu_pstate *);
+int             acpicpu_md_tstate_get(struct acpicpu_softc *, uint32_t *);
+int             acpicpu_md_tstate_set(struct acpicpu_tstate *);
 
 #endif /* !_SYS_DEV_ACPI_ACPI_CPU_H */



Home | Main Index | Thread Index | Old Index