]> xenbits.xensource.com Git - people/liuw/xtf.git/commitdiff
Collect CPU family/model/stepping information on boot
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 27 May 2016 13:34:41 +0000 (14:34 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 5 Jul 2016 12:58:30 +0000 (13:58 +0100)
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/setup.c
include/arch/x86/cpuid.h

index dd214927cd96ac2898297596d1201c93cf33ae38..433148a84befc6bbcd2701d4e342910628a1e48e 100644 (file)
@@ -18,6 +18,7 @@
 uint8_t boot_stack[2 * PAGE_SIZE] __aligned(PAGE_SIZE);
 uint32_t x86_features[FSCAPINTS];
 enum x86_vendor x86_vendor;
+unsigned int x86_family, x86_model, x86_stepping;
 
 const char *environment_description = ENVIRONMENT_DESCRIPTION;
 
@@ -28,7 +29,7 @@ start_info_t *start_info = NULL;
 
 static void collect_cpuid(cpuid_count_fn_t cpuid_fn)
 {
-    unsigned int max, tmp, ebx, ecx, edx;
+    unsigned int max, tmp, eax, ebx, ecx, edx;
 
     cpuid_fn(0, 0, &max, &ebx, &ecx, &edx);
 
@@ -46,9 +47,22 @@ static void collect_cpuid(cpuid_count_fn_t cpuid_fn)
         x86_vendor = X86_VENDOR_UNKNOWN;
 
     if ( max >= 1 )
-        cpuid_fn(1, 0, &tmp, &tmp,
+    {
+        cpuid_fn(1, 0, &eax, &tmp,
                  &x86_features[FEATURESET_1c],
                  &x86_features[FEATURESET_1d]);
+
+        x86_stepping = (eax >> 0) & 0xf;
+        x86_model    = (eax >> 4) & 0xf;
+        x86_family   = (eax >> 8) & 0xf;
+
+        if ( (x86_family == 0xf) ||
+             (x86_vendor == X86_VENDOR_INTEL && x86_family == 0x6) )
+            x86_model |= ((eax >> 16) & 0xf) << 4;
+
+        if ( x86_family == 0xf )
+            x86_family += (eax >> 20) & 0xff;
+    }
     if ( max >= 7 )
         cpuid_fn(7, 0, &tmp,
                  &x86_features[FEATURESET_7b0],
index 35e6f233bb63c01933fe5afb3eb3d55ed0a5e3b5..f09337b9210c44a5d17898ba6bd1b0e908c0ae93 100644 (file)
@@ -21,6 +21,7 @@ enum x86_vendor
 };
 
 extern enum x86_vendor x86_vendor;
+extern unsigned int x86_family, x86_model, x86_stepping;
 
 static inline bool vendor_is(enum x86_vendor v)
 {