vboot_display: Add full_info parameter to VbExDisplayDebugInfo()

VbExDisplayDebugInfo() was invented for the TAB display that dumps a
whole lot of possibly interesting debug data to the screen. Since some
debug data is only available to the calling firmware, the convention has
always been that the calling firmware is supposed to append any of its
own debug data it thinks may be relevant to the output.

Later, the function was reused to print small info messages that give
the user a hint what went wrong when a Ctrl+U or Ctrl+L fails
(unlocalized, of course, but better than nothing). The calling firmware
is not aware of this new use case, so every time vboot prints a
"WARNING: Ctrl+L not enabled" sort of message on the screen, depthcharge
also dumps the firmware IDs and TPM state below it.

This patch introduces a new parameter to the function to make the two
differing use cases clear to the calling firmware.

CQ-DEPEND=CL:1496903
BRANCH=None
BUG=None
TEST=with other patches

Change-Id: I52a1e764189508130fea562ad6d53bcefb1fce64
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1497038
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h
index 860a5fc..fdb7615 100644
--- a/firmware/include/vboot_api.h
+++ b/firmware/include/vboot_api.h
@@ -735,15 +735,15 @@
  * platform-dependent font.  Should be able to handle newlines '\n' in the
  * string.  Firmware must support displaying at least 20 lines of text, where
  * each line may be at least 80 characters long.  If the firmware has its own
- * debug state, it may display it to the screen below this information.
+ * debug state, it may display it to the screen below this information if the
+ * full_info parameter is set.
  *
- * NOTE: This is what we currently display when TAB is pressed.  Some
- * information (HWID, recovery reason) is ours; some (CMOS breadcrumbs) is
- * platform-specific.  If we decide to soft-render the HWID string
- * (chrome-os-partner:3693), we'll need to maintain our own fonts, so we'll
- * likely display it via VbExDisplayImage() above.
+ * @param info_str	The debug string to display
+ * @param full_info	1 if firmware should append its own info, 0 if not
+ *
+ * @return VBERROR_SUCCESS or error code on error.
  */
-VbError_t VbExDisplayDebugInfo(const char *info_str);
+VbError_t VbExDisplayDebugInfo(const char *info_str, int full_info);
 
 /**
  * Write vendor data to read-only VPD
diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c
index 49c5331..c709425 100644
--- a/firmware/lib/vboot_display.c
+++ b/firmware/lib/vboot_display.c
@@ -405,7 +405,7 @@
 
 	buf[DEBUG_INFO_SIZE - 1] = '\0';
 	VB2_DEBUG("[TAB] Debug Info:\n%s", buf);
-	return VbExDisplayDebugInfo(buf);
+	return VbExDisplayDebugInfo(buf, 1);
 }
 
 #define MAGIC_WORD_LEN 5
diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c
index dea6e03..3fb2ce6 100644
--- a/firmware/lib/vboot_ui.c
+++ b/firmware/lib/vboot_ui.c
@@ -422,7 +422,7 @@
 		VB2_DEBUG("dev_disable_boot is set\n");
 		VbDisplayScreen(ctx,
 				VB_SCREEN_DEVELOPER_TO_NORM, 0, NULL);
-		VbExDisplayDebugInfo(dev_disable_msg);
+		VbExDisplayDebugInfo(dev_disable_msg, 0);
 
 		/* Ignore space in VbUserConfirms()... */
 		switch (VbUserConfirms(ctx, 0)) {
diff --git a/firmware/lib/vboot_ui_common.c b/firmware/lib/vboot_ui_common.c
index af9c495..b15bf29 100644
--- a/firmware/lib/vboot_ui_common.c
+++ b/firmware/lib/vboot_ui_common.c
@@ -35,7 +35,7 @@
 		      enum vb2_beep_type beep)
 {
 	if (print_msg)
-		VbExDisplayDebugInfo(print_msg);
+		VbExDisplayDebugInfo(print_msg, 0);
 	if (!log_msg)
 		log_msg = print_msg;
 	if (log_msg)
@@ -60,7 +60,7 @@
 	VB2_DEBUG("Legacy boot is disabled\n");
 	VbExDisplayDebugInfo("WARNING: Booting legacy BIOS has not been "
 			     "enabled. Refer to the developer-mode "
-			     "documentation for details.\n");
+			     "documentation for details.\n", 0);
 	vb2_error_beep(VB_BEEP_NOT_ALLOWED);
 }
 
diff --git a/firmware/lib/vboot_ui_menu.c b/firmware/lib/vboot_ui_menu.c
index 39b00d6..96a24e0 100644
--- a/firmware/lib/vboot_ui_menu.c
+++ b/firmware/lib/vboot_ui_menu.c
@@ -345,7 +345,7 @@
 	vb2_run_altfw(current_menu_idx + 1);
 	vb2_flash_screen(ctx);
 	VB2_DEBUG(no_legacy);
-	VbExDisplayDebugInfo(no_legacy);
+	VbExDisplayDebugInfo(no_legacy, 0);
 
 	return VBERROR_KEEP_LOOPING;
 }
@@ -775,7 +775,7 @@
 
 		/* Make sure user knows dev mode disabled */
 		if (disable_dev_boot)
-			VbExDisplayDebugInfo(dev_disable_msg);
+			VbExDisplayDebugInfo(dev_disable_msg, 0);
 
 		switch (key) {
 		case VB_BUTTON_VOL_DOWN_LONG_PRESS:
diff --git a/firmware/stub/vboot_api_stub.c b/firmware/stub/vboot_api_stub.c
index 599b80c..3363aa4 100644
--- a/firmware/stub/vboot_api_stub.c
+++ b/firmware/stub/vboot_api_stub.c
@@ -39,7 +39,7 @@
 	return VBERROR_SUCCESS;
 }
 
-VbError_t VbExDisplayDebugInfo(const char *info_str)
+VbError_t VbExDisplayDebugInfo(const char *info_str, int full_info)
 {
 	return VBERROR_SUCCESS;
 }
diff --git a/tests/vboot_display_tests.c b/tests/vboot_display_tests.c
index ef9d146..2c7691e 100644
--- a/tests/vboot_display_tests.c
+++ b/tests/vboot_display_tests.c
@@ -94,7 +94,7 @@
 	return mock_altfw_mask;
 }
 
-VbError_t VbExDisplayDebugInfo(const char *info_str)
+VbError_t VbExDisplayDebugInfo(const char *info_str, int full_info)
 {
 	strncpy(debug_info, info_str, sizeof(debug_info));
 	debug_info[sizeof(debug_info) - 1] = '\0';