summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authoredisonhello <edisonhello@google.com>2021-09-02 15:20:47 +0800
committerCommit Bot <commit-bot@chromium.org>2021-09-14 08:03:17 +0000
commit3852f05c1cf9a0178ec5d16352d213e6ec2ab422 (patch)
tree6e5ba9257a80ec9d5d36142674a9b408d7062a37 /firmware
parent0d72f07a52e25c53ce4529345994401c835eb9e2 (diff)
downloadvboot-3852f05c1cf9a0178ec5d16352d213e6ec2ab422.tar.gz
vboot/ui: Remove diagnostics menu and related tests
This CL is a part of centralizing ui codes. The removed screens and unit tests will be added in depthcharge. Remove diagnostics menu, diagnostics storage and memory checking screens. Remove unit tests for above screens and menu. BUG=b:172339016 TEST=export CC=x86_64-pc-linux-gnu-clang DEBUG=1 DETACHABLE=0; \ make -j test_setup && make -j runtests TEST=export CC=x86_64-pc-linux-gnu-clang DEBUG=1 DETACHABLE=1; \ make -j test_setup && make -j runtests BRANCH=none Cq-Depend: chromium:3138687 Signed-off-by: edisonhello <edisonhello@google.com> Change-Id: I5eb1bee6a5f1aedb77298acbddab20156c1c086e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3139537 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
Diffstat (limited to 'firmware')
-rw-r--r--firmware/2lib/2stub.c6
-rw-r--r--firmware/2lib/2ui.c8
-rw-r--r--firmware/2lib/2ui_screens.c350
-rw-r--r--firmware/2lib/include/2api.h11
-rw-r--r--firmware/2lib/include/2ui.h14
-rw-r--r--firmware/lib/vboot_api_kernel.c3
6 files changed, 18 insertions, 374 deletions
diff --git a/firmware/2lib/2stub.c b/firmware/2lib/2stub.c
index 181fa496..47fb2df7 100644
--- a/firmware/2lib/2stub.c
+++ b/firmware/2lib/2stub.c
@@ -274,3 +274,9 @@ vb2_error_t vb2ex_developer_ui(struct vb2_context *ctx)
{
return VB2_SUCCESS;
}
+
+__attribute__((weak))
+vb2_error_t vb2ex_diagnostic_ui(struct vb2_context *ctx)
+{
+ return VB2_SUCCESS;
+}
diff --git a/firmware/2lib/2ui.c b/firmware/2lib/2ui.c
index ab0692bf..64680220 100644
--- a/firmware/2lib/2ui.c
+++ b/firmware/2lib/2ui.c
@@ -412,11 +412,3 @@ vb2_error_t vb2_ui_loop(struct vb2_context *ctx, enum vb2_screen root_screen_id,
return VB2_SUCCESS;
return rv;
}
-
-/*****************************************************************************/
-/* Diagnostics */
-
-vb2_error_t vb2_diagnostic_menu(struct vb2_context *ctx)
-{
- return vb2_ui_loop(ctx, VB2_SCREEN_DIAGNOSTICS, NULL);
-}
diff --git a/firmware/2lib/2ui_screens.c b/firmware/2lib/2ui_screens.c
index 5e08b57d..3a8e0b60 100644
--- a/firmware/2lib/2ui_screens.c
+++ b/firmware/2lib/2ui_screens.c
@@ -125,25 +125,6 @@ static vb2_error_t log_page_reset_to_top(struct vb2_ui_context *ui)
return log_page_update(ui, NULL);
}
-static vb2_error_t log_page_show_back_or_cancel(struct vb2_ui_context *ui,
- int is_show_cancel)
-{
- int back_item = ui->state->screen->back_item;
- int cancel_item = ui->state->screen->cancel_item;
- VB2_CLR_BIT(ui->state->hidden_item_mask, back_item);
- VB2_CLR_BIT(ui->state->hidden_item_mask, cancel_item);
- if (is_show_cancel) {
- VB2_SET_BIT(ui->state->hidden_item_mask, back_item);
- if (ui->state->selected_item == back_item)
- ui->state->selected_item = cancel_item;
- } else {
- VB2_SET_BIT(ui->state->hidden_item_mask, cancel_item);
- if (ui->state->selected_item == cancel_item)
- ui->state->selected_item = back_item;
- }
- return VB2_SUCCESS;
-}
-
static vb2_error_t log_page_prev_action(struct vb2_ui_context *ui)
{
/* Validity check. */
@@ -514,331 +495,6 @@ static const struct vb2_screen_info recovery_to_dev_screen = {
.menu = MENU_ITEMS(recovery_to_dev_items),
};
-/******************************************************************************/
-/* VB2_SCREEN_DIAGNOSTICS */
-
-#define DIAGNOSTICS_ITEM_STORAGE_HEALTH 1
-#define DIAGNOSTICS_ITEM_STORAGE_TEST_SHORT 2
-#define DIAGNOSTICS_ITEM_STORAGE_TEST_EXTENDED 3
-
-static vb2_error_t diagnostics_init(struct vb2_ui_context *ui)
-{
- const char *unused_log_string;
- vb2_error_t rv = vb2ex_diag_get_storage_test_log(&unused_log_string);
- if (rv == VB2_ERROR_EX_UNIMPLEMENTED) {
- VB2_SET_BIT(ui->state->disabled_item_mask,
- DIAGNOSTICS_ITEM_STORAGE_TEST_SHORT);
- VB2_SET_BIT(ui->state->disabled_item_mask,
- DIAGNOSTICS_ITEM_STORAGE_TEST_EXTENDED);
- }
- ui->state->selected_item = DIAGNOSTICS_ITEM_STORAGE_HEALTH;
- return VB2_SUCCESS;
-}
-
-static const struct vb2_menu_item diagnostics_items[] = {
- LANGUAGE_SELECT_ITEM,
- [DIAGNOSTICS_ITEM_STORAGE_HEALTH] = {
- .text = "Storage health info",
- .target = VB2_SCREEN_DIAGNOSTICS_STORAGE_HEALTH,
- },
- [DIAGNOSTICS_ITEM_STORAGE_TEST_SHORT] = {
- .text = "Storage self-test (short)",
- .target = VB2_SCREEN_DIAGNOSTICS_STORAGE_TEST_SHORT,
- },
- [DIAGNOSTICS_ITEM_STORAGE_TEST_EXTENDED] = {
- .text = "Storage self-test (Extended)",
- .target = VB2_SCREEN_DIAGNOSTICS_STORAGE_TEST_EXTENDED,
- },
- {
- .text = "Memory check (quick)",
- .target = VB2_SCREEN_DIAGNOSTICS_MEMORY_QUICK,
- },
- {
- .text = "Memory check (full)",
- .target = VB2_SCREEN_DIAGNOSTICS_MEMORY_FULL,
- },
- POWER_OFF_ITEM,
-};
-
-static const struct vb2_screen_info diagnostics_screen = {
- .id = VB2_SCREEN_DIAGNOSTICS,
- .name = "Diagnostic tools",
- .init = diagnostics_init,
- .menu = MENU_ITEMS(diagnostics_items),
-};
-
-/******************************************************************************/
-/* VB2_SCREEN_DIAGNOSTICS_STORAGE_HEALTH */
-
-#define DIAGNOSTICS_STORAGE_HEALTH_ITEM_PAGE_UP 0
-#define DIAGNOSTICS_STORAGE_HEALTH_ITEM_PAGE_DOWN 1
-#define DIAGNOSTICS_STORAGE_HEALTH_ITEM_BACK 2
-
-static vb2_error_t diagnostics_storage_health_init_impl(
- struct vb2_ui_context *ui)
-{
- const char *log_string;
- VB2_TRY(vb2ex_diag_get_storage_health(&log_string));
- VB2_TRY(log_page_update(ui, log_string));
- return log_page_reset_to_top(ui);
-}
-
-static vb2_error_t diagnostics_storage_health_init(struct vb2_ui_context *ui)
-{
- if (vb2_is_error(diagnostics_storage_health_init_impl(ui)))
- return set_ui_error_and_go_back(ui, VB2_UI_ERROR_DIAGNOSTICS);
- return VB2_SUCCESS;
-}
-
-static const struct vb2_menu_item diagnostics_storage_health_items[] = {
- [DIAGNOSTICS_STORAGE_HEALTH_ITEM_PAGE_UP] = PAGE_UP_ITEM,
- [DIAGNOSTICS_STORAGE_HEALTH_ITEM_PAGE_DOWN] = PAGE_DOWN_ITEM,
- [DIAGNOSTICS_STORAGE_HEALTH_ITEM_BACK] = BACK_ITEM,
- POWER_OFF_ITEM,
-};
-
-static const struct vb2_screen_info diagnostics_storage_health_screen = {
- .id = VB2_SCREEN_DIAGNOSTICS_STORAGE_HEALTH,
- .name = "Storage health info",
- .init = diagnostics_storage_health_init,
- .menu = MENU_ITEMS(diagnostics_storage_health_items),
- .page_up_item = DIAGNOSTICS_STORAGE_HEALTH_ITEM_PAGE_UP,
- .page_down_item = DIAGNOSTICS_STORAGE_HEALTH_ITEM_PAGE_DOWN,
- .back_item = DIAGNOSTICS_STORAGE_HEALTH_ITEM_BACK,
-};
-
-/******************************************************************************/
-/* VB2_SCREEN_DIAGNOSTICS_STORAGE_TEST */
-
-#define DIAGNOSTICS_STORAGE_TEST_ITEM_PAGE_UP 0
-#define DIAGNOSTICS_STORAGE_TEST_ITEM_PAGE_DOWN 1
-#define DIAGNOSTICS_STORAGE_TEST_ITEM_BACK 2
-#define DIAGNOSTICS_STORAGE_TEST_ITEM_CANCEL 3
-
-static vb2_error_t diagnostics_storage_test_update_impl(
- struct vb2_ui_context *ui)
-{
- const char *log_string;
- int is_test_running = 0;
-
- /* Early return if the test is done. */
- if (ui->state->test_finished)
- return VB2_SUCCESS;
-
- vb2_error_t rv = vb2ex_diag_get_storage_test_log(&log_string);
- switch (rv) {
- case VB2_ERROR_EX_DIAG_TEST_RUNNING:
- is_test_running = 1;
- break;
- case VB2_SUCCESS:
- ui->state->test_finished = 1;
- break;
- default:
- VB2_DEBUG("vb2ex_diag_get_storage_test_log returned %#x\n", rv);
- return rv;
- }
- VB2_TRY(log_page_show_back_or_cancel(ui, is_test_running));
- return log_page_update(ui, log_string);
-}
-
-static vb2_error_t diagnostics_storage_test_update(struct vb2_ui_context *ui)
-{
- if (vb2_is_error(diagnostics_storage_test_update_impl(ui)))
- return set_ui_error_and_go_back(ui, VB2_UI_ERROR_DIAGNOSTICS);
- return VB2_SUCCESS;
-}
-
-static vb2_error_t diagnostics_storage_test_control(
- struct vb2_ui_context *ui, enum vb2_diag_storage_test op)
-{
- if (vb2_is_error(vb2ex_diag_storage_test_control(op)))
- return set_ui_error_and_go_back(ui, VB2_UI_ERROR_DIAGNOSTICS);
- return VB2_SUCCESS;
-}
-
-static vb2_error_t diagnostics_storage_test_init(struct vb2_ui_context *ui)
-{
- VB2_TRY(diagnostics_storage_test_update(ui));
- if (vb2_is_error(log_page_reset_to_top(ui)))
- return set_ui_error_and_go_back(ui, VB2_UI_ERROR_DIAGNOSTICS);
- return VB2_SUCCESS;
-}
-
-static vb2_error_t diagnostics_storage_test_short_init(
- struct vb2_ui_context *ui)
-{
- VB2_TRY(diagnostics_storage_test_control(ui,
- VB2_DIAG_STORAGE_TEST_STOP));
- VB2_TRY(diagnostics_storage_test_control(ui,
- VB2_DIAG_STORAGE_TEST_SHORT));
- return diagnostics_storage_test_init(ui);
-}
-
-static vb2_error_t diagnostics_storage_test_extended_init(
- struct vb2_ui_context *ui)
-{
- VB2_TRY(diagnostics_storage_test_control(ui,
- VB2_DIAG_STORAGE_TEST_STOP));
- VB2_TRY(diagnostics_storage_test_control(
- ui, VB2_DIAG_STORAGE_TEST_EXTENDED));
- return diagnostics_storage_test_init(ui);
-}
-
-static vb2_error_t diagnostics_storage_test_cancel(struct vb2_ui_context *ui)
-{
- VB2_TRY(diagnostics_storage_test_control(ui,
- VB2_DIAG_STORAGE_TEST_STOP));
- return vb2_ui_screen_back(ui);
-}
-
-static const struct vb2_menu_item diagnostics_storage_test_items[] = {
- [DIAGNOSTICS_STORAGE_TEST_ITEM_PAGE_UP] = PAGE_UP_ITEM,
- [DIAGNOSTICS_STORAGE_TEST_ITEM_PAGE_DOWN] = PAGE_DOWN_ITEM,
- [DIAGNOSTICS_STORAGE_TEST_ITEM_BACK] = BACK_ITEM,
- [DIAGNOSTICS_STORAGE_TEST_ITEM_CANCEL] = {
- .text = "Cancel",
- .action = diagnostics_storage_test_cancel,
- },
- POWER_OFF_ITEM,
-};
-
-static const struct vb2_screen_info diagnostics_storage_test_short_screen = {
- .id = VB2_SCREEN_DIAGNOSTICS_STORAGE_TEST_SHORT,
- .name = "Storage self-test (short)",
- .init = diagnostics_storage_test_short_init,
- .action = diagnostics_storage_test_update,
- .menu = MENU_ITEMS(diagnostics_storage_test_items),
- .page_up_item = DIAGNOSTICS_STORAGE_TEST_ITEM_PAGE_UP,
- .page_down_item = DIAGNOSTICS_STORAGE_TEST_ITEM_PAGE_DOWN,
- .back_item = DIAGNOSTICS_STORAGE_TEST_ITEM_BACK,
- .cancel_item = DIAGNOSTICS_STORAGE_TEST_ITEM_CANCEL,
-};
-
-static const struct vb2_screen_info diagnostics_storage_test_extended_screen = {
- .id = VB2_SCREEN_DIAGNOSTICS_STORAGE_TEST_EXTENDED,
- .name = "Storage self-test (extended)",
- .init = diagnostics_storage_test_extended_init,
- .action = diagnostics_storage_test_update,
- .menu = MENU_ITEMS(diagnostics_storage_test_items),
- .page_up_item = DIAGNOSTICS_STORAGE_TEST_ITEM_PAGE_UP,
- .page_down_item = DIAGNOSTICS_STORAGE_TEST_ITEM_PAGE_DOWN,
- .back_item = DIAGNOSTICS_STORAGE_TEST_ITEM_BACK,
- .cancel_item = DIAGNOSTICS_STORAGE_TEST_ITEM_CANCEL,
-};
-
-/******************************************************************************/
-/* VB2_SCREEN_DIAGNOSTICS_MEMORY_QUICK
- VB2_SCREEN_DIAGNOSTICS_MEMORY_FULL */
-
-#define DIAGNOSTICS_MEMORY_ITEM_PAGE_UP 0
-#define DIAGNOSTICS_MEMORY_ITEM_PAGE_DOWN 1
-#define DIAGNOSTICS_MEMORY_ITEM_BACK 2
-#define DIAGNOSTICS_MEMORY_ITEM_CANCEL 3
-
-typedef vb2_error_t (*memory_test_op_t)(int reset, const char **out);
-static vb2_error_t diagnostics_memory_update_screen_impl(
- struct vb2_ui_context *ui, memory_test_op_t op, int reset)
-{
- const char *log_string = NULL;
- vb2_error_t rv;
- int is_test_running = 0;
-
- /* Early return if the memory test is done. */
- if (ui->state->test_finished)
- return VB2_SUCCESS;
-
- rv = op(reset, &log_string);
- switch (rv) {
- /* The test is still running but the output buffer was unchanged. */
- case VB2_ERROR_EX_DIAG_TEST_RUNNING:
- return VB2_SUCCESS;
- case VB2_ERROR_EX_DIAG_TEST_UPDATED:
- is_test_running = 1;
- break;
- case VB2_SUCCESS:
- ui->state->test_finished = 1;
- break;
- default:
- VB2_DEBUG("memory_test_op returned %#x\n", rv);
- return rv;
- }
- VB2_TRY(log_page_show_back_or_cancel(ui, is_test_running));
- return log_page_update(ui, log_string);
-}
-
-static vb2_error_t diagnostics_memory_update_screen(struct vb2_ui_context *ui,
- memory_test_op_t op,
- int reset)
-{
- if (vb2_is_error(diagnostics_memory_update_screen_impl(ui, op, reset)))
- return set_ui_error_and_go_back(ui, VB2_UI_ERROR_DIAGNOSTICS);
- return VB2_SUCCESS;
-}
-
-static vb2_error_t diagnostics_memory_init_quick(struct vb2_ui_context *ui)
-{
- VB2_TRY(diagnostics_memory_update_screen(
- ui, &vb2ex_diag_memory_quick_test, 1));
- if (vb2_is_error(log_page_reset_to_top(ui)))
- return set_ui_error_and_go_back(ui, VB2_UI_ERROR_DIAGNOSTICS);
- return VB2_SUCCESS;
-}
-
-static vb2_error_t diagnostics_memory_init_full(struct vb2_ui_context *ui)
-{
- VB2_TRY(diagnostics_memory_update_screen(
- ui, &vb2ex_diag_memory_full_test, 1));
- if (vb2_is_error(log_page_reset_to_top(ui)))
- return set_ui_error_and_go_back(ui, VB2_UI_ERROR_DIAGNOSTICS);
- return VB2_SUCCESS;
-}
-
-static vb2_error_t diagnostics_memory_update_quick(struct vb2_ui_context *ui)
-{
- return diagnostics_memory_update_screen(
- ui, &vb2ex_diag_memory_quick_test, 0);
-}
-
-static vb2_error_t diagnostics_memory_update_full(struct vb2_ui_context *ui)
-{
- return diagnostics_memory_update_screen(
- ui, &vb2ex_diag_memory_full_test, 0);
-}
-
-static const struct vb2_menu_item diagnostics_memory_items[] = {
- [DIAGNOSTICS_MEMORY_ITEM_PAGE_UP] = PAGE_UP_ITEM,
- [DIAGNOSTICS_MEMORY_ITEM_PAGE_DOWN] = PAGE_DOWN_ITEM,
- [DIAGNOSTICS_MEMORY_ITEM_BACK] = BACK_ITEM,
- [DIAGNOSTICS_MEMORY_ITEM_CANCEL] = {
- .text = "Cancel",
- .action = vb2_ui_screen_back,
- },
- POWER_OFF_ITEM,
-};
-
-static const struct vb2_screen_info diagnostics_memory_quick_screen = {
- .id = VB2_SCREEN_DIAGNOSTICS_MEMORY_QUICK,
- .name = "Memory check (quick)",
- .init = diagnostics_memory_init_quick,
- .action = diagnostics_memory_update_quick,
- .menu = MENU_ITEMS(diagnostics_memory_items),
- .page_up_item = DIAGNOSTICS_MEMORY_ITEM_PAGE_UP,
- .page_down_item = DIAGNOSTICS_MEMORY_ITEM_PAGE_DOWN,
- .back_item = DIAGNOSTICS_MEMORY_ITEM_BACK,
- .cancel_item = DIAGNOSTICS_MEMORY_ITEM_CANCEL,
-};
-
-static const struct vb2_screen_info diagnostics_memory_full_screen = {
- .id = VB2_SCREEN_DIAGNOSTICS_MEMORY_FULL,
- .name = "Memory check (full)",
- .init = diagnostics_memory_init_full,
- .action = diagnostics_memory_update_full,
- .menu = MENU_ITEMS(diagnostics_memory_items),
- .page_up_item = DIAGNOSTICS_MEMORY_ITEM_PAGE_UP,
- .page_down_item = DIAGNOSTICS_MEMORY_ITEM_PAGE_DOWN,
- .back_item = DIAGNOSTICS_MEMORY_ITEM_BACK,
- .cancel_item = DIAGNOSTICS_MEMORY_ITEM_CANCEL,
-};
/******************************************************************************/
/*
@@ -854,12 +510,6 @@ static const struct vb2_screen_info *screens[] = {
&debug_info_screen,
&firmware_log_screen,
&recovery_to_dev_screen,
- &diagnostics_screen,
- &diagnostics_storage_health_screen,
- &diagnostics_storage_test_short_screen,
- &diagnostics_storage_test_extended_screen,
- &diagnostics_memory_quick_screen,
- &diagnostics_memory_full_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 a1cda6a1..521cae8f 100644
--- a/firmware/2lib/include/2api.h
+++ b/firmware/2lib/include/2api.h
@@ -1430,6 +1430,17 @@ vb2_error_t vb2ex_manual_recovery_ui(struct vb2_context *ctx);
*/
vb2_error_t vb2ex_developer_ui(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
+ * @return VB2_SUCCESS, or non-zero error code.
+ */
+vb2_error_t vb2ex_diagnostic_ui(struct vb2_context *ctx);
+
/* Helpers for bitmask operations */
#define VB2_SET_BIT(mask, index) ((mask) |= ((uint32_t)1 << (index)))
#define VB2_CLR_BIT(mask, index) ((mask) &= ~((uint32_t)1 << (index)))
diff --git a/firmware/2lib/include/2ui.h b/firmware/2lib/include/2ui.h
index 0fb18513..c01c1f97 100644
--- a/firmware/2lib/include/2ui.h
+++ b/firmware/2lib/include/2ui.h
@@ -228,18 +228,4 @@ vb2_error_t vb2_ui_screen_back(struct vb2_ui_context *ui);
*/
vb2_error_t vb2_ui_screen_change(struct vb2_ui_context *ui, enum vb2_screen id);
-/*****************************************************************************/
-/* UI loops */
-
-/**
- * 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
- * @return 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 10728b95..b79b26fd 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -13,7 +13,6 @@
#include "2rsa.h"
#include "2secdata.h"
#include "2sysincludes.h"
-#include "2ui.h"
#include "load_kernel_fw.h"
#include "vboot_api.h"
#include "vboot_struct.h"
@@ -209,7 +208,7 @@ vb2_error_t VbSelectAndLoadKernel(struct vb2_context *ctx,
vb2ex_commit_data(ctx);
/* Diagnostic boot. This has UI. */
- VB2_TRY(vb2_diagnostic_menu(ctx));
+ VB2_TRY(vb2ex_diagnostic_ui(ctx));
/*
* The diagnostic menu should either boot a rom, or
* return either of reboot or shutdown.