]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/NorFlashDxe: use correct PCD accessors
authorArd Biesheuvel <ard.biesheuvel@arm.com>
Mon, 11 Jan 2021 10:47:22 +0000 (11:47 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 18 Jan 2021 11:19:45 +0000 (11:19 +0000)
Commit 8015f3f6d4005d83 ("ArmPlatformPkg: Enable support for flash in
64-bit address space") updated the NorFlash DXE and StMM drivers to
take alternate PCDs into account when discovering the base of the
NOR flash regions.

This introduced a disparity between the declarations of the PCD references
in the .INF files, which permits the use of dynamic PCDs, and the code
itself, which now uses FixedPcdGet() accessors. On platforms that actually
use dynamic PCDs, this results in a build error.

So let's clean this up:
- for the DXE version, use the generic PcdGet() accessors, so dynamic PCDs
  are permitted
- for the standalone MM version, redeclare the PCDs as [FixedPcd] in the
  .INF description, and switch to the FixedPcdGet() accessors.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Vijayenthiran Subramaniam <vijayenthiran.subramaniam@arm.com>
ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c
ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf

index 28dc8e125c78786a9c92f1137370304f6be69592..f412731200cf451a48a549cd50124e16cb9441b8 100644 (file)
@@ -422,8 +422,8 @@ NorFlashFvbInitialize (
       EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  mFlashNvStorageVariableBase = (FixedPcdGet64 (PcdFlashNvStorageVariableBase64) != 0) ?\r
-    FixedPcdGet64 (PcdFlashNvStorageVariableBase64) : FixedPcdGet32 (PcdFlashNvStorageVariableBase);\r
+  mFlashNvStorageVariableBase = (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0) ?\r
+    PcdGet64 (PcdFlashNvStorageVariableBase64) : PcdGet32 (PcdFlashNvStorageVariableBase);\r
 \r
   // Set the index of the first LBA for the FVB\r
   Instance->StartLba = (mFlashNvStorageVariableBase - Instance->RegionBaseAddress) / Instance->Media.BlockSize;\r
index 8a4fb395d286d78fa60ca029c56c8abf0b2462a6..4ebbc06e1de3ef14d628a4b03fef006409cc4587 100644 (file)
@@ -299,15 +299,15 @@ NorFlashInitialise (
   for (Index = 0; Index < mNorFlashDeviceCount; Index++) {\r
     // Check if this NOR Flash device contain the variable storage region\r
 \r
-   if (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0) {\r
+   if (FixedPcdGet64 (PcdFlashNvStorageVariableBase64) != 0) {\r
      ContainVariableStorage =\r
-       (NorFlashDevices[Index].RegionBaseAddress <= PcdGet64 (PcdFlashNvStorageVariableBase64)) &&\r
-       (PcdGet64 (PcdFlashNvStorageVariableBase64) + PcdGet32 (PcdFlashNvStorageVariableSize) <=\r
+       (NorFlashDevices[Index].RegionBaseAddress <= FixedPcdGet64 (PcdFlashNvStorageVariableBase64)) &&\r
+       (FixedPcdGet64 (PcdFlashNvStorageVariableBase64) + FixedPcdGet32 (PcdFlashNvStorageVariableSize) <=\r
         NorFlashDevices[Index].RegionBaseAddress + NorFlashDevices[Index].Size);\r
    } else {\r
      ContainVariableStorage =\r
-       (NorFlashDevices[Index].RegionBaseAddress <= PcdGet32 (PcdFlashNvStorageVariableBase)) &&\r
-       (PcdGet32 (PcdFlashNvStorageVariableBase) + PcdGet32 (PcdFlashNvStorageVariableSize) <=\r
+       (NorFlashDevices[Index].RegionBaseAddress <= FixedPcdGet32 (PcdFlashNvStorageVariableBase)) &&\r
+       (FixedPcdGet32 (PcdFlashNvStorageVariableBase) + FixedPcdGet32 (PcdFlashNvStorageVariableSize) <=\r
         NorFlashDevices[Index].RegionBaseAddress + NorFlashDevices[Index].Size);\r
   }\r
 \r
index b2f72fb4de20463c7478a2424c9fb0f34fc0c8f5..56347a8bc7c167c8c4b16251d64285bf08933890 100644 (file)
@@ -49,7 +49,7 @@
 [Protocols]\r
   gEfiSmmFirmwareVolumeBlockProtocolGuid\r
 \r
-[Pcd.common]\r
+[FixedPcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
@@ -60,6 +60,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
 \r
+[FeaturePcd]\r
   gArmPlatformTokenSpaceGuid.PcdNorFlashCheckBlockLocked\r
 \r
 [Depex]\r