[PATCH 1/1] efi_loader: Show the FirmwareVendor and FirmwareRevision in helloworld

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Wed Oct 9 13:55:52 CEST 2024


From: Simon Glass <sjg at chromium.org>

Show the firmware vendor and revision to make it clear which firmware is
used, e.g. whether U-Boot is providing the boot services.

The output will look like

    Firmware vendor: Das U-Boot
    Firmware revision: 20241000

Signed-off-by: Simon Glass <sjg at chromium.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
 lib/efi_loader/helloworld.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/lib/efi_loader/helloworld.c b/lib/efi_loader/helloworld.c
index 586177de0c8..f9154386472 100644
--- a/lib/efi_loader/helloworld.c
+++ b/lib/efi_loader/helloworld.c
@@ -71,6 +71,33 @@ static void uint2dec(u32 value, u16 **buf)
 	*buf = pos;
 }
 
+/*
+ * Print an unsigned 32bit value as hexadecimal number to an u16 string
+ *
+ * @value:	value to be printed
+ * @buf:	pointer to buffer address
+ *		on return position of terminating zero word
+ */
+static void uint2hex(u32 value, u16 **buf)
+{
+	u16 *pos = *buf;
+	int i;
+	u16 c;
+
+	for (i = 0; i < 8; ++i) {
+		/* Write current digit */
+		c = value >> 28;
+		value <<= 4;
+		if (c < 10)
+			c += '0';
+		else
+			c += 'a' - 10;
+		*pos++ = c;
+	}
+	*pos = 0;
+	*buf = pos;
+}
+
 /**
  * print_uefi_revision() - print UEFI revision number
  */
@@ -96,6 +123,16 @@ static void print_uefi_revision(void)
 	con_out->output_string(con_out, u"Running on UEFI ");
 	con_out->output_string(con_out, rev);
 	con_out->output_string(con_out, u"\r\n");
+
+	con_out->output_string(con_out, u"Firmware vendor: ");
+	con_out->output_string(con_out, systable->fw_vendor);
+	con_out->output_string(con_out, u"\r\n");
+
+	buf = rev;
+	uint2hex(systable->fw_revision, &buf);
+	con_out->output_string(con_out, u"Firmware revision: ");
+	con_out->output_string(con_out, rev);
+	con_out->output_string(con_out, u"\r\n");
 }
 
 /**
-- 
2.45.2



More information about the U-Boot mailing list