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