From a6c5ddd595e145ffd091a9fcadb5e0ffbf0fa8d1 Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Fri, 22 Jul 2016 06:59:40 -0700 Subject: vboot: Clean up vboot code 1. Remove unused functions/structures. 2. Add checks for NULL return values. 3. Change prefixes to vb2 instead of vboot for functions used internally within vboot2/ 4. Get rid of vboot_handoff.h file and move the structure definition to vboot_common.h 5. Rename all functions using handoff structure to have prefix vboot_handoff_*. All the handoff functions can be run _only_ after cbmem is online. 6. Organize vboot_common.h content according to different functionalities. BUG=chrome-os-partner:55431 Change-Id: I4c07d50327d88cddbdfbb0b6f82c264e2b8620eb Signed-off-by: Furquan Shaikh Reviewed-on: https://review.coreboot.org/15799 Reviewed-by: Aaron Durbin Tested-by: build bot (Jenkins) --- src/vendorcode/google/chromeos/vboot_common.c | 51 +++++++++++++-------------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'src/vendorcode/google/chromeos/vboot_common.c') diff --git a/src/vendorcode/google/chromeos/vboot_common.c b/src/vendorcode/google/chromeos/vboot_common.c index 28135a0d65..66800ed635 100644 --- a/src/vendorcode/google/chromeos/vboot_common.c +++ b/src/vendorcode/google/chromeos/vboot_common.c @@ -26,72 +26,70 @@ #include "chromeos.h" #include "vboot_common.h" -#include "vboot_handoff.h" int vboot_named_region_device(const char *name, struct region_device *rdev) { return fmap_locate_area_as_rdev(name, rdev); } -int vboot_region_device(const struct region *reg, struct region_device *rdev) -{ - return boot_device_ro_subregion(reg, rdev); -} - +/* ========================== VBOOT HANDOFF APIs =========================== */ int vboot_get_handoff_info(void **addr, uint32_t *size) { - struct vboot_handoff *vboot_handoff; - - /* No flags are available in a separate verstage or bootblock because - * cbmem only comes online when dram does. */ - if ((ENV_VERSTAGE && IS_ENABLED(CONFIG_VBOOT_STARTS_IN_BOOTBLOCK)) || - ENV_BOOTBLOCK) + /* + * vboot_handoff is present only after cbmem comes online. If we are in + * pre-ram stage, then bail out early. + */ + if (ENV_BOOTBLOCK || + (ENV_VERSTAGE && IS_ENABLED(CONFIG_VBOOT_STARTS_IN_BOOTBLOCK))) return -1; + struct vboot_handoff *vboot_handoff; vboot_handoff = cbmem_find(CBMEM_ID_VBOOT_HANDOFF); if (vboot_handoff == NULL) return -1; *addr = vboot_handoff; - *size = sizeof(*vboot_handoff); + + if (size) + *size = sizeof(*vboot_handoff); return 0; } -static int vboot_handoff_flag(uint32_t flag) +static int vboot_get_handoff_flag(uint32_t flag) { struct vboot_handoff *vbho; - uint32_t size; - if (vboot_get_handoff_info((void **)&vbho, &size)) + /* + * If vboot_handoff cannot be found, return default value of flag as 0. + */ + if (vboot_get_handoff_info((void **)&vbho, NULL)) return 0; return !!(vbho->init_params.out_flags & flag); } -int vboot_skip_display_init(void) +int vboot_handoff_skip_display_init(void) { - return !vboot_handoff_flag(VB_INIT_OUT_ENABLE_DISPLAY); + return !vboot_get_handoff_flag(VB_INIT_OUT_ENABLE_DISPLAY); } -int vboot_enable_developer(void) +int vboot_handoff_check_developer_flag(void) { - return vboot_handoff_flag(VB_INIT_OUT_ENABLE_DEVELOPER); + return vboot_get_handoff_flag(VB_INIT_OUT_ENABLE_DEVELOPER); } -int vboot_enable_recovery(void) +int vboot_handoff_check_recovery_flag(void) { - return vboot_handoff_flag(VB_INIT_OUT_ENABLE_RECOVERY); + return vboot_get_handoff_flag(VB_INIT_OUT_ENABLE_RECOVERY); } -int vboot_recovery_reason(void) +int vboot_handoff_get_recovery_reason(void) { struct vboot_handoff *vbho; VbSharedDataHeader *sd; - vbho = cbmem_find(CBMEM_ID_VBOOT_HANDOFF); - - if (vbho == NULL) + if (vboot_get_handoff_info((void **)&vbho, NULL)) return 0; sd = (VbSharedDataHeader *)vbho->shared_data; @@ -99,6 +97,7 @@ int vboot_recovery_reason(void) return sd->recovery_reason; } +/* ============================ VBOOT REBOOT ============================== */ void __attribute__((weak)) vboot_platform_prepare_reboot(void) { } -- cgit v1.2.3