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

Function diff_msr

util/msrtool/msrutils.c:303–342  ·  view source on GitHub ↗

* Compare two MSR values and print any differences with field definitions and * both old and new values decoded. * * @param f Output stream. * @param addr MSR address. * @param a Left value. * @param b Right value. * @return 1 when a and b differ, 0 when they are equal or only reserved bits * differ and processing of reserved bits was not requested (with -r). */

Source from the content-addressed store, hash-verified

301 * differ and processing of reserved bits was not requested (with -r).
302 */
303uint8_t diff_msr(FILE *f, const uint32_t addr, const struct msr a, const struct msr b) {
304 uint8_t ret = 0, first = 1;
305 struct msr aval, bval, mask;
306 const struct msrdef *m = findmsrdef(addr);
307 const struct msrbits *mb;
308
309 if (a.hi == b.hi && a.lo == b.lo)
310 return 0;
311
312 if (NULL == m) {
313 fprintf(stderr, "MSR 0x%08x has no definition! Please add it and send a Signed-off-by patch\n", addr);
314 fprintf(stderr, "to coreboot@coreboot.org. Thank you for your help!\n");
315 return 1;
316 }
317
318 for (mb = m->bits; mb->size; mb++) {
319 if (!reserved && 0 == strcmp(mb->name, "RSVD"))
320 continue;
321 mask.hi = mask.lo = 0xffffffff;
322 mask = msr_shr(mask, 64 - mb->size);
323 aval = msr_shr(a, mb->start - mb->size + 1);
324 bval = msr_shr(b, mb->start - mb->size + 1);
325 msr_and(&aval, mask);
326 msr_and(&bval, mask);
327 if (msr_eq(aval, bval))
328 continue;
329 if (first) {
330 fprintf(f, "# %s\n", m->symbol);
331 fprintf(f, "-0x%08x 0x%08x%08x\n", addr, a.hi, a.lo);
332 fprintf(f, "+0x%08x 0x%08x%08x\n", addr, b.hi, b.lo);
333 first = 0;
334 ret = 1;
335 }
336 print_bitdef(f, mb, "\n-");
337 print_bitval(f, mb, aval);
338 fprintf(f, "+");
339 print_bitval(f, mb, bval);
340 }
341 return ret;
342}

Callers 1

do_diffFunction · 0.85

Calls 8

findmsrdefFunction · 0.85
fprintfFunction · 0.85
msr_shrFunction · 0.85
msr_andFunction · 0.85
msr_eqFunction · 0.85
print_bitdefFunction · 0.85
print_bitvalFunction · 0.85
strcmpFunction · 0.50

Tested by

no test coverage detected