diff options
author | Joel Kitching <kitching@google.com> | 2019-10-22 15:49:54 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-10-25 18:00:12 +0000 |
commit | f63c95e2c95b83b731b4ae6d68842dd17917bbe4 (patch) | |
tree | ad031c232bb0d2453571965b3d67d00effa9439e | |
parent | abc4d18514301ae9ab73f38f2ff16842ba762e80 (diff) | |
download | vboot-f63c95e2c95b83b731b4ae6d68842dd17917bbe4.tar.gz |
vboot: merge ec_sync and ec_sync_all
Merge ec_sync and ec_sync_all in preparation for EC and auxfw
refactoring. This CL just moves code around without actually
making any modifications.
BUG=b:124141368, chromium:1016688, b:112198832, b:143094352
TEST=make clean && make runtests
BRANCH=none
Change-Id: I833c429e36a8f75e9b6d8f21aeb4c8c92c860256
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1872253
Reviewed-by: Karthikeyan Ramasubramanian <kramasub@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Sean Abraham <seanabraham@chromium.org>
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | firmware/lib/ec_sync.c | 83 | ||||
-rw-r--r-- | firmware/lib/ec_sync_all.c | 98 |
3 files changed, 83 insertions, 99 deletions
@@ -338,7 +338,6 @@ FWLIB_SRCS = \ firmware/lib/cgptlib/cgptlib.c \ firmware/lib/cgptlib/cgptlib_internal.c \ firmware/lib/cgptlib/crc32.c \ - firmware/lib/ec_sync_all.c \ firmware/lib/ec_sync.c \ firmware/lib/gpt_misc.c \ firmware/lib/utility_string.c \ diff --git a/firmware/lib/ec_sync.c b/firmware/lib/ec_sync.c index a2fac707..c83b0005 100644 --- a/firmware/lib/ec_sync.c +++ b/firmware/lib/ec_sync.c @@ -12,6 +12,7 @@ #include "ec_sync.h" #include "vboot_api.h" #include "vboot_common.h" +#include "vboot_display.h" #include "vboot_kernel.h" #define VB2_SD_FLAG_ECSYNC_RW \ @@ -495,3 +496,85 @@ vb2_error_t ec_sync_phase3(struct vb2_context *ctx) return VB2_SUCCESS; } + +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; +} + +static void display_wait_screen(struct vb2_context *ctx, const char *fw_name) +{ + VB2_DEBUG("%s update is slow. Show WAIT screen.\n", fw_name); + VbDisplayScreen(ctx, VB_SCREEN_WAIT, 0, NULL); +} + +vb2_error_t ec_sync_all(struct vb2_context *ctx) +{ + VbAuxFwUpdateSeverity_t fw_update = VB_AUX_FW_NO_UPDATE; + vb2_error_t rv; + + /* Phase 1; this determines if we need an update */ + vb2_error_t phase1_rv = ec_sync_phase1(ctx); + int need_wait_screen = ec_will_update_slowly(ctx); + + /* Check if EC SW Sync Phase1 needs reboot */ + if (phase1_rv) { + ec_sync_check_aux_fw(ctx, &fw_update); + /* It does -- speculatively check if we need display as well */ + if (need_wait_screen || fw_update == VB_AUX_FW_SLOW_UPDATE) + check_reboot_for_display(ctx); + return VBERROR_EC_REBOOT_TO_RO_REQUIRED; + } + + /* Is EC already in RO and needs slow update? */ + if (need_wait_screen) { + /* Might still need display in that case */ + if (check_reboot_for_display(ctx)) + return VBERROR_REBOOT_REQUIRED; + /* Display is available, so pop up the wait screen */ + display_wait_screen(ctx, "EC FW"); + } + + /* Phase 2; Applies update and/or jumps to the correct EC image */ + rv = ec_sync_phase2(ctx); + if (rv) + return rv; + + /* EC in RW, now we can check the severity of the AUX FW update */ + rv = ec_sync_check_aux_fw(ctx, &fw_update); + if (rv) + return rv; + + /* 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)) + return VBERROR_REBOOT_REQUIRED; + display_wait_screen(ctx, "AUX FW"); + } + + if (fw_update > VB_AUX_FW_NO_UPDATE) { + /* Do Aux FW software sync */ + rv = ec_sync_update_aux_fw(ctx); + if (rv) + return rv; + /* + * AUX FW Update is applied successfully. Request EC reboot to + * RO, so that the chips that had FW update gets reset to a + * clean state. + */ + return VBERROR_EC_REBOOT_TO_RO_REQUIRED; + } + + /* Phase 3; Completes sync and handles battery cutoff */ + rv = ec_sync_phase3(ctx); + if (rv) + return rv; + + return VB2_SUCCESS; +} diff --git a/firmware/lib/ec_sync_all.c b/firmware/lib/ec_sync_all.c deleted file mode 100644 index 5b205474..00000000 --- a/firmware/lib/ec_sync_all.c +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * EC software sync routines for vboot - */ - -#include "2common.h" -#include "2misc.h" -#include "2nvstorage.h" -#include "2sysincludes.h" -#include "ec_sync.h" -#include "vboot_api.h" -#include "vboot_common.h" -#include "vboot_display.h" -#include "vboot_kernel.h" - -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; -} - -static void display_wait_screen(struct vb2_context *ctx, const char *fw_name) -{ - VB2_DEBUG("%s update is slow. Show WAIT screen.\n", fw_name); - VbDisplayScreen(ctx, VB_SCREEN_WAIT, 0, NULL); -} - -vb2_error_t ec_sync_all(struct vb2_context *ctx) -{ - VbAuxFwUpdateSeverity_t fw_update = VB_AUX_FW_NO_UPDATE; - vb2_error_t rv; - - /* Phase 1; this determines if we need an update */ - vb2_error_t phase1_rv = ec_sync_phase1(ctx); - int need_wait_screen = ec_will_update_slowly(ctx); - - /* Check if EC SW Sync Phase1 needs reboot */ - if (phase1_rv) { - ec_sync_check_aux_fw(ctx, &fw_update); - /* It does -- speculatively check if we need display as well */ - if (need_wait_screen || fw_update == VB_AUX_FW_SLOW_UPDATE) - check_reboot_for_display(ctx); - return VBERROR_EC_REBOOT_TO_RO_REQUIRED; - } - - /* Is EC already in RO and needs slow update? */ - if (need_wait_screen) { - /* Might still need display in that case */ - if (check_reboot_for_display(ctx)) - return VBERROR_REBOOT_REQUIRED; - /* Display is available, so pop up the wait screen */ - display_wait_screen(ctx, "EC FW"); - } - - /* Phase 2; Applies update and/or jumps to the correct EC image */ - rv = ec_sync_phase2(ctx); - if (rv) - return rv; - - /* EC in RW, now we can check the severity of the AUX FW update */ - rv = ec_sync_check_aux_fw(ctx, &fw_update); - if (rv) - return rv; - - /* 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)) - return VBERROR_REBOOT_REQUIRED; - display_wait_screen(ctx, "AUX FW"); - } - - if (fw_update > VB_AUX_FW_NO_UPDATE) { - /* Do Aux FW software sync */ - rv = ec_sync_update_aux_fw(ctx); - if (rv) - return rv; - /* - * AUX FW Update is applied successfully. Request EC reboot to - * RO, so that the chips that had FW update gets reset to a - * clean state. - */ - return VBERROR_EC_REBOOT_TO_RO_REQUIRED; - } - - /* Phase 3; Completes sync and handles battery cutoff */ - rv = ec_sync_phase3(ctx); - if (rv) - return rv; - - return VB2_SUCCESS; -} |