diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | board/chromebook-x86/vbexport/Makefile | 4 | ||||
-rw-r--r-- | common/Makefile | 2 | ||||
-rw-r--r-- | common/cmd_vboot_bootstub.c | 22 | ||||
-rw-r--r-- | common/cmd_vboot_main.c | 22 | ||||
-rw-r--r-- | include/configs/coreboot.h | 4 | ||||
-rw-r--r-- | include/vboot/entry_points.h | 19 | ||||
-rw-r--r-- | include/vboot/firmware_cache.h | 61 | ||||
-rw-r--r-- | include/vboot/global_data.h | 51 | ||||
-rw-r--r-- | lib/vboot/Makefile | 33 | ||||
-rw-r--r-- | lib/vboot/bootstub_entry.c | 377 | ||||
-rw-r--r-- | lib/vboot/firmware_cache.c | 33 | ||||
-rw-r--r-- | lib/vboot/global_data.c | 98 | ||||
-rw-r--r-- | lib/vboot/main_entry.c | 110 |
14 files changed, 2 insertions, 835 deletions
@@ -218,7 +218,6 @@ LIBS += lib/zlib/libz.o ifdef VBOOT LIBS += lib/chromeos/libchromeos.a LIBS += lib/vbexport/libvbexport.a -LIBS += lib/vboot/libvboot.a endif LIBS += board/$(VENDOR)/chromeos/libchromeos_board.a diff --git a/board/chromebook-x86/vbexport/Makefile b/board/chromebook-x86/vbexport/Makefile index b46b1112ea..a40c42c7ee 100644 --- a/board/chromebook-x86/vbexport/Makefile +++ b/board/chromebook-x86/vbexport/Makefile @@ -12,8 +12,8 @@ include $(TOPDIR)/config.mk LIB = $(obj)libvbexport_board.a -COBJS-$(CONFIG_CHROMEOS_VBEXPORT) += nvstorage.o -COBJS-$(CONFIG_CHROMEOS_VBEXPORT) += utility.o +COBJS-$(CONFIG_CHROMEOS) += nvstorage.o +COBJS-$(CONFIG_CHROMEOS) += utility.o COBJS := $(COBJS-y) OBJS := $(addprefix $(obj),$(COBJS)) diff --git a/common/Makefile b/common/Makefile index 71483a7851..203ed6c835 100644 --- a/common/Makefile +++ b/common/Makefile @@ -74,8 +74,6 @@ COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o COBJS-$(CONFIG_CMD_CPLBINFO) += cmd_cplbinfo.o -COBJS-$(CONFIG_CMD_VBOOT_BOOTSTUB) += cmd_vboot_bootstub.o -COBJS-$(CONFIG_CMD_VBOOT_MAIN) += cmd_vboot_main.o COBJS-$(CONFIG_CHROMEOS) += cmd_vboot_twostop.o COBJS-$(CONFIG_CHROMEOS_TEST) += cmd_vbexport_test.o COBJS-$(CONFIG_CHROMEOS_TEST) += cmd_vboot_test.o diff --git a/common/cmd_vboot_bootstub.c b/common/cmd_vboot_bootstub.c deleted file mode 100644 index b7a48cffb2..0000000000 --- a/common/cmd_vboot_bootstub.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - */ - -#include <common.h> -#include <command.h> -#include <vboot/entry_points.h> - -int do_vboot_bootstub(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) -{ - bootstub_entry(); - return 0; -} - -U_BOOT_CMD(vboot_bootstub, 1, 1, do_vboot_bootstub, - "verified boot bootstub firmware", NULL); diff --git a/common/cmd_vboot_main.c b/common/cmd_vboot_main.c deleted file mode 100644 index 07c97d5b78..0000000000 --- a/common/cmd_vboot_main.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - */ - -#include <common.h> -#include <command.h> -#include <vboot/entry_points.h> - -int do_vboot_main(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) -{ - main_entry(); - return 0; -} - -U_BOOT_CMD(vboot_main, 1, 1, do_vboot_main, - "verified boot main firmware", NULL); diff --git a/include/configs/coreboot.h b/include/configs/coreboot.h index ba41bf23c9..2e8bd39b8b 100644 --- a/include/configs/coreboot.h +++ b/include/configs/coreboot.h @@ -131,8 +131,6 @@ * VBoot Configuration. */ #define CONFIG_CHROMEOS -#define CONFIG_CHROMEOS_VBOOT -#define CONFIG_CHROMEOS_VBEXPORT #define CHROMEOS_BOOTARGS "" /* This value is just to get the chromeos library to compile. */ #define CHROMEOS_VBNVCONTEXT_LBA 0 @@ -172,8 +170,6 @@ #define CONFIG_CMD_FAT #define CONFIG_CMD_EXT2 #define CONFIG_CMD_USB -#define CONFIG_CMD_VBOOT_BOOTSTUB -#define CONFIG_CMD_VBOOT_MAIN #define CONFIG_BOOTDELAY -1 #undef CONFIG_BOOTARGS diff --git a/include/vboot/entry_points.h b/include/vboot/entry_points.h deleted file mode 100644 index e8c939ae55..0000000000 --- a/include/vboot/entry_points.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - */ - -/* Entry point of bootstub/recovery/normal/developer firmware */ - -#ifndef VBOOT_ENTRY_POINTS_H_ -#define VBOOT_ENTRY_POINTS_H_ - -void bootstub_entry(void); -void main_entry(void); - -#endif /* VBOOT_ENTRY_POINTS_H */ diff --git a/include/vboot/firmware_cache.h b/include/vboot/firmware_cache.h deleted file mode 100644 index df18c86ded..0000000000 --- a/include/vboot/firmware_cache.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - */ - -/* - * Firmware cache is the internal context for firmware/VbExHashFirmwareBody(). - * It keeps the RW firmware A/B data which is loaded in VbExHashFirmwareBody(). - * After VbSelectFirmware() returns, we can directly jump to the loaded - * firmware without another load from flash. - */ - -#ifndef VBOOT_FIRMWARE_CACHE_H_ -#define VBOOT_FIRMWARE_CACHE_H_ - -#include <linux/types.h> -#include <chromeos/firmware_storage.h> - -typedef struct { - /* - * The offset of the firmware data section from the beginning of - * the firmware storage device. - */ - off_t offset; - - /* - * The size of the signed firmware data section, which should be - * exactly the same size as what is described by the vblock. - * - * If this size is larger than what was signed (the vblock value), - * then VbExHashFirmwareBody() will hash the extra data and compute - * a different hash value that does not match. - */ - size_t size; - - /* - * Pointer to the firmware data section loaded by - * VbExHashFirmwareBody(). - */ - uint8_t *buffer; -} firmware_info_t; - -typedef struct { - firmware_storage_t *file; - firmware_info_t infos[2]; -} firmware_cache_t; - -/* Initialize fields of firmware cache. */ -void init_firmware_cache(firmware_cache_t *cache, firmware_storage_t *file, - off_t firmware_a_offset, size_t firmware_a_size, - off_t firmware_b_offset, size_t firmware_b_size); - -/* Release fields of firmware cache. */ -void free_firmware_cache(firmware_cache_t *cache); - -#endif /* VBOOT_FIRMWARE_CACHE_H */ diff --git a/include/vboot/global_data.h b/include/vboot/global_data.h deleted file mode 100644 index 408e553d7b..0000000000 --- a/include/vboot/global_data.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - */ - -/* - * VBoot Global Data keeps the common data which can be shared between - * different firmware variants, like the crossystem data between bootstub, - * normal/developer firmware, and kernel, the GBB data between bootstub and - * recovery/developer firmware. This data is stored in a fixed memory - * address, a region just above the stack region, such that u-boot - * with differnet symbol table can also locates it. - */ - -#ifndef VBOOT_GLOBAL_DATA_H_ -#define VBOOT_GLOBAL_DATA_H_ - -#include <common.h> -#include <chromeos/firmware_storage.h> -#include <chromeos/crossystem_data.h> -#include <vboot_struct.h> - -#define VBGLOBAL_SIGNATURE "VBGLOBAL" -#define VBGLOBAL_SIGNATURE_SIZE 8 -#define VBGLOBAL_VERSION 1 -#define GBB_MAX_LENGTH 0x20000 - -typedef struct { - uint8_t signature[VBGLOBAL_SIGNATURE_SIZE]; - uint32_t version; - uint32_t gbb_size; - uint8_t gbb_data[GBB_MAX_LENGTH]; - uint32_t cdata_size; - crossystem_data_t cdata_blob; -} vb_global_t; - -/* Gets vboot global data pointer. */ -vb_global_t *get_vboot_global(void); - -/* Initializes vboot global data. It also loads the GBB data from SPI. */ -int init_vboot_global(vb_global_t *global, firmware_storage_t *file); - -/* Checks if vboot global data valid or not. */ -int is_vboot_global_valid(vb_global_t *global); - -#endif /* VBOOT_GLOBAL_DATA_H */ diff --git a/lib/vboot/Makefile b/lib/vboot/Makefile deleted file mode 100644 index b209529113..0000000000 --- a/lib/vboot/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -# Alternatively, this software may be distributed under the terms of the -# GNU General Public License ("GPL") version 2 as published by the Free -# Software Foundation. -# - -include $(TOPDIR)/config.mk - -LIB = $(obj)libvboot.a - -COBJS-$(CONFIG_CHROMEOS_VBOOT) += bootstub_entry.o -COBJS-$(CONFIG_CHROMEOS_VBOOT) += firmware_cache.o -COBJS-$(CONFIG_CHROMEOS_VBOOT) += global_data.o -COBJS-$(CONFIG_CHROMEOS_VBOOT) += main_entry.o - -COBJS := $(COBJS-y) -OBJS := $(addprefix $(obj),$(COBJS)) - -$(LIB): $(obj).depend $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) - -######################################################################### - -# defines $(obj).depend target -include $(SRCTREE)/rules.mk - -sinclude $(obj).depend - -######################################################################### diff --git a/lib/vboot/bootstub_entry.c b/lib/vboot/bootstub_entry.c deleted file mode 100644 index 17110b67b5..0000000000 --- a/lib/vboot/bootstub_entry.c +++ /dev/null @@ -1,377 +0,0 @@ -/* - * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - */ - -#include <common.h> -#include <chromeos/common.h> -#include <fdt_decode.h> -#include <chromeos/crossystem_data.h> -#include <chromeos/fdt_decode.h> -#include <chromeos/firmware_storage.h> -#include <chromeos/gbb.h> -#include <chromeos/power_management.h> -#include <chromeos/memory_wipe.h> -#include <vboot/entry_points.h> -#include <vboot/firmware_cache.h> -#include <vboot/global_data.h> - -#include <vboot_api.h> - -#define PREFIX "bootstub: " - -DECLARE_GLOBAL_DATA_PTR; - -/* The margin to keep extra stack region that not to be wiped. */ -#define STACK_MARGIN 1024 - -static void prepare_cparams(vb_global_t *global, VbCommonParams *cparams) -{ - cparams->gbb_data = global->gbb_data; - cparams->gbb_size = global->gbb_size; - cparams->shared_data_blob = global->cdata_blob.vb_shared_data; - cparams->shared_data_size = VB_SHARED_DATA_REC_SIZE; -} - -static void prepare_iparams(vb_global_t *global, VbInitParams *iparams) -{ - crossystem_data_t *cdata = &global->cdata_blob; - iparams->flags = VB_INIT_FLAG_RO_NORMAL_SUPPORT; - if (cdata->boot_developer_switch) - iparams->flags |= VB_INIT_FLAG_DEV_SWITCH_ON; - if (cdata->boot_recovery_switch) - iparams->flags |= VB_INIT_FLAG_REC_BUTTON_PRESSED; - if (cdata->boot_write_protect_switch) - iparams->flags |= VB_INIT_FLAG_WP_ENABLED; -} - -static int read_verification_block(firmware_storage_t *file, - const off_t vblock_offset, void **vblock_ptr, - uint32_t *vblock_size_ptr, uint32_t *body_size_ptr) -{ - VbKeyBlockHeader kbh; - VbFirmwarePreambleHeader fph; - uint32_t key_block_size, vblock_size; - void *vblock; - - /* read key block header */ - if (file->read(file, vblock_offset, sizeof(kbh), &kbh)) { - VBDEBUG(PREFIX "Failed to read key block!\n"); - return -1; - } - key_block_size = kbh.key_block_size; - - /* read firmware preamble header */ - if (file->read(file, vblock_offset + key_block_size, - sizeof(fph), &fph)) { - VBDEBUG(PREFIX "Failed to read preamble!\n"); - return -1; - } - vblock_size = key_block_size + fph.preamble_size; - - vblock = VbExMalloc(vblock_size); - - if (file->read(file, vblock_offset, vblock_size, vblock)) { - VBDEBUG(PREFIX "Failed to read verification block!\n"); - VbExFree(vblock); - return -1; - } - - *vblock_ptr = vblock; - *vblock_size_ptr = vblock_size; - *body_size_ptr = fph.body_signature.data_size; - - return 0; -} - -static void prepare_fparams(firmware_storage_t *file, - firmware_cache_t *cache, - struct twostop_fmap *fmap, - VbSelectFirmwareParams *fparams) -{ - uint32_t fw_main_a_size, fw_main_b_size; - - if (read_verification_block(file, - fmap->readwrite_a.vblock.offset, - &fparams->verification_block_A, - &fparams->verification_size_A, - &fw_main_a_size)) - VbExError(PREFIX "Failed to read verification block A!\n"); - - if (read_verification_block(file, - fmap->readwrite_b.vblock.offset, - &fparams->verification_block_B, - &fparams->verification_size_B, - &fw_main_b_size)) - VbExError(PREFIX "Failed to read verification block B!\n"); - - /* Prepare the firmware cache which is passed as caller_context. */ - init_firmware_cache(cache, - file, - fmap->readwrite_a.boot.offset, - fw_main_a_size, - fmap->readwrite_b.boot.offset, - fw_main_b_size); -} - -static void release_fparams(VbSelectFirmwareParams *fparams) -{ - VbExFree(fparams->verification_block_A); - VbExFree(fparams->verification_block_B); -} - -#ifdef CONFIG_OF_CONTROL -static uintptr_t get_current_sp(void) -{ - uintptr_t addr; - - addr = (uintptr_t)&addr; - return addr; -} -#endif - -static void wipe_unused_memory(const void const *fdt_ptr, vb_global_t *global) -{ -#ifdef CONFIG_OF_CONTROL - memory_wipe_t wipe; - struct fdt_memory config; - - if (fdt_decode_memory(fdt_ptr, &config)) - VbExError(PREFIX "FDT decode memory section error\n"); - - memory_wipe_init(&wipe, config.start, config.end); - - /* Excludes stack, fdt, gd, bd, heap, u-boot, framebuffer, etc. */ - memory_wipe_exclude(&wipe, get_current_sp() - STACK_MARGIN, config.end); - - /* Excludes the shared data between bootstub and main firmware. */ - memory_wipe_exclude(&wipe, (uintptr_t)global, - (uintptr_t)global + sizeof(*global)); - - /* Excludes the LP0 vector. */ - memory_wipe_exclude(&wipe, - (uintptr_t)TEGRA_LP0_ADDR, - (uintptr_t)(TEGRA_LP0_ADDR + TEGRA_LP0_SIZE)); - - memory_wipe_execute(&wipe); -#else - printf("wipe_unused_memory depends on fdt_decode_memory which" - " isn't configured\n"); -#endif -} - -typedef void (*firmware_entry_t)(void); - -static void jump_to_firmware(firmware_entry_t firmware_entry) -{ - VBDEBUG(PREFIX "Jump to firmware %p...\n", firmware_entry); - - cleanup_before_linux(); - - /* Jump and never return */ - (*firmware_entry)(); - - VbExError(PREFIX "Firmware %p returned!\n", firmware_entry); -} - -static VbError_t call_VbInit(VbCommonParams *cparams, VbInitParams *iparams) -{ - VbError_t ret; - - VBDEBUG("VbCommonParams:\n"); - VBDEBUG(" gbb_data : %p\n", cparams->gbb_data); - VBDEBUG(" gbb_size : %u\n", cparams->gbb_size); - VBDEBUG(" shared_data_blob : %p\n", cparams->shared_data_blob); - VBDEBUG(" shared_data_size : %u\n", cparams->shared_data_size); - VBDEBUG(" caller_context : %p\n", cparams->caller_context); - VBDEBUG("VbInitParams:\n"); - VBDEBUG(" flags : %#x\n", iparams->flags); - VBDEBUG("Calling VbInit()...\n"); - - ret = VbInit(cparams, iparams); - VBDEBUG("Returned %#x\n", ret); - - if (!ret) { - VBDEBUG("VbInitParams:\n"); - VBDEBUG(" out_flags : %#x\n", iparams->out_flags); - } - - return ret; -} - -static VbError_t call_VbSelectFirmware(VbCommonParams *cparams, - VbSelectFirmwareParams *fparams) -{ - VbError_t ret; - - VBDEBUG("VbCommonParams:\n"); - VBDEBUG(" gbb_data : %p\n", cparams->gbb_data); - VBDEBUG(" gbb_size : %u\n", cparams->gbb_size); - VBDEBUG(" shared_data_blob : %p\n", cparams->shared_data_blob); - VBDEBUG(" shared_data_size : %u\n", cparams->shared_data_size); - VBDEBUG(" caller_context : %p\n", cparams->caller_context); - - VBDEBUG("VbSelectFirmwareParams:\n"); - VBDEBUG(" verification_block_A : %p\n", - fparams->verification_block_A); - VBDEBUG(" verification_block_B : %p\n", - fparams->verification_block_B); - VBDEBUG(" verification_size_A : %u\n", - fparams->verification_size_A); - VBDEBUG(" verification_size_B : %u\n", - fparams->verification_size_B); - VBDEBUG("Calling VbSelectFirmware()...\n"); - - ret = VbSelectFirmware(cparams, fparams); - VBDEBUG("Returned %#x\n", ret); - - if (!ret) { - VBDEBUG("VbSelectFirmwareParams:\n"); - VBDEBUG(" selected_firmware : %u\n", - fparams->selected_firmware); - } - - return ret; -} - -static int fill_crossystem_data(vb_global_t *global, - firmware_storage_t *file, - struct twostop_fmap *fmap, - uint32_t selected_firmware) -{ - crossystem_data_t *cdata = &global->cdata_blob; - uint8_t fwid_buf[ID_LEN]; - uint8_t *fwid = fwid_buf; - uint32_t fwid_offset; - /* mainfw_type of non-recovery boot depends on dev switch */ - int mainfw_type = cdata->boot_developer_switch ? - FIRMWARE_TYPE_DEVELOPER : FIRMWARE_TYPE_NORMAL; - - /* Fills FWID */ - switch (selected_firmware) { - case VB_SELECT_FIRMWARE_RECOVERY: - mainfw_type = FIRMWARE_TYPE_RECOVERY; - /* continue */ - - case VB_SELECT_FIRMWARE_READONLY: - fwid = cdata->readonly_firmware_id; - goto done; - - case VB_SELECT_FIRMWARE_A: - fwid_offset = fmap->readwrite_a.firmware_id.offset; - assert(fmap->readwrite_a.firmware_id.length == ID_LEN); - break; - - case VB_SELECT_FIRMWARE_B: - fwid_offset = fmap->readwrite_b.firmware_id.offset; - assert(fmap->readwrite_b.firmware_id.length == ID_LEN); - break; - - default: - return 1; - } - - if (file->read(file, fwid_offset, ID_LEN, fwid_buf)) { - VBDEBUG(PREFIX "Failed to read FWID from firmware!\n"); - return 1; - } - -done: - crossystem_data_set_main_firmware(cdata, mainfw_type, fwid); - crossystem_data_dump(cdata); - - return 0; -} - -void bootstub_entry(void) -{ - void *fdt_ptr = (void *)gd->blob; - struct twostop_fmap fmap; - vb_global_t *global; - firmware_storage_t file; - firmware_cache_t cache; - VbCommonParams cparams; - VbInitParams iparams; - VbSelectFirmwareParams fparams; - VbError_t ret; - - if (decode_twostop_fmap(&fmap)) - VbExError(PREFIX "Failed to load fmap config.\n"); - - /* Open firmware storage device */ - if (firmware_storage_open_spi(&file)) - VbExError(PREFIX "Failed to open firmware device!\n"); - - /* Init VBoot Global Data and load GBB from SPI */ - global = get_vboot_global(); - if (init_vboot_global(global, &file)) - VbExError(PREFIX "Failed to init vboot global data!\n"); - - /* Call VbInit() */ - prepare_cparams(global, &cparams); - prepare_iparams(global, &iparams); - if ((ret = call_VbInit(&cparams, &iparams))) - VbExError(PREFIX "VbInit() returns error: %#x!\n", ret); - - /* Handle the VbInit() results */ - if (iparams.out_flags & VB_INIT_OUT_CLEAR_RAM) - wipe_unused_memory(fdt_ptr, global); - if (iparams.out_flags & VB_INIT_OUT_ENABLE_DISPLAY) - if (gbb_read_bmp_block(global->gbb_data, &file, - fmap.readonly.gbb.offset)) - VbExError(PREFIX "Failed to load BMP Block!\n"); - if (iparams.out_flags & VB_INIT_OUT_ENABLE_RECOVERY) - if (gbb_read_recovery_key(global->gbb_data, &file, - fmap.readonly.gbb.offset)) - VbExError(PREFIX "Failed to load recovery key!\n"); - - /* Call VbSelectFirmware() */ - cparams.caller_context = &cache; - prepare_fparams(&file, &cache, &fmap, &fparams); - if ((ret = call_VbSelectFirmware(&cparams, &fparams))) - VbExError(PREFIX "VbSelectFirmare() returned error: %#x!\n", - ret); - release_fparams(&fparams); - - if (fill_crossystem_data(global, &file, &fmap, - fparams.selected_firmware)) - VbExError(PREFIX "Failed to fill crossystem data!\n"); - - if (file.close(&file)) - VbExError(PREFIX "Failed to close firmware device!\n"); - - /* Handle the VbSelectFirmware() results */ - switch (fparams.selected_firmware) { - case VB_SELECT_FIRMWARE_A: - memcpy((void *)CONFIG_SYS_TEXT_BASE, cache.infos[0].buffer, - cache.infos[0].size); - jump_to_firmware((firmware_entry_t)CONFIG_SYS_TEXT_BASE); - break; - - case VB_SELECT_FIRMWARE_B: - memcpy((void *)CONFIG_SYS_TEXT_BASE, cache.infos[1].buffer, - cache.infos[1].size); - jump_to_firmware((firmware_entry_t)CONFIG_SYS_TEXT_BASE); - break; - - case VB_SELECT_FIRMWARE_RECOVERY: - VBDEBUG(PREFIX "Boot to recovery mode...\n"); - main_entry(); - break; - - case VB_SELECT_FIRMWARE_READONLY: - VBDEBUG(PREFIX "Boot to RO firmware...\n"); - main_entry(); - break; - - default: - VbExError(PREFIX "Unexpected selected firmware value!\n"); - } - - VbExError(PREFIX "Should not reach here!\n"); -} diff --git a/lib/vboot/firmware_cache.c b/lib/vboot/firmware_cache.c deleted file mode 100644 index 188e7b9404..0000000000 --- a/lib/vboot/firmware_cache.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - */ - -#include <vboot/firmware_cache.h> - -/* Import the header files from vboot_reference. */ -#include <vboot_api.h> - -void init_firmware_cache(firmware_cache_t *cache, firmware_storage_t *file, - off_t firmware_a_offset, size_t firmware_a_size, - off_t firmware_b_offset, size_t firmware_b_size) -{ - cache->file = file; - cache->infos[0].offset = firmware_a_offset; - cache->infos[1].offset = firmware_b_offset; - cache->infos[0].size = firmware_a_size; - cache->infos[1].size = firmware_b_size; - cache->infos[0].buffer = VbExMalloc(firmware_a_size); - cache->infos[1].buffer = VbExMalloc(firmware_b_size); -} - -void free_firmware_cache(firmware_cache_t *cache) -{ - VbExFree(cache->infos[0].buffer); - VbExFree(cache->infos[1].buffer); -} diff --git a/lib/vboot/global_data.c b/lib/vboot/global_data.c deleted file mode 100644 index ac0fac5e3a..0000000000 --- a/lib/vboot/global_data.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - */ - -#include <common.h> -#include <fdt_decode.h> -#include <chromeos/common.h> -#include <chromeos/cros_gpio.h> -#include <chromeos/gbb.h> -#include <vboot/global_data.h> - -#include <gbb_header.h> -#include <vboot_api.h> - -#define PREFIX "global_data: " - -DECLARE_GLOBAL_DATA_PTR; - -vb_global_t *get_vboot_global(void) -{ - return (vb_global_t *)(CONFIG_VBGLOBAL_BASE); -} - -int init_vboot_global(vb_global_t *global, firmware_storage_t *file) -{ - cros_gpio_t wpsw, recsw, devsw; - struct twostop_fmap fmap; - uint8_t frid[ID_LEN]; - GoogleBinaryBlockHeader *gbb = - (GoogleBinaryBlockHeader *)global->gbb_data; - - global->version = VBGLOBAL_VERSION; - memcpy(global->signature, VBGLOBAL_SIGNATURE, - VBGLOBAL_SIGNATURE_SIZE); - - /* Gets GPIO status */ - if (cros_gpio_fetch(CROS_GPIO_WPSW, &wpsw) || - cros_gpio_fetch(CROS_GPIO_RECSW, &recsw) || - cros_gpio_fetch(CROS_GPIO_DEVSW, &devsw)) { - VBDEBUG(PREFIX "Failed to fetch GPIO!\n"); - return 1; - } - - if (decode_twostop_fmap(&fmap)) { - VBDEBUG(PREFIX "Failed to load fmap config!\n"); - return 1; - } - - /* Loads a minimal required part of GBB from SPI */ - if (fmap.readonly.gbb.length > GBB_MAX_LENGTH) { - VBDEBUG(PREFIX "The GBB size declared in FDT is too big!\n"); - return 1; - } - global->gbb_size = fmap.readonly.gbb.length; - - if (gbb_init(global->gbb_data, file, fmap.readonly.gbb.offset)) { - VBDEBUG(PREFIX "Failed to read GBB!\n"); - return 1; - } - - if (fmap.readonly.firmware_id.length > ID_LEN) { - VBDEBUG(PREFIX "The FWID size declared in FDT is too big!\n"); - return 1; - } - if (file->read(file, - fmap.readonly.firmware_id.offset, - fmap.readonly.firmware_id.length, - frid)) { - VBDEBUG(PREFIX "Failed to read frid!\n"); - return 1; - } - - if (crossystem_data_init(&global->cdata_blob, - &wpsw, &recsw, &devsw, - fmap.readonly.fmap.offset, - ACTIVE_EC_FIRMWARE_RO, - (uint8_t *)global->gbb_data + gbb->hwid_offset, - frid)) { - VBDEBUG(PREFIX "Failed to init crossystem data!\n"); - return 1; - } - - global->cdata_size = sizeof(crossystem_data_t); - - return 0; -} - -int is_vboot_global_valid(vb_global_t *global) -{ - return (global && memcmp(global->signature, - VBGLOBAL_SIGNATURE, VBGLOBAL_SIGNATURE_SIZE) == 0); -} diff --git a/lib/vboot/main_entry.c b/lib/vboot/main_entry.c deleted file mode 100644 index c2cb49bfec..0000000000 --- a/lib/vboot/main_entry.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - */ - -#include <common.h> -#include <chromeos/boot_kernel.h> -#include <chromeos/common.h> -#include <tss_constants.h> -#include <vboot/entry_points.h> -#include <vboot/global_data.h> -#include <vboot_api.h> - -#define PREFIX "main: " - -static void prepare_cparams(vb_global_t *global, VbCommonParams *cparams) -{ - cparams->gbb_data = global->gbb_data; - cparams->gbb_size = global->gbb_size; - cparams->shared_data_blob = global->cdata_blob.vb_shared_data; - cparams->shared_data_size = VB_SHARED_DATA_REC_SIZE; -} - -static void prepare_kparams(VbSelectAndLoadKernelParams *kparams) -{ - kparams->kernel_buffer = (void *)CHROMEOS_KERNEL_LOADADDR; - kparams->kernel_buffer_size = CHROMEOS_KERNEL_BUFSIZE; -} - -static VbError_t call_VbSelectAndLoadKernel(VbCommonParams* cparams, - VbSelectAndLoadKernelParams* kparams) -{ - VbError_t ret; - - VBDEBUG("VbCommonParams:\n"); - VBDEBUG(" gbb_data : %p\n", cparams->gbb_data); - VBDEBUG(" gbb_size : %u\n", cparams->gbb_size); - VBDEBUG(" shared_data_blob : %p\n", cparams->shared_data_blob); - VBDEBUG(" shared_data_size : %u\n", cparams->shared_data_size); - VBDEBUG(" caller_context : %p\n", cparams->caller_context); - VBDEBUG("VbSelectAndLoadKernelParams:\n"); - VBDEBUG(" kernel_buffer : %p\n", kparams->kernel_buffer); - VBDEBUG(" kernel_buffer_size : %u\n", - kparams->kernel_buffer_size); - VBDEBUG("Calling VbSelectAndLoadKernel()...\n"); - - ret = VbSelectAndLoadKernel(cparams, kparams); - VBDEBUG("Returned %#x\n", ret); - - if (!ret) { - int i; - VBDEBUG("VbSelectAndLoadKernelParams:\n"); - VBDEBUG(" disk_handle : %p\n", - kparams->disk_handle); - VBDEBUG(" partition_number : %u\n", - kparams->partition_number); - VBDEBUG(" bootloader_address : %#llx\n", - kparams->bootloader_address); - VBDEBUG(" bootloader_size : %u\n", - kparams->bootloader_size); - VBDEBUG(" partition_guid :"); - for (i = 0; i < 16; i++) - VBDEBUG(" %02x", kparams->partition_guid[i]); - VBDEBUG("\n"); - } - - return ret; -} - -void main_entry(void) -{ - vb_global_t *global; - VbCommonParams cparams; - VbSelectAndLoadKernelParams kparams; - VbError_t ret; - - /* Get VBoot Global Data which was initialized by bootstub. */ - global = get_vboot_global(); - if (!is_vboot_global_valid(global)) - VbExError(PREFIX "VBoot Global Data is not initialized!\n"); - - prepare_cparams(global, &cparams); - prepare_kparams(&kparams); - - /* - * VbSelectAndLoadKernel() assumes the TPM interface has already been - * initialized by VbSelectFirmware(). Since we haven't called - * VbSelectFirmware() in the readwrite firmware, we need to explicitly - * initialize the TPM interface. Note that this only re-initializes the - * interface, not the TPM itself. - */ - if (VbExTpmInit() != TPM_SUCCESS) { - VbExError(PREFIX "failed to init tpm interface\n"); - } - - ret = call_VbSelectAndLoadKernel(&cparams, &kparams); - - if (ret) - VbExError(PREFIX "Failed to select and load kernel!\n"); - - /* Do boot partition substitution in kernel cmdline and boot */ - ret = boot_kernel(&kparams, &global->cdata_blob); - - VbExError(PREFIX "boot_kernel_helper returned, %u\n", ret); -} |