You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UefiTcgPlatform.h 12KB

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