| 1 |
|
| 2 |
|
| 3 |
#include <sys/types.h> |
| 4 |
#include <sys/stat.h> |
| 5 |
#include <fcntl.h> |
| 6 |
#include <unistd.h> |
| 7 |
#include <string.h> |
| 8 |
#include <errno.h> |
| 9 |
|
| 10 |
#include "msrtool.h" |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
int darwin_probe(const struct sysdef *system) |
| 17 |
{ |
| 18 |
#ifdef __DARWIN__ |
| 19 |
return iopl(3) == 0; |
| 20 |
#else |
| 21 |
return 0; |
| 22 |
#endif |
| 23 |
} |
| 24 |
|
| 25 |
int darwin_open(uint8_t cpu, enum SysModes mode) |
| 26 |
{ |
| 27 |
#ifdef __DARWIN__ |
| 28 |
if (cpu > 0) { |
| 29 |
fprintf(stderr, "%s: only core 0 is supported on Mac OS X right now.\n", __func__); |
| 30 |
return 0; |
| 31 |
} |
| 32 |
return 1; |
| 33 |
#else |
| 34 |
return 0; |
| 35 |
#endif |
| 36 |
} |
| 37 |
|
| 38 |
int darwin_close(uint8_t cpu) |
| 39 |
{ |
| 40 |
return 1; |
| 41 |
} |
| 42 |
|
| 43 |
int darwin_rdmsr(uint8_t cpu, uint32_t addr, struct msr *val) |
| 44 |
{ |
| 45 |
#ifdef __DARWIN__ |
| 46 |
msr_t msr; |
| 47 |
|
| 48 |
msr = rdmsr(addr); |
| 49 |
|
| 50 |
val->hi = msr.lo; |
| 51 |
val->lo = msr.hi; |
| 52 |
return 1; |
| 53 |
#else |
| 54 |
return 0; |
| 55 |
#endif |
| 56 |
} |