blob: 683a47925920b72833e9fb990df6f975e1cd2b20 [file] [log] [blame]
Subrata Banik20fe24b2021-12-09 02:46:38 +05301/** @file
2 TCG EFI Platform Definition in TCG_EFI_Platform_1_20_Final and
3 TCG PC Client Platform Firmware Profile Specification, Revision 1.05
4
5 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9
10#ifndef __UEFI_TCG_PLATFORM_H__
11#define __UEFI_TCG_PLATFORM_H__
12
13#include <IndustryStandard/Tpm12.h>
14#include <IndustryStandard/Tpm20.h>
15#include <Uefi.h>
16
17//
18// Standard event types
19//
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)
36
37//
38// EFI specific event types
39//
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)
56
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"
67
68
69#define EV_POSTCODE_INFO_POST_CODE "POST CODE"
70#define POST_CODE_STR_LEN (sizeof(EV_POSTCODE_INFO_POST_CODE) - 1)
71
72#define EV_POSTCODE_INFO_SMM_CODE "SMM CODE"
73#define SMM_CODE_STR_LEN (sizeof(EV_POSTCODE_INFO_SMM_CODE) - 1)
74
75#define EV_POSTCODE_INFO_ACPI_DATA "ACPI DATA"
76#define ACPI_DATA_LEN (sizeof(EV_POSTCODE_INFO_ACPI_DATA) - 1)
77
78#define EV_POSTCODE_INFO_BIS_CODE "BIS CODE"
79#define BIS_CODE_LEN (sizeof(EV_POSTCODE_INFO_BIS_CODE) - 1)
80
81#define EV_POSTCODE_INFO_UEFI_PI "UEFI PI"
82#define UEFI_PI_LEN (sizeof(EV_POSTCODE_INFO_UEFI_PI) - 1)
83
84#define EV_POSTCODE_INFO_OPROM "Embedded Option ROM"
85#define OPROM_LEN (sizeof(EV_POSTCODE_INFO_OPROM) - 1)
86
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)
89
90#define FIRMWARE_DEBUGGER_EVENT_STRING "UEFI Debug Mode"
91#define FIRMWARE_DEBUGGER_EVENT_STRING_LEN (sizeof(FIRMWARE_DEBUGGER_EVENT_STRING) - 1)
92
93//
94// Set structure alignment to 1-byte
95//
96#pragma pack (1)
97
98typedef UINT32 TCG_EVENTTYPE;
99typedef TPM_PCRINDEX TCG_PCRINDEX;
100typedef TPM_DIGEST TCG_DIGEST;
101///
102/// Event Log Entry Structure Definition
103///
104typedef 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
110} TCG_PCR_EVENT;
111
112#define TSS_EVENT_DATA_MAX_SIZE 256
113
114///
115/// TCG_PCR_EVENT_HDR
116///
117typedef struct tdTCG_PCR_EVENT_HDR {
118 TCG_PCRINDEX PCRIndex;
119 TCG_EVENTTYPE EventType;
120 TCG_DIGEST Digest;
121 UINT32 EventSize;
122} TCG_PCR_EVENT_HDR;
123
124///
125/// EFI_PLATFORM_FIRMWARE_BLOB
126///
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
129///
130typedef struct tdEFI_PLATFORM_FIRMWARE_BLOB {
131 EFI_PHYSICAL_ADDRESS BlobBase;
132 UINT64 BlobLength;
133} EFI_PLATFORM_FIRMWARE_BLOB;
134
135///
136/// UEFI_PLATFORM_FIRMWARE_BLOB
137///
138/// This structure is used in EV_EFI_PLATFORM_FIRMWARE_BLOB
139/// event to facilitate the measurement of firmware volume.
140///
141typedef struct tdUEFI_PLATFORM_FIRMWARE_BLOB {
142 EFI_PHYSICAL_ADDRESS BlobBase;
143 UINT64 BlobLength;
144} UEFI_PLATFORM_FIRMWARE_BLOB;
145
146///
147/// UEFI_PLATFORM_FIRMWARE_BLOB2
148///
149/// This structure is used in EV_EFI_PLATFORM_FIRMWARE_BLOB2
150/// event to facilitate the measurement of firmware volume.
151///
152typedef struct tdUEFI_PLATFORM_FIRMWARE_BLOB2 {
153 UINT8 BlobDescriptionSize;
154//UINT8 BlobDescription[BlobDescriptionSize];
155//EFI_PHYSICAL_ADDRESS BlobBase;
156//UINT64 BlobLength;
157} UEFI_PLATFORM_FIRMWARE_BLOB2;
158
159///
160/// EFI_IMAGE_LOAD_EVENT
161///
162/// This structure is used in EV_EFI_BOOT_SERVICES_APPLICATION,
163/// EV_EFI_BOOT_SERVICES_DRIVER and EV_EFI_RUNTIME_SERVICES_DRIVER
164///
165typedef 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;
172
173///
174/// UEFI_IMAGE_LOAD_EVENT
175///
176/// This structure is used in EV_EFI_BOOT_SERVICES_APPLICATION,
177/// EV_EFI_BOOT_SERVICES_DRIVER and EV_EFI_RUNTIME_SERVICES_DRIVER
178///
179typedef 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;
186
187///
188/// EFI_HANDOFF_TABLE_POINTERS
189///
190/// This structure is used in EV_EFI_HANDOFF_TABLES event to facilitate
191/// the measurement of given configuration tables.
192///
193typedef struct tdEFI_HANDOFF_TABLE_POINTERS {
194 UINTN NumberOfTables;
195 EFI_CONFIGURATION_TABLE TableEntry[1];
196} EFI_HANDOFF_TABLE_POINTERS;
197
198///
199/// UEFI_HANDOFF_TABLE_POINTERS
200///
201/// This structure is used in EV_EFI_HANDOFF_TABLES event to facilitate
202/// the measurement of given configuration tables.
203///
204typedef struct tdUEFI_HANDOFF_TABLE_POINTERS {
205 UINT64 NumberOfTables;
206 EFI_CONFIGURATION_TABLE TableEntry[1];
207} UEFI_HANDOFF_TABLE_POINTERS;
208
209///
210/// UEFI_HANDOFF_TABLE_POINTERS2
211///
212/// This structure is used in EV_EFI_HANDOFF_TABLES2 event to facilitate
213/// the measurement of given configuration tables.
214///
215typedef 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;
221
222///
223/// EFI_VARIABLE_DATA
224///
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
227/// data.
228/// This is defined in TCG EFI Platform Spec for TPM1.1 or 1.2 V1.22
229///
230typedef 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
236} EFI_VARIABLE_DATA;
237
238///
239/// UEFI_VARIABLE_DATA
240///
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
243/// data.
244/// This is defined in TCG PC Client Firmware Profile Spec 00.21
245///
246typedef 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;
253
254//
255// For TrEE1.0 compatibility
256//
257typedef struct {
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;
264
265typedef struct tdEFI_GPT_DATA {
266 EFI_PARTITION_TABLE_HEADER EfiPartitionHeader;
267 UINTN NumberOfPartitions;
268 EFI_PARTITION_ENTRY Partitions[1];
269} EFI_GPT_DATA;
270
271typedef struct tdUEFI_GPT_DATA {
272 EFI_PARTITION_TABLE_HEADER EfiPartitionHeader;
273 UINT64 NumberOfPartitions;
274 EFI_PARTITION_ENTRY Partitions[1];
275} UEFI_GPT_DATA;
276
277#define TCG_DEVICE_SECURITY_EVENT_DATA_SIGNATURE "SPDM Device Sec"
278#define TCG_DEVICE_SECURITY_EVENT_DATA_VERSION 1
279
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
283
284///
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.
288///
289typedef struct {
290 UINT8 Signature[16];
291 UINT16 Version;
292 UINT16 Length;
293 UINT32 SpdmHashAlgo;
294 UINT32 DeviceType;
295//SPDM_MEASUREMENT_BLOCK SpdmMeasurementBlock;
296} TCG_DEVICE_SECURITY_EVENT_DATA_HEADER;
297
298#define TCG_DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT_VERSION 0
299
300///
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.
304///
305typedef struct {
306 UINT16 Version;
307 UINT16 Length;
308 UINT16 VendorId;
309 UINT16 DeviceId;
310 UINT8 RevisionID;
311 UINT8 ClassCode[3];
312 UINT16 SubsystemVendorID;
313 UINT16 SubsystemID;
314} TCG_DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT;
315
316#define TCG_DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT_VERSION 0
317
318///
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.
322///
323typedef struct {
324 UINT16 Version;
325 UINT16 Length;
326//UINT8 DeviceDescriptor[DescLen];
327//UINT8 BodDescriptor[DescLen];
328//UINT8 ConfigurationDescriptor[DescLen][NumOfConfiguration];
329} TCG_DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT;
330
331//
332// Crypto Agile Log Entry Format
333//
334typedef struct tdTCG_PCR_EVENT2 {
335 TCG_PCRINDEX PCRIndex;
336 TCG_EVENTTYPE EventType;
337 TPML_DIGEST_VALUES Digest;
338 UINT32 EventSize;
339 UINT8 Event[1];
340} TCG_PCR_EVENT2;
341
342//
343// TCG PCR Event2 Header
344// Follow TCG EFI Protocol Spec 5.2 Crypto Agile Log Entry Format
345//
346typedef struct tdTCG_PCR_EVENT2_HDR{
347 TCG_PCRINDEX PCRIndex;
348 TCG_EVENTTYPE EventType;
349 TPML_DIGEST_VALUES Digests;
350 UINT32 EventSize;
351} TCG_PCR_EVENT2_HDR;
352
353//
354// Log Header Entry Data
355//
356typedef struct {
357 //
358 // TCG defined hashing algorithm ID.
359 //
360 UINT16 algorithmId;
361 //
362 // The size of the digest for the respective hashing algorithm.
363 //
364 UINT16 digestSize;
365} TCG_EfiSpecIdEventAlgorithmSize;
366
367#define TCG_EfiSpecIDEventStruct_SIGNATURE_02 "Spec ID Event02"
368#define TCG_EfiSpecIDEventStruct_SIGNATURE_03 "Spec ID Event03"
369
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
373
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
378
379typedef struct {
380 UINT8 signature[16];
381 //
382 // The value for the Platform Class.
383 // The enumeration is defined in the TCG ACPI Specification Client Common Header.
384 //
385 UINT32 platformClass;
386 //
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.
390 //
391 UINT8 specVersionMinor;
392 //
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.
396 //
397 UINT8 specVersionMajor;
398 //
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.
402 //
403 UINT8 specErrata;
404 //
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.
407 //
408 UINT8 uintnSize;
409 //
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.
413 //
414//UINT32 numberOfAlgorithms;
415 //
416 // This field is added in "Spec ID Event03".
417 // An array of size numberOfAlgorithms of value pairs.
418 //
419//TCG_EfiSpecIdEventAlgorithmSize digestSize[numberOfAlgorithms];
420 //
421 // Size in bytes of the VendorInfo field.
422 // Maximum value SHALL be FFh bytes.
423 //
424//UINT8 vendorInfoSize;
425 //
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.
430 //
431//UINT8 vendorInfo[vendorInfoSize];
432} TCG_EfiSpecIDEventStruct;
433
434typedef struct tdTCG_PCClientTaggedEvent {
435 UINT32 taggedEventID;
436 UINT32 taggedEventDataSize;
437//UINT8 taggedEventData[taggedEventDataSize];
438} TCG_PCClientTaggedEvent;
439
440#define TCG_Sp800_155_PlatformId_Event_SIGNATURE "SP800-155 Event"
441#define TCG_Sp800_155_PlatformId_Event2_SIGNATURE "SP800-155 Event2"
442
443typedef struct tdTCG_Sp800_155_PlatformId_Event2 {
444 UINT8 Signature[16];
445 //
446 // Where Vendor ID is an integer defined
447 // at http://www.iana.org/assignments/enterprisenumbers
448 //
449 UINT32 VendorId;
450 //
451 // 16-byte identifier of a given platform's static configuration of code
452 //
453 EFI_GUID ReferenceManifestGuid;
454 //
455 // Below structure is newly added in TCG_Sp800_155_PlatformId_Event2.
456 //
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;
471
472#define TCG_EfiStartupLocalityEvent_SIGNATURE "StartupLocality"
473
474
475//
476// The Locality Indicator which sent the TPM2_Startup command
477//
478#define LOCALITY_0_INDICATOR 0x00
479#define LOCALITY_3_INDICATOR 0x03
480
481//
482// Startup Locality Event
483//
484typedef struct tdTCG_EfiStartupLocalityEvent{
485 UINT8 Signature[16];
486 //
487 // The Locality Indicator which sent the TPM2_Startup command
488 //
489 UINT8 StartupLocality;
490} TCG_EfiStartupLocalityEvent;
491
492
493//
494// Restore original structure alignment
495//
496#pragma pack ()
497
498#endif
499
500