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