Wed Mar 7 23:26:01 2012 UTC ()
Pull up following revision(s) (requested by sborrill in ticket #79):
	usr.sbin/cpuctl/arch/i386.c: revision 1.29
Print CPU stepping level


(riz)
diff -r1.27.2.1 -r1.27.2.2 src/usr.sbin/cpuctl/arch/i386.c

cvs diff -r1.27.2.1 -r1.27.2.2 src/usr.sbin/cpuctl/arch/i386.c (switch to unified diff)

--- src/usr.sbin/cpuctl/arch/i386.c 2012/03/05 19:12:06 1.27.2.1
+++ src/usr.sbin/cpuctl/arch/i386.c 2012/03/07 23:26:01 1.27.2.2
@@ -1,1999 +1,2000 @@ @@ -1,1999 +1,2000 @@
1/* $NetBSD: i386.c,v 1.27.2.1 2012/03/05 19:12:06 sborrill Exp $ */ 1/* $NetBSD: i386.c,v 1.27.2.2 2012/03/07 23:26:01 riz Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frank van der Linden, and by Jason R. Thorpe. 8 * by Frank van der Linden, and by Jason R. Thorpe.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32/*- 32/*-
33 * Copyright (c)2008 YAMAMOTO Takashi, 33 * Copyright (c)2008 YAMAMOTO Takashi,
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions 37 * modification, are permitted provided that the following conditions
38 * are met: 38 * are met:
39 * 1. Redistributions of source code must retain the above copyright 39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer. 40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright 41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the 42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution. 43 * documentation and/or other materials provided with the distribution.
44 * 44 *
45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 48 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * SUCH DAMAGE. 55 * SUCH DAMAGE.
56 */ 56 */
57 57
58#include <sys/cdefs.h> 58#include <sys/cdefs.h>
59#ifndef lint 59#ifndef lint
60__RCSID("$NetBSD: i386.c,v 1.27.2.1 2012/03/05 19:12:06 sborrill Exp $"); 60__RCSID("$NetBSD: i386.c,v 1.27.2.2 2012/03/07 23:26:01 riz Exp $");
61#endif /* not lint */ 61#endif /* not lint */
62 62
63#include <sys/types.h> 63#include <sys/types.h>
64#include <sys/param.h> 64#include <sys/param.h>
65#include <sys/bitops.h> 65#include <sys/bitops.h>
66#include <sys/sysctl.h> 66#include <sys/sysctl.h>
67 67
68#include <string.h> 68#include <string.h>
69#include <stdio.h> 69#include <stdio.h>
70#include <stdlib.h> 70#include <stdlib.h>
71#include <err.h> 71#include <err.h>
72#include <assert.h> 72#include <assert.h>
73#include <math.h> 73#include <math.h>
74#include <util.h> 74#include <util.h>
75 75
76#include <machine/specialreg.h> 76#include <machine/specialreg.h>
77#include <machine/cpu.h> 77#include <machine/cpu.h>
78 78
79#include <x86/cpuvar.h> 79#include <x86/cpuvar.h>
80#include <x86/cputypes.h> 80#include <x86/cputypes.h>
81#include <x86/cacheinfo.h> 81#include <x86/cacheinfo.h>
82 82
83#include "../cpuctl.h" 83#include "../cpuctl.h"
84 84
85/* Size of buffer for printing humanized numbers */ 85/* Size of buffer for printing humanized numbers */
86#define HUMAN_BUFSIZE sizeof("999KB") 86#define HUMAN_BUFSIZE sizeof("999KB")
87 87
88#define x86_cpuid(a,b) x86_cpuid2((a),0,(b)) 88#define x86_cpuid(a,b) x86_cpuid2((a),0,(b))
89 89
90void x86_cpuid2(uint32_t, uint32_t, uint32_t *); 90void x86_cpuid2(uint32_t, uint32_t, uint32_t *);
91void x86_identify(void); 91void x86_identify(void);
92 92
93struct cpu_info { 93struct cpu_info {
94 const char *ci_dev; 94 const char *ci_dev;
95 int32_t ci_cpuid_level; 95 int32_t ci_cpuid_level;
96 uint32_t ci_signature; /* X86 cpuid type */ 96 uint32_t ci_signature; /* X86 cpuid type */
97 uint32_t ci_feat_val[5]; /* X86 CPUID feature bits 97 uint32_t ci_feat_val[5]; /* X86 CPUID feature bits
98 * [0] basic features %edx 98 * [0] basic features %edx
99 * [1] basic features %ecx 99 * [1] basic features %ecx
100 * [2] extended features %edx 100 * [2] extended features %edx
101 * [3] extended features %ecx 101 * [3] extended features %ecx
102 * [4] VIA padlock features 102 * [4] VIA padlock features
103 */ 103 */
104 uint32_t ci_cpu_class; /* CPU class */ 104 uint32_t ci_cpu_class; /* CPU class */
105 uint32_t ci_brand_id; /* Intel brand id */ 105 uint32_t ci_brand_id; /* Intel brand id */
106 uint32_t ci_vendor[4]; /* vendor string */ 106 uint32_t ci_vendor[4]; /* vendor string */
107 uint32_t ci_cpu_serial[3]; /* PIII serial number */ 107 uint32_t ci_cpu_serial[3]; /* PIII serial number */
108 uint64_t ci_tsc_freq; /* cpu cycles/second */ 108 uint64_t ci_tsc_freq; /* cpu cycles/second */
109 uint8_t ci_packageid; 109 uint8_t ci_packageid;
110 uint8_t ci_coreid; 110 uint8_t ci_coreid;
111 uint8_t ci_smtid; 111 uint8_t ci_smtid;
112 uint32_t ci_initapicid; 112 uint32_t ci_initapicid;
113 struct x86_cache_info ci_cinfo[CAI_COUNT]; 113 struct x86_cache_info ci_cinfo[CAI_COUNT];
114 void (*ci_info)(struct cpu_info *); 114 void (*ci_info)(struct cpu_info *);
115}; 115};
116 116
117struct cpu_nocpuid_nameclass { 117struct cpu_nocpuid_nameclass {
118 int cpu_vendor; 118 int cpu_vendor;
119 const char *cpu_vendorname; 119 const char *cpu_vendorname;
120 const char *cpu_name; 120 const char *cpu_name;
121 int cpu_class; 121 int cpu_class;
122 void (*cpu_setup)(struct cpu_info *); 122 void (*cpu_setup)(struct cpu_info *);
123 void (*cpu_cacheinfo)(struct cpu_info *); 123 void (*cpu_cacheinfo)(struct cpu_info *);
124 void (*cpu_info)(struct cpu_info *); 124 void (*cpu_info)(struct cpu_info *);
125}; 125};
126 126
127struct cpu_extend_nameclass { 127struct cpu_extend_nameclass {
128 int ext_model; 128 int ext_model;
129 const char *cpu_models[CPU_MAXMODEL+1]; 129 const char *cpu_models[CPU_MAXMODEL+1];
130}; 130};
131 131
132struct cpu_cpuid_nameclass { 132struct cpu_cpuid_nameclass {
133 const char *cpu_id; 133 const char *cpu_id;
134 int cpu_vendor; 134 int cpu_vendor;
135 const char *cpu_vendorname; 135 const char *cpu_vendorname;
136 struct cpu_cpuid_family { 136 struct cpu_cpuid_family {
137 int cpu_class; 137 int cpu_class;
138 const char *cpu_models[CPU_MAXMODEL+2]; 138 const char *cpu_models[CPU_MAXMODEL+2];
139 void (*cpu_setup)(struct cpu_info *); 139 void (*cpu_setup)(struct cpu_info *);
140 void (*cpu_probe)(struct cpu_info *); 140 void (*cpu_probe)(struct cpu_info *);
141 void (*cpu_info)(struct cpu_info *); 141 void (*cpu_info)(struct cpu_info *);
142 struct cpu_extend_nameclass *cpu_extended_names; 142 struct cpu_extend_nameclass *cpu_extended_names;
143 } cpu_family[CPU_MAXFAMILY - CPU_MINFAMILY + 1]; 143 } cpu_family[CPU_MAXFAMILY - CPU_MINFAMILY + 1];
144}; 144};
145 145
146static const struct x86_cache_info intel_cpuid_cache_info[] = INTEL_CACHE_INFO; 146static const struct x86_cache_info intel_cpuid_cache_info[] = INTEL_CACHE_INFO;
147 147
148/* 148/*
149 * Map Brand ID from cpuid instruction to brand name. 149 * Map Brand ID from cpuid instruction to brand name.
150 * Source: Intel Processor Identification and the CPUID Instruction, AP-485 150 * Source: Intel Processor Identification and the CPUID Instruction, AP-485
151 */ 151 */
152static const char * const i386_intel_brand[] = { 152static const char * const i386_intel_brand[] = {
153 "", /* Unsupported */ 153 "", /* Unsupported */
154 "Celeron", /* Intel (R) Celeron (TM) processor */ 154 "Celeron", /* Intel (R) Celeron (TM) processor */
155 "Pentium III", /* Intel (R) Pentium (R) III processor */ 155 "Pentium III", /* Intel (R) Pentium (R) III processor */
156 "Pentium III Xeon", /* Intel (R) Pentium (R) III Xeon (TM) processor */ 156 "Pentium III Xeon", /* Intel (R) Pentium (R) III Xeon (TM) processor */
157 "Pentium III", /* Intel (R) Pentium (R) III processor */ 157 "Pentium III", /* Intel (R) Pentium (R) III processor */
158 "", /* Reserved */ 158 "", /* Reserved */
159 "Mobile Pentium III", /* Mobile Intel (R) Pentium (R) III processor-M */ 159 "Mobile Pentium III", /* Mobile Intel (R) Pentium (R) III processor-M */
160 "Mobile Celeron", /* Mobile Intel (R) Celeron (R) processor */  160 "Mobile Celeron", /* Mobile Intel (R) Celeron (R) processor */
161 "Pentium 4", /* Intel (R) Pentium (R) 4 processor */ 161 "Pentium 4", /* Intel (R) Pentium (R) 4 processor */
162 "Pentium 4", /* Intel (R) Pentium (R) 4 processor */ 162 "Pentium 4", /* Intel (R) Pentium (R) 4 processor */
163 "Celeron", /* Intel (R) Celeron (TM) processor */ 163 "Celeron", /* Intel (R) Celeron (TM) processor */
164 "Xeon", /* Intel (R) Xeon (TM) processor */ 164 "Xeon", /* Intel (R) Xeon (TM) processor */
165 "Xeon MP", /* Intel (R) Xeon (TM) processor MP */ 165 "Xeon MP", /* Intel (R) Xeon (TM) processor MP */
166 "", /* Reserved */ 166 "", /* Reserved */
167 "Mobile Pentium 4", /* Mobile Intel (R) Pentium (R) 4 processor-M */ 167 "Mobile Pentium 4", /* Mobile Intel (R) Pentium (R) 4 processor-M */
168 "Mobile Celeron", /* Mobile Intel (R) Celeron (R) processor */ 168 "Mobile Celeron", /* Mobile Intel (R) Celeron (R) processor */
169}; 169};
170 170
171/* 171/*
172 * AMD processors don't have Brand IDs, so we need these names for probe. 172 * AMD processors don't have Brand IDs, so we need these names for probe.
173 */ 173 */
174static const char * const amd_brand[] = { 174static const char * const amd_brand[] = {
175 "", 175 "",
176 "Duron", /* AMD Duron(tm) */ 176 "Duron", /* AMD Duron(tm) */
177 "MP", /* AMD Athlon(tm) MP */ 177 "MP", /* AMD Athlon(tm) MP */
178 "XP", /* AMD Athlon(tm) XP */ 178 "XP", /* AMD Athlon(tm) XP */
179 "4" /* AMD Athlon(tm) 4 */ 179 "4" /* AMD Athlon(tm) 4 */
180}; 180};
181 181
182static int cpu_vendor; 182static int cpu_vendor;
183static char cpu_brand_string[49]; 183static char cpu_brand_string[49];
184static char amd_brand_name[48]; 184static char amd_brand_name[48];
185static int use_pae, largepagesize; 185static int use_pae, largepagesize;
186 186
187static void via_cpu_probe(struct cpu_info *); 187static void via_cpu_probe(struct cpu_info *);
188static void amd_family6_probe(struct cpu_info *); 188static void amd_family6_probe(struct cpu_info *);
189static void intel_family_new_probe(struct cpu_info *); 189static void intel_family_new_probe(struct cpu_info *);
190static const char *intel_family6_name(struct cpu_info *); 190static const char *intel_family6_name(struct cpu_info *);
191static const char *amd_amd64_name(struct cpu_info *); 191static const char *amd_amd64_name(struct cpu_info *);
192static void amd_family5_setup(struct cpu_info *); 192static void amd_family5_setup(struct cpu_info *);
193static void transmeta_cpu_info(struct cpu_info *); 193static void transmeta_cpu_info(struct cpu_info *);
194static const char *print_cache_config(struct cpu_info *, int, const char *, 194static const char *print_cache_config(struct cpu_info *, int, const char *,
195 const char *); 195 const char *);
196static const char *print_tlb_config(struct cpu_info *, int, const char *, 196static const char *print_tlb_config(struct cpu_info *, int, const char *,
197 const char *); 197 const char *);
198static void amd_cpu_cacheinfo(struct cpu_info *); 198static void amd_cpu_cacheinfo(struct cpu_info *);
199static void via_cpu_cacheinfo(struct cpu_info *); 199static void via_cpu_cacheinfo(struct cpu_info *);
200static void x86_print_cacheinfo(struct cpu_info *); 200static void x86_print_cacheinfo(struct cpu_info *);
201static const struct x86_cache_info *cache_info_lookup( 201static const struct x86_cache_info *cache_info_lookup(
202 const struct x86_cache_info *, uint8_t); 202 const struct x86_cache_info *, uint8_t);
203static void cyrix6x86_cpu_setup(struct cpu_info *); 203static void cyrix6x86_cpu_setup(struct cpu_info *);
204static void winchip_cpu_setup(struct cpu_info *); 204static void winchip_cpu_setup(struct cpu_info *);
205static void amd_family5_setup(struct cpu_info *); 205static void amd_family5_setup(struct cpu_info *);
206static void powernow_probe(struct cpu_info *); 206static void powernow_probe(struct cpu_info *);
207 207
208/* 208/*
209 * Info for CTL_HW 209 * Info for CTL_HW
210 */ 210 */
211static char cpu_model[120]; 211static char cpu_model[120];
212 212
213/* 213/*
214 * Note: these are just the ones that may not have a cpuid instruction. 214 * Note: these are just the ones that may not have a cpuid instruction.
215 * We deal with the rest in a different way. 215 * We deal with the rest in a different way.
216 */ 216 */
217const struct cpu_nocpuid_nameclass i386_nocpuid_cpus[] = { 217const struct cpu_nocpuid_nameclass i386_nocpuid_cpus[] = {
218 { CPUVENDOR_INTEL, "Intel", "386SX", CPUCLASS_386, 218 { CPUVENDOR_INTEL, "Intel", "386SX", CPUCLASS_386,
219 NULL, NULL, NULL }, /* CPU_386SX */ 219 NULL, NULL, NULL }, /* CPU_386SX */
220 { CPUVENDOR_INTEL, "Intel", "386DX", CPUCLASS_386, 220 { CPUVENDOR_INTEL, "Intel", "386DX", CPUCLASS_386,
221 NULL, NULL, NULL }, /* CPU_386 */ 221 NULL, NULL, NULL }, /* CPU_386 */
222 { CPUVENDOR_INTEL, "Intel", "486SX", CPUCLASS_486, 222 { CPUVENDOR_INTEL, "Intel", "486SX", CPUCLASS_486,
223 NULL, NULL, NULL }, /* CPU_486SX */ 223 NULL, NULL, NULL }, /* CPU_486SX */
224 { CPUVENDOR_INTEL, "Intel", "486DX", CPUCLASS_486, 224 { CPUVENDOR_INTEL, "Intel", "486DX", CPUCLASS_486,
225 NULL, NULL, NULL }, /* CPU_486 */ 225 NULL, NULL, NULL }, /* CPU_486 */
226 { CPUVENDOR_CYRIX, "Cyrix", "486DLC", CPUCLASS_486, 226 { CPUVENDOR_CYRIX, "Cyrix", "486DLC", CPUCLASS_486,
227 NULL, NULL, NULL }, /* CPU_486DLC */ 227 NULL, NULL, NULL }, /* CPU_486DLC */
228 { CPUVENDOR_CYRIX, "Cyrix", "6x86", CPUCLASS_486, 228 { CPUVENDOR_CYRIX, "Cyrix", "6x86", CPUCLASS_486,
229 NULL, NULL, NULL }, /* CPU_6x86 */ 229 NULL, NULL, NULL }, /* CPU_6x86 */
230 { CPUVENDOR_NEXGEN,"NexGen","586", CPUCLASS_386, 230 { CPUVENDOR_NEXGEN,"NexGen","586", CPUCLASS_386,
231 NULL, NULL, NULL }, /* CPU_NX586 */ 231 NULL, NULL, NULL }, /* CPU_NX586 */
232}; 232};
233 233
234const char *classnames[] = { 234const char *classnames[] = {
235 "386", 235 "386",
236 "486", 236 "486",
237 "586", 237 "586",
238 "686" 238 "686"
239}; 239};
240 240
241const char *modifiers[] = { 241const char *modifiers[] = {
242 "", 242 "",
243 "OverDrive", 243 "OverDrive",
244 "Dual", 244 "Dual",
245 "" 245 ""
246}; 246};
247 247
248struct cpu_extend_nameclass intel_family6_ext_models[] = { 248struct cpu_extend_nameclass intel_family6_ext_models[] = {
249 { /* Extended models 1x */ 249 { /* Extended models 1x */
250 0x01, { NULL, NULL, 250 0x01, { NULL, NULL,
251 NULL, NULL, 251 NULL, NULL,
252 NULL, "EP80579 Integrated Processor", 252 NULL, "EP80579 Integrated Processor",
253 "Celeron (45nm)", "Core 2 Extreme", 253 "Celeron (45nm)", "Core 2 Extreme",
254 NULL, NULL, 254 NULL, NULL,
255 "Core i7 (Nehalem)", NULL, 255 "Core i7 (Nehalem)", NULL,
256 "Atom", "XeonMP (Nehalem)", 256 "Atom", "XeonMP (Nehalem)",
257 NULL, NULL} }, 257 NULL, NULL} },
258 { /* End of list */ 258 { /* End of list */
259 0x00, { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 259 0x00, { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
260 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL} } 260 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL} }
261}; 261};
262 262
263const struct cpu_cpuid_nameclass i386_cpuid_cpus[] = { 263const struct cpu_cpuid_nameclass i386_cpuid_cpus[] = {
264 { 264 {
265 "GenuineIntel", 265 "GenuineIntel",
266 CPUVENDOR_INTEL, 266 CPUVENDOR_INTEL,
267 "Intel", 267 "Intel",
268 /* Family 4 */ 268 /* Family 4 */
269 { { 269 { {
270 CPUCLASS_486, 270 CPUCLASS_486,
271 { 271 {
272 "486DX", "486DX", "486SX", "486DX2", "486SL", 272 "486DX", "486DX", "486SX", "486DX2", "486SL",
273 "486SX2", 0, "486DX2 W/B Enhanced", 273 "486SX2", 0, "486DX2 W/B Enhanced",
274 "486DX4", 0, 0, 0, 0, 0, 0, 0, 274 "486DX4", 0, 0, 0, 0, 0, 0, 0,
275 "486" /* Default */ 275 "486" /* Default */
276 }, 276 },
277 NULL, 277 NULL,
278 NULL, 278 NULL,
279 NULL, 279 NULL,
280 NULL, 280 NULL,
281 }, 281 },
282 /* Family 5 */ 282 /* Family 5 */
283 { 283 {
284 CPUCLASS_586, 284 CPUCLASS_586,
285 { 285 {
286 "Pentium (P5 A-step)", "Pentium (P5)", 286 "Pentium (P5 A-step)", "Pentium (P5)",
287 "Pentium (P54C)", "Pentium (P24T)", 287 "Pentium (P54C)", "Pentium (P24T)",
288 "Pentium/MMX", "Pentium", 0, 288 "Pentium/MMX", "Pentium", 0,
289 "Pentium (P54C)", "Pentium/MMX (Tillamook)", 289 "Pentium (P54C)", "Pentium/MMX (Tillamook)",
290 0, 0, 0, 0, 0, 0, 0, 290 0, 0, 0, 0, 0, 0, 0,
291 "Pentium" /* Default */ 291 "Pentium" /* Default */
292 }, 292 },
293 NULL, 293 NULL,
294 NULL, 294 NULL,
295 NULL, 295 NULL,
296 NULL, 296 NULL,
297 }, 297 },
298 /* Family 6 */ 298 /* Family 6 */
299 { 299 {
300 CPUCLASS_686, 300 CPUCLASS_686,
301 { 301 {
302 "Pentium Pro (A-step)", "Pentium Pro", 0, 302 "Pentium Pro (A-step)", "Pentium Pro", 0,
303 "Pentium II (Klamath)", "Pentium Pro", 303 "Pentium II (Klamath)", "Pentium Pro",
304 "Pentium II/Celeron (Deschutes)", 304 "Pentium II/Celeron (Deschutes)",
305 "Celeron (Mendocino)", 305 "Celeron (Mendocino)",
306 "Pentium III (Katmai)", 306 "Pentium III (Katmai)",
307 "Pentium III (Coppermine)", 307 "Pentium III (Coppermine)",
308 "Pentium M (Banias)",  308 "Pentium M (Banias)",
309 "Pentium III Xeon (Cascades)", 309 "Pentium III Xeon (Cascades)",
310 "Pentium III (Tualatin)", 0, 310 "Pentium III (Tualatin)", 0,
311 "Pentium M (Dothan)",  311 "Pentium M (Dothan)",
312 "Pentium M (Yonah)", 312 "Pentium M (Yonah)",
313 "Core 2", 313 "Core 2",
314 "Pentium Pro, II or III" /* Default */ 314 "Pentium Pro, II or III" /* Default */
315 }, 315 },
316 NULL, 316 NULL,
317 intel_family_new_probe, 317 intel_family_new_probe,
318 NULL, 318 NULL,
319 &intel_family6_ext_models[0], 319 &intel_family6_ext_models[0],
320 }, 320 },
321 /* Family > 6 */ 321 /* Family > 6 */
322 { 322 {
323 CPUCLASS_686, 323 CPUCLASS_686,
324 { 324 {
325 0, 0, 0, 0, 0, 0, 0, 0, 325 0, 0, 0, 0, 0, 0, 0, 0,
326 0, 0, 0, 0, 0, 0, 0, 0, 326 0, 0, 0, 0, 0, 0, 0, 0,
327 "Pentium 4" /* Default */ 327 "Pentium 4" /* Default */
328 }, 328 },
329 NULL, 329 NULL,
330 intel_family_new_probe, 330 intel_family_new_probe,
331 NULL, 331 NULL,
332 NULL, 332 NULL,
333 } } 333 } }
334 }, 334 },
335 { 335 {
336 "AuthenticAMD", 336 "AuthenticAMD",
337 CPUVENDOR_AMD, 337 CPUVENDOR_AMD,
338 "AMD", 338 "AMD",
339 /* Family 4 */ 339 /* Family 4 */
340 { { 340 { {
341 CPUCLASS_486, 341 CPUCLASS_486,
342 { 342 {
343 0, 0, 0, "Am486DX2 W/T", 343 0, 0, 0, "Am486DX2 W/T",
344 0, 0, 0, "Am486DX2 W/B", 344 0, 0, 0, "Am486DX2 W/B",
345 "Am486DX4 W/T or Am5x86 W/T 150", 345 "Am486DX4 W/T or Am5x86 W/T 150",
346 "Am486DX4 W/B or Am5x86 W/B 150", 0, 0, 346 "Am486DX4 W/B or Am5x86 W/B 150", 0, 0,
347 0, 0, "Am5x86 W/T 133/160", 347 0, 0, "Am5x86 W/T 133/160",
348 "Am5x86 W/B 133/160", 348 "Am5x86 W/B 133/160",
349 "Am486 or Am5x86" /* Default */ 349 "Am486 or Am5x86" /* Default */
350 }, 350 },
351 NULL, 351 NULL,
352 NULL, 352 NULL,
353 NULL, 353 NULL,
354 NULL, 354 NULL,
355 }, 355 },
356 /* Family 5 */ 356 /* Family 5 */
357 { 357 {
358 CPUCLASS_586, 358 CPUCLASS_586,
359 { 359 {
360 "K5", "K5", "K5", "K5", 0, 0, "K6", 360 "K5", "K5", "K5", "K5", 0, 0, "K6",
361 "K6", "K6-2", "K6-III", "Geode LX", 0, 0, 361 "K6", "K6-2", "K6-III", "Geode LX", 0, 0,
362 "K6-2+/III+", 0, 0, 362 "K6-2+/III+", 0, 0,
363 "K5 or K6" /* Default */ 363 "K5 or K6" /* Default */
364 }, 364 },
365 amd_family5_setup, 365 amd_family5_setup,
366 NULL, 366 NULL,
367 amd_cpu_cacheinfo, 367 amd_cpu_cacheinfo,
368 NULL, 368 NULL,
369 }, 369 },
370 /* Family 6 */ 370 /* Family 6 */
371 { 371 {
372 CPUCLASS_686, 372 CPUCLASS_686,
373 { 373 {
374 0, "Athlon Model 1", "Athlon Model 2", 374 0, "Athlon Model 1", "Athlon Model 2",
375 "Duron", "Athlon Model 4 (Thunderbird)", 375 "Duron", "Athlon Model 4 (Thunderbird)",
376 0, "Athlon", "Duron", "Athlon", 0, 376 0, "Athlon", "Duron", "Athlon", 0,
377 "Athlon", 0, 0, 0, 0, 0, 377 "Athlon", 0, 0, 0, 0, 0,
378 "K7 (Athlon)" /* Default */ 378 "K7 (Athlon)" /* Default */
379 }, 379 },
380 NULL, 380 NULL,
381 amd_family6_probe, 381 amd_family6_probe,
382 amd_cpu_cacheinfo, 382 amd_cpu_cacheinfo,
383 NULL, 383 NULL,
384 }, 384 },
385 /* Family > 6 */ 385 /* Family > 6 */
386 { 386 {
387 CPUCLASS_686, 387 CPUCLASS_686,
388 { 388 {
389 0, 0, 0, 0, 0, 0, 0, 0, 389 0, 0, 0, 0, 0, 0, 0, 0,
390 0, 0, 0, 0, 0, 0, 0, 0, 390 0, 0, 0, 0, 0, 0, 0, 0,
391 "Unknown K8 (Athlon)" /* Default */ 391 "Unknown K8 (Athlon)" /* Default */
392 }, 392 },
393 NULL, 393 NULL,
394 amd_family6_probe, 394 amd_family6_probe,
395 amd_cpu_cacheinfo, 395 amd_cpu_cacheinfo,
396 NULL, 396 NULL,
397 } } 397 } }
398 }, 398 },
399 { 399 {
400 "CyrixInstead", 400 "CyrixInstead",
401 CPUVENDOR_CYRIX, 401 CPUVENDOR_CYRIX,
402 "Cyrix", 402 "Cyrix",
403 /* Family 4 */ 403 /* Family 4 */
404 { { 404 { {
405 CPUCLASS_486, 405 CPUCLASS_486,
406 { 406 {
407 0, 0, 0, 407 0, 0, 0,
408 "MediaGX", 408 "MediaGX",
409 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 409 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
410 "486" /* Default */ 410 "486" /* Default */
411 }, 411 },
412 cyrix6x86_cpu_setup, /* XXX ?? */ 412 cyrix6x86_cpu_setup, /* XXX ?? */
413 NULL, 413 NULL,
414 NULL, 414 NULL,
415 NULL, 415 NULL,
416 }, 416 },
417 /* Family 5 */ 417 /* Family 5 */
418 { 418 {
419 CPUCLASS_586, 419 CPUCLASS_586,
420 { 420 {
421 0, 0, "6x86", 0, 421 0, 0, "6x86", 0,
422 "MMX-enhanced MediaGX (GXm)", /* or Geode? */ 422 "MMX-enhanced MediaGX (GXm)", /* or Geode? */
423 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 423 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
424 "6x86" /* Default */ 424 "6x86" /* Default */
425 }, 425 },
426 cyrix6x86_cpu_setup, 426 cyrix6x86_cpu_setup,
427 NULL, 427 NULL,
428 NULL, 428 NULL,
429 NULL, 429 NULL,
430 }, 430 },
431 /* Family 6 */ 431 /* Family 6 */
432 { 432 {
433 CPUCLASS_686, 433 CPUCLASS_686,
434 { 434 {
435 "6x86MX", 0, 0, 0, 0, 0, 0, 0, 435 "6x86MX", 0, 0, 0, 0, 0, 0, 0,
436 0, 0, 0, 0, 0, 0, 0, 0, 436 0, 0, 0, 0, 0, 0, 0, 0,
437 "6x86MX" /* Default */ 437 "6x86MX" /* Default */
438 }, 438 },
439 cyrix6x86_cpu_setup, 439 cyrix6x86_cpu_setup,
440 NULL, 440 NULL,
441 NULL, 441 NULL,
442 NULL, 442 NULL,
443 }, 443 },
444 /* Family > 6 */ 444 /* Family > 6 */
445 { 445 {
446 CPUCLASS_686, 446 CPUCLASS_686,
447 { 447 {
448 0, 0, 0, 0, 0, 0, 0, 0, 448 0, 0, 0, 0, 0, 0, 0, 0,
449 0, 0, 0, 0, 0, 0, 0, 0, 449 0, 0, 0, 0, 0, 0, 0, 0,
450 "Unknown 6x86MX" /* Default */ 450 "Unknown 6x86MX" /* Default */
451 }, 451 },
452 NULL, 452 NULL,
453 NULL, 453 NULL,
454 NULL, 454 NULL,
455 NULL, 455 NULL,
456 } } 456 } }
457 }, 457 },
458 { /* MediaGX is now owned by National Semiconductor */ 458 { /* MediaGX is now owned by National Semiconductor */
459 "Geode by NSC", 459 "Geode by NSC",
460 CPUVENDOR_CYRIX, /* XXX */ 460 CPUVENDOR_CYRIX, /* XXX */
461 "National Semiconductor", 461 "National Semiconductor",
462 /* Family 4, NSC never had any of these */ 462 /* Family 4, NSC never had any of these */
463 { { 463 { {
464 CPUCLASS_486, 464 CPUCLASS_486,
465 { 465 {
466 0, 0, 0, 0, 0, 0, 0, 0, 466 0, 0, 0, 0, 0, 0, 0, 0,
467 0, 0, 0, 0, 0, 0, 0, 0, 467 0, 0, 0, 0, 0, 0, 0, 0,
468 "486 compatible" /* Default */ 468 "486 compatible" /* Default */
469 }, 469 },
470 NULL, 470 NULL,
471 NULL, 471 NULL,
472 NULL, 472 NULL,
473 NULL, 473 NULL,
474 }, 474 },
475 /* Family 5: Geode family, formerly MediaGX */ 475 /* Family 5: Geode family, formerly MediaGX */
476 { 476 {
477 CPUCLASS_586, 477 CPUCLASS_586,
478 { 478 {
479 0, 0, 0, 0, 479 0, 0, 0, 0,
480 "Geode GX1", 480 "Geode GX1",
481 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 481 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
482 "Geode" /* Default */ 482 "Geode" /* Default */
483 }, 483 },
484 cyrix6x86_cpu_setup, 484 cyrix6x86_cpu_setup,
485 NULL, 485 NULL,
486 amd_cpu_cacheinfo, 486 amd_cpu_cacheinfo,
487 NULL, 487 NULL,
488 }, 488 },
489 /* Family 6, not yet available from NSC */ 489 /* Family 6, not yet available from NSC */
490 { 490 {
491 CPUCLASS_686, 491 CPUCLASS_686,
492 { 492 {
493 0, 0, 0, 0, 0, 0, 0, 0, 493 0, 0, 0, 0, 0, 0, 0, 0,
494 0, 0, 0, 0, 0, 0, 0, 0, 494 0, 0, 0, 0, 0, 0, 0, 0,
495 "Pentium Pro compatible" /* Default */ 495 "Pentium Pro compatible" /* Default */
496 }, 496 },
497 NULL, 497 NULL,
498 NULL, 498 NULL,
499 NULL, 499 NULL,
500 NULL, 500 NULL,
501 }, 501 },
502 /* Family > 6, not yet available from NSC */ 502 /* Family > 6, not yet available from NSC */
503 { 503 {
504 CPUCLASS_686, 504 CPUCLASS_686,
505 { 505 {
506 0, 0, 0, 0, 0, 0, 0, 0, 506 0, 0, 0, 0, 0, 0, 0, 0,
507 0, 0, 0, 0, 0, 0, 0, 0, 507 0, 0, 0, 0, 0, 0, 0, 0,
508 "Pentium Pro compatible" /* Default */ 508 "Pentium Pro compatible" /* Default */
509 }, 509 },
510 NULL, 510 NULL,
511 NULL, 511 NULL,
512 NULL, 512 NULL,
513 NULL, 513 NULL,
514 } } 514 } }
515 }, 515 },
516 { 516 {
517 "CentaurHauls", 517 "CentaurHauls",
518 CPUVENDOR_IDT, 518 CPUVENDOR_IDT,
519 "IDT", 519 "IDT",
520 /* Family 4, IDT never had any of these */ 520 /* Family 4, IDT never had any of these */
521 { { 521 { {
522 CPUCLASS_486, 522 CPUCLASS_486,
523 { 523 {
524 0, 0, 0, 0, 0, 0, 0, 0, 524 0, 0, 0, 0, 0, 0, 0, 0,
525 0, 0, 0, 0, 0, 0, 0, 0, 525 0, 0, 0, 0, 0, 0, 0, 0,
526 "486 compatible" /* Default */ 526 "486 compatible" /* Default */
527 }, 527 },
528 NULL, 528 NULL,
529 NULL, 529 NULL,
530 NULL, 530 NULL,
531 NULL, 531 NULL,
532 }, 532 },
533 /* Family 5 */ 533 /* Family 5 */
534 { 534 {
535 CPUCLASS_586, 535 CPUCLASS_586,
536 { 536 {
537 0, 0, 0, 0, "WinChip C6", 0, 0, 0, 537 0, 0, 0, 0, "WinChip C6", 0, 0, 0,
538 "WinChip 2", "WinChip 3", 0, 0, 0, 0, 0, 0, 538 "WinChip 2", "WinChip 3", 0, 0, 0, 0, 0, 0,
539 "WinChip" /* Default */ 539 "WinChip" /* Default */
540 }, 540 },
541 winchip_cpu_setup, 541 winchip_cpu_setup,
542 NULL, 542 NULL,
543 NULL, 543 NULL,
544 NULL, 544 NULL,
545 }, 545 },
546 /* Family 6, VIA acquired IDT Centaur design subsidiary */ 546 /* Family 6, VIA acquired IDT Centaur design subsidiary */
547 { 547 {
548 CPUCLASS_686, 548 CPUCLASS_686,
549 { 549 {
550 0, 0, 0, 0, 0, 0, "C3 Samuel", 550 0, 0, 0, 0, 0, 0, "C3 Samuel",
551 "C3 Samuel 2/Ezra", "C3 Ezra-T", 551 "C3 Samuel 2/Ezra", "C3 Ezra-T",
552 "C3 Nehemiah", "C7 Esther", 0, 0, "C7 Esther", 552 "C3 Nehemiah", "C7 Esther", 0, 0, "C7 Esther",
553 0, "VIA Nano", 553 0, "VIA Nano",
554 "Unknown VIA/IDT" /* Default */ 554 "Unknown VIA/IDT" /* Default */
555 }, 555 },
556 NULL, 556 NULL,
557 via_cpu_probe, 557 via_cpu_probe,
558 via_cpu_cacheinfo, 558 via_cpu_cacheinfo,
559 NULL, 559 NULL,
560 }, 560 },
561 /* Family > 6, not yet available from VIA */ 561 /* Family > 6, not yet available from VIA */
562 { 562 {
563 CPUCLASS_686, 563 CPUCLASS_686,
564 { 564 {
565 0, 0, 0, 0, 0, 0, 0, 0, 565 0, 0, 0, 0, 0, 0, 0, 0,
566 0, 0, 0, 0, 0, 0, 0, 0, 566 0, 0, 0, 0, 0, 0, 0, 0,
567 "Pentium Pro compatible" /* Default */ 567 "Pentium Pro compatible" /* Default */
568 }, 568 },
569 NULL, 569 NULL,
570 NULL, 570 NULL,
571 NULL, 571 NULL,
572 NULL, 572 NULL,
573 } } 573 } }
574 }, 574 },
575 { 575 {
576 "GenuineTMx86", 576 "GenuineTMx86",
577 CPUVENDOR_TRANSMETA, 577 CPUVENDOR_TRANSMETA,
578 "Transmeta", 578 "Transmeta",
579 /* Family 4, Transmeta never had any of these */ 579 /* Family 4, Transmeta never had any of these */
580 { { 580 { {
581 CPUCLASS_486, 581 CPUCLASS_486,
582 { 582 {
583 0, 0, 0, 0, 0, 0, 0, 0, 583 0, 0, 0, 0, 0, 0, 0, 0,
584 0, 0, 0, 0, 0, 0, 0, 0, 584 0, 0, 0, 0, 0, 0, 0, 0,
585 "486 compatible" /* Default */ 585 "486 compatible" /* Default */
586 }, 586 },
587 NULL, 587 NULL,
588 NULL, 588 NULL,
589 NULL, 589 NULL,
590 NULL, 590 NULL,
591 }, 591 },
592 /* Family 5 */ 592 /* Family 5 */
593 { 593 {
594 CPUCLASS_586, 594 CPUCLASS_586,
595 { 595 {
596 0, 0, 0, 0, 0, 0, 0, 0, 596 0, 0, 0, 0, 0, 0, 0, 0,
597 0, 0, 0, 0, 0, 0, 0, 0, 597 0, 0, 0, 0, 0, 0, 0, 0,
598 "Crusoe" /* Default */ 598 "Crusoe" /* Default */
599 }, 599 },
600 NULL, 600 NULL,
601 NULL, 601 NULL,
602 transmeta_cpu_info, 602 transmeta_cpu_info,
603 NULL, 603 NULL,
604 }, 604 },
605 /* Family 6, not yet available from Transmeta */ 605 /* Family 6, not yet available from Transmeta */
606 { 606 {
607 CPUCLASS_686, 607 CPUCLASS_686,
608 { 608 {
609 0, 0, 0, 0, 0, 0, 0, 0, 609 0, 0, 0, 0, 0, 0, 0, 0,
610 0, 0, 0, 0, 0, 0, 0, 0, 610 0, 0, 0, 0, 0, 0, 0, 0,
611 "Pentium Pro compatible" /* Default */ 611 "Pentium Pro compatible" /* Default */
612 }, 612 },
613 NULL, 613 NULL,
614 NULL, 614 NULL,
615 NULL, 615 NULL,
616 NULL, 616 NULL,
617 }, 617 },
618 /* Family > 6, not yet available from Transmeta */ 618 /* Family > 6, not yet available from Transmeta */
619 { 619 {
620 CPUCLASS_686, 620 CPUCLASS_686,
621 { 621 {
622 0, 0, 0, 0, 0, 0, 0, 0, 622 0, 0, 0, 0, 0, 0, 0, 0,
623 0, 0, 0, 0, 0, 0, 0, 0, 623 0, 0, 0, 0, 0, 0, 0, 0,
624 "Pentium Pro compatible" /* Default */ 624 "Pentium Pro compatible" /* Default */
625 }, 625 },
626 NULL, 626 NULL,
627 NULL, 627 NULL,
628 NULL, 628 NULL,
629 NULL, 629 NULL,
630 } } 630 } }
631 } 631 }
632}; 632};
633 633
634/* 634/*
635 * disable the TSC such that we don't use the TSC in microtime(9) 635 * disable the TSC such that we don't use the TSC in microtime(9)
636 * because some CPUs got the implementation wrong. 636 * because some CPUs got the implementation wrong.
637 */ 637 */
638static void 638static void
639disable_tsc(struct cpu_info *ci) 639disable_tsc(struct cpu_info *ci)
640{ 640{
641 if (ci->ci_feat_val[0] & CPUID_TSC) { 641 if (ci->ci_feat_val[0] & CPUID_TSC) {
642 ci->ci_feat_val[0] &= ~CPUID_TSC; 642 ci->ci_feat_val[0] &= ~CPUID_TSC;
643 aprint_error("WARNING: broken TSC disabled\n"); 643 aprint_error("WARNING: broken TSC disabled\n");
644 } 644 }
645} 645}
646 646
647static void 647static void
648cyrix6x86_cpu_setup(struct cpu_info *ci) 648cyrix6x86_cpu_setup(struct cpu_info *ci)
649{ 649{
650 650
651 /*  651 /*
652 * Do not disable the TSC on the Geode GX, it's reported to 652 * Do not disable the TSC on the Geode GX, it's reported to
653 * work fine. 653 * work fine.
654 */ 654 */
655 if (ci->ci_signature != 0x552) 655 if (ci->ci_signature != 0x552)
656 disable_tsc(ci); 656 disable_tsc(ci);
657} 657}
658 658
659void 659void
660winchip_cpu_setup(struct cpu_info *ci) 660winchip_cpu_setup(struct cpu_info *ci)
661{ 661{
662 switch (CPUID2MODEL(ci->ci_signature)) { /* model */ 662 switch (CPUID2MODEL(ci->ci_signature)) { /* model */
663 case 4: /* WinChip C6 */ 663 case 4: /* WinChip C6 */
664 disable_tsc(ci); 664 disable_tsc(ci);
665 } 665 }
666} 666}
667 667
668 668
669static void 669static void
670identifycpu_cpuids(struct cpu_info *ci) 670identifycpu_cpuids(struct cpu_info *ci)
671{ 671{
672 const char *cpuname = ci->ci_dev; 672 const char *cpuname = ci->ci_dev;
673 u_int lp_max = 1; /* logical processors per package */ 673 u_int lp_max = 1; /* logical processors per package */
674 u_int smt_max; /* smt per core */ 674 u_int smt_max; /* smt per core */
675 u_int core_max = 1; /* core per package */ 675 u_int core_max = 1; /* core per package */
676 u_int smt_bits, core_bits; 676 u_int smt_bits, core_bits;
677 uint32_t descs[4]; 677 uint32_t descs[4];
678 678
679 aprint_verbose("%s: Initial APIC ID %u\n", cpuname, ci->ci_initapicid); 679 aprint_verbose("%s: Initial APIC ID %u\n", cpuname, ci->ci_initapicid);
680 ci->ci_packageid = ci->ci_initapicid; 680 ci->ci_packageid = ci->ci_initapicid;
681 ci->ci_coreid = 0; 681 ci->ci_coreid = 0;
682 ci->ci_smtid = 0; 682 ci->ci_smtid = 0;
683 if (cpu_vendor != CPUVENDOR_INTEL) { 683 if (cpu_vendor != CPUVENDOR_INTEL) {
684 return; 684 return;
685 } 685 }
686 686
687 /* 687 /*
688 * 253668.pdf 7.10.2 688 * 253668.pdf 7.10.2
689 */ 689 */
690 690
691 if ((ci->ci_feat_val[0] & CPUID_HTT) != 0) { 691 if ((ci->ci_feat_val[0] & CPUID_HTT) != 0) {
692 x86_cpuid(1, descs); 692 x86_cpuid(1, descs);
693 lp_max = (descs[1] >> 16) & 0xff; 693 lp_max = (descs[1] >> 16) & 0xff;
694 } 694 }
695 x86_cpuid(0, descs); 695 x86_cpuid(0, descs);
696 if (descs[0] >= 4) { 696 if (descs[0] >= 4) {
697 x86_cpuid2(4, 0, descs); 697 x86_cpuid2(4, 0, descs);
698 core_max = (descs[0] >> 26) + 1; 698 core_max = (descs[0] >> 26) + 1;
699 } 699 }
700 assert(lp_max >= core_max); 700 assert(lp_max >= core_max);
701 smt_max = lp_max / core_max; 701 smt_max = lp_max / core_max;
702 smt_bits = ilog2(smt_max - 1) + 1; 702 smt_bits = ilog2(smt_max - 1) + 1;
703 core_bits = ilog2(core_max - 1) + 1; 703 core_bits = ilog2(core_max - 1) + 1;
704 if (smt_bits + core_bits) { 704 if (smt_bits + core_bits) {
705 ci->ci_packageid = ci->ci_initapicid >> (smt_bits + core_bits); 705 ci->ci_packageid = ci->ci_initapicid >> (smt_bits + core_bits);
706 } 706 }
707 aprint_verbose("%s: Cluster/Package ID %u\n", cpuname, 707 aprint_verbose("%s: Cluster/Package ID %u\n", cpuname,
708 ci->ci_packageid); 708 ci->ci_packageid);
709 if (core_bits) { 709 if (core_bits) {
710 u_int core_mask = __BITS(smt_bits, smt_bits + core_bits - 1); 710 u_int core_mask = __BITS(smt_bits, smt_bits + core_bits - 1);
711 711
712 ci->ci_coreid = 712 ci->ci_coreid =
713 __SHIFTOUT(ci->ci_initapicid, core_mask); 713 __SHIFTOUT(ci->ci_initapicid, core_mask);
714 aprint_verbose("%s: Core ID %u\n", cpuname, ci->ci_coreid); 714 aprint_verbose("%s: Core ID %u\n", cpuname, ci->ci_coreid);
715 } 715 }
716 if (smt_bits) { 716 if (smt_bits) {
717 u_int smt_mask = __BITS((int)0, (int)(smt_bits - 1)); 717 u_int smt_mask = __BITS((int)0, (int)(smt_bits - 1));
718 718
719 ci->ci_smtid = __SHIFTOUT(ci->ci_initapicid, smt_mask); 719 ci->ci_smtid = __SHIFTOUT(ci->ci_initapicid, smt_mask);
720 aprint_verbose("%s: SMT ID %u\n", cpuname, ci->ci_smtid); 720 aprint_verbose("%s: SMT ID %u\n", cpuname, ci->ci_smtid);
721 } 721 }
722} 722}
723 723
724static void 724static void
725via_cpu_probe(struct cpu_info *ci) 725via_cpu_probe(struct cpu_info *ci)
726{ 726{
727 u_int model = CPUID2MODEL(ci->ci_signature); 727 u_int model = CPUID2MODEL(ci->ci_signature);
728 u_int stepping = CPUID2STEPPING(ci->ci_signature); 728 u_int stepping = CPUID2STEPPING(ci->ci_signature);
729 u_int descs[4]; 729 u_int descs[4];
730 u_int lfunc; 730 u_int lfunc;
731 731
732 /* 732 /*
733 * Determine the largest extended function value. 733 * Determine the largest extended function value.
734 */ 734 */
735 x86_cpuid(0x80000000, descs); 735 x86_cpuid(0x80000000, descs);
736 lfunc = descs[0]; 736 lfunc = descs[0];
737 737
738 /* 738 /*
739 * Determine the extended feature flags. 739 * Determine the extended feature flags.
740 */ 740 */
741 if (lfunc >= 0x80000001) { 741 if (lfunc >= 0x80000001) {
742 x86_cpuid(0x80000001, descs); 742 x86_cpuid(0x80000001, descs);
743 ci->ci_feat_val[2] |= descs[3]; 743 ci->ci_feat_val[2] |= descs[3];
744 } 744 }
745 745
746 if (model < 0x9 || (model == 0x9 && stepping < 3)) 746 if (model < 0x9 || (model == 0x9 && stepping < 3))
747 return; 747 return;
748 748
749 /* Nehemiah or Esther */ 749 /* Nehemiah or Esther */
750 x86_cpuid(0xc0000000, descs); 750 x86_cpuid(0xc0000000, descs);
751 lfunc = descs[0]; 751 lfunc = descs[0];
752 if (lfunc < 0xc0000001) /* no ACE, no RNG */ 752 if (lfunc < 0xc0000001) /* no ACE, no RNG */
753 return; 753 return;
754 754
755 x86_cpuid(0xc0000001, descs); 755 x86_cpuid(0xc0000001, descs);
756 lfunc = descs[3]; 756 lfunc = descs[3];
757 ci->ci_feat_val[4] = lfunc; 757 ci->ci_feat_val[4] = lfunc;
758} 758}
759 759
760static const char * 760static const char *
761intel_family6_name(struct cpu_info *ci) 761intel_family6_name(struct cpu_info *ci)
762{ 762{
763 int model = CPUID2MODEL(ci->ci_signature); 763 int model = CPUID2MODEL(ci->ci_signature);
764 const char *ret = NULL; 764 const char *ret = NULL;
765 u_int l2cache = ci->ci_cinfo[CAI_L2CACHE].cai_totalsize; 765 u_int l2cache = ci->ci_cinfo[CAI_L2CACHE].cai_totalsize;
766 766
767 if (model == 5) { 767 if (model == 5) {
768 switch (l2cache) { 768 switch (l2cache) {
769 case 0: 769 case 0:
770 case 128 * 1024: 770 case 128 * 1024:
771 ret = "Celeron (Covington)"; 771 ret = "Celeron (Covington)";
772 break; 772 break;
773 case 256 * 1024: 773 case 256 * 1024:
774 ret = "Mobile Pentium II (Dixon)"; 774 ret = "Mobile Pentium II (Dixon)";
775 break; 775 break;
776 case 512 * 1024: 776 case 512 * 1024:
777 ret = "Pentium II"; 777 ret = "Pentium II";
778 break; 778 break;
779 case 1 * 1024 * 1024: 779 case 1 * 1024 * 1024:
780 case 2 * 1024 * 1024: 780 case 2 * 1024 * 1024:
781 ret = "Pentium II Xeon"; 781 ret = "Pentium II Xeon";
782 break; 782 break;
783 } 783 }
784 } else if (model == 6) { 784 } else if (model == 6) {
785 switch (l2cache) { 785 switch (l2cache) {
786 case 256 * 1024: 786 case 256 * 1024:
787 case 512 * 1024: 787 case 512 * 1024:
788 ret = "Mobile Pentium II"; 788 ret = "Mobile Pentium II";
789 break; 789 break;
790 } 790 }
791 } else if (model == 7) { 791 } else if (model == 7) {
792 switch (l2cache) { 792 switch (l2cache) {
793 case 512 * 1024: 793 case 512 * 1024:
794 ret = "Pentium III"; 794 ret = "Pentium III";
795 break; 795 break;
796 case 1 * 1024 * 1024: 796 case 1 * 1024 * 1024:
797 case 2 * 1024 * 1024: 797 case 2 * 1024 * 1024:
798 ret = "Pentium III Xeon"; 798 ret = "Pentium III Xeon";
799 break; 799 break;
800 } 800 }
801 } else if (model >= 8) { 801 } else if (model >= 8) {
802 if (ci->ci_brand_id && ci->ci_brand_id < 0x10) { 802 if (ci->ci_brand_id && ci->ci_brand_id < 0x10) {
803 switch (ci->ci_brand_id) { 803 switch (ci->ci_brand_id) {
804 case 0x3: 804 case 0x3:
805 if (ci->ci_signature == 0x6B1) 805 if (ci->ci_signature == 0x6B1)
806 ret = "Celeron"; 806 ret = "Celeron";
807 break; 807 break;
808 case 0x8: 808 case 0x8:
809 if (ci->ci_signature >= 0xF13) 809 if (ci->ci_signature >= 0xF13)
810 ret = "genuine processor"; 810 ret = "genuine processor";
811 break; 811 break;
812 case 0xB: 812 case 0xB:
813 if (ci->ci_signature >= 0xF13) 813 if (ci->ci_signature >= 0xF13)
814 ret = "Xeon MP"; 814 ret = "Xeon MP";
815 break; 815 break;
816 case 0xE: 816 case 0xE:
817 if (ci->ci_signature < 0xF13) 817 if (ci->ci_signature < 0xF13)
818 ret = "Xeon"; 818 ret = "Xeon";
819 break; 819 break;
820 } 820 }
821 if (ret == NULL) 821 if (ret == NULL)
822 ret = i386_intel_brand[ci->ci_brand_id]; 822 ret = i386_intel_brand[ci->ci_brand_id];
823 } 823 }
824 } 824 }
825 825
826 return ret; 826 return ret;
827} 827}
828 828
829/* 829/*
830 * Identify AMD64 CPU names from cpuid. 830 * Identify AMD64 CPU names from cpuid.
831 * 831 *
832 * Based on: 832 * Based on:
833 * "Revision Guide for AMD Athlon 64 and AMD Opteron Processors" 833 * "Revision Guide for AMD Athlon 64 and AMD Opteron Processors"
834 * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/25759.pdf 834 * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/25759.pdf
835 * "Revision Guide for AMD NPT Family 0Fh Processors" 835 * "Revision Guide for AMD NPT Family 0Fh Processors"
836 * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/33610.pdf 836 * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/33610.pdf
837 * and other miscellaneous reports. 837 * and other miscellaneous reports.
838 */ 838 */
839static const char * 839static const char *
840amd_amd64_name(struct cpu_info *ci) 840amd_amd64_name(struct cpu_info *ci)
841{ 841{
842 int extfamily, extmodel, model; 842 int extfamily, extmodel, model;
843 const char *ret = NULL; 843 const char *ret = NULL;
844 844
845 model = CPUID2MODEL(ci->ci_signature); 845 model = CPUID2MODEL(ci->ci_signature);
846 extfamily = CPUID2EXTFAMILY(ci->ci_signature); 846 extfamily = CPUID2EXTFAMILY(ci->ci_signature);
847 extmodel = CPUID2EXTMODEL(ci->ci_signature); 847 extmodel = CPUID2EXTMODEL(ci->ci_signature);
848 848
849 switch (extfamily) { 849 switch (extfamily) {
850 case 0x00: 850 case 0x00:
851 switch (model) { 851 switch (model) {
852 case 0x1: 852 case 0x1:
853 switch (extmodel) { 853 switch (extmodel) {
854 case 0x2: /* rev JH-E1/E6 */ 854 case 0x2: /* rev JH-E1/E6 */
855 case 0x4: /* rev JH-F2 */ 855 case 0x4: /* rev JH-F2 */
856 ret = "Dual-Core Opteron"; 856 ret = "Dual-Core Opteron";
857 break; 857 break;
858 } 858 }
859 break; 859 break;
860 case 0x3: 860 case 0x3:
861 switch (extmodel) { 861 switch (extmodel) {
862 case 0x2: /* rev JH-E6 (Toledo) */ 862 case 0x2: /* rev JH-E6 (Toledo) */
863 ret = "Dual-Core Opteron or Athlon 64 X2"; 863 ret = "Dual-Core Opteron or Athlon 64 X2";
864 break; 864 break;
865 case 0x4: /* rev JH-F2 (Windsor) */ 865 case 0x4: /* rev JH-F2 (Windsor) */
866 ret = "Athlon 64 FX or Athlon 64 X2"; 866 ret = "Athlon 64 FX or Athlon 64 X2";
867 break; 867 break;
868 } 868 }
869 break; 869 break;
870 case 0x4: 870 case 0x4:
871 switch (extmodel) { 871 switch (extmodel) {
872 case 0x0: /* rev SH-B0/C0/CG (ClawHammer) */ 872 case 0x0: /* rev SH-B0/C0/CG (ClawHammer) */
873 case 0x1: /* rev SH-D0 */ 873 case 0x1: /* rev SH-D0 */
874 ret = "Athlon 64"; 874 ret = "Athlon 64";
875 break; 875 break;
876 case 0x2: /* rev SH-E5 (Lancaster?) */ 876 case 0x2: /* rev SH-E5 (Lancaster?) */
877 ret = "Mobile Athlon 64 or Turion 64"; 877 ret = "Mobile Athlon 64 or Turion 64";
878 break; 878 break;
879 } 879 }
880 break; 880 break;
881 case 0x5: 881 case 0x5:
882 switch (extmodel) { 882 switch (extmodel) {
883 case 0x0: /* rev SH-B0/B3/C0/CG (SledgeHammer?) */ 883 case 0x0: /* rev SH-B0/B3/C0/CG (SledgeHammer?) */
884 ret = "Opteron or Athlon 64 FX"; 884 ret = "Opteron or Athlon 64 FX";
885 break; 885 break;
886 case 0x1: /* rev SH-D0 */ 886 case 0x1: /* rev SH-D0 */
887 case 0x2: /* rev SH-E4 */ 887 case 0x2: /* rev SH-E4 */
888 ret = "Opteron"; 888 ret = "Opteron";
889 break; 889 break;
890 } 890 }
891 break; 891 break;
892 case 0x7: 892 case 0x7:
893 switch (extmodel) { 893 switch (extmodel) {
894 case 0x0: /* rev SH-CG (ClawHammer) */ 894 case 0x0: /* rev SH-CG (ClawHammer) */
895 case 0x1: /* rev SH-D0 */ 895 case 0x1: /* rev SH-D0 */
896 ret = "Athlon 64"; 896 ret = "Athlon 64";
897 break; 897 break;
898 case 0x2: /* rev DH-E4, SH-E4 */ 898 case 0x2: /* rev DH-E4, SH-E4 */
899 ret = "Athlon 64 or Athlon 64 FX or Opteron"; 899 ret = "Athlon 64 or Athlon 64 FX or Opteron";
900 break; 900 break;
901 } 901 }
902 break; 902 break;
903 case 0x8: 903 case 0x8:
904 switch (extmodel) { 904 switch (extmodel) {
905 case 0x0: /* rev CH-CG */ 905 case 0x0: /* rev CH-CG */
906 case 0x1: /* rev CH-D0 */ 906 case 0x1: /* rev CH-D0 */
907 ret = "Athlon 64 or Sempron"; 907 ret = "Athlon 64 or Sempron";
908 break; 908 break;
909 case 0x4: /* rev BH-F2 */ 909 case 0x4: /* rev BH-F2 */
910 ret = "Turion 64 X2"; 910 ret = "Turion 64 X2";
911 break; 911 break;
912 } 912 }
913 break; 913 break;
914 case 0xb: 914 case 0xb:
915 switch (extmodel) { 915 switch (extmodel) {
916 case 0x0: /* rev CH-CG */ 916 case 0x0: /* rev CH-CG */
917 case 0x1: /* rev CH-D0 */ 917 case 0x1: /* rev CH-D0 */
918 ret = "Athlon 64"; 918 ret = "Athlon 64";
919 break; 919 break;
920 case 0x2: /* rev BH-E4 (Manchester) */ 920 case 0x2: /* rev BH-E4 (Manchester) */
921 case 0x4: /* rev BH-F2 (Windsor) */ 921 case 0x4: /* rev BH-F2 (Windsor) */
922 ret = "Athlon 64 X2"; 922 ret = "Athlon 64 X2";
923 break; 923 break;
924 case 0x6: /* rev BH-G1 (Brisbane) */ 924 case 0x6: /* rev BH-G1 (Brisbane) */
925 ret = "Athlon X2 or Athlon 64 X2"; 925 ret = "Athlon X2 or Athlon 64 X2";
926 break; 926 break;
927 } 927 }
928 break; 928 break;
929 case 0xc: 929 case 0xc:
930 switch (extmodel) { 930 switch (extmodel) {
931 case 0x0: /* rev DH-CG (Newcastle) */ 931 case 0x0: /* rev DH-CG (Newcastle) */
932 case 0x1: /* rev DH-D0 (Winchester) */ 932 case 0x1: /* rev DH-D0 (Winchester) */
933 case 0x2: /* rev DH-E3/E6 */ 933 case 0x2: /* rev DH-E3/E6 */
934 ret = "Athlon 64 or Sempron"; 934 ret = "Athlon 64 or Sempron";
935 break; 935 break;
936 } 936 }
937 break; 937 break;
938 case 0xe: 938 case 0xe:
939 switch (extmodel) { 939 switch (extmodel) {
940 case 0x0: /* rev DH-CG (Newcastle?) */ 940 case 0x0: /* rev DH-CG (Newcastle?) */
941 ret = "Athlon 64 or Sempron"; 941 ret = "Athlon 64 or Sempron";
942 break; 942 break;
943 } 943 }
944 break; 944 break;
945 case 0xf: 945 case 0xf:
946 switch (extmodel) { 946 switch (extmodel) {
947 case 0x0: /* rev DH-CG (Newcastle/Paris) */ 947 case 0x0: /* rev DH-CG (Newcastle/Paris) */
948 case 0x1: /* rev DH-D0 (Winchester/Victoria) */ 948 case 0x1: /* rev DH-D0 (Winchester/Victoria) */
949 case 0x2: /* rev DH-E3/E6 (Venice/Palermo) */ 949 case 0x2: /* rev DH-E3/E6 (Venice/Palermo) */
950 case 0x4: /* rev DH-F2 (Orleans/Manila) */ 950 case 0x4: /* rev DH-F2 (Orleans/Manila) */
951 case 0x5: /* rev DH-F2 (Orleans/Manila) */ 951 case 0x5: /* rev DH-F2 (Orleans/Manila) */
952 case 0x6: /* rev DH-G1 */ 952 case 0x6: /* rev DH-G1 */
953 ret = "Athlon 64 or Sempron"; 953 ret = "Athlon 64 or Sempron";
954 break; 954 break;
955 } 955 }
956 break; 956 break;
957 default: 957 default:
958 ret = "Unknown AMD64 CPU"; 958 ret = "Unknown AMD64 CPU";
959 } 959 }
960 break; 960 break;
961 case 0x01: 961 case 0x01:
962 switch (model) { 962 switch (model) {
963 case 0x02: 963 case 0x02:
964 ret = "Family 10h"; 964 ret = "Family 10h";
965 break; 965 break;
966 default: 966 default:
967 ret = "Unknown AMD64 CPU"; 967 ret = "Unknown AMD64 CPU";
968 break; 968 break;
969 } 969 }
970 break; 970 break;
971 case 0x02: 971 case 0x02:
972 switch (model) { 972 switch (model) {
973 case 0x03: 973 case 0x03:
974 ret = "Family 11h"; 974 ret = "Family 11h";
975 break; 975 break;
976 default: 976 default:
977 ret = "Unknown AMD64 CPU"; 977 ret = "Unknown AMD64 CPU";
978 break; 978 break;
979 } 979 }
980 break; 980 break;
981 } 981 }
982 982
983 return ret; 983 return ret;
984} 984}
985 985
986static void 986static void
987cpu_probe_base_features(struct cpu_info *ci) 987cpu_probe_base_features(struct cpu_info *ci)
988{ 988{
989 const struct x86_cache_info *cai; 989 const struct x86_cache_info *cai;
990 u_int descs[4]; 990 u_int descs[4];
991 int iterations, i, j; 991 int iterations, i, j;
992 uint8_t desc; 992 uint8_t desc;
993 uint32_t miscbytes; 993 uint32_t miscbytes;
994 uint32_t brand[12]; 994 uint32_t brand[12];
995 995
996 if (ci->ci_cpuid_level < 0) 996 if (ci->ci_cpuid_level < 0)
997 return; 997 return;
998 998
999 x86_cpuid(0, descs); 999 x86_cpuid(0, descs);
1000 ci->ci_cpuid_level = descs[0]; 1000 ci->ci_cpuid_level = descs[0];
1001 ci->ci_vendor[0] = descs[1]; 1001 ci->ci_vendor[0] = descs[1];
1002 ci->ci_vendor[2] = descs[2]; 1002 ci->ci_vendor[2] = descs[2];
1003 ci->ci_vendor[1] = descs[3]; 1003 ci->ci_vendor[1] = descs[3];
1004 ci->ci_vendor[3] = 0; 1004 ci->ci_vendor[3] = 0;
1005 1005
1006 x86_cpuid(0x80000000, brand); 1006 x86_cpuid(0x80000000, brand);
1007 if (brand[0] >= 0x80000004) { 1007 if (brand[0] >= 0x80000004) {
1008 x86_cpuid(0x80000002, brand); 1008 x86_cpuid(0x80000002, brand);
1009 x86_cpuid(0x80000003, brand + 4); 1009 x86_cpuid(0x80000003, brand + 4);
1010 x86_cpuid(0x80000004, brand + 8); 1010 x86_cpuid(0x80000004, brand + 8);
1011 for (i = 0; i < 48; i++) 1011 for (i = 0; i < 48; i++)
1012 if (((char *) brand)[i] != ' ') 1012 if (((char *) brand)[i] != ' ')
1013 break; 1013 break;
1014 memcpy(cpu_brand_string, ((char *) brand) + i, 48 - i); 1014 memcpy(cpu_brand_string, ((char *) brand) + i, 48 - i);
1015 } 1015 }
1016 1016
1017 if (ci->ci_cpuid_level < 1) 1017 if (ci->ci_cpuid_level < 1)
1018 return; 1018 return;
1019 1019
1020 x86_cpuid(1, descs); 1020 x86_cpuid(1, descs);
1021 ci->ci_signature = descs[0]; 1021 ci->ci_signature = descs[0];
1022 miscbytes = descs[1]; 1022 miscbytes = descs[1];
1023 ci->ci_feat_val[1] = descs[2]; 1023 ci->ci_feat_val[1] = descs[2];
1024 ci->ci_feat_val[0] = descs[3]; 1024 ci->ci_feat_val[0] = descs[3];
1025 1025
1026 /* Brand is low order 8 bits of ebx */ 1026 /* Brand is low order 8 bits of ebx */
1027 ci->ci_brand_id = miscbytes & 0xff; 1027 ci->ci_brand_id = miscbytes & 0xff;
1028 ci->ci_initapicid = (miscbytes >> 24) & 0xff; 1028 ci->ci_initapicid = (miscbytes >> 24) & 0xff;
1029 if (ci->ci_cpuid_level < 2) 1029 if (ci->ci_cpuid_level < 2)
1030 return; 1030 return;
1031 1031
1032 /* 1032 /*
1033 * Parse the cache info from `cpuid', if we have it. 1033 * Parse the cache info from `cpuid', if we have it.
1034 * XXX This is kinda ugly, but hey, so is the architecture... 1034 * XXX This is kinda ugly, but hey, so is the architecture...
1035 */ 1035 */
1036 1036
1037 x86_cpuid(2, descs); 1037 x86_cpuid(2, descs);
1038 1038
1039 iterations = descs[0] & 0xff; 1039 iterations = descs[0] & 0xff;
1040 while (iterations-- > 0) { 1040 while (iterations-- > 0) {
1041 for (i = 0; i < 4; i++) { 1041 for (i = 0; i < 4; i++) {
1042 if (descs[i] & 0x80000000) 1042 if (descs[i] & 0x80000000)
1043 continue; 1043 continue;
1044 for (j = 0; j < 4; j++) { 1044 for (j = 0; j < 4; j++) {
1045 if (i == 0 && j == 0) 1045 if (i == 0 && j == 0)
1046 continue; 1046 continue;
1047 desc = (descs[i] >> (j * 8)) & 0xff; 1047 desc = (descs[i] >> (j * 8)) & 0xff;
1048 if (desc == 0) 1048 if (desc == 0)
1049 continue; 1049 continue;
1050 cai = cache_info_lookup(intel_cpuid_cache_info, 1050 cai = cache_info_lookup(intel_cpuid_cache_info,
1051 desc); 1051 desc);
1052 if (cai != NULL) 1052 if (cai != NULL)
1053 ci->ci_cinfo[cai->cai_index] = *cai; 1053 ci->ci_cinfo[cai->cai_index] = *cai;
1054 } 1054 }
1055 } 1055 }
1056 x86_cpuid(2, descs); 1056 x86_cpuid(2, descs);
1057 } 1057 }
1058 1058
1059 if (ci->ci_cpuid_level < 3) 1059 if (ci->ci_cpuid_level < 3)
1060 return; 1060 return;
1061 1061
1062 /* 1062 /*
1063 * If the processor serial number misfeature is present and supported, 1063 * If the processor serial number misfeature is present and supported,
1064 * extract it here. 1064 * extract it here.
1065 */ 1065 */
1066 if ((ci->ci_feat_val[0] & CPUID_PN) != 0) { 1066 if ((ci->ci_feat_val[0] & CPUID_PN) != 0) {
1067 ci->ci_cpu_serial[0] = ci->ci_signature; 1067 ci->ci_cpu_serial[0] = ci->ci_signature;
1068 x86_cpuid(3, descs); 1068 x86_cpuid(3, descs);
1069 ci->ci_cpu_serial[2] = descs[2]; 1069 ci->ci_cpu_serial[2] = descs[2];
1070 ci->ci_cpu_serial[1] = descs[3]; 1070 ci->ci_cpu_serial[1] = descs[3];
1071 } 1071 }
1072} 1072}
1073 1073
1074static void 1074static void
1075cpu_probe_features(struct cpu_info *ci) 1075cpu_probe_features(struct cpu_info *ci)
1076{ 1076{
1077 const struct cpu_cpuid_nameclass *cpup = NULL; 1077 const struct cpu_cpuid_nameclass *cpup = NULL;
1078 int i, xmax, family; 1078 int i, xmax, family;
1079 1079
1080 cpu_probe_base_features(ci); 1080 cpu_probe_base_features(ci);
1081 1081
1082 if (ci->ci_cpuid_level < 1) 1082 if (ci->ci_cpuid_level < 1)
1083 return; 1083 return;
1084 1084
1085 xmax = __arraycount(i386_cpuid_cpus); 1085 xmax = __arraycount(i386_cpuid_cpus);
1086 for (i = 0; i < xmax; i++) { 1086 for (i = 0; i < xmax; i++) {
1087 if (!strncmp((char *)ci->ci_vendor, 1087 if (!strncmp((char *)ci->ci_vendor,
1088 i386_cpuid_cpus[i].cpu_id, 12)) { 1088 i386_cpuid_cpus[i].cpu_id, 12)) {
1089 cpup = &i386_cpuid_cpus[i]; 1089 cpup = &i386_cpuid_cpus[i];
1090 break; 1090 break;
1091 } 1091 }
1092 } 1092 }
1093 1093
1094 if (cpup == NULL) 1094 if (cpup == NULL)
1095 return; 1095 return;
1096 1096
1097 family = (ci->ci_signature >> 8) & 0xf; 1097 family = (ci->ci_signature >> 8) & 0xf;
1098 1098
1099 if (family > CPU_MAXFAMILY) { 1099 if (family > CPU_MAXFAMILY) {
1100 family = CPU_MAXFAMILY; 1100 family = CPU_MAXFAMILY;
1101 } 1101 }
1102 i = family - CPU_MINFAMILY; 1102 i = family - CPU_MINFAMILY;
1103 1103
1104 if (cpup->cpu_family[i].cpu_probe == NULL) 1104 if (cpup->cpu_family[i].cpu_probe == NULL)
1105 return; 1105 return;
1106 1106
1107 (*cpup->cpu_family[i].cpu_probe)(ci); 1107 (*cpup->cpu_family[i].cpu_probe)(ci);
1108} 1108}
1109 1109
1110static void 1110static void
1111intel_family_new_probe(struct cpu_info *ci) 1111intel_family_new_probe(struct cpu_info *ci)
1112{ 1112{
1113 uint32_t descs[4]; 1113 uint32_t descs[4];
1114 1114
1115 x86_cpuid(0x80000000, descs); 1115 x86_cpuid(0x80000000, descs);
1116 1116
1117 /* 1117 /*
1118 * Determine extended feature flags. 1118 * Determine extended feature flags.
1119 */ 1119 */
1120 if (descs[0] >= 0x80000001) { 1120 if (descs[0] >= 0x80000001) {
1121 x86_cpuid(0x80000001, descs); 1121 x86_cpuid(0x80000001, descs);
1122 ci->ci_feat_val[2] |= descs[3]; 1122 ci->ci_feat_val[2] |= descs[3];
1123 ci->ci_feat_val[3] |= descs[2]; 1123 ci->ci_feat_val[3] |= descs[2];
1124 } 1124 }
1125} 1125}
1126 1126
1127static void 1127static void
1128amd_family6_probe(struct cpu_info *ci) 1128amd_family6_probe(struct cpu_info *ci)
1129{ 1129{
1130 uint32_t descs[4]; 1130 uint32_t descs[4];
1131 char *p; 1131 char *p;
1132 size_t i; 1132 size_t i;
1133 1133
1134 x86_cpuid(0x80000000, descs); 1134 x86_cpuid(0x80000000, descs);
1135 1135
1136 /* 1136 /*
1137 * Determine the extended feature flags. 1137 * Determine the extended feature flags.
1138 */ 1138 */
1139 if (descs[0] >= 0x80000001) { 1139 if (descs[0] >= 0x80000001) {
1140 x86_cpuid(0x80000001, descs); 1140 x86_cpuid(0x80000001, descs);
1141 ci->ci_feat_val[2] |= descs[3]; /* %edx */ 1141 ci->ci_feat_val[2] |= descs[3]; /* %edx */
1142 ci->ci_feat_val[3] = descs[2]; /* %ecx */ 1142 ci->ci_feat_val[3] = descs[2]; /* %ecx */
1143 } 1143 }
1144 1144
1145 if (*cpu_brand_string == '\0') 1145 if (*cpu_brand_string == '\0')
1146 return; 1146 return;
1147  1147
1148 for (i = 1; i < __arraycount(amd_brand); i++) 1148 for (i = 1; i < __arraycount(amd_brand); i++)
1149 if ((p = strstr(cpu_brand_string, amd_brand[i])) != NULL) { 1149 if ((p = strstr(cpu_brand_string, amd_brand[i])) != NULL) {
1150 ci->ci_brand_id = i; 1150 ci->ci_brand_id = i;
1151 strlcpy(amd_brand_name, p, sizeof(amd_brand_name)); 1151 strlcpy(amd_brand_name, p, sizeof(amd_brand_name));
1152 break; 1152 break;
1153 } 1153 }
1154} 1154}
1155 1155
1156static void 1156static void
1157amd_family5_setup(struct cpu_info *ci) 1157amd_family5_setup(struct cpu_info *ci)
1158{ 1158{
1159 1159
1160 switch (CPUID2MODEL(ci->ci_signature)) { 1160 switch (CPUID2MODEL(ci->ci_signature)) {
1161 case 0: /* AMD-K5 Model 0 */ 1161 case 0: /* AMD-K5 Model 0 */
1162 /* 1162 /*
1163 * According to the AMD Processor Recognition App Note, 1163 * According to the AMD Processor Recognition App Note,
1164 * the AMD-K5 Model 0 uses the wrong bit to indicate 1164 * the AMD-K5 Model 0 uses the wrong bit to indicate
1165 * support for global PTEs, instead using bit 9 (APIC) 1165 * support for global PTEs, instead using bit 9 (APIC)
1166 * rather than bit 13 (i.e. "0x200" vs. 0x2000". Oops!). 1166 * rather than bit 13 (i.e. "0x200" vs. 0x2000". Oops!).
1167 */ 1167 */
1168 if (ci->ci_feat_val[0] & CPUID_APIC) 1168 if (ci->ci_feat_val[0] & CPUID_APIC)
1169 ci->ci_feat_val[0] = 1169 ci->ci_feat_val[0] =
1170 (ci->ci_feat_val[0] & ~CPUID_APIC) | CPUID_PGE; 1170 (ci->ci_feat_val[0] & ~CPUID_APIC) | CPUID_PGE;
1171 /* 1171 /*
1172 * XXX But pmap_pg_g is already initialized -- need to kick 1172 * XXX But pmap_pg_g is already initialized -- need to kick
1173 * XXX the pmap somehow. How does the MP branch do this? 1173 * XXX the pmap somehow. How does the MP branch do this?
1174 */ 1174 */
1175 break; 1175 break;
1176 } 1176 }
1177} 1177}
1178 1178
1179static void 1179static void
1180tmx86_get_longrun_status(u_int *frequency, u_int *voltage, u_int *percentage) 1180tmx86_get_longrun_status(u_int *frequency, u_int *voltage, u_int *percentage)
1181{ 1181{
1182 u_int descs[4]; 1182 u_int descs[4];
1183 1183
1184 x86_cpuid(0x80860007, descs); 1184 x86_cpuid(0x80860007, descs);
1185 *frequency = descs[0]; 1185 *frequency = descs[0];
1186 *voltage = descs[1]; 1186 *voltage = descs[1];
1187 *percentage = descs[2]; 1187 *percentage = descs[2];
1188} 1188}
1189 1189
1190static void 1190static void
1191transmeta_cpu_info(struct cpu_info *ci) 1191transmeta_cpu_info(struct cpu_info *ci)
1192{ 1192{
1193 u_int descs[4], nreg; 1193 u_int descs[4], nreg;
1194 u_int frequency, voltage, percentage; 1194 u_int frequency, voltage, percentage;
1195 1195
1196 x86_cpuid(0x80860000, descs); 1196 x86_cpuid(0x80860000, descs);
1197 nreg = descs[0]; 1197 nreg = descs[0];
1198 if (nreg >= 0x80860001) { 1198 if (nreg >= 0x80860001) {
1199 x86_cpuid(0x80860001, descs); 1199 x86_cpuid(0x80860001, descs);
1200 aprint_verbose_dev(ci->ci_dev, "Processor revision %u.%u.%u.%u\n", 1200 aprint_verbose_dev(ci->ci_dev, "Processor revision %u.%u.%u.%u\n",
1201 (descs[1] >> 24) & 0xff, 1201 (descs[1] >> 24) & 0xff,
1202 (descs[1] >> 16) & 0xff, 1202 (descs[1] >> 16) & 0xff,
1203 (descs[1] >> 8) & 0xff, 1203 (descs[1] >> 8) & 0xff,
1204 descs[1] & 0xff); 1204 descs[1] & 0xff);
1205 } 1205 }
1206 if (nreg >= 0x80860002) { 1206 if (nreg >= 0x80860002) {
1207 x86_cpuid(0x80860002, descs); 1207 x86_cpuid(0x80860002, descs);
1208 aprint_verbose_dev(ci->ci_dev, "Code Morphing Software Rev: %u.%u.%u-%u-%u\n", 1208 aprint_verbose_dev(ci->ci_dev, "Code Morphing Software Rev: %u.%u.%u-%u-%u\n",
1209 (descs[1] >> 24) & 0xff, 1209 (descs[1] >> 24) & 0xff,
1210 (descs[1] >> 16) & 0xff, 1210 (descs[1] >> 16) & 0xff,
1211 (descs[1] >> 8) & 0xff, 1211 (descs[1] >> 8) & 0xff,
1212 descs[1] & 0xff, 1212 descs[1] & 0xff,
1213 descs[2]); 1213 descs[2]);
1214 } 1214 }
1215 if (nreg >= 0x80860006) { 1215 if (nreg >= 0x80860006) {
1216 union { 1216 union {
1217 char text[65]; 1217 char text[65];
1218 u_int descs[4][4]; 1218 u_int descs[4][4];
1219 } info; 1219 } info;
1220 int i; 1220 int i;
1221 1221
1222 for (i=0; i<4; i++) { 1222 for (i=0; i<4; i++) {
1223 x86_cpuid(0x80860003 + i, info.descs[i]); 1223 x86_cpuid(0x80860003 + i, info.descs[i]);
1224 } 1224 }
1225 info.text[64] = '\0'; 1225 info.text[64] = '\0';
1226 aprint_verbose_dev(ci->ci_dev, "%s\n", info.text); 1226 aprint_verbose_dev(ci->ci_dev, "%s\n", info.text);
1227 } 1227 }
1228 1228
1229 if (nreg >= 0x80860007) { 1229 if (nreg >= 0x80860007) {
1230 tmx86_get_longrun_status(&frequency, 1230 tmx86_get_longrun_status(&frequency,
1231 &voltage, &percentage); 1231 &voltage, &percentage);
1232 aprint_verbose_dev(ci->ci_dev, "LongRun <%dMHz %dmV %d%%>\n", 1232 aprint_verbose_dev(ci->ci_dev, "LongRun <%dMHz %dmV %d%%>\n",
1233 frequency, voltage, percentage); 1233 frequency, voltage, percentage);
1234 } 1234 }
1235} 1235}
1236 1236
1237void 1237void
1238identifycpu(const char *cpuname) 1238identifycpu(const char *cpuname)
1239{ 1239{
1240 const char *name = "", *modifier, *vendorname, *brand = ""; 1240 const char *name = "", *modifier, *vendorname, *brand = "";
1241 int class = CPUCLASS_386, i, xmax; 1241 int class = CPUCLASS_386, i, xmax;
1242 int modif, family, model, ext_model; 1242 int modif, family, model, ext_model;
1243 const struct cpu_extend_nameclass *modlist; 1243 const struct cpu_extend_nameclass *modlist;
1244 const struct cpu_cpuid_nameclass *cpup = NULL; 1244 const struct cpu_cpuid_nameclass *cpup = NULL;
1245 const struct cpu_cpuid_family *cpufam; 1245 const struct cpu_cpuid_family *cpufam;
1246 const char *feature_str[5]; 1246 const char *feature_str[5];
1247 struct cpu_info *ci, cistore; 1247 struct cpu_info *ci, cistore;
1248 extern int cpu; 1248 extern int cpu;
1249 extern int cpu_info_level; 1249 extern int cpu_info_level;
1250 size_t sz; 1250 size_t sz;
1251 char buf[512]; 1251 char buf[512];
1252 char *bp; 1252 char *bp;
1253 1253
1254 ci = &cistore; 1254 ci = &cistore;
1255 memset(ci, 0, sizeof(*ci)); 1255 memset(ci, 0, sizeof(*ci));
1256 ci->ci_dev = cpuname; 1256 ci->ci_dev = cpuname;
1257 1257
1258 x86_identify(); 1258 x86_identify();
1259 ci->ci_cpuid_level = cpu_info_level; 1259 ci->ci_cpuid_level = cpu_info_level;
1260 cpu_probe_features(ci); 1260 cpu_probe_features(ci);
1261 1261
1262 if (ci->ci_cpuid_level == -1) { 1262 if (ci->ci_cpuid_level == -1) {
1263 if ((size_t)cpu >= __arraycount(i386_nocpuid_cpus)) 1263 if ((size_t)cpu >= __arraycount(i386_nocpuid_cpus))
1264 errx(1, "unknown cpu type %d", cpu); 1264 errx(1, "unknown cpu type %d", cpu);
1265 name = i386_nocpuid_cpus[cpu].cpu_name; 1265 name = i386_nocpuid_cpus[cpu].cpu_name;
1266 cpu_vendor = i386_nocpuid_cpus[cpu].cpu_vendor; 1266 cpu_vendor = i386_nocpuid_cpus[cpu].cpu_vendor;
1267 vendorname = i386_nocpuid_cpus[cpu].cpu_vendorname; 1267 vendorname = i386_nocpuid_cpus[cpu].cpu_vendorname;
1268 class = i386_nocpuid_cpus[cpu].cpu_class; 1268 class = i386_nocpuid_cpus[cpu].cpu_class;
1269 ci->ci_info = i386_nocpuid_cpus[cpu].cpu_info; 1269 ci->ci_info = i386_nocpuid_cpus[cpu].cpu_info;
1270 modifier = ""; 1270 modifier = "";
1271 } else { 1271 } else {
1272 xmax = __arraycount(i386_cpuid_cpus); 1272 xmax = __arraycount(i386_cpuid_cpus);
1273 modif = (ci->ci_signature >> 12) & 0x3; 1273 modif = (ci->ci_signature >> 12) & 0x3;
1274 family = CPUID2FAMILY(ci->ci_signature); 1274 family = CPUID2FAMILY(ci->ci_signature);
1275 if (family < CPU_MINFAMILY) 1275 if (family < CPU_MINFAMILY)
1276 errx(1, "identifycpu: strange family value"); 1276 errx(1, "identifycpu: strange family value");
1277 model = CPUID2MODEL(ci->ci_signature); 1277 model = CPUID2MODEL(ci->ci_signature);
1278 ext_model = CPUID2EXTMODEL(ci->ci_signature); 1278 ext_model = CPUID2EXTMODEL(ci->ci_signature);
1279 1279
1280 for (i = 0; i < xmax; i++) { 1280 for (i = 0; i < xmax; i++) {
1281 if (!strncmp((char *)ci->ci_vendor, 1281 if (!strncmp((char *)ci->ci_vendor,
1282 i386_cpuid_cpus[i].cpu_id, 12)) { 1282 i386_cpuid_cpus[i].cpu_id, 12)) {
1283 cpup = &i386_cpuid_cpus[i]; 1283 cpup = &i386_cpuid_cpus[i];
1284 break; 1284 break;
1285 } 1285 }
1286 } 1286 }
1287 1287
1288 if (cpup == NULL) { 1288 if (cpup == NULL) {
1289 cpu_vendor = CPUVENDOR_UNKNOWN; 1289 cpu_vendor = CPUVENDOR_UNKNOWN;
1290 if (ci->ci_vendor[0] != '\0') 1290 if (ci->ci_vendor[0] != '\0')
1291 vendorname = (char *)&ci->ci_vendor[0]; 1291 vendorname = (char *)&ci->ci_vendor[0];
1292 else 1292 else
1293 vendorname = "Unknown"; 1293 vendorname = "Unknown";
1294 if (family >= CPU_MAXFAMILY) 1294 if (family >= CPU_MAXFAMILY)
1295 family = CPU_MINFAMILY; 1295 family = CPU_MINFAMILY;
1296 class = family - 3; 1296 class = family - 3;
1297 modifier = ""; 1297 modifier = "";
1298 name = ""; 1298 name = "";
1299 ci->ci_info = NULL; 1299 ci->ci_info = NULL;
1300 } else { 1300 } else {
1301 cpu_vendor = cpup->cpu_vendor; 1301 cpu_vendor = cpup->cpu_vendor;
1302 vendorname = cpup->cpu_vendorname; 1302 vendorname = cpup->cpu_vendorname;
1303 modifier = modifiers[modif]; 1303 modifier = modifiers[modif];
1304 if (family > CPU_MAXFAMILY) { 1304 if (family > CPU_MAXFAMILY) {
1305 family = CPU_MAXFAMILY; 1305 family = CPU_MAXFAMILY;
1306 model = CPU_DEFMODEL; 1306 model = CPU_DEFMODEL;
1307 } else if (model > CPU_MAXMODEL) { 1307 } else if (model > CPU_MAXMODEL) {
1308 model = CPU_DEFMODEL; 1308 model = CPU_DEFMODEL;
1309 ext_model = 0; 1309 ext_model = 0;
1310 } 1310 }
1311 cpufam = &cpup->cpu_family[family - CPU_MINFAMILY]; 1311 cpufam = &cpup->cpu_family[family - CPU_MINFAMILY];
1312 if (cpufam->cpu_extended_names == NULL || 1312 if (cpufam->cpu_extended_names == NULL ||
1313 ext_model == 0) 1313 ext_model == 0)
1314 name = cpufam->cpu_models[model]; 1314 name = cpufam->cpu_models[model];
1315 else { 1315 else {
1316 /* 1316 /*
1317 * Scan list(s) of extended model names 1317 * Scan list(s) of extended model names
1318 */ 1318 */
1319 modlist = cpufam->cpu_extended_names; 1319 modlist = cpufam->cpu_extended_names;
1320 while (modlist->ext_model != 0) { 1320 while (modlist->ext_model != 0) {
1321 if (modlist->ext_model == ext_model) { 1321 if (modlist->ext_model == ext_model) {
1322 name = 1322 name =
1323 modlist->cpu_models[model]; 1323 modlist->cpu_models[model];
1324 break; 1324 break;
1325 } 1325 }
1326 modlist++; 1326 modlist++;
1327 } 1327 }
1328 } 1328 }
1329 if (name == NULL || *name == '\0') 1329 if (name == NULL || *name == '\0')
1330 name = cpufam->cpu_models[CPU_DEFMODEL]; 1330 name = cpufam->cpu_models[CPU_DEFMODEL];
1331 class = cpufam->cpu_class; 1331 class = cpufam->cpu_class;
1332 ci->ci_info = cpufam->cpu_info; 1332 ci->ci_info = cpufam->cpu_info;
1333 1333
1334 if (cpu_vendor == CPUVENDOR_INTEL) { 1334 if (cpu_vendor == CPUVENDOR_INTEL) {
1335 if (family == 6 && model >= 5) { 1335 if (family == 6 && model >= 5) {
1336 const char *tmp; 1336 const char *tmp;
1337 tmp = intel_family6_name(ci); 1337 tmp = intel_family6_name(ci);
1338 if (tmp != NULL) 1338 if (tmp != NULL)
1339 name = tmp; 1339 name = tmp;
1340 } 1340 }
1341 if (family == CPU_MAXFAMILY && 1341 if (family == CPU_MAXFAMILY &&
1342 ci->ci_brand_id < 1342 ci->ci_brand_id <
1343 __arraycount(i386_intel_brand) && 1343 __arraycount(i386_intel_brand) &&
1344 i386_intel_brand[ci->ci_brand_id]) 1344 i386_intel_brand[ci->ci_brand_id])
1345 name = 1345 name =
1346 i386_intel_brand[ci->ci_brand_id]; 1346 i386_intel_brand[ci->ci_brand_id];
1347 } 1347 }
1348 1348
1349 if (cpu_vendor == CPUVENDOR_AMD) { 1349 if (cpu_vendor == CPUVENDOR_AMD) {
1350 if (family == 6 && model >= 6) { 1350 if (family == 6 && model >= 6) {
1351 if (ci->ci_brand_id == 1) 1351 if (ci->ci_brand_id == 1)
1352 /*  1352 /*
1353 * It's Duron. We override the  1353 * It's Duron. We override the
1354 * name, since it might have 1354 * name, since it might have
1355 * been misidentified as Athlon. 1355 * been misidentified as Athlon.
1356 */ 1356 */
1357 name = 1357 name =
1358 amd_brand[ci->ci_brand_id]; 1358 amd_brand[ci->ci_brand_id];
1359 else 1359 else
1360 brand = amd_brand_name; 1360 brand = amd_brand_name;
1361 } 1361 }
1362 if (CPUID2FAMILY(ci->ci_signature) == 0xf) { 1362 if (CPUID2FAMILY(ci->ci_signature) == 0xf) {
1363 /* 1363 /*
1364 * Identify AMD64 CPU names. 1364 * Identify AMD64 CPU names.
1365 * Note family value is clipped by 1365 * Note family value is clipped by
1366 * CPU_MAXFAMILY. 1366 * CPU_MAXFAMILY.
1367 */ 1367 */
1368 const char *tmp; 1368 const char *tmp;
1369 tmp = amd_amd64_name(ci); 1369 tmp = amd_amd64_name(ci);
1370 if (tmp != NULL) 1370 if (tmp != NULL)
1371 name = tmp; 1371 name = tmp;
1372 } 1372 }
1373 } 1373 }
1374  1374
1375 if (cpu_vendor == CPUVENDOR_IDT && family >= 6) 1375 if (cpu_vendor == CPUVENDOR_IDT && family >= 6)
1376 vendorname = "VIA"; 1376 vendorname = "VIA";
1377 } 1377 }
1378 } 1378 }
1379 1379
1380 ci->ci_cpu_class = class; 1380 ci->ci_cpu_class = class;
1381 1381
1382 sz = sizeof(ci->ci_tsc_freq); 1382 sz = sizeof(ci->ci_tsc_freq);
1383 (void)sysctlbyname("machdep.tsc_freq", &ci->ci_tsc_freq, &sz, NULL, 0); 1383 (void)sysctlbyname("machdep.tsc_freq", &ci->ci_tsc_freq, &sz, NULL, 0);
1384 sz = sizeof(use_pae); 1384 sz = sizeof(use_pae);
1385 (void)sysctlbyname("machdep.pae", &use_pae, &sz, NULL, 0); 1385 (void)sysctlbyname("machdep.pae", &use_pae, &sz, NULL, 0);
1386 largepagesize = (use_pae ? 2 * 1024 * 1024 : 4 * 1024 * 1024); 1386 largepagesize = (use_pae ? 2 * 1024 * 1024 : 4 * 1024 * 1024);
1387 1387
1388 snprintf(cpu_model, sizeof(cpu_model), "%s%s%s%s%s%s%s (%s-class)", 1388 snprintf(cpu_model, sizeof(cpu_model), "%s%s%s%s%s%s%s (%s-class)",
1389 vendorname, 1389 vendorname,
1390 *modifier ? " " : "", modifier, 1390 *modifier ? " " : "", modifier,
1391 *name ? " " : "", name, 1391 *name ? " " : "", name,
1392 *brand ? " " : "", brand, 1392 *brand ? " " : "", brand,
1393 classnames[class]); 1393 classnames[class]);
1394 aprint_normal("%s: %s", cpuname, cpu_model); 1394 aprint_normal("%s: %s", cpuname, cpu_model);
1395 1395
1396 if (ci->ci_tsc_freq != 0) 1396 if (ci->ci_tsc_freq != 0)
1397 aprint_normal(", %ju.%02ju MHz", 1397 aprint_normal(", %ju.%02ju MHz",
1398 ((uintmax_t)ci->ci_tsc_freq + 4999) / 1000000, 1398 ((uintmax_t)ci->ci_tsc_freq + 4999) / 1000000,
1399 (((uintmax_t)ci->ci_tsc_freq + 4999) / 10000) % 100); 1399 (((uintmax_t)ci->ci_tsc_freq + 4999) / 10000) % 100);
1400 if (ci->ci_signature != 0) 1400 if (ci->ci_signature != 0)
1401 aprint_normal(", id 0x%x", ci->ci_signature); 1401 aprint_normal(", id 0x%x", ci->ci_signature);
1402 aprint_normal("\n"); 1402 aprint_normal("\n");
1403 1403
1404 if (ci->ci_info) 1404 if (ci->ci_info)
1405 (*ci->ci_info)(ci); 1405 (*ci->ci_info)(ci);
1406 1406
1407 /* 1407 /*
1408 * display CPU feature flags 1408 * display CPU feature flags
1409 */ 1409 */
1410 1410
1411#define MAX_FEATURE_LEN 60 /* XXX Need to find a better way to set this */ 1411#define MAX_FEATURE_LEN 60 /* XXX Need to find a better way to set this */
1412 1412
1413 feature_str[0] = CPUID_FLAGS1; 1413 feature_str[0] = CPUID_FLAGS1;
1414 feature_str[1] = CPUID2_FLAGS1; 1414 feature_str[1] = CPUID2_FLAGS1;
1415 feature_str[2] = CPUID_EXT_FLAGS; 1415 feature_str[2] = CPUID_EXT_FLAGS;
1416 feature_str[3] = NULL; 1416 feature_str[3] = NULL;
1417 feature_str[4] = NULL; 1417 feature_str[4] = NULL;
1418 1418
1419 switch (cpu_vendor) { 1419 switch (cpu_vendor) {
1420 case CPUVENDOR_AMD: 1420 case CPUVENDOR_AMD:
1421 feature_str[3] = CPUID_AMD_FLAGS4; 1421 feature_str[3] = CPUID_AMD_FLAGS4;
1422 break; 1422 break;
1423 case CPUVENDOR_INTEL: 1423 case CPUVENDOR_INTEL:
1424 feature_str[2] = CPUID_INTEL_EXT_FLAGS; 1424 feature_str[2] = CPUID_INTEL_EXT_FLAGS;
1425 feature_str[3] = CPUID_INTEL_FLAGS4; 1425 feature_str[3] = CPUID_INTEL_FLAGS4;
1426 break; 1426 break;
1427 case CPUVENDOR_IDT: 1427 case CPUVENDOR_IDT:
1428 feature_str[4] = CPUID_FLAGS_PADLOCK; 1428 feature_str[4] = CPUID_FLAGS_PADLOCK;
1429 break; 1429 break;
1430 default: 1430 default:
1431 break; 1431 break;
1432 } 1432 }
1433  1433
1434 for (i = 0; i <= 4; i++) { 1434 for (i = 0; i <= 4; i++) {
1435 if (ci->ci_feat_val[i] && feature_str[i] != NULL) { 1435 if (ci->ci_feat_val[i] && feature_str[i] != NULL) {
1436 snprintb_m(buf, sizeof(buf), feature_str[i], 1436 snprintb_m(buf, sizeof(buf), feature_str[i],
1437 ci->ci_feat_val[i], MAX_FEATURE_LEN); 1437 ci->ci_feat_val[i], MAX_FEATURE_LEN);
1438 bp = buf; 1438 bp = buf;
1439 while (*bp != '\0') { 1439 while (*bp != '\0') {
1440 aprint_verbose("%s: %sfeatures%c %s\n", 1440 aprint_verbose("%s: %sfeatures%c %s\n",
1441 cpuname, (i == 4)?"padlock ":"",  1441 cpuname, (i == 4)?"padlock ":"",
1442 (i == 4 || i == 0)?' ':'1' + i, bp); 1442 (i == 4 || i == 0)?' ':'1' + i, bp);
1443 bp += strlen(bp) + 1; 1443 bp += strlen(bp) + 1;
1444 } 1444 }
1445 } 1445 }
1446 } 1446 }
1447 1447
1448 if (*cpu_brand_string != '\0') 1448 if (*cpu_brand_string != '\0')
1449 aprint_normal("%s: \"%s\"\n", cpuname, cpu_brand_string); 1449 aprint_normal("%s: \"%s\"\n", cpuname, cpu_brand_string);
1450 1450
1451 x86_print_cacheinfo(ci); 1451 x86_print_cacheinfo(ci);
1452 1452
1453 if (ci->ci_cpuid_level >= 3 && (ci->ci_feat_val[0] & CPUID_PN)) { 1453 if (ci->ci_cpuid_level >= 3 && (ci->ci_feat_val[0] & CPUID_PN)) {
1454 aprint_verbose("%s: serial number %04X-%04X-%04X-%04X-%04X-%04X\n", 1454 aprint_verbose("%s: serial number %04X-%04X-%04X-%04X-%04X-%04X\n",
1455 cpuname, 1455 cpuname,
1456 ci->ci_cpu_serial[0] / 65536, ci->ci_cpu_serial[0] % 65536, 1456 ci->ci_cpu_serial[0] / 65536, ci->ci_cpu_serial[0] % 65536,
1457 ci->ci_cpu_serial[1] / 65536, ci->ci_cpu_serial[1] % 65536, 1457 ci->ci_cpu_serial[1] / 65536, ci->ci_cpu_serial[1] % 65536,
1458 ci->ci_cpu_serial[2] / 65536, ci->ci_cpu_serial[2] % 65536); 1458 ci->ci_cpu_serial[2] / 65536, ci->ci_cpu_serial[2] % 65536);
1459 } 1459 }
1460 1460
1461 if (ci->ci_cpu_class == CPUCLASS_386) { 1461 if (ci->ci_cpu_class == CPUCLASS_386) {
1462 errx(1, "NetBSD requires an 80486 or later processor"); 1462 errx(1, "NetBSD requires an 80486 or later processor");
1463 } 1463 }
1464 1464
1465 if (cpu == CPU_486DLC) { 1465 if (cpu == CPU_486DLC) {
1466#ifndef CYRIX_CACHE_WORKS 1466#ifndef CYRIX_CACHE_WORKS
1467 aprint_error("WARNING: CYRIX 486DLC CACHE UNCHANGED.\n"); 1467 aprint_error("WARNING: CYRIX 486DLC CACHE UNCHANGED.\n");
1468#else 1468#else
1469#ifndef CYRIX_CACHE_REALLY_WORKS 1469#ifndef CYRIX_CACHE_REALLY_WORKS
1470 aprint_error("WARNING: CYRIX 486DLC CACHE ENABLED IN HOLD-FLUSH MODE.\n"); 1470 aprint_error("WARNING: CYRIX 486DLC CACHE ENABLED IN HOLD-FLUSH MODE.\n");
1471#else 1471#else
1472 aprint_error("WARNING: CYRIX 486DLC CACHE ENABLED.\n"); 1472 aprint_error("WARNING: CYRIX 486DLC CACHE ENABLED.\n");
1473#endif 1473#endif
1474#endif 1474#endif
1475 } 1475 }
1476 1476
1477 /* 1477 /*
1478 * Everything past this point requires a Pentium or later. 1478 * Everything past this point requires a Pentium or later.
1479 */ 1479 */
1480 if (ci->ci_cpuid_level < 0) 1480 if (ci->ci_cpuid_level < 0)
1481 return; 1481 return;
1482 1482
1483 identifycpu_cpuids(ci); 1483 identifycpu_cpuids(ci);
1484 1484
1485#ifdef INTEL_CORETEMP 1485#ifdef INTEL_CORETEMP
1486 if (cpu_vendor == CPUVENDOR_INTEL && ci->ci_cpuid_level >= 0x06) 1486 if (cpu_vendor == CPUVENDOR_INTEL && ci->ci_cpuid_level >= 0x06)
1487 coretemp_register(ci); 1487 coretemp_register(ci);
1488#endif 1488#endif
1489 1489
1490 if (cpu_vendor == CPUVENDOR_AMD) { 1490 if (cpu_vendor == CPUVENDOR_AMD) {
1491 uint32_t data[4]; 1491 uint32_t data[4];
1492 1492
1493 x86_cpuid(0x80000000, data); 1493 x86_cpuid(0x80000000, data);
1494 if (data[0] >= 0x80000007) 1494 if (data[0] >= 0x80000007)
1495 powernow_probe(ci); 1495 powernow_probe(ci);
1496 1496
1497 if ((data[0] >= 0x8000000a) 1497 if ((data[0] >= 0x8000000a)
1498 && (ci->ci_feat_val[3] & CPUID_SVM) != 0) { 1498 && (ci->ci_feat_val[3] & CPUID_SVM) != 0) {
1499 1499
1500 x86_cpuid(0x8000000a, data); 1500 x86_cpuid(0x8000000a, data);
1501 aprint_verbose("%s: SVM Rev. %d\n", cpuname, 1501 aprint_verbose("%s: SVM Rev. %d\n", cpuname,
1502 data[0] & 0xf); 1502 data[0] & 0xf);
1503 aprint_verbose("%s: SVM NASID %d\n", cpuname, data[1]); 1503 aprint_verbose("%s: SVM NASID %d\n", cpuname, data[1]);
1504 snprintb_m(buf, sizeof(buf), CPUID_AMD_SVM_FLAGS, 1504 snprintb_m(buf, sizeof(buf), CPUID_AMD_SVM_FLAGS,
1505 data[3], MAX_FEATURE_LEN); 1505 data[3], MAX_FEATURE_LEN);
1506 bp = buf; 1506 bp = buf;
1507 while (*bp != '\0') { 1507 while (*bp != '\0') {
1508 aprint_verbose("%s: SVM features %s\n", 1508 aprint_verbose("%s: SVM features %s\n",
1509 cpuname, bp); 1509 cpuname, bp);
1510 bp += strlen(bp) + 1; 1510 bp += strlen(bp) + 1;
1511 } 1511 }
1512 } 1512 }
1513 } 1513 }
1514 1514
1515#ifdef INTEL_ONDEMAND_CLOCKMOD 1515#ifdef INTEL_ONDEMAND_CLOCKMOD
1516 clockmod_init(); 1516 clockmod_init();
1517#endif 1517#endif
1518 1518
1519 aprint_normal_dev(ci->ci_dev, "family %02x model %02x " 1519 aprint_normal_dev(ci->ci_dev, "family %02x model %02x "
1520 "extfamily %02x extmodel %02x\n", CPUID2FAMILY(ci->ci_signature), 1520 "extfamily %02x extmodel %02x stepping %02x\n",
1521 CPUID2MODEL(ci->ci_signature), CPUID2EXTFAMILY(ci->ci_signature), 1521 CPUID2FAMILY(ci->ci_signature), CPUID2MODEL(ci->ci_signature),
1522 CPUID2EXTMODEL(ci->ci_signature)); 1522 CPUID2EXTFAMILY(ci->ci_signature), CPUID2EXTMODEL(ci->ci_signature),
 1523 CPUID2STEPPING(ci->ci_signature));
1523} 1524}
1524 1525
1525static const char * 1526static const char *
1526print_cache_config(struct cpu_info *ci, int cache_tag, const char *name, 1527print_cache_config(struct cpu_info *ci, int cache_tag, const char *name,
1527 const char *sep) 1528 const char *sep)
1528{ 1529{
1529 struct x86_cache_info *cai = &ci->ci_cinfo[cache_tag]; 1530 struct x86_cache_info *cai = &ci->ci_cinfo[cache_tag];
1530 char human_num[HUMAN_BUFSIZE]; 1531 char human_num[HUMAN_BUFSIZE];
1531 1532
1532 if (cai->cai_totalsize == 0) 1533 if (cai->cai_totalsize == 0)
1533 return sep; 1534 return sep;
1534 1535
1535 if (sep == NULL) 1536 if (sep == NULL)
1536 aprint_verbose_dev(ci->ci_dev, ""); 1537 aprint_verbose_dev(ci->ci_dev, "");
1537 else 1538 else
1538 aprint_verbose("%s", sep); 1539 aprint_verbose("%s", sep);
1539 if (name != NULL) 1540 if (name != NULL)
1540 aprint_verbose("%s ", name); 1541 aprint_verbose("%s ", name);
1541 1542
1542 if (cai->cai_string != NULL) { 1543 if (cai->cai_string != NULL) {
1543 aprint_verbose("%s ", cai->cai_string); 1544 aprint_verbose("%s ", cai->cai_string);
1544 } else { 1545 } else {
1545 (void)humanize_number(human_num, sizeof(human_num), 1546 (void)humanize_number(human_num, sizeof(human_num),
1546 cai->cai_totalsize, "B", HN_AUTOSCALE, HN_NOSPACE); 1547 cai->cai_totalsize, "B", HN_AUTOSCALE, HN_NOSPACE);
1547 aprint_verbose("%s %dB/line ", human_num, cai->cai_linesize); 1548 aprint_verbose("%s %dB/line ", human_num, cai->cai_linesize);
1548 } 1549 }
1549 switch (cai->cai_associativity) { 1550 switch (cai->cai_associativity) {
1550 case 0: 1551 case 0:
1551 aprint_verbose("disabled"); 1552 aprint_verbose("disabled");
1552 break; 1553 break;
1553 case 1: 1554 case 1:
1554 aprint_verbose("direct-mapped"); 1555 aprint_verbose("direct-mapped");
1555 break; 1556 break;
1556 case 0xff: 1557 case 0xff:
1557 aprint_verbose("fully associative"); 1558 aprint_verbose("fully associative");
1558 break; 1559 break;
1559 default: 1560 default:
1560 aprint_verbose("%d-way", cai->cai_associativity); 1561 aprint_verbose("%d-way", cai->cai_associativity);
1561 break; 1562 break;
1562 } 1563 }
1563 return ", "; 1564 return ", ";
1564} 1565}
1565 1566
1566static const char * 1567static const char *
1567print_tlb_config(struct cpu_info *ci, int cache_tag, const char *name, 1568print_tlb_config(struct cpu_info *ci, int cache_tag, const char *name,
1568 const char *sep) 1569 const char *sep)
1569{ 1570{
1570 struct x86_cache_info *cai = &ci->ci_cinfo[cache_tag]; 1571 struct x86_cache_info *cai = &ci->ci_cinfo[cache_tag];
1571 char human_num[HUMAN_BUFSIZE]; 1572 char human_num[HUMAN_BUFSIZE];
1572 1573
1573 if (cai->cai_totalsize == 0) 1574 if (cai->cai_totalsize == 0)
1574 return sep; 1575 return sep;
1575 1576
1576 if (sep == NULL) 1577 if (sep == NULL)
1577 aprint_verbose_dev(ci->ci_dev, ""); 1578 aprint_verbose_dev(ci->ci_dev, "");
1578 else 1579 else
1579 aprint_verbose("%s", sep); 1580 aprint_verbose("%s", sep);
1580 if (name != NULL) 1581 if (name != NULL)
1581 aprint_verbose("%s ", name); 1582 aprint_verbose("%s ", name);
1582 1583
1583 if (cai->cai_string != NULL) { 1584 if (cai->cai_string != NULL) {
1584 aprint_verbose("%s", cai->cai_string); 1585 aprint_verbose("%s", cai->cai_string);
1585 } else { 1586 } else {
1586 (void)humanize_number(human_num, sizeof(human_num), 1587 (void)humanize_number(human_num, sizeof(human_num),
1587 cai->cai_linesize, "B", HN_AUTOSCALE, HN_NOSPACE); 1588 cai->cai_linesize, "B", HN_AUTOSCALE, HN_NOSPACE);
1588 aprint_verbose("%d %s entries ", cai->cai_totalsize, 1589 aprint_verbose("%d %s entries ", cai->cai_totalsize,
1589 human_num); 1590 human_num);
1590 switch (cai->cai_associativity) { 1591 switch (cai->cai_associativity) {
1591 case 0: 1592 case 0:
1592 aprint_verbose("disabled"); 1593 aprint_verbose("disabled");
1593 break; 1594 break;
1594 case 1: 1595 case 1:
1595 aprint_verbose("direct-mapped"); 1596 aprint_verbose("direct-mapped");
1596 break; 1597 break;
1597 case 0xff: 1598 case 0xff:
1598 aprint_verbose("fully associative"); 1599 aprint_verbose("fully associative");
1599 break; 1600 break;
1600 default: 1601 default:
1601 aprint_verbose("%d-way", cai->cai_associativity); 1602 aprint_verbose("%d-way", cai->cai_associativity);
1602 break; 1603 break;
1603 } 1604 }
1604 } 1605 }
1605 return ", "; 1606 return ", ";
1606} 1607}
1607 1608
1608static const struct x86_cache_info * 1609static const struct x86_cache_info *
1609cache_info_lookup(const struct x86_cache_info *cai, uint8_t desc) 1610cache_info_lookup(const struct x86_cache_info *cai, uint8_t desc)
1610{ 1611{
1611 int i; 1612 int i;
1612 1613
1613 for (i = 0; cai[i].cai_desc != 0; i++) { 1614 for (i = 0; cai[i].cai_desc != 0; i++) {
1614 if (cai[i].cai_desc == desc) 1615 if (cai[i].cai_desc == desc)
1615 return (&cai[i]); 1616 return (&cai[i]);
1616 } 1617 }
1617 1618
1618 return (NULL); 1619 return (NULL);
1619} 1620}
1620 1621
1621static const struct x86_cache_info amd_cpuid_l2cache_assoc_info[] =  1622static const struct x86_cache_info amd_cpuid_l2cache_assoc_info[] =
1622 AMD_L2CACHE_INFO; 1623 AMD_L2CACHE_INFO;
1623 1624
1624static const struct x86_cache_info amd_cpuid_l3cache_assoc_info[] =  1625static const struct x86_cache_info amd_cpuid_l3cache_assoc_info[] =
1625 AMD_L3CACHE_INFO; 1626 AMD_L3CACHE_INFO;
1626 1627
1627static void 1628static void
1628amd_cpu_cacheinfo(struct cpu_info *ci) 1629amd_cpu_cacheinfo(struct cpu_info *ci)
1629{ 1630{
1630 const struct x86_cache_info *cp; 1631 const struct x86_cache_info *cp;
1631 struct x86_cache_info *cai; 1632 struct x86_cache_info *cai;
1632 int family, model; 1633 int family, model;
1633 u_int descs[4]; 1634 u_int descs[4];
1634 u_int lfunc; 1635 u_int lfunc;
1635 1636
1636 family = (ci->ci_signature >> 8) & 15; 1637 family = (ci->ci_signature >> 8) & 15;
1637 model = CPUID2MODEL(ci->ci_signature); 1638 model = CPUID2MODEL(ci->ci_signature);
1638 1639
1639 /* 1640 /*
1640 * K5 model 0 has none of this info. 1641 * K5 model 0 has none of this info.
1641 */ 1642 */
1642 if (family == 5 && model == 0) 1643 if (family == 5 && model == 0)
1643 return; 1644 return;
1644 1645
1645 /* 1646 /*
1646 * Get extended values for K8 and up. 1647 * Get extended values for K8 and up.
1647 */ 1648 */
1648 if (family == 0xf) { 1649 if (family == 0xf) {
1649 family += CPUID2EXTFAMILY(ci->ci_signature); 1650 family += CPUID2EXTFAMILY(ci->ci_signature);
1650 model += CPUID2EXTMODEL(ci->ci_signature); 1651 model += CPUID2EXTMODEL(ci->ci_signature);
1651 } 1652 }
1652 1653
1653 /* 1654 /*
1654 * Determine the largest extended function value. 1655 * Determine the largest extended function value.
1655 */ 1656 */
1656 x86_cpuid(0x80000000, descs); 1657 x86_cpuid(0x80000000, descs);
1657 lfunc = descs[0]; 1658 lfunc = descs[0];
1658 1659
1659 /* 1660 /*
1660 * Determine L1 cache/TLB info. 1661 * Determine L1 cache/TLB info.
1661 */ 1662 */
1662 if (lfunc < 0x80000005) { 1663 if (lfunc < 0x80000005) {
1663 /* No L1 cache info available. */ 1664 /* No L1 cache info available. */
1664 return; 1665 return;
1665 } 1666 }
1666 1667
1667 x86_cpuid(0x80000005, descs); 1668 x86_cpuid(0x80000005, descs);
1668 1669
1669 /* 1670 /*
1670 * K6-III and higher have large page TLBs. 1671 * K6-III and higher have large page TLBs.
1671 */ 1672 */
1672 if ((family == 5 && model >= 9) || family >= 6) { 1673 if ((family == 5 && model >= 9) || family >= 6) {
1673 cai = &ci->ci_cinfo[CAI_ITLB2]; 1674 cai = &ci->ci_cinfo[CAI_ITLB2];
1674 cai->cai_totalsize = AMD_L1_EAX_ITLB_ENTRIES(descs[0]); 1675 cai->cai_totalsize = AMD_L1_EAX_ITLB_ENTRIES(descs[0]);
1675 cai->cai_associativity = AMD_L1_EAX_ITLB_ASSOC(descs[0]); 1676 cai->cai_associativity = AMD_L1_EAX_ITLB_ASSOC(descs[0]);
1676 cai->cai_linesize = largepagesize; 1677 cai->cai_linesize = largepagesize;
1677 1678
1678 cai = &ci->ci_cinfo[CAI_DTLB2]; 1679 cai = &ci->ci_cinfo[CAI_DTLB2];
1679 cai->cai_totalsize = AMD_L1_EAX_DTLB_ENTRIES(descs[0]); 1680 cai->cai_totalsize = AMD_L1_EAX_DTLB_ENTRIES(descs[0]);
1680 cai->cai_associativity = AMD_L1_EAX_DTLB_ASSOC(descs[0]); 1681 cai->cai_associativity = AMD_L1_EAX_DTLB_ASSOC(descs[0]);
1681 cai->cai_linesize = largepagesize; 1682 cai->cai_linesize = largepagesize;
1682 } 1683 }
1683 1684
1684 cai = &ci->ci_cinfo[CAI_ITLB]; 1685 cai = &ci->ci_cinfo[CAI_ITLB];
1685 cai->cai_totalsize = AMD_L1_EBX_ITLB_ENTRIES(descs[1]); 1686 cai->cai_totalsize = AMD_L1_EBX_ITLB_ENTRIES(descs[1]);
1686 cai->cai_associativity = AMD_L1_EBX_ITLB_ASSOC(descs[1]); 1687 cai->cai_associativity = AMD_L1_EBX_ITLB_ASSOC(descs[1]);
1687 cai->cai_linesize = (4 * 1024); 1688 cai->cai_linesize = (4 * 1024);
1688 1689
1689 cai = &ci->ci_cinfo[CAI_DTLB]; 1690 cai = &ci->ci_cinfo[CAI_DTLB];
1690 cai->cai_totalsize = AMD_L1_EBX_DTLB_ENTRIES(descs[1]); 1691 cai->cai_totalsize = AMD_L1_EBX_DTLB_ENTRIES(descs[1]);
1691 cai->cai_associativity = AMD_L1_EBX_DTLB_ASSOC(descs[1]); 1692 cai->cai_associativity = AMD_L1_EBX_DTLB_ASSOC(descs[1]);
1692 cai->cai_linesize = (4 * 1024); 1693 cai->cai_linesize = (4 * 1024);
1693 1694
1694 cai = &ci->ci_cinfo[CAI_DCACHE]; 1695 cai = &ci->ci_cinfo[CAI_DCACHE];
1695 cai->cai_totalsize = AMD_L1_ECX_DC_SIZE(descs[2]); 1696 cai->cai_totalsize = AMD_L1_ECX_DC_SIZE(descs[2]);
1696 cai->cai_associativity = AMD_L1_ECX_DC_ASSOC(descs[2]); 1697 cai->cai_associativity = AMD_L1_ECX_DC_ASSOC(descs[2]);
1697 cai->cai_linesize = AMD_L1_ECX_DC_LS(descs[2]); 1698 cai->cai_linesize = AMD_L1_ECX_DC_LS(descs[2]);
1698 1699
1699 cai = &ci->ci_cinfo[CAI_ICACHE]; 1700 cai = &ci->ci_cinfo[CAI_ICACHE];
1700 cai->cai_totalsize = AMD_L1_EDX_IC_SIZE(descs[3]); 1701 cai->cai_totalsize = AMD_L1_EDX_IC_SIZE(descs[3]);
1701 cai->cai_associativity = AMD_L1_EDX_IC_ASSOC(descs[3]); 1702 cai->cai_associativity = AMD_L1_EDX_IC_ASSOC(descs[3]);
1702 cai->cai_linesize = AMD_L1_EDX_IC_LS(descs[3]); 1703 cai->cai_linesize = AMD_L1_EDX_IC_LS(descs[3]);
1703 1704
1704 /* 1705 /*
1705 * Determine L2 cache/TLB info. 1706 * Determine L2 cache/TLB info.
1706 */ 1707 */
1707 if (lfunc < 0x80000006) { 1708 if (lfunc < 0x80000006) {
1708 /* No L2 cache info available. */ 1709 /* No L2 cache info available. */
1709 return; 1710 return;
1710 } 1711 }
1711 1712
1712 x86_cpuid(0x80000006, descs); 1713 x86_cpuid(0x80000006, descs);
1713 1714
1714 cai = &ci->ci_cinfo[CAI_L2_ITLB]; 1715 cai = &ci->ci_cinfo[CAI_L2_ITLB];
1715 cai->cai_totalsize = AMD_L2_EBX_IUTLB_ENTRIES(descs[1]); 1716 cai->cai_totalsize = AMD_L2_EBX_IUTLB_ENTRIES(descs[1]);
1716 cai->cai_associativity = AMD_L2_EBX_IUTLB_ASSOC(descs[1]); 1717 cai->cai_associativity = AMD_L2_EBX_IUTLB_ASSOC(descs[1]);
1717 cai->cai_linesize = (4 * 1024); 1718 cai->cai_linesize = (4 * 1024);
1718 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info, 1719 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
1719 cai->cai_associativity); 1720 cai->cai_associativity);
1720 if (cp != NULL) 1721 if (cp != NULL)
1721 cai->cai_associativity = cp->cai_associativity; 1722 cai->cai_associativity = cp->cai_associativity;
1722 else 1723 else
1723 cai->cai_associativity = 0; /* XXX Unknown/reserved */ 1724 cai->cai_associativity = 0; /* XXX Unknown/reserved */
1724 1725
1725 cai = &ci->ci_cinfo[CAI_L2_ITLB2]; 1726 cai = &ci->ci_cinfo[CAI_L2_ITLB2];
1726 cai->cai_totalsize = AMD_L2_EAX_IUTLB_ENTRIES(descs[0]); 1727 cai->cai_totalsize = AMD_L2_EAX_IUTLB_ENTRIES(descs[0]);
1727 cai->cai_associativity = AMD_L2_EAX_IUTLB_ASSOC(descs[0]); 1728 cai->cai_associativity = AMD_L2_EAX_IUTLB_ASSOC(descs[0]);
1728 cai->cai_linesize = largepagesize; 1729 cai->cai_linesize = largepagesize;
1729 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info, 1730 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
1730 cai->cai_associativity); 1731 cai->cai_associativity);
1731 if (cp != NULL) 1732 if (cp != NULL)
1732 cai->cai_associativity = cp->cai_associativity; 1733 cai->cai_associativity = cp->cai_associativity;
1733 else 1734 else
1734 cai->cai_associativity = 0; /* XXX Unknown/reserved */ 1735 cai->cai_associativity = 0; /* XXX Unknown/reserved */
1735 1736
1736 cai = &ci->ci_cinfo[CAI_L2_DTLB]; 1737 cai = &ci->ci_cinfo[CAI_L2_DTLB];
1737 cai->cai_totalsize = AMD_L2_EBX_DTLB_ENTRIES(descs[1]); 1738 cai->cai_totalsize = AMD_L2_EBX_DTLB_ENTRIES(descs[1]);
1738 cai->cai_associativity = AMD_L2_EBX_DTLB_ASSOC(descs[1]); 1739 cai->cai_associativity = AMD_L2_EBX_DTLB_ASSOC(descs[1]);
1739 cai->cai_linesize = (4 * 1024); 1740 cai->cai_linesize = (4 * 1024);
1740 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info, 1741 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
1741 cai->cai_associativity); 1742 cai->cai_associativity);
1742 if (cp != NULL) 1743 if (cp != NULL)
1743 cai->cai_associativity = cp->cai_associativity; 1744 cai->cai_associativity = cp->cai_associativity;
1744 else 1745 else
1745 cai->cai_associativity = 0; /* XXX Unknown/reserved */ 1746 cai->cai_associativity = 0; /* XXX Unknown/reserved */
1746 1747
1747 cai = &ci->ci_cinfo[CAI_L2_DTLB2]; 1748 cai = &ci->ci_cinfo[CAI_L2_DTLB2];
1748 cai->cai_totalsize = AMD_L2_EAX_DTLB_ENTRIES(descs[0]); 1749 cai->cai_totalsize = AMD_L2_EAX_DTLB_ENTRIES(descs[0]);
1749 cai->cai_associativity = AMD_L2_EAX_DTLB_ASSOC(descs[0]); 1750 cai->cai_associativity = AMD_L2_EAX_DTLB_ASSOC(descs[0]);
1750 cai->cai_linesize = largepagesize; 1751 cai->cai_linesize = largepagesize;
1751 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info, 1752 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
1752 cai->cai_associativity); 1753 cai->cai_associativity);
1753 if (cp != NULL) 1754 if (cp != NULL)
1754 cai->cai_associativity = cp->cai_associativity; 1755 cai->cai_associativity = cp->cai_associativity;
1755 else 1756 else
1756 cai->cai_associativity = 0; /* XXX Unknown/reserved */ 1757 cai->cai_associativity = 0; /* XXX Unknown/reserved */
1757 1758
1758 cai = &ci->ci_cinfo[CAI_L2CACHE]; 1759 cai = &ci->ci_cinfo[CAI_L2CACHE];
1759 cai->cai_totalsize = AMD_L2_ECX_C_SIZE(descs[2]); 1760 cai->cai_totalsize = AMD_L2_ECX_C_SIZE(descs[2]);
1760 cai->cai_associativity = AMD_L2_ECX_C_ASSOC(descs[2]); 1761 cai->cai_associativity = AMD_L2_ECX_C_ASSOC(descs[2]);
1761 cai->cai_linesize = AMD_L2_ECX_C_LS(descs[2]); 1762 cai->cai_linesize = AMD_L2_ECX_C_LS(descs[2]);
1762 1763
1763 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info, 1764 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
1764 cai->cai_associativity); 1765 cai->cai_associativity);
1765 if (cp != NULL) 1766 if (cp != NULL)
1766 cai->cai_associativity = cp->cai_associativity; 1767 cai->cai_associativity = cp->cai_associativity;
1767 else 1768 else
1768 cai->cai_associativity = 0; /* XXX Unknown/reserved */ 1769 cai->cai_associativity = 0; /* XXX Unknown/reserved */
1769 1770
1770 /* 1771 /*
1771 * Determine L3 cache info on AMD Family 10h processors 1772 * Determine L3 cache info on AMD Family 10h processors
1772 */ 1773 */
1773 if (family == 0x10) { 1774 if (family == 0x10) {
1774 cai = &ci->ci_cinfo[CAI_L3CACHE]; 1775 cai = &ci->ci_cinfo[CAI_L3CACHE];
1775 cai->cai_totalsize = AMD_L3_EDX_C_SIZE(descs[3]); 1776 cai->cai_totalsize = AMD_L3_EDX_C_SIZE(descs[3]);
1776 cai->cai_associativity = AMD_L3_EDX_C_ASSOC(descs[3]); 1777 cai->cai_associativity = AMD_L3_EDX_C_ASSOC(descs[3]);
1777 cai->cai_linesize = AMD_L3_EDX_C_LS(descs[3]); 1778 cai->cai_linesize = AMD_L3_EDX_C_LS(descs[3]);
1778 1779
1779 cp = cache_info_lookup(amd_cpuid_l3cache_assoc_info, 1780 cp = cache_info_lookup(amd_cpuid_l3cache_assoc_info,
1780 cai->cai_associativity); 1781 cai->cai_associativity);
1781 if (cp != NULL) 1782 if (cp != NULL)
1782 cai->cai_associativity = cp->cai_associativity; 1783 cai->cai_associativity = cp->cai_associativity;
1783 else 1784 else
1784 cai->cai_associativity = 0; /* XXX Unkn/Rsvd */ 1785 cai->cai_associativity = 0; /* XXX Unkn/Rsvd */
1785 } 1786 }
1786 1787
1787 /* 1788 /*
1788 * Determine 1GB TLB info. 1789 * Determine 1GB TLB info.
1789 */ 1790 */
1790 if (lfunc < 0x80000019) { 1791 if (lfunc < 0x80000019) {
1791 /* No 1GB TLB info available. */ 1792 /* No 1GB TLB info available. */
1792 return; 1793 return;
1793 } 1794 }
1794 1795
1795 x86_cpuid(0x80000019, descs); 1796 x86_cpuid(0x80000019, descs);
1796 1797
1797 cai = &ci->ci_cinfo[CAI_L1_1GBITLB]; 1798 cai = &ci->ci_cinfo[CAI_L1_1GBITLB];
1798 cai->cai_totalsize = AMD_L1_1GB_EAX_IUTLB_ENTRIES(descs[0]); 1799 cai->cai_totalsize = AMD_L1_1GB_EAX_IUTLB_ENTRIES(descs[0]);
1799 cai->cai_associativity = AMD_L1_1GB_EAX_IUTLB_ASSOC(descs[0]); 1800 cai->cai_associativity = AMD_L1_1GB_EAX_IUTLB_ASSOC(descs[0]);
1800 cai->cai_linesize = (1024 * 1024 * 1024); 1801 cai->cai_linesize = (1024 * 1024 * 1024);
1801 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info, 1802 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
1802 cai->cai_associativity); 1803 cai->cai_associativity);
1803 if (cp != NULL) 1804 if (cp != NULL)
1804 cai->cai_associativity = cp->cai_associativity; 1805 cai->cai_associativity = cp->cai_associativity;
1805 else 1806 else
1806 cai->cai_associativity = 0; /* XXX Unknown/reserved */ 1807 cai->cai_associativity = 0; /* XXX Unknown/reserved */
1807 1808
1808 cai = &ci->ci_cinfo[CAI_L1_1GBDTLB]; 1809 cai = &ci->ci_cinfo[CAI_L1_1GBDTLB];
1809 cai->cai_totalsize = AMD_L1_1GB_EAX_DTLB_ENTRIES(descs[0]); 1810 cai->cai_totalsize = AMD_L1_1GB_EAX_DTLB_ENTRIES(descs[0]);
1810 cai->cai_associativity = AMD_L1_1GB_EAX_DTLB_ASSOC(descs[0]); 1811 cai->cai_associativity = AMD_L1_1GB_EAX_DTLB_ASSOC(descs[0]);
1811 cai->cai_linesize = (1024 * 1024 * 1024); 1812 cai->cai_linesize = (1024 * 1024 * 1024);
1812 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info, 1813 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
1813 cai->cai_associativity); 1814 cai->cai_associativity);
1814 if (cp != NULL) 1815 if (cp != NULL)
1815 cai->cai_associativity = cp->cai_associativity; 1816 cai->cai_associativity = cp->cai_associativity;
1816 else 1817 else
1817 cai->cai_associativity = 0; /* XXX Unknown/reserved */ 1818 cai->cai_associativity = 0; /* XXX Unknown/reserved */
1818 1819
1819 cai = &ci->ci_cinfo[CAI_L2_1GBITLB]; 1820 cai = &ci->ci_cinfo[CAI_L2_1GBITLB];
1820 cai->cai_totalsize = AMD_L2_1GB_EBX_IUTLB_ENTRIES(descs[1]); 1821 cai->cai_totalsize = AMD_L2_1GB_EBX_IUTLB_ENTRIES(descs[1]);
1821 cai->cai_associativity = AMD_L2_1GB_EBX_IUTLB_ASSOC(descs[1]); 1822 cai->cai_associativity = AMD_L2_1GB_EBX_IUTLB_ASSOC(descs[1]);
1822 cai->cai_linesize = (1024 * 1024 * 1024); 1823 cai->cai_linesize = (1024 * 1024 * 1024);
1823 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info, 1824 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
1824 cai->cai_associativity); 1825 cai->cai_associativity);
1825 if (cp != NULL) 1826 if (cp != NULL)
1826 cai->cai_associativity = cp->cai_associativity; 1827 cai->cai_associativity = cp->cai_associativity;
1827 else 1828 else
1828 cai->cai_associativity = 0; /* XXX Unknown/reserved */ 1829 cai->cai_associativity = 0; /* XXX Unknown/reserved */
1829 1830
1830 cai = &ci->ci_cinfo[CAI_L2_1GBDTLB]; 1831 cai = &ci->ci_cinfo[CAI_L2_1GBDTLB];
1831 cai->cai_totalsize = AMD_L2_1GB_EBX_DUTLB_ENTRIES(descs[1]); 1832 cai->cai_totalsize = AMD_L2_1GB_EBX_DUTLB_ENTRIES(descs[1]);
1832 cai->cai_associativity = AMD_L2_1GB_EBX_DUTLB_ASSOC(descs[1]); 1833 cai->cai_associativity = AMD_L2_1GB_EBX_DUTLB_ASSOC(descs[1]);
1833 cai->cai_linesize = (1024 * 1024 * 1024); 1834 cai->cai_linesize = (1024 * 1024 * 1024);
1834 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info, 1835 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
1835 cai->cai_associativity); 1836 cai->cai_associativity);
1836 if (cp != NULL) 1837 if (cp != NULL)
1837 cai->cai_associativity = cp->cai_associativity; 1838 cai->cai_associativity = cp->cai_associativity;
1838 else 1839 else
1839 cai->cai_associativity = 0; /* XXX Unknown/reserved */ 1840 cai->cai_associativity = 0; /* XXX Unknown/reserved */
1840} 1841}
1841 1842
1842static void 1843static void
1843via_cpu_cacheinfo(struct cpu_info *ci) 1844via_cpu_cacheinfo(struct cpu_info *ci)
1844{ 1845{
1845 struct x86_cache_info *cai; 1846 struct x86_cache_info *cai;
1846 int family, model, stepping; 1847 int family, model, stepping;
1847 u_int descs[4]; 1848 u_int descs[4];
1848 u_int lfunc; 1849 u_int lfunc;
1849 1850
1850 family = (ci->ci_signature >> 8) & 15; 1851 family = (ci->ci_signature >> 8) & 15;
1851 model = CPUID2MODEL(ci->ci_signature); 1852 model = CPUID2MODEL(ci->ci_signature);
1852 stepping = CPUID2STEPPING(ci->ci_signature); 1853 stepping = CPUID2STEPPING(ci->ci_signature);
1853 1854
1854 /* 1855 /*
1855 * Determine the largest extended function value. 1856 * Determine the largest extended function value.
1856 */ 1857 */
1857 x86_cpuid(0x80000000, descs); 1858 x86_cpuid(0x80000000, descs);
1858 lfunc = descs[0]; 1859 lfunc = descs[0];
1859 1860
1860 /* 1861 /*
1861 * Determine L1 cache/TLB info. 1862 * Determine L1 cache/TLB info.
1862 */ 1863 */
1863 if (lfunc < 0x80000005) { 1864 if (lfunc < 0x80000005) {
1864 /* No L1 cache info available. */ 1865 /* No L1 cache info available. */
1865 return; 1866 return;
1866 } 1867 }
1867 1868
1868 x86_cpuid(0x80000005, descs); 1869 x86_cpuid(0x80000005, descs);
1869 1870
1870 cai = &ci->ci_cinfo[CAI_ITLB]; 1871 cai = &ci->ci_cinfo[CAI_ITLB];
1871 cai->cai_totalsize = VIA_L1_EBX_ITLB_ENTRIES(descs[1]); 1872 cai->cai_totalsize = VIA_L1_EBX_ITLB_ENTRIES(descs[1]);
1872 cai->cai_associativity = VIA_L1_EBX_ITLB_ASSOC(descs[1]); 1873 cai->cai_associativity = VIA_L1_EBX_ITLB_ASSOC(descs[1]);
1873 cai->cai_linesize = (4 * 1024); 1874 cai->cai_linesize = (4 * 1024);
1874 1875
1875 cai = &ci->ci_cinfo[CAI_DTLB]; 1876 cai = &ci->ci_cinfo[CAI_DTLB];
1876 cai->cai_totalsize = VIA_L1_EBX_DTLB_ENTRIES(descs[1]); 1877 cai->cai_totalsize = VIA_L1_EBX_DTLB_ENTRIES(descs[1]);
1877 cai->cai_associativity = VIA_L1_EBX_DTLB_ASSOC(descs[1]); 1878 cai->cai_associativity = VIA_L1_EBX_DTLB_ASSOC(descs[1]);
1878 cai->cai_linesize = (4 * 1024); 1879 cai->cai_linesize = (4 * 1024);
1879 1880
1880 cai = &ci->ci_cinfo[CAI_DCACHE]; 1881 cai = &ci->ci_cinfo[CAI_DCACHE];
1881 cai->cai_totalsize = VIA_L1_ECX_DC_SIZE(descs[2]); 1882 cai->cai_totalsize = VIA_L1_ECX_DC_SIZE(descs[2]);
1882 cai->cai_associativity = VIA_L1_ECX_DC_ASSOC(descs[2]); 1883 cai->cai_associativity = VIA_L1_ECX_DC_ASSOC(descs[2]);
1883 cai->cai_linesize = VIA_L1_EDX_IC_LS(descs[2]); 1884 cai->cai_linesize = VIA_L1_EDX_IC_LS(descs[2]);
1884 if (model == 9 && stepping == 8) { 1885 if (model == 9 && stepping == 8) {
1885 /* Erratum: stepping 8 reports 4 when it should be 2 */ 1886 /* Erratum: stepping 8 reports 4 when it should be 2 */
1886 cai->cai_associativity = 2; 1887 cai->cai_associativity = 2;
1887 } 1888 }
1888 1889
1889 cai = &ci->ci_cinfo[CAI_ICACHE]; 1890 cai = &ci->ci_cinfo[CAI_ICACHE];
1890 cai->cai_totalsize = VIA_L1_EDX_IC_SIZE(descs[3]); 1891 cai->cai_totalsize = VIA_L1_EDX_IC_SIZE(descs[3]);
1891 cai->cai_associativity = VIA_L1_EDX_IC_ASSOC(descs[3]); 1892 cai->cai_associativity = VIA_L1_EDX_IC_ASSOC(descs[3]);
1892 cai->cai_linesize = VIA_L1_EDX_IC_LS(descs[3]); 1893 cai->cai_linesize = VIA_L1_EDX_IC_LS(descs[3]);
1893 if (model == 9 && stepping == 8) { 1894 if (model == 9 && stepping == 8) {
1894 /* Erratum: stepping 8 reports 4 when it should be 2 */ 1895 /* Erratum: stepping 8 reports 4 when it should be 2 */
1895 cai->cai_associativity = 2; 1896 cai->cai_associativity = 2;
1896 } 1897 }
1897 1898
1898 /* 1899 /*
1899 * Determine L2 cache/TLB info. 1900 * Determine L2 cache/TLB info.
1900 */ 1901 */
1901 if (lfunc < 0x80000006) { 1902 if (lfunc < 0x80000006) {
1902 /* No L2 cache info available. */ 1903 /* No L2 cache info available. */
1903 return; 1904 return;
1904 } 1905 }
1905 1906
1906 x86_cpuid(0x80000006, descs); 1907 x86_cpuid(0x80000006, descs);
1907 1908
1908 cai = &ci->ci_cinfo[CAI_L2CACHE]; 1909 cai = &ci->ci_cinfo[CAI_L2CACHE];
1909 if (model >= 9) { 1910 if (model >= 9) {
1910 cai->cai_totalsize = VIA_L2N_ECX_C_SIZE(descs[2]); 1911 cai->cai_totalsize = VIA_L2N_ECX_C_SIZE(descs[2]);
1911 cai->cai_associativity = VIA_L2N_ECX_C_ASSOC(descs[2]); 1912 cai->cai_associativity = VIA_L2N_ECX_C_ASSOC(descs[2]);
1912 cai->cai_linesize = VIA_L2N_ECX_C_LS(descs[2]); 1913 cai->cai_linesize = VIA_L2N_ECX_C_LS(descs[2]);
1913 } else { 1914 } else {
1914 cai->cai_totalsize = VIA_L2_ECX_C_SIZE(descs[2]); 1915 cai->cai_totalsize = VIA_L2_ECX_C_SIZE(descs[2]);
1915 cai->cai_associativity = VIA_L2_ECX_C_ASSOC(descs[2]); 1916 cai->cai_associativity = VIA_L2_ECX_C_ASSOC(descs[2]);
1916 cai->cai_linesize = VIA_L2_ECX_C_LS(descs[2]); 1917 cai->cai_linesize = VIA_L2_ECX_C_LS(descs[2]);
1917 } 1918 }
1918} 1919}
1919 1920
1920static void 1921static void
1921x86_print_cacheinfo(struct cpu_info *ci) 1922x86_print_cacheinfo(struct cpu_info *ci)
1922{ 1923{
1923 const char *sep; 1924 const char *sep;
1924 1925
1925 if (ci->ci_cinfo[CAI_ICACHE].cai_totalsize != 0 || 1926 if (ci->ci_cinfo[CAI_ICACHE].cai_totalsize != 0 ||
1926 ci->ci_cinfo[CAI_DCACHE].cai_totalsize != 0) { 1927 ci->ci_cinfo[CAI_DCACHE].cai_totalsize != 0) {
1927 sep = print_cache_config(ci, CAI_ICACHE, "I-cache", NULL); 1928 sep = print_cache_config(ci, CAI_ICACHE, "I-cache", NULL);
1928 sep = print_cache_config(ci, CAI_DCACHE, "D-cache", sep); 1929 sep = print_cache_config(ci, CAI_DCACHE, "D-cache", sep);
1929 if (sep != NULL) 1930 if (sep != NULL)
1930 aprint_verbose("\n"); 1931 aprint_verbose("\n");
1931 } 1932 }
1932 if (ci->ci_cinfo[CAI_L2CACHE].cai_totalsize != 0) { 1933 if (ci->ci_cinfo[CAI_L2CACHE].cai_totalsize != 0) {
1933 sep = print_cache_config(ci, CAI_L2CACHE, "L2 cache", NULL); 1934 sep = print_cache_config(ci, CAI_L2CACHE, "L2 cache", NULL);
1934 if (sep != NULL) 1935 if (sep != NULL)
1935 aprint_verbose("\n"); 1936 aprint_verbose("\n");
1936 } 1937 }
1937 if (ci->ci_cinfo[CAI_L3CACHE].cai_totalsize != 0) { 1938 if (ci->ci_cinfo[CAI_L3CACHE].cai_totalsize != 0) {
1938 sep = print_cache_config(ci, CAI_L3CACHE, "L3 cache", NULL); 1939 sep = print_cache_config(ci, CAI_L3CACHE, "L3 cache", NULL);
1939 if (sep != NULL) 1940 if (sep != NULL)
1940 aprint_verbose("\n"); 1941 aprint_verbose("\n");
1941 } 1942 }
1942 if (ci->ci_cinfo[CAI_ITLB].cai_totalsize != 0) { 1943 if (ci->ci_cinfo[CAI_ITLB].cai_totalsize != 0) {
1943 sep = print_tlb_config(ci, CAI_ITLB, "ITLB", NULL); 1944 sep = print_tlb_config(ci, CAI_ITLB, "ITLB", NULL);
1944 sep = print_tlb_config(ci, CAI_ITLB2, NULL, sep); 1945 sep = print_tlb_config(ci, CAI_ITLB2, NULL, sep);
1945 if (sep != NULL) 1946 if (sep != NULL)
1946 aprint_verbose("\n"); 1947 aprint_verbose("\n");
1947 } 1948 }
1948 if (ci->ci_cinfo[CAI_DTLB].cai_totalsize != 0) { 1949 if (ci->ci_cinfo[CAI_DTLB].cai_totalsize != 0) {
1949 sep = print_tlb_config(ci, CAI_DTLB, "DTLB", NULL); 1950 sep = print_tlb_config(ci, CAI_DTLB, "DTLB", NULL);
1950 sep = print_tlb_config(ci, CAI_DTLB2, NULL, sep); 1951 sep = print_tlb_config(ci, CAI_DTLB2, NULL, sep);
1951 if (sep != NULL) 1952 if (sep != NULL)
1952 aprint_verbose("\n"); 1953 aprint_verbose("\n");
1953 } 1954 }
1954 if (ci->ci_cinfo[CAI_L2_ITLB].cai_totalsize != 0) { 1955 if (ci->ci_cinfo[CAI_L2_ITLB].cai_totalsize != 0) {
1955 sep = print_tlb_config(ci, CAI_L2_ITLB, "L2 ITLB", NULL); 1956 sep = print_tlb_config(ci, CAI_L2_ITLB, "L2 ITLB", NULL);
1956 sep = print_tlb_config(ci, CAI_L2_ITLB2, NULL, sep); 1957 sep = print_tlb_config(ci, CAI_L2_ITLB2, NULL, sep);
1957 if (sep != NULL) 1958 if (sep != NULL)
1958 aprint_verbose("\n"); 1959 aprint_verbose("\n");
1959 } 1960 }
1960 if (ci->ci_cinfo[CAI_L2_DTLB].cai_totalsize != 0) { 1961 if (ci->ci_cinfo[CAI_L2_DTLB].cai_totalsize != 0) {
1961 sep = print_tlb_config(ci, CAI_L2_DTLB, "L2 DTLB", NULL); 1962 sep = print_tlb_config(ci, CAI_L2_DTLB, "L2 DTLB", NULL);
1962 sep = print_tlb_config(ci, CAI_L2_DTLB2, NULL, sep); 1963 sep = print_tlb_config(ci, CAI_L2_DTLB2, NULL, sep);
1963 if (sep != NULL) 1964 if (sep != NULL)
1964 aprint_verbose("\n"); 1965 aprint_verbose("\n");
1965 } 1966 }
1966 if (ci->ci_cinfo[CAI_L1_1GBITLB].cai_totalsize != 0) { 1967 if (ci->ci_cinfo[CAI_L1_1GBITLB].cai_totalsize != 0) {
1967 sep = print_tlb_config(ci, CAI_L1_1GBITLB, "L1 1GB page ITLB", NULL); 1968 sep = print_tlb_config(ci, CAI_L1_1GBITLB, "L1 1GB page ITLB", NULL);
1968 if (sep != NULL) 1969 if (sep != NULL)
1969 aprint_verbose("\n"); 1970 aprint_verbose("\n");
1970 } 1971 }
1971 if (ci->ci_cinfo[CAI_L1_1GBDTLB].cai_totalsize != 0) { 1972 if (ci->ci_cinfo[CAI_L1_1GBDTLB].cai_totalsize != 0) {
1972 sep = print_tlb_config(ci, CAI_L1_1GBDTLB, "L1 1GB page DTLB", NULL); 1973 sep = print_tlb_config(ci, CAI_L1_1GBDTLB, "L1 1GB page DTLB", NULL);
1973 if (sep != NULL) 1974 if (sep != NULL)
1974 aprint_verbose("\n"); 1975 aprint_verbose("\n");
1975 } 1976 }
1976 if (ci->ci_cinfo[CAI_L2_1GBITLB].cai_totalsize != 0) { 1977 if (ci->ci_cinfo[CAI_L2_1GBITLB].cai_totalsize != 0) {
1977 sep = print_tlb_config(ci, CAI_L2_1GBITLB, "L2 1GB page ITLB", NULL); 1978 sep = print_tlb_config(ci, CAI_L2_1GBITLB, "L2 1GB page ITLB", NULL);
1978 if (sep != NULL) 1979 if (sep != NULL)
1979 aprint_verbose("\n"); 1980 aprint_verbose("\n");
1980 } 1981 }
1981 if (ci->ci_cinfo[CAI_L2_1GBDTLB].cai_totalsize != 0) { 1982 if (ci->ci_cinfo[CAI_L2_1GBDTLB].cai_totalsize != 0) {
1982 sep = print_tlb_config(ci, CAI_L2_1GBDTLB, "L2 1GB page DTLB", NULL); 1983 sep = print_tlb_config(ci, CAI_L2_1GBDTLB, "L2 1GB page DTLB", NULL);
1983 if (sep != NULL) 1984 if (sep != NULL)
1984 aprint_verbose("\n"); 1985 aprint_verbose("\n");
1985 } 1986 }
1986} 1987}
1987 1988
1988static void 1989static void
1989powernow_probe(struct cpu_info *ci) 1990powernow_probe(struct cpu_info *ci)
1990{ 1991{
1991 uint32_t regs[4]; 1992 uint32_t regs[4];
1992 char buf[256]; 1993 char buf[256];
1993 1994
1994 x86_cpuid(0x80000007, regs); 1995 x86_cpuid(0x80000007, regs);
1995 1996
1996 snprintb(buf, sizeof(buf), CPUID_APM_FLAGS, regs[3]); 1997 snprintb(buf, sizeof(buf), CPUID_APM_FLAGS, regs[3]);
1997 aprint_normal_dev(ci->ci_dev, "AMD Power Management features: %s\n", 1998 aprint_normal_dev(ci->ci_dev, "AMD Power Management features: %s\n",
1998 buf); 1999 buf);
1999} 2000}