]>
Commit | Line | Data |
---|---|---|
2e61fb38 | 1 | /** @file\r |
e3917fc7 | 2 | This protocol is defined to abstract TPM2 hardware access in boot phase.\r |
2e61fb38 | 3 | \r |
9095d37b | 4 | Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r |
9344f092 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
2e61fb38 JY |
6 | \r |
7 | **/\r | |
8 | \r | |
9 | #ifndef __TREE_H__\r | |
10 | #define __TREE_H__\r | |
11 | \r | |
12 | #include <IndustryStandard/UefiTcgPlatform.h>\r | |
13 | #include <IndustryStandard/Tpm20.h>\r | |
14 | \r | |
15 | #define EFI_TREE_PROTOCOL_GUID \\r | |
16 | {0x607f766c, 0x7455, 0x42be, 0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f}\r | |
17 | \r | |
18 | typedef struct _EFI_TREE_PROTOCOL EFI_TREE_PROTOCOL;\r | |
19 | \r | |
20 | typedef struct _TREE_VERSION {\r | |
2f88bd3a MK |
21 | UINT8 Major;\r |
22 | UINT8 Minor;\r | |
2e61fb38 JY |
23 | } TREE_VERSION;\r |
24 | \r | |
25 | typedef UINT32 TREE_EVENT_LOG_BITMAP;\r | |
26 | typedef UINT32 TREE_EVENT_LOG_FORMAT;\r | |
27 | \r | |
2f88bd3a | 28 | #define TREE_EVENT_LOG_FORMAT_TCG_1_2 0x00000001\r |
2e61fb38 JY |
29 | \r |
30 | typedef struct _TREE_BOOT_SERVICE_CAPABILITY {\r | |
31 | //\r | |
9095d37b | 32 | // Allocated size of the structure passed in\r |
2e61fb38 | 33 | //\r |
2f88bd3a | 34 | UINT8 Size;\r |
2e61fb38 JY |
35 | //\r |
36 | // Version of the TREE_BOOT_SERVICE_CAPABILITY structure itself.\r | |
37 | // For this version of the protocol, the Major version shall be set to 1\r | |
9095d37b | 38 | // and the Minor version shall be set to 0.\r |
2e61fb38 | 39 | //\r |
2f88bd3a | 40 | TREE_VERSION StructureVersion;\r |
2e61fb38 JY |
41 | //\r |
42 | // Version of the TrEE protocol.\r | |
43 | // For this version of the protocol, the Major version shall be set to 1\r | |
9095d37b | 44 | // and the Minor version shall be set to 0.\r |
2e61fb38 | 45 | //\r |
2f88bd3a | 46 | TREE_VERSION ProtocolVersion;\r |
2e61fb38 JY |
47 | //\r |
48 | // Supported hash algorithms\r | |
49 | //\r | |
2f88bd3a | 50 | UINT32 HashAlgorithmBitmap;\r |
2e61fb38 JY |
51 | //\r |
52 | // Bitmap of supported event log formats\r | |
53 | //\r | |
2f88bd3a | 54 | TREE_EVENT_LOG_BITMAP SupportedEventLogs;\r |
2e61fb38 | 55 | //\r |
9095d37b | 56 | // False = TrEE not present\r |
2e61fb38 | 57 | //\r |
2f88bd3a | 58 | BOOLEAN TrEEPresentFlag;\r |
2e61fb38 | 59 | //\r |
9095d37b | 60 | // Max size (in bytes) of a command that can be sent to the TrEE\r |
2e61fb38 | 61 | //\r |
2f88bd3a | 62 | UINT16 MaxCommandSize;\r |
2e61fb38 | 63 | //\r |
9095d37b | 64 | // Max size (in bytes) of a response that can be provided by the TrEE\r |
2e61fb38 | 65 | //\r |
2f88bd3a | 66 | UINT16 MaxResponseSize;\r |
2e61fb38 JY |
67 | //\r |
68 | // 4-byte Vendor ID (see Trusted Computing Group, "TCG Vendor ID Registry,"\r | |
9095d37b | 69 | // Version 1.0, Revision 0.1, August 31, 2007, "TPM Capabilities Vendor ID" section)\r |
2e61fb38 | 70 | //\r |
2f88bd3a | 71 | UINT32 ManufacturerID;\r |
2e61fb38 JY |
72 | } TREE_BOOT_SERVICE_CAPABILITY_1_0;\r |
73 | \r | |
74 | typedef TREE_BOOT_SERVICE_CAPABILITY_1_0 TREE_BOOT_SERVICE_CAPABILITY;\r | |
75 | \r | |
2f88bd3a MK |
76 | #define TREE_BOOT_HASH_ALG_SHA1 0x00000001\r |
77 | #define TREE_BOOT_HASH_ALG_SHA256 0x00000002\r | |
78 | #define TREE_BOOT_HASH_ALG_SHA384 0x00000004\r | |
79 | #define TREE_BOOT_HASH_ALG_SHA512 0x00000008\r | |
2e61fb38 JY |
80 | \r |
81 | //\r | |
82 | // This bit is shall be set when an event shall be extended but not logged.\r | |
83 | //\r | |
84 | #define TREE_EXTEND_ONLY 0x0000000000000001\r | |
85 | //\r | |
86 | // This bit shall be set when the intent is to measure a PE/COFF image.\r | |
87 | //\r | |
2f88bd3a | 88 | #define PE_COFF_IMAGE 0x0000000000000010\r |
2e61fb38 | 89 | \r |
2e61fb38 JY |
90 | typedef UINT32 TrEE_PCRINDEX;\r |
91 | typedef UINT32 TrEE_EVENTTYPE;\r | |
92 | \r | |
2f88bd3a | 93 | #define MAX_PCR_INDEX 23\r |
2e61fb38 JY |
94 | #define TREE_EVENT_HEADER_VERSION 1\r |
95 | \r | |
96 | #pragma pack(1)\r | |
97 | \r | |
98 | typedef struct {\r | |
99 | //\r | |
9095d37b | 100 | // Size of the event header itself (sizeof(TrEE_EVENT_HEADER)).\r |
2e61fb38 JY |
101 | //\r |
102 | UINT32 HeaderSize;\r | |
103 | //\r | |
104 | // Header version. For this version of this specification, the value shall be 1.\r | |
105 | //\r | |
106 | UINT16 HeaderVersion;\r | |
107 | //\r | |
9095d37b | 108 | // Index of the PCR that shall be extended (0 - 23).\r |
2e61fb38 JY |
109 | //\r |
110 | TrEE_PCRINDEX PCRIndex;\r | |
111 | //\r | |
9095d37b | 112 | // Type of the event that shall be extended (and optionally logged).\r |
2e61fb38 JY |
113 | //\r |
114 | TrEE_EVENTTYPE EventType;\r | |
115 | } TrEE_EVENT_HEADER;\r | |
116 | \r | |
117 | typedef struct {\r | |
118 | //\r | |
9095d37b | 119 | // Total size of the event including the Size component, the header and the Event data.\r |
2e61fb38 | 120 | //\r |
2f88bd3a MK |
121 | UINT32 Size;\r |
122 | TrEE_EVENT_HEADER Header;\r | |
123 | UINT8 Event[1];\r | |
2e61fb38 JY |
124 | } TrEE_EVENT;\r |
125 | \r | |
126 | #pragma pack()\r | |
127 | \r | |
128 | /**\r | |
129 | The EFI_TREE_PROTOCOL GetCapability function call provides protocol\r | |
130 | capability information and state information about the TrEE.\r | |
131 | \r | |
132 | @param[in] This Indicates the calling context\r | |
133 | @param[out] ProtocolCapability The caller allocates memory for a TREE_BOOT_SERVICE_CAPABILITY\r | |
134 | structure and sets the size field to the size of the structure allocated.\r | |
135 | The callee fills in the fields with the EFI protocol capability information\r | |
136 | and the current TrEE state information up to the number of fields which\r | |
137 | fit within the size of the structure passed in.\r | |
138 | \r | |
139 | @retval EFI_SUCCESS Operation completed successfully.\r | |
140 | @retval EFI_DEVICE_ERROR The command was unsuccessful.\r | |
9095d37b | 141 | The ProtocolCapability variable will not be populated.\r |
2e61fb38 JY |
142 | @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.\r |
143 | The ProtocolCapability variable will not be populated.\r | |
144 | @retval EFI_BUFFER_TOO_SMALL The ProtocolCapability variable is too small to hold the full response.\r | |
9095d37b | 145 | It will be partially populated (required Size field will be set).\r |
2e61fb38 JY |
146 | **/\r |
147 | typedef\r | |
148 | EFI_STATUS\r | |
2f88bd3a | 149 | (EFIAPI *EFI_TREE_GET_CAPABILITY)(\r |
2e61fb38 JY |
150 | IN EFI_TREE_PROTOCOL *This,\r |
151 | IN OUT TREE_BOOT_SERVICE_CAPABILITY *ProtocolCapability\r | |
152 | );\r | |
153 | \r | |
154 | /**\r | |
155 | The EFI_TREE_PROTOCOL Get Event Log function call allows a caller to\r | |
9095d37b | 156 | retrieve the address of a given event log and its last entry.\r |
2e61fb38 JY |
157 | \r |
158 | @param[in] This Indicates the calling context\r | |
159 | @param[in] EventLogFormat The type of the event log for which the information is requested.\r | |
160 | @param[out] EventLogLocation A pointer to the memory address of the event log.\r | |
161 | @param[out] EventLogLastEntry If the Event Log contains more than one entry, this is a pointer to the\r | |
162 | address of the start of the last entry in the event log in memory.\r | |
163 | @param[out] EventLogTruncated If the Event Log is missing at least one entry because an event would\r | |
164 | have exceeded the area allocated for events, this value is set to TRUE.\r | |
165 | Otherwise, the value will be FALSE and the Event Log will be complete.\r | |
166 | \r | |
167 | @retval EFI_SUCCESS Operation completed successfully.\r | |
168 | @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect\r | |
169 | (e.g. asking for an event log whose format is not supported).\r | |
170 | **/\r | |
171 | typedef\r | |
172 | EFI_STATUS\r | |
2f88bd3a | 173 | (EFIAPI *EFI_TREE_GET_EVENT_LOG)(\r |
2e61fb38 JY |
174 | IN EFI_TREE_PROTOCOL *This,\r |
175 | IN TREE_EVENT_LOG_FORMAT EventLogFormat,\r | |
176 | OUT EFI_PHYSICAL_ADDRESS *EventLogLocation,\r | |
177 | OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry,\r | |
178 | OUT BOOLEAN *EventLogTruncated\r | |
179 | );\r | |
180 | \r | |
181 | /**\r | |
182 | The EFI_TREE_PROTOCOL HashLogExtendEvent function call provides callers with\r | |
183 | an opportunity to extend and optionally log events without requiring\r | |
9095d37b | 184 | knowledge of actual TPM commands.\r |
2e61fb38 | 185 | The extend operation will occur even if this function cannot create an event\r |
9095d37b | 186 | log entry (e.g. due to the event log being full).\r |
2e61fb38 JY |
187 | \r |
188 | @param[in] This Indicates the calling context\r | |
189 | @param[in] Flags Bitmap providing additional information.\r | |
9095d37b | 190 | @param[in] DataToHash Physical address of the start of the data buffer to be hashed.\r |
2e61fb38 JY |
191 | @param[in] DataToHashLen The length in bytes of the buffer referenced by DataToHash.\r |
192 | @param[in] Event Pointer to data buffer containing information about the event.\r | |
193 | \r | |
194 | @retval EFI_SUCCESS Operation completed successfully.\r | |
195 | @retval EFI_DEVICE_ERROR The command was unsuccessful.\r | |
196 | @retval EFI_VOLUME_FULL The extend operation occurred, but the event could not be written to one or more event logs.\r | |
197 | @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.\r | |
198 | @retval EFI_UNSUPPORTED The PE/COFF image type is not supported.\r | |
199 | **/\r | |
200 | typedef\r | |
201 | EFI_STATUS\r | |
2f88bd3a | 202 | (EFIAPI *EFI_TREE_HASH_LOG_EXTEND_EVENT)(\r |
2e61fb38 JY |
203 | IN EFI_TREE_PROTOCOL *This,\r |
204 | IN UINT64 Flags,\r | |
205 | IN EFI_PHYSICAL_ADDRESS DataToHash,\r | |
206 | IN UINT64 DataToHashLen,\r | |
207 | IN TrEE_EVENT *Event\r | |
208 | );\r | |
209 | \r | |
210 | /**\r | |
211 | This service enables the sending of commands to the TrEE.\r | |
212 | \r | |
213 | @param[in] This Indicates the calling context\r | |
214 | @param[in] InputParameterBlockSize Size of the TrEE input parameter block.\r | |
215 | @param[in] InputParameterBlock Pointer to the TrEE input parameter block.\r | |
216 | @param[in] OutputParameterBlockSize Size of the TrEE output parameter block.\r | |
217 | @param[in] OutputParameterBlock Pointer to the TrEE output parameter block.\r | |
218 | \r | |
219 | @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.\r | |
220 | @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.\r | |
221 | @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.\r | |
9095d37b | 222 | @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.\r |
2e61fb38 JY |
223 | **/\r |
224 | typedef\r | |
225 | EFI_STATUS\r | |
2f88bd3a | 226 | (EFIAPI *EFI_TREE_SUBMIT_COMMAND)(\r |
2e61fb38 JY |
227 | IN EFI_TREE_PROTOCOL *This,\r |
228 | IN UINT32 InputParameterBlockSize,\r | |
229 | IN UINT8 *InputParameterBlock,\r | |
230 | IN UINT32 OutputParameterBlockSize,\r | |
231 | IN UINT8 *OutputParameterBlock\r | |
232 | );\r | |
233 | \r | |
234 | struct _EFI_TREE_PROTOCOL {\r | |
2f88bd3a MK |
235 | EFI_TREE_GET_CAPABILITY GetCapability;\r |
236 | EFI_TREE_GET_EVENT_LOG GetEventLog;\r | |
237 | EFI_TREE_HASH_LOG_EXTEND_EVENT HashLogExtendEvent;\r | |
238 | EFI_TREE_SUBMIT_COMMAND SubmitCommand;\r | |
2e61fb38 JY |
239 | };\r |
240 | \r | |
2f88bd3a | 241 | extern EFI_GUID gEfiTrEEProtocolGuid;\r |
2e61fb38 JY |
242 | \r |
243 | #endif\r |