Home | History | Annotate | Download | only in IndustryStandard
      1 /** @file
      2   TCG EFI Platform Definition in TCG_EFI_Platform_1_20_Final
      3 
      4   Copyright (c) 2006 - 2015, 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_POST_CODE                ((TCG_EVENTTYPE) 0x00000001)
     26 #define EV_NO_ACTION                ((TCG_EVENTTYPE) 0x00000003)
     27 #define EV_SEPARATOR                ((TCG_EVENTTYPE) 0x00000004)
     28 #define EV_S_CRTM_CONTENTS          ((TCG_EVENTTYPE) 0x00000007)
     29 #define EV_S_CRTM_VERSION           ((TCG_EVENTTYPE) 0x00000008)
     30 #define EV_CPU_MICROCODE            ((TCG_EVENTTYPE) 0x00000009)
     31 #define EV_TABLE_OF_DEVICES         ((TCG_EVENTTYPE) 0x0000000B)
     32 
     33 //
     34 // EFI specific event types
     35 //
     36 #define EV_EFI_EVENT_BASE                   ((TCG_EVENTTYPE) 0x80000000)
     37 #define EV_EFI_VARIABLE_DRIVER_CONFIG       (EV_EFI_EVENT_BASE + 1)
     38 #define EV_EFI_VARIABLE_BOOT                (EV_EFI_EVENT_BASE + 2)
     39 #define EV_EFI_BOOT_SERVICES_APPLICATION    (EV_EFI_EVENT_BASE + 3)
     40 #define EV_EFI_BOOT_SERVICES_DRIVER         (EV_EFI_EVENT_BASE + 4)
     41 #define EV_EFI_RUNTIME_SERVICES_DRIVER      (EV_EFI_EVENT_BASE + 5)
     42 #define EV_EFI_GPT_EVENT                    (EV_EFI_EVENT_BASE + 6)
     43 #define EV_EFI_ACTION                       (EV_EFI_EVENT_BASE + 7)
     44 #define EV_EFI_PLATFORM_FIRMWARE_BLOB       (EV_EFI_EVENT_BASE + 8)
     45 #define EV_EFI_HANDOFF_TABLES               (EV_EFI_EVENT_BASE + 9)
     46 #define EV_EFI_VARIABLE_AUTHORITY           (EV_EFI_EVENT_BASE + 0xE0)
     47 
     48 #define EFI_CALLING_EFI_APPLICATION         \
     49   "Calling EFI Application from Boot Option"
     50 #define EFI_RETURNING_FROM_EFI_APPLICATOIN  \
     51   "Returning from EFI Application from Boot Option"
     52 #define EFI_EXIT_BOOT_SERVICES_INVOCATION   \
     53   "Exit Boot Services Invocation"
     54 #define EFI_EXIT_BOOT_SERVICES_FAILED       \
     55   "Exit Boot Services Returned with Failure"
     56 #define EFI_EXIT_BOOT_SERVICES_SUCCEEDED    \
     57   "Exit Boot Services Returned with Success"
     58 
     59 
     60 #define EV_POSTCODE_INFO_POST_CODE    "POST CODE"
     61 #define POST_CODE_STR_LEN             (sizeof(EV_POSTCODE_INFO_POST_CODE) - 1)
     62 
     63 #define EV_POSTCODE_INFO_SMM_CODE     "SMM CODE"
     64 #define SMM_CODE_STR_LEN              (sizeof(EV_POSTCODE_INFO_SMM_CODE) - 1)
     65 
     66 #define EV_POSTCODE_INFO_ACPI_DATA    "ACPI DATA"
     67 #define ACPI_DATA_LEN                 (sizeof(EV_POSTCODE_INFO_ACPI_DATA) - 1)
     68 
     69 #define EV_POSTCODE_INFO_BIS_CODE     "BIS CODE"
     70 #define BIS_CODE_LEN                  (sizeof(EV_POSTCODE_INFO_BIS_CODE) - 1)
     71 
     72 #define EV_POSTCODE_INFO_UEFI_PI      "UEFI PI"
     73 #define UEFI_PI_LEN                   (sizeof(EV_POSTCODE_INFO_UEFI_PI) - 1)
     74 
     75 #define EV_POSTCODE_INFO_OPROM        "Embedded Option ROM"
     76 #define OPROM_LEN                     (sizeof(EV_POSTCODE_INFO_OPROM) - 1)
     77 
     78 #define FIRMWARE_DEBUGGER_EVENT_STRING      "UEFI Debug Mode"
     79 #define FIRMWARE_DEBUGGER_EVENT_STRING_LEN  (sizeof(FIRMWARE_DEBUGGER_EVENT_STRING) - 1)
     80 
     81 //
     82 // Set structure alignment to 1-byte
     83 //
     84 #pragma pack (1)
     85 
     86 typedef UINT32                     TCG_EVENTTYPE;
     87 typedef TPM_PCRINDEX               TCG_PCRINDEX;
     88 typedef TPM_DIGEST                 TCG_DIGEST;
     89 ///
     90 /// Event Log Entry Structure Definition
     91 ///
     92 typedef struct tdTCG_PCR_EVENT {
     93   TCG_PCRINDEX                      PCRIndex;  ///< PCRIndex event extended to
     94   TCG_EVENTTYPE                     EventType; ///< TCG EFI event type
     95   TCG_DIGEST                        Digest;    ///< Value extended into PCRIndex
     96   UINT32                            EventSize; ///< Size of the event data
     97   UINT8                             Event[1];  ///< The event data
     98 } TCG_PCR_EVENT;
     99 
    100 #define TSS_EVENT_DATA_MAX_SIZE   256
    101 
    102 ///
    103 /// TCG_PCR_EVENT_HDR
    104 ///
    105 typedef struct tdTCG_PCR_EVENT_HDR {
    106   TCG_PCRINDEX                      PCRIndex;
    107   TCG_EVENTTYPE                     EventType;
    108   TCG_DIGEST                        Digest;
    109   UINT32                            EventSize;
    110 } TCG_PCR_EVENT_HDR;
    111 
    112 ///
    113 /// EFI_PLATFORM_FIRMWARE_BLOB
    114 ///
    115 /// BlobLength should be of type UINTN but we use UINT64 here
    116 /// because PEI is 32-bit while DXE is 64-bit on x64 platforms
    117 ///
    118 typedef struct tdEFI_PLATFORM_FIRMWARE_BLOB {
    119   EFI_PHYSICAL_ADDRESS              BlobBase;
    120   UINT64                            BlobLength;
    121 } EFI_PLATFORM_FIRMWARE_BLOB;
    122 
    123 ///
    124 /// EFI_IMAGE_LOAD_EVENT
    125 ///
    126 /// This structure is used in EV_EFI_BOOT_SERVICES_APPLICATION,
    127 /// EV_EFI_BOOT_SERVICES_DRIVER and EV_EFI_RUNTIME_SERVICES_DRIVER
    128 ///
    129 typedef struct tdEFI_IMAGE_LOAD_EVENT {
    130   EFI_PHYSICAL_ADDRESS              ImageLocationInMemory;
    131   UINTN                             ImageLengthInMemory;
    132   UINTN                             ImageLinkTimeAddress;
    133   UINTN                             LengthOfDevicePath;
    134   EFI_DEVICE_PATH_PROTOCOL          DevicePath[1];
    135 } EFI_IMAGE_LOAD_EVENT;
    136 
    137 ///
    138 /// EFI_HANDOFF_TABLE_POINTERS
    139 ///
    140 /// This structure is used in EV_EFI_HANDOFF_TABLES event to facilitate
    141 /// the measurement of given configuration tables.
    142 ///
    143 typedef struct tdEFI_HANDOFF_TABLE_POINTERS {
    144   UINTN                             NumberOfTables;
    145   EFI_CONFIGURATION_TABLE           TableEntry[1];
    146 } EFI_HANDOFF_TABLE_POINTERS;
    147 
    148 ///
    149 /// EFI_VARIABLE_DATA
    150 ///
    151 /// This structure serves as the header for measuring variables. The name of the
    152 /// variable (in Unicode format) should immediately follow, then the variable
    153 /// data.
    154 ///
    155 typedef struct tdEFI_VARIABLE_DATA {
    156   EFI_GUID                          VariableName;
    157   UINTN                             UnicodeNameLength;
    158   UINTN                             VariableDataLength;
    159   CHAR16                            UnicodeName[1];
    160   INT8                              VariableData[1];  ///< Driver or platform-specific data
    161 } EFI_VARIABLE_DATA;
    162 
    163 //
    164 // For TrEE1.0 compatibility
    165 //
    166 typedef struct {
    167   EFI_GUID                          VariableName;
    168   UINT64                            UnicodeNameLength;   // The TCG Definition used UINTN
    169   UINT64                            VariableDataLength;  // The TCG Definition used UINTN
    170   CHAR16                            UnicodeName[1];
    171   INT8                              VariableData[1];
    172 } EFI_VARIABLE_DATA_TREE;
    173 
    174 typedef struct tdEFI_GPT_DATA {
    175   EFI_PARTITION_TABLE_HEADER  EfiPartitionHeader;
    176   UINTN                       NumberOfPartitions;
    177   EFI_PARTITION_ENTRY         Partitions[1];
    178 } EFI_GPT_DATA;
    179 
    180 //
    181 // Crypto Agile Log Entry Format
    182 //
    183 typedef struct tdTCG_PCR_EVENT2 {
    184   TCG_PCRINDEX        PCRIndex;
    185   TCG_EVENTTYPE       EventType;
    186   TPML_DIGEST_VALUES  Digest;
    187   UINT32              EventSize;
    188   UINT8               Event[1];
    189 } TCG_PCR_EVENT2;
    190 
    191 //
    192 // Log Header Entry Data
    193 //
    194 typedef struct {
    195   //
    196   // TCG defined hashing algorithm ID.
    197   //
    198   UINT16              algorithmId;
    199   //
    200   // The size of the digest for the respective hashing algorithm.
    201   //
    202   UINT16              digestSize;
    203 } TCG_EfiSpecIdEventAlgorithmSize;
    204 
    205 #define TCG_EfiSpecIDEventStruct_SIGNATURE_02 "Spec ID Event02"
    206 #define TCG_EfiSpecIDEventStruct_SIGNATURE_03 "Spec ID Event03"
    207 
    208 #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MAJOR_TPM12   1
    209 #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MINOR_TPM12   2
    210 #define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM12          2
    211 
    212 #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MAJOR_TPM2   2
    213 #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MINOR_TPM2   0
    214 #define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2          0
    215 
    216 typedef struct {
    217   UINT8               signature[16];
    218   //
    219   // The value for the Platform Class.
    220   // The enumeration is defined in the TCG ACPI Specification Client Common Header.
    221   //
    222   UINT32              platformClass;
    223   //
    224   // The TCG EFI Platform Specification minor version number this BIOS supports.
    225   // Any BIOS supporting version (1.22) MUST set this value to 02h.
    226   // Any BIOS supporting version (2.0) SHALL set this value to 0x00.
    227   //
    228   UINT8               specVersionMinor;
    229   //
    230   // The TCG EFI Platform Specification major version number this BIOS supports.
    231   // Any BIOS supporting version (1.22) MUST set this value to 01h.
    232   // Any BIOS supporting version (2.0) SHALL set this value to 0x02.
    233   //
    234   UINT8               specVersionMajor;
    235   //
    236   // The TCG EFI Platform Specification errata for this specification this BIOS supports.
    237   // Any BIOS supporting version and errata (1.22) MUST set this value to 02h.
    238   // Any BIOS supporting version and errata (2.0) SHALL set this value to 0x00.
    239   //
    240   UINT8               specErrata;
    241   //
    242   // Specifies the size of the UINTN fields used in various data structures used in this specification.
    243   // 0x01 indicates UINT32 and 0x02 indicates UINT64.
    244   //
    245   UINT8               uintnSize;
    246   //
    247   // This field is added in "Spec ID Event03".
    248   // The number of hashing algorithms used in this event log (except the first event).
    249   // All events in this event log use all hashing algorithms defined here.
    250   //
    251 //UINT32              numberOfAlgorithms;
    252   //
    253   // This field is added in "Spec ID Event03".
    254   // An array of size numberOfAlgorithms of value pairs.
    255   //
    256 //TCG_EfiSpecIdEventAlgorithmSize digestSize[numberOfAlgorithms];
    257   //
    258   // Size in bytes of the VendorInfo field.
    259   // Maximum value SHALL be FFh bytes.
    260   //
    261 //UINT8               vendorInfoSize;
    262   //
    263   // Provided for use by the BIOS implementer.
    264   // The value might be used, for example, to provide more detailed information about the specific BIOS such as BIOS revision numbers, etc.
    265   // The values within this field are not standardized and are implementer-specific.
    266   // Platform-specific or -unique information SHALL NOT be provided in this field.
    267   //
    268 //UINT8               vendorInfo[vendorInfoSize];
    269 } TCG_EfiSpecIDEventStruct;
    270 
    271 //
    272 // Restore original structure alignment
    273 //
    274 #pragma pack ()
    275 
    276 #endif
    277 
    278 
    279