aboutsummaryrefslogtreecommitdiff
path: root/util/msrtool/sys.c
diff options
context:
space:
mode:
authorStefan Reinauer <stepan@coresystems.de>2009-09-01 10:03:01 +0000
committerStefan Reinauer <stepan@openbios.org>2009-09-01 10:03:01 +0000
commit37f3935029cef0616fa36b9c822496e3e51f03ba (patch)
tree347c23e4a92e282a9e2d074d46e29cd73475e1db /util/msrtool/sys.c
parente95eb616cc987072a1a17f8b98854645fb82bfce (diff)
port msrtool to darwin.
Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Peter Stuge <peter@stuge.se> with minor changes to allow 32bit and 64bit compilation and (I hope), Peter's concerns addressed. git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4624 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/msrtool/sys.c')
-rw-r--r--util/msrtool/sys.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/util/msrtool/sys.c b/util/msrtool/sys.c
index cc2cc4e7c0..f6aded52bc 100644
--- a/util/msrtool/sys.c
+++ b/util/msrtool/sys.c
@@ -2,6 +2,7 @@
* This file is part of msrtool.
*
* Copyright (c) 2008 Peter Stuge <peter@stuge.se>
+ * Copyright (c) 2009 coresystems GmbH
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -25,7 +26,18 @@ static struct cpuid_t id;
struct cpuid_t *cpuid(void) {
uint32_t outeax;
+
+#if defined(__DARWIN__) && !defined(__LP64__)
+ asm volatile (
+ "pushl %%ebx \n"
+ "cpuid \n"
+ "popl %%ebx \n"
+ : "=a" (outeax) : "a" (1) : "%ecx", "%edx"
+ );
+#else
asm ("cpuid" : "=a" (outeax) : "a" (1) : "%ebx", "%ecx", "%edx");
+#endif
+
id.stepping = outeax & 0xf;
outeax >>= 4;
id.model = outeax & 0xf;
@@ -40,6 +52,9 @@ struct cpuid_t *cpuid(void) {
id.model |= (id.ext_model << 4);
id.family += id.ext_family;
}
+ printf_verbose("CPU: family %x, model %x, stepping %x\n",
+ id.family, id.model, id.stepping);
+
return &id;
}