]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/PlatformPei/Fv.c
OvmfPkg/AmdSevDxe: sort #includes, and entries in INF file sections
[mirror_edk2.git] / OvmfPkg / PlatformPei / Fv.c
index 7ae35237b272ed0fe2c5409b0c41c83e0ec4d269..248c58508558a2741848073776a8db3d4a17193e 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Build FV related hobs for platform.\r
 \r
-  Copyright (c) 2006 - 2009, Intel Corporation\r
-  All rights reserved. This program and the accompanying materials\r
+  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   http://opensource.org/licenses/bsd-license.php\r
 **/\r
 \r
 #include "PiPei.h"\r
+#include "Platform.h"\r
 #include <Library/DebugLib.h>\r
-#include <Library/PeimEntryPoint.h>\r
 #include <Library/HobLib.h>\r
 #include <Library/PeiServicesLib.h>\r
-#include <Library/PeiServicesTablePointerLib.h>\r
 #include <Library/PcdLib.h>\r
 \r
 \r
 /**\r
-  Perform a call-back into the SEC simulator to get address of the Firmware Hub\r
-\r
-  @param  FfsHeader     Ffs Header availible to every PEIM\r
-  @param  PeiServices   General purpose services available to every PEIM.\r
+  Publish PEI & DXE (Decompressed) Memory based FVs to let PEI\r
+  and DXE know about them.\r
 \r
   @retval EFI_SUCCESS   Platform PEI FVs were initialized successfully.\r
 \r
@@ -35,25 +32,67 @@ PeiFvInitialization (
   VOID\r
   )\r
 {\r
-  EFI_PHYSICAL_ADDRESS FdBase;\r
+  BOOLEAN SecureS3Needed;\r
+\r
+  DEBUG ((EFI_D_INFO, "Platform PEI Firmware Volume Initialization\n"));\r
+\r
+  //\r
+  // Create a memory allocation HOB for the PEI FV.\r
+  //\r
+  // Allocate as ACPI NVS is S3 is supported\r
+  //\r
+  BuildMemoryAllocationHob (\r
+    PcdGet32 (PcdOvmfPeiMemFvBase),\r
+    PcdGet32 (PcdOvmfPeiMemFvSize),\r
+    mS3Supported ? EfiACPIMemoryNVS : EfiBootServicesData\r
+    );\r
+\r
+  //\r
+  // Let DXE know about the DXE FV\r
+  //\r
+  BuildFvHob (PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSize));\r
 \r
-  DEBUG ((EFI_D_ERROR, "Platform PEI Firmware Volume Initialization\n"));\r
+  SecureS3Needed = mS3Supported && FeaturePcdGet (PcdSmmSmramRequire);\r
 \r
-  DEBUG (\r
-    (EFI_D_ERROR, "Firmware Volume HOB: 0x%x 0x%x\n",\r
-      PcdGet32 (PcdOvmfFlashFvRecoveryBase),\r
-      PcdGet32 (PcdOvmfFlashFvRecoverySize)\r
-      )\r
+  //\r
+  // Create a memory allocation HOB for the DXE FV.\r
+  //\r
+  // If "secure" S3 is needed, then SEC will decompress both PEI and DXE\r
+  // firmware volumes at S3 resume too, hence we need to keep away the OS from\r
+  // DXEFV as well. Otherwise we only need to keep away DXE itself from the\r
+  // DXEFV area.\r
+  //\r
+  BuildMemoryAllocationHob (\r
+    PcdGet32 (PcdOvmfDxeMemFvBase),\r
+    PcdGet32 (PcdOvmfDxeMemFvSize),\r
+    SecureS3Needed ? EfiACPIMemoryNVS : EfiBootServicesData\r
     );\r
 \r
-  FdBase = PcdGet32 (PcdOvmfFlashFvRecoveryBase) - PcdGet32 (PcdVariableStoreSize) - PcdGet32 (PcdFlashNvStorageFtwSpareSize);\r
-  BuildFvHob (PcdGet32 (PcdOvmfFlashFvRecoveryBase), PcdGet32 (PcdOvmfFlashFvRecoverySize));\r
+  //\r
+  // Additionally, said decompression will use temporary memory above the end\r
+  // of DXEFV, so let's keep away the OS from there too.\r
+  //\r
+  if (SecureS3Needed) {\r
+    UINT32 DxeMemFvEnd;\r
+\r
+    DxeMemFvEnd = PcdGet32 (PcdOvmfDxeMemFvBase) +\r
+                  PcdGet32 (PcdOvmfDxeMemFvSize);\r
+    BuildMemoryAllocationHob (\r
+      DxeMemFvEnd,\r
+      PcdGet32 (PcdOvmfDecompressionScratchEnd) - DxeMemFvEnd,\r
+      EfiACPIMemoryNVS\r
+      );\r
+  }\r
 \r
-  BuildResourceDescriptorHob (\r
-    EFI_RESOURCE_FIRMWARE_DEVICE,\r
-    (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
-    FdBase,\r
-    PcdGet32 (PcdOvmfFirmwareFdSize)\r
+  //\r
+  // Let PEI know about the DXE FV so it can find the DXE Core\r
+  //\r
+  PeiServicesInstallFvInfoPpi (\r
+    NULL,\r
+    (VOID *)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase),\r
+    PcdGet32 (PcdOvmfDxeMemFvSize),\r
+    NULL,\r
+    NULL\r
     );\r
 \r
   return EFI_SUCCESS;\r