iPXE
UefiTcgPlatform.h
Go to the documentation of this file.
00001 /** @file
00002   TCG EFI Platform Definition in TCG_EFI_Platform_1_20_Final
00003 
00004   Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
00005   This program and the accompanying materials
00006   are licensed and made available under the terms and conditions of the BSD License
00007   which accompanies this distribution.  The full text of the license may be found at
00008   http://opensource.org/licenses/bsd-license.php
00009 
00010   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
00011   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
00012 
00013 **/
00014 
00015 #ifndef __UEFI_TCG_PLATFORM_H__
00016 #define __UEFI_TCG_PLATFORM_H__
00017 
00018 FILE_LICENCE ( BSD3 );
00019 
00020 #include <ipxe/efi/IndustryStandard/Tpm12.h>
00021 #include <ipxe/efi/IndustryStandard/Tpm20.h>
00022 #include <ipxe/efi/Uefi.h>
00023 
00024 //
00025 // Standard event types
00026 //
00027 #define EV_POST_CODE                ((TCG_EVENTTYPE) 0x00000001)
00028 #define EV_NO_ACTION                ((TCG_EVENTTYPE) 0x00000003)
00029 #define EV_SEPARATOR                ((TCG_EVENTTYPE) 0x00000004)
00030 #define EV_S_CRTM_CONTENTS          ((TCG_EVENTTYPE) 0x00000007)
00031 #define EV_S_CRTM_VERSION           ((TCG_EVENTTYPE) 0x00000008)
00032 #define EV_CPU_MICROCODE            ((TCG_EVENTTYPE) 0x00000009)
00033 #define EV_TABLE_OF_DEVICES         ((TCG_EVENTTYPE) 0x0000000B)
00034 
00035 //
00036 // EFI specific event types
00037 //
00038 #define EV_EFI_EVENT_BASE                   ((TCG_EVENTTYPE) 0x80000000)
00039 #define EV_EFI_VARIABLE_DRIVER_CONFIG       (EV_EFI_EVENT_BASE + 1)
00040 #define EV_EFI_VARIABLE_BOOT                (EV_EFI_EVENT_BASE + 2)
00041 #define EV_EFI_BOOT_SERVICES_APPLICATION    (EV_EFI_EVENT_BASE + 3)
00042 #define EV_EFI_BOOT_SERVICES_DRIVER         (EV_EFI_EVENT_BASE + 4)
00043 #define EV_EFI_RUNTIME_SERVICES_DRIVER      (EV_EFI_EVENT_BASE + 5)
00044 #define EV_EFI_GPT_EVENT                    (EV_EFI_EVENT_BASE + 6)
00045 #define EV_EFI_ACTION                       (EV_EFI_EVENT_BASE + 7)
00046 #define EV_EFI_PLATFORM_FIRMWARE_BLOB       (EV_EFI_EVENT_BASE + 8)
00047 #define EV_EFI_HANDOFF_TABLES               (EV_EFI_EVENT_BASE + 9)
00048 #define EV_EFI_VARIABLE_AUTHORITY           (EV_EFI_EVENT_BASE + 0xE0)
00049 
00050 #define EFI_CALLING_EFI_APPLICATION         \
00051   "Calling EFI Application from Boot Option"
00052 #define EFI_RETURNING_FROM_EFI_APPLICATOIN  \
00053   "Returning from EFI Application from Boot Option"
00054 #define EFI_EXIT_BOOT_SERVICES_INVOCATION   \
00055   "Exit Boot Services Invocation"
00056 #define EFI_EXIT_BOOT_SERVICES_FAILED       \
00057   "Exit Boot Services Returned with Failure"
00058 #define EFI_EXIT_BOOT_SERVICES_SUCCEEDED    \
00059   "Exit Boot Services Returned with Success"
00060 
00061 
00062 #define EV_POSTCODE_INFO_POST_CODE    "POST CODE"
00063 #define POST_CODE_STR_LEN             (sizeof(EV_POSTCODE_INFO_POST_CODE) - 1)
00064 
00065 #define EV_POSTCODE_INFO_SMM_CODE     "SMM CODE"
00066 #define SMM_CODE_STR_LEN              (sizeof(EV_POSTCODE_INFO_SMM_CODE) - 1)
00067 
00068 #define EV_POSTCODE_INFO_ACPI_DATA    "ACPI DATA"
00069 #define ACPI_DATA_LEN                 (sizeof(EV_POSTCODE_INFO_ACPI_DATA) - 1)
00070 
00071 #define EV_POSTCODE_INFO_BIS_CODE     "BIS CODE"
00072 #define BIS_CODE_LEN                  (sizeof(EV_POSTCODE_INFO_BIS_CODE) - 1)
00073 
00074 #define EV_POSTCODE_INFO_UEFI_PI      "UEFI PI"
00075 #define UEFI_PI_LEN                   (sizeof(EV_POSTCODE_INFO_UEFI_PI) - 1)
00076 
00077 #define EV_POSTCODE_INFO_OPROM        "Embedded Option ROM"
00078 #define OPROM_LEN                     (sizeof(EV_POSTCODE_INFO_OPROM) - 1)
00079 
00080 #define FIRMWARE_DEBUGGER_EVENT_STRING      "UEFI Debug Mode"
00081 #define FIRMWARE_DEBUGGER_EVENT_STRING_LEN  (sizeof(FIRMWARE_DEBUGGER_EVENT_STRING) - 1)
00082 
00083 //
00084 // Set structure alignment to 1-byte
00085 //
00086 #pragma pack (1)
00087 
00088 typedef UINT32                     TCG_EVENTTYPE;
00089 typedef TPM_PCRINDEX               TCG_PCRINDEX;
00090 typedef TPM_DIGEST                 TCG_DIGEST;
00091 ///
00092 /// Event Log Entry Structure Definition
00093 ///
00094 typedef struct tdTCG_PCR_EVENT {
00095   TCG_PCRINDEX                      PCRIndex;  ///< PCRIndex event extended to
00096   TCG_EVENTTYPE                     EventType; ///< TCG EFI event type
00097   TCG_DIGEST                        Digest;    ///< Value extended into PCRIndex
00098   UINT32                            EventSize; ///< Size of the event data
00099   UINT8                             Event[1];  ///< The event data
00100 } TCG_PCR_EVENT;
00101 
00102 #define TSS_EVENT_DATA_MAX_SIZE   256
00103 
00104 ///
00105 /// TCG_PCR_EVENT_HDR
00106 ///
00107 typedef struct tdTCG_PCR_EVENT_HDR {
00108   TCG_PCRINDEX                      PCRIndex;
00109   TCG_EVENTTYPE                     EventType;
00110   TCG_DIGEST                        Digest;
00111   UINT32                            EventSize;
00112 } TCG_PCR_EVENT_HDR;
00113 
00114 ///
00115 /// EFI_PLATFORM_FIRMWARE_BLOB
00116 ///
00117 /// BlobLength should be of type UINTN but we use UINT64 here
00118 /// because PEI is 32-bit while DXE is 64-bit on x64 platforms
00119 ///
00120 typedef struct tdEFI_PLATFORM_FIRMWARE_BLOB {
00121   EFI_PHYSICAL_ADDRESS              BlobBase;
00122   UINT64                            BlobLength;
00123 } EFI_PLATFORM_FIRMWARE_BLOB;
00124 
00125 ///
00126 /// EFI_IMAGE_LOAD_EVENT
00127 ///
00128 /// This structure is used in EV_EFI_BOOT_SERVICES_APPLICATION,
00129 /// EV_EFI_BOOT_SERVICES_DRIVER and EV_EFI_RUNTIME_SERVICES_DRIVER
00130 ///
00131 typedef struct tdEFI_IMAGE_LOAD_EVENT {
00132   EFI_PHYSICAL_ADDRESS              ImageLocationInMemory;
00133   UINTN                             ImageLengthInMemory;
00134   UINTN                             ImageLinkTimeAddress;
00135   UINTN                             LengthOfDevicePath;
00136   EFI_DEVICE_PATH_PROTOCOL          DevicePath[1];
00137 } EFI_IMAGE_LOAD_EVENT;
00138 
00139 ///
00140 /// EFI_HANDOFF_TABLE_POINTERS
00141 ///
00142 /// This structure is used in EV_EFI_HANDOFF_TABLES event to facilitate
00143 /// the measurement of given configuration tables.
00144 ///
00145 typedef struct tdEFI_HANDOFF_TABLE_POINTERS {
00146   UINTN                             NumberOfTables;
00147   EFI_CONFIGURATION_TABLE           TableEntry[1];
00148 } EFI_HANDOFF_TABLE_POINTERS;
00149 
00150 ///
00151 /// EFI_VARIABLE_DATA
00152 ///
00153 /// This structure serves as the header for measuring variables. The name of the
00154 /// variable (in Unicode format) should immediately follow, then the variable
00155 /// data.
00156 /// This is defined in TCG EFI Platform Spec for TPM1.1 or 1.2 V1.22
00157 ///
00158 typedef struct tdEFI_VARIABLE_DATA {
00159   EFI_GUID                          VariableName;
00160   UINTN                             UnicodeNameLength;
00161   UINTN                             VariableDataLength;
00162   CHAR16                            UnicodeName[1];
00163   INT8                              VariableData[1];  ///< Driver or platform-specific data
00164 } EFI_VARIABLE_DATA;
00165 
00166 ///
00167 /// UEFI_VARIABLE_DATA
00168 ///
00169 /// This structure serves as the header for measuring variables. The name of the
00170 /// variable (in Unicode format) should immediately follow, then the variable
00171 /// data.
00172 /// This is defined in TCG PC Client Firmware Profile Spec 00.21
00173 ///
00174 typedef struct tdUEFI_VARIABLE_DATA {
00175   EFI_GUID                          VariableName;
00176   UINT64                            UnicodeNameLength;
00177   UINT64                            VariableDataLength;
00178   CHAR16                            UnicodeName[1];
00179   INT8                              VariableData[1];  ///< Driver or platform-specific data
00180 } UEFI_VARIABLE_DATA;
00181 
00182 //
00183 // For TrEE1.0 compatibility
00184 //
00185 typedef struct {
00186   EFI_GUID                          VariableName;
00187   UINT64                            UnicodeNameLength;   // The TCG Definition used UINTN
00188   UINT64                            VariableDataLength;  // The TCG Definition used UINTN
00189   CHAR16                            UnicodeName[1];
00190   INT8                              VariableData[1];
00191 } EFI_VARIABLE_DATA_TREE;
00192 
00193 typedef struct tdEFI_GPT_DATA {
00194   EFI_PARTITION_TABLE_HEADER  EfiPartitionHeader;
00195   UINTN                       NumberOfPartitions;
00196   EFI_PARTITION_ENTRY         Partitions[1];
00197 } EFI_GPT_DATA;
00198 
00199 //
00200 // Crypto Agile Log Entry Format
00201 //
00202 typedef struct tdTCG_PCR_EVENT2 {
00203   TCG_PCRINDEX        PCRIndex;
00204   TCG_EVENTTYPE       EventType;
00205   TPML_DIGEST_VALUES  Digest;
00206   UINT32              EventSize;
00207   UINT8               Event[1];
00208 } TCG_PCR_EVENT2;
00209 
00210 //
00211 // TCG PCR Event2 Header
00212 // Follow TCG EFI Protocol Spec 5.2 Crypto Agile Log Entry Format
00213 //
00214 typedef struct tdTCG_PCR_EVENT2_HDR{
00215   TCG_PCRINDEX        PCRIndex;
00216   TCG_EVENTTYPE       EventType;
00217   TPML_DIGEST_VALUES  Digests;
00218   UINT32              EventSize;
00219 } TCG_PCR_EVENT2_HDR;
00220 
00221 //
00222 // Log Header Entry Data
00223 //
00224 typedef struct {
00225   //
00226   // TCG defined hashing algorithm ID.
00227   //
00228   UINT16              algorithmId;
00229   //
00230   // The size of the digest for the respective hashing algorithm.
00231   //
00232   UINT16              digestSize;
00233 } TCG_EfiSpecIdEventAlgorithmSize;
00234 
00235 #define TCG_EfiSpecIDEventStruct_SIGNATURE_02 "Spec ID Event02"
00236 #define TCG_EfiSpecIDEventStruct_SIGNATURE_03 "Spec ID Event03"
00237 
00238 #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MAJOR_TPM12   1
00239 #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MINOR_TPM12   2
00240 #define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM12          2
00241 
00242 #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MAJOR_TPM2   2
00243 #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MINOR_TPM2   0
00244 #define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2          0
00245 
00246 typedef struct {
00247   UINT8               signature[16];
00248   //
00249   // The value for the Platform Class.
00250   // The enumeration is defined in the TCG ACPI Specification Client Common Header.
00251   //
00252   UINT32              platformClass;
00253   //
00254   // The TCG EFI Platform Specification minor version number this BIOS supports.
00255   // Any BIOS supporting version (1.22) MUST set this value to 02h.
00256   // Any BIOS supporting version (2.0) SHALL set this value to 0x00.
00257   //
00258   UINT8               specVersionMinor;
00259   //
00260   // The TCG EFI Platform Specification major version number this BIOS supports.
00261   // Any BIOS supporting version (1.22) MUST set this value to 01h.
00262   // Any BIOS supporting version (2.0) SHALL set this value to 0x02.
00263   //
00264   UINT8               specVersionMajor;
00265   //
00266   // The TCG EFI Platform Specification errata for this specification this BIOS supports.
00267   // Any BIOS supporting version and errata (1.22) MUST set this value to 02h.
00268   // Any BIOS supporting version and errata (2.0) SHALL set this value to 0x00.
00269   //
00270   UINT8               specErrata;
00271   //
00272   // Specifies the size of the UINTN fields used in various data structures used in this specification.
00273   // 0x01 indicates UINT32 and 0x02 indicates UINT64.
00274   //
00275   UINT8               uintnSize;
00276   //
00277   // This field is added in "Spec ID Event03".
00278   // The number of hashing algorithms used in this event log (except the first event).
00279   // All events in this event log use all hashing algorithms defined here.
00280   //
00281 //UINT32              numberOfAlgorithms;
00282   //
00283   // This field is added in "Spec ID Event03".
00284   // An array of size numberOfAlgorithms of value pairs.
00285   //
00286 //TCG_EfiSpecIdEventAlgorithmSize digestSize[numberOfAlgorithms];
00287   //
00288   // Size in bytes of the VendorInfo field.
00289   // Maximum value SHALL be FFh bytes.
00290   //
00291 //UINT8               vendorInfoSize;
00292   //
00293   // Provided for use by the BIOS implementer.
00294   // The value might be used, for example, to provide more detailed information about the specific BIOS such as BIOS revision numbers, etc.
00295   // The values within this field are not standardized and are implementer-specific.
00296   // Platform-specific or -unique information SHALL NOT be provided in this field.
00297   //
00298 //UINT8               vendorInfo[vendorInfoSize];
00299 } TCG_EfiSpecIDEventStruct;
00300 
00301 
00302 
00303 #define TCG_EfiStartupLocalityEvent_SIGNATURE      "StartupLocality"
00304 
00305 
00306 //
00307 // PC Client PTP spec Table 8 Relationship between Locality and Locality Attribute
00308 //
00309 #define LOCALITY_0_INDICATOR        0x01
00310 #define LOCALITY_1_INDICATOR        0x02
00311 #define LOCALITY_2_INDICATOR        0x03
00312 #define LOCALITY_3_INDICATOR        0x04
00313 #define LOCALITY_4_INDICATOR        0x05
00314 
00315 
00316 //
00317 // Startup Locality Event
00318 //
00319 typedef struct tdTCG_EfiStartupLocalityEvent{
00320   UINT8       Signature[16];
00321   //
00322   // The Locality Indicator which sent the TPM2_Startup command
00323   //
00324   UINT8       StartupLocality;
00325 } TCG_EfiStartupLocalityEvent;
00326 
00327 
00328 //
00329 // Restore original structure alignment
00330 //
00331 #pragma pack ()
00332 
00333 #endif
00334 
00335