summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/2lib/2ec_sync.c33
-rw-r--r--firmware/lib/vboot_api_kernel.c28
2 files changed, 28 insertions, 33 deletions
diff --git a/firmware/2lib/2ec_sync.c b/firmware/2lib/2ec_sync.c
index 979c0a5d..b884cb85 100644
--- a/firmware/2lib/2ec_sync.c
+++ b/firmware/2lib/2ec_sync.c
@@ -448,35 +448,6 @@ static vb2_error_t ec_sync_phase2(struct vb2_context *ctx)
return sync_ec(ctx);
}
-/**
- * EC sync, phase 3
- *
- * This completes EC sync and handles battery cutoff if needed.
- *
- * @param ctx Vboot2 context
- * @return VB2_SUCCESS or non-zero error code.
- */
-static vb2_error_t ec_sync_phase3(struct vb2_context *ctx)
-{
- /* EC verification (and possibly updating / jumping) is done */
- vb2_error_t rv = vb2ex_ec_vboot_done(ctx);
- if (rv)
- return rv;
-
- /* Check if we need to cut-off battery. This must be done after EC
- * firmware updating and before kernel started. */
- if (vb2_nv_get(ctx, VB2_NV_BATTERY_CUTOFF_REQUEST)) {
- VB2_DEBUG("Request to cut-off battery\n");
- vb2_nv_set(ctx, VB2_NV_BATTERY_CUTOFF_REQUEST, 0);
- /* May lose power immediately, so commit our update now. */
- vb2_nv_commit(ctx);
- vb2ex_ec_battery_cutoff();
- return VBERROR_SHUTDOWN_REQUESTED;
- }
-
- return VB2_SUCCESS;
-}
-
vb2_error_t vb2api_ec_sync(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
@@ -509,8 +480,8 @@ vb2_error_t vb2api_ec_sync(struct vb2_context *ctx)
if (rv)
return rv;
- /* Phase 3; Completes sync and handles battery cutoff */
- rv = ec_sync_phase3(ctx);
+ /* Phase 3; Let the platform know that EC software sync is now done */
+ rv = vb2ex_ec_vboot_done(ctx);
if (rv)
return rv;
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index facd1fea..a2062ff3 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -50,6 +50,26 @@ void vb2_nv_commit(struct vb2_context *ctx)
VbExNvStorageWrite(ctx->nvdata);
}
+static vb2_error_t handle_battery_cutoff(struct vb2_context *ctx)
+{
+ /*
+ * Check if we need to cut-off battery. This should be done after EC
+ * FW and Aux FW are updated, and before the kernel is started. This
+ * is to make sure all firmware is up-to-date before shipping (which
+ * is the typical use-case for cutoff).
+ */
+ if (vb2_nv_get(ctx, VB2_NV_BATTERY_CUTOFF_REQUEST)) {
+ VB2_DEBUG("Request to cut-off battery\n");
+ vb2_nv_set(ctx, VB2_NV_BATTERY_CUTOFF_REQUEST, 0);
+ /* May lose power immediately, so commit our update now. */
+ vb2_nv_commit(ctx);
+ vb2ex_ec_battery_cutoff();
+ return VBERROR_SHUTDOWN_REQUESTED;
+ }
+
+ return VB2_SUCCESS;
+}
+
uint32_t vb2_get_fwmp_flags(void)
{
return fwmp.flags;
@@ -367,8 +387,8 @@ vb2_error_t VbSelectAndLoadKernel(struct vb2_context *ctx,
VB2_DEBUG("GBB flags are %#x\n", vb2_get_gbb(ctx)->flags);
/*
- * Do EC software sync unless we're in recovery mode. This has UI but
- * it's just a single non-interactive WAIT screen.
+ * Do EC and Aux FW software sync unless we're in recovery mode. This
+ * has UI but it's just a single non-interactive WAIT screen.
*/
if (!(ctx->flags & VB2_CONTEXT_RECOVERY_MODE)) {
rv = vb2api_ec_sync(ctx);
@@ -378,6 +398,10 @@ vb2_error_t VbSelectAndLoadKernel(struct vb2_context *ctx,
rv = vb2api_auxfw_sync(ctx);
if (rv)
goto VbSelectAndLoadKernel_exit;
+
+ rv = handle_battery_cutoff(ctx);
+ if (rv)
+ goto VbSelectAndLoadKernel_exit;
}
/* Select boot path */