1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef __VBOOT_VBOOT_COMMON_H__
3 #define __VBOOT_VBOOT_COMMON_H__
5 #include <commonlib/region.h>
10 * Function to check if there is a request to enter recovery mode. Returns
11 * reason code if request to enter recovery mode is present, otherwise 0.
13 int vboot_check_recovery_request(void);
15 /* ============================ VBOOT REBOOT ============================== */
17 * vboot_reboot handles the reboot requests made by vboot_reference library. It
18 * allows the platform to run any preparation steps before the reboot and then
21 void vboot_reboot(void);
24 * Save vboot data and reboot device. Subcode will only be printed. To store
25 * failure reason and subcode vb2api_fail() should be called before this
26 * function or vboot_fail_and_reboot() should be used instead.
28 void vboot_save_and_reboot(struct vb2_context
*ctx
, uint8_t subcode
);
30 /* Call vb2api_fail() with reason and subcode, save vboot data and reboot. */
31 void vboot_fail_and_reboot(struct vb2_context
*ctx
, uint8_t reason
, uint8_t subcode
);
33 /* Allow the platform to do any clean up work when vboot requests a reboot. */
34 void vboot_platform_prepare_reboot(void);
36 /* ============================ VBOOT RESUME ============================== */
38 * Save the provided hash digest to a secure location to check against in
39 * the resume path. Returns 0 on success, < 0 on error.
41 int vboot_save_hash(void *digest
, size_t digest_size
);
44 * Retrieve the previously saved hash digest. Returns 0 on success,
47 int vboot_retrieve_hash(void *digest
, size_t digest_size
);
49 /* ============================= VERSTAGE ================================== */
51 * Main logic for verified boot. verstage_main() is just the core vboot logic.
52 * If the verstage is a separate stage, it should be entered via main().
54 void verstage_main(void);
55 void verstage_mainboard_early_init(void);
56 void verstage_mainboard_init(void);
58 /* Check boot modes */
59 #if CONFIG(VBOOT) && !ENV_SMM
60 int vboot_developer_mode_enabled(void);
61 int vboot_recovery_mode_enabled(void);
62 int vboot_can_enable_udc(void);
63 void vboot_run_logic(void);
64 const struct cbfs_boot_device
*vboot_get_cbfs_boot_device(void);
65 #else /* !CONFIG_VBOOT */
66 static inline int vboot_developer_mode_enabled(void) { return 0; }
67 static inline int vboot_recovery_mode_enabled(void) { return 0; }
68 /* If VBOOT is not enabled, we are okay enabling USB device controller (UDC). */
69 static inline int vboot_can_enable_udc(void) { return 1; }
70 static inline void vboot_run_logic(void) {}
71 static inline const struct cbfs_boot_device
*vboot_get_cbfs_boot_device(void)
77 void vboot_save_data(struct vb2_context
*ctx
);
80 * The API for performing EC software sync. Does not support
81 * "slow" updates or Auxiliary FW sync.
83 void vboot_sync_ec(void);
85 #endif /* __VBOOT_VBOOT_COMMON_H__ */