MdePkg: UefiTcgPlatform.h: Add UEFI_VARIABLE_DATA
[mirror_edk2.git] / MdePkg / Include / IndustryStandard / UefiTcgPlatform.h
CommitLineData
c311f86b 1/** @file\r
267669ba
LG
2 TCG EFI Platform Definition in TCG_EFI_Platform_1_20_Final\r
3\r
6671cd74 4 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
9df063a0 5 This program and the accompanying materials\r
267669ba
LG
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 __UEFI_TCG_PLATFORM_H__\r
22a25d24 16#define __UEFI_TCG_PLATFORM_H__\r
267669ba
LG
17\r
18#include <IndustryStandard/Tpm12.h>\r
59b226d6 19#include <IndustryStandard/Tpm20.h>\r
a979fca9 20#include <Uefi.h>\r
1fd83dd2 21\r
267669ba
LG
22//\r
23// Standard event types\r
24//\r
25#define EV_POST_CODE ((TCG_EVENTTYPE) 0x00000001)\r
59b226d6 26#define EV_NO_ACTION ((TCG_EVENTTYPE) 0x00000003)\r
267669ba
LG
27#define EV_SEPARATOR ((TCG_EVENTTYPE) 0x00000004)\r
28#define EV_S_CRTM_CONTENTS ((TCG_EVENTTYPE) 0x00000007)\r
29#define EV_S_CRTM_VERSION ((TCG_EVENTTYPE) 0x00000008)\r
04a89420 30#define EV_CPU_MICROCODE ((TCG_EVENTTYPE) 0x00000009)\r
f5a859d6 31#define EV_TABLE_OF_DEVICES ((TCG_EVENTTYPE) 0x0000000B)\r
267669ba
LG
32\r
33//\r
34// EFI specific event types\r
35//\r
36#define EV_EFI_EVENT_BASE ((TCG_EVENTTYPE) 0x80000000)\r
37#define EV_EFI_VARIABLE_DRIVER_CONFIG (EV_EFI_EVENT_BASE + 1)\r
38#define EV_EFI_VARIABLE_BOOT (EV_EFI_EVENT_BASE + 2)\r
39#define EV_EFI_BOOT_SERVICES_APPLICATION (EV_EFI_EVENT_BASE + 3)\r
40#define EV_EFI_BOOT_SERVICES_DRIVER (EV_EFI_EVENT_BASE + 4)\r
41#define EV_EFI_RUNTIME_SERVICES_DRIVER (EV_EFI_EVENT_BASE + 5)\r
42#define EV_EFI_GPT_EVENT (EV_EFI_EVENT_BASE + 6)\r
43#define EV_EFI_ACTION (EV_EFI_EVENT_BASE + 7)\r
44#define EV_EFI_PLATFORM_FIRMWARE_BLOB (EV_EFI_EVENT_BASE + 8)\r
45#define EV_EFI_HANDOFF_TABLES (EV_EFI_EVENT_BASE + 9)\r
59b226d6 46#define EV_EFI_VARIABLE_AUTHORITY (EV_EFI_EVENT_BASE + 0xE0)\r
267669ba 47\r
267669ba
LG
48#define EFI_CALLING_EFI_APPLICATION \\r
49 "Calling EFI Application from Boot Option"\r
50#define EFI_RETURNING_FROM_EFI_APPLICATOIN \\r
51 "Returning from EFI Application from Boot Option"\r
52#define EFI_EXIT_BOOT_SERVICES_INVOCATION \\r
53 "Exit Boot Services Invocation"\r
54#define EFI_EXIT_BOOT_SERVICES_FAILED \\r
55 "Exit Boot Services Returned with Failure"\r
56#define EFI_EXIT_BOOT_SERVICES_SUCCEEDED \\r
57 "Exit Boot Services Returned with Success"\r
58\r
2096185d 59\r
60#define EV_POSTCODE_INFO_POST_CODE "POST CODE"\r
61#define POST_CODE_STR_LEN (sizeof(EV_POSTCODE_INFO_POST_CODE) - 1)\r
62\r
63#define EV_POSTCODE_INFO_SMM_CODE "SMM CODE"\r
64#define SMM_CODE_STR_LEN (sizeof(EV_POSTCODE_INFO_SMM_CODE) - 1)\r
65\r
66#define EV_POSTCODE_INFO_ACPI_DATA "ACPI DATA"\r
67#define ACPI_DATA_LEN (sizeof(EV_POSTCODE_INFO_ACPI_DATA) - 1)\r
68\r
69#define EV_POSTCODE_INFO_BIS_CODE "BIS CODE"\r
70#define BIS_CODE_LEN (sizeof(EV_POSTCODE_INFO_BIS_CODE) - 1)\r
71\r
72#define EV_POSTCODE_INFO_UEFI_PI "UEFI PI"\r
73#define UEFI_PI_LEN (sizeof(EV_POSTCODE_INFO_UEFI_PI) - 1)\r
74\r
75#define EV_POSTCODE_INFO_OPROM "Embedded Option ROM"\r
76#define OPROM_LEN (sizeof(EV_POSTCODE_INFO_OPROM) - 1)\r
77\r
59b226d6
JY
78#define FIRMWARE_DEBUGGER_EVENT_STRING "UEFI Debug Mode"\r
79#define FIRMWARE_DEBUGGER_EVENT_STRING_LEN (sizeof(FIRMWARE_DEBUGGER_EVENT_STRING) - 1)\r
80\r
267669ba
LG
81//\r
82// Set structure alignment to 1-byte\r
83//\r
a04ad3f0 84#pragma pack (1)\r
267669ba
LG
85\r
86typedef UINT32 TCG_EVENTTYPE;\r
992f22b9
LG
87typedef TPM_PCRINDEX TCG_PCRINDEX;\r
88typedef TPM_DIGEST TCG_DIGEST;\r
fb5148a0 89///\r
3ed785e9 90/// Event Log Entry Structure Definition\r
fb5148a0 91///\r
267669ba 92typedef struct tdTCG_PCR_EVENT {\r
3ed785e9 93 TCG_PCRINDEX PCRIndex; ///< PCRIndex event extended to\r
94 TCG_EVENTTYPE EventType; ///< TCG EFI event type\r
95 TCG_DIGEST Digest; ///< Value extended into PCRIndex\r
96 UINT32 EventSize; ///< Size of the event data\r
97 UINT8 Event[1]; ///< The event data\r
267669ba
LG
98} TCG_PCR_EVENT;\r
99\r
3ed785e9 100#define TSS_EVENT_DATA_MAX_SIZE 256\r
101\r
fb5148a0 102///\r
103/// TCG_PCR_EVENT_HDR\r
104///\r
267669ba
LG
105typedef struct tdTCG_PCR_EVENT_HDR {\r
106 TCG_PCRINDEX PCRIndex;\r
107 TCG_EVENTTYPE EventType;\r
108 TCG_DIGEST Digest;\r
109 UINT32 EventSize;\r
110} TCG_PCR_EVENT_HDR;\r
111\r
fb5148a0 112///\r
113/// EFI_PLATFORM_FIRMWARE_BLOB\r
114///\r
115/// BlobLength should be of type UINTN but we use UINT64 here\r
116/// because PEI is 32-bit while DXE is 64-bit on x64 platforms\r
117///\r
267669ba
LG
118typedef struct tdEFI_PLATFORM_FIRMWARE_BLOB {\r
119 EFI_PHYSICAL_ADDRESS BlobBase;\r
120 UINT64 BlobLength;\r
121} EFI_PLATFORM_FIRMWARE_BLOB;\r
122\r
fb5148a0 123///\r
124/// EFI_IMAGE_LOAD_EVENT\r
125///\r
126/// This structure is used in EV_EFI_BOOT_SERVICES_APPLICATION,\r
127/// EV_EFI_BOOT_SERVICES_DRIVER and EV_EFI_RUNTIME_SERVICES_DRIVER\r
128///\r
267669ba
LG
129typedef struct tdEFI_IMAGE_LOAD_EVENT {\r
130 EFI_PHYSICAL_ADDRESS ImageLocationInMemory;\r
131 UINTN ImageLengthInMemory;\r
132 UINTN ImageLinkTimeAddress;\r
133 UINTN LengthOfDevicePath;\r
134 EFI_DEVICE_PATH_PROTOCOL DevicePath[1];\r
135} EFI_IMAGE_LOAD_EVENT;\r
136\r
fb5148a0 137///\r
138/// EFI_HANDOFF_TABLE_POINTERS\r
139///\r
140/// This structure is used in EV_EFI_HANDOFF_TABLES event to facilitate\r
141/// the measurement of given configuration tables.\r
142///\r
267669ba 143typedef struct tdEFI_HANDOFF_TABLE_POINTERS {\r
3ed785e9 144 UINTN NumberOfTables;\r
267669ba
LG
145 EFI_CONFIGURATION_TABLE TableEntry[1];\r
146} EFI_HANDOFF_TABLE_POINTERS;\r
147\r
fb5148a0 148///\r
149/// EFI_VARIABLE_DATA\r
150///\r
151/// This structure serves as the header for measuring variables. The name of the\r
152/// variable (in Unicode format) should immediately follow, then the variable\r
153/// data.\r
49945882 154/// This is defined in TCG EFI Platform Spec for TPM1.1 or 1.2 V1.22\r
fb5148a0 155///\r
267669ba
LG
156typedef struct tdEFI_VARIABLE_DATA {\r
157 EFI_GUID VariableName;\r
158 UINTN UnicodeNameLength;\r
159 UINTN VariableDataLength;\r
160 CHAR16 UnicodeName[1];\r
3ed785e9 161 INT8 VariableData[1]; ///< Driver or platform-specific data\r
267669ba
LG
162} EFI_VARIABLE_DATA;\r
163\r
49945882
ZC
164///\r
165/// UEFI_VARIABLE_DATA\r
166///\r
167/// This structure serves as the header for measuring variables. The name of the\r
168/// variable (in Unicode format) should immediately follow, then the variable\r
169/// data.\r
170/// This is defined in TCG PC Client Firmware Profile Spec 00.21\r
171///\r
172typedef struct tdUEFI_VARIABLE_DATA {\r
173 EFI_GUID VariableName;\r
174 UINT64 UnicodeNameLength;\r
175 UINT64 VariableDataLength;\r
176 CHAR16 UnicodeName[1];\r
177 INT8 VariableData[1]; ///< Driver or platform-specific data\r
178} UEFI_VARIABLE_DATA;\r
179\r
59b226d6
JY
180//\r
181// For TrEE1.0 compatibility\r
182//\r
183typedef struct {\r
184 EFI_GUID VariableName;\r
185 UINT64 UnicodeNameLength; // The TCG Definition used UINTN\r
186 UINT64 VariableDataLength; // The TCG Definition used UINTN\r
187 CHAR16 UnicodeName[1];\r
188 INT8 VariableData[1];\r
189} EFI_VARIABLE_DATA_TREE;\r
190\r
267669ba
LG
191typedef struct tdEFI_GPT_DATA {\r
192 EFI_PARTITION_TABLE_HEADER EfiPartitionHeader;\r
193 UINTN NumberOfPartitions; \r
194 EFI_PARTITION_ENTRY Partitions[1];\r
195} EFI_GPT_DATA;\r
196\r
59b226d6
JY
197//\r
198// Crypto Agile Log Entry Format\r
199//\r
200typedef struct tdTCG_PCR_EVENT2 {\r
201 TCG_PCRINDEX PCRIndex;\r
202 TCG_EVENTTYPE EventType;\r
203 TPML_DIGEST_VALUES Digest;\r
204 UINT32 EventSize;\r
205 UINT8 Event[1];\r
206} TCG_PCR_EVENT2;\r
207\r
208//\r
209// Log Header Entry Data\r
210//\r
211typedef struct {\r
212 //\r
213 // TCG defined hashing algorithm ID.\r
214 //\r
215 UINT16 algorithmId;\r
216 //\r
217 // The size of the digest for the respective hashing algorithm.\r
218 //\r
219 UINT16 digestSize;\r
220} TCG_EfiSpecIdEventAlgorithmSize;\r
221\r
222#define TCG_EfiSpecIDEventStruct_SIGNATURE_02 "Spec ID Event02"\r
223#define TCG_EfiSpecIDEventStruct_SIGNATURE_03 "Spec ID Event03"\r
224\r
225#define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MAJOR_TPM12 1\r
226#define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MINOR_TPM12 2\r
227#define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM12 2\r
228\r
229#define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MAJOR_TPM2 2\r
230#define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MINOR_TPM2 0\r
231#define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2 0\r
232\r
233typedef struct {\r
234 UINT8 signature[16];\r
235 //\r
236 // The value for the Platform Class.\r
237 // The enumeration is defined in the TCG ACPI Specification Client Common Header.\r
238 //\r
239 UINT32 platformClass;\r
240 //\r
241 // The TCG EFI Platform Specification minor version number this BIOS supports.\r
242 // Any BIOS supporting version (1.22) MUST set this value to 02h.\r
243 // Any BIOS supporting version (2.0) SHALL set this value to 0x00.\r
244 //\r
245 UINT8 specVersionMinor;\r
246 //\r
247 // The TCG EFI Platform Specification major version number this BIOS supports.\r
248 // Any BIOS supporting version (1.22) MUST set this value to 01h.\r
249 // Any BIOS supporting version (2.0) SHALL set this value to 0x02.\r
250 //\r
251 UINT8 specVersionMajor;\r
252 //\r
253 // The TCG EFI Platform Specification errata for this specification this BIOS supports.\r
254 // Any BIOS supporting version and errata (1.22) MUST set this value to 02h.\r
255 // Any BIOS supporting version and errata (2.0) SHALL set this value to 0x00.\r
256 //\r
257 UINT8 specErrata;\r
258 //\r
259 // Specifies the size of the UINTN fields used in various data structures used in this specification.\r
260 // 0x01 indicates UINT32 and 0x02 indicates UINT64.\r
261 //\r
262 UINT8 uintnSize;\r
263 //\r
264 // This field is added in "Spec ID Event03".\r
265 // The number of hashing algorithms used in this event log (except the first event).\r
266 // All events in this event log use all hashing algorithms defined here.\r
267 //\r
268//UINT32 numberOfAlgorithms;\r
269 //\r
270 // This field is added in "Spec ID Event03".\r
271 // An array of size numberOfAlgorithms of value pairs.\r
272 //\r
273//TCG_EfiSpecIdEventAlgorithmSize digestSize[numberOfAlgorithms];\r
274 //\r
275 // Size in bytes of the VendorInfo field.\r
276 // Maximum value SHALL be FFh bytes.\r
277 //\r
278//UINT8 vendorInfoSize;\r
279 //\r
280 // Provided for use by the BIOS implementer.\r
281 // The value might be used, for example, to provide more detailed information about the specific BIOS such as BIOS revision numbers, etc.\r
282 // The values within this field are not standardized and are implementer-specific.\r
283 // Platform-specific or -unique information SHALL NOT be provided in this field.\r
284 //\r
285//UINT8 vendorInfo[vendorInfoSize];\r
286} TCG_EfiSpecIDEventStruct;\r
287\r
6671cd74
ZC
288\r
289\r
290#define TCG_EfiStartupLocalityEvent_SIGNATURE "StartupLocality"\r
291\r
292\r
293//\r
294// PC Client PTP spec Table 8 Relationship between Locality and Locality Attribute\r
295//\r
296#define LOCALITY_0_INDICATOR 0x01\r
297#define LOCALITY_1_INDICATOR 0x02\r
298#define LOCALITY_2_INDICATOR 0x03\r
299#define LOCALITY_3_INDICATOR 0x04\r
300#define LOCALITY_4_INDICATOR 0x05\r
301\r
302\r
303//\r
304// Startup Locality Event\r
305//\r
306typedef struct tdTCG_EfiStartupLocalityEvent{\r
307 UINT8 Signature[16];\r
308 //\r
309 // The Locality Indicator which sent the TPM2_Startup command\r
310 //\r
311 UINT8 StartupLocality;\r
312} TCG_EfiStartupLocalityEvent;\r
313\r
314\r
267669ba
LG
315//\r
316// Restore original structure alignment\r
317//\r
a04ad3f0 318#pragma pack ()\r
267669ba
LG
319\r
320#endif\r
321\r
322\r