BiosInfo.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /** @file
  2. Driver for BIOS Info support.
  3. Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <PiPei.h>
  7. #include <Guid/BiosInfo.h>
  8. #include <Library/PeiServicesLib.h>
  9. #include <Library/BaseMemoryLib.h>
  10. #include <Library/DebugLib.h>
  11. #include <Library/HobLib.h>
  12. #include <Library/PcdLib.h>
  13. #include <IndustryStandard/FirmwareInterfaceTable.h>
  14. #include <Ppi/FirmwareVolumeInfoMeasurementExcluded.h>
  15. #include <Library/MemoryAllocationLib.h>
  16. #define BASE_FV_SIZE 10
  17. #define FSP_WRAPPER_FV_SIZE 3
  18. #define TSN_MAC_ADDRESS_FV_SIZE 0
  19. #define BIOS_INFO_STRUCT_SIZE (BASE_FV_SIZE + FSP_WRAPPER_FV_SIZE + TSN_MAC_ADDRESS_FV_SIZE)
  20. /*
  21. BIOS_INFO structure is the base of the firmware volume layout for Intel platform BIOS implementation
  22. so security checker module can run based on the structure and throw warnings, error or deadloop
  23. when any unexpected firmware volumes are detected.
  24. BIOS_INFO is recommended to support full entries of firmware volumes present in a flash
  25. with right type, attribute, version, flash map base address and size,
  26. all associated information which is defined by BIOS_INFO_STRUCT structure.
  27. - IBB firmware volumes, which are expected to be measured or/and verified
  28. by hardware base security solution to meet SecureBoot chain of trust
  29. (Intel BootGuard for example), have attribute 0x0.
  30. - Post IBB firmware volumes, which are expected to be measured or/and verified
  31. by BIOS (TCG code for measurement, RSA2048SHA256Sign algorithm for verification for example),
  32. have attribute BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB.
  33. - Else, follows Firmware Interface Table specification.
  34. */
  35. #pragma pack (1)
  36. typedef struct {
  37. BIOS_INFO_HEADER Header;
  38. BIOS_INFO_STRUCT Entry[BIOS_INFO_STRUCT_SIZE];
  39. } BIOS_INFO;
  40. #pragma pack ()
  41. GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO mBiosInfo = {
  42. {
  43. BIOS_INFO_SIGNATURE,
  44. BIOS_INFO_STRUCT_SIZE,
  45. 0,
  46. },
  47. {
  48. {
  49. FIT_TYPE_07_BIOS_STARTUP_MODULE,
  50. BIOS_INFO_STRUCT_ATTRIBUTE_GENERAL_EXCLUDE_FROM_FIT,
  51. 0x0100,
  52. FixedPcdGet32 (PcdFlashNvStorageVariableSize) + FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize),
  53. FixedPcdGet32 (PcdFlashNvStorageVariableBase)
  54. },
  55. {
  56. FIT_TYPE_07_BIOS_STARTUP_MODULE,
  57. BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
  58. 0x0100,
  59. FixedPcdGet32 (PcdFlashFvAdvancedSize),
  60. FixedPcdGet32 (PcdFlashFvAdvancedBase)
  61. },
  62. {
  63. FIT_TYPE_07_BIOS_STARTUP_MODULE,
  64. BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
  65. 0x0100,
  66. FixedPcdGet32 (PcdFlashFvOptionalSize),
  67. FixedPcdGet32 (PcdFlashFvOptionalBase)
  68. },
  69. {
  70. FIT_TYPE_07_BIOS_STARTUP_MODULE,
  71. BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
  72. 0x0100,
  73. FixedPcdGet32 (PcdFlashFvOsBootSize),
  74. FixedPcdGet32 (PcdFlashFvOsBootBase)
  75. },
  76. {
  77. FIT_TYPE_07_BIOS_STARTUP_MODULE,
  78. BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
  79. 0x0100,
  80. FixedPcdGet32 (PcdFlashFvUefiBootSize),
  81. FixedPcdGet32 (PcdFlashFvUefiBootBase)
  82. },
  83. {
  84. FIT_TYPE_07_BIOS_STARTUP_MODULE,
  85. BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
  86. 0x0100,
  87. FixedPcdGet32 (PcdFlashFvPostMemorySize),
  88. FixedPcdGet32 (PcdFlashFvPostMemoryBase)
  89. },
  90. {
  91. /*
  92. Note :
  93. Startup ACM is one of the binaries in FvFirmwareBinaries,
  94. so put type 07 but not type 02.
  95. FIT table will contain a type 02 entry with actual address
  96. of ACM binary (it is passed as an input to FitGen tool).
  97. */
  98. FIT_TYPE_07_BIOS_STARTUP_MODULE,
  99. BIOS_INFO_STRUCT_ATTRIBUTE_GENERAL_EXCLUDE_FROM_FIT,
  100. 0x0100,
  101. FixedPcdGet32 (PcdFlashFvFirmwareBinariesSize),
  102. FixedPcdGet32 (PcdFlashFvFirmwareBinariesBase)
  103. },
  104. {
  105. FIT_TYPE_07_BIOS_STARTUP_MODULE,
  106. BIOS_INFO_STRUCT_ATTRIBUTE_BIOS_POST_IBB,
  107. 0x0100,
  108. FixedPcdGet32 (PcdFlashFvFspSSize),
  109. FixedPcdGet32 (PcdFlashFvFspSBase)
  110. },
  111. {
  112. FIT_TYPE_07_BIOS_STARTUP_MODULE,
  113. 0x00, // IBB FV
  114. 0x0100,
  115. FixedPcdGet32 (PcdFlashFvFspMSize),
  116. FixedPcdGet32 (PcdFlashFvFspMBase)
  117. },
  118. {
  119. FIT_TYPE_07_BIOS_STARTUP_MODULE,
  120. 0x00, // IBB FV
  121. 0x0100,
  122. FixedPcdGet32 (PcdFlashFvFspTSize),
  123. FixedPcdGet32 (PcdFlashFvFspTBase)
  124. },
  125. {
  126. FIT_TYPE_07_BIOS_STARTUP_MODULE,
  127. 0x00, // IBB FV
  128. 0x0100,
  129. FixedPcdGet32 (PcdFlashFvSecuritySize),
  130. FixedPcdGet32 (PcdFlashFvSecurityBase)
  131. },
  132. {
  133. FIT_TYPE_07_BIOS_STARTUP_MODULE,
  134. 0x00, // IBB FV
  135. 0x0100,
  136. FixedPcdGet32 (PcdFlashFvPreMemorySize),
  137. FixedPcdGet32 (PcdFlashFvPreMemoryBase)
  138. },
  139. {
  140. FIT_TYPE_01_MICROCODE,
  141. BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION,
  142. 0x0100,
  143. FixedPcdGet32 (PcdFlashMicrocodeFvSize),
  144. FixedPcdGet32 (PcdFlashMicrocodeFvBase)
  145. },
  146. }
  147. };
  148. GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR mBiosInfoPpiList = {
  149. EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
  150. &gBiosInfoGuid,
  151. &mBiosInfo
  152. };
  153. /**
  154. Installs BiosInfo Ppi.
  155. @param FileHandle Handle of the file being invoked.
  156. @param PeiServices Describes the list of possible PEI Services.
  157. @retval EFI_SUCCESS Install the BiosInfo Ppi successfully.
  158. **/
  159. EFI_STATUS
  160. EFIAPI
  161. BiosInfoEntryPoint (
  162. IN EFI_PEI_FILE_HANDLE FileHandle,
  163. IN CONST EFI_PEI_SERVICES **PeiServices
  164. )
  165. {
  166. EFI_STATUS Status;
  167. VOID *HobData;
  168. //
  169. // Install PPI, so that other PEI module can add dependency.
  170. //
  171. Status = PeiServicesInstallPpi (&mBiosInfoPpiList);
  172. ASSERT_EFI_ERROR (Status);
  173. //
  174. // Build hob, so that DXE module can also get the data.
  175. //
  176. HobData = BuildGuidHob (&gBiosInfoGuid, sizeof (mBiosInfo));
  177. ASSERT (HobData != NULL);
  178. if (HobData == NULL) {
  179. return EFI_OUT_OF_RESOURCES;
  180. }
  181. CopyMem (HobData, &mBiosInfo, sizeof (mBiosInfo));
  182. return EFI_SUCCESS;
  183. }