| 122 | } |
| 123 | |
| 124 | static msr_t rdmsr_from_cpu(int cpu, unsigned long addr) |
| 125 | { |
| 126 | int fd; |
| 127 | msr_t msr = { 0xffffffff, 0xffffffff }; |
| 128 | uint32_t buf[2]; |
| 129 | char temp_string[50]; |
| 130 | |
| 131 | if (open_and_seek(cpu, addr, O_RDONLY, &fd) < 0) { |
| 132 | snprintf(temp_string, sizeof(temp_string), |
| 133 | "Could not read MSR for CPU#%d", cpu); |
| 134 | perror(temp_string); |
| 135 | } |
| 136 | |
| 137 | if (read(fd, buf, 8) == 8) { |
| 138 | msr.lo = buf[0]; |
| 139 | msr.hi = buf[1]; |
| 140 | } |
| 141 | |
| 142 | close(fd); |
| 143 | |
| 144 | return msr; |
| 145 | } |
| 146 | |
| 147 | static int get_number_of_cpus(void) |
| 148 | { |
no test coverage detected