summaryrefslogtreecommitdiffstats
path: root/ArmPlatformPkg/PrePeiCore
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2012-02-27 10:27:10 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2012-02-27 10:27:10 +0000
commit3222e7b1efc5e01eb17fdacbb1979733e4f25b6a (patch)
tree13a63b6ff6df7924fc4701e6374a8f521e3c69b0 /ArmPlatformPkg/PrePeiCore
parent782d45d1e3a6b7439985f2bbef333e4d2ec32960 (diff)
downloadedk2-3222e7b1efc5e01eb17fdacbb1979733e4f25b6a.tar.gz
edk2-3222e7b1efc5e01eb17fdacbb1979733e4f25b6a.tar.bz2
edk2-3222e7b1efc5e01eb17fdacbb1979733e4f25b6a.zip
ArmPlatformPkg/PrePeiCore: Ensured the size is 8-byte aligned
Once divided by 2, the size should be 4-byte aligned to ensure the stack pointer is 4-byte aligned. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13044 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg/PrePeiCore')
-rw-r--r--ArmPlatformPkg/PrePeiCore/MainMPCore.c10
-rw-r--r--ArmPlatformPkg/PrePeiCore/MainUniCore.c10
2 files changed, 14 insertions, 6 deletions
diff --git a/ArmPlatformPkg/PrePeiCore/MainMPCore.c b/ArmPlatformPkg/PrePeiCore/MainMPCore.c
index 75b8bb3713..a98d560133 100644
--- a/ArmPlatformPkg/PrePeiCore/MainMPCore.c
+++ b/ArmPlatformPkg/PrePeiCore/MainMPCore.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2012, 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
@@ -124,6 +124,10 @@ PrimaryMain (
TemporaryRamBase = (UINTN)PcdGet32 (PcdCPUCoresStackBase) + PpiListSize;
TemporaryRamSize = (UINTN)PcdGet32 (PcdCPUCorePrimaryStackSize) - PpiListSize;
+ // Make sure the size is 8-byte aligned. Once divided by 2, the size should be 4-byte aligned
+ // to ensure the stack pointer is 4-byte aligned.
+ TemporaryRamSize = TemporaryRamSize - (TemporaryRamSize & (0x8-1));
+
//
// Bind this information into the SEC hand-off state
// Note: this must be in sync with the stuff in the asm file
@@ -136,8 +140,8 @@ PrimaryMain (
SecCoreData.TemporaryRamSize = TemporaryRamSize;
SecCoreData.PeiTemporaryRamBase = SecCoreData.TemporaryRamBase;
SecCoreData.PeiTemporaryRamSize = SecCoreData.TemporaryRamSize / 2;
- SecCoreData.StackBase = (VOID *)((UINTN)(SecCoreData.TemporaryRamBase) + (SecCoreData.TemporaryRamSize/2));
- SecCoreData.StackSize = SecCoreData.TemporaryRamSize / 2;
+ SecCoreData.StackBase = (VOID *)ALIGN_VALUE((UINTN)(SecCoreData.TemporaryRamBase) + SecCoreData.PeiTemporaryRamSize, 0x4);
+ SecCoreData.StackSize = (TemporaryRamBase + TemporaryRamSize) - (UINTN)SecCoreData.StackBase;
// Jump to PEI core entry point
(PeiCoreEntryPoint)(&SecCoreData, PpiList);
diff --git a/ArmPlatformPkg/PrePeiCore/MainUniCore.c b/ArmPlatformPkg/PrePeiCore/MainUniCore.c
index 65682b155d..b437ad6510 100644
--- a/ArmPlatformPkg/PrePeiCore/MainUniCore.c
+++ b/ArmPlatformPkg/PrePeiCore/MainUniCore.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2012, 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
@@ -43,6 +43,10 @@ PrimaryMain (
TemporaryRamBase = (UINTN)PcdGet32 (PcdCPUCoresStackBase) + PpiListSize;
TemporaryRamSize = (UINTN)PcdGet32 (PcdCPUCorePrimaryStackSize) - PpiListSize;
+ // Make sure the size is 8-byte aligned. Once divided by 2, the size should be 4-byte aligned
+ // to ensure the stack pointer is 4-byte aligned.
+ TemporaryRamSize = TemporaryRamSize - (TemporaryRamSize & (0x8-1));
+
//
// Bind this information into the SEC hand-off state
// Note: this must be in sync with the stuff in the asm file
@@ -55,8 +59,8 @@ PrimaryMain (
SecCoreData.TemporaryRamSize = TemporaryRamSize;
SecCoreData.PeiTemporaryRamBase = SecCoreData.TemporaryRamBase;
SecCoreData.PeiTemporaryRamSize = SecCoreData.TemporaryRamSize / 2;
- SecCoreData.StackBase = (VOID *)((UINTN)(SecCoreData.TemporaryRamBase) + (SecCoreData.TemporaryRamSize/2));
- SecCoreData.StackSize = SecCoreData.TemporaryRamSize / 2;
+ SecCoreData.StackBase = (VOID *)ALIGN_VALUE((UINTN)(SecCoreData.TemporaryRamBase) + SecCoreData.PeiTemporaryRamSize, 0x4);
+ SecCoreData.StackSize = (TemporaryRamBase + TemporaryRamSize) - (UINTN)SecCoreData.StackBase;
// Jump to PEI core entry point
(PeiCoreEntryPoint)(&SecCoreData, PpiList);