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