]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/PlatformPei/Fv.c
OvmfPkg: PlatformPei: determine the 64-bit PCI host aperture for X64 DXE
[mirror_edk2.git] / OvmfPkg / PlatformPei / Fv.c
index f9e263520858b3cc67ecf535174982d80b0cf0e3..248c58508558a2741848073776a8db3d4a17193e 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Build FV related hobs for platform.\r
 \r
-  Copyright (c) 2006 - 2010, 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
@@ -13,6 +13,7 @@
 **/\r
 \r
 #include "PiPei.h"\r
+#include "Platform.h"\r
 #include <Library/DebugLib.h>\r
 #include <Library/HobLib.h>\r
 #include <Library/PeiServicesLib.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
@@ -33,27 +32,67 @@ PeiFvInitialization (
   VOID\r
   )\r
 {\r
-  EFI_PHYSICAL_ADDRESS        FdBase;\r
+  BOOLEAN SecureS3Needed;\r
 \r
-  DEBUG ((EFI_D_ERROR, "Platform PEI Firmware Volume Initialization\n"));\r
+  DEBUG ((EFI_D_INFO, "Platform PEI Firmware Volume Initialization\n"));\r
 \r
-  DEBUG (\r
-    (EFI_D_ERROR, "Firmware Volume HOB: 0x%x 0x%x\n",\r
-      PcdGet32 (PcdOvmfMemFvBase),\r
-      PcdGet32 (PcdOvmfMemFvSize)\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
-  FdBase = PcdGet32 (PcdOvmfMemFvBase) - PcdGet32 (PcdVariableStoreSize) - PcdGet32 (PcdFlashNvStorageFtwSpareSize);\r
-  BuildFvHob (PcdGet32 (PcdOvmfMemFvBase), PcdGet32 (PcdOvmfMemFvSize));\r
+  //\r
+  // Let DXE know about the DXE FV\r
+  //\r
+  BuildFvHob (PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSize));\r
 \r
+  SecureS3Needed = mS3Supported && FeaturePcdGet (PcdSmmSmramRequire);\r
+\r
+  //\r
+  // Create a memory allocation HOB for the DXE FV.\r
   //\r
-  // Create a memory allocation HOB.\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 (PcdOvmfMemFvBase),\r
-    PcdGet32 (PcdOvmfMemFvSize),\r
-    EfiBootServicesData\r
+    PcdGet32 (PcdOvmfDxeMemFvBase),\r
+    PcdGet32 (PcdOvmfDxeMemFvSize),\r
+    SecureS3Needed ? EfiACPIMemoryNVS : EfiBootServicesData\r
+    );\r
+\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
+  //\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