diff mbox

[edk2,v2,09/29] ArmPlatformPkg/PrePi: allow use of patchable PCDs

Message ID 1422299011-2409-10-git-send-email-ard.biesheuvel@linaro.org
State New
Headers show

Commit Message

Ard Biesheuvel Jan. 26, 2015, 7:03 p.m. UTC
Avoid using FixedPcdGetXX () to reference system memory and FD
base address PCDs so that the platform can choose to use patchable
PCDs instead. This allows a runtime self-relocating PrePi to poke
alternate values into them that can only be discovered at runtime.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S | 8 ++++----
 ArmPlatformPkg/PrePi/PrePi.c                    | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

Comments

Ard Biesheuvel Jan. 28, 2015, 4:59 p.m. UTC | #1
On 28 January 2015 at 15:28, Olivier Martin <olivier.martin@arm.com> wrote:
> Reviewed-By: Olivier Martin <Olivier.martin@arm.com>
>

Looking at these patches again, it might make sense to replace #9, #10
and #11 with a single patch that introduces RelocatablePrePi under
ArmVirtualizationPkg with these changes already applied. That way, we
adhere to the single .inf per directory rule and not affect any
existing platforms with changes that are irrelevant to them.


>> -----Original Message-----
>> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> Sent: 26 January 2015 19:03
>> To: edk2-devel@lists.sourceforge.net; lersek@redhat.com; Olivier
>> Martin; roy.franz@linaro.org; leif.lindholm@linaro.org;
>> stefano.stabellini@eu.citrix.com; Ian.Campbell@citrix.com;
>> anthony.perard@citrix.com; christoffer.dall@linaro.org; xen-
>> devel@lists.xen.org; ilias.biris@linaro.org
>> Cc: Ard Biesheuvel
>> Subject: [PATCH v2 09/29] ArmPlatformPkg/PrePi: allow use of patchable
>> PCDs
>>
>> Avoid using FixedPcdGetXX () to reference system memory and FD
>> base address PCDs so that the platform can choose to use patchable
>> PCDs instead. This allows a runtime self-relocating PrePi to poke
>> alternate values into them that can only be discovered at runtime.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> ---
>>  ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S | 8 ++++----
>>  ArmPlatformPkg/PrePi/PrePi.c                    | 8 ++++----
>>  2 files changed, 8 insertions(+), 8 deletions(-)
>>
>> diff --git a/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
>> b/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
>> index fcea9496cbd5..3fa6bf1f0322 100644
>> --- a/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
>> +++ b/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
>> @@ -42,14 +42,14 @@ _SetSVCMode:
>>  // at the top of the DRAM)
>>  _SetupStackPosition:
>>    // Compute Top of System Memory
>> -  LoadConstantToReg (FixedPcdGet64 (PcdSystemMemoryBase), x1)
>> -  LoadConstantToReg (FixedPcdGet64 (PcdSystemMemorySize), x2)
>> +  ldr   x1, PcdGet64 (PcdSystemMemoryBase)
>> +  ldr   x2, PcdGet64 (PcdSystemMemorySize)
>>    sub   x2, x2, #1
>>    add   x1, x1, x2      // x1 = SystemMemoryTop = PcdSystemMemoryBase
>> + PcdSystemMemorySize
>>
>>    // Calculate Top of the Firmware Device
>> -  LoadConstantToReg (FixedPcdGet32(PcdFdBaseAddress), x2)
>> -  LoadConstantToReg (FixedPcdGet32(PcdFdSize), x3)
>> +  ldr   x2, PcdGet64 (PcdFdBaseAddress)
>> +  ldr   w3, PcdGet32 (PcdFdSize)
>>    sub   x3, x3, #1
>>    add   x3, x3, x2      // x3 = FdTop = PcdFdBaseAddress + PcdFdSize
>>
>> diff --git a/ArmPlatformPkg/PrePi/PrePi.c
>> b/ArmPlatformPkg/PrePi/PrePi.c
>> index 9a5e067ef537..0e551c518d6b 100755
>> --- a/ArmPlatformPkg/PrePi/PrePi.c
>> +++ b/ArmPlatformPkg/PrePi/PrePi.c
>> @@ -30,8 +30,8 @@
>>  #include "PrePi.h"
>>  #include "LzmaDecompress.h"
>>
>> -#define IS_XIP() (((UINT32)FixedPcdGet32 (PcdFdBaseAddress) >
>> (UINT32)(FixedPcdGet64 (PcdSystemMemoryBase) + FixedPcdGet32
>> (PcdSystemMemorySize))) || \
>> -                  ((FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32
>> (PcdFdSize)) < FixedPcdGet64 (PcdSystemMemoryBase)))
>> +#define IS_XIP() (((UINT32)PcdGet64 (PcdFdBaseAddress) >
>> (UINT32)(PcdGet64 (PcdSystemMemoryBase) + PcdGet64
>> (PcdSystemMemorySize))) || \
>> +                  ((PcdGet64 (PcdFdBaseAddress) + PcdGet32
>> (PcdFdSize)) < PcdGet64 (PcdSystemMemoryBase)))
>>
>>  // Not used when PrePi in run in XIP mode
>>  UINTN mGlobalVariableBase = 0;
>> @@ -108,8 +108,8 @@ PrePiMain (
>>
>>    // If ensure the FD is either part of the System Memory or totally
>> outside of the System Memory (XIP)
>>    ASSERT (IS_XIP() ||
>> -          ((FixedPcdGet32 (PcdFdBaseAddress) >= FixedPcdGet64
>> (PcdSystemMemoryBase)) &&
>> -           ((UINT32)(FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32
>> (PcdFdSize)) <= (UINT32)(FixedPcdGet64 (PcdSystemMemoryBase) +
>> FixedPcdGet64 (PcdSystemMemorySize)))));
>> +          ((PcdGet64 (PcdFdBaseAddress) >= PcdGet64
>> (PcdSystemMemoryBase)) &&
>> +           ((UINT32)(PcdGet64 (PcdFdBaseAddress) + PcdGet32
>> (PcdFdSize)) <= (UINT32)(PcdGet64 (PcdSystemMemoryBase) + PcdGet64
>> (PcdSystemMemorySize)))));
>>
>>    // Initialize the architecture specific bits
>>    ArchInitialize ();
>> --
>> 1.8.3.2
>>
>
>
>
>

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
diff mbox

