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