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
21 /* SHA1, SHA256, SHA384, SHA512, TPM_ALG_SM3_256 */
22 #define MAX_HASH_COUNT 5
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 typedef u32 efi_tcg_event_log_bitmap;
31 typedef u32 efi_tcg_event_log_format;
32 typedef u32 efi_tcg_event_algorithm_bitmap;
34 struct efi_tcg2_version {
39 struct efi_tcg2_event_header {
46 struct efi_tcg2_event {
48 struct efi_tcg2_event_header header;
52 struct efi_tcg2_boot_service_capability {
54 struct efi_tcg2_version structure_version;
55 struct efi_tcg2_version protocol_version;
56 efi_tcg_event_algorithm_bitmap hash_algorithm_bitmap;
57 efi_tcg_event_log_bitmap supported_event_logs;
60 u16 max_response_size;
62 u32 number_of_pcr_banks;
63 efi_tcg_event_algorithm_bitmap active_pcr_banks;
66 #define boot_service_capability_min \
67 sizeof(struct efi_tcg2_boot_service_capability) - \
68 offsetof(struct efi_tcg2_boot_service_capability, number_of_pcr_banks)
70 struct efi_tcg2_protocol {
71 efi_status_t (EFIAPI * get_capability)(struct efi_tcg2_protocol *this,
72 struct efi_tcg2_boot_service_capability *capability);
73 efi_status_t (EFIAPI * get_eventlog)(struct efi_tcg2_protocol *this,
74 efi_tcg_event_log_format log_format,
75 u64 *event_log_location, u64 *event_log_last_entry,
76 bool *event_log_truncated);
77 efi_status_t (EFIAPI * hash_log_extend_event)(struct efi_tcg2_protocol *this,
78 u64 flags, u64 data_to_hash,
80 struct efi_tcg2_event *efi_tcg_event);
81 efi_status_t (EFIAPI * submit_command)(struct efi_tcg2_protocol *this,
82 u32 input_parameter_block_size,
83 u8 *input_parameter_block,
84 u32 output_parameter_block_size,
85 u8 *output_parameter_block);
86 efi_status_t (EFIAPI * get_active_pcr_banks)(struct efi_tcg2_protocol *this,
87 u32 *active_pcr_banks);
88 efi_status_t (EFIAPI * set_active_pcr_banks)(struct efi_tcg2_protocol *this,
89 u32 active_pcr_banks);
90 efi_status_t (EFIAPI * get_result_of_set_active_pcr_banks)(struct efi_tcg2_protocol *this,
91 u32 *operation_present,