ArmPlatformPkg/PrePi: Make dynamic the top of the System Memory

This change allows to change the top of the System Memory that
was hardcoded by:
FixedPcdGet64 (PcdSystemMemoryBase) + FixedPcdGet64 (PcdSystemMemorySize)

It allows to add support when the Trusted Firmware reserves the
top of the System Memory as Trusted. The size of this region
might not be known in advance.

Note: The reason why the start of the System Memory has not been
made dynamic is because the early code calculates where to place
the stack from the top of the System Memory.
So there is no need to make the start of the System Memory a
dynamic value at the early stage of the boot phase.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <Olivier.Martin@arm.com>
Reviewed-by: Ronald Cron <Ronald.Cron@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17835 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Olivier Martin
2015-07-06 16:56:31 +00:00
committed by oliviermartin
parent 40a3f38f67
commit 5dbacdb21b
7 changed files with 72 additions and 31 deletions

View File

@@ -1,6 +1,6 @@
/** @file
*
* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -19,7 +19,9 @@
#include <Library/PcdLib.h>
#include <Library/DebugLib.h>
#define IS_XIP() (((UINT32)PcdGet64 (PcdFdBaseAddress) > (UINT32)(PcdGet64 (PcdSystemMemoryBase) + PcdGet64 (PcdSystemMemorySize))) || \
extern UINT64 mSystemMemoryEnd;
#define IS_XIP() (((UINT32)PcdGet64 (PcdFdBaseAddress) > (UINT32)(mSystemMemoryEnd)) || \
((PcdGet64 (PcdFdBaseAddress) + PcdGet32 (PcdFdSize)) < PcdGet64 (PcdSystemMemoryBase)))
// Declared by ArmPlatformPkg/PrePi Module
@@ -40,7 +42,7 @@ ArmPlatformGetGlobalVariable (
if (IS_XIP()) {
// In Case of XIP, we expect the Primary Stack at the top of the System Memory
// The size must be 64bit aligned to allow 64bit variable to be aligned
GlobalVariableBase = PcdGet64 (PcdSystemMemoryBase) + PcdGet64 (PcdSystemMemorySize) - ALIGN_VALUE(PcdGet32 (PcdPeiGlobalVariableSize),0x8);
GlobalVariableBase = mSystemMemoryEnd + 1 - ALIGN_VALUE (PcdGet32 (PcdPeiGlobalVariableSize), 0x8);
} else {
GlobalVariableBase = mGlobalVariableBase;
}
@@ -69,7 +71,7 @@ ArmPlatformSetGlobalVariable (
if (IS_XIP()) {
// In Case of XIP, we expect the Primary Stack at the top of the System Memory
// The size must be 64bit aligned to allow 64bit variable to be aligned
GlobalVariableBase = PcdGet64 (PcdSystemMemoryBase) + PcdGet64 (PcdSystemMemorySize) - ALIGN_VALUE(PcdGet32 (PcdPeiGlobalVariableSize),0x8);
GlobalVariableBase = mSystemMemoryEnd + 1 - ALIGN_VALUE (PcdGet32 (PcdPeiGlobalVariableSize), 0x8);
} else {
GlobalVariableBase = mGlobalVariableBase;
}
@@ -96,7 +98,7 @@ ArmPlatformGetGlobalVariableAddress (
if (IS_XIP()) {
// In Case of XIP, we expect the Primary Stack at the top of the System Memory
// The size must be 64bit aligned to allow 64bit variable to be aligned
GlobalVariableBase = PcdGet64 (PcdSystemMemoryBase) + PcdGet64 (PcdSystemMemorySize) - ALIGN_VALUE(PcdGet32 (PcdPeiGlobalVariableSize),0x8);
GlobalVariableBase = mSystemMemoryEnd + 1 - ALIGN_VALUE (PcdGet32 (PcdPeiGlobalVariableSize), 0x8);
} else {
GlobalVariableBase = mGlobalVariableBase;
}