/* * vb2_check_recovery_request looks up different components to identify if there * is a recovery request and returns appropriate reason code: * 1. Checks if recovery mode is initiated by EC. If yes, returns * VB2_RECOVERY_RO_MANUAL. * 2. Checks if recovery request is present in VBNV and returns the code read * from it. * 3. Checks recovery request in handoff for stages post-cbmem. * 4. For non-CBMEM stages, check if vboot verification is done and look-up * selected region to identify if vboot_refence library has requested recovery * path. If yes, return the reason code from shared data. * 5. If nothing applies, return 0 indicating no recovery request. */ int vboot_check_recovery_request(void) { int reason = 0; /* EC-initiated recovery. */ if (get_recovery_mode_switch()) return VB2_RECOVERY_RO_MANUAL; /* Recovery request in VBNV. */ if ((reason = get_recovery_mode_from_vbnv()) != 0) return reason; /* * Check recovery flag in vboot_handoff for stages post CBMEM coming * online. Since for some stages there is no way to know if cbmem has * already come online, try looking up handoff anyways. If it fails, * flow will fallback to looking up shared data. */ if (cbmem_possibly_online() && ((reason = vboot_handoff_get_recovery_reason()) != 0)) return reason; /* * For stages where CBMEM might not be online, identify if vboot * verification is already complete and no slot was selected * i.e. recovery path was requested. */ if (vboot_possibly_executed() && vb2_logic_executed() && !vb2_is_slot_selected()) return vb2_get_recovery_reason_shared_data(); return 0; }
static int vboot_locate(struct cbfs_props *props) { struct region selected_region; /* Don't honor vboot results until the vboot logic has run. */ if (!vb2_logic_executed()) return -1; if (vb2_get_selected_region(&selected_region)) return -1; props->offset = region_offset(&selected_region); props->size = region_sz(&selected_region); return 0; }