1 /* Firmware Interface Table support */ 2 /* SPDX-License-Identifier: GPL-2.0-only */ 3 4 #ifndef __CBFSTOOL_FIT_H 5 #define __CBFSTOOL_FIT_H 6 7 #include "cbfs_image.h" 8 #include "common.h" 9 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 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 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); 60 int set_fit_pointer(struct buffer *bootblock, const uint32_t offset, 61 fit_offset_converter_t offset_fn, uint32_t topswap_size); 62 #endif 63