2014-10-10 19:51:06 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Google, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
2016-07-25 20:48:03 +02:00
|
|
|
#ifndef __VBOOT_VBOOT_COMMON_H__
|
|
|
|
#define __VBOOT_VBOOT_COMMON_H__
|
2014-10-10 19:51:06 +02:00
|
|
|
|
2015-09-08 20:34:43 +02:00
|
|
|
#include <commonlib/region.h>
|
2016-07-22 15:59:40 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <vboot_api.h>
|
|
|
|
#include <vboot_struct.h>
|
2014-10-10 19:51:06 +02:00
|
|
|
|
2016-07-22 15:59:40 +02:00
|
|
|
/* 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);
|
|
|
|
|
2016-08-12 19:46:07 +02:00
|
|
|
/* Like vboot_named_region_device() but provides a RW region device. */
|
|
|
|
int vboot_named_region_device_rw(const char *name, struct region_device *rdev);
|
|
|
|
|
2016-07-22 17:28:57 +02:00
|
|
|
/*
|
|
|
|
* Function to check if there is a request to enter recovery mode. Returns
|
|
|
|
* reason code if request to enter recovery mode is present, otherwise 0.
|
|
|
|
*/
|
|
|
|
int vboot_check_recovery_request(void);
|
|
|
|
|
2016-07-22 15:59:40 +02:00
|
|
|
/* ============================ 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.
|
|
|
|
*/
|
2015-09-03 11:41:14 +02:00
|
|
|
void vboot_reboot(void);
|
2014-10-10 19:51:06 +02:00
|
|
|
|
2016-07-22 15:59:40 +02:00
|
|
|
/* Allow the platform to do any clean up work when vboot requests a reboot. */
|
|
|
|
void vboot_platform_prepare_reboot(void);
|
|
|
|
|
|
|
|
/* ============================ VBOOT RESUME ============================== */
|
2016-01-22 22:26:04 +01:00
|
|
|
/*
|
|
|
|
* Save the provided hash digest to a secure location to check against in
|
|
|
|
* the resume path. Returns 0 on success, < 0 on error.
|
|
|
|
*/
|
|
|
|
int vboot_save_hash(void *digest, size_t digest_size);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Retrieve the previously saved hash digest. Returns 0 on success,
|
|
|
|
* < 0 on error.
|
|
|
|
*/
|
|
|
|
int vboot_retrieve_hash(void *digest, size_t digest_size);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine if the platform is resuming from suspend. Returns 0 when
|
|
|
|
* not resuming, > 0 if resuming, and < 0 on error.
|
|
|
|
*/
|
|
|
|
int vboot_platform_is_resuming(void);
|
|
|
|
|
2016-07-22 15:59:40 +02:00
|
|
|
/* ============================= VERSTAGE ================================== */
|
|
|
|
/*
|
2017-03-17 03:21:51 +01:00
|
|
|
* Main logic for verified boot. verstage_main() is just the core vboot logic.
|
|
|
|
* If the verstage is a separate stage, it should be entered via main().
|
2016-07-22 15:59:40 +02:00
|
|
|
*/
|
2015-09-30 00:56:59 +02:00
|
|
|
void verstage_main(void);
|
2016-07-22 15:59:40 +02:00
|
|
|
void verstage_mainboard_init(void);
|
2015-09-30 00:56:59 +02:00
|
|
|
|
2016-07-25 22:02:36 +02:00
|
|
|
/* Check boot modes */
|
2019-03-06 01:53:33 +01:00
|
|
|
#if CONFIG(VBOOT)
|
2016-07-25 22:02:36 +02:00
|
|
|
int vboot_developer_mode_enabled(void);
|
|
|
|
int vboot_recovery_mode_enabled(void);
|
2016-11-06 07:52:08 +01:00
|
|
|
int vboot_recovery_mode_memory_retrain(void);
|
2018-04-26 03:15:44 +02:00
|
|
|
int vboot_can_enable_udc(void);
|
2017-03-17 22:29:10 +01:00
|
|
|
#else /* !CONFIG_VBOOT */
|
|
|
|
static inline int vboot_developer_mode_enabled(void) { return 0; }
|
|
|
|
static inline int vboot_recovery_mode_enabled(void) { return 0; }
|
|
|
|
static inline int vboot_recovery_mode_memory_retrain(void) { return 0; }
|
2018-04-26 03:15:44 +02:00
|
|
|
/* If VBOOT is not enabled, we are okay enabling USB device controller (UDC). */
|
|
|
|
static inline int vboot_can_enable_udc(void) { return 1; }
|
2017-03-17 22:29:10 +01:00
|
|
|
#endif
|
2016-07-25 22:02:36 +02:00
|
|
|
|
2016-07-25 20:48:03 +02:00
|
|
|
#endif /* __VBOOT_VBOOT_COMMON_H__ */
|