summaryrefslogtreecommitdiffstats
path: root/ArmPlatformPkg/PrePi
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-22 23:11:03 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-22 23:11:03 +0000
commit8fc38a3f50915b6b11b48f830f6c7b091dbb35d8 (patch)
tree459a4a3c480686413b588183f04cc312a6bbd9d0 /ArmPlatformPkg/PrePi
parent5b1928ffd6c03d171a06b89542d25ed01562c1eb (diff)
downloadedk2-8fc38a3f50915b6b11b48f830f6c7b091dbb35d8.tar.gz
edk2-8fc38a3f50915b6b11b48f830f6c7b091dbb35d8.tar.bz2
edk2-8fc38a3f50915b6b11b48f830f6c7b091dbb35d8.zip
ArmPlatformPkg: Introduce ArmPlatformGlobalVariableLib
This library hides where the 'XIP' Global Variable are located in the memory. It is expected the Sec/PrePi modules define the Global Variable area through the GlobalVariable HOB. The ArmPlatformGlobalVariableLib library allows access to global variables by their offsets in this region. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12420 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg/PrePi')
-rwxr-xr-xArmPlatformPkg/PrePi/PeiMPCore.inf4
-rwxr-xr-xArmPlatformPkg/PrePi/PeiUniCore.inf4
-rwxr-xr-xArmPlatformPkg/PrePi/PrePi.c36
3 files changed, 42 insertions, 2 deletions
diff --git a/ArmPlatformPkg/PrePi/PeiMPCore.inf b/ArmPlatformPkg/PrePi/PeiMPCore.inf
index 3b2d723c39..9d580e6cf4 100755
--- a/ArmPlatformPkg/PrePi/PeiMPCore.inf
+++ b/ArmPlatformPkg/PrePi/PeiMPCore.inf
@@ -56,6 +56,9 @@
PlatformPeiLib
MemoryInitPeiLib
+[Guids]
+ gArmGlobalVariableGuid
+
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdCacheEnable
gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob
@@ -75,7 +78,6 @@
gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize
gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize
- gArmPlatformTokenSpaceGuid.PcdHobListPtrGlobalOffset
gArmTokenSpaceGuid.PcdGicDistributorBase
gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
diff --git a/ArmPlatformPkg/PrePi/PeiUniCore.inf b/ArmPlatformPkg/PrePi/PeiUniCore.inf
index 6c13738293..515748aafa 100755
--- a/ArmPlatformPkg/PrePi/PeiUniCore.inf
+++ b/ArmPlatformPkg/PrePi/PeiUniCore.inf
@@ -54,6 +54,9 @@
PlatformPeiLib
MemoryInitPeiLib
+[Guids]
+ gArmGlobalVariableGuid
+
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdCacheEnable
gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob
@@ -72,7 +75,6 @@
gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize
gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize
- gArmPlatformTokenSpaceGuid.PcdHobListPtrGlobalOffset
gArmTokenSpaceGuid.PcdSystemMemoryBase
gArmTokenSpaceGuid.PcdSystemMemorySize
diff --git a/ArmPlatformPkg/PrePi/PrePi.c b/ArmPlatformPkg/PrePi/PrePi.c
index 2ca9c3b8fd..9fd1a27085 100755
--- a/ArmPlatformPkg/PrePi/PrePi.c
+++ b/ArmPlatformPkg/PrePi/PrePi.c
@@ -26,10 +26,17 @@
#include <Ppi/GuidedSectionExtraction.h>
#include <Guid/LzmaDecompress.h>
+#include <Guid/ArmGlobalVariableHob.h>
#include "PrePi.h"
#include "LzmaDecompress.h"
+#define IS_XIP() ((FixedPcdGet32 (PcdFdBaseAddress) > (FixedPcdGet32 (PcdSystemMemoryBase) + FixedPcdGet32 (PcdSystemMemorySize))) || \
+ ((FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) < FixedPcdGet32 (PcdSystemMemoryBase)))
+
+// Not used when PrePi in run in XIP mode
+UINTN mGlobalVariableBase = 0;
+
VOID
PrePiCommonExceptionEntry (
IN UINT32 Entry,
@@ -49,6 +56,23 @@ LzmaDecompressLibConstructor (
);
VOID
+EFIAPI
+BuildGlobalVariableHob (
+ IN EFI_PHYSICAL_ADDRESS GlobalVariableBase,
+ IN UINT32 GlobalVariableSize
+ )
+{
+ ARM_HOB_GLOBAL_VARIABLE *Hob;
+
+ Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, sizeof (ARM_HOB_GLOBAL_VARIABLE));
+ ASSERT(Hob != NULL);
+
+ CopyGuid (&(Hob->Header.Name), &gArmGlobalVariableGuid);
+ Hob->GlobalVariableBase = GlobalVariableBase;
+ Hob->GlobalVariableSize = GlobalVariableSize;
+}
+
+VOID
PrePiMain (
IN UINTN UefiMemoryBase,
IN UINTN StacksBase,
@@ -62,6 +86,11 @@ PrePiMain (
UINTN CharCount;
UINTN StacksSize;
+ // If ensure the FD is either part of the System Memory or totally outside of the System Memory (XIP)
+ ASSERT (IS_XIP() ||
+ ((FixedPcdGet32 (PcdFdBaseAddress) >= FixedPcdGet32 (PcdSystemMemoryBase)) &&
+ ((FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) <= (FixedPcdGet32 (PcdSystemMemoryBase) + FixedPcdGet32 (PcdSystemMemorySize)))));
+
// Enable program flow prediction, if supported.
ArmEnableBranchPrediction ();
@@ -77,6 +106,10 @@ PrePiMain (
// Initialize the Debug Agent for Source Level Debugging
InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, NULL, NULL);
SaveAndSetDebugTimerInterrupt (TRUE);
+
+ if (!IS_XIP()) {
+ mGlobalVariableBase = GlobalVariableBase;
+ }
// Declare the PI/UEFI memory region
HobList = HobConstructor (
@@ -95,6 +128,9 @@ PrePiMain (
StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize) + (FixedPcdGet32(PcdClusterCount) * 4 * FixedPcdGet32(PcdCPUCoreSecondaryStackSize));
BuildStackHob (StacksBase, StacksSize);
+ // Declare the Global Variable HOB
+ BuildGlobalVariableHob (GlobalVariableBase, FixedPcdGet32 (PcdPeiGlobalVariableSize));
+
// Set the Boot Mode
SetBootMode (ArmPlatformGetBootMode ());