summaryrefslogtreecommitdiff
path: root/util/inteltool/cpu.c
diff options
context:
space:
mode:
authorStefan Reinauer <stepan@coresystems.de>2009-09-01 09:52:14 +0000
committerStefan Reinauer <stepan@openbios.org>2009-09-01 09:52:14 +0000
commitf7f2f258d8b44218c2efb83cfb276890fd4fb95c (patch)
treed6eb6993ca8574571bfed1ca0b05835ea5850e1a /util/inteltool/cpu.c
parentb2aedb1a3f2409b549c4094654281893b82c7435 (diff)
downloadcoreboot-f7f2f258d8b44218c2efb83cfb276890fd4fb95c.tar.xz
Clean up Mac OS X support of inteltool
Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Peter Stuge <peter@stuge.se> Some minor modifications to allow 64bit/32bit compilation on Darwin git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4621 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/inteltool/cpu.c')
-rw-r--r--util/inteltool/cpu.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/util/inteltool/cpu.c b/util/inteltool/cpu.c
index c1972b77ea..9427fee9d5 100644
--- a/util/inteltool/cpu.c
+++ b/util/inteltool/cpu.c
@@ -30,30 +30,23 @@ int fd_msr;
unsigned int cpuid(unsigned int op)
{
- unsigned int ret;
- unsigned int dummy2, dummy3, dummy4;
-#if DARWIN
- asm volatile (
- "pushl %%ebx \n"
- "cpuid \n"
- "movl %%ebx, %1 \n"
- "popl %%ebx \n"
- : "=a" (ret), "=r" (dummy2), "=c" (dummy3), "=d" (dummy4)
- : "a" (op)
- : "cc"
- );
+ uint32_t ret;
+
+#if defined(__DARWIN__) && !defined(__LP64__)
+ asm volatile (
+ "pushl %%ebx \n"
+ "cpuid \n"
+ "popl %%ebx \n"
+ : "=a" (ret) : "a" (op) : "%ecx", "%edx"
+ );
#else
- asm volatile (
- "cpuid"
- : "=a" (ret), "=b" (dummy2), "=c" (dummy3), "=d" (dummy4)
- : "a" (op)
- : "cc"
- );
+ asm ("cpuid" : "=a" (ret) : "a" (op) : "%ebx", "%ecx", "%edx");
#endif
+
return ret;
}
-#ifndef DARWIN
+#ifndef __DARWIN__
int msr_readerror = 0;
msr_t rdmsr(int addr)
@@ -288,7 +281,7 @@ int print_intel_core_msrs(void)
return -1;
}
-#ifndef DARWIN
+#ifndef __DARWIN__
fd_msr = open("/dev/cpu/0/msr", O_RDWR);
if (fd_msr < 0) {
perror("Error while opening /dev/cpu/0/msr");
@@ -309,7 +302,7 @@ int print_intel_core_msrs(void)
close(fd_msr);
for (core = 0; core < 8; core++) {
-#ifndef DARWIN
+#ifndef __DARWIN__
char msrfilename[64];
memset(msrfilename, 0, 64);
sprintf(msrfilename, "/dev/cpu/%d/msr", core);
@@ -330,12 +323,12 @@ int print_intel_core_msrs(void)
cpu->per_core_msrs[i].number, msr.hi, msr.lo,
cpu->per_core_msrs[i].name);
}
-#ifndef DARWIN
+#ifndef __DARWIN__
close(fd_msr);
#endif
}
-#ifndef DARWIN
+#ifndef __DARWIN__
if (msr_readerror)
printf("\n(*) Some MSRs could not be read. The marked values are unreliable.\n");
#endif