diff options
Diffstat (limited to 'firmware/2lib/2misc.c')
-rw-r--r-- | firmware/2lib/2misc.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/firmware/2lib/2misc.c b/firmware/2lib/2misc.c index a8567758..a955f536 100644 --- a/firmware/2lib/2misc.c +++ b/firmware/2lib/2misc.c @@ -139,29 +139,34 @@ int vb2_init_context(struct vb2_context *ctx) void vb2_check_recovery(struct vb2_context *ctx) { struct vb2_shared_data *sd = vb2_get_sd(ctx); + uint32_t reason = vb2_nv_get(ctx, VB2_NV_RECOVERY_REQUEST); + uint32_t subcode = vb2_nv_get(ctx, VB2_NV_RECOVERY_SUBCODE); + + VB2_DEBUG("Recovery reason from previous boot: %#x / %#x\n", + reason, subcode); /* - * Read the current recovery request, unless there's already been a + * Sets the current recovery request, unless there's already been a * failure earlier in the boot process. */ if (!sd->recovery_reason) - sd->recovery_reason = vb2_nv_get(ctx, VB2_NV_RECOVERY_REQUEST); + sd->recovery_reason = reason; - /* Clear the recovery request so we don't get stuck in recovery mode */ - if (sd->recovery_reason) { - vb2_nv_set(ctx, VB2_NV_RECOVERY_REQUEST, - VB2_RECOVERY_NOT_REQUESTED); - /* - * Note that we ignore failures clearing the request. We only - * hit this code path if recovery mode has already been - * requested, so what more can we do? Don't want to obscure - * the original reason for going into recovery mode. - */ - } + /* Clear request and subcode so we don't get stuck in recovery mode */ + vb2_nv_set(ctx, VB2_NV_RECOVERY_REQUEST, VB2_RECOVERY_NOT_REQUESTED); + vb2_nv_set(ctx, VB2_NV_RECOVERY_SUBCODE, VB2_RECOVERY_NOT_REQUESTED); - /* If forcing recovery, override recovery reason */ if (ctx->flags & VB2_CONTEXT_FORCE_RECOVERY_MODE) { - sd->recovery_reason = VB2_RECOVERY_RO_MANUAL; + VB2_DEBUG("Recovery was requested manually\n"); + if (subcode && !sd->recovery_reason) + /* + * Recovery was requested at 'broken' screen. + * Promote subcode to reason. + */ + sd->recovery_reason = subcode; + else + /* Recovery was forced. Override recovery reason */ + sd->recovery_reason = VB2_RECOVERY_RO_MANUAL; sd->flags |= VB2_SD_FLAG_MANUAL_RECOVERY; } |