]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/PlatformPei: eliminate unchecked PcdSetXX() calls
authorLaszlo Ersek <lersek@redhat.com>
Fri, 21 Oct 2016 09:59:36 +0000 (11:59 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Tue, 25 Oct 2016 08:46:22 +0000 (10:46 +0200)
These are deprecated / disabled under the
DISABLE_NEW_DEPRECATED_INTERFACES feature test macro.

Introduce a variable called PcdStatus, and use it to assert the success of
these operations (there is no reason for them to fail here).

Cc: Anthony PERARD <anthony.perard@citrix.com>
Cc: Gary Lin <glin@suse.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=166
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Gary Lin <glin@suse.com>
Tested-by: Gary Lin <glin@suse.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
OvmfPkg/PlatformPei/MemDetect.c
OvmfPkg/PlatformPei/Platform.c
OvmfPkg/PlatformPei/Xen.c

index 4863eb101067d29e899f341156f3cea06a0d5bd0..d00a570d438116320e57d2456679ad4f974b2f09 100644 (file)
@@ -107,6 +107,7 @@ GetFirstNonAddress (
   FIRMWARE_CONFIG_ITEM FwCfgItem;\r
   UINTN                FwCfgSize;\r
   UINT64               HotPlugMemoryEnd;\r
+  RETURN_STATUS        PcdStatus;\r
 \r
   FirstNonAddress = BASE_4GB + GetSystemMemorySizeAbove4gb ();\r
 \r
@@ -154,7 +155,8 @@ GetFirstNonAddress (
     if (mBootMode != BOOT_ON_S3_RESUME) {\r
       DEBUG ((EFI_D_INFO, "%a: disabling 64-bit PCI host aperture\n",\r
         __FUNCTION__));\r
-      PcdSet64 (PcdPciMmio64Size, 0);\r
+      PcdStatus = PcdSet64S (PcdPciMmio64Size, 0);\r
+      ASSERT_RETURN_ERROR (PcdStatus);\r
     }\r
 \r
     //\r
@@ -202,8 +204,11 @@ GetFirstNonAddress (
     // the GCD memory space map through our PciHostBridgeLib instance; here we\r
     // only need to set the PCDs.\r
     //\r
-    PcdSet64 (PcdPciMmio64Base, Pci64Base);\r
-    PcdSet64 (PcdPciMmio64Size, Pci64Size);\r
+    PcdStatus = PcdSet64S (PcdPciMmio64Base, Pci64Base);\r
+    ASSERT_RETURN_ERROR (PcdStatus);\r
+    PcdStatus = PcdSet64S (PcdPciMmio64Size, Pci64Size);\r
+    ASSERT_RETURN_ERROR (PcdStatus);\r
+\r
     DEBUG ((EFI_D_INFO, "%a: Pci64Base=0x%Lx Pci64Size=0x%Lx\n",\r
       __FUNCTION__, Pci64Base, Pci64Size));\r
   }\r
index ca1e6dc7e320169c1611a9de81c71e85c875fc6b..c6e1106c9ed01ef790ad9947497e9192cf34dd5a 100644 (file)
@@ -156,8 +156,9 @@ MemMapInitialization (
   VOID\r
   )\r
 {\r
-  UINT64 PciIoBase;\r
-  UINT64 PciIoSize;\r
+  UINT64        PciIoBase;\r
+  UINT64        PciIoSize;\r
+  RETURN_STATUS PcdStatus;\r
 \r
   PciIoBase = 0xC000;\r
   PciIoSize = 0x4000;\r
@@ -212,8 +213,11 @@ MemMapInitialization (
     //\r
     PciSize = 0xFC000000 - PciBase;\r
     AddIoMemoryBaseSizeHob (PciBase, PciSize);\r
-    PcdSet64 (PcdPciMmio32Base, PciBase);\r
-    PcdSet64 (PcdPciMmio32Size, PciSize);\r
+    PcdStatus = PcdSet64S (PcdPciMmio32Base, PciBase);\r
+    ASSERT_RETURN_ERROR (PcdStatus);\r
+    PcdStatus = PcdSet64S (PcdPciMmio32Size, PciSize);\r
+    ASSERT_RETURN_ERROR (PcdStatus);\r
+\r
     AddIoMemoryBaseSizeHob (0xFEC00000, SIZE_4KB);\r
     AddIoMemoryBaseSizeHob (0xFED00000, SIZE_1KB);\r
     if (mHostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) {\r
@@ -266,8 +270,10 @@ MemMapInitialization (
     PciIoBase,\r
     PciIoSize\r
     );\r
-  PcdSet64 (PcdPciIoBase, PciIoBase);\r
-  PcdSet64 (PcdPciIoSize, PciIoSize);\r
+  PcdStatus = PcdSet64S (PcdPciIoBase, PciIoBase);\r
+  ASSERT_RETURN_ERROR (PcdStatus);\r
+  PcdStatus = PcdSet64S (PcdPciIoSize, PciIoSize);\r
+  ASSERT_RETURN_ERROR (PcdStatus);\r
 }\r
 \r
 EFI_STATUS\r
@@ -316,11 +322,13 @@ GetNamedFwCfgBoolean (
 \r
 #define UPDATE_BOOLEAN_PCD_FROM_FW_CFG(TokenName)                   \\r
           do {                                                      \\r
-            BOOLEAN Setting;                                        \\r
+            BOOLEAN       Setting;                                  \\r
+            RETURN_STATUS PcdStatus;                                \\r
                                                                     \\r
             if (!EFI_ERROR (GetNamedFwCfgBoolean (                  \\r
                               "opt/ovmf/" #TokenName, &Setting))) { \\r
-              PcdSetBool (TokenName, Setting);                      \\r
+              PcdStatus = PcdSetBoolS (TokenName, Setting);         \\r
+              ASSERT_RETURN_ERROR (PcdStatus);                      \\r
             }                                                       \\r
           } while (0)\r
 \r
@@ -379,12 +387,13 @@ MiscInitialization (
   VOID\r
   )\r
 {\r
-  UINTN  PmCmd;\r
-  UINTN  Pmba;\r
-  UINT32 PmbaAndVal;\r
-  UINT32 PmbaOrVal;\r
-  UINTN  AcpiCtlReg;\r
-  UINT8  AcpiEnBit;\r
+  UINTN         PmCmd;\r
+  UINTN         Pmba;\r
+  UINT32        PmbaAndVal;\r
+  UINT32        PmbaOrVal;\r
+  UINTN         AcpiCtlReg;\r
+  UINT8         AcpiEnBit;\r
+  RETURN_STATUS PcdStatus;\r
 \r
   //\r
   // Disable A20 Mask\r
@@ -424,7 +433,8 @@ MiscInitialization (
       ASSERT (FALSE);\r
       return;\r
   }\r
-  PcdSet16 (PcdOvmfHostBridgePciDevId, mHostBridgeDevId);\r
+  PcdStatus = PcdSet16S (PcdOvmfHostBridgePciDevId, mHostBridgeDevId);\r
+  ASSERT_RETURN_ERROR (PcdStatus);\r
 \r
   //\r
   // If the appropriate IOspace enable bit is set, assume the ACPI PMBA\r
@@ -491,6 +501,7 @@ ReserveEmuVariableNvStore (
   )\r
 {\r
   EFI_PHYSICAL_ADDRESS VariableStore;\r
+  RETURN_STATUS        PcdStatus;\r
 \r
   //\r
   // Allocate storage for NV variables early on so it will be\r
@@ -509,7 +520,8 @@ ReserveEmuVariableNvStore (
           VariableStore,\r
           (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024\r
         ));\r
-  PcdSet64 (PcdEmuVariableNvStoreReserved, VariableStore);\r
+  PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);\r
+  ASSERT_RETURN_ERROR (PcdStatus);\r
 }\r
 \r
 \r
index 223908a4f529b2711609641db484a78677605471..ab38f97a67aa4a1334f4bbfd3f381718615a23d9 100644 (file)
@@ -210,6 +210,8 @@ InitializeXen (
   VOID\r
   )\r
 {\r
+  RETURN_STATUS PcdStatus;\r
+\r
   if (mXenLeaf == 0) {\r
     return EFI_NOT_FOUND;\r
   }\r
@@ -222,7 +224,8 @@ InitializeXen (
   //\r
   AddReservedMemoryBaseSizeHob (0xFC000000, 0x1000000, FALSE);\r
 \r
-  PcdSetBool (PcdPciDisableBusEnumeration, TRUE);\r
+  PcdStatus = PcdSetBoolS (PcdPciDisableBusEnumeration, TRUE);\r
+  ASSERT_RETURN_ERROR (PcdStatus);\r
 \r
   return EFI_SUCCESS;\r
 }\r