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_
14 #define EFI_TCG2_PROTOCOL_GUID \
15 EFI_GUID(0x607f766c, 0x7455, 0x42be, 0x93, \
16 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f)
19 #define TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002
20 #define EFI_TCG2_EXTEND_ONLY 0x0000000000000001
21 #define PE_COFF_IMAGE 0x0000000000000010
23 /* Algorithm Registry */
24 #define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x00000001
25 #define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x00000002
26 #define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x00000004
27 #define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x00000008
28 #define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x00000010
30 #define EFI_TCG2_FINAL_EVENTS_TABLE_VERSION 1
32 #define TPM2_EVENT_LOG_SIZE CONFIG_EFI_TCG2_PROTOCOL_EVENTLOG_SIZE
34 typedef u32 efi_tcg_event_log_bitmap;
35 typedef u32 efi_tcg_event_log_format;
36 typedef u32 efi_tcg_event_algorithm_bitmap;
38 struct efi_tcg2_version {
43 struct efi_tcg2_event_header {
50 struct efi_tcg2_event {
52 struct efi_tcg2_event_header header;
56 struct efi_tcg2_boot_service_capability {
58 struct efi_tcg2_version structure_version;
59 struct efi_tcg2_version protocol_version;
60 efi_tcg_event_algorithm_bitmap hash_algorithm_bitmap;
61 efi_tcg_event_log_bitmap supported_event_logs;
64 u16 max_response_size;
66 u32 number_of_pcr_banks;
67 efi_tcg_event_algorithm_bitmap active_pcr_banks;
70 #define boot_service_capability_min \
71 sizeof(struct efi_tcg2_boot_service_capability) - \
72 offsetof(struct efi_tcg2_boot_service_capability, number_of_pcr_banks)
74 #define TCG_EFI_SPEC_ID_EVENT_SIGNATURE_03 "Spec ID Event03"
75 #define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MAJOR_TPM2 2
76 #define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MINOR_TPM2 0
77 #define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_ERRATA_TPM2 2
80 * struct TCG_EfiSpecIdEventAlgorithmSize
82 * @algorithm_id: algorithm defined in enum tpm2_algorithms
83 * @digest_size: size of the algorithm
85 struct tcg_efi_spec_id_event_algorithm_size {
91 * struct TCG_EfiSpecIDEventStruct
93 * @signature: signature, set to Spec ID Event03
94 * @platform_class: class defined in TCG ACPI Specification
95 * Client Common Header.
96 * @spec_version_minor: minor version
97 * @spec_version_major: major version
98 * @spec_version_errata: major version
99 * @uintn_size: size of the efi_uintn_t fields used in various
100 * data structures used in this specification.
101 * 0x01 indicates u32 and 0x02 indicates u64
102 * @number_of_algorithms: hashing algorithms used in this event log
103 * @digest_sizes: array of number_of_algorithms pairs
104 * 1st member defines the algorithm id
105 * 2nd member defines the algorithm size
106 * @vendor_info_size: size in bytes for vendor specific info
107 * @vendor_info: vendor specific info
109 struct tcg_efi_spec_id_event {
112 u8 spec_version_minor;
113 u8 spec_version_major;
116 u32 number_of_algorithms;
117 struct tcg_efi_spec_id_event_algorithm_size digest_sizes[TPM2_NUM_PCR_BANKS];
119 /* U-Boot does not provide any vendor info */
124 * struct tdEFI_TCG2_FINAL_EVENTS_TABLE
125 * @version: version number for this structure
126 * @number_of_events: number of events recorded after invocation of
128 * @event: List of events of type tcg_pcr_event2
130 struct efi_tcg2_final_events_table {
132 u64 number_of_events;
133 struct tcg_pcr_event2 event[];
136 struct efi_tcg2_protocol {
137 efi_status_t (EFIAPI * get_capability)(struct efi_tcg2_protocol *this,
138 struct efi_tcg2_boot_service_capability *capability);
139 efi_status_t (EFIAPI * get_eventlog)(struct efi_tcg2_protocol *this,
140 efi_tcg_event_log_format log_format,
141 u64 *event_log_location, u64 *event_log_last_entry,
142 bool *event_log_truncated);
143 efi_status_t (EFIAPI * hash_log_extend_event)(struct efi_tcg2_protocol *this,
145 efi_physical_addr_t data_to_hash,
146 u64 data_to_hash_len,
147 struct efi_tcg2_event *efi_tcg_event);
148 efi_status_t (EFIAPI * submit_command)(struct efi_tcg2_protocol *this,
149 u32 input_parameter_block_size,
150 u8 *input_parameter_block,
151 u32 output_parameter_block_size,
152 u8 *output_parameter_block);
153 efi_status_t (EFIAPI * get_active_pcr_banks)(struct efi_tcg2_protocol *this,
154 u32 *active_pcr_banks);
155 efi_status_t (EFIAPI * set_active_pcr_banks)(struct efi_tcg2_protocol *this,
156 u32 active_pcr_banks);
157 efi_status_t (EFIAPI * get_result_of_set_active_pcr_banks)(struct efi_tcg2_protocol *this,
158 u32 *operation_present,