| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: viac7temp.c,v 1.8 2014/08/10 16:44:34 tls Exp $ */ | | 1 | /* $NetBSD: viac7temp.c,v 1.8.32.1 2024/04/18 16:40:17 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2009 Jared D. McNeill <jmcneill@invisible.ca> | | 4 | * Copyright (c) 2009 Jared D. McNeill <jmcneill@invisible.ca> |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -17,31 +17,32 @@ | | | @@ -17,31 +17,32 @@ |
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 | * POSSIBILITY OF SUCH DAMAGE. | | 26 | * POSSIBILITY OF SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __KERNEL_RCSID(0, "$NetBSD: viac7temp.c,v 1.8 2014/08/10 16:44:34 tls Exp $"); | | 30 | __KERNEL_RCSID(0, "$NetBSD: viac7temp.c,v 1.8.32.1 2024/04/18 16:40:17 martin Exp $"); |
31 | | | 31 | |
32 | #include <sys/param.h> | | 32 | #include <sys/param.h> |
33 | #include <sys/device.h> | | 33 | #include <sys/device.h> |
34 | #include <sys/kmem.h> | | 34 | #include <sys/kmem.h> |
| | | 35 | #include <sys/module.h> |
35 | #include <sys/xcall.h> | | 36 | #include <sys/xcall.h> |
36 | | | 37 | |
37 | #include <dev/sysmon/sysmonvar.h> | | 38 | #include <dev/sysmon/sysmonvar.h> |
38 | | | 39 | |
39 | #include <machine/cpuvar.h> | | 40 | #include <machine/cpuvar.h> |
40 | #include <machine/cpufunc.h> | | 41 | #include <machine/cpufunc.h> |
41 | #include <machine/cputypes.h> | | 42 | #include <machine/cputypes.h> |
42 | #include <machine/specialreg.h> | | 43 | #include <machine/specialreg.h> |
43 | | | 44 | |
44 | struct viac7temp_softc { | | 45 | struct viac7temp_softc { |
45 | device_t sc_dev; | | 46 | device_t sc_dev; |
46 | struct cpu_info *sc_ci; | | 47 | struct cpu_info *sc_ci; |
47 | struct sysmon_envsys *sc_sme; | | 48 | struct sysmon_envsys *sc_sme; |
| @@ -152,13 +153,42 @@ viac7temp_refresh(struct sysmon_envsys * | | | @@ -152,13 +153,42 @@ viac7temp_refresh(struct sysmon_envsys * |
152 | static void | | 153 | static void |
153 | viac7temp_refresh_xcall(void *arg0, void *arg1) | | 154 | viac7temp_refresh_xcall(void *arg0, void *arg1) |
154 | { | | 155 | { |
155 | envsys_data_t *edata = arg1; | | 156 | envsys_data_t *edata = arg1; |
156 | uint32_t descs[4]; | | 157 | uint32_t descs[4]; |
157 | | | 158 | |
158 | x86_cpuid(0xc0000002, descs); | | 159 | x86_cpuid(0xc0000002, descs); |
159 | | | 160 | |
160 | edata->value_cur = descs[0] >> 8; | | 161 | edata->value_cur = descs[0] >> 8; |
161 | edata->value_cur *= 1000000; | | 162 | edata->value_cur *= 1000000; |
162 | edata->value_cur += 273150000; | | 163 | edata->value_cur += 273150000; |
163 | edata->state = ENVSYS_SVALID; | | 164 | edata->state = ENVSYS_SVALID; |
164 | } | | 165 | } |
| | | 166 | |
| | | 167 | MODULE(MODULE_CLASS_DRIVER, viac7temp, NULL); |
| | | 168 | |
| | | 169 | #ifdef _MODULE |
| | | 170 | #include "ioconf.c" |
| | | 171 | #endif |
| | | 172 | |
| | | 173 | static int |
| | | 174 | viac7temp_modcmd(modcmd_t cmd, void *arg __unused) |
| | | 175 | { |
| | | 176 | int error = 0; |
| | | 177 | |
| | | 178 | switch (cmd) { |
| | | 179 | case MODULE_CMD_INIT: |
| | | 180 | #ifdef _MODULE |
| | | 181 | error = config_init_component(cfdriver_ioconf_viac7temp, |
| | | 182 | cfattach_ioconf_viac7temp, cfdata_ioconf_viac7temp); |
| | | 183 | #endif |
| | | 184 | return error; |
| | | 185 | case MODULE_CMD_FINI: |
| | | 186 | #ifdef _MODULE |
| | | 187 | error = config_fini_component(cfdriver_ioconf_viac7temp, |
| | | 188 | cfattach_ioconf_viac7temp, cfdata_ioconf_viac7temp); |
| | | 189 | #endif |
| | | 190 | return error; |
| | | 191 | default: |
| | | 192 | return ENOTTY; |
| | | 193 | } |
| | | 194 | } |