diff options
Diffstat (limited to 'firmware/lib/vboot_api_kernel.c')
-rw-r--r-- | firmware/lib/vboot_api_kernel.c | 28 |
1 files changed, 26 insertions, 2 deletions
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 */ |