diff options
Diffstat (limited to 'firmware/2lib/2api.c')
-rw-r--r-- | firmware/2lib/2api.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/firmware/2lib/2api.c b/firmware/2lib/2api.c index 9184b23d..13b3a697 100644 --- a/firmware/2lib/2api.c +++ b/firmware/2lib/2api.c @@ -365,3 +365,33 @@ int vb2api_check_hash(struct vb2_context *ctx) { return vb2api_check_hash_get_digest(ctx, NULL, 0); } + +union vb2_fw_boot_info vb2api_get_fw_boot_info(struct vb2_context *ctx) +{ + union vb2_fw_boot_info info; + + struct vb2_shared_data *sd = vb2_get_sd(ctx); + + info.tries = vb2_nv_get(ctx, VB2_NV_TRY_COUNT); + info.slot = sd->fw_slot; + info.prev_slot = sd->last_fw_slot; + info.prev_result = sd->last_fw_result; + info.boot_mode = ctx->boot_mode; + + VB2_DEBUG("boot_mode=`%s`\n", vb2_boot_mode_string(info.boot_mode)); + + if (ctx->flags & VB2_CONTEXT_RECOVERY_MODE) { + info.recovery_reason = sd->recovery_reason; + info.recovery_subcode = vb2_nv_get(ctx, VB2_NV_RECOVERY_SUBCODE); + VB2_DEBUG("recovery_reason: %#x / %#x\n", + info.recovery_reason, info.recovery_subcode); + } + + VB2_DEBUG("fw_tried=`%s` fw_try_count=%d " + "fw_prev_tried=`%s` fw_prev_result=`%s`.\n", + vb2_slot_string(info.slot), info.tries, + vb2_slot_string(info.prev_slot), + vb2_result_string(info.prev_result)); + + return info; +} |