blob: a0c956cac571308febdaef332d46ff6ae91e8d1c [file] [log] [blame]
Patrick Georgiea063cb2020-05-08 19:28:13 +02001/* Firmware Interface Table support */
Patrick Georgi7333a112020-05-08 20:48:04 +02002/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbin6b0d0d62012-12-14 17:16:21 -06003
4#ifndef __CBFSTOOL_FIT_H
5#define __CBFSTOOL_FIT_H
6
Sol Boucher32532ac2015-05-06 14:44:40 -07007#include "cbfs_image.h"
8#include "common.h"
9
Philipp Deppenwiese5ada0022018-11-20 13:54:49 +010010/**
11 * Based on "Intel Trusted Execution Technology (Intel TXT) LAB Handout" and
12 * https://github.com/slimbootloader/slimbootloader/
13 */
14enum 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 Boucher32532ac2015-05-06 14:44:40 -070030/*
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 */
36typedef unsigned (*fit_offset_converter_t)(const struct buffer *region,
37 unsigned offset);
38
Philipp Deppenwiese5ada0022018-11-20 13:54:49 +010039struct fit_table;
40
41struct fit_table *fit_get_table(struct buffer *bootblock,
42 fit_offset_converter_t offset_fn,
43 uint32_t topswap_size);
44int fit_dump(struct fit_table *fit);
45int fit_clear_table(struct fit_table *fit);
46int fit_is_supported_type(const enum fit_type type);
47int 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);
52int fit_delete_entry(struct fit_table *fit,
53 const size_t idx);
54
55int 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 Heymanse9e4e542021-02-17 17:34:44 +010060int set_fit_pointer(struct buffer *bootblock, const uint32_t offset,
61 fit_offset_converter_t offset_fn, uint32_t topswap_size);
Aaron Durbin6b0d0d62012-12-14 17:16:21 -060062#endif