[coreboot-gerrit] Change in coreboot[master]: msrtool: add support for printing string values

Philipp Deppenwiese (Code Review) gerrit at coreboot.org
Sun May 13 12:07:29 CEST 2018


Philipp Deppenwiese has submitted this change and it was merged. ( https://review.coreboot.org/18257 )

Change subject: msrtool: add support for printing string values
......................................................................

msrtool: add support for printing string values

The VIA CPUs allow setting the CPUID vendor, which is best read as
a character string.

Change-Id: I67f77ca75f7d77e47b3ba09bad904df5805e373a
Signed-off-by: Lubomir Rintel <lkundrak at v3.sk>
Reviewed-on: https://review.coreboot.org/18257
Tested-by: build bot (Jenkins) <no-reply at coreboot.org>
Reviewed-by: Martin Roth <martinroth at google.com>
---
M util/msrtool/msrtool.h
M util/msrtool/msrutils.c
2 files changed, 25 insertions(+), 1 deletion(-)

Approvals:
  build bot (Jenkins): Verified
  Martin Roth: Looks good to me, approved



diff --git a/util/msrtool/msrtool.h b/util/msrtool/msrtool.h
index 93881e9..1e923c4 100644
--- a/util/msrtool/msrtool.h
+++ b/util/msrtool/msrtool.h
@@ -45,7 +45,8 @@
 	PRESENT_BIN,
 	PRESENT_OCT,
 	PRESENT_HEX,
-	PRESENT_HEXDEC
+	PRESENT_HEXDEC,
+	PRESENT_STR,
 } PresentTypes;
 
 struct msr {
@@ -162,6 +163,7 @@
 
 /* msrutils.c */
 void hexprint(FILE *f, const struct msr val, const uint8_t bits);
+void strprint(FILE *f, const struct msr val, const uint8_t bits);
 int msr_eq(const struct msr a, const struct msr b);
 struct msr msr_shl(const struct msr a, const uint8_t bits);
 struct msr msr_shr(const struct msr a, const uint8_t bits);
diff --git a/util/msrtool/msrutils.c b/util/msrtool/msrutils.c
index 57a271d..1c6707e 100644
--- a/util/msrtool/msrutils.c
+++ b/util/msrtool/msrutils.c
@@ -65,6 +65,9 @@
 		hexprint(f, val, mb->size);
 		fprintf(f, " %d", val.lo);
 		break;
+	case PRESENT_STR:
+		strprint(f, val, mb->size);
+		break;
 	}
 	if (mbv->text)
 		fprintf(f, ": %s", mbv->text);
@@ -106,6 +109,25 @@
 		fprintf(f, "0x%08x%08x", val.hi, val.lo);
 }
 
+void strprint(FILE *f, const struct msr val, const uint8_t bits) {
+	if (bits > 56)
+		fputc(val.hi, f);
+	if (bits > 48)
+		fputc(val.hi >> 8, f);
+	if (bits > 40)
+		fputc(val.hi >> 16, f);
+	if (bits > 32)
+		fputc(val.hi >> 24, f);
+	if (bits > 24)
+		fputc(val.lo, f);
+	if (bits > 16)
+		fputc(val.lo >> 8, f);
+	if (bits > 8)
+		fputc(val.lo >> 16, f);
+	if (bits > 0)
+		fputc(val.lo >> 24, f);
+}
+
 int msr_eq(const struct msr a, const struct msr b) {
 	return a.hi == b.hi && a.lo == b.lo;
 }

-- 
To view, visit https://review.coreboot.org/18257
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I67f77ca75f7d77e47b3ba09bad904df5805e373a
Gerrit-Change-Number: 18257
Gerrit-PatchSet: 5
Gerrit-Owner: Lubomir Rintel <lkundrak at v3.sk>
Gerrit-Reviewer: Martin Roth <martinroth at google.com>
Gerrit-Reviewer: Paul Menzel <paulepanter at users.sourceforge.net>
Gerrit-Reviewer: Philipp Deppenwiese <zaolin.daisuki at gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply at coreboot.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180513/1f61c849/attachment.html>


More information about the coreboot-gerrit mailing list