static void vboot_wrapper(void *arg) { VbError_t res; struct vboot_context *context; context = arg; gcontext = context; VbExDebug("Calling VbInit()\n"); res = VbInit(context->cparams, &context->handoff->init_params); VbExDebug("VbInit() returned 0x%08x\n", res); if (res != VBERROR_SUCCESS) { if(res == VBERROR_TPM_REBOOT_REQUIRED) { VbExDebug("TPM Reboot Required. Proceeding reboot.\n"); gcontext->reset(); } return; } VbExDebug("Calling VbSelectFirmware()\n"); res = VbSelectFirmware(context->cparams, context->fparams); VbExDebug("VbSelectFirmware() returned 0x%08x\n", res); if (res != VBERROR_SUCCESS) return; }
static void vboot_wrapper(void *arg) { int i; VbError_t res; const struct components *components; struct vboot_context *context; context = arg; gcontext = context; VbExDebug("Calling VbInit()\n"); res = VbInit(context->cparams, &context->handoff->init_params); VbExDebug("VbInit() returned 0x%08x\n", res); if (res != VBERROR_SUCCESS) return; VbExDebug("Calling VbSelectFirmware()\n"); res = VbSelectFirmware(context->cparams, context->fparams); VbExDebug("VbSelectFirmware() returned 0x%08x\n", res); if (res != VBERROR_SUCCESS) return; /* Fix up the handoff structure. */ context->handoff->selected_firmware = context->fparams->selected_firmware; /* Parse out the components for downstream consumption. */ if (context->handoff->selected_firmware == VB_SELECT_FIRMWARE_A) components = (void *)context->fw_a; else if (context->handoff->selected_firmware == VB_SELECT_FIRMWARE_B) components = (void *)context->fw_b; else return; for (i = 0; i < MAX_PARSED_FW_COMPONENTS; i++) { parse_component(components, i, &context->handoff->components[i]); } }
static VbError_t twostop_init_vboot_library(firmware_storage_t *file, void *gbb, uint32_t gbb_offset, size_t gbb_size, crossystem_data_t *cdata, VbCommonParams *cparams) { VbError_t err; VbInitParams iparams; int virtual_dev_switch = cros_fdtdec_config_has_prop(gd->fdt_blob, "virtual-dev-switch"); #ifdef CONFIG_MKBP struct mkbp_dev *mdev = board_get_mkbp_dev(); #endif memset(&iparams, 0, sizeof(iparams)); iparams.flags = check_ro_normal_support(); #ifdef CONFIG_MKBP if (mdev) { uint32_t ec_events = 0; const uint32_t kb_rec_mask = EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY); /* Read keyboard recovery flag from EC, then clear it */ if (mkbp_get_host_events(mdev, &ec_events)) { /* * TODO: what can we do if that fails? Request * recovery? We don't simply want to fail, because * that'll prevent us from going into recovery mode. * We don't want to go into recovery mode * automatically, because that'll break snow. */ VBDEBUG("VbInit: unable to read EC events\n"); ec_events = 0; } if (ec_events & kb_rec_mask) { iparams.flags |= VB_INIT_FLAG_REC_BUTTON_PRESSED; if (mkbp_clear_host_events(mdev, kb_rec_mask)) VBDEBUG("VbInit: unable to clear " "EC KB recovery event\n"); } } #endif if (cdata->boot_write_protect_switch) iparams.flags |= VB_INIT_FLAG_WP_ENABLED; if (cdata->boot_recovery_switch) iparams.flags |= VB_INIT_FLAG_REC_BUTTON_PRESSED; if (cdata->boot_developer_switch) iparams.flags |= VB_INIT_FLAG_DEV_SWITCH_ON; if (cdata->boot_oprom_loaded) iparams.flags |= VB_INIT_FLAG_OPROM_LOADED; if (cdata->oprom_matters) iparams.flags |= VB_INIT_FLAG_OPROM_MATTERS; if (virtual_dev_switch) iparams.flags |= VB_INIT_FLAG_VIRTUAL_DEV_SWITCH; if (cros_fdtdec_config_has_prop(gd->fdt_blob, "ec-software-sync")) iparams.flags |= VB_INIT_FLAG_EC_SOFTWARE_SYNC; if (cros_fdtdec_config_has_prop(gd->fdt_blob, "ec-slow-update")) iparams.flags |= VB_INIT_FLAG_EC_SLOW_UPDATE; if (flash_sw_wp_is_enabled(file)) iparams.flags |= VB_INIT_FLAG_SW_WP_ENABLED; VBDEBUG("iparams.flags: %08x\n", iparams.flags); if ((err = VbInit(cparams, &iparams))) { VBDEBUG("VbInit: %u\n", err); /* * If vboot wants EC to reboot to RO, make request now, * because there isn't a clear path to pass this request * through to do_vboot_twostop(). */ if (err == VBERROR_EC_REBOOT_TO_RO_REQUIRED) request_ec_reboot_to_ro(); return err; } #ifdef CONFIG_VIDEO_TEGRA tegra_lcd_check_next_stage(gd->fdt_blob, 0); #endif #ifdef CONFIG_EXYNOS_DISPLAYPORT exynos_lcd_check_next_stage(gd->fdt_blob, 0); #endif VBDEBUG("iparams.out_flags: %08x\n", iparams.out_flags); if (virtual_dev_switch) { cdata->boot_developer_switch = (iparams.out_flags & VB_INIT_OUT_ENABLE_DEVELOPER) ? 1 : 0; VBDEBUG("cdata->boot_developer_switch=%d\n", cdata->boot_developer_switch); } if (iparams.out_flags & VB_INIT_OUT_CLEAR_RAM) wipe_unused_memory(cdata, cparams); /* Load required information of GBB */ if (iparams.out_flags & VB_INIT_OUT_ENABLE_DISPLAY) { if (gbb_read_bmp_block(gbb, file, gbb_offset, gbb_size)) return VBERROR_INVALID_GBB; have_read_gbb_bmp_block = 1; } if (cdata->boot_developer_switch || iparams.out_flags & VB_INIT_OUT_ENABLE_RECOVERY) { if (gbb_read_recovery_key(gbb, file, gbb_offset, gbb_size)) return VBERROR_INVALID_GBB; } return VBERROR_SUCCESS; }
int main(void) { /* vboot_api.h - entry points INTO vboot_reference */ VbInit(0, 0); return 0; }