Daisuke Nojiri | 742fc8d | 2014-10-10 10:51:06 -0700 | [diff] [blame] | 1 | /* |
| 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 Nojiri | 742fc8d | 2014-10-10 10:51:06 -0700 | [diff] [blame] | 14 | */ |
| 15 | #ifndef VBOOT_COMMON_H |
| 16 | #define VBOOT_COMMON_H |
| 17 | |
| 18 | #include <stdint.h> |
Aaron Durbin | dc9f5cd | 2015-09-08 13:34:43 -0500 | [diff] [blame] | 19 | #include <commonlib/region.h> |
Daisuke Nojiri | 742fc8d | 2014-10-10 10:51:06 -0700 | [diff] [blame] | 20 | |
| 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. */ |
| 25 | struct vboot_component_entry { |
| 26 | uint32_t offset; |
| 27 | uint32_t size; |
| 28 | } __attribute__((packed)); |
| 29 | |
| 30 | struct vboot_components { |
| 31 | uint32_t num_components; |
| 32 | struct vboot_component_entry entries[0]; |
| 33 | } __attribute__((packed)); |
| 34 | |
Aaron Durbin | 4e50cdd | 2015-05-15 23:25:46 -0500 | [diff] [blame] | 35 | /* The following functions return 0 on success, < 0 on error. */ |
| 36 | int vboot_named_region_device(const char *name, struct region_device *rdev); |
| 37 | int vboot_region_device(const struct region *reg, struct region_device *rdev); |
Paul Kocialkowski | 115360f | 2015-09-03 11:41:14 +0200 | [diff] [blame] | 38 | int vboot_get_handoff_info(void **addr, uint32_t *size); |
| 39 | |
| 40 | /* The following functions return 1 for true and 0 for false. */ |
| 41 | int vboot_skip_display_init(void); |
| 42 | int vboot_enable_recovery(void); |
| 43 | int vboot_enable_developer(void); |
| 44 | |
Subrata Banik | df13c31 | 2015-09-28 15:12:08 +0530 | [diff] [blame] | 45 | int vboot_recovery_reason(void); |
| 46 | |
Paul Kocialkowski | 115360f | 2015-09-03 11:41:14 +0200 | [diff] [blame] | 47 | void vboot_reboot(void); |
Daisuke Nojiri | 742fc8d | 2014-10-10 10:51:06 -0700 | [diff] [blame] | 48 | |
Aaron Durbin | 87c9fae | 2016-01-22 15:26:04 -0600 | [diff] [blame^] | 49 | /* |
| 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 | */ |
| 53 | int 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 | */ |
| 59 | int 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 | */ |
| 65 | int vboot_platform_is_resuming(void); |
| 66 | |
Aaron Durbin | 588ad7b | 2015-09-29 17:56:59 -0500 | [diff] [blame] | 67 | /* Main logic for verified boot. verstage() is the stage entry point |
| 68 | * while the verstage_main() is just the core logic. */ |
| 69 | void verstage_main(void); |
| 70 | void verstage_mainboard_init(void); |
| 71 | void verstage(void); |
| 72 | |
Daisuke Nojiri | 742fc8d | 2014-10-10 10:51:06 -0700 | [diff] [blame] | 73 | #endif /* VBOOT_COMMON_H */ |