#include "inteltool.h"
+#ifdef __x86_64__
+# define BREG "%%rbx"
+#else
+# define BREG "%%ebx"
+#endif
+
int fd_msr;
unsigned int cpuid(unsigned int op)
#if defined(__PIC__) || defined(__DARWIN__) && !defined(__LP64__)
asm volatile (
- "pushl %%ebx\n"
- "cpuid\n"
- "popl %%ebx\n"
+ "push " BREG "\n\t"
+ "cpuid\n\t"
+ "pop " BREG "\n\t"
: "=a" (ret) : "a" (op) : "%ecx", "%edx"
);
#else
msr_t rdmsr(int addr)
{
- uint8_t buf[8];
+ uint32_t buf[2];
msr_t msr = { 0xffffffff, 0xffffffff };
if (lseek(fd_msr, (off_t) addr, SEEK_SET) == -1) {
}
if (read(fd_msr, buf, 8) == 8) {
- msr.lo = *(uint32_t *)buf;
- msr.hi = *(uint32_t *)(buf + 4);
-
+ msr.lo = buf[0];
+ msr.hi = buf[1];
return msr;
}