]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/PlatformPei/Platform.c
OvmfPkg: Create GHCB pages for use during Pei and Dxe phase
[mirror_edk2.git] / OvmfPkg / PlatformPei / Platform.c
index 510d6d7477ecbf2a80f33a9a2d1e3d6cf67e5ef2..96468701e3b8c5f474526a4c51f6cc2e8d7599b4 100644 (file)
@@ -27,8 +27,8 @@
 #include <Library/PeiServicesLib.h>\r
 #include <Library/QemuFwCfgLib.h>\r
 #include <Library/QemuFwCfgS3Lib.h>\r
+#include <Library/QemuFwCfgSimpleParserLib.h>\r
 #include <Library/ResourcePublicationLib.h>\r
-#include <Guid/MemoryTypeInformation.h>\r
 #include <Ppi/MasterBootMode.h>\r
 #include <IndustryStandard/I440FxPiix4.h>\r
 #include <IndustryStandard/Pci22.h>\r
 #include "Platform.h"\r
 #include "Cmos.h"\r
 \r
-EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = {\r
-  { EfiACPIMemoryNVS,       0x004 },\r
-  { EfiACPIReclaimMemory,   0x008 },\r
-  { EfiReservedMemoryType,  0x004 },\r
-  { EfiRuntimeServicesData, 0x024 },\r
-  { EfiRuntimeServicesCode, 0x030 },\r
-  { EfiBootServicesCode,    0x180 },\r
-  { EfiBootServicesData,    0xF00 },\r
-  { EfiMaxMemoryType,       0x000 }\r
-};\r
-\r
-\r
 EFI_PEI_PPI_DESCRIPTOR   mPpiBootMode[] = {\r
   {\r
     EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
@@ -162,15 +150,6 @@ MemMapInitialization (
   PciIoBase = 0xC000;\r
   PciIoSize = 0x4000;\r
 \r
-  //\r
-  // Create Memory Type Information HOB\r
-  //\r
-  BuildGuidDataHob (\r
-    &gEfiMemoryTypeInformationGuid,\r
-    mDefaultMemoryTypeInformation,\r
-    sizeof(mDefaultMemoryTypeInformation)\r
-    );\r
-\r
   //\r
   // Video memory + Legacy BIOS region\r
   //\r
@@ -276,56 +255,12 @@ MemMapInitialization (
   ASSERT_RETURN_ERROR (PcdStatus);\r
 }\r
 \r
-EFI_STATUS\r
-GetNamedFwCfgBoolean (\r
-  IN  CHAR8   *FwCfgFileName,\r
-  OUT BOOLEAN *Setting\r
-  )\r
-{\r
-  EFI_STATUS           Status;\r
-  FIRMWARE_CONFIG_ITEM FwCfgItem;\r
-  UINTN                FwCfgSize;\r
-  UINT8                Value[3];\r
-\r
-  Status = QemuFwCfgFindFile (FwCfgFileName, &FwCfgItem, &FwCfgSize);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  if (FwCfgSize > sizeof Value) {\r
-    return EFI_BAD_BUFFER_SIZE;\r
-  }\r
-  QemuFwCfgSelectItem (FwCfgItem);\r
-  QemuFwCfgReadBytes (FwCfgSize, Value);\r
-\r
-  if ((FwCfgSize == 1) ||\r
-      (FwCfgSize == 2 && Value[1] == '\n') ||\r
-      (FwCfgSize == 3 && Value[1] == '\r' && Value[2] == '\n')) {\r
-    switch (Value[0]) {\r
-      case '0':\r
-      case 'n':\r
-      case 'N':\r
-        *Setting = FALSE;\r
-        return EFI_SUCCESS;\r
-\r
-      case '1':\r
-      case 'y':\r
-      case 'Y':\r
-        *Setting = TRUE;\r
-        return EFI_SUCCESS;\r
-\r
-      default:\r
-        break;\r
-    }\r
-  }\r
-  return EFI_PROTOCOL_ERROR;\r
-}\r
-\r
 #define UPDATE_BOOLEAN_PCD_FROM_FW_CFG(TokenName)                   \\r
           do {                                                      \\r
             BOOLEAN       Setting;                                  \\r
             RETURN_STATUS PcdStatus;                                \\r
                                                                     \\r
-            if (!EFI_ERROR (GetNamedFwCfgBoolean (                  \\r
+            if (!RETURN_ERROR (QemuFwCfgParseBool (                 \\r
                               "opt/ovmf/" #TokenName, &Setting))) { \\r
               PcdStatus = PcdSetBoolS (TokenName, Setting);         \\r
               ASSERT_RETURN_ERROR (PcdStatus);                      \\r
@@ -337,7 +272,6 @@ NoexecDxeInitialization (
   VOID\r
   )\r
 {\r
-  UPDATE_BOOLEAN_PCD_FROM_FW_CFG (PcdPropertiesTableEnable);\r
   UPDATE_BOOLEAN_PCD_FROM_FW_CFG (PcdSetNxForStack);\r
 }\r
 \r
@@ -428,7 +362,7 @@ MiscInitialization (
       AcpiEnBit  = ICH9_ACPI_CNTL_ACPI_EN;\r
       break;\r
     default:\r
-      DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",\r
+      DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",\r
         __FUNCTION__, mHostBridgeDevId));\r
       ASSERT (FALSE);\r
       return;\r
@@ -514,7 +448,7 @@ ReserveEmuVariableNvStore (
       AllocateRuntimePages (\r
         EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize))\r
         );\r
-  DEBUG ((EFI_D_INFO,\r
+  DEBUG ((DEBUG_INFO,\r
           "Reserved variable store memory: 0x%lX; size: %dkb\n",\r
           VariableStore,\r
           (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024\r
@@ -531,15 +465,15 @@ DebugDumpCmos (
 {\r
   UINT32 Loop;\r
 \r
-  DEBUG ((EFI_D_INFO, "CMOS:\n"));\r
+  DEBUG ((DEBUG_INFO, "CMOS:\n"));\r
 \r
   for (Loop = 0; Loop < 0x80; Loop++) {\r
     if ((Loop % 0x10) == 0) {\r
-      DEBUG ((EFI_D_INFO, "%02x:", Loop));\r
+      DEBUG ((DEBUG_INFO, "%02x:", Loop));\r
     }\r
-    DEBUG ((EFI_D_INFO, " %02x", CmosRead8 (Loop)));\r
+    DEBUG ((DEBUG_INFO, " %02x", CmosRead8 (Loop)));\r
     if ((Loop % 0x10) == 0xf) {\r
-      DEBUG ((EFI_D_INFO, "\n"));\r
+      DEBUG ((DEBUG_INFO, "\n"));\r
     }\r
   }\r
 }\r
@@ -552,12 +486,12 @@ S3Verification (
 {\r
 #if defined (MDE_CPU_X64)\r
   if (FeaturePcdGet (PcdSmmSmramRequire) && mS3Supported) {\r
-    DEBUG ((EFI_D_ERROR,\r
+    DEBUG ((DEBUG_ERROR,\r
       "%a: S3Resume2Pei doesn't support X64 PEI + SMM yet.\n", __FUNCTION__));\r
-    DEBUG ((EFI_D_ERROR,\r
+    DEBUG ((DEBUG_ERROR,\r
       "%a: Please disable S3 on the QEMU command line (see the README),\n",\r
       __FUNCTION__));\r
-    DEBUG ((EFI_D_ERROR,\r
+    DEBUG ((DEBUG_ERROR,\r
       "%a: or build OVMF with \"OvmfPkgIa32X64.dsc\".\n", __FUNCTION__));\r
     ASSERT (FALSE);\r
     CpuDeadLoop ();\r
@@ -772,7 +706,7 @@ InitializePlatform (
   XenDetect ();\r
 \r
   if (QemuFwCfgS3Enabled ()) {\r
-    DEBUG ((EFI_D_INFO, "S3 support was detected on QEMU\n"));\r
+    DEBUG ((DEBUG_INFO, "S3 support was detected on QEMU\n"));\r
     mS3Supported = TRUE;\r
     Status = PcdSetBoolS (PcdAcpiS3Enable, TRUE);\r
     ASSERT_EFI_ERROR (Status);\r
@@ -792,6 +726,7 @@ InitializePlatform (
   if (FeaturePcdGet (PcdSmmSmramRequire)) {\r
     Q35BoardVerification ();\r
     Q35TsegMbytesInitialization ();\r
+    Q35SmramAtDefaultSmbaseInitialization ();\r
   }\r
 \r
   PublishPeiMemory ();\r
@@ -801,7 +736,7 @@ InitializePlatform (
   InitializeRamRegions ();\r
 \r
   if (mXen) {\r
-    DEBUG ((EFI_D_INFO, "Xen was detected\n"));\r
+    DEBUG ((DEBUG_INFO, "Xen was detected\n"));\r
     InitializeXen ();\r
   }\r
 \r
@@ -810,6 +745,7 @@ InitializePlatform (
       ReserveEmuVariableNvStore ();\r
     }\r
     PeiFvInitialization ();\r
+    MemTypeInfoInitialization ();\r
     MemMapInitialization ();\r
     NoexecDxeInitialization ();\r
   }\r