static void VbRegionReadTest(void) { /* Should read GBB */ ResetMocks(); TEST_TRUE(1, "Normal call"); TEST_EQ(VbSelectFirmware(&cparams, &fparams), VBERROR_SUCCESS, " Success"); TEST_EQ(mock_seen_region, 1 << VB_REGION_GBB, " GBB region"); TEST_PTR_EQ(cparams.gbb, NULL, " GBB free"); ResetMocks(); TEST_EQ(VbSelectAndLoadKernel(&cparams, &kparams), VBERROR_NO_DISK_FOUND, "Kernel"); TEST_PTR_EQ(cparams.gbb, NULL, " GBB free"); TEST_PTR_EQ(cparams.bmp, NULL, " BMP free"); ResetMocks(); shared->flags |= VBSD_BOOT_DEV_SWITCH_ON; TEST_EQ(VbSelectAndLoadKernel(&cparams, &kparams), VBERROR_NO_DISK_FOUND, "Kernel"); }
static uint32_t twostop_main_firmware(struct twostop_fmap *fmap, void *gbb, crossystem_data_t *cdata, void *vb_shared_data) { VbError_t err; VbSelectAndLoadKernelParams kparams; VbCommonParams cparams; size_t size = 0; #ifdef CONFIG_BOOTSTAGE_STASH bootstage_unstash((void *)CONFIG_BOOTSTAGE_STASH, CONFIG_BOOTSTAGE_STASH_SIZE); #endif bootstage_mark_name(BOOTSTAGE_VBOOT_TWOSTOP_MAIN_FIRMWARE, "twostop_main_firmware"); if (twostop_init_cparams(fmap, gbb, vb_shared_data, &cparams)) { VBDEBUG("failed to init cparams\n"); return TWOSTOP_SELECT_ERROR; } /* * Note that in case "kernel" is not found in the device tree, the * "size" value is going to remain unchanged. */ kparams.kernel_buffer = cros_fdtdec_alloc_region(gd->fdt_blob, "kernel", &size); kparams.kernel_buffer_size = size; VBDEBUG("kparams:\n"); VBDEBUG("- kernel_buffer: : %p\n", kparams.kernel_buffer); VBDEBUG("- kernel_buffer_size: : %08x\n", kparams.kernel_buffer_size); #ifdef CONFIG_EXYNOS_DISPLAYPORT /* * Make sure the LCD is up before we load the kernel. Partly this * is because VbSelectAndLoadKernel may do a software sync. */ exynos_lcd_check_next_stage(gd->fdt_blob, 1); #endif if ((err = VbSelectAndLoadKernel(&cparams, &kparams))) { VBDEBUG("VbSelectAndLoadKernel: %d\n", err); switch (err) { case VBERROR_SHUTDOWN_REQUESTED: return TWOSTOP_SELECT_POWER_OFF; case VBERROR_BIOS_SHELL_REQUESTED: return TWOSTOP_SELECT_COMMAND_LINE; case VBERROR_EC_REBOOT_TO_RO_REQUIRED: request_ec_reboot_to_ro(); return TWOSTOP_SELECT_POWER_OFF; } return TWOSTOP_SELECT_ERROR; } VBDEBUG("kparams:\n"); VBDEBUG("- kernel_buffer: : %p\n", kparams.kernel_buffer); VBDEBUG("- kernel_buffer_size: : %08x\n", kparams.kernel_buffer_size); VBDEBUG("- disk_handle: : %p\n", kparams.disk_handle); VBDEBUG("- partition_number: : %08x\n", kparams.partition_number); VBDEBUG("- bootloader_address: : %08llx\n", kparams.bootloader_address); VBDEBUG("- bootloader_size: : %08x\n", kparams.bootloader_size); VBDEBUG("- partition_guid: :"); #ifdef VBOOT_DEBUG int i; for (i = 0; i < 16; i++) VbExDebug(" %02x", kparams.partition_guid[i]); VbExDebug("\n"); #endif /* VBOOT_DEBUG */ /* EC might jump between RO and RW during software sync. We need to * update active EC copy in cdata. */ set_active_ec_firmware(cdata); crossystem_data_dump(cdata); #if defined(CONFIG_SANDBOX) return TWOSTOP_SELECT_COMMAND_LINE; #else boot_kernel(&kparams, cdata); /* It is an error if boot_kenel returns */ return TWOSTOP_SELECT_ERROR; #endif }