1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Defines data structures and APIs that allow an OS to interact with UEFI
4 * firmware to query information about the device
6 * Copyright (c) 2020, Linaro Limited
9 #if !defined _EFI_TCG2_PROTOCOL_H_
10 #define _EFI_TCG2_PROTOCOL_H_
15 #define EFI_TCG2_PROTOCOL_GUID \
16 EFI_GUID(0x607f766c, 0x7455, 0x42be, 0x93, \
17 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f)
20 #define TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002
21 #define EFI_TCG2_EXTEND_ONLY 0x0000000000000001
22 #define PE_COFF_IMAGE 0x0000000000000010
24 /* Algorithm Registry */
25 #define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x00000001
26 #define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x00000002
27 #define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x00000004
28 #define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x00000008
29 #define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x00000010
31 #define EFI_TCG2_FINAL_EVENTS_TABLE_VERSION 1
33 #define TPM2_EVENT_LOG_SIZE CONFIG_EFI_TCG2_PROTOCOL_EVENTLOG_SIZE
35 typedef u32 efi_tcg_event_log_bitmap;
36 typedef u32 efi_tcg_event_log_format;
37 typedef u32 efi_tcg_event_algorithm_bitmap;
39 struct efi_tcg2_version {
44 struct efi_tcg2_event_header {
51 struct efi_tcg2_event {
53 struct efi_tcg2_event_header header;
57 struct uefi_image_load_event {
58 efi_physical_addr_t image_location_in_memory;
59 u64 image_length_in_memory;
60 u64 image_link_time_address;
61 u64 length_of_device_path;
62 struct efi_device_path device_path[];
65 struct efi_tcg2_boot_service_capability {
67 struct efi_tcg2_version structure_version;
68 struct efi_tcg2_version protocol_version;
69 efi_tcg_event_algorithm_bitmap hash_algorithm_bitmap;
70 efi_tcg_event_log_bitmap supported_event_logs;
73 u16 max_response_size;
75 u32 number_of_pcr_banks;
76 efi_tcg_event_algorithm_bitmap active_pcr_banks;
79 #define boot_service_capability_min \
80 sizeof(struct efi_tcg2_boot_service_capability) - \
81 offsetof(struct efi_tcg2_boot_service_capability, number_of_pcr_banks)
83 #define TCG_EFI_SPEC_ID_EVENT_SIGNATURE_03 "Spec ID Event03"
84 #define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MAJOR_TPM2 2
85 #define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MINOR_TPM2 0
86 #define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_ERRATA_TPM2 2
89 * struct TCG_EfiSpecIdEventAlgorithmSize
91 * @algorithm_id: algorithm defined in enum tpm2_algorithms
92 * @digest_size: size of the algorithm
94 struct tcg_efi_spec_id_event_algorithm_size {
100 * struct TCG_EfiSpecIDEventStruct
102 * @signature: signature, set to Spec ID Event03
103 * @platform_class: class defined in TCG ACPI Specification
104 * Client Common Header.
105 * @spec_version_minor: minor version
106 * @spec_version_major: major version
107 * @spec_version_errata: major version
108 * @uintn_size: size of the efi_uintn_t fields used in various
109 * data structures used in this specification.
110 * 0x01 indicates u32 and 0x02 indicates u64
111 * @number_of_algorithms: hashing algorithms used in this event log
112 * @digest_sizes: array of number_of_algorithms pairs
113 * 1st member defines the algorithm id
114 * 2nd member defines the algorithm size
115 * @vendor_info_size: size in bytes for vendor specific info
116 * @vendor_info: vendor specific info
118 struct tcg_efi_spec_id_event {
121 u8 spec_version_minor;
122 u8 spec_version_major;
125 u32 number_of_algorithms;
126 struct tcg_efi_spec_id_event_algorithm_size digest_sizes[TPM2_NUM_PCR_BANKS];
128 /* U-Boot does not provide any vendor info */
133 * struct tdEFI_TCG2_FINAL_EVENTS_TABLE
134 * @version: version number for this structure
135 * @number_of_events: number of events recorded after invocation of
137 * @event: List of events of type tcg_pcr_event2
139 struct efi_tcg2_final_events_table {
141 u64 number_of_events;
142 struct tcg_pcr_event2 event[];
145 struct efi_tcg2_protocol {
146 efi_status_t (EFIAPI * get_capability)(struct efi_tcg2_protocol *this,
147 struct efi_tcg2_boot_service_capability *capability);
148 efi_status_t (EFIAPI * get_eventlog)(struct efi_tcg2_protocol *this,
149 efi_tcg_event_log_format log_format,
150 u64 *event_log_location, u64 *event_log_last_entry,
151 bool *event_log_truncated);
152 efi_status_t (EFIAPI * hash_log_extend_event)(struct efi_tcg2_protocol *this,
154 efi_physical_addr_t data_to_hash,
155 u64 data_to_hash_len,
156 struct efi_tcg2_event *efi_tcg_event);
157 efi_status_t (EFIAPI * submit_command)(struct efi_tcg2_protocol *this,
158 u32 input_parameter_block_size,
159 u8 *input_parameter_block,
160 u32 output_parameter_block_size,
161 u8 *output_parameter_block);
162 efi_status_t (EFIAPI * get_active_pcr_banks)(struct efi_tcg2_protocol *this,
163 u32 *active_pcr_banks);
164 efi_status_t (EFIAPI * set_active_pcr_banks)(struct efi_tcg2_protocol *this,
165 u32 active_pcr_banks);
166 efi_status_t (EFIAPI * get_result_of_set_active_pcr_banks)(struct efi_tcg2_protocol *this,
167 u32 *operation_present,