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