diff options
author | Yu-Ping Wu <yupingso@chromium.org> | 2019-12-09 11:40:31 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-12-13 05:42:33 +0000 |
commit | bf4b951cc89d3fa5b548d5e6e4c501ecad6eccd7 (patch) | |
tree | 4ab0374f74c779f222760c938e352eb8486af675 | |
parent | 0e934808068d2bce1d85419a5ae30c43eea68858 (diff) | |
download | vboot-bf4b951cc89d3fa5b548d5e6e4c501ecad6eccd7.tar.gz |
vboot: Publicize check_reboot_for_display()
Publicize check_reboot_for_display() and rename it to
vb2api_need_reboot_for_display() for depthcharge to use.
BRANCH=none
BUG=chromium:1030608
TEST=FEATURES=test emerge-nami vboot_reference
Change-Id: Ie6c734850b67b29c8a098c3f232888f3ab47fddf
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1957726
Reviewed-by: Joel Kitching <kitching@chromium.org>
-rw-r--r-- | firmware/2lib/2auxfw_sync.c | 16 | ||||
-rw-r--r-- | firmware/2lib/2ec_sync.c | 15 | ||||
-rw-r--r-- | firmware/2lib/2misc.c | 11 | ||||
-rw-r--r-- | firmware/2lib/include/2api.h | 8 | ||||
-rw-r--r-- | tests/vb2_misc_tests.c | 19 |
5 files changed, 41 insertions, 28 deletions
diff --git a/firmware/2lib/2auxfw_sync.c b/firmware/2lib/2auxfw_sync.c index 7c6c2ba4..e90ee7ff 100644 --- a/firmware/2lib/2auxfw_sync.c +++ b/firmware/2lib/2auxfw_sync.c @@ -5,6 +5,7 @@ * Auxiliary firmware sync routines for vboot */ +#include "2api.h" #include "2common.h" #include "2misc.h" #include "2nvstorage.h" @@ -14,19 +15,6 @@ #include "vboot_display.h" /** - * If no display is available, set DISPLAY_REQUEST in NV space - */ -static int check_reboot_for_display(struct vb2_context *ctx) -{ - if (!(vb2_get_sd(ctx)->flags & VB2_SD_FLAG_DISPLAY_AVAILABLE)) { - VB2_DEBUG("Reboot to initialize display\n"); - vb2_nv_set(ctx, VB2_NV_DISPLAY_REQUEST, 1); - return 1; - } - return 0; -} - -/** * Display the WAIT screen */ static void display_wait_screen(struct vb2_context *ctx) @@ -126,7 +114,7 @@ vb2_error_t vb2api_auxfw_sync(struct vb2_context *ctx) /* If AUX FW update is slow display the wait screen */ if (fw_update == VB_AUX_FW_SLOW_UPDATE) { /* Display should be available, but better check again */ - if (check_reboot_for_display(ctx)) + if (vb2api_need_reboot_for_display(ctx)) return VBERROR_REBOOT_REQUIRED; display_wait_screen(ctx); } diff --git a/firmware/2lib/2ec_sync.c b/firmware/2lib/2ec_sync.c index aa06303b..03948ea5 100644 --- a/firmware/2lib/2ec_sync.c +++ b/firmware/2lib/2ec_sync.c @@ -19,19 +19,6 @@ VB2_SD_FLAG_ECSYNC_EC_RO : VB2_SD_FLAG_ECSYNC_EC_RW) /** - * If no display is available, set DISPLAY_REQUEST in NV space - */ -static int check_reboot_for_display(struct vb2_context *ctx) -{ - if (!(vb2_get_sd(ctx)->flags & VB2_SD_FLAG_DISPLAY_AVAILABLE)) { - VB2_DEBUG("Reboot to initialize display\n"); - vb2_nv_set(ctx, VB2_NV_DISPLAY_REQUEST, 1); - return 1; - } - return 0; -} - -/** * Display the WAIT screen */ static void display_wait_screen(struct vb2_context *ctx) @@ -474,7 +461,7 @@ vb2_error_t vb2api_ec_sync(struct vb2_context *ctx) vb2_error_t phase1_rv = ec_sync_phase1(ctx); int need_wait_screen = ec_will_update_slowly(ctx); - if (need_wait_screen && check_reboot_for_display(ctx)) + if (need_wait_screen && vb2api_need_reboot_for_display(ctx)) return VBERROR_REBOOT_REQUIRED; if (phase1_rv) diff --git a/firmware/2lib/2misc.c b/firmware/2lib/2misc.c index 8df75d6e..76c780b9 100644 --- a/firmware/2lib/2misc.c +++ b/firmware/2lib/2misc.c @@ -12,6 +12,7 @@ #include "2rsa.h" #include "2secdata.h" #include "2sha.h" +#include "2struct.h" #include "2sysincludes.h" #include "vboot_api.h" #include "vboot_struct.h" @@ -406,3 +407,13 @@ int vb2_allow_recovery(struct vb2_context *ctx) /* Now we confidently check the recovery switch state at boot */ return !!(vb2_get_sd(ctx)->vbsd->flags & VBSD_BOOT_REC_SWITCH_ON); } + +int vb2api_need_reboot_for_display(struct vb2_context *ctx) +{ + if (!(vb2_get_sd(ctx)->flags & VB2_SD_FLAG_DISPLAY_AVAILABLE)) { + VB2_DEBUG("Need reboot to initialize display\n"); + vb2_nv_set(ctx, VB2_NV_DISPLAY_REQUEST, 1); + return 1; + } + return 0; +} diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h index 0c56e64f..fda1fa78 100644 --- a/firmware/2lib/include/2api.h +++ b/firmware/2lib/include/2api.h @@ -788,6 +788,14 @@ vb2_error_t vb2api_ec_sync(struct vb2_context *ctx); */ vb2_error_t vb2api_auxfw_sync(struct vb2_context *ctx); +/** + * If no display is available, set DISPLAY_REQUEST in nvdata. + * + * @param ctx Vboot2 context + * @return 1 if DISPLAY_REQUEST is set and a reboot is required, or 0 otherwise. + */ +int vb2api_need_reboot_for_display(struct vb2_context *ctx); + /*****************************************************************************/ /* APIs provided by the caller to verified boot */ diff --git a/tests/vb2_misc_tests.c b/tests/vb2_misc_tests.c index 38806eaa..22de3ae2 100644 --- a/tests/vb2_misc_tests.c +++ b/tests/vb2_misc_tests.c @@ -724,6 +724,24 @@ static void select_slot_tests(void) "prev failure"); } +static void need_reboot_for_display_tests(void) +{ + /* Display not available, reboot required */ + reset_common_data(); + TEST_EQ(vb2api_need_reboot_for_display(ctx), 1, + "need_reboot_for_display: need reboot"); + TEST_EQ(vb2_nv_get(ctx, VB2_NV_DISPLAY_REQUEST), 1, + " set display request"); + + /* Display available, don't need reboot */ + reset_common_data(); + sd->flags |= VB2_SD_FLAG_DISPLAY_AVAILABLE; + TEST_EQ(vb2api_need_reboot_for_display(ctx), 0, + "need_reboot_for_display: don't need reboot"); + TEST_EQ(vb2_nv_get(ctx, VB2_NV_DISPLAY_REQUEST), 0, + " not set display request"); +} + int main(int argc, char* argv[]) { init_workbuf_tests(); @@ -734,6 +752,7 @@ int main(int argc, char* argv[]) dev_switch_tests(); tpm_clear_tests(); select_slot_tests(); + need_reboot_for_display_tests(); return gTestSuccess ? 0 : 255; } |