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