Tue Apr 21 07:08:12 2020 UTC ()
 Print "Hz".


(msaitoh)
diff -r1.1 -r1.2 src/sys/arch/x86/x86/identcpu_subr.c

cvs diff -r1.1 -r1.2 src/sys/arch/x86/x86/identcpu_subr.c (expand / switch to unified diff)

--- src/sys/arch/x86/x86/identcpu_subr.c 2020/04/21 02:56:37 1.1
+++ src/sys/arch/x86/x86/identcpu_subr.c 2020/04/21 07:08:12 1.2
@@ -23,27 +23,27 @@ @@ -23,27 +23,27 @@
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE. 27 * POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30/* 30/*
31 * Subroutines for CPU. 31 * Subroutines for CPU.
32 * This file is shared between kernel and userland. 32 * This file is shared between kernel and userland.
33 * See src/usr.sbin/cpuctl/{Makefile, arch/i386.c}). 33 * See src/usr.sbin/cpuctl/{Makefile, arch/i386.c}).
34 */ 34 */
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36__KERNEL_RCSID(0, "$NetBSD: identcpu_subr.c,v 1.1 2020/04/21 02:56:37 msaitoh Exp $"); 36__KERNEL_RCSID(0, "$NetBSD: identcpu_subr.c,v 1.2 2020/04/21 07:08:12 msaitoh Exp $");
37 37
38#ifdef _KERNEL_OPT 38#ifdef _KERNEL_OPT
39#include "lapic.h" 39#include "lapic.h"
40#endif 40#endif
41 41
42#include <sys/param.h> 42#include <sys/param.h>
43 43
44#ifdef _KERNEL 44#ifdef _KERNEL
45#include <sys/systm.h> 45#include <sys/systm.h>
46#include <x86/cpuvar.h> 46#include <x86/cpuvar.h>
47#include <x86/apicvar.h> 47#include <x86/apicvar.h>
48#include <machine/cpufunc.h> 48#include <machine/cpufunc.h>
49#include <machine/cputypes.h> 49#include <machine/cputypes.h>
@@ -100,47 +100,47 @@ cpu_tsc_freq_cpuid(struct cpu_info *ci) @@ -100,47 +100,47 @@ cpu_tsc_freq_cpuid(struct cpu_info *ci)
100 break; 100 break;
101 case 0x5c: /* Atom Goldmont */ 101 case 0x5c: /* Atom Goldmont */
102 khz = 19200; /* 19.2 MHz */ 102 khz = 19200; /* 19.2 MHz */
103 break; 103 break;
104 default: /* Unknown */ 104 default: /* Unknown */
105 break; 105 break;
106 } 106 }
107 } 107 }
108 freq = khz * 1000 * numerator / denominator; 108 freq = khz * 1000 * numerator / denominator;
109 if (ci->ci_max_cpuid >= 0x16) { 109 if (ci->ci_max_cpuid >= 0x16) {
110 x86_cpuid(0x16, descs); 110 x86_cpuid(0x16, descs);
111 if (descs[0] != 0) { 111 if (descs[0] != 0) {
112 aprint_verbose_dev(ci->ci_dev, 112 aprint_verbose_dev(ci->ci_dev,
113 "CPU base freq %" PRIu64 "\n", 113 "CPU base freq %" PRIu64 " Hz\n",
114 (uint64_t)descs[0] * 1000000); 114 (uint64_t)descs[0] * 1000000);
115 115
116 /* 116 /*
117 * If we couldn't get frequency from 117 * If we couldn't get frequency from
118 * CPUID 0x15, use CPUID 0x16 EAX. 118 * CPUID 0x15, use CPUID 0x16 EAX.
119 */ 119 */
120 if (freq == 0) { 120 if (freq == 0) {
121 khz = (uint64_t)descs[0] * 1000 121 khz = (uint64_t)descs[0] * 1000
122 * denominator / numerator; 122 * denominator / numerator;
123 freq = (uint64_t)descs[0] * 1000000; 123 freq = (uint64_t)descs[0] * 1000000;
124 } 124 }
125 } 125 }
126 if (descs[1] != 0) { 126 if (descs[1] != 0) {
127 aprint_verbose_dev(ci->ci_dev, 127 aprint_verbose_dev(ci->ci_dev,
128 "CPU max freq %" PRIu64 "\n", 128 "CPU max freq %" PRIu64 " Hz\n",
129 (uint64_t)descs[1] * 1000000); 129 (uint64_t)descs[1] * 1000000);
130 } 130 }
131 } 131 }
132#if defined(_KERNEL) && NLAPIC > 0 132#if defined(_KERNEL) && NLAPIC > 0
133 if ((khz != 0) && (lapic_per_second == 0)) { 133 if ((khz != 0) && (lapic_per_second == 0)) {
134 lapic_per_second = khz * 1000; 134 lapic_per_second = khz * 1000;
135 aprint_debug_dev(ci->ci_dev, 135 aprint_debug_dev(ci->ci_dev,
136 "lapic_per_second set to %" PRIu32 "\n", 136 "lapic_per_second set to %" PRIu32 "\n",
137 lapic_per_second); 137 lapic_per_second);
138 } 138 }
139#endif 139#endif
140 } 140 }
141 if (freq != 0) 141 if (freq != 0)
142 aprint_verbose_dev(ci->ci_dev, "TSC freq %" PRIu64 "\n", 142 aprint_verbose_dev(ci->ci_dev, "TSC freq %" PRIu64 " Hz\n",
143 freq); 143 freq);
144 144
145 return freq; 145 return freq;
146} 146}