[patch] extending {amd64|i386} cpu info

Alexander Best alexbestms at wwu.de
Thu Mar 11 13:43:38 UTC 2010


since ed@ noticed that there's no CPUID_TO_STEPPING() macro this new patch
adds one. i checked and include/specialreg.h is only available on amd64, i386
and pc98. all the latter does however is:

#include <i386/specialreg.h>

cheers.
alex
-------------- next part --------------
Index: amd64/include/specialreg.h
===================================================================
--- amd64/include/specialreg.h	(revision 204977)
+++ amd64/include/specialreg.h	(working copy)
@@ -169,6 +169,8 @@
 #define	CPUID_FAMILY		0x00000f00
 #define	CPUID_EXT_MODEL		0x000f0000
 #define	CPUID_EXT_FAMILY	0x0ff00000
+#define CPUID_TO_STEPPING(id) \
+    ((id) & CPUID_STEPPING)
 #define	CPUID_TO_MODEL(id) \
     ((((id) & CPUID_MODEL) >> 4) | \
     (((id) & CPUID_EXT_MODEL) >> 12))
Index: amd64/amd64/identcpu.c
===================================================================
--- amd64/amd64/identcpu.c	(revision 204977)
+++ amd64/amd64/identcpu.c	(working copy)
@@ -187,7 +187,12 @@
 	if (cpu_vendor_id == CPU_VENDOR_INTEL ||
 	    cpu_vendor_id == CPU_VENDOR_AMD ||
 	    cpu_vendor_id == CPU_VENDOR_CENTAUR) {
-		printf("  Stepping = %u", cpu_id & 0xf);
+		printf("  Stepping = %u"
+		       "  Model = %u"
+		       "  Family = %u",
+		       CPUID_TO_STEPPING(cpu_id),
+		       CPUID_TO_MODEL(cpu_id),
+		       CPUID_TO_FAMILY(cpu_id));
 		if (cpu_high > 0) {
 
 			/*
Index: i386/include/specialreg.h
===================================================================
--- i386/include/specialreg.h	(revision 204977)
+++ i386/include/specialreg.h	(working copy)
@@ -166,6 +166,8 @@
 #define	CPUID_FAMILY		0x00000f00
 #define	CPUID_EXT_MODEL		0x000f0000
 #define	CPUID_EXT_FAMILY	0x0ff00000
+#define CPUID_TO_STEPPING(id) \
+    ((id) & CPUID_STEPPING)
 #define	CPUID_TO_MODEL(id) \
     ((((id) & CPUID_MODEL) >> 4) | \
     ((((id) & CPUID_FAMILY) >= 0x600) ? \
Index: i386/i386/identcpu.c
===================================================================
--- i386/i386/identcpu.c	(revision 204977)
+++ i386/i386/identcpu.c	(working copy)
@@ -672,7 +672,12 @@
 	    cpu_vendor_id == CPU_VENDOR_NSC ||
 		(cpu_vendor_id == CPU_VENDOR_CYRIX &&
 		 ((cpu_id & 0xf00) > 0x500))) {
-		printf("  Stepping = %u", cpu_id & 0xf);
+		printf("  Stepping = %u"
+		       "  Model = %u"
+		       "  Family = %u",
+		       CPUID_TO_STEPPING(cpu_id),
+		       CPUID_TO_MODEL(cpu_id),
+		       CPUID_TO_FAMILY(cpu_id));
 		if (cpu_vendor_id == CPU_VENDOR_CYRIX)
 			printf("  DIR=0x%04x", cyrix_did);
 		if (cpu_high > 0) {


More information about the freebsd-hackers mailing list