BiosInfo.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /** @file
  2. Driver for BIOS Info support.
  3. @copyright
  4. Copyright 2011 - 2021 Intel Corporation.
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include <PiPei.h>
  8. #include <BiosInfo.h>
  9. #include <Library/PeiServicesLib.h>
  10. #include <Library/BaseMemoryLib.h>
  11. #include <Library/DebugLib.h>
  12. #include <Library/HobLib.h>
  13. #include <Library/PcdLib.h>
  14. #include <IndustryStandard/FirmwareInterfaceTable.h>
  15. GLOBAL_REMOVE_IF_UNREFERENCED BIOS_INFO mBiosInfo = {
  16. {
  17. BIOS_INFO_SIGNATURE,
  18. BIOS_INFO_STRUCT_SIZE,
  19. 0,
  20. },
  21. {
  22. {
  23. FIT_TYPE_07_BIOS_STARTUP_MODULE,
  24. BIOS_INFO_STRUCT_ATTRIBUTE_GENERAL_EXCLUDE_FROM_FIT,
  25. 0x0100,
  26. FixedPcdGet32 (PcdFlashNvStorageVariableSize) + FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize),
  27. FixedPcdGet32 (PcdFlashNvStorageVariableBase)
  28. },
  29. {
  30. FIT_TYPE_07_BIOS_STARTUP_MODULE,
  31. 0,
  32. 0x0100,
  33. FixedPcdGet32 (PcdFlashFvPreMemorySize),
  34. FixedPcdGet32 (PcdFlashFvPreMemoryBase)
  35. },
  36. {
  37. FIT_TYPE_07_BIOS_STARTUP_MODULE,
  38. 0,
  39. 0x0100,
  40. FixedPcdGet32 (PcdFlashFvFspMSize),
  41. FixedPcdGet32 (PcdFlashFvFspMBase)
  42. },
  43. {
  44. FIT_TYPE_01_MICROCODE,
  45. BIOS_INFO_STRUCT_ATTRIBUTE_MICROCODE_WHOLE_REGION,
  46. 0x0100,
  47. FixedPcdGet32 (PcdFlashNvStorageMicrocodeSize),
  48. FixedPcdGet32 (PcdFlashNvStorageMicrocodeBase)
  49. },
  50. }
  51. };
  52. GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR mBiosInfoPpiList = {
  53. EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
  54. &gBiosInfoGuid,
  55. &mBiosInfo
  56. };
  57. /**
  58. Installs BiosInfo Ppi.
  59. @param FileHandle Handle of the file being invoked.
  60. @param PeiServices Describes the list of possible PEI Services.
  61. @retval EFI_SUCCESS Install the BiosInfo Ppi successfully.
  62. **/
  63. EFI_STATUS
  64. EFIAPI
  65. BiosInfoEntryPoint (
  66. IN EFI_PEI_FILE_HANDLE FileHandle,
  67. IN CONST EFI_PEI_SERVICES **PeiServices
  68. )
  69. {
  70. EFI_STATUS Status;
  71. VOID *HobData;
  72. //
  73. // Install PPI, so that other PEI module can add dependency.
  74. //
  75. Status = PeiServicesInstallPpi (&mBiosInfoPpiList);
  76. ASSERT_EFI_ERROR (Status);
  77. if (EFI_ERROR(Status)) {
  78. return Status;
  79. }
  80. //
  81. // Build hob, so that DXE module can also get the data.
  82. //
  83. HobData = BuildGuidHob (&gBiosInfoGuid, sizeof (BIOS_INFO));
  84. ASSERT (HobData != NULL);
  85. if (HobData == NULL) {
  86. return EFI_OUT_OF_RESOURCES;
  87. }
  88. CopyMem (HobData, &mBiosInfo, sizeof (BIOS_INFO));
  89. return EFI_SUCCESS;
  90. }