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

Function open_and_seek

util/inteltool/cpu.c:109–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109static int open_and_seek(int cpu, unsigned long msr, int mode, int *fd)
110{
111 char dev[32];
112 char temp_string[50];
113
114 snprintf(dev, sizeof(dev), "/dev/cpu/%d/msr", cpu);
115 *fd = open(dev, mode);
116
117 if (*fd < 0) {
118 snprintf(temp_string, sizeof(temp_string), "open(\"%s\")", dev);
119 perror(temp_string);
120 return -1;
121 }
122
123 if (lseek(*fd, msr, SEEK_SET) == (off_t)-1) {
124 snprintf(temp_string, sizeof(temp_string), "lseek(%lu)", msr);
125 perror(temp_string);
126 close(*fd);
127 return -1;
128 }
129
130 return 0;
131}
132
133static msr_t rdmsr_from_cpu(int cpu, unsigned long addr)
134{

Callers 1

rdmsr_from_cpuFunction · 0.70

Calls 2

perrorFunction · 0.85
snprintfFunction · 0.50

Tested by

no test coverage detected