blob: a658d62ab48ff81703248c25d56bdd406472835c [file] [log] [blame]
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 Google, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -070014 */
15#ifndef VBOOT_COMMON_H
16#define VBOOT_COMMON_H
17
18#include <stdint.h>
Aaron Durbindc9f5cd2015-09-08 13:34:43 -050019#include <commonlib/region.h>
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -070020
21/* The FW areas consist of multiple components. At the beginning of
22 * each area is the number of total compoments as well as the size and
23 * offset for each component. One needs to caculate the total size of the
24 * signed firmware region based off of the embedded metadata. */
25struct vboot_component_entry {
26 uint32_t offset;
27 uint32_t size;
28} __attribute__((packed));
29
30struct vboot_components {
31 uint32_t num_components;
32 struct vboot_component_entry entries[0];
33} __attribute__((packed));
34
Aaron Durbin4e50cdd2015-05-15 23:25:46 -050035/* The following functions return 0 on success, < 0 on error. */
36int vboot_named_region_device(const char *name, struct region_device *rdev);
37int vboot_region_device(const struct region *reg, struct region_device *rdev);
Paul Kocialkowski115360f2015-09-03 11:41:14 +020038int vboot_get_handoff_info(void **addr, uint32_t *size);
39
40/* The following functions return 1 for true and 0 for false. */
41int vboot_skip_display_init(void);
42int vboot_enable_recovery(void);
43int vboot_enable_developer(void);
44
Subrata Banikdf13c312015-09-28 15:12:08 +053045int vboot_recovery_reason(void);
46
Paul Kocialkowski115360f2015-09-03 11:41:14 +020047void vboot_reboot(void);
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -070048
Aaron Durbin87c9fae2016-01-22 15:26:04 -060049/*
50 * Save the provided hash digest to a secure location to check against in
51 * the resume path. Returns 0 on success, < 0 on error.
52 */
53int vboot_save_hash(void *digest, size_t digest_size);
54
55/*
56 * Retrieve the previously saved hash digest. Returns 0 on success,
57 * < 0 on error.
58 */
59int vboot_retrieve_hash(void *digest, size_t digest_size);
60
61/*
62 * Determine if the platform is resuming from suspend. Returns 0 when
63 * not resuming, > 0 if resuming, and < 0 on error.
64 */
65int vboot_platform_is_resuming(void);
66
Aaron Durbin588ad7b2015-09-29 17:56:59 -050067/* Main logic for verified boot. verstage() is the stage entry point
68 * while the verstage_main() is just the core logic. */
69void verstage_main(void);
70void verstage_mainboard_init(void);
71void verstage(void);
72
Daisuke Nojiri742fc8d2014-10-10 10:51:06 -070073#endif /* VBOOT_COMMON_H */