Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86 Add sysctl-glue for interaction with the acpicp...



details:   https://anonhg.NetBSD.org/src/rev/5d7161eb41d6
branches:  trunk
changeset: 757206:5d7161eb41d6
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Thu Aug 19 04:12:45 2010 +0000

description:
Add sysctl-glue for interaction with the acpicpu(4).

diffstat:

 sys/arch/x86/include/powernow.h |   3 +-
 sys/arch/x86/x86/powernow_k8.c  |  48 +++++++++++++++++++++++-----------------
 2 files changed, 29 insertions(+), 22 deletions(-)

diffs (171 lines):

diff -r 92acca27a467 -r 5d7161eb41d6 sys/arch/x86/include/powernow.h
--- a/sys/arch/x86/include/powernow.h   Thu Aug 19 02:37:04 2010 +0000
+++ b/sys/arch/x86/include/powernow.h   Thu Aug 19 04:12:45 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: powernow.h,v 1.9 2007/03/24 15:35:15 xtraeme Exp $     */
+/*     $NetBSD: powernow.h,v 1.10 2010/08/19 04:12:45 jruoho Exp $     */
 
 /*-
  * Copyright (c) 2004 Martin Végiard.
@@ -178,6 +178,7 @@
 
 /* x86/x86/powernow_k8.c */
 void k8_powernow_init(void);
+void k8_powernow_init_main(int);
 void k8_powernow_destroy(void);
 
 #endif
diff -r 92acca27a467 -r 5d7161eb41d6 sys/arch/x86/x86/powernow_k8.c
--- a/sys/arch/x86/x86/powernow_k8.c    Thu Aug 19 02:37:04 2010 +0000
+++ b/sys/arch/x86/x86/powernow_k8.c    Thu Aug 19 04:12:45 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: powernow_k8.c,v 1.26 2009/10/05 23:59:31 rmind Exp $ */
+/*     $NetBSD: powernow_k8.c,v 1.27 2010/08/19 04:12:45 jruoho Exp $ */
 /*     $OpenBSD: powernow-k8.c,v 1.8 2006/06/16 05:58:50 gwk Exp $ */
 
 /*-
@@ -59,7 +59,7 @@
 /* AMD POWERNOW K8 driver */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: powernow_k8.c,v 1.26 2009/10/05 23:59:31 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: powernow_k8.c,v 1.27 2010/08/19 04:12:45 jruoho Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -70,6 +70,7 @@
 #include <sys/xcall.h>
 
 #include <x86/cpu_msr.h>
+#include <x86/cpuvar.h>
 #include <x86/powernow.h>
 
 #include <dev/isa/isareg.h>
@@ -79,13 +80,6 @@
 #include <machine/cpufunc.h>
 #include <machine/bus.h>
 
-#ifdef _MODULE
-static struct sysctllog *sysctllog;
-#define SYSCTLLOG      &sysctllog
-#else
-#define SYSCTLLOG      NULL
-#endif
-
 static struct powernow_cpu_state *k8pnow_current_state;
 static unsigned int cur_freq;
 static int powernow_node_target, powernow_node_current;
@@ -98,7 +92,6 @@
     unsigned int);
 static int k8_powernow_setperf(unsigned int);
 static int k8_powernow_init_once(void);
-static void k8_powernow_init_main(void);
 
 static uint64_t
 k8pnow_wr_fidvid(u_int fid, uint64_t vid, uint64_t ctrl)
@@ -341,7 +334,7 @@
 static int
 k8_powernow_init_once(void)
 {
-       k8_powernow_init_main();
+       k8_powernow_init_main(0);
        return 0;
 }
 
@@ -357,8 +350,8 @@
        }
 }
 
-static void
-k8_powernow_init_main(void)
+void
+k8_powernow_init_main(int vendor)
 {
        uint64_t status;
        uint32_t maxfid, maxvid, i;
@@ -425,29 +418,34 @@
                goto err;
        }
 
+       if (cpu_freq_sysctllog != NULL)
+               goto err;
+
+       cpu_freq_init = k8_powernow_init_main;
+
        /* Create sysctl machdep.powernow.frequency. */
-       if (sysctl_createv(SYSCTLLOG, 0, NULL, &node,
+       if (sysctl_createv(&cpu_freq_sysctllog, 0, NULL, &node,
            CTLFLAG_PERMANENT,
            CTLTYPE_NODE, "machdep", NULL,
            NULL, 0, NULL, 0,
            CTL_MACHDEP, CTL_EOL) != 0)
                goto err;
 
-       if (sysctl_createv(SYSCTLLOG, 0, &node, &pnownode,
+       if (sysctl_createv(&cpu_freq_sysctllog, 0, &node, &pnownode,
            0,
            CTLTYPE_NODE, "powernow", NULL,
            NULL, 0, NULL, 0,
            CTL_CREATE, CTL_EOL) != 0)
                goto err;
 
-       if (sysctl_createv(SYSCTLLOG, 0, &pnownode, &freqnode,
+       if (sysctl_createv(&cpu_freq_sysctllog, 0, &pnownode, &freqnode,
            0,
            CTLTYPE_NODE, "frequency", NULL,
            NULL, 0, NULL, 0,
            CTL_CREATE, CTL_EOL) != 0)
                goto err;
 
-       if (sysctl_createv(SYSCTLLOG, 0, &freqnode, &node,
+       if (sysctl_createv(&cpu_freq_sysctllog, 0, &freqnode, &node,
            CTLFLAG_READWRITE,
            CTLTYPE_INT, "target", NULL,
            k8pnow_sysctl_helper, 0, NULL, 0,
@@ -456,7 +454,7 @@
 
        powernow_node_target = node->sysctl_num;
 
-       if (sysctl_createv(SYSCTLLOG, 0, &freqnode, &node,
+       if (sysctl_createv(&cpu_freq_sysctllog, 0, &freqnode, &node,
            0,
            CTLTYPE_INT, "current", NULL,
            k8pnow_sysctl_helper, 0, NULL, 0,
@@ -465,7 +463,7 @@
 
        powernow_node_current = node->sysctl_num;
 
-       if (sysctl_createv(SYSCTLLOG, 0, &freqnode, &node,
+       if (sysctl_createv(&cpu_freq_sysctllog, 0, &freqnode, &node,
            0,
            CTLTYPE_STRING, "available", NULL,
            NULL, 0, freq_names, freq_names_len,
@@ -481,18 +479,26 @@
 
        return;
 
-  err:
+err:
        if (cstate)
                free(cstate, M_DEVBUF);
+
        if (freq_names)
                free(freq_names, M_SYSCTLDATA);
+
+       if (cpu_freq_sysctllog) {
+               sysctl_teardown(&cpu_freq_sysctllog);
+               cpu_freq_sysctllog = NULL;
+       }
+
+       cpu_freq_init = NULL;
 }
 
 void
 k8_powernow_destroy(void)
 {
 #ifdef _MODULE
-       sysctl_teardown(SYSCTLLOG);
+       sysctl_teardown(&cpu_freq_sysctllog);
 
        if (k8pnow_current_state)
                free(k8pnow_current_state, M_DEVBUF);



Home | Main Index | Thread Index | Old Index