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