2 TCG EFI Platform Definition in TCG_EFI_Platform_1_20_Final and
3 TCG PC Client Platform Firmware Profile Specification, Revision 1.05
5 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef __UEFI_TCG_PLATFORM_H__
11 #define __UEFI_TCG_PLATFORM_H__
13 #include <IndustryStandard/Tpm12.h>
14 #include <IndustryStandard/Tpm20.h>
18 // Standard event types
20 #define EV_PREBOOT_CERT ((TCG_EVENTTYPE) 0x00000000)
21 #define EV_POST_CODE ((TCG_EVENTTYPE) 0x00000001)
22 #define EV_NO_ACTION ((TCG_EVENTTYPE) 0x00000003)
23 #define EV_SEPARATOR ((TCG_EVENTTYPE) 0x00000004)
24 #define EV_ACTION ((TCG_EVENTTYPE) 0x00000005)
25 #define EV_EVENT_TAG ((TCG_EVENTTYPE) 0x00000006)
26 #define EV_S_CRTM_CONTENTS ((TCG_EVENTTYPE) 0x00000007)
27 #define EV_S_CRTM_VERSION ((TCG_EVENTTYPE) 0x00000008)
28 #define EV_CPU_MICROCODE ((TCG_EVENTTYPE) 0x00000009)
29 #define EV_PLATFORM_CONFIG_FLAGS ((TCG_EVENTTYPE) 0x0000000A)
30 #define EV_TABLE_OF_DEVICES ((TCG_EVENTTYPE) 0x0000000B)
31 #define EV_COMPACT_HASH ((TCG_EVENTTYPE) 0x0000000C)
32 #define EV_NONHOST_CODE ((TCG_EVENTTYPE) 0x0000000F)
33 #define EV_NONHOST_CONFIG ((TCG_EVENTTYPE) 0x00000010)
34 #define EV_NONHOST_INFO ((TCG_EVENTTYPE) 0x00000011)
35 #define EV_OMIT_BOOT_DEVICE_EVENTS ((TCG_EVENTTYPE) 0x00000012)
38 // EFI specific event types
40 #define EV_EFI_EVENT_BASE ((TCG_EVENTTYPE) 0x80000000)
41 #define EV_EFI_VARIABLE_DRIVER_CONFIG (EV_EFI_EVENT_BASE + 1)
42 #define EV_EFI_VARIABLE_BOOT (EV_EFI_EVENT_BASE + 2)
43 #define EV_EFI_BOOT_SERVICES_APPLICATION (EV_EFI_EVENT_BASE + 3)
44 #define EV_EFI_BOOT_SERVICES_DRIVER (EV_EFI_EVENT_BASE + 4)
45 #define EV_EFI_RUNTIME_SERVICES_DRIVER (EV_EFI_EVENT_BASE + 5)
46 #define EV_EFI_GPT_EVENT (EV_EFI_EVENT_BASE + 6)
47 #define EV_EFI_ACTION (EV_EFI_EVENT_BASE + 7)
48 #define EV_EFI_PLATFORM_FIRMWARE_BLOB (EV_EFI_EVENT_BASE + 8)
49 #define EV_EFI_HANDOFF_TABLES (EV_EFI_EVENT_BASE + 9)
50 #define EV_EFI_PLATFORM_FIRMWARE_BLOB2 (EV_EFI_EVENT_BASE + 0xA)
51 #define EV_EFI_HANDOFF_TABLES2 (EV_EFI_EVENT_BASE + 0xB)
52 #define EV_EFI_HCRTM_EVENT (EV_EFI_EVENT_BASE + 0x10)
53 #define EV_EFI_VARIABLE_AUTHORITY (EV_EFI_EVENT_BASE + 0xE0)
54 #define EV_EFI_SPDM_FIRMWARE_BLOB (EV_EFI_EVENT_BASE + 0xE1)
55 #define EV_EFI_SPDM_FIRMWARE_CONFIG (EV_EFI_EVENT_BASE + 0xE2)
57 #define EFI_CALLING_EFI_APPLICATION \
58 "Calling EFI Application from Boot Option"
59 #define EFI_RETURNING_FROM_EFI_APPLICATION \
60 "Returning from EFI Application from Boot Option"
61 #define EFI_EXIT_BOOT_SERVICES_INVOCATION \
62 "Exit Boot Services Invocation"
63 #define EFI_EXIT_BOOT_SERVICES_FAILED \
64 "Exit Boot Services Returned with Failure"
65 #define EFI_EXIT_BOOT_SERVICES_SUCCEEDED \
66 "Exit Boot Services Returned with Success"
69 #define EV_POSTCODE_INFO_POST_CODE "POST CODE"
70 #define POST_CODE_STR_LEN (sizeof(EV_POSTCODE_INFO_POST_CODE) - 1)
72 #define EV_POSTCODE_INFO_SMM_CODE "SMM CODE"
73 #define SMM_CODE_STR_LEN (sizeof(EV_POSTCODE_INFO_SMM_CODE) - 1)
75 #define EV_POSTCODE_INFO_ACPI_DATA "ACPI DATA"
76 #define ACPI_DATA_LEN (sizeof(EV_POSTCODE_INFO_ACPI_DATA) - 1)
78 #define EV_POSTCODE_INFO_BIS_CODE "BIS CODE"
79 #define BIS_CODE_LEN (sizeof(EV_POSTCODE_INFO_BIS_CODE) - 1)
81 #define EV_POSTCODE_INFO_UEFI_PI "UEFI PI"
82 #define UEFI_PI_LEN (sizeof(EV_POSTCODE_INFO_UEFI_PI) - 1)
84 #define EV_POSTCODE_INFO_OPROM "Embedded Option ROM"
85 #define OPROM_LEN (sizeof(EV_POSTCODE_INFO_OPROM) - 1)
87 #define EV_POSTCODE_INFO_EMBEDDED_UEFI_DRIVER "Embedded UEFI Driver"
88 #define EMBEDDED_UEFI_DRIVER_LEN (sizeof(EV_POSTCODE_INFO_EMBEDDED_UEFI_DRIVER) - 1)
90 #define FIRMWARE_DEBUGGER_EVENT_STRING "UEFI Debug Mode"
91 #define FIRMWARE_DEBUGGER_EVENT_STRING_LEN (sizeof(FIRMWARE_DEBUGGER_EVENT_STRING) - 1)
94 // Set structure alignment to 1-byte
98 typedef UINT32 TCG_EVENTTYPE
;
99 typedef TPM_PCRINDEX TCG_PCRINDEX
;
100 typedef TPM_DIGEST TCG_DIGEST
;
102 /// Event Log Entry Structure Definition
104 typedef struct tdTCG_PCR_EVENT
{
105 TCG_PCRINDEX PCRIndex
; ///< PCRIndex event extended to
106 TCG_EVENTTYPE EventType
; ///< TCG EFI event type
107 TCG_DIGEST Digest
; ///< Value extended into PCRIndex
108 UINT32 EventSize
; ///< Size of the event data
109 UINT8 Event
[1]; ///< The event data
112 #define TSS_EVENT_DATA_MAX_SIZE 256
115 /// TCG_PCR_EVENT_HDR
117 typedef struct tdTCG_PCR_EVENT_HDR
{
118 TCG_PCRINDEX PCRIndex
;
119 TCG_EVENTTYPE EventType
;
125 /// EFI_PLATFORM_FIRMWARE_BLOB
127 /// BlobLength should be of type UINTN but we use UINT64 here
128 /// because PEI is 32-bit while DXE is 64-bit on x64 platforms
130 typedef struct tdEFI_PLATFORM_FIRMWARE_BLOB
{
131 EFI_PHYSICAL_ADDRESS BlobBase
;
133 } EFI_PLATFORM_FIRMWARE_BLOB
;
136 /// UEFI_PLATFORM_FIRMWARE_BLOB
138 /// This structure is used in EV_EFI_PLATFORM_FIRMWARE_BLOB
139 /// event to facilitate the measurement of firmware volume.
141 typedef struct tdUEFI_PLATFORM_FIRMWARE_BLOB
{
142 EFI_PHYSICAL_ADDRESS BlobBase
;
144 } UEFI_PLATFORM_FIRMWARE_BLOB
;
147 /// UEFI_PLATFORM_FIRMWARE_BLOB2
149 /// This structure is used in EV_EFI_PLATFORM_FIRMWARE_BLOB2
150 /// event to facilitate the measurement of firmware volume.
152 typedef struct tdUEFI_PLATFORM_FIRMWARE_BLOB2
{
153 UINT8 BlobDescriptionSize
;
154 //UINT8 BlobDescription[BlobDescriptionSize];
155 //EFI_PHYSICAL_ADDRESS BlobBase;
157 } UEFI_PLATFORM_FIRMWARE_BLOB2
;
160 /// EFI_IMAGE_LOAD_EVENT
162 /// This structure is used in EV_EFI_BOOT_SERVICES_APPLICATION,
163 /// EV_EFI_BOOT_SERVICES_DRIVER and EV_EFI_RUNTIME_SERVICES_DRIVER
165 typedef struct tdEFI_IMAGE_LOAD_EVENT
{
166 EFI_PHYSICAL_ADDRESS ImageLocationInMemory
;
167 UINTN ImageLengthInMemory
;
168 UINTN ImageLinkTimeAddress
;
169 UINTN LengthOfDevicePath
;
170 EFI_DEVICE_PATH_PROTOCOL DevicePath
[1];
171 } EFI_IMAGE_LOAD_EVENT
;
174 /// UEFI_IMAGE_LOAD_EVENT
176 /// This structure is used in EV_EFI_BOOT_SERVICES_APPLICATION,
177 /// EV_EFI_BOOT_SERVICES_DRIVER and EV_EFI_RUNTIME_SERVICES_DRIVER
179 typedef struct tdUEFI_IMAGE_LOAD_EVENT
{
180 EFI_PHYSICAL_ADDRESS ImageLocationInMemory
;
181 UINT64 ImageLengthInMemory
;
182 UINT64 ImageLinkTimeAddress
;
183 UINT64 LengthOfDevicePath
;
184 EFI_DEVICE_PATH_PROTOCOL DevicePath
[1];
185 } UEFI_IMAGE_LOAD_EVENT
;
188 /// EFI_HANDOFF_TABLE_POINTERS
190 /// This structure is used in EV_EFI_HANDOFF_TABLES event to facilitate
191 /// the measurement of given configuration tables.
193 typedef struct tdEFI_HANDOFF_TABLE_POINTERS
{
194 UINTN NumberOfTables
;
195 EFI_CONFIGURATION_TABLE TableEntry
[1];
196 } EFI_HANDOFF_TABLE_POINTERS
;
199 /// UEFI_HANDOFF_TABLE_POINTERS
201 /// This structure is used in EV_EFI_HANDOFF_TABLES event to facilitate
202 /// the measurement of given configuration tables.
204 typedef struct tdUEFI_HANDOFF_TABLE_POINTERS
{
205 UINT64 NumberOfTables
;
206 EFI_CONFIGURATION_TABLE TableEntry
[1];
207 } UEFI_HANDOFF_TABLE_POINTERS
;
210 /// UEFI_HANDOFF_TABLE_POINTERS2
212 /// This structure is used in EV_EFI_HANDOFF_TABLES2 event to facilitate
213 /// the measurement of given configuration tables.
215 typedef struct tdUEFI_HANDOFF_TABLE_POINTERS2
{
216 UINT8 TableDescriptionSize
;
217 //UINT8 TableDescription[TableDescriptionSize];
218 //UINT64 NumberOfTables;
219 //EFI_CONFIGURATION_TABLE TableEntry[1];
220 } UEFI_HANDOFF_TABLE_POINTERS2
;
223 /// EFI_VARIABLE_DATA
225 /// This structure serves as the header for measuring variables. The name of the
226 /// variable (in Unicode format) should immediately follow, then the variable
228 /// This is defined in TCG EFI Platform Spec for TPM1.1 or 1.2 V1.22
230 typedef struct tdEFI_VARIABLE_DATA
{
231 EFI_GUID VariableName
;
232 UINTN UnicodeNameLength
;
233 UINTN VariableDataLength
;
234 CHAR16 UnicodeName
[1];
235 INT8 VariableData
[1]; ///< Driver or platform-specific data
239 /// UEFI_VARIABLE_DATA
241 /// This structure serves as the header for measuring variables. The name of the
242 /// variable (in Unicode format) should immediately follow, then the variable
244 /// This is defined in TCG PC Client Firmware Profile Spec 00.21
246 typedef struct tdUEFI_VARIABLE_DATA
{
247 EFI_GUID VariableName
;
248 UINT64 UnicodeNameLength
;
249 UINT64 VariableDataLength
;
250 CHAR16 UnicodeName
[1];
251 INT8 VariableData
[1]; ///< Driver or platform-specific data
252 } UEFI_VARIABLE_DATA
;
255 // For TrEE1.0 compatibility
258 EFI_GUID VariableName
;
259 UINT64 UnicodeNameLength
; // The TCG Definition used UINTN
260 UINT64 VariableDataLength
; // The TCG Definition used UINTN
261 CHAR16 UnicodeName
[1];
262 INT8 VariableData
[1];
263 } EFI_VARIABLE_DATA_TREE
;
265 typedef struct tdEFI_GPT_DATA
{
266 EFI_PARTITION_TABLE_HEADER EfiPartitionHeader
;
267 UINTN NumberOfPartitions
;
268 EFI_PARTITION_ENTRY Partitions
[1];
271 typedef struct tdUEFI_GPT_DATA
{
272 EFI_PARTITION_TABLE_HEADER EfiPartitionHeader
;
273 UINT64 NumberOfPartitions
;
274 EFI_PARTITION_ENTRY Partitions
[1];
277 #define TCG_DEVICE_SECURITY_EVENT_DATA_SIGNATURE "SPDM Device Sec"
278 #define TCG_DEVICE_SECURITY_EVENT_DATA_VERSION 0
280 #define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_TYPE_NULL 0
281 #define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_TYPE_PCI 1
282 #define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_TYPE_USB 2
285 /// TCG_DEVICE_SECURITY_EVENT_DATA_HEADER
286 /// This is the header of TCG_DEVICE_SECURITY_EVENT_DATA, which is
287 /// used in EV_EFI_SPDM_FIRMWARE_BLOB and EV_EFI_SPDM_FIRMWARE_CONFIG.
295 //SPDM_MEASUREMENT_BLOCK SpdmMeasurementBlock;
296 } TCG_DEVICE_SECURITY_EVENT_DATA_HEADER
;
298 #define TCG_DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT_VERSION 0
301 /// TCG_DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT
302 /// This is the PCI context data of TCG_DEVICE_SECURITY_EVENT_DATA, which is
303 /// used in EV_EFI_SPDM_FIRMWARE_BLOB and EV_EFI_SPDM_FIRMWARE_CONFIG.
312 UINT16 SubsystemVendorID
;
314 } TCG_DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT
;
316 #define TCG_DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT_VERSION 0
319 /// TCG_DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT
320 /// This is the USB context data of TCG_DEVICE_SECURITY_EVENT_DATA, which is
321 /// used in EV_EFI_SPDM_FIRMWARE_BLOB and EV_EFI_SPDM_FIRMWARE_CONFIG.
326 //UINT8 DeviceDescriptor[DescLen];
327 //UINT8 BodDescriptor[DescLen];
328 //UINT8 ConfigurationDescriptor[DescLen][NumOfConfiguration];
329 } TCG_DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT
;
332 // Crypto Agile Log Entry Format
334 typedef struct tdTCG_PCR_EVENT2
{
335 TCG_PCRINDEX PCRIndex
;
336 TCG_EVENTTYPE EventType
;
337 TPML_DIGEST_VALUES Digest
;
343 // TCG PCR Event2 Header
344 // Follow TCG EFI Protocol Spec 5.2 Crypto Agile Log Entry Format
346 typedef struct tdTCG_PCR_EVENT2_HDR
{
347 TCG_PCRINDEX PCRIndex
;
348 TCG_EVENTTYPE EventType
;
349 TPML_DIGEST_VALUES Digests
;
351 } TCG_PCR_EVENT2_HDR
;
354 // Log Header Entry Data
358 // TCG defined hashing algorithm ID.
362 // The size of the digest for the respective hashing algorithm.
365 } TCG_EfiSpecIdEventAlgorithmSize
;
367 #define TCG_EfiSpecIDEventStruct_SIGNATURE_02 "Spec ID Event02"
368 #define TCG_EfiSpecIDEventStruct_SIGNATURE_03 "Spec ID Event03"
370 #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MAJOR_TPM12 1
371 #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MINOR_TPM12 2
372 #define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM12 2
374 #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MAJOR_TPM2 2
375 #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MINOR_TPM2 0
376 #define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2 0
377 #define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2_REV_105 105
382 // The value for the Platform Class.
383 // The enumeration is defined in the TCG ACPI Specification Client Common Header.
385 UINT32 platformClass
;
387 // The TCG EFI Platform Specification minor version number this BIOS supports.
388 // Any BIOS supporting version (1.22) MUST set this value to 02h.
389 // Any BIOS supporting version (2.0) SHALL set this value to 0x00.
391 UINT8 specVersionMinor
;
393 // The TCG EFI Platform Specification major version number this BIOS supports.
394 // Any BIOS supporting version (1.22) MUST set this value to 01h.
395 // Any BIOS supporting version (2.0) SHALL set this value to 0x02.
397 UINT8 specVersionMajor
;
399 // The TCG EFI Platform Specification errata for this specification this BIOS supports.
400 // Any BIOS supporting version and errata (1.22) MUST set this value to 02h.
401 // Any BIOS supporting version and errata (2.0) SHALL set this value to 0x00.
405 // Specifies the size of the UINTN fields used in various data structures used in this specification.
406 // 0x01 indicates UINT32 and 0x02 indicates UINT64.
410 // This field is added in "Spec ID Event03".
411 // The number of hashing algorithms used in this event log (except the first event).
412 // All events in this event log use all hashing algorithms defined here.
414 //UINT32 numberOfAlgorithms;
416 // This field is added in "Spec ID Event03".
417 // An array of size numberOfAlgorithms of value pairs.
419 //TCG_EfiSpecIdEventAlgorithmSize digestSize[numberOfAlgorithms];
421 // Size in bytes of the VendorInfo field.
422 // Maximum value SHALL be FFh bytes.
424 //UINT8 vendorInfoSize;
426 // Provided for use by the BIOS implementer.
427 // The value might be used, for example, to provide more detailed information about the specific BIOS such as BIOS revision numbers, etc.
428 // The values within this field are not standardized and are implementer-specific.
429 // Platform-specific or -unique information SHALL NOT be provided in this field.
431 //UINT8 vendorInfo[vendorInfoSize];
432 } TCG_EfiSpecIDEventStruct
;
434 typedef struct tdTCG_PCClientTaggedEvent
{
435 UINT32 taggedEventID
;
436 UINT32 taggedEventDataSize
;
437 //UINT8 taggedEventData[taggedEventDataSize];
438 } TCG_PCClientTaggedEvent
;
440 #define TCG_Sp800_155_PlatformId_Event_SIGNATURE "SP800-155 Event"
441 #define TCG_Sp800_155_PlatformId_Event2_SIGNATURE "SP800-155 Event2"
443 typedef struct tdTCG_Sp800_155_PlatformId_Event2
{
446 // Where Vendor ID is an integer defined
447 // at http://www.iana.org/assignments/enterprisenumbers
451 // 16-byte identifier of a given platform's static configuration of code
453 EFI_GUID ReferenceManifestGuid
;
455 // Below structure is newly added in TCG_Sp800_155_PlatformId_Event2.
457 //UINT8 PlatformManufacturerStrSize;
458 //UINT8 PlatformManufacturerStr[PlatformManufacturerStrSize];
459 //UINT8 PlatformModelSize;
460 //UINT8 PlatformModel[PlatformModelSize];
461 //UINT8 PlatformVersionSize;
462 //UINT8 PlatformVersion[PlatformVersionSize];
463 //UINT8 PlatformModelSize;
464 //UINT8 PlatformModel[PlatformModelSize];
465 //UINT8 FirmwareManufacturerStrSize;
466 //UINT8 FirmwareManufacturerStr[FirmwareManufacturerStrSize];
467 //UINT32 FirmwareManufacturerId;
468 //UINT8 FirmwareVersion;
469 //UINT8 FirmwareVersion[FirmwareVersionSize]];
470 } TCG_Sp800_155_PlatformId_Event2
;
472 #define TCG_EfiStartupLocalityEvent_SIGNATURE "StartupLocality"
476 // The Locality Indicator which sent the TPM2_Startup command
478 #define LOCALITY_0_INDICATOR 0x00
479 #define LOCALITY_3_INDICATOR 0x03
482 // Startup Locality Event
484 typedef struct tdTCG_EfiStartupLocalityEvent
{
487 // The Locality Indicator which sent the TPM2_Startup command
489 UINT8 StartupLocality
;
490 } TCG_EfiStartupLocalityEvent
;
494 // Restore original structure alignment