[coreboot-gerrit] Patch set updated for coreboot: msrtool: add support for printing string values

Lubomir Rintel (lkundrak@v3.sk) gerrit at coreboot.org
Mon Feb 13 19:55:11 CET 2017


Lubomir Rintel (lkundrak at v3.sk) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/18257

-gerrit

commit 1d0a308796c9150ebcf09cb3e7e4e02a0d032849
Author: Lubomir Rintel <lkundrak at v3.sk>
Date:   Sun Jan 22 22:19:33 2017 +0100

    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>
---
 util/msrtool/msrtool.h  |  4 +++-
 util/msrtool/msrutils.c | 22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/util/msrtool/msrtool.h b/util/msrtool/msrtool.h
index 6565fff..7e85dc0 100644
--- a/util/msrtool/msrtool.h
+++ b/util/msrtool/msrtool.h
@@ -45,7 +45,8 @@ enum {
 	PRESENT_BIN,
 	PRESENT_OCT,
 	PRESENT_HEX,
-	PRESENT_HEXDEC
+	PRESENT_HEXDEC,
+	PRESENT_STR,
 } PresentTypes;
 
 struct msr {
@@ -162,6 +163,7 @@ struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
 
 /* 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 @@ static void print_bitval(FILE *f, const struct msrbits *mb, const struct msr val
 		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 @@ void hexprint(FILE *f, const struct msr val, const uint8_t bits) {
 		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;
 }



More information about the coreboot-gerrit mailing list