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.h | 78 +++++++++++++++++---------- 1 file changed, 51 insertions(+), 27 deletions(-) (limited to 'src/vendorcode/google/chromeos/vboot_common.h') diff --git a/src/vendorcode/google/chromeos/vboot_common.h b/src/vendorcode/google/chromeos/vboot_common.h index 250b0e50ac..ae135fe66f 100644 --- a/src/vendorcode/google/chromeos/vboot_common.h +++ b/src/vendorcode/google/chromeos/vboot_common.h @@ -15,37 +15,61 @@ #ifndef VBOOT_COMMON_H #define VBOOT_COMMON_H -#include #include +#include +#include +#include -/* The FW areas consist of multiple components. At the beginning of - * each area is the number of total compoments as well as the size and - * offset for each component. One needs to caculate the total size of the - * signed firmware region based off of the embedded metadata. */ -struct vboot_component_entry { - uint32_t offset; - uint32_t size; -} __attribute__((packed)); +#include "chromeos.h" -struct vboot_components { - uint32_t num_components; - struct vboot_component_entry entries[0]; +/* Locate vboot area by name. Returns 0 on success and -1 on error. */ +int vboot_named_region_device(const char *name, struct region_device *rdev); + +/* ========================== VBOOT HANDOFF APIs =========================== */ +/* + * The vboot_handoff structure contains the data to be consumed by downstream + * firmware after firmware selection has been completed. Namely it provides + * vboot shared data as well as the flags from VbInit. + */ +struct vboot_handoff { + VbInitParams init_params; + uint32_t selected_firmware; + char shared_data[VB_SHARED_DATA_MIN_SIZE]; } __attribute__((packed)); -/* The following functions return 0 on success, < 0 on error. */ -int vboot_named_region_device(const char *name, struct region_device *rdev); -int vboot_region_device(const struct region *reg, struct region_device *rdev); +/* + * vboot_get_handoff_info returns pointer to the vboot_handoff structure if + * available. vboot_handoff is available only after CBMEM comes online. If size + * is not NULL, size of the vboot_handoff structure is returned in it. + * Returns 0 on success and -1 on error. + */ int vboot_get_handoff_info(void **addr, uint32_t *size); -/* The following functions return 1 for true and 0 for false. */ -int vboot_skip_display_init(void); -int vboot_enable_recovery(void); -int vboot_enable_developer(void); - -int vboot_recovery_reason(void); +/* + * The following functions read vboot_handoff structure to obtain requested + * information. If vboot handoff is not available, 0 is returned by default. + * If vboot handoff is available: + * Returns 1 for flag if true + * Returns 0 for flag if false + * Returns value read for other fields + */ +int vboot_handoff_skip_display_init(void); +int vboot_handoff_check_recovery_flag(void); +int vboot_handoff_check_developer_flag(void); +int vboot_handoff_get_recovery_reason(void); +/* ============================ VBOOT REBOOT ============================== */ +/* + * vboot_reboot handles the reboot requests made by vboot_reference library. It + * allows the platform to run any preparation steps before the reboot and then + * does a hard reset. + */ void vboot_reboot(void); +/* Allow the platform to do any clean up work when vboot requests a reboot. */ +void vboot_platform_prepare_reboot(void); + +/* ============================ VBOOT RESUME ============================== */ /* * Save the provided hash digest to a secure location to check against in * the resume path. Returns 0 on success, < 0 on error. @@ -64,13 +88,13 @@ int vboot_retrieve_hash(void *digest, size_t digest_size); */ int vboot_platform_is_resuming(void); -/* Allow the platform to do any clean up work when vboot requests a reboot. */ -void vboot_platform_prepare_reboot(void); - -/* Main logic for verified boot. verstage() is the stage entry point - * while the verstage_main() is just the core logic. */ +/* ============================= VERSTAGE ================================== */ +/* + * Main logic for verified boot. verstage() is the stage entry point + * while the verstage_main() is just the core logic. + */ void verstage_main(void); -void verstage_mainboard_init(void); void verstage(void); +void verstage_mainboard_init(void); #endif /* VBOOT_COMMON_H */ -- cgit v1.2.3