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