Module Name:    src
Committed By:   msaitoh
Date:           Wed Apr 27 06:58:06 UTC 2016

Modified Files:
        src/usr.sbin/cpuctl/arch: i386.c

Log Message:
- 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.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/usr.sbin/cpuctl/arch/i386.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/cpuctl/arch/i386.c
diff -u src/usr.sbin/cpuctl/arch/i386.c:1.70 src/usr.sbin/cpuctl/arch/i386.c:1.71
--- src/usr.sbin/cpuctl/arch/i386.c:1.70	Fri Jan  8 02:28:44 2016
+++ src/usr.sbin/cpuctl/arch/i386.c	Wed Apr 27 06:58:06 2016
@@ -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 @@ struct cpu_info {
 	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 @@ static const char * const i386_intel_bra
 	"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 @@ cpu_probe_base_features(struct cpu_info 
 		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 @@ identifycpu(int fd, const char *cpuname)
 	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 @@ identifycpu(int fd, const char *cpuname)
 		    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

Reply via email to