Aaron Durbin | 6b0d0d6 | 2012-12-14 17:16:21 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Firmware Interface Table support. |
| 3 | * |
| 4 | * Copyright (C) 2012 Google Inc. |
Philipp Deppenwiese | 5ada002 | 2018-11-20 13:54:49 +0100 | [diff] [blame] | 5 | * Copyright (C) 2019 9elements Agency GmbH |
| 6 | * Copyright (C) 2019 Facebook Inc. |
Aaron Durbin | 6b0d0d6 | 2012-12-14 17:16:21 -0600 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; version 2 of the License. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
Aaron Durbin | 6b0d0d6 | 2012-12-14 17:16:21 -0600 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #ifndef __CBFSTOOL_FIT_H |
| 19 | #define __CBFSTOOL_FIT_H |
| 20 | |
Sol Boucher | 32532ac | 2015-05-06 14:44:40 -0700 | [diff] [blame] | 21 | #include "cbfs_image.h" |
| 22 | #include "common.h" |
| 23 | |
Philipp Deppenwiese | 5ada002 | 2018-11-20 13:54:49 +0100 | [diff] [blame] | 24 | /** |
| 25 | * Based on "Intel Trusted Execution Technology (Intel TXT) LAB Handout" and |
| 26 | * https://github.com/slimbootloader/slimbootloader/ |
| 27 | */ |
| 28 | enum fit_type { |
| 29 | FIT_TYPE_HEADER = 0, |
| 30 | FIT_TYPE_MICROCODE = 1, |
| 31 | FIT_TYPE_BIOS_ACM = 2, |
| 32 | FIT_TYPE_BIOS_STARTUP = 7, |
| 33 | FIT_TYPE_TPM_POLICY = 8, |
| 34 | FIT_TYPE_BIOS_POLICY = 9, |
| 35 | FIT_TYPE_TXT_POLICY = 0xa, |
| 36 | FIT_TYPE_KEY_MANIFEST = 0xb, |
| 37 | FIT_TYPE_BOOT_POLICY = 0xc, |
| 38 | FIT_TYPE_CSE_SECURE_BOOT = 0x10, |
| 39 | FIT_TYPE_TXTSX_POLICY = 0x2d, |
| 40 | FIT_TYPE_JMP_DEBUG_POLICY = 0x2f, |
| 41 | FIT_TYPE_UNUSED = 127, |
| 42 | }; |
| 43 | |
Sol Boucher | 32532ac | 2015-05-06 14:44:40 -0700 | [diff] [blame] | 44 | /* |
| 45 | * Converts between offsets from the start of the specified image region and |
| 46 | * "top-aligned" offsets from the top of the entire flash image. Should work in |
| 47 | * both directions: accepts either type of offset and produces the other type. |
| 48 | * The implementation must have some notion of the flash image's total size. |
| 49 | */ |
| 50 | typedef unsigned (*fit_offset_converter_t)(const struct buffer *region, |
| 51 | unsigned offset); |
| 52 | |
Philipp Deppenwiese | 5ada002 | 2018-11-20 13:54:49 +0100 | [diff] [blame] | 53 | struct fit_table; |
| 54 | |
| 55 | struct fit_table *fit_get_table(struct buffer *bootblock, |
| 56 | fit_offset_converter_t offset_fn, |
| 57 | uint32_t topswap_size); |
| 58 | int fit_dump(struct fit_table *fit); |
| 59 | int fit_clear_table(struct fit_table *fit); |
| 60 | int fit_is_supported_type(const enum fit_type type); |
| 61 | int fit_add_entry(struct fit_table *fit, |
| 62 | const uint32_t offset, |
| 63 | const uint32_t len, |
| 64 | const enum fit_type type, |
| 65 | const size_t max_fit_entries); |
| 66 | int fit_delete_entry(struct fit_table *fit, |
| 67 | const size_t idx); |
| 68 | |
| 69 | int fit_add_microcode_file(struct fit_table *fit, |
| 70 | struct cbfs_image *image, |
| 71 | const char *blob_name, |
| 72 | fit_offset_converter_t offset_helper, |
| 73 | const size_t max_fit_entries); |
| 74 | |
Aaron Durbin | 6b0d0d6 | 2012-12-14 17:16:21 -0600 | [diff] [blame] | 75 | #endif |