Fv.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /** @file
  2. Build FV related hobs for platform.
  3. Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include "PiPei.h"
  7. #include "Platform.h"
  8. #include <Library/DebugLib.h>
  9. #include <Library/HobLib.h>
  10. #include <Library/PcdLib.h>
  11. #include <Library/PeiServicesLib.h>
  12. /**
  13. Publish PEI & DXE (Decompressed) Memory based FVs to let PEI
  14. and DXE know about them.
  15. @retval EFI_SUCCESS Platform PEI FVs were initialized successfully.
  16. **/
  17. EFI_STATUS
  18. PeiFvInitialization (
  19. VOID
  20. )
  21. {
  22. BOOLEAN SecureS3Needed;
  23. DEBUG ((DEBUG_INFO, "Platform PEI Firmware Volume Initialization\n"));
  24. //
  25. // Create a memory allocation HOB for the PEI FV.
  26. //
  27. // Allocate as ACPI NVS is S3 is supported
  28. //
  29. BuildMemoryAllocationHob (
  30. PcdGet32 (PcdOvmfPeiMemFvBase),
  31. PcdGet32 (PcdOvmfPeiMemFvSize),
  32. mS3Supported ? EfiACPIMemoryNVS : EfiBootServicesData
  33. );
  34. //
  35. // Let DXE know about the DXE FV
  36. //
  37. BuildFvHob (PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSize));
  38. SecureS3Needed = mS3Supported && FeaturePcdGet (PcdSmmSmramRequire);
  39. //
  40. // Create a memory allocation HOB for the DXE FV.
  41. //
  42. // If "secure" S3 is needed, then SEC will decompress both PEI and DXE
  43. // firmware volumes at S3 resume too, hence we need to keep away the OS from
  44. // DXEFV as well. Otherwise we only need to keep away DXE itself from the
  45. // DXEFV area.
  46. //
  47. BuildMemoryAllocationHob (
  48. PcdGet32 (PcdOvmfDxeMemFvBase),
  49. PcdGet32 (PcdOvmfDxeMemFvSize),
  50. SecureS3Needed ? EfiACPIMemoryNVS : EfiBootServicesData
  51. );
  52. //
  53. // Additionally, said decompression will use temporary memory above the end
  54. // of DXEFV, so let's keep away the OS from there too.
  55. //
  56. if (SecureS3Needed) {
  57. UINT32 DxeMemFvEnd;
  58. DxeMemFvEnd = PcdGet32 (PcdOvmfDxeMemFvBase) +
  59. PcdGet32 (PcdOvmfDxeMemFvSize);
  60. BuildMemoryAllocationHob (
  61. DxeMemFvEnd,
  62. PcdGet32 (PcdOvmfDecompressionScratchEnd) - DxeMemFvEnd,
  63. EfiACPIMemoryNVS
  64. );
  65. }
  66. //
  67. // Let PEI know about the DXE FV so it can find the DXE Core
  68. //
  69. PeiServicesInstallFvInfoPpi (
  70. NULL,
  71. (VOID *)(UINTN)PcdGet32 (PcdOvmfDxeMemFvBase),
  72. PcdGet32 (PcdOvmfDxeMemFvSize),
  73. NULL,
  74. NULL
  75. );
  76. return EFI_SUCCESS;
  77. }