diff options
| author | msaitoh <msaitoh@NetBSD.org> | 2013-11-15 08:47:55 +0000 |
|---|---|---|
| committer | msaitoh <msaitoh@NetBSD.org> | 2013-11-15 08:47:55 +0000 |
| commit | b1bcfb8009819cc093d9a2f7c84d38f405ea046d (patch) | |
| tree | 4ccc83da4d4724af6caa6d3efccb0d3f5cfdfc0e | |
| parent | d77d258119a86b80ff86aa434cab8d452eac169f (diff) | |
Modify some macros and add some new macros for CPU family and model
to reduce code duplication and to avoid bug.
CPUID_TO_STEPPING(cpuid) (not changed)
CPUID_TO_FAMILY(cpuid) (new)
CPUID_TO_MODEL(cpuid) (new)
Return the display family and the display model.
The macro names are the same as FreeBSD.
CPUID_TO_BASEFAMILY(cpuid) (The old name was CPUID2FAMILY)
CPUID_TO_BASEMODEL(cpuid) (The old name was CPUID2MODEL)
Only for the base field.
CPUID_TO_EXTFAMILY(cpuid) (The old name was CPUID2EXTFAMILY)
CPUID_TO_EXTMODEL(cpuid) (The old name was CPUID2EXTMODEL)
Only for the extended field.
See http://mail-index.netbsd.org/port-amd64/2013/11/12/msg001978.html
| -rw-r--r-- | sys/arch/x86/acpi/acpi_cpu_md.c | 14 | ||||
| -rw-r--r-- | sys/arch/x86/include/specialreg.h | 27 | ||||
| -rw-r--r-- | sys/arch/x86/pci/amdtemp.c | 20 | ||||
| -rw-r--r-- | sys/arch/x86/x86/coretemp.c | 16 | ||||
| -rw-r--r-- | sys/arch/x86/x86/cpu.c | 12 | ||||
| -rw-r--r-- | sys/arch/x86/x86/cpu_topology.c | 8 | ||||
| -rw-r--r-- | sys/arch/x86/x86/cpu_ucode_amd.c | 8 | ||||
| -rw-r--r-- | sys/arch/x86/x86/cpu_ucode_intel.c | 8 | ||||
| -rw-r--r-- | sys/arch/x86/x86/est.c | 8 | ||||
| -rw-r--r-- | sys/arch/x86/x86/identcpu.c | 44 | ||||
| -rw-r--r-- | sys/arch/x86/x86/intel_busclock.c | 22 | ||||
| -rw-r--r-- | sys/arch/x86/x86/lapic.c | 6 | ||||
| -rw-r--r-- | sys/arch/x86/x86/odcm.c | 6 | ||||
| -rw-r--r-- | sys/arch/x86/x86/patch.c | 10 | ||||
| -rw-r--r-- | sys/arch/x86/x86/powernow.c | 10 | ||||
| -rw-r--r-- | sys/arch/x86/x86/tprof_amdpmi.c | 7 | ||||
| -rw-r--r-- | sys/arch/x86/x86/tprof_pmi.c | 6 | ||||
| -rw-r--r-- | sys/arch/x86/x86/tsc.c | 16 | ||||
| -rw-r--r-- | sys/arch/x86/x86/viac7temp.c | 8 | ||||
| -rw-r--r-- | usr.sbin/cpuctl/arch/i386.c | 21 |
20 files changed, 128 insertions, 149 deletions
diff --git a/sys/arch/x86/acpi/acpi_cpu_md.c b/sys/arch/x86/acpi/acpi_cpu_md.c index 5534f5ddefa..78a0e84efc8 100644 --- a/sys/arch/x86/acpi/acpi_cpu_md.c +++ b/sys/arch/x86/acpi/acpi_cpu_md.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_cpu_md.c,v 1.72 2012/12/06 04:43:29 jruoho Exp $ */ +/* $NetBSD: acpi_cpu_md.c,v 1.73 2013/11/15 08:47:55 msaitoh Exp $ */ /*- * Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen@iki.fi> @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.72 2012/12/06 04:43:29 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.73 2013/11/15 08:47:55 msaitoh Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -243,10 +243,7 @@ acpicpu_md_flags(void) x86_cpuid(0x80000007, regs); - family = CPUID2FAMILY(ci->ci_signature); - - if (family == 0xf) - family += CPUID2EXTFAMILY(ci->ci_signature); + family = CPUID_TO_FAMILY(ci->ci_signature); switch (family) { @@ -547,10 +544,7 @@ acpicpu_md_pstate_init(struct acpicpu_softc *sc) if ((sc->sc_flags & ACPICPU_FLAG_P_FIDVID) != 0) msr.ps_flags |= ACPICPU_FLAG_P_FIDVID; - family = CPUID2FAMILY(ci->ci_signature); - - if (family == 0xf) - family += CPUID2EXTFAMILY(ci->ci_signature); + family = CPUID_TO_FAMILY(ci->ci_signature); switch (family) { diff --git a/sys/arch/x86/include/specialreg.h b/sys/arch/x86/include/specialreg.h index 8cfcbad3071..4d673529333 100644 --- a/sys/arch/x86/include/specialreg.h +++ b/sys/arch/x86/include/specialreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: specialreg.h,v 1.71 2013/10/21 06:11:49 msaitoh Exp $ */ +/* $NetBSD: specialreg.h,v 1.72 2013/11/15 08:47:55 msaitoh Exp $ */ /*- * Copyright (c) 1991 The Regents of the University of California. @@ -192,19 +192,30 @@ "\31" "DEADLINE" "\32" "AES" "\33" "XSAVE" "\34" "OSXSAVE" \ "\35" "AVX" "\36" "F16C" "\37" "RDRAND" "\40" "RAZ" -#define CPUID2FAMILY(cpuid) (((cpuid) >> 8) & 0xf) -#define CPUID2MODEL(cpuid) (((cpuid) >> 4) & 0xf) -#define CPUID2STEPPING(cpuid) ((cpuid) & 0xf) +/* CPUID Fn00000001 %eax */ + +#define CPUID_TO_BASEFAMILY(cpuid) (((cpuid) >> 8) & 0xf) +#define CPUID_TO_BASEMODEL(cpuid) (((cpuid) >> 4) & 0xf) +#define CPUID_TO_STEPPING(cpuid) ((cpuid) & 0xf) /* - * The Extended family bits should only be inspected when CPUID2FAMILY() + * The Extended family bits should only be inspected when CPUID_TO_BASEFAMILY() * returns 15. They are use to encode family value 16 to 270 (add 15). - * The Extended model hits are the high 4 bits of the model. + * The Extended model bits are the high 4 bits of the model. * They are only valid for family >= 15 or family 6 (intel, but all amd * family 6 are documented to return zero bits for them). */ -#define CPUID2EXTFAMILY(cpuid) (((cpuid) >> 20) & 0xff) -#define CPUID2EXTMODEL(cpuid) (((cpuid) >> 16) & 0xf) +#define CPUID_TO_EXTFAMILY(cpuid) (((cpuid) >> 20) & 0xff) +#define CPUID_TO_EXTMODEL(cpuid) (((cpuid) >> 16) & 0xf) + +/* The macros for the Display Family and the Display Model */ +#define CPUID_TO_FAMILY(cpuid) (CPUID_TO_BASEFAMILY(cpuid) \ + + ((CPUID_TO_BASEFAMILY(cpuid) != 0x0f) \ + ? 0 : CPUID_TO_EXTFAMILY(cpuid))) +#define CPUID_TO_MODEL(cpuid) (CPUID_TO_BASEMODEL(cpuid) \ + | ((CPUID_TO_BASEFAMILY(cpuid) != 0x0f) \ + && (CPUID_TO_BASEFAMILY(cpuid) != 0x06) \ + ? 0 : (CPUID_TO_EXTMODEL(cpuid) << 4))) /* * Intel Deterministic Cache Parameter Leaf diff --git a/sys/arch/x86/pci/amdtemp.c b/sys/arch/x86/pci/amdtemp.c index 1324cf8876c..e9efe44021f 100644 --- a/sys/arch/x86/pci/amdtemp.c +++ b/sys/arch/x86/pci/amdtemp.c @@ -1,4 +1,4 @@ -/* $NetBSD: amdtemp.c,v 1.17 2013/11/12 15:08:01 msaitoh Exp $ */ +/* $NetBSD: amdtemp.c,v 1.18 2013/11/15 08:47:55 msaitoh Exp $ */ /* $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $ */ /* @@ -48,7 +48,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: amdtemp.c,v 1.17 2013/11/12 15:08:01 msaitoh Exp $ "); +__KERNEL_RCSID(0, "$NetBSD: amdtemp.c,v 1.18 2013/11/15 08:47:55 msaitoh Exp $ "); #include <sys/param.h> #include <sys/bus.h> @@ -199,16 +199,14 @@ amdtemp_match(device_t parent, cfdata_t match, void *aux) if (cpu_signature == 0x0) return 0; - family = CPUID2FAMILY(cpu_signature); - if (family == 0xf) - family += CPUID2EXTFAMILY(cpu_signature); + family = CPUID_TO_FAMILY(cpu_signature); /* Errata #319: This has been fixed in Revision C2. */ if (family == 0x10) { - if (CPUID2MODEL(cpu_signature) < 4) + if (CPUID_TO_BASEMODEL(cpu_signature) < 4) return 0; - if (CPUID2MODEL(cpu_signature) == 4 - && CPUID2STEPPING(cpu_signature) < 2) + if (CPUID_TO_BASEMODEL(cpu_signature) == 4 + && CPUID_TO_STEPPING(cpu_signature) < 2) return 0; } @@ -238,9 +236,7 @@ amdtemp_attach(device_t parent, device_t self, void *aux) /* If we hit this, then match routine is wrong. */ KASSERT(cpu_signature != 0x0); - sc->sc_family = CPUID2FAMILY(cpu_signature); - if (sc->sc_family == 0xf) - sc->sc_family += CPUID2EXTFAMILY(cpu_signature); + sc->sc_family = CPUID_TO_FAMILY(cpu_signature); KASSERT(sc->sc_family >= 0xf); @@ -379,7 +375,7 @@ amdtemp_k8_init(struct amdtemp_softc *sc, pcireg_t cpu_signature) sc->sc_rev = amdtemp_core[i].rev[3]; aprint_normal(": core rev %.4s%.1x", amdtemp_core[i].rev, - CPUID2STEPPING(cpu_signature)); + CPUID_TO_STEPPING(cpu_signature)); switch (amdtemp_core[i].cpu[j].socket) { case K8_SOCKET_AM2: diff --git a/sys/arch/x86/x86/coretemp.c b/sys/arch/x86/x86/coretemp.c index 03d5c17ca80..e84833d719e 100644 --- a/sys/arch/x86/x86/coretemp.c +++ b/sys/arch/x86/x86/coretemp.c @@ -1,4 +1,4 @@ -/* $NetBSD: coretemp.c,v 1.30 2013/11/12 15:58:38 msaitoh Exp $ */ +/* $NetBSD: coretemp.c,v 1.31 2013/11/15 08:47:55 msaitoh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: coretemp.c,v 1.30 2013/11/12 15:58:38 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: coretemp.c,v 1.31 2013/11/15 08:47:55 msaitoh Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -217,8 +217,8 @@ coretemp_quirks(struct cpu_info *ci) uint32_t model, stepping; uint64_t msr; - model = CPUID2MODEL(ci->ci_signature); - stepping = CPUID2STEPPING(ci->ci_signature); + model = CPUID_TO_MODEL(ci->ci_signature); + stepping = CPUID_TO_STEPPING(ci->ci_signature); /* * Check if the MSR contains thermal @@ -259,11 +259,9 @@ coretemp_tjmax(device_t self) uint32_t family, model, stepping; uint64_t msr; - family = CPUID2FAMILY(ci->ci_signature); - model = CPUID2MODEL(ci->ci_signature); - if ((family == 0xf) || (family == 0x6)) - model |= CPUID2EXTMODEL(ci->ci_signature) << 4; - stepping = CPUID2STEPPING(ci->ci_signature); + family = CPUID_TO_FAMILY(ci->ci_signature); + model = CPUID_TO_MODEL(ci->ci_signature); + stepping = CPUID_TO_STEPPING(ci->ci_signature); sc->sc_tjmax = 100; diff --git a/sys/arch/x86/x86/cpu.c b/sys/arch/x86/x86/cpu.c index 85217c62e99..f75d9211839 100644 --- a/sys/arch/x86/x86/cpu.c +++ b/sys/arch/x86/x86/cpu.c @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.105 2013/11/12 16:15:54 msaitoh Exp $ */ +/* $NetBSD: cpu.c,v 1.106 2013/11/15 08:47:55 msaitoh Exp $ */ /*- * Copyright (c) 2000-2012 NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.105 2013/11/12 16:15:54 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.106 2013/11/15 08:47:55 msaitoh Exp $"); #include "opt_ddb.h" #include "opt_mpbios.h" /* for MPDEBUG */ @@ -592,10 +592,10 @@ cpu_init(struct cpu_info *ci) /* * Must be a K6-2 Step >= 7 or a K6-III. */ - if (CPUID2FAMILY(ci->ci_signature) == 5) { - if (CPUID2MODEL(ci->ci_signature) > 8 || - (CPUID2MODEL(ci->ci_signature) == 8 && - CPUID2STEPPING(ci->ci_signature) >= 7)) { + if (CPUID_TO_FAMILY(ci->ci_signature) == 5) { + if (CPUID_TO_MODEL(ci->ci_signature) > 8 || + (CPUID_TO_MODEL(ci->ci_signature) == 8 && + CPUID_TO_STEPPING(ci->ci_signature) >= 7)) { mtrr_funcs = &k6_mtrr_funcs; k6_mtrr_init_first(); mtrr_init_cpu(ci); diff --git a/sys/arch/x86/x86/cpu_topology.c b/sys/arch/x86/x86/cpu_topology.c index 08187ce7174..38a6dafff5d 100644 --- a/sys/arch/x86/x86/cpu_topology.c +++ b/sys/arch/x86/x86/cpu_topology.c @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_topology.c,v 1.7 2013/11/12 16:35:57 msaitoh Exp $ */ +/* $NetBSD: cpu_topology.c,v 1.8 2013/11/15 08:47:55 msaitoh Exp $ */ /*- * Copyright (c) 2009 Mindaugas Rasiukevicius <rmind at NetBSD org>, @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.7 2013/11/12 16:35:57 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.8 2013/11/15 08:47:55 msaitoh Exp $"); #include <sys/param.h> #include <sys/bitops.h> @@ -57,9 +57,7 @@ x86_cpu_topology(struct cpu_info *ci) uint32_t descs[4], lextmode; apic_id = ci->ci_initapicid; - cpu_family = CPUID2FAMILY(ci->ci_signature); - if (cpu_family == 0xf) - cpu_family += CPUID2EXTFAMILY(ci->ci_signature); + cpu_family = CPUID_TO_FAMILY(ci->ci_signature); /* Initial values. */ ci->ci_package_id = apic_id; diff --git a/sys/arch/x86/x86/cpu_ucode_amd.c b/sys/arch/x86/x86/cpu_ucode_amd.c index 7841d4632e0..88a810d77f8 100644 --- a/sys/arch/x86/x86/cpu_ucode_amd.c +++ b/sys/arch/x86/x86/cpu_ucode_amd.c @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_ucode_amd.c,v 1.6 2013/07/06 12:03:11 gdt Exp $ */ +/* $NetBSD: cpu_ucode_amd.c,v 1.7 2013/11/15 08:47:55 msaitoh Exp $ */ /* * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_amd.c,v 1.6 2013/07/06 12:03:11 gdt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_amd.c,v 1.7 2013/11/15 08:47:55 msaitoh Exp $"); #include "opt_xen.h" #include "opt_cpu_ucode.h" @@ -95,9 +95,7 @@ amd_cpufamily(void) uint32_t family; struct cpu_info *ci = curcpu(); - family = CPUID2FAMILY(ci->ci_signature); - if (family == 0xf) - family += CPUID2EXTFAMILY(ci->ci_signature); + family = CPUID_TO_FAMILY(ci->ci_signature); return family; } diff --git a/sys/arch/x86/x86/cpu_ucode_intel.c b/sys/arch/x86/x86/cpu_ucode_intel.c index d64898a6b5e..9a67c10631b 100644 --- a/sys/arch/x86/x86/cpu_ucode_intel.c +++ b/sys/arch/x86/x86/cpu_ucode_intel.c @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_ucode_intel.c,v 1.3 2013/07/06 12:11:54 gdt Exp $ */ +/* $NetBSD: cpu_ucode_intel.c,v 1.4 2013/11/15 08:47:55 msaitoh Exp $ */ /* * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_intel.c,v 1.3 2013/07/06 12:11:54 gdt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_intel.c,v 1.4 2013/11/15 08:47:55 msaitoh Exp $"); #include "opt_xen.h" #include "opt_cpu_ucode.h" @@ -76,7 +76,7 @@ cpu_ucode_intel_get_version(struct cpu_ucode_version *ucode) struct cpu_ucode_version_intel1 data; if (ucode->loader_version != CPU_UCODE_LOADER_INTEL1 || - CPUID2FAMILY(ci->ci_signature) < 6) + CPUID_TO_FAMILY(ci->ci_signature) < 6) return EOPNOTSUPP; if (!ucode->data) return 0; @@ -98,7 +98,7 @@ cpu_ucode_intel_firmware_open(firmware_handle_t *fwh, const char *fwname) return firmware_open(fw_path, fwname, fwh); cpu_signature = curcpu()->ci_signature; - if (CPUID2FAMILY(cpu_signature) < 6) + if (CPUID_TO_FAMILY(cpu_signature) < 6) return EOPNOTSUPP; intel_getcurrentucode(&ucodeversion, &platformid); diff --git a/sys/arch/x86/x86/est.c b/sys/arch/x86/x86/est.c index c332a6f230a..089b318474a 100644 --- a/sys/arch/x86/x86/est.c +++ b/sys/arch/x86/x86/est.c @@ -1,4 +1,4 @@ -/* $NetBSD: est.c,v 1.27 2013/11/08 19:05:52 msaitoh Exp $ */ +/* $NetBSD: est.c,v 1.28 2013/11/15 08:47:55 msaitoh Exp $ */ /* * Copyright (c) 2003 Michael Eriksson. * All rights reserved. @@ -76,7 +76,7 @@ * http://www.codemonkey.org.uk/projects/cpufreq/cpufreq-2.4.22-pre6-1.gz */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: est.c,v 1.27 2013/11/08 19:05:52 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: est.c,v 1.28 2013/11/15 08:47:55 msaitoh Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -1080,8 +1080,8 @@ est_bus_clock(struct cpu_info *ci) uint32_t family, model; int bus_clock = 0; - model = CPUID2MODEL(ci->ci_signature); - family = CPUID2FAMILY(ci->ci_signature); + family = CPUID_TO_BASEFAMILY(ci->ci_signature); + model = CPUID_TO_MODEL(ci->ci_signature); switch (family) { diff --git a/sys/arch/x86/x86/identcpu.c b/sys/arch/x86/x86/identcpu.c index b9348b782c6..67bbf1f1196 100644 --- a/sys/arch/x86/x86/identcpu.c +++ b/sys/arch/x86/x86/identcpu.c @@ -1,4 +1,4 @@ -/* $NetBSD: identcpu.c,v 1.37 2013/11/12 16:13:56 msaitoh Exp $ */ +/* $NetBSD: identcpu.c,v 1.38 2013/11/15 08:47:55 msaitoh Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.37 2013/11/12 16:13:56 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.38 2013/11/15 08:47:55 msaitoh Exp $"); #include "opt_xen.h" @@ -107,8 +107,8 @@ cpu_probe_amd_cache(struct cpu_info *ci) u_int descs[4]; u_int lfunc; - family = CPUID2FAMILY(ci->ci_signature); - model = CPUID2MODEL(ci->ci_signature); + family = CPUID_TO_FAMILY(ci->ci_signature); + model = CPUID_TO_MODEL(ci->ci_signature); /* * K5 model 0 has none of this info. @@ -117,15 +117,6 @@ cpu_probe_amd_cache(struct cpu_info *ci) return; /* - * Get extended values for K8 and up. - */ - if (family == 0xf) - family += CPUID2EXTFAMILY(ci->ci_signature); - - if ((family == 0xf) || (family == 0x6)) - model |= CPUID2EXTMODEL(ci->ci_signature) << 4; - - /* * Determine the largest extended function value. */ x86_cpuid(0x80000000, descs); @@ -249,10 +240,10 @@ cpu_probe_k5(struct cpu_info *ci) int flag; if (cpu_vendor != CPUVENDOR_AMD || - CPUID2FAMILY(ci->ci_signature) != 5) + CPUID_TO_FAMILY(ci->ci_signature) != 5) return; - if (CPUID2MODEL(ci->ci_signature) == 0) { + if (CPUID_TO_MODEL(ci->ci_signature) == 0) { /* * According to the AMD Processor Recognition App Note, * the AMD-K5 Model 0 uses the wrong bit to indicate @@ -274,7 +265,7 @@ cpu_probe_k678(struct cpu_info *ci) uint32_t descs[4]; if (cpu_vendor != CPUVENDOR_AMD || - CPUID2FAMILY(ci->ci_signature) < 6) + CPUID_TO_FAMILY(ci->ci_signature) < 6) return; /* Determine the extended feature flags. */ @@ -370,8 +361,8 @@ cpu_probe_cyrix(struct cpu_info *ci) { if (cpu_vendor != CPUVENDOR_CYRIX || - CPUID2FAMILY(ci->ci_signature) < 4 || - CPUID2FAMILY(ci->ci_signature) > 6) + CPUID_TO_FAMILY(ci->ci_signature) < 4 || + CPUID_TO_FAMILY(ci->ci_signature) > 6) return; cpu_probe_cyrix_cmn(ci); @@ -384,10 +375,10 @@ cpu_probe_winchip(struct cpu_info *ci) if (cpu_vendor != CPUVENDOR_IDT) return; - switch (CPUID2FAMILY(ci->ci_signature)) { + switch (CPUID_TO_FAMILY(ci->ci_signature)) { case 5: /* WinChip C6 */ - if (CPUID2MODEL(ci->ci_signature) == 4) + if (CPUID_TO_MODEL(ci->ci_signature) == 4) ci->ci_feat_val[0] &= ~CPUID_TSC; break; case 6: @@ -416,12 +407,12 @@ cpu_probe_c3(struct cpu_info *ci) struct x86_cache_info *cai; if (cpu_vendor != CPUVENDOR_IDT || - CPUID2FAMILY(ci->ci_signature) < 6) + CPUID_TO_FAMILY(ci->ci_signature) < 6) return; - family = CPUID2FAMILY(ci->ci_signature); - model = CPUID2MODEL(ci->ci_signature); - stepping = CPUID2STEPPING(ci->ci_signature); + family = CPUID_TO_FAMILY(ci->ci_signature); + model = CPUID_TO_MODEL(ci->ci_signature); + stepping = CPUID_TO_STEPPING(ci->ci_signature); /* Determine the largest extended function value. */ x86_cpuid(0x80000000, descs); @@ -556,7 +547,7 @@ cpu_probe_geode(struct cpu_info *ci) { if (memcmp("Geode by NSC", ci->ci_vendor, 12) != 0 || - CPUID2FAMILY(ci->ci_signature) != 5) + CPUID_TO_FAMILY(ci->ci_signature) != 5) return; cpu_probe_cyrix_cmn(ci); @@ -668,7 +659,8 @@ cpu_probe(struct cpu_info *ci) ci->ci_feat_val[0] = descs[3]; /* Determine family + class. */ - cpu_class = CPUID2FAMILY(ci->ci_signature) + (CPUCLASS_386 - 3); + cpu_class = CPUID_TO_FAMILY(ci->ci_signature) + + (CPUCLASS_386 - 3); if (cpu_class > CPUCLASS_686) cpu_class = CPUCLASS_686; diff --git a/sys/arch/x86/x86/intel_busclock.c b/sys/arch/x86/x86/intel_busclock.c index fe9e1a6b3be..f5fef6222c3 100644 --- a/sys/arch/x86/x86/intel_busclock.c +++ b/sys/arch/x86/x86/intel_busclock.c @@ -1,4 +1,4 @@ -/* $NetBSD: intel_busclock.c,v 1.16 2013/11/12 16:57:30 msaitoh Exp $ */ +/* $NetBSD: intel_busclock.c,v 1.17 2013/11/15 08:47:55 msaitoh Exp $ */ /*- * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: intel_busclock.c,v 1.16 2013/11/12 16:57:30 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intel_busclock.c,v 1.17 2013/11/15 08:47:55 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -94,12 +94,8 @@ p3_get_bus_clock(struct cpu_info *ci) int bus, bus_clock = 0; uint32_t family, model; - family = CPUID2FAMILY(ci->ci_signature); - model = CPUID2MODEL(ci->ci_signature); - - /* Note that this function is called only when family != 0xf */ - if (family == 6) - model |= CPUID2EXTMODEL(ci->ci_signature) << 4; + family = CPUID_TO_FAMILY(ci->ci_signature); + model = CPUID_TO_MODEL(ci->ci_signature); switch (model) { case 0x9: /* Pentium M (130 nm, Banias) */ @@ -284,7 +280,7 @@ p3_get_bus_clock(struct cpu_info *ci) default: aprint_debug("%s: unknown i686 model %d, can't get bus clock", device_xname(ci->ci_dev), - CPUID2MODEL(ci->ci_signature)); + CPUID_TO_MODEL(ci->ci_signature)); print_msr: /* * Show the EBL_CR_POWERON MSR, so we'll at least have @@ -304,7 +300,7 @@ p4_get_bus_clock(struct cpu_info *ci) int bus, bus_clock = 0; msr = rdmsr(MSR_EBC_FREQUENCY_ID); - if (CPUID2MODEL(ci->ci_signature) < 2) { + if (CPUID_TO_MODEL(ci->ci_signature) < 2) { bus = (msr >> 21) & 0x7; switch (bus) { case 0: @@ -317,14 +313,14 @@ p4_get_bus_clock(struct cpu_info *ci) aprint_debug("%s: unknown Pentium 4 (model %d) " "EBC_FREQUENCY_ID value %d\n", device_xname(ci->ci_dev), - CPUID2MODEL(ci->ci_signature), bus); + CPUID_TO_MODEL(ci->ci_signature), bus); break; } } else { bus = (msr >> 16) & 0x7; switch (bus) { case 0: - bus_clock = (CPUID2MODEL(ci->ci_signature) == 2) ? + bus_clock = (CPUID_TO_MODEL(ci->ci_signature) == 2) ? 10000 : 26666; break; case 1: @@ -340,7 +336,7 @@ p4_get_bus_clock(struct cpu_info *ci) aprint_debug("%s: unknown Pentium 4 (model %d) " "EBC_FREQUENCY_ID value %d\n", device_xname(ci->ci_dev), - CPUID2MODEL(ci->ci_signature), bus); + CPUID_TO_MODEL(ci->ci_signature), bus); break; } } diff --git a/sys/arch/x86/x86/lapic.c b/sys/arch/x86/x86/lapic.c index 602fc4c0537..b6af3ae77d1 100644 --- a/sys/arch/x86/x86/lapic.c +++ b/sys/arch/x86/x86/lapic.c @@ -1,4 +1,4 @@ -/* $NetBSD: lapic.c,v 1.46 2011/06/12 03:35:50 rmind Exp $ */ +/* $NetBSD: lapic.c,v 1.47 2013/11/15 08:47:55 msaitoh Exp $ */ /*- * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.46 2011/06/12 03:35:50 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.47 2013/11/15 08:47:55 msaitoh Exp $"); #include "opt_ddb.h" #include "opt_mpbios.h" /* for MPDEBUG */ @@ -101,7 +101,7 @@ lapic_map(paddr_t lapic_base) * to using it at this point. Be conservative and assume that the MSR * is not present on the Pentium (is it?). */ - if (CPUID2FAMILY(curcpu()->ci_signature) >= 6) { + if (CPUID_TO_FAMILY(curcpu()->ci_signature) >= 6) { lapic_base = (paddr_t)rdmsr(LAPIC_MSR); if ((lapic_base & LAPIC_MSR_ADDR) == 0) { lapic_base |= LAPIC_BASE; diff --git a/sys/arch/x86/x86/odcm.c b/sys/arch/x86/x86/odcm.c index acf5c7e719b..f063a9e1982 100644 --- a/sys/arch/x86/x86/odcm.c +++ b/sys/arch/x86/x86/odcm.c @@ -1,4 +1,4 @@ -/* $NetBSD: odcm.c,v 1.2 2012/06/02 21:36:42 dsl Exp $ */ +/* $NetBSD: odcm.c,v 1.3 2013/11/15 08:47:55 msaitoh Exp $ */ /* $OpenBSD: p4tcc.c,v 1.13 2006/12/20 17:50:40 gwk Exp $ */ /* @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: odcm.c,v 1.2 2012/06/02 21:36:42 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: odcm.c,v 1.3 2013/11/15 08:47:55 msaitoh Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -166,7 +166,7 @@ odcm_quirks(void) x86_cpuid(1, regs); - switch (CPUID2STEPPING(regs[0])) { + switch (CPUID_TO_STEPPING(regs[0])) { case 0x22: /* errata O50 P44 and Z21 */ case 0x24: diff --git a/sys/arch/x86/x86/patch.c b/sys/arch/x86/x86/patch.c index 7c4080fb946..0168033c15d 100644 --- a/sys/arch/x86/x86/patch.c +++ b/sys/arch/x86/x86/patch.c @@ -1,4 +1,4 @@ -/* $NetBSD: patch.c,v 1.21 2010/04/18 23:47:51 jym Exp $ */ +/* $NetBSD: patch.c,v 1.22 2013/11/15 08:47:55 msaitoh Exp $ */ /*- * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.21 2010/04/18 23:47:51 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.22 2013/11/15 08:47:55 msaitoh Exp $"); #include "opt_lockdebug.h" #ifdef i386 @@ -227,9 +227,9 @@ x86_patch(bool early) * sections. Apply workaround. */ if (cpu_vendor == CPUVENDOR_AMD && - (CPUID2FAMILY(cpu_info_primary.ci_signature) == 0xe || - (CPUID2FAMILY(cpu_info_primary.ci_signature) == 0xf && - CPUID2EXTMODEL(cpu_info_primary.ci_signature) < 0x4))) { + (CPUID_TO_FAMILY(cpu_info_primary.ci_signature) == 0xe || + (CPUID_TO_FAMILY(cpu_info_primary.ci_signature) == 0xf && + CPUID_TO_EXTMODEL(cpu_info_primary.ci_signature) < 0x4))) { for (i = 0; x86_retpatch[i] != 0; i++) { /* ret,nop,nop,ret -> lfence,ret */ patchbytes(x86_retpatch[i], 0x0f, 0xae, 0xe8); diff --git a/sys/arch/x86/x86/powernow.c b/sys/arch/x86/x86/powernow.c index 8af88657003..5ed5799067f 100644 --- a/sys/arch/x86/x86/powernow.c +++ b/sys/arch/x86/x86/powernow.c @@ -1,4 +1,4 @@ -/* $NetBSD: powernow.c,v 1.7 2012/10/27 07:19:45 joerg Exp $ */ +/* $NetBSD: powernow.c,v 1.8 2013/11/15 08:47:55 msaitoh Exp $ */ /* $OpenBSD: powernow-k8.c,v 1.8 2006/06/16 05:58:50 gwk Exp $ */ /*- @@ -57,7 +57,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: powernow.c,v 1.7 2012/10/27 07:19:45 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: powernow.c,v 1.8 2013/11/15 08:47:55 msaitoh Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -153,7 +153,7 @@ powernow_match(device_t parent, cfdata_t cf, void *aux) if (cpu_vendor != CPUVENDOR_AMD) return 0; - family = CPUID2FAMILY(ci->ci_signature); + family = CPUID_TO_BASEFAMILY(ci->ci_signature); if (family != 0x06 && family != 0x0f) return 0; @@ -190,7 +190,7 @@ powernow_attach(device_t parent, device_t self, void *aux) sc->sc_state = NULL; sc->sc_freqs = NULL; - family = CPUID2FAMILY(ci->ci_signature); + family = CPUID_TO_BASEFAMILY(ci->ci_signature); switch (family) { @@ -342,7 +342,7 @@ powernow_sysctl_helper(SYSCTLFN_ARGS) if (error || newp == NULL) return error; - family = CPUID2FAMILY(sc->sc_ci->ci_signature); + family = CPUID_TO_BASEFAMILY(sc->sc_ci->ci_signature); if (rnode->sysctl_num == sc->sc_node_target && fq != oldfq) { diff --git a/sys/arch/x86/x86/tprof_amdpmi.c b/sys/arch/x86/x86/tprof_amdpmi.c index 98465d9a248..fc28b97477e 100644 --- a/sys/arch/x86/x86/tprof_amdpmi.c +++ b/sys/arch/x86/x86/tprof_amdpmi.c @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_amdpmi.c,v 1.3 2011/02/05 14:04:40 yamt Exp $ */ +/* $NetBSD: tprof_amdpmi.c,v 1.4 2013/11/15 08:47:55 msaitoh Exp $ */ /*- * Copyright (c)2008,2009 YAMAMOTO Takashi, @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tprof_amdpmi.c,v 1.3 2011/02/05 14:04:40 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tprof_amdpmi.c,v 1.4 2013/11/15 08:47:55 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -178,8 +178,7 @@ tprof_amdpmi_start(tprof_backend_cookie_t *cookie) uint64_t xc; if (!(cpu_vendor == CPUVENDOR_AMD) || - CPUID2FAMILY(ci->ci_signature) + - CPUID2EXTFAMILY(ci->ci_signature) != 0xf) { /* XXX */ + CPUID_TO_FAMILY(ci->ci_signature) != 0xf) { /* XXX */ return ENOTSUP; } diff --git a/sys/arch/x86/x86/tprof_pmi.c b/sys/arch/x86/x86/tprof_pmi.c index 2a0c21ba2f3..d510b22cce1 100644 --- a/sys/arch/x86/x86/tprof_pmi.c +++ b/sys/arch/x86/x86/tprof_pmi.c @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_pmi.c,v 1.12 2011/02/05 14:04:40 yamt Exp $ */ +/* $NetBSD: tprof_pmi.c,v 1.13 2013/11/15 08:47:55 msaitoh Exp $ */ /*- * Copyright (c)2008,2009 YAMAMOTO Takashi, @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tprof_pmi.c,v 1.12 2011/02/05 14:04:40 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tprof_pmi.c,v 1.13 2013/11/15 08:47:55 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -227,7 +227,7 @@ tprof_pmi_start(tprof_backend_cookie_t *cookie) uint64_t xc; if (!(cpu_vendor == CPUVENDOR_INTEL && - CPUID2FAMILY(ci->ci_signature) == 15)) { + CPUID_TO_BASEFAMILY(ci->ci_signature) == 15)) { return ENOTSUP; } diff --git a/sys/arch/x86/x86/tsc.c b/sys/arch/x86/x86/tsc.c index 271766aef3e..5321ee96ab9 100644 --- a/sys/arch/x86/x86/tsc.c +++ b/sys/arch/x86/x86/tsc.c @@ -1,4 +1,4 @@ -/* $NetBSD: tsc.c,v 1.32 2013/07/02 00:01:17 christos Exp $ */ +/* $NetBSD: tsc.c,v 1.33 2013/11/15 08:47:55 msaitoh Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.32 2013/07/02 00:01:17 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.33 2013/11/15 08:47:55 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -95,17 +95,17 @@ tsc_tc_init(void) * that it's safe on P-II and P-III Xeons due to the * typical configuration of those systems. */ - switch (CPUID2FAMILY(ci->ci_signature)) { + switch (CPUID_TO_BASEFAMILY(ci->ci_signature)) { case 0x05: safe = true; break; case 0x06: - safe = CPUID2MODEL(ci->ci_signature) == 0x0e || - CPUID2MODEL(ci->ci_signature) == 0x0f || - CPUID2MODEL(ci->ci_signature) == 0x0a; + safe = CPUID_TO_MODEL(ci->ci_signature) == 0x0e || + CPUID_TO_MODEL(ci->ci_signature) == 0x0f || + CPUID_TO_MODEL(ci->ci_signature) == 0x0a; break; case 0x0f: - safe = CPUID2MODEL(ci->ci_signature) >= 0x03; + safe = CPUID_TO_MODEL(ci->ci_signature) >= 0x03; break; } } else if (cpu_vendor == CPUVENDOR_AMD) { @@ -118,7 +118,7 @@ tsc_tc_init(void) * We're only going to follow the simple, reliable * ones. */ - switch (CPUID2FAMILY(ci->ci_signature)) { + switch (CPUID_TO_BASEFAMILY(ci->ci_signature)) { case 0x06: case 0x07: /* diff --git a/sys/arch/x86/x86/viac7temp.c b/sys/arch/x86/x86/viac7temp.c index 1c608dcea09..451a73a90b3 100644 --- a/sys/arch/x86/x86/viac7temp.c +++ b/sys/arch/x86/x86/viac7temp.c @@ -1,4 +1,4 @@ -/* $NetBSD: viac7temp.c,v 1.6 2011/06/20 17:07:21 pgoyette Exp $ */ +/* $NetBSD: viac7temp.c,v 1.7 2013/11/15 08:47:55 msaitoh Exp $ */ /*- * Copyright (c) 2009 Jared D. McNeill <jmcneill@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: viac7temp.c,v 1.6 2011/06/20 17:07:21 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: viac7temp.c,v 1.7 2013/11/15 08:47:55 msaitoh Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -71,8 +71,8 @@ viac7temp_match(device_t parent, cfdata_t cf, void *aux) if (cpu_vendor != CPUVENDOR_IDT) return 0; - model = CPUID2MODEL(ci->ci_signature); - family = CPUID2FAMILY(ci->ci_signature); + model = CPUID_TO_MODEL(ci->ci_signature); + family = CPUID_TO_FAMILY(ci->ci_signature); if (family != 0x06 || model < 0x09) return 0; diff --git a/usr.sbin/cpuctl/arch/i386.c b/usr.sbin/cpuctl/arch/i386.c index f8ce5b8bd0b..266acc653f7 100644 --- a/usr.sbin/cpuctl/arch/i386.c +++ b/usr.sbin/cpuctl/arch/i386.c @@ -1,4 +1,4 @@ -/* $NetBSD: i386.c,v 1.49 2013/11/07 18:59:01 msaitoh Exp $ */ +/* $NetBSD: i386.c,v 1.50 2013/11/15 08:47:55 msaitoh Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: i386.c,v 1.49 2013/11/07 18:59:01 msaitoh Exp $"); +__RCSID("$NetBSD: i386.c,v 1.50 2013/11/15 08:47:55 msaitoh Exp $"); #endif /* not lint */ #include <sys/types.h> @@ -897,7 +897,7 @@ intel_family_new_probe(struct cpu_info *ci) static void via_cpu_probe(struct cpu_info *ci) { - u_int stepping = CPUID2STEPPING(ci->ci_signature); + u_int stepping = CPUID_TO_STEPPING(ci->ci_signature); u_int descs[4]; u_int lfunc; @@ -1175,7 +1175,7 @@ via_cpu_cacheinfo(struct cpu_info *ci) u_int descs[4]; u_int lfunc; - stepping = CPUID2STEPPING(ci->ci_signature); + stepping = CPUID_TO_STEPPING(ci->ci_signature); /* * Determine the largest extended function value. @@ -1349,12 +1349,8 @@ cpu_probe_base_features(struct cpu_info *ci, const char *cpuname) ci->ci_signature = descs[0]; /* Extract full family/model values */ - ci->ci_family = CPUID2FAMILY(ci->ci_signature); - ci->ci_model = CPUID2MODEL(ci->ci_signature); - if (ci->ci_family == 15) - ci->ci_family += CPUID2EXTFAMILY(ci->ci_signature); - if (ci->ci_family == 6 || ci->ci_family == 15) - ci->ci_model += CPUID2EXTMODEL(ci->ci_signature) << 4; + ci->ci_family = CPUID_TO_FAMILY(ci->ci_signature); + ci->ci_model = CPUID_TO_MODEL(ci->ci_signature); /* Brand is low order 8 bits of ebx */ ci->ci_brand_id = descs[1] & 0xff; @@ -1676,7 +1672,8 @@ identifycpu(int fd, const char *cpuname) else brand = amd_brand_name; } - if (CPUID2FAMILY(ci->ci_signature) == 0xf) { + if (CPUID_TO_BASEFAMILY(ci->ci_signature) + == 0xf) { /* Identify AMD64 CPU names. */ const char *tmp; tmp = amd_amd64_name(ci); @@ -1720,7 +1717,7 @@ identifycpu(int fd, const char *cpuname) (((uintmax_t)ci->ci_tsc_freq + 4999) / 10000) % 100); aprint_normal_dev(ci->ci_dev, "family %#x model %#x stepping %#x", - ci->ci_family, ci->ci_model, CPUID2STEPPING(ci->ci_signature)); + ci->ci_family, ci->ci_model, CPUID_TO_STEPPING(ci->ci_signature)); if (ci->ci_signature != 0) aprint_normal(" (id %#x)", ci->ci_signature); aprint_normal("\n"); |
