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

Function rdmsr

util/amdtool/cpu.c:70–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

print_amd_msrsFunction · 0.70
init_video_modeFunction · 0.50
darwin_rdmsrFunction · 0.50

Calls 4

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

Tested by

no test coverage detected