xref: /freebsd/sys/contrib/edk2/Include/IndustryStandard/UefiTcgPlatform.h (revision 1aa241b4ee657b8a62a0d86b91f82cf792f08dca)
1*1aa241b4SWarner Losh /** @file
2*1aa241b4SWarner Losh   TCG EFI Platform Definition in TCG_EFI_Platform_1_20_Final and
3*1aa241b4SWarner Losh   TCG PC Client Platform Firmware Profile Specification, Revision 1.06
4*1aa241b4SWarner Losh 
5*1aa241b4SWarner Losh   Copyright (c) 2006 - 2024, Intel Corporation. All rights reserved.<BR>
6*1aa241b4SWarner Losh   SPDX-License-Identifier: BSD-2-Clause-Patent
7*1aa241b4SWarner Losh 
8*1aa241b4SWarner Losh **/
9*1aa241b4SWarner Losh 
10*1aa241b4SWarner Losh #ifndef __UEFI_TCG_PLATFORM_H__
11*1aa241b4SWarner Losh #define __UEFI_TCG_PLATFORM_H__
12*1aa241b4SWarner Losh 
13*1aa241b4SWarner Losh #include <IndustryStandard/Tpm12.h>
14*1aa241b4SWarner Losh #include <IndustryStandard/Tpm20.h>
15*1aa241b4SWarner Losh #include <Uefi.h>
16*1aa241b4SWarner Losh 
17*1aa241b4SWarner Losh //
18*1aa241b4SWarner Losh // Standard event types
19*1aa241b4SWarner Losh //
20*1aa241b4SWarner Losh #define EV_PREBOOT_CERT             ((TCG_EVENTTYPE) 0x00000000)
21*1aa241b4SWarner Losh #define EV_POST_CODE                ((TCG_EVENTTYPE) 0x00000001)
22*1aa241b4SWarner Losh #define EV_NO_ACTION                ((TCG_EVENTTYPE) 0x00000003)
23*1aa241b4SWarner Losh #define EV_SEPARATOR                ((TCG_EVENTTYPE) 0x00000004)
24*1aa241b4SWarner Losh #define EV_ACTION                   ((TCG_EVENTTYPE) 0x00000005)
25*1aa241b4SWarner Losh #define EV_EVENT_TAG                ((TCG_EVENTTYPE) 0x00000006)
26*1aa241b4SWarner Losh #define EV_S_CRTM_CONTENTS          ((TCG_EVENTTYPE) 0x00000007)
27*1aa241b4SWarner Losh #define EV_S_CRTM_VERSION           ((TCG_EVENTTYPE) 0x00000008)
28*1aa241b4SWarner Losh #define EV_CPU_MICROCODE            ((TCG_EVENTTYPE) 0x00000009)
29*1aa241b4SWarner Losh #define EV_PLATFORM_CONFIG_FLAGS    ((TCG_EVENTTYPE) 0x0000000A)
30*1aa241b4SWarner Losh #define EV_TABLE_OF_DEVICES         ((TCG_EVENTTYPE) 0x0000000B)
31*1aa241b4SWarner Losh #define EV_COMPACT_HASH             ((TCG_EVENTTYPE) 0x0000000C)
32*1aa241b4SWarner Losh #define EV_NONHOST_CODE             ((TCG_EVENTTYPE) 0x0000000F)
33*1aa241b4SWarner Losh #define EV_NONHOST_CONFIG           ((TCG_EVENTTYPE) 0x00000010)
34*1aa241b4SWarner Losh #define EV_NONHOST_INFO             ((TCG_EVENTTYPE) 0x00000011)
35*1aa241b4SWarner Losh #define EV_OMIT_BOOT_DEVICE_EVENTS  ((TCG_EVENTTYPE) 0x00000012)
36*1aa241b4SWarner Losh 
37*1aa241b4SWarner Losh //
38*1aa241b4SWarner Losh // EFI specific event types
39*1aa241b4SWarner Losh //
40*1aa241b4SWarner Losh #define EV_EFI_EVENT_BASE                 ((TCG_EVENTTYPE) 0x80000000)
41*1aa241b4SWarner Losh #define EV_EFI_VARIABLE_DRIVER_CONFIG     (EV_EFI_EVENT_BASE + 1)
42*1aa241b4SWarner Losh #define EV_EFI_VARIABLE_BOOT              (EV_EFI_EVENT_BASE + 2)
43*1aa241b4SWarner Losh #define EV_EFI_BOOT_SERVICES_APPLICATION  (EV_EFI_EVENT_BASE + 3)
44*1aa241b4SWarner Losh #define EV_EFI_BOOT_SERVICES_DRIVER       (EV_EFI_EVENT_BASE + 4)
45*1aa241b4SWarner Losh #define EV_EFI_RUNTIME_SERVICES_DRIVER    (EV_EFI_EVENT_BASE + 5)
46*1aa241b4SWarner Losh #define EV_EFI_GPT_EVENT                  (EV_EFI_EVENT_BASE + 6)
47*1aa241b4SWarner Losh #define EV_EFI_ACTION                     (EV_EFI_EVENT_BASE + 7)
48*1aa241b4SWarner Losh #define EV_EFI_PLATFORM_FIRMWARE_BLOB     (EV_EFI_EVENT_BASE + 8)
49*1aa241b4SWarner Losh #define EV_EFI_HANDOFF_TABLES             (EV_EFI_EVENT_BASE + 9)
50*1aa241b4SWarner Losh #define EV_EFI_PLATFORM_FIRMWARE_BLOB2    (EV_EFI_EVENT_BASE + 0xA)
51*1aa241b4SWarner Losh #define EV_EFI_HANDOFF_TABLES2            (EV_EFI_EVENT_BASE + 0xB)
52*1aa241b4SWarner Losh #define EV_EFI_HCRTM_EVENT                (EV_EFI_EVENT_BASE + 0x10)
53*1aa241b4SWarner Losh #define EV_EFI_VARIABLE_AUTHORITY         (EV_EFI_EVENT_BASE + 0xE0)
54*1aa241b4SWarner Losh #define EV_EFI_SPDM_FIRMWARE_BLOB         (EV_EFI_EVENT_BASE + 0xE1)
55*1aa241b4SWarner Losh #define EV_EFI_SPDM_FIRMWARE_CONFIG       (EV_EFI_EVENT_BASE + 0xE2)
56*1aa241b4SWarner Losh #define EV_EFI_SPDM_DEVICE_BLOB           EV_EFI_SPDM_FIRMWARE_BLOB
57*1aa241b4SWarner Losh #define EV_EFI_SPDM_DEVICE_CONFIG         EV_EFI_SPDM_FIRMWARE_CONFIG
58*1aa241b4SWarner Losh //
59*1aa241b4SWarner Losh // The SPDM policy database for SPDM verification.
60*1aa241b4SWarner Losh // It goes to PCR7
61*1aa241b4SWarner Losh //
62*1aa241b4SWarner Losh #define EV_EFI_SPDM_DEVICE_POLICY  (EV_EFI_EVENT_BASE + 0xE3)
63*1aa241b4SWarner Losh //
64*1aa241b4SWarner Losh // The SPDM policy authority for SPDM verification for the signature
65*1aa241b4SWarner Losh // of GET_MEASUREMENT or CHALLENGE_AUTH. It goes to PCR7.
66*1aa241b4SWarner Losh //
67*1aa241b4SWarner Losh #define EV_EFI_SPDM_DEVICE_AUTHORITY  (EV_EFI_EVENT_BASE + 0xE4)
68*1aa241b4SWarner Losh 
69*1aa241b4SWarner Losh #define EFI_CALLING_EFI_APPLICATION         \
70*1aa241b4SWarner Losh   "Calling EFI Application from Boot Option"
71*1aa241b4SWarner Losh #define EFI_RETURNING_FROM_EFI_APPLICATION  \
72*1aa241b4SWarner Losh   "Returning from EFI Application from Boot Option"
73*1aa241b4SWarner Losh #define EFI_EXIT_BOOT_SERVICES_INVOCATION   \
74*1aa241b4SWarner Losh   "Exit Boot Services Invocation"
75*1aa241b4SWarner Losh #define EFI_EXIT_BOOT_SERVICES_FAILED       \
76*1aa241b4SWarner Losh   "Exit Boot Services Returned with Failure"
77*1aa241b4SWarner Losh #define EFI_EXIT_BOOT_SERVICES_SUCCEEDED    \
78*1aa241b4SWarner Losh   "Exit Boot Services Returned with Success"
79*1aa241b4SWarner Losh 
80*1aa241b4SWarner Losh #define EV_POSTCODE_INFO_POST_CODE  "POST CODE"
81*1aa241b4SWarner Losh #define POST_CODE_STR_LEN           (sizeof(EV_POSTCODE_INFO_POST_CODE) - 1)
82*1aa241b4SWarner Losh 
83*1aa241b4SWarner Losh #define EV_POSTCODE_INFO_SMM_CODE  "SMM CODE"
84*1aa241b4SWarner Losh #define SMM_CODE_STR_LEN           (sizeof(EV_POSTCODE_INFO_SMM_CODE) - 1)
85*1aa241b4SWarner Losh 
86*1aa241b4SWarner Losh #define EV_POSTCODE_INFO_ACPI_DATA  "ACPI DATA"
87*1aa241b4SWarner Losh #define ACPI_DATA_LEN               (sizeof(EV_POSTCODE_INFO_ACPI_DATA) - 1)
88*1aa241b4SWarner Losh 
89*1aa241b4SWarner Losh #define EV_POSTCODE_INFO_BIS_CODE  "BIS CODE"
90*1aa241b4SWarner Losh #define BIS_CODE_LEN               (sizeof(EV_POSTCODE_INFO_BIS_CODE) - 1)
91*1aa241b4SWarner Losh 
92*1aa241b4SWarner Losh #define EV_POSTCODE_INFO_UEFI_PI  "UEFI PI"
93*1aa241b4SWarner Losh #define UEFI_PI_LEN               (sizeof(EV_POSTCODE_INFO_UEFI_PI) - 1)
94*1aa241b4SWarner Losh 
95*1aa241b4SWarner Losh #define EV_POSTCODE_INFO_OPROM  "Embedded Option ROM"
96*1aa241b4SWarner Losh #define OPROM_LEN               (sizeof(EV_POSTCODE_INFO_OPROM) - 1)
97*1aa241b4SWarner Losh 
98*1aa241b4SWarner Losh #define EV_POSTCODE_INFO_EMBEDDED_UEFI_DRIVER  "Embedded UEFI Driver"
99*1aa241b4SWarner Losh #define EMBEDDED_UEFI_DRIVER_LEN               (sizeof(EV_POSTCODE_INFO_EMBEDDED_UEFI_DRIVER) - 1)
100*1aa241b4SWarner Losh 
101*1aa241b4SWarner Losh #define FIRMWARE_DEBUGGER_EVENT_STRING      "UEFI Debug Mode"
102*1aa241b4SWarner Losh #define FIRMWARE_DEBUGGER_EVENT_STRING_LEN  (sizeof(FIRMWARE_DEBUGGER_EVENT_STRING) - 1)
103*1aa241b4SWarner Losh 
104*1aa241b4SWarner Losh //
105*1aa241b4SWarner Losh // Set structure alignment to 1-byte
106*1aa241b4SWarner Losh //
107*1aa241b4SWarner Losh #pragma pack (1)
108*1aa241b4SWarner Losh 
109*1aa241b4SWarner Losh typedef UINT32        TCG_EVENTTYPE;
110*1aa241b4SWarner Losh typedef TPM_PCRINDEX  TCG_PCRINDEX;
111*1aa241b4SWarner Losh typedef TPM_DIGEST    TCG_DIGEST;
112*1aa241b4SWarner Losh ///
113*1aa241b4SWarner Losh /// Event Log Entry Structure Definition
114*1aa241b4SWarner Losh ///
115*1aa241b4SWarner Losh typedef struct tdTCG_PCR_EVENT {
116*1aa241b4SWarner Losh   TCG_PCRINDEX     PCRIndex;                   ///< PCRIndex event extended to
117*1aa241b4SWarner Losh   TCG_EVENTTYPE    EventType;                  ///< TCG EFI event type
118*1aa241b4SWarner Losh   TCG_DIGEST       Digest;                     ///< Value extended into PCRIndex
119*1aa241b4SWarner Losh   UINT32           EventSize;                  ///< Size of the event data
120*1aa241b4SWarner Losh   UINT8            Event[1];                   ///< The event data
121*1aa241b4SWarner Losh } TCG_PCR_EVENT;
122*1aa241b4SWarner Losh 
123*1aa241b4SWarner Losh #define TSS_EVENT_DATA_MAX_SIZE  256
124*1aa241b4SWarner Losh 
125*1aa241b4SWarner Losh ///
126*1aa241b4SWarner Losh /// TCG_PCR_EVENT_HDR
127*1aa241b4SWarner Losh ///
128*1aa241b4SWarner Losh typedef struct tdTCG_PCR_EVENT_HDR {
129*1aa241b4SWarner Losh   TCG_PCRINDEX     PCRIndex;
130*1aa241b4SWarner Losh   TCG_EVENTTYPE    EventType;
131*1aa241b4SWarner Losh   TCG_DIGEST       Digest;
132*1aa241b4SWarner Losh   UINT32           EventSize;
133*1aa241b4SWarner Losh } TCG_PCR_EVENT_HDR;
134*1aa241b4SWarner Losh 
135*1aa241b4SWarner Losh ///
136*1aa241b4SWarner Losh /// EFI_PLATFORM_FIRMWARE_BLOB
137*1aa241b4SWarner Losh ///
138*1aa241b4SWarner Losh /// BlobLength should be of type UINTN but we use UINT64 here
139*1aa241b4SWarner Losh /// because PEI is 32-bit while DXE is 64-bit on x64 platforms
140*1aa241b4SWarner Losh ///
141*1aa241b4SWarner Losh typedef struct tdEFI_PLATFORM_FIRMWARE_BLOB {
142*1aa241b4SWarner Losh   EFI_PHYSICAL_ADDRESS    BlobBase;
143*1aa241b4SWarner Losh   UINT64                  BlobLength;
144*1aa241b4SWarner Losh } EFI_PLATFORM_FIRMWARE_BLOB;
145*1aa241b4SWarner Losh 
146*1aa241b4SWarner Losh ///
147*1aa241b4SWarner Losh /// UEFI_PLATFORM_FIRMWARE_BLOB
148*1aa241b4SWarner Losh ///
149*1aa241b4SWarner Losh /// This structure is used in EV_EFI_PLATFORM_FIRMWARE_BLOB
150*1aa241b4SWarner Losh /// event to facilitate the measurement of firmware volume.
151*1aa241b4SWarner Losh ///
152*1aa241b4SWarner Losh typedef struct tdUEFI_PLATFORM_FIRMWARE_BLOB {
153*1aa241b4SWarner Losh   EFI_PHYSICAL_ADDRESS    BlobBase;
154*1aa241b4SWarner Losh   UINT64                  BlobLength;
155*1aa241b4SWarner Losh } UEFI_PLATFORM_FIRMWARE_BLOB;
156*1aa241b4SWarner Losh 
157*1aa241b4SWarner Losh ///
158*1aa241b4SWarner Losh /// UEFI_PLATFORM_FIRMWARE_BLOB2
159*1aa241b4SWarner Losh ///
160*1aa241b4SWarner Losh /// This structure is used in EV_EFI_PLATFORM_FIRMWARE_BLOB2
161*1aa241b4SWarner Losh /// event to facilitate the measurement of firmware volume.
162*1aa241b4SWarner Losh ///
163*1aa241b4SWarner Losh typedef struct tdUEFI_PLATFORM_FIRMWARE_BLOB2 {
164*1aa241b4SWarner Losh   UINT8    BlobDescriptionSize;
165*1aa241b4SWarner Losh   // UINT8                             BlobDescription[BlobDescriptionSize];
166*1aa241b4SWarner Losh   // EFI_PHYSICAL_ADDRESS              BlobBase;
167*1aa241b4SWarner Losh   // UINT64                            BlobLength;
168*1aa241b4SWarner Losh } UEFI_PLATFORM_FIRMWARE_BLOB2;
169*1aa241b4SWarner Losh 
170*1aa241b4SWarner Losh ///
171*1aa241b4SWarner Losh /// EFI_IMAGE_LOAD_EVENT
172*1aa241b4SWarner Losh ///
173*1aa241b4SWarner Losh /// This structure is used in EV_EFI_BOOT_SERVICES_APPLICATION,
174*1aa241b4SWarner Losh /// EV_EFI_BOOT_SERVICES_DRIVER and EV_EFI_RUNTIME_SERVICES_DRIVER
175*1aa241b4SWarner Losh ///
176*1aa241b4SWarner Losh typedef struct tdEFI_IMAGE_LOAD_EVENT {
177*1aa241b4SWarner Losh   EFI_PHYSICAL_ADDRESS        ImageLocationInMemory;
178*1aa241b4SWarner Losh   UINTN                       ImageLengthInMemory;
179*1aa241b4SWarner Losh   UINTN                       ImageLinkTimeAddress;
180*1aa241b4SWarner Losh   UINTN                       LengthOfDevicePath;
181*1aa241b4SWarner Losh   EFI_DEVICE_PATH_PROTOCOL    DevicePath[1];
182*1aa241b4SWarner Losh } EFI_IMAGE_LOAD_EVENT;
183*1aa241b4SWarner Losh 
184*1aa241b4SWarner Losh ///
185*1aa241b4SWarner Losh /// UEFI_IMAGE_LOAD_EVENT
186*1aa241b4SWarner Losh ///
187*1aa241b4SWarner Losh /// This structure is used in EV_EFI_BOOT_SERVICES_APPLICATION,
188*1aa241b4SWarner Losh /// EV_EFI_BOOT_SERVICES_DRIVER and EV_EFI_RUNTIME_SERVICES_DRIVER
189*1aa241b4SWarner Losh ///
190*1aa241b4SWarner Losh typedef struct tdUEFI_IMAGE_LOAD_EVENT {
191*1aa241b4SWarner Losh   EFI_PHYSICAL_ADDRESS        ImageLocationInMemory;
192*1aa241b4SWarner Losh   UINT64                      ImageLengthInMemory;
193*1aa241b4SWarner Losh   UINT64                      ImageLinkTimeAddress;
194*1aa241b4SWarner Losh   UINT64                      LengthOfDevicePath;
195*1aa241b4SWarner Losh   EFI_DEVICE_PATH_PROTOCOL    DevicePath[1];
196*1aa241b4SWarner Losh } UEFI_IMAGE_LOAD_EVENT;
197*1aa241b4SWarner Losh 
198*1aa241b4SWarner Losh ///
199*1aa241b4SWarner Losh /// EFI_HANDOFF_TABLE_POINTERS
200*1aa241b4SWarner Losh ///
201*1aa241b4SWarner Losh /// This structure is used in EV_EFI_HANDOFF_TABLES event to facilitate
202*1aa241b4SWarner Losh /// the measurement of given configuration tables.
203*1aa241b4SWarner Losh ///
204*1aa241b4SWarner Losh typedef struct tdEFI_HANDOFF_TABLE_POINTERS {
205*1aa241b4SWarner Losh   UINTN                      NumberOfTables;
206*1aa241b4SWarner Losh   EFI_CONFIGURATION_TABLE    TableEntry[1];
207*1aa241b4SWarner Losh } EFI_HANDOFF_TABLE_POINTERS;
208*1aa241b4SWarner Losh 
209*1aa241b4SWarner Losh ///
210*1aa241b4SWarner Losh /// UEFI_HANDOFF_TABLE_POINTERS
211*1aa241b4SWarner Losh ///
212*1aa241b4SWarner Losh /// This structure is used in EV_EFI_HANDOFF_TABLES event to facilitate
213*1aa241b4SWarner Losh /// the measurement of given configuration tables.
214*1aa241b4SWarner Losh ///
215*1aa241b4SWarner Losh typedef struct tdUEFI_HANDOFF_TABLE_POINTERS {
216*1aa241b4SWarner Losh   UINT64                     NumberOfTables;
217*1aa241b4SWarner Losh   EFI_CONFIGURATION_TABLE    TableEntry[1];
218*1aa241b4SWarner Losh } UEFI_HANDOFF_TABLE_POINTERS;
219*1aa241b4SWarner Losh 
220*1aa241b4SWarner Losh ///
221*1aa241b4SWarner Losh /// UEFI_HANDOFF_TABLE_POINTERS2
222*1aa241b4SWarner Losh ///
223*1aa241b4SWarner Losh /// This structure is used in EV_EFI_HANDOFF_TABLES2 event to facilitate
224*1aa241b4SWarner Losh /// the measurement of given configuration tables.
225*1aa241b4SWarner Losh ///
226*1aa241b4SWarner Losh typedef struct tdUEFI_HANDOFF_TABLE_POINTERS2 {
227*1aa241b4SWarner Losh   UINT8    TableDescriptionSize;
228*1aa241b4SWarner Losh   // UINT8                             TableDescription[TableDescriptionSize];
229*1aa241b4SWarner Losh   // UINT64                            NumberOfTables;
230*1aa241b4SWarner Losh   // EFI_CONFIGURATION_TABLE           TableEntry[1];
231*1aa241b4SWarner Losh } UEFI_HANDOFF_TABLE_POINTERS2;
232*1aa241b4SWarner Losh 
233*1aa241b4SWarner Losh ///
234*1aa241b4SWarner Losh /// EFI_VARIABLE_DATA
235*1aa241b4SWarner Losh ///
236*1aa241b4SWarner Losh /// This structure serves as the header for measuring variables. The name of the
237*1aa241b4SWarner Losh /// variable (in Unicode format) should immediately follow, then the variable
238*1aa241b4SWarner Losh /// data.
239*1aa241b4SWarner Losh /// This is defined in TCG EFI Platform Spec for TPM1.1 or 1.2 V1.22
240*1aa241b4SWarner Losh ///
241*1aa241b4SWarner Losh typedef struct tdEFI_VARIABLE_DATA {
242*1aa241b4SWarner Losh   EFI_GUID    VariableName;
243*1aa241b4SWarner Losh   UINTN       UnicodeNameLength;
244*1aa241b4SWarner Losh   UINTN       VariableDataLength;
245*1aa241b4SWarner Losh   CHAR16      UnicodeName[1];
246*1aa241b4SWarner Losh   INT8        VariableData[1];                        ///< Driver or platform-specific data
247*1aa241b4SWarner Losh } EFI_VARIABLE_DATA;
248*1aa241b4SWarner Losh 
249*1aa241b4SWarner Losh ///
250*1aa241b4SWarner Losh /// UEFI_VARIABLE_DATA
251*1aa241b4SWarner Losh ///
252*1aa241b4SWarner Losh /// This structure serves as the header for measuring variables. The name of the
253*1aa241b4SWarner Losh /// variable (in Unicode format) should immediately follow, then the variable
254*1aa241b4SWarner Losh /// data.
255*1aa241b4SWarner Losh /// This is defined in TCG PC Client Firmware Profile Spec 00.21
256*1aa241b4SWarner Losh ///
257*1aa241b4SWarner Losh typedef struct tdUEFI_VARIABLE_DATA {
258*1aa241b4SWarner Losh   EFI_GUID    VariableName;
259*1aa241b4SWarner Losh   UINT64      UnicodeNameLength;
260*1aa241b4SWarner Losh   UINT64      VariableDataLength;
261*1aa241b4SWarner Losh   CHAR16      UnicodeName[1];
262*1aa241b4SWarner Losh   INT8        VariableData[1];                        ///< Driver or platform-specific data
263*1aa241b4SWarner Losh } UEFI_VARIABLE_DATA;
264*1aa241b4SWarner Losh 
265*1aa241b4SWarner Losh //
266*1aa241b4SWarner Losh // For TrEE1.0 compatibility
267*1aa241b4SWarner Losh //
268*1aa241b4SWarner Losh typedef struct {
269*1aa241b4SWarner Losh   EFI_GUID    VariableName;
270*1aa241b4SWarner Losh   UINT64      UnicodeNameLength;                         // The TCG Definition used UINTN
271*1aa241b4SWarner Losh   UINT64      VariableDataLength;                        // The TCG Definition used UINTN
272*1aa241b4SWarner Losh   CHAR16      UnicodeName[1];
273*1aa241b4SWarner Losh   INT8        VariableData[1];
274*1aa241b4SWarner Losh } EFI_VARIABLE_DATA_TREE;
275*1aa241b4SWarner Losh 
276*1aa241b4SWarner Losh typedef struct tdEFI_GPT_DATA {
277*1aa241b4SWarner Losh   EFI_PARTITION_TABLE_HEADER    EfiPartitionHeader;
278*1aa241b4SWarner Losh   UINTN                         NumberOfPartitions;
279*1aa241b4SWarner Losh   EFI_PARTITION_ENTRY           Partitions[1];
280*1aa241b4SWarner Losh } EFI_GPT_DATA;
281*1aa241b4SWarner Losh 
282*1aa241b4SWarner Losh typedef struct tdUEFI_GPT_DATA {
283*1aa241b4SWarner Losh   EFI_PARTITION_TABLE_HEADER    EfiPartitionHeader;
284*1aa241b4SWarner Losh   UINT64                        NumberOfPartitions;
285*1aa241b4SWarner Losh   EFI_PARTITION_ENTRY           Partitions[1];
286*1aa241b4SWarner Losh } UEFI_GPT_DATA;
287*1aa241b4SWarner Losh 
288*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_SIGNATURE  "SPDM Device Sec"
289*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_VERSION    1
290*1aa241b4SWarner Losh 
291*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_TYPE_NULL  0
292*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_TYPE_PCI   1
293*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_TYPE_USB   2
294*1aa241b4SWarner Losh 
295*1aa241b4SWarner Losh ///
296*1aa241b4SWarner Losh /// TCG_DEVICE_SECURITY_EVENT_DATA_HEADER
297*1aa241b4SWarner Losh /// This is the header of TCG_DEVICE_SECURITY_EVENT_DATA, which is
298*1aa241b4SWarner Losh /// used in EV_EFI_SPDM_FIRMWARE_BLOB and EV_EFI_SPDM_FIRMWARE_CONFIG.
299*1aa241b4SWarner Losh ///
300*1aa241b4SWarner Losh typedef struct {
301*1aa241b4SWarner Losh   UINT8     Signature[16];
302*1aa241b4SWarner Losh   UINT16    Version;
303*1aa241b4SWarner Losh   UINT16    Length;
304*1aa241b4SWarner Losh   UINT32    SpdmHashAlgo;
305*1aa241b4SWarner Losh   UINT32    DeviceType;
306*1aa241b4SWarner Losh   // SPDM_MEASUREMENT_BLOCK         SpdmMeasurementBlock;
307*1aa241b4SWarner Losh } TCG_DEVICE_SECURITY_EVENT_DATA_HEADER;
308*1aa241b4SWarner Losh 
309*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT_VERSION  0
310*1aa241b4SWarner Losh 
311*1aa241b4SWarner Losh ///
312*1aa241b4SWarner Losh /// TCG_DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT
313*1aa241b4SWarner Losh /// This is the PCI context data of TCG_DEVICE_SECURITY_EVENT_DATA, which is
314*1aa241b4SWarner Losh /// used in EV_EFI_SPDM_FIRMWARE_BLOB and EV_EFI_SPDM_FIRMWARE_CONFIG.
315*1aa241b4SWarner Losh ///
316*1aa241b4SWarner Losh typedef struct {
317*1aa241b4SWarner Losh   UINT16    Version;
318*1aa241b4SWarner Losh   UINT16    Length;
319*1aa241b4SWarner Losh   UINT16    VendorId;
320*1aa241b4SWarner Losh   UINT16    DeviceId;
321*1aa241b4SWarner Losh   UINT8     RevisionID;
322*1aa241b4SWarner Losh   UINT8     ClassCode[3];
323*1aa241b4SWarner Losh   UINT16    SubsystemVendorID;
324*1aa241b4SWarner Losh   UINT16    SubsystemID;
325*1aa241b4SWarner Losh } TCG_DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT;
326*1aa241b4SWarner Losh 
327*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT_VERSION  0
328*1aa241b4SWarner Losh 
329*1aa241b4SWarner Losh ///
330*1aa241b4SWarner Losh /// TCG_DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT
331*1aa241b4SWarner Losh /// This is the USB context data of TCG_DEVICE_SECURITY_EVENT_DATA, which is
332*1aa241b4SWarner Losh /// used in EV_EFI_SPDM_FIRMWARE_BLOB and EV_EFI_SPDM_FIRMWARE_CONFIG.
333*1aa241b4SWarner Losh ///
334*1aa241b4SWarner Losh typedef struct {
335*1aa241b4SWarner Losh   UINT16    Version;
336*1aa241b4SWarner Losh   UINT16    Length;
337*1aa241b4SWarner Losh   // UINT8   DeviceDescriptor[DescLen];
338*1aa241b4SWarner Losh   // UINT8   BodDescriptor[DescLen];
339*1aa241b4SWarner Losh   // UINT8   ConfigurationDescriptor[DescLen][NumOfConfiguration];
340*1aa241b4SWarner Losh } TCG_DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT;
341*1aa241b4SWarner Losh 
342*1aa241b4SWarner Losh //
343*1aa241b4SWarner Losh // Crypto Agile Log Entry Format
344*1aa241b4SWarner Losh //
345*1aa241b4SWarner Losh typedef struct tdTCG_PCR_EVENT2 {
346*1aa241b4SWarner Losh   TCG_PCRINDEX          PCRIndex;
347*1aa241b4SWarner Losh   TCG_EVENTTYPE         EventType;
348*1aa241b4SWarner Losh   TPML_DIGEST_VALUES    Digest;
349*1aa241b4SWarner Losh   UINT32                EventSize;
350*1aa241b4SWarner Losh   UINT8                 Event[1];
351*1aa241b4SWarner Losh } TCG_PCR_EVENT2;
352*1aa241b4SWarner Losh 
353*1aa241b4SWarner Losh //
354*1aa241b4SWarner Losh // TCG PCR Event2 Header
355*1aa241b4SWarner Losh // Follow TCG EFI Protocol Spec 5.2 Crypto Agile Log Entry Format
356*1aa241b4SWarner Losh //
357*1aa241b4SWarner Losh typedef struct tdTCG_PCR_EVENT2_HDR {
358*1aa241b4SWarner Losh   TCG_PCRINDEX          PCRIndex;
359*1aa241b4SWarner Losh   TCG_EVENTTYPE         EventType;
360*1aa241b4SWarner Losh   TPML_DIGEST_VALUES    Digests;
361*1aa241b4SWarner Losh   UINT32                EventSize;
362*1aa241b4SWarner Losh } TCG_PCR_EVENT2_HDR;
363*1aa241b4SWarner Losh 
364*1aa241b4SWarner Losh //
365*1aa241b4SWarner Losh // Log Header Entry Data
366*1aa241b4SWarner Losh //
367*1aa241b4SWarner Losh typedef struct {
368*1aa241b4SWarner Losh   //
369*1aa241b4SWarner Losh   // TCG defined hashing algorithm ID.
370*1aa241b4SWarner Losh   //
371*1aa241b4SWarner Losh   UINT16    algorithmId;
372*1aa241b4SWarner Losh   //
373*1aa241b4SWarner Losh   // The size of the digest for the respective hashing algorithm.
374*1aa241b4SWarner Losh   //
375*1aa241b4SWarner Losh   UINT16    digestSize;
376*1aa241b4SWarner Losh } TCG_EfiSpecIdEventAlgorithmSize;
377*1aa241b4SWarner Losh 
378*1aa241b4SWarner Losh #define TCG_EfiSpecIDEventStruct_SIGNATURE_02  "Spec ID Event02"
379*1aa241b4SWarner Losh #define TCG_EfiSpecIDEventStruct_SIGNATURE_03  "Spec ID Event03"
380*1aa241b4SWarner Losh 
381*1aa241b4SWarner Losh #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MAJOR_TPM12  1
382*1aa241b4SWarner Losh #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MINOR_TPM12  2
383*1aa241b4SWarner Losh #define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM12         2
384*1aa241b4SWarner Losh 
385*1aa241b4SWarner Losh #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MAJOR_TPM2   2
386*1aa241b4SWarner Losh #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MINOR_TPM2   0
387*1aa241b4SWarner Losh #define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2          0
388*1aa241b4SWarner Losh #define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2_REV_105  105
389*1aa241b4SWarner Losh #define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2_REV_106  106
390*1aa241b4SWarner Losh 
391*1aa241b4SWarner Losh typedef struct {
392*1aa241b4SWarner Losh   UINT8     signature[16];
393*1aa241b4SWarner Losh   //
394*1aa241b4SWarner Losh   // The value for the Platform Class.
395*1aa241b4SWarner Losh   // The enumeration is defined in the TCG ACPI Specification Client Common Header.
396*1aa241b4SWarner Losh   //
397*1aa241b4SWarner Losh   UINT32    platformClass;
398*1aa241b4SWarner Losh   //
399*1aa241b4SWarner Losh   // The TCG EFI Platform Specification minor version number this BIOS supports.
400*1aa241b4SWarner Losh   // Any BIOS supporting version (1.22) MUST set this value to 02h.
401*1aa241b4SWarner Losh   // Any BIOS supporting version (2.0) SHALL set this value to 0x00.
402*1aa241b4SWarner Losh   //
403*1aa241b4SWarner Losh   UINT8     specVersionMinor;
404*1aa241b4SWarner Losh   //
405*1aa241b4SWarner Losh   // The TCG EFI Platform Specification major version number this BIOS supports.
406*1aa241b4SWarner Losh   // Any BIOS supporting version (1.22) MUST set this value to 01h.
407*1aa241b4SWarner Losh   // Any BIOS supporting version (2.0) SHALL set this value to 0x02.
408*1aa241b4SWarner Losh   //
409*1aa241b4SWarner Losh   UINT8     specVersionMajor;
410*1aa241b4SWarner Losh   //
411*1aa241b4SWarner Losh   // The TCG EFI Platform Specification errata for this specification this BIOS supports.
412*1aa241b4SWarner Losh   // Any BIOS supporting version and errata (1.22) MUST set this value to 02h.
413*1aa241b4SWarner Losh   // Any BIOS supporting version and errata (2.0) SHALL set this value to 0x00.
414*1aa241b4SWarner Losh   //
415*1aa241b4SWarner Losh   UINT8     specErrata;
416*1aa241b4SWarner Losh   //
417*1aa241b4SWarner Losh   // Specifies the size of the UINTN fields used in various data structures used in this specification.
418*1aa241b4SWarner Losh   // 0x01 indicates UINT32 and 0x02 indicates UINT64.
419*1aa241b4SWarner Losh   //
420*1aa241b4SWarner Losh   UINT8     uintnSize;
421*1aa241b4SWarner Losh   //
422*1aa241b4SWarner Losh   // This field is added in "Spec ID Event03".
423*1aa241b4SWarner Losh   // The number of hashing algorithms used in this event log (except the first event).
424*1aa241b4SWarner Losh   // All events in this event log use all hashing algorithms defined here.
425*1aa241b4SWarner Losh   //
426*1aa241b4SWarner Losh   UINT32              numberOfAlgorithms;
427*1aa241b4SWarner Losh   //
428*1aa241b4SWarner Losh   // This field is added in "Spec ID Event03".
429*1aa241b4SWarner Losh   // An array of size numberOfAlgorithms of value pairs.
430*1aa241b4SWarner Losh   //
431*1aa241b4SWarner Losh   //TCG_EfiSpecIdEventAlgorithmSize digestSize[numberOfAlgorithms];
432*1aa241b4SWarner Losh   TCG_EfiSpecIdEventAlgorithmSize digestSize[];
433*1aa241b4SWarner Losh   //
434*1aa241b4SWarner Losh   // Size in bytes of the VendorInfo field.
435*1aa241b4SWarner Losh   // Maximum value SHALL be FFh bytes.
436*1aa241b4SWarner Losh   //
437*1aa241b4SWarner Losh   //UINT8               vendorInfoSize;
438*1aa241b4SWarner Losh   //
439*1aa241b4SWarner Losh   // Provided for use by the BIOS implementer.
440*1aa241b4SWarner Losh   // The value might be used, for example, to provide more detailed information about the specific BIOS such as BIOS revision numbers, etc.
441*1aa241b4SWarner Losh   // The values within this field are not standardized and are implementer-specific.
442*1aa241b4SWarner Losh   // Platform-specific or -unique information SHALL NOT be provided in this field.
443*1aa241b4SWarner Losh   //
444*1aa241b4SWarner Losh   //UINT8               vendorInfo[vendorInfoSize];
445*1aa241b4SWarner Losh } TCG_EfiSpecIDEventStruct;
446*1aa241b4SWarner Losh 
447*1aa241b4SWarner Losh typedef struct tdTCG_PCClientTaggedEvent {
448*1aa241b4SWarner Losh   UINT32    taggedEventID;
449*1aa241b4SWarner Losh   UINT32    taggedEventDataSize;
450*1aa241b4SWarner Losh   // UINT8               taggedEventData[taggedEventDataSize];
451*1aa241b4SWarner Losh } TCG_PCClientTaggedEvent;
452*1aa241b4SWarner Losh 
453*1aa241b4SWarner Losh #define TCG_Sp800_155_PlatformId_Event_SIGNATURE   "SP800-155 Event"
454*1aa241b4SWarner Losh #define TCG_Sp800_155_PlatformId_Event2_SIGNATURE  "SP800-155 Event2"
455*1aa241b4SWarner Losh #define TCG_Sp800_155_PlatformId_Event3_SIGNATURE  "SP800-155 Event3"
456*1aa241b4SWarner Losh 
457*1aa241b4SWarner Losh typedef struct tdTCG_Sp800_155_PlatformId_Event2 {
458*1aa241b4SWarner Losh   UINT8       Signature[16];
459*1aa241b4SWarner Losh   //
460*1aa241b4SWarner Losh   // Where Vendor ID is an integer defined
461*1aa241b4SWarner Losh   // at http://www.iana.org/assignments/enterprisenumbers
462*1aa241b4SWarner Losh   //
463*1aa241b4SWarner Losh   UINT32      VendorId;
464*1aa241b4SWarner Losh   //
465*1aa241b4SWarner Losh   // 16-byte identifier of a given platform's static configuration of code
466*1aa241b4SWarner Losh   //
467*1aa241b4SWarner Losh   EFI_GUID    ReferenceManifestGuid;
468*1aa241b4SWarner Losh   //
469*1aa241b4SWarner Losh   // Below structure is newly added in TCG_Sp800_155_PlatformId_Event2.
470*1aa241b4SWarner Losh   //
471*1aa241b4SWarner Losh   // UINT8               PlatformManufacturerStrSize;
472*1aa241b4SWarner Losh   // UINT8               PlatformManufacturerStr[PlatformManufacturerStrSize];
473*1aa241b4SWarner Losh   // UINT8               PlatformModelSize;
474*1aa241b4SWarner Losh   // UINT8               PlatformModel[PlatformModelSize];
475*1aa241b4SWarner Losh   // UINT8               PlatformVersionSize;
476*1aa241b4SWarner Losh   // UINT8               PlatformVersion[PlatformVersionSize];
477*1aa241b4SWarner Losh   // UINT8               FirmwareManufacturerStrSize;
478*1aa241b4SWarner Losh   // UINT8               FirmwareManufacturerStr[FirmwareManufacturerStrSize];
479*1aa241b4SWarner Losh   // UINT32              FirmwareManufacturerId;
480*1aa241b4SWarner Losh   // UINT8               FirmwareVersion;
481*1aa241b4SWarner Losh   // UINT8               FirmwareVersion[FirmwareVersionSize];
482*1aa241b4SWarner Losh } TCG_Sp800_155_PlatformId_Event2;
483*1aa241b4SWarner Losh 
484*1aa241b4SWarner Losh typedef struct tdTCG_Sp800_155_PlatformId_Event3 {
485*1aa241b4SWarner Losh   UINT8       Signature[16];
486*1aa241b4SWarner Losh   //
487*1aa241b4SWarner Losh   // Where Vendor ID is an integer defined
488*1aa241b4SWarner Losh   // at http://www.iana.org/assignments/enterprisenumbers
489*1aa241b4SWarner Losh   //
490*1aa241b4SWarner Losh   UINT32      VendorId;
491*1aa241b4SWarner Losh   //
492*1aa241b4SWarner Losh   // 16-byte identifier of a given platform's static configuration of code
493*1aa241b4SWarner Losh   //
494*1aa241b4SWarner Losh   EFI_GUID    ReferenceManifestGuid;
495*1aa241b4SWarner Losh   // UINT8               PlatformManufacturerStrSize;
496*1aa241b4SWarner Losh   // UINT8               PlatformManufacturerStr[PlatformManufacturerStrSize];
497*1aa241b4SWarner Losh   // UINT8               PlatformModelSize;
498*1aa241b4SWarner Losh   // UINT8               PlatformModel[PlatformModelSize];
499*1aa241b4SWarner Losh   // UINT8               PlatformVersionSize;
500*1aa241b4SWarner Losh   // UINT8               PlatformVersion[PlatformVersionSize];
501*1aa241b4SWarner Losh   // UINT8               FirmwareManufacturerStrSize;
502*1aa241b4SWarner Losh   // UINT8               FirmwareManufacturerStr[FirmwareManufacturerStrSize];
503*1aa241b4SWarner Losh   // UINT32              FirmwareManufacturerId;
504*1aa241b4SWarner Losh   // UINT8               FirmwareVersion;
505*1aa241b4SWarner Losh   // UINT8               FirmwareVersion[FirmwareVersionSize];
506*1aa241b4SWarner Losh   //
507*1aa241b4SWarner Losh   // Below structure is newly added in TCG_Sp800_155_PlatformId_Event3
508*1aa241b4SWarner Losh   //
509*1aa241b4SWarner Losh   // UINT32              RimLocatorType;
510*1aa241b4SWarner Losh   // UINT32              RimLocatorLength;
511*1aa241b4SWarner Losh   // UINT8               RimLocator[RimLocatorLength];
512*1aa241b4SWarner Losh   // UINT32              PlatformCertLocatorType;
513*1aa241b4SWarner Losh   // UINT32              PlatformCertLocatorLength;
514*1aa241b4SWarner Losh   // UINT8               PlatformCertLocator[PlatformCertLocatorLength];
515*1aa241b4SWarner Losh } TCG_Sp800_155_PlatformId_Event3;
516*1aa241b4SWarner Losh 
517*1aa241b4SWarner Losh /**
518*1aa241b4SWarner Losh  * TCG specifies a locator type with the following values
519*1aa241b4SWarner Losh  * 0 - Raw data in the locator itself.
520*1aa241b4SWarner Losh  * 1 - URI in rtf2396 format.
521*1aa241b4SWarner Losh  * 2 - local device path in EFI_DEVICE_PATH_PROTOCOL format.
522*1aa241b4SWarner Losh  * 3 - UEFI variable (16 byte EFI_GUID, then 00-terminated UCS2 string)
523*1aa241b4SWarner Losh **/
524*1aa241b4SWarner Losh #define TCG_LOCATOR_TYPE_RAW_DATA       0
525*1aa241b4SWarner Losh #define TCG_LOCATOR_TYPE_URI            1
526*1aa241b4SWarner Losh #define TCG_LOCATOR_TYPE_DEVICE_PATH    2
527*1aa241b4SWarner Losh #define TCG_LOCATOR_TYPE_UEFI_VARIABLE  3
528*1aa241b4SWarner Losh 
529*1aa241b4SWarner Losh #define TCG_EfiStartupLocalityEvent_SIGNATURE  "StartupLocality"
530*1aa241b4SWarner Losh 
531*1aa241b4SWarner Losh //
532*1aa241b4SWarner Losh // The Locality Indicator which sent the TPM2_Startup command
533*1aa241b4SWarner Losh //
534*1aa241b4SWarner Losh #define LOCALITY_0_INDICATOR  0x00
535*1aa241b4SWarner Losh #define LOCALITY_3_INDICATOR  0x03
536*1aa241b4SWarner Losh 
537*1aa241b4SWarner Losh //
538*1aa241b4SWarner Losh // Startup Locality Event
539*1aa241b4SWarner Losh //
540*1aa241b4SWarner Losh typedef struct tdTCG_EfiStartupLocalityEvent {
541*1aa241b4SWarner Losh   UINT8    Signature[16];
542*1aa241b4SWarner Losh   //
543*1aa241b4SWarner Losh   // The Locality Indicator which sent the TPM2_Startup command
544*1aa241b4SWarner Losh   //
545*1aa241b4SWarner Losh   UINT8    StartupLocality;
546*1aa241b4SWarner Losh } TCG_EfiStartupLocalityEvent;
547*1aa241b4SWarner Losh 
548*1aa241b4SWarner Losh //
549*1aa241b4SWarner Losh // Restore original structure alignment
550*1aa241b4SWarner Losh //
551*1aa241b4SWarner Losh #pragma pack ()
552*1aa241b4SWarner Losh 
553*1aa241b4SWarner Losh //
554*1aa241b4SWarner Losh // ======================================================================================================================
555*1aa241b4SWarner Losh // Event Type                    PCR  Event Log                                   Usage
556*1aa241b4SWarner Losh // ======================================================================================================================
557*1aa241b4SWarner Losh // EV_EFI_SPDM_DEVICE_BLOB       2    SPDM_MEASUREMENT_BLOCK (subtype)            MEASUREMENT from device
558*1aa241b4SWarner Losh // EV_EFI_SPDM_DEVICE_CONFIG     3    SPDM_MEASUREMENT_BLOCK (subtype)            MEASUREMENT from device
559*1aa241b4SWarner Losh // EV_EFI_SPDM_DEVICE_BLOB       2    SPDM_MEASUREMENT_SUMMARY_HASH.TCB (subtype) SUMMARY_HASH from device
560*1aa241b4SWarner Losh 
561*1aa241b4SWarner Losh // EV_EFI_SPDM_DEVICE_POLICY     7    UEFI_VARIABLE_DATA with EFI_SIGNATURE_LIST  Provisioned device public cert.
562*1aa241b4SWarner Losh // EV_EFI_SPDM_DEVICE_AUTHORITY  7    UEFI_VARIABLE_DATA with EFI_SIGNATURE_DATA  CHALLENGE_AUTH signature verification
563*1aa241b4SWarner Losh // ======================================================================================================================
564*1aa241b4SWarner Losh //
565*1aa241b4SWarner Losh 
566*1aa241b4SWarner Losh #define PCR_INDEX_FOR_SIGNATURE_DB  7
567*1aa241b4SWarner Losh 
568*1aa241b4SWarner Losh #pragma pack(1)
569*1aa241b4SWarner Losh 
570*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_VERSION_1    1
571*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_VERSION_2    2
572*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_SIGNATURE_2  "SPDM Device Sec2"
573*1aa241b4SWarner Losh 
574*1aa241b4SWarner Losh typedef struct {
575*1aa241b4SWarner Losh   UINT8     Signature[16];
576*1aa241b4SWarner Losh   UINT16    Version;
577*1aa241b4SWarner Losh   UINT8     AuthState;
578*1aa241b4SWarner Losh   UINT8     Reserved;
579*1aa241b4SWarner Losh   UINT32    Length;                      // Length in bytes for all following structures.
580*1aa241b4SWarner Losh   UINT32    DeviceType;
581*1aa241b4SWarner Losh   UINT32    SubHeaderType;
582*1aa241b4SWarner Losh   UINT32    SubHeaderLength;                      // Length in bytes of the sub header followed by.
583*1aa241b4SWarner Losh   UINT64    SubHeaderUID;                         // Universal identifier assigned by the event log creator. It can be used to bind two sub header structure together.
584*1aa241b4SWarner Losh   // UINT64                         DevicePathLength;
585*1aa241b4SWarner Losh   // UINT8                          DevicePath[DevicePathLength];
586*1aa241b4SWarner Losh } TCG_DEVICE_SECURITY_EVENT_DATA_HEADER2;
587*1aa241b4SWarner Losh 
588*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_SUCCESS       0
589*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_NO_AUTH       1
590*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_NO_BINDING    2
591*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_FAIL_NO_SIG   3
592*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_FAIL_INVALID  4
593*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_NO_SPDM       0xFF
594*1aa241b4SWarner Losh 
595*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_SUB_HEADER_TYPE_SPDM_MEASUREMENT_BLOCK  0
596*1aa241b4SWarner Losh #define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_SUB_HEADER_TYPE_SPDM_CERT_CHAIN         1
597*1aa241b4SWarner Losh 
598*1aa241b4SWarner Losh typedef struct {
599*1aa241b4SWarner Losh   UINT16    SpdmVersion;
600*1aa241b4SWarner Losh   UINT8     SpdmMeasurementBlockCount;
601*1aa241b4SWarner Losh   UINT8     Reserved;
602*1aa241b4SWarner Losh   UINT32    SpdmMeasurementHashAlgo;
603*1aa241b4SWarner Losh   // SPDM_MEASUREMENT_BLOCK         SpdmMeasurementBlock;
604*1aa241b4SWarner Losh } TCG_DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_MEASUREMENT_BLOCK;
605*1aa241b4SWarner Losh 
606*1aa241b4SWarner Losh typedef struct {
607*1aa241b4SWarner Losh   UINT16    SpdmVersion;
608*1aa241b4SWarner Losh   UINT8     SpdmSlotId;
609*1aa241b4SWarner Losh   UINT8     Reserved;
610*1aa241b4SWarner Losh   UINT32    SpdmHashAlgo;
611*1aa241b4SWarner Losh   // SPDM_CERT_CHAIN                SpdmCertChain;
612*1aa241b4SWarner Losh } TCG_DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_CERT_CHAIN;
613*1aa241b4SWarner Losh 
614*1aa241b4SWarner Losh typedef struct {
615*1aa241b4SWarner Losh   UINT32    Type;
616*1aa241b4SWarner Losh   UINT32    Length;
617*1aa241b4SWarner Losh   UINT8     Value[1];
618*1aa241b4SWarner Losh } TCG_DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_OEM_MEASUREMENT;
619*1aa241b4SWarner Losh 
620*1aa241b4SWarner Losh typedef union {
621*1aa241b4SWarner Losh   TCG_DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_MEASUREMENT_BLOCK    SpdmMeasurementBlock;
622*1aa241b4SWarner Losh   TCG_DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_CERT_CHAIN           SpdmCertChain;
623*1aa241b4SWarner Losh   TCG_DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_OEM_MEASUREMENT           OemMeasurement;
624*1aa241b4SWarner Losh } TCG_DEVICE_SECURITY_EVENT_DATA_SUB_HEADER;
625*1aa241b4SWarner Losh 
626*1aa241b4SWarner Losh typedef union {
627*1aa241b4SWarner Losh   TCG_DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT    Pci;
628*1aa241b4SWarner Losh   TCG_DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT    Usb;
629*1aa241b4SWarner Losh } TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_CONTEXT;
630*1aa241b4SWarner Losh 
631*1aa241b4SWarner Losh typedef struct {
632*1aa241b4SWarner Losh   TCG_DEVICE_SECURITY_EVENT_DATA_HEADER2           EventDataHeader;
633*1aa241b4SWarner Losh   TCG_DEVICE_SECURITY_EVENT_DATA_SUB_HEADER        EventDataSubHeader;
634*1aa241b4SWarner Losh   TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_CONTEXT    DeviceContext;
635*1aa241b4SWarner Losh } TCG_DEVICE_SECURITY_EVENT_DATA2;
636*1aa241b4SWarner Losh 
637*1aa241b4SWarner Losh #pragma pack()
638*1aa241b4SWarner Losh 
639*1aa241b4SWarner Losh //
640*1aa241b4SWarner Losh // EventType:EV_NO_ACTION
641*1aa241b4SWarner Losh // ======================================================================================================================
642*1aa241b4SWarner Losh // NVIndex Name                                PCR/NvIndex  Event Log                            Usage
643*1aa241b4SWarner Losh // ======================================================================================================================
644*1aa241b4SWarner Losh // NV_EXTEND_INDEX_FOR_INSTANCE                0x01C40200   NV_INDEX_INSTANCE_EVENT_LOG_STRUCT   NV Extend Record for instance data (CertChain)
645*1aa241b4SWarner Losh // NV_EXTEND_INDEX_FOR_DYNAMIC                 0x01C40201   NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT    NV Extend Record for dynamic data  (Nonce)
646*1aa241b4SWarner Losh 
647*1aa241b4SWarner Losh // EVENT_LOG_INTEGRITY_NV_INDEX_EXIT_PM_AUTH   0x01C40202   EVENT_LOG_INTEGRITY_NV_INDEX_STRUCT  Event Log Integrity for ExitPmAuth
648*1aa241b4SWarner Losh // EVENT_LOG_INTEGRITY_NV_INDEX_READY_TO_BOOT  0x01C40203   EVENT_LOG_INTEGRITY_NV_INDEX_STRUCT  Event Log Integrity for ReadyToBoot
649*1aa241b4SWarner Losh // ======================================================================================================================
650*1aa241b4SWarner Losh //
651*1aa241b4SWarner Losh 
652*1aa241b4SWarner Losh #define TCG_NV_EXTEND_INDEX_FOR_INSTANCE                0x01C40200
653*1aa241b4SWarner Losh #define TCG_NV_EXTEND_INDEX_FOR_DYNAMIC                 0x01C40201
654*1aa241b4SWarner Losh #define TCG_EVENT_LOG_INTEGRITY_NV_INDEX_EXIT_PM_AUTH   0x01C40202
655*1aa241b4SWarner Losh #define TCG_EVENT_LOG_INTEGRITY_NV_INDEX_READY_TO_BOOT  0x01C40203
656*1aa241b4SWarner Losh 
657*1aa241b4SWarner Losh #pragma pack(1)
658*1aa241b4SWarner Losh 
659*1aa241b4SWarner Losh #define TCG_NV_EXTEND_INDEX_FOR_INSTANCE_SIGNATURE      "NvIndexInstance"
660*1aa241b4SWarner Losh #define TCG_NV_INDEX_INSTANCE_EVENT_LOG_STRUCT_VERSION  1
661*1aa241b4SWarner Losh 
662*1aa241b4SWarner Losh typedef struct {
663*1aa241b4SWarner Losh   UINT8     Signature[16];
664*1aa241b4SWarner Losh   UINT16    Version;
665*1aa241b4SWarner Losh   UINT8     Reserved[6];
666*1aa241b4SWarner Losh   // TCG_DEVICE_SECURITY_EVENT_DATA2  Data;
667*1aa241b4SWarner Losh } TCG_NV_INDEX_INSTANCE_EVENT_LOG_STRUCT;
668*1aa241b4SWarner Losh 
669*1aa241b4SWarner Losh #define TCG_NV_EXTEND_INDEX_FOR_DYNAMIC_SIGNATURE      "NvIndexDynamic "
670*1aa241b4SWarner Losh #define TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT_VERSION  1
671*1aa241b4SWarner Losh 
672*1aa241b4SWarner Losh #define TCG_SPDM_CHALLENGE_DESCRIPTION         "SPDM CHALLENGE"
673*1aa241b4SWarner Losh #define TCG_SPDM_CHALLENGE_AUTH_DESCRIPTION    "SPDM CHALLENGE_AUTH"
674*1aa241b4SWarner Losh #define TCG_SPDM_GET_MEASUREMENTS_DESCRIPTION  "SPDM GET_MEASUREMENTS"
675*1aa241b4SWarner Losh #define TCG_SPDM_MEASUREMENTS_DESCRIPTION      "SPDM MEASUREMENTS"
676*1aa241b4SWarner Losh 
677*1aa241b4SWarner Losh typedef struct {
678*1aa241b4SWarner Losh   UINT8     Signature[16];
679*1aa241b4SWarner Losh   UINT16    Version;
680*1aa241b4SWarner Losh   UINT8     Reserved[6];
681*1aa241b4SWarner Losh   UINT64    Uid;
682*1aa241b4SWarner Losh   // UINT16                           DescriptionSize;
683*1aa241b4SWarner Losh   // UINT8                            Description[DescriptionSize];
684*1aa241b4SWarner Losh   // UINT16                           DataSize;
685*1aa241b4SWarner Losh   // UINT8                            Data[DataSize];
686*1aa241b4SWarner Losh } TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT;
687*1aa241b4SWarner Losh 
688*1aa241b4SWarner Losh typedef struct {
689*1aa241b4SWarner Losh   TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT    Header;
690*1aa241b4SWarner Losh   UINT16                                   DescriptionSize;
691*1aa241b4SWarner Losh   UINT8                                    Description[sizeof (TCG_SPDM_CHALLENGE_DESCRIPTION)];
692*1aa241b4SWarner Losh   UINT16                                   DataSize;
693*1aa241b4SWarner Losh   UINT8                                    Data[32];
694*1aa241b4SWarner Losh } TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT_SPDM_CHALLENGE;
695*1aa241b4SWarner Losh 
696*1aa241b4SWarner Losh typedef struct {
697*1aa241b4SWarner Losh   TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT    Header;
698*1aa241b4SWarner Losh   UINT16                                   DescriptionSize;
699*1aa241b4SWarner Losh   UINT8                                    Description[sizeof (TCG_SPDM_CHALLENGE_AUTH_DESCRIPTION)];
700*1aa241b4SWarner Losh   UINT16                                   DataSize;
701*1aa241b4SWarner Losh   UINT8                                    Data[32];
702*1aa241b4SWarner Losh } TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT_SPDM_CHALLENGE_AUTH;
703*1aa241b4SWarner Losh 
704*1aa241b4SWarner Losh typedef struct {
705*1aa241b4SWarner Losh   TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT    Header;
706*1aa241b4SWarner Losh   UINT16                                   DescriptionSize;
707*1aa241b4SWarner Losh   UINT8                                    Description[sizeof (TCG_SPDM_GET_MEASUREMENTS_DESCRIPTION)];
708*1aa241b4SWarner Losh   UINT16                                   DataSize;
709*1aa241b4SWarner Losh   UINT8                                    Data[32];
710*1aa241b4SWarner Losh } TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT_SPDM_GET_MEASUREMENTS;
711*1aa241b4SWarner Losh 
712*1aa241b4SWarner Losh typedef struct {
713*1aa241b4SWarner Losh   TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT    Header;
714*1aa241b4SWarner Losh   UINT16                                   DescriptionSize;
715*1aa241b4SWarner Losh   UINT8                                    Description[sizeof (TCG_SPDM_MEASUREMENTS_DESCRIPTION)];
716*1aa241b4SWarner Losh   UINT16                                   DataSize;
717*1aa241b4SWarner Losh   UINT8                                    Data[32];
718*1aa241b4SWarner Losh } TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT_SPDM_MEASUREMENTS;
719*1aa241b4SWarner Losh 
720*1aa241b4SWarner Losh #pragma pack()
721*1aa241b4SWarner Losh 
722*1aa241b4SWarner Losh #endif
723