summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorMeng-Huan Yu <menghuan@chromium.org>2020-08-18 18:05:19 +0800
committerCommit Bot <commit-bot@chromium.org>2020-09-05 13:20:46 +0000
commit94801a71980ddf3295a7849bbe575327d295595d (patch)
tree9e339f87c42a6956eee896c85e4a8ea970dd918b /firmware
parent7f37cd1886b82522b4bac0c3e422341d68b7bd08 (diff)
downloadvboot-94801a71980ddf3295a7849bbe575327d295595d.tar.gz
minidiag: Add diagnostic menu screen
BRANCH=none BUG=b:156692539, b:156693348 TEST=emerge-hatch vboot_reference TEST=unittest passed: ( export CC=x86_64-pc-linux-gnu-clang DEBUG=1 MENU_UI=0 DIAGNOSTIC_UI=0 MINIMAL=1 TPM2_MODE= MOCK_TPM=; make clean && make -j32 test_setup && make runtests; echo $? ) ( export CC=x86_64-pc-linux-gnu-clang DEBUG=1 MENU_UI=1 DIAGNOSTIC_UI=0 MINIMAL=1 TPM2_MODE= MOCK_TPM=; make clean && make -j32 test_setup && make runtests; echo $? ) ( export CC=x86_64-pc-linux-gnu-clang DEBUG=1 MENU_UI=0 DIAGNOSTIC_UI=1 MINIMAL=1 TPM2_MODE= MOCK_TPM=; make clean && make -j32 test_setup && make runtests; echo $? ) ( export CC=x86_64-pc-linux-gnu-clang DEBUG=1 MENU_UI=1 DIAGNOSTIC_UI=1 MINIMAL=1 TPM2_MODE= MOCK_TPM=; make clean && make -j32 test_setup && make runtests; echo $? ) Cq-Depend: chromium:2193314, chromium:2328704 Signed-off-by: Meng-Huan Yu <menghuan@chromium.org> Change-Id: I4f3c64ce53b14437cb14d3c1109e14608d082141 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2318590 Commit-Queue: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
Diffstat (limited to 'firmware')
-rw-r--r--firmware/2lib/2ui.c8
-rw-r--r--firmware/2lib/2ui_screens.c24
-rw-r--r--firmware/2lib/include/2api.h2
-rw-r--r--firmware/2lib/include/2ui.h11
-rw-r--r--firmware/lib/vboot_api_kernel.c20
5 files changed, 56 insertions, 9 deletions
diff --git a/firmware/2lib/2ui.c b/firmware/2lib/2ui.c
index 85c00672..d80002d5 100644
--- a/firmware/2lib/2ui.c
+++ b/firmware/2lib/2ui.c
@@ -469,3 +469,11 @@ vb2_error_t manual_recovery_action(struct vb2_ui_context *ui)
return VB2_REQUEST_UI_CONTINUE;
}
+
+/*****************************************************************************/
+/* Diagnostics */
+
+vb2_error_t vb2_diagnostic_menu(struct vb2_context *ctx)
+{
+ return ui_loop(ctx, VB2_SCREEN_DIAGNOSTICS, NULL);
+}
diff --git a/firmware/2lib/2ui_screens.c b/firmware/2lib/2ui_screens.c
index 6728fe72..b8ff3a5c 100644
--- a/firmware/2lib/2ui_screens.c
+++ b/firmware/2lib/2ui_screens.c
@@ -907,6 +907,29 @@ static const struct vb2_screen_info developer_invalid_disk_screen = {
};
/******************************************************************************/
+/* VB2_SCREEN_DIAGNOSTICS */
+
+static const struct vb2_menu_item diagnostics_items[] = {
+ LANGUAGE_SELECT_ITEM,
+ {
+ .text = "Storage",
+ },
+ {
+ .text = "Quick memory check",
+ },
+ {
+ .text = "Full memory check",
+ },
+ POWER_OFF_ITEM,
+};
+
+static const struct vb2_screen_info diagnostics_screen = {
+ .id = VB2_SCREEN_DIAGNOSTICS,
+ .name = "Diagnostic tools",
+ .menu = MENU_ITEMS(diagnostics_items),
+};
+
+/******************************************************************************/
/*
* TODO(chromium:1035800): Refactor UI code across vboot and depthcharge.
* Currently vboot and depthcharge maintain their own copies of menus/screens.
@@ -933,6 +956,7 @@ static const struct vb2_screen_info *screens[] = {
&developer_to_norm_screen,
&developer_boot_external_screen,
&developer_invalid_disk_screen,
+ &diagnostics_screen,
};
const struct vb2_screen_info *vb2_get_screen_info(enum vb2_screen id)
diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h
index ad484825..a6c76764 100644
--- a/firmware/2lib/include/2api.h
+++ b/firmware/2lib/include/2api.h
@@ -1316,6 +1316,8 @@ enum vb2_screen {
VB2_SCREEN_DEVELOPER_BOOT_EXTERNAL = 0x320,
/* Invalid external disk inserted */
VB2_SCREEN_DEVELOPER_INVALID_DISK = 0x330,
+ /* Diagnostic tools */
+ VB2_SCREEN_DIAGNOSTICS = 0x400,
};
enum vb2_ui_error {
diff --git a/firmware/2lib/include/2ui.h b/firmware/2lib/include/2ui.h
index 790301ef..cc21f580 100644
--- a/firmware/2lib/include/2ui.h
+++ b/firmware/2lib/include/2ui.h
@@ -229,4 +229,15 @@ vb2_error_t vb2_broken_recovery_menu(struct vb2_context *ctx);
*/
vb2_error_t vb2_manual_recovery_menu(struct vb2_context *ctx);
+/**
+ * UI for a diagnostic tools boot.
+ *
+ * Enter the diagnostic tools menu, which provides debug information and
+ * diagnostic tests of various hardware components.
+ *
+ * @param ctx Vboot context
+ * @returns VB2_SUCCESS, or non-zero error code.
+ */
+vb2_error_t vb2_diagnostic_menu(struct vb2_context *ctx);
+
#endif /* VBOOT_REFERENCE_2UI_H_ */
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index eeabde8e..a910b552 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -240,18 +240,20 @@ vb2_error_t VbSelectAndLoadKernel(struct vb2_context *ctx,
} else {
VB2_TRY(VbBootRecoveryLegacyClamshell(ctx));
}
- } else if (DIAGNOSTIC_UI && !MENU_UI &&
- vb2api_diagnostic_ui_enabled(ctx) &&
+ } else if (DIAGNOSTIC_UI && vb2api_diagnostic_ui_enabled(ctx) &&
vb2_nv_get(ctx, VB2_NV_DIAG_REQUEST)) {
vb2_nv_set(ctx, VB2_NV_DIAG_REQUEST, 0);
- /*
- * Diagnostic boot. This has a UI but only power button
- * is used for input so no detachable-specific UI is
- * needed. This mode is also 1-shot so it's placed
- * before developer mode.
- */
- VB2_TRY(VbBootDiagnosticLegacyClamshell(ctx));
+ /* Diagnostic boot. This has UI. */
+ if (MENU_UI)
+ VB2_TRY(vb2_diagnostic_menu(ctx));
+ else
+ /*
+ * Only power button is used for input so no
+ * detachable-specific UI is needed. This mode is also
+ * 1-shot so it's placed before developer mode.
+ */
+ VB2_TRY(VbBootDiagnosticLegacyClamshell(ctx));
/*
* The diagnostic menu should either boot a rom, or
* return either of reboot or shutdown.