Merge tag 'u-boot-atmel-fixes-2021.01-b' of https://gitlab.denx.de/u-boot/custodians...
[platform/kernel/u-boot.git] / include / efi_tcg2.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Defines data structures and APIs that allow an OS to interact with UEFI
4  * firmware to query information about the device
5  *
6  * Copyright (c) 2020, Linaro Limited
7  */
8
9 #if !defined _EFI_TCG2_PROTOCOL_H_
10 #define _EFI_TCG2_PROTOCOL_H_
11
12 #include <tpm-v2.h>
13
14 #define EFI_TCG2_PROTOCOL_GUID \
15         EFI_GUID(0x607f766c, 0x7455, 0x42be, 0x93, \
16                  0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f)
17
18 /* TPMV2 only */
19 #define TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002
20
21 /* Algorithm Registry */
22 #define EFI_TCG2_BOOT_HASH_ALG_SHA1    0x00000001
23 #define EFI_TCG2_BOOT_HASH_ALG_SHA256  0x00000002
24 #define EFI_TCG2_BOOT_HASH_ALG_SHA384  0x00000004
25 #define EFI_TCG2_BOOT_HASH_ALG_SHA512  0x00000008
26 #define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x00000010
27
28 typedef u32 efi_tcg_event_log_bitmap;
29 typedef u32 efi_tcg_event_log_format;
30 typedef u32 efi_tcg_event_algorithm_bitmap;
31
32 struct efi_tcg2_version {
33         u8 major;
34         u8 minor;
35 };
36
37 struct efi_tcg2_event_header {
38         u32 header_size;
39         u16 header_version;
40         u32 pcr_index;
41         u32 event_type;
42 } __packed;
43
44 struct efi_tcg2_event {
45         u32 size;
46         struct efi_tcg2_event_header header;
47         u8 event[];
48 } __packed;
49
50 struct efi_tcg2_boot_service_capability {
51         u8 size;
52         struct efi_tcg2_version structure_version;
53         struct efi_tcg2_version protocol_version;
54         efi_tcg_event_algorithm_bitmap hash_algorithm_bitmap;
55         efi_tcg_event_log_bitmap supported_event_logs;
56         u8 tpm_present_flag;
57         u16 max_command_size;
58         u16 max_response_size;
59         u32 manufacturer_id;
60         u32 number_of_pcr_banks;
61         efi_tcg_event_algorithm_bitmap active_pcr_banks;
62 };
63
64 #define boot_service_capability_min \
65         sizeof(struct efi_tcg2_boot_service_capability) - \
66         offsetof(struct efi_tcg2_boot_service_capability, number_of_pcr_banks)
67
68 struct efi_tcg2_protocol {
69         efi_status_t (EFIAPI * get_capability)(struct efi_tcg2_protocol *this,
70                                                struct efi_tcg2_boot_service_capability *capability);
71         efi_status_t (EFIAPI * get_eventlog)(struct efi_tcg2_protocol *this,
72                                              efi_tcg_event_log_format log_format,
73                                              u64 *event_log_location, u64 *event_log_last_entry,
74                                              bool *event_log_truncated);
75         efi_status_t (EFIAPI * hash_log_extend_event)(struct efi_tcg2_protocol *this,
76                                                       u64 flags, u64 data_to_hash,
77                                                       u64 data_to_hash_len,
78                                                       struct efi_tcg2_event *efi_tcg_event);
79         efi_status_t (EFIAPI * submit_command)(struct efi_tcg2_protocol *this,
80                                                u32 input_parameter_block_size,
81                                                u8 *input_parameter_block,
82                                                u32 output_parameter_block_size,
83                                                u8 *output_parameter_block);
84         efi_status_t (EFIAPI * get_active_pcr_banks)(struct efi_tcg2_protocol *this,
85                                                      u32 *active_pcr_banks);
86         efi_status_t (EFIAPI * set_active_pcr_banks)(struct efi_tcg2_protocol *this,
87                                                      u32 active_pcr_banks);
88         efi_status_t (EFIAPI * get_result_of_set_active_pcr_banks)(struct efi_tcg2_protocol *this,
89                                                                    u32 *operation_present,
90                                                                    u32 *response);
91 };
92 #endif