Source-Changes-HG archive

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

[src/trunk]: src Define CPUID Fn00000001 %ebx bits and use them. No functiona...



details:   https://anonhg.NetBSD.org/src/rev/e85f5db518e7
branches:  trunk
changeset: 356172:e85f5db518e7
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Sep 07 06:40:42 2017 +0000

description:
Define CPUID Fn00000001 %ebx bits and use them. No functional change.

diffstat:

 sys/arch/x86/include/specialreg.h |   8 +++++++-
 sys/arch/x86/x86/cpu_topology.c   |   6 +++---
 sys/arch/x86/x86/identcpu.c       |   9 +++++----
 usr.sbin/cpuctl/arch/i386.c       |  10 +++++-----
 4 files changed, 20 insertions(+), 13 deletions(-)

diffs (118 lines):

diff -r b64992e4fdfe -r e85f5db518e7 sys/arch/x86/include/specialreg.h
--- a/sys/arch/x86/include/specialreg.h Thu Sep 07 06:36:24 2017 +0000
+++ b/sys/arch/x86/include/specialreg.h Thu Sep 07 06:40:42 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: specialreg.h,v 1.101 2017/08/11 06:27:12 maxv Exp $    */
+/*     $NetBSD: specialreg.h,v 1.102 2017/09/07 06:40:42 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -248,6 +248,12 @@
                && (CPUID_TO_BASEFAMILY(cpuid) != 0x06)         \
                ? 0 : (CPUID_TO_EXTMODEL(cpuid) << 4)))
 
+/* CPUID Fn00000001 %ebx */
+#define        CPUID_BRAND_INDEX       __BITS(7,0)
+#define        CPUID_CLFUSH_SIZE       __BITS(15,8)
+#define        CPUID_HTT_CORES         __BITS(23,16)
+#define        CPUID_LOCAL_APIC_ID     __BITS(31,24)
+
 /*
  * Intel Deterministic Cache Parameter Leaf
  * Fn0000_0004
diff -r b64992e4fdfe -r e85f5db518e7 sys/arch/x86/x86/cpu_topology.c
--- a/sys/arch/x86/x86/cpu_topology.c   Thu Sep 07 06:36:24 2017 +0000
+++ b/sys/arch/x86/x86/cpu_topology.c   Thu Sep 07 06:40:42 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu_topology.c,v 1.9 2014/02/22 17:48:08 dsl Exp $     */
+/*     $NetBSD: cpu_topology.c,v 1.10 2017/09/07 06:40:42 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.9 2014/02/22 17:48:08 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.10 2017/09/07 06:40:42 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/bitops.h>
@@ -81,7 +81,7 @@
        if ((ci->ci_feat_val[0] & CPUID_HTT) != 0) {
                /* Maximum number of LPs sharing a cache (ebx[23:16]). */
                x86_cpuid(1, descs);
-               lp_max = (descs[1] >> 16) & 0xff;
+               lp_max = __SHIFTOUT(descs[1], CPUID_HTT_CORES);
        } else {
                lp_max = 1;
        }
diff -r b64992e4fdfe -r e85f5db518e7 sys/arch/x86/x86/identcpu.c
--- a/sys/arch/x86/x86/identcpu.c       Thu Sep 07 06:36:24 2017 +0000
+++ b/sys/arch/x86/x86/identcpu.c       Thu Sep 07 06:40:42 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: identcpu.c,v 1.55 2017/05/23 08:48:34 nonaka Exp $     */
+/*     $NetBSD: identcpu.c,v 1.56 2017/09/07 06:40:42 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.55 2017/05/23 08:48:34 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.56 2017/09/07 06:40:42 msaitoh Exp $");
 
 #include "opt_xen.h"
 
@@ -847,8 +847,9 @@
 
                /* CLFLUSH line size is next 8 bits */
                if (ci->ci_feat_val[0] & CPUID_CFLUSH)
-                       ci->ci_cflush_lsize = ((miscbytes >> 8) & 0xff) << 3;
-               ci->ci_initapicid = (miscbytes >> 24) & 0xff;
+                       ci->ci_cflush_lsize
+                           = __SHIFTOUT(miscbytes, CPUID_CLFUSH_SIZE);
+               ci->ci_initapicid = __SHIFTOUT(miscbytes, CPUID_LOCAL_APIC_ID);
        }
 
        /*
diff -r b64992e4fdfe -r e85f5db518e7 usr.sbin/cpuctl/arch/i386.c
--- a/usr.sbin/cpuctl/arch/i386.c       Thu Sep 07 06:36:24 2017 +0000
+++ b/usr.sbin/cpuctl/arch/i386.c       Thu Sep 07 06:40:42 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i386.c,v 1.74 2016/10/11 04:16:28 msaitoh Exp $        */
+/*     $NetBSD: i386.c,v 1.75 2017/09/07 06:40:42 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.74 2016/10/11 04:16:28 msaitoh Exp $");
+__RCSID("$NetBSD: i386.c,v 1.75 2017/09/07 06:40:42 msaitoh Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -1506,9 +1506,9 @@
        ci->ci_model = CPUID_TO_MODEL(ci->ci_signature);
 
        /* Brand is low order 8 bits of ebx */
-       ci->ci_brand_id = descs[1] & 0xff;
+       ci->ci_brand_id = __SHIFTOUT(descs[1], CPUID_BRAND_INDEX);
        /* Initial local APIC ID */
-       ci->ci_initapicid = (descs[1] >> 24) & 0xff;
+       ci->ci_initapicid = __SHIFTOUT(descs[1], CPUID_LOCAL_APIC_ID);
 
        ci->ci_feat_val[1] = descs[2];
        ci->ci_feat_val[0] = descs[3];
@@ -1668,7 +1668,7 @@
 
        if ((ci->ci_feat_val[0] & CPUID_HTT) != 0) {
                x86_cpuid(1, descs);
-               lp_max = (descs[1] >> 16) & 0xff;
+               lp_max = __SHIFTOUT(descs[1], CPUID_HTT_CORES);
        }
        if (ci->ci_cpuid_level >= 4) {
                x86_cpuid2(4, 0, descs);



Home | Main Index | Thread Index | Old Index