1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#if !defined _EFI_TCG2_PROTOCOL_H_
17#define _EFI_TCG2_PROTOCOL_H_
18
19#include <efi_api.h>
20#include <tpm-v2.h>
21
22#define EFI_TCG2_PROTOCOL_GUID \
23 EFI_GUID(0x607f766c, 0x7455, 0x42be, 0x93, \
24 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f)
25
26
27#define TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002
28#define EFI_TCG2_EXTEND_ONLY 0x0000000000000001
29#define PE_COFF_IMAGE 0x0000000000000010
30
31#define EFI_TCG2_MAX_PCR_INDEX 23
32
33
34#define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x00000001
35#define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x00000002
36#define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x00000004
37#define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x00000008
38#define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x00000010
39
40#define EFI_TCG2_FINAL_EVENTS_TABLE_VERSION 1
41
42#define TPM2_EVENT_LOG_SIZE CONFIG_EFI_TCG2_PROTOCOL_EVENTLOG_SIZE
43
44typedef u32 efi_tcg_event_log_bitmap;
45typedef u32 efi_tcg_event_log_format;
46typedef u32 efi_tcg_event_algorithm_bitmap;
47
48
49
50
51
52
53struct efi_tcg2_version {
54 u8 major;
55 u8 minor;
56};
57
58
59
60
61
62
63
64
65struct efi_tcg2_event_header {
66 u32 header_size;
67 u16 header_version;
68 u32 pcr_index;
69 u32 event_type;
70} __packed;
71
72
73
74
75
76
77
78
79struct efi_tcg2_event {
80 u32 size;
81 struct efi_tcg2_event_header header;
82 u8 event[];
83} __packed;
84
85
86
87
88
89
90
91
92
93struct uefi_image_load_event {
94 efi_physical_addr_t image_location_in_memory;
95 u64 image_length_in_memory;
96 u64 image_link_time_address;
97 u64 length_of_device_path;
98 struct efi_device_path device_path[];
99};
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118struct efi_tcg2_boot_service_capability {
119 u8 size;
120 struct efi_tcg2_version structure_version;
121 struct efi_tcg2_version protocol_version;
122 efi_tcg_event_algorithm_bitmap hash_algorithm_bitmap;
123 efi_tcg_event_log_bitmap supported_event_logs;
124 u8 tpm_present_flag;
125 u16 max_command_size;
126 u16 max_response_size;
127 u32 manufacturer_id;
128 u32 number_of_pcr_banks;
129 efi_tcg_event_algorithm_bitmap active_pcr_banks;
130};
131
132
133#define BOOT_SERVICE_CAPABILITY_MIN \
134 offsetof(struct efi_tcg2_boot_service_capability, number_of_pcr_banks)
135
136#define TCG_EFI_SPEC_ID_EVENT_SIGNATURE_03 "Spec ID Event03"
137#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MAJOR_TPM2 2
138#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MINOR_TPM2 0
139#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_ERRATA_TPM2 2
140
141
142
143
144
145
146
147struct tcg_efi_spec_id_event_algorithm_size {
148 u16 algorithm_id;
149 u16 digest_size;
150} __packed;
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169struct tcg_efi_spec_id_event {
170 u8 signature[16];
171 u32 platform_class;
172 u8 spec_version_minor;
173 u8 spec_version_major;
174 u8 spec_errata;
175 u8 uintn_size;
176 u32 number_of_algorithms;
177 struct tcg_efi_spec_id_event_algorithm_size digest_sizes[];
178} __packed;
179
180
181
182
183
184
185
186
187struct efi_tcg2_final_events_table {
188 u64 version;
189 u64 number_of_events;
190 struct tcg_pcr_event2 event[];
191};
192
193
194
195
196
197
198
199
200
201
202
203
204
205struct efi_tcg2_uefi_variable_data {
206 efi_guid_t variable_name;
207 u64 unicode_name_length;
208 u64 variable_data_length;
209 u16 unicode_name[1];
210 u8 variable_data[1];
211};
212
213
214
215
216
217
218
219
220#define SMBIOS_HANDOFF_TABLE_DESC "SmbiosTable"
221struct smbios_handoff_table_pointers2 {
222 u8 table_description_size;
223 u8 table_description[sizeof(SMBIOS_HANDOFF_TABLE_DESC)];
224 u64 number_of_tables;
225 struct efi_configuration_table table_entry[];
226} __packed;
227
228
229
230
231
232
233
234struct efi_gpt_data {
235 gpt_header uefi_partition_header;
236 u64 number_of_partitions;
237 gpt_entry partitions[];
238} __packed;
239
240struct efi_tcg2_protocol {
241 efi_status_t (EFIAPI * get_capability)(struct efi_tcg2_protocol *this,
242 struct efi_tcg2_boot_service_capability *capability);
243 efi_status_t (EFIAPI * get_eventlog)(struct efi_tcg2_protocol *this,
244 efi_tcg_event_log_format log_format,
245 u64 *event_log_location, u64 *event_log_last_entry,
246 bool *event_log_truncated);
247 efi_status_t (EFIAPI * hash_log_extend_event)(struct efi_tcg2_protocol *this,
248 u64 flags,
249 efi_physical_addr_t data_to_hash,
250 u64 data_to_hash_len,
251 struct efi_tcg2_event *efi_tcg_event);
252 efi_status_t (EFIAPI * submit_command)(struct efi_tcg2_protocol *this,
253 u32 input_parameter_block_size,
254 u8 *input_parameter_block,
255 u32 output_parameter_block_size,
256 u8 *output_parameter_block);
257 efi_status_t (EFIAPI * get_active_pcr_banks)(struct efi_tcg2_protocol *this,
258 u32 *active_pcr_banks);
259 efi_status_t (EFIAPI * set_active_pcr_banks)(struct efi_tcg2_protocol *this,
260 u32 active_pcr_banks);
261 efi_status_t (EFIAPI * get_result_of_set_active_pcr_banks)(struct efi_tcg2_protocol *this,
262 u32 *operation_present,
263 u32 *response);
264};
265#endif
266