From ffbbecc9eed9705d7fdb9f6825ab7ccd9224fb09 Mon Sep 17 00:00:00 2001 From: Anton Kochkov Date: Wed, 4 Jul 2012 07:31:37 +0400 Subject: msrtool: Fix Intel CPUs detection Added vendor check in sys.c file and fixed models checking in intel targets files. Change-Id: I1ce52bbce431dea79e903d6bc7a12e5b9ad061be Signed-off-by: Anton Kochkov Reviewed-on: http://review.coreboot.org/1169 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- util/msrtool/sys.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'util/msrtool/sys.c') diff --git a/util/msrtool/sys.c b/util/msrtool/sys.c index f6aded52bc..7300abf476 100644 --- a/util/msrtool/sys.c +++ b/util/msrtool/sys.c @@ -26,7 +26,23 @@ static struct cpuid_t id; struct cpuid_t *cpuid(void) { uint32_t outeax; + uint32_t outebx; +/* First, we need determine which vendor we have */ +#if defined(__DARWIN__) && !defined(__LP64__) + asm volatile ( + "pushl %%ebx \n" + "cpuid \n" + "popl %%ebx \n" + : "=b" (outebx) : "a" (0) : "%ecx", "%edx" + ); +#else + asm ("cpuid" : "=b" (outebx) : "a" (0) : "%ecx", "%edx"); +#endif + + id.vendor = (outebx == 0x756e6547) ? VENDOR_INTEL : VENDOR_AMD; + +/* Then, identificate CPU itself */ #if defined(__DARWIN__) && !defined(__LP64__) asm volatile ( "pushl %%ebx \n" @@ -47,7 +63,8 @@ struct cpuid_t *cpuid(void) { id.ext_model = outeax & 0xf; outeax >>= 4; id.ext_family = outeax & 0xff; - if (0xf == id.family) { + if ((0xf == id.family) || ((VENDOR_INTEL == id.vendor) + && (0x6 == id.family))) { /* Intel says always do this, AMD says only for family f */ id.model |= (id.ext_model << 4); id.family += id.ext_family; -- cgit v1.2.3