MCPcopy Create free account
hub / github.com/coreboot/coreboot / rdmsr

Function rdmsr

util/inteltool/cpu.c:79–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77int msr_readerror = 0;
78
79static msr_t rdmsr(int addr)
80{
81 uint32_t buf[2];
82 msr_t msr = { 0xffffffff, 0xffffffff };
83
84 if (lseek(fd_msr, (off_t) addr, SEEK_SET) == -1) {
85 perror("Could not lseek() to MSR");
86 close(fd_msr);
87 exit(1);
88 }
89
90 if (read(fd_msr, buf, 8) == 8) {
91 msr.lo = buf[0];
92 msr.hi = buf[1];
93 return msr;
94 }
95
96 if (errno == 5) {
97 printf(" (*)"); // Not all bits of the MSR could be read
98 msr_readerror = 1;
99 } else {
100 // A severe error.
101 perror("Could not read() MSR");
102 close(fd_msr);
103 exit(1);
104 }
105
106 return msr;
107}
108
109static int open_and_seek(int cpu, unsigned long msr, int mode, int *fd)
110{

Callers 1

print_intel_msrsFunction · 0.70

Calls 4

perrorFunction · 0.85
exitFunction · 0.85
readFunction · 0.85
printfFunction · 0.85

Tested by

no test coverage detected