Patch

diff --git a/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S b/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
index fcea9496cbd5..3fa6bf1f0322 100644
--- a/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
+++ b/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
@@ -42,14 +42,14 @@  _SetSVCMode:
 // at the top of the DRAM)
 _SetupStackPosition:
   // Compute Top of System Memory
-  LoadConstantToReg (FixedPcdGet64 (PcdSystemMemoryBase), x1)
-  LoadConstantToReg (FixedPcdGet64 (PcdSystemMemorySize), x2)
+  ldr   x1, PcdGet64 (PcdSystemMemoryBase)
+  ldr   x2, PcdGet64 (PcdSystemMemorySize)
   sub   x2, x2, #1
   add   x1, x1, x2      // x1 = SystemMemoryTop = PcdSystemMemoryBase + PcdSystemMemorySize
 
   // Calculate Top of the Firmware Device
-  LoadConstantToReg (FixedPcdGet32(PcdFdBaseAddress), x2)
-  LoadConstantToReg (FixedPcdGet32(PcdFdSize), x3)
+  ldr   x2, PcdGet64 (PcdFdBaseAddress)
+  ldr   w3, PcdGet32 (PcdFdSize)
   sub   x3, x3, #1
   add   x3, x3, x2      // x3 = FdTop = PcdFdBaseAddress + PcdFdSize
 
diff --git a/ArmPlatformPkg/PrePi/PrePi.c b/ArmPlatformPkg/PrePi/PrePi.c
index 9a5e067ef537..0e551c518d6b 100755
--- a/ArmPlatformPkg/PrePi/PrePi.c
+++ b/ArmPlatformPkg/PrePi/PrePi.c
@@ -30,8 +30,8 @@ 
 #include "PrePi.h"
 #include "LzmaDecompress.h"
 
-#define IS_XIP() (((UINT32)FixedPcdGet32 (PcdFdBaseAddress) > (UINT32)(FixedPcdGet64 (PcdSystemMemoryBase) + FixedPcdGet32 (PcdSystemMemorySize))) || \
-                  ((FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) < FixedPcdGet64 (PcdSystemMemoryBase)))
+#define IS_XIP() (((UINT32)PcdGet64 (PcdFdBaseAddress) > (UINT32)(PcdGet64 (PcdSystemMemoryBase) + PcdGet64 (PcdSystemMemorySize))) || \
+                  ((PcdGet64 (PcdFdBaseAddress) + PcdGet32 (PcdFdSize)) < PcdGet64 (PcdSystemMemoryBase)))
 
 // Not used when PrePi in run in XIP mode
 UINTN mGlobalVariableBase = 0;
@@ -108,8 +108,8 @@  PrePiMain (
 
   // If ensure the FD is either part of the System Memory or totally outside of the System Memory (XIP)
   ASSERT (IS_XIP() ||
-          ((FixedPcdGet32 (PcdFdBaseAddress) >= FixedPcdGet64 (PcdSystemMemoryBase)) &&
-           ((UINT32)(FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) <= (UINT32)(FixedPcdGet64 (PcdSystemMemoryBase) + FixedPcdGet64 (PcdSystemMemorySize)))));
+          ((PcdGet64 (PcdFdBaseAddress) >= PcdGet64 (PcdSystemMemoryBase)) &&
+           ((UINT32)(PcdGet64 (PcdFdBaseAddress) + PcdGet32 (PcdFdSize)) <= (UINT32)(PcdGet64 (PcdSystemMemoryBase) + PcdGet64 (PcdSystemMemorySize)))));
 
   // Initialize the architecture specific bits
   ArchInitialize ();