Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/cpuctl/arch - Add structure extended feature regist...



details:   https://anonhg.NetBSD.org/src/rev/bbe4b0f5047f
branches:  trunk
changeset: 344904:bbe4b0f5047f
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Apr 27 06:58:06 2016 +0000

description:
- Add structure extended feature registers into ci_feat_val[]. The locations
  are the same as x86/include/cpu.h. Curreltly those values are not used yet.
- KNF.

diffstat:

 usr.sbin/cpuctl/arch/i386.c |  32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 deletions(-)

diffs (98 lines):

diff -r 852b2d605c65 -r bbe4b0f5047f usr.sbin/cpuctl/arch/i386.c
--- a/usr.sbin/cpuctl/arch/i386.c       Wed Apr 27 06:57:24 2016 +0000
+++ b/usr.sbin/cpuctl/arch/i386.c       Wed Apr 27 06:58:06 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i386.c,v 1.70 2016/01/08 02:28:44 msaitoh Exp $        */
+/*     $NetBSD: i386.c,v 1.71 2016/04/27 06:58:06 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.70 2016/01/08 02:28:44 msaitoh Exp $");
+__RCSID("$NetBSD: i386.c,v 1.71 2016/04/27 06:58:06 msaitoh Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -98,14 +98,16 @@
        uint32_t        ci_signature;    /* X86 cpuid type */
        uint32_t        ci_family;       /* from ci_signature */
        uint32_t        ci_model;        /* from ci_signature */
-       uint32_t        ci_feat_val[8];  /* X86 CPUID feature bits
+       uint32_t        ci_feat_val[9];  /* X86 CPUID feature bits
                                          *     [0] basic features %edx
                                          *     [1] basic features %ecx
                                          *     [2] extended features %edx
                                          *     [3] extended features %ecx
                                          *     [4] VIA padlock features
-                                         *     [5] XCR0 bits (d:0 %eax)
-                                         *     [6] xsave flags (d:1 %eax)
+                                         *     [5] structure ext. feat. %ebx
+                                         *     [6] structure ext. feat. %ecx
+                                         *     [7] XCR0 bits (d:0 %eax)
+                                         *     [8] xsave flags (d:1 %eax)
                                          */
        uint32_t        ci_cpu_class;    /* CPU class */
        uint32_t        ci_brand_id;     /* Intel brand id */
@@ -163,7 +165,7 @@
        "Pentium III Xeon", /* Intel (R) Pentium (R) III Xeon (TM) processor */
        "Pentium III",      /* Intel (R) Pentium (R) III processor */
        "",                 /* 0x05: Reserved */
-       "Mobile Pentium III", /* Mobile Intel (R) Pentium (R) III processor-M */
+       "Mobile Pentium III",/* Mobile Intel (R) Pentium (R) III processor-M */
        "Mobile Celeron",   /* Mobile Intel (R) Celeron (R) processor */    
        "Pentium 4",        /* Intel (R) Pentium (R) 4 processor */
        "Pentium 4",        /* Intel (R) Pentium (R) 4 processor */
@@ -1519,18 +1521,25 @@
                ci->ci_cpu_serial[1] = descs[3];
        }
 
+       if (ci->ci_cpuid_level < 0x7)
+               return;
+
+       x86_cpuid(7, descs);
+       ci->ci_feat_val[5] = descs[1];
+       ci->ci_feat_val[6] = descs[2];
+
        if (ci->ci_cpuid_level < 0xd)
                return;
 
        /* Get support XCR0 bits */
        x86_cpuid2(0xd, 0, descs);
-       ci->ci_feat_val[5] = descs[0];  /* Actually 64 bits */
+       ci->ci_feat_val[7] = descs[0];  /* Actually 64 bits */
        ci->ci_cur_xsave = descs[1];
        ci->ci_max_xsave = descs[2];
 
        /* Additional flags (eg xsaveopt support) */
        x86_cpuid2(0xd, 1, descs);
-       ci->ci_feat_val[6] = descs[0];   /* Actually 64 bits */
+       ci->ci_feat_val[8] = descs[0];   /* Actually 64 bits */
 }
 
 static void
@@ -1878,9 +1887,9 @@
        print_bits(cpuname, "padloack features", CPUID_FLAGS_PADLOCK,
            ci->ci_feat_val[4]);
 
-       print_bits(cpuname, "xsave features", XCR0_FLAGS1, ci->ci_feat_val[5]);
+       print_bits(cpuname, "xsave features", XCR0_FLAGS1, ci->ci_feat_val[7]);
        print_bits(cpuname, "xsave instructions", CPUID_PES1_FLAGS,
-           ci->ci_feat_val[6]);
+           ci->ci_feat_val[8]);
 
        if (ci->ci_max_xsave != 0) {
                aprint_normal("%s: xsave area size: current %d, maximum %d",
@@ -1902,9 +1911,8 @@
                    ci->ci_cpu_serial[2] / 65536, ci->ci_cpu_serial[2] % 65536);
        }
 
-       if (ci->ci_cpu_class == CPUCLASS_386) {
+       if (ci->ci_cpu_class == CPUCLASS_386)
                errx(1, "NetBSD requires an 80486 or later processor");
-       }
 
        if (ci->ci_cpu_type == CPU_486DLC) {
 #ifndef CYRIX_CACHE_WORKS



Home | Main Index | Thread Index | Old Index