Patrick Georgi | ea063cb | 2020-05-08 19:28:13 +0200 | [diff] [blame] | 1 | /* Firmware Interface Table support */ |
Patrick Georgi | 7333a11 | 2020-05-08 20:48:04 +0200 | [diff] [blame] | 2 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | 6b0d0d6 | 2012-12-14 17:16:21 -0600 | [diff] [blame] | 3 | |
| 4 | #ifndef __CBFSTOOL_FIT_H |
| 5 | #define __CBFSTOOL_FIT_H |
| 6 | |
Sol Boucher | 32532ac | 2015-05-06 14:44:40 -0700 | [diff] [blame] | 7 | #include "cbfs_image.h" |
| 8 | #include "common.h" |
| 9 | |
Philipp Deppenwiese | 5ada002 | 2018-11-20 13:54:49 +0100 | [diff] [blame] | 10 | /** |
| 11 | * Based on "Intel Trusted Execution Technology (Intel TXT) LAB Handout" and |
| 12 | * https://github.com/slimbootloader/slimbootloader/ |
| 13 | */ |
| 14 | enum fit_type { |
| 15 | FIT_TYPE_HEADER = 0, |
| 16 | FIT_TYPE_MICROCODE = 1, |
| 17 | FIT_TYPE_BIOS_ACM = 2, |
| 18 | FIT_TYPE_BIOS_STARTUP = 7, |
| 19 | FIT_TYPE_TPM_POLICY = 8, |
| 20 | FIT_TYPE_BIOS_POLICY = 9, |
| 21 | FIT_TYPE_TXT_POLICY = 0xa, |
| 22 | FIT_TYPE_KEY_MANIFEST = 0xb, |
| 23 | FIT_TYPE_BOOT_POLICY = 0xc, |
| 24 | FIT_TYPE_CSE_SECURE_BOOT = 0x10, |
| 25 | FIT_TYPE_TXTSX_POLICY = 0x2d, |
| 26 | FIT_TYPE_JMP_DEBUG_POLICY = 0x2f, |
| 27 | FIT_TYPE_UNUSED = 127, |
| 28 | }; |
| 29 | |
Sol Boucher | 32532ac | 2015-05-06 14:44:40 -0700 | [diff] [blame] | 30 | /* |
| 31 | * Converts between offsets from the start of the specified image region and |
| 32 | * "top-aligned" offsets from the top of the entire flash image. Should work in |
| 33 | * both directions: accepts either type of offset and produces the other type. |
| 34 | * The implementation must have some notion of the flash image's total size. |
| 35 | */ |
| 36 | typedef unsigned (*fit_offset_converter_t)(const struct buffer *region, |
| 37 | unsigned offset); |
| 38 | |
Philipp Deppenwiese | 5ada002 | 2018-11-20 13:54:49 +0100 | [diff] [blame] | 39 | struct fit_table; |
| 40 | |
| 41 | struct fit_table *fit_get_table(struct buffer *bootblock, |
| 42 | fit_offset_converter_t offset_fn, |
| 43 | uint32_t topswap_size); |
| 44 | int fit_dump(struct fit_table *fit); |
| 45 | int fit_clear_table(struct fit_table *fit); |
| 46 | int fit_is_supported_type(const enum fit_type type); |
| 47 | int fit_add_entry(struct fit_table *fit, |
| 48 | const uint32_t offset, |
| 49 | const uint32_t len, |
| 50 | const enum fit_type type, |
| 51 | const size_t max_fit_entries); |
| 52 | int fit_delete_entry(struct fit_table *fit, |
| 53 | const size_t idx); |
| 54 | |
| 55 | int fit_add_microcode_file(struct fit_table *fit, |
| 56 | struct cbfs_image *image, |
| 57 | const char *blob_name, |
| 58 | fit_offset_converter_t offset_helper, |
| 59 | const size_t max_fit_entries); |
Arthur Heymans | e9e4e54 | 2021-02-17 17:34:44 +0100 | [diff] [blame] | 60 | int set_fit_pointer(struct buffer *bootblock, const uint32_t offset, |
| 61 | fit_offset_converter_t offset_fn, uint32_t topswap_size); |
Aaron Durbin | 6b0d0d6 | 2012-12-14 17:16:21 -0600 | [diff] [blame] | 62 | #endif |