summaryrefslogtreecommitdiff
path: root/util/msrtool
diff options
context:
space:
mode:
authorAnton Kochkov <anton.kochkov@gmail.com>2012-07-04 07:31:37 +0400
committerStefan Reinauer <stefan.reinauer@coreboot.org>2012-07-10 00:56:49 +0200
commitffbbecc9eed9705d7fdb9f6825ab7ccd9224fb09 (patch)
tree122ff5685804395ad52288e2601529d752f94916 /util/msrtool
parente1e6a91ce0738400fa1615179de88ebc0df29f66 (diff)
downloadcoreboot-ffbbecc9eed9705d7fdb9f6825ab7ccd9224fb09.tar.xz
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 <anton.kochkov@gmail.com> Reviewed-on: http://review.coreboot.org/1169 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'util/msrtool')
-rw-r--r--util/msrtool/intel_core1.c2
-rw-r--r--util/msrtool/intel_core2_early.c2
-rw-r--r--util/msrtool/intel_pentium3.c5
-rw-r--r--util/msrtool/intel_pentium3_early.c5
-rw-r--r--util/msrtool/intel_pentium4_early.c2
-rw-r--r--util/msrtool/intel_pentium4_later.c5
-rw-r--r--util/msrtool/msrtool.h2
-rw-r--r--util/msrtool/sys.c19
8 files changed, 35 insertions, 7 deletions
diff --git a/util/msrtool/intel_core1.c b/util/msrtool/intel_core1.c
index c7837c6a69..1ebc7df7df 100644
--- a/util/msrtool/intel_core1.c
+++ b/util/msrtool/intel_core1.c
@@ -21,7 +21,7 @@
int intel_core1_probe(const struct targetdef *target) {
struct cpuid_t *id = cpuid();
- return ((0x6 == id->family)&(0xe == id->model));
+ return ((0x6 == id->family) && (0xe == id->model));
}
const struct msrdef intel_core1_msrs[] = {
diff --git a/util/msrtool/intel_core2_early.c b/util/msrtool/intel_core2_early.c
index 0c6e15ff74..674d7db8da 100644
--- a/util/msrtool/intel_core2_early.c
+++ b/util/msrtool/intel_core2_early.c
@@ -21,7 +21,7 @@
int intel_core2_early_probe(const struct targetdef *target) {
struct cpuid_t *id = cpuid();
- return ((0x6 == id->family)&(0xf == id->model));
+ return ((0x6 == id->family) && (0xf == id->model));
}
const struct msrdef intel_core2_early_msrs[] = {
diff --git a/util/msrtool/intel_pentium3.c b/util/msrtool/intel_pentium3.c
index a2b422562e..442ae3d323 100644
--- a/util/msrtool/intel_pentium3.c
+++ b/util/msrtool/intel_pentium3.c
@@ -21,7 +21,10 @@
int intel_pentium3_probe(const struct targetdef *target) {
struct cpuid_t *id = cpuid();
- return ((0x6 == id->family)&((0xa == id->model)|(0xb == id->model)));
+ return ((0x6 == id->family) && (
+ (0xa == id->model) ||
+ (0xb == id->model)
+ ));
}
const struct msrdef intel_pentium3_msrs[] = {
diff --git a/util/msrtool/intel_pentium3_early.c b/util/msrtool/intel_pentium3_early.c
index 5de74c1d78..ced303778b 100644
--- a/util/msrtool/intel_pentium3_early.c
+++ b/util/msrtool/intel_pentium3_early.c
@@ -21,7 +21,10 @@
int intel_pentium3_early_probe(const struct targetdef *target) {
struct cpuid_t *id = cpuid();
- return ((0x6 == id->family)&((0x7 == id->model)|(0x8 == id->model)));
+ return ((0x6 == id->family) && (
+ (0x7 == id->model) ||
+ (0x8 == id->model)
+ ));
}
const struct msrdef intel_pentium3_early_msrs[] = {
diff --git a/util/msrtool/intel_pentium4_early.c b/util/msrtool/intel_pentium4_early.c
index d6703d2df2..cb6c53e4da 100644
--- a/util/msrtool/intel_pentium4_early.c
+++ b/util/msrtool/intel_pentium4_early.c
@@ -21,7 +21,7 @@
int intel_pentium4_early_probe(const struct targetdef *target) {
struct cpuid_t *id = cpuid();
- return ((0xf == id->family)&(0x2 == id->model));
+ return ((0xf == id->family) && (0x2 == id->model));
}
const struct msrdef intel_pentium4_early_msrs[] = {
diff --git a/util/msrtool/intel_pentium4_later.c b/util/msrtool/intel_pentium4_later.c
index 6bb6ebea43..7c077eef49 100644
--- a/util/msrtool/intel_pentium4_later.c
+++ b/util/msrtool/intel_pentium4_later.c
@@ -21,7 +21,10 @@
int intel_pentium4_later_probe(const struct targetdef *target) {
struct cpuid_t *id = cpuid();
- return ((0xf == id->family)&((0x3 == id->model)|(0x4 == id->model)));
+ return ((0xf == id->family) && (
+ (0x3 == id->model) ||
+ (0x4 == id->model)
+ ));
}
const struct msrdef intel_pentium4_later_msrs[] = {
diff --git a/util/msrtool/msrtool.h b/util/msrtool/msrtool.h
index e6cea46863..162e743f65 100644
--- a/util/msrtool/msrtool.h
+++ b/util/msrtool/msrtool.h
@@ -126,6 +126,7 @@ struct sysdef {
#define SYSTEM_EOT .name = NULL
#define SYSTEM_ISEOT(s) (NULL == (s).name)
+typedef enum { VENDOR_INTEL = 1, VENDOR_AMD = 2 } vendor_t;
struct cpuid_t {
uint8_t family;
@@ -133,6 +134,7 @@ struct cpuid_t {
uint8_t stepping;
uint8_t ext_family;
uint8_t ext_model;
+ vendor_t vendor;
};
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;