*\r
* Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
*\r
-* This program and the accompanying materials\r
-* are licensed and made available under the terms and conditions of the BSD License\r
-* which accompanies this distribution. The full text of the license may be found at\r
-* http://opensource.org/licenses/bsd-license.php\r
-*\r
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+* SPDX-License-Identifier: BSD-2-Clause-Patent\r
*\r
**/\r
\r
VOID *NewHeap;\r
VOID *OldStack;\r
VOID *NewStack;\r
+ UINTN HeapSize;\r
+\r
+ HeapSize = ALIGN_VALUE (CopySize / 2, CPU_STACK_ALIGNMENT);\r
\r
OldHeap = (VOID*)(UINTN)TemporaryMemoryBase;\r
- NewHeap = (VOID*)((UINTN)PermanentMemoryBase + (CopySize >> 1));\r
+ NewHeap = (VOID*)((UINTN)PermanentMemoryBase + (CopySize - HeapSize));\r
\r
- OldStack = (VOID*)((UINTN)TemporaryMemoryBase + (CopySize >> 1));\r
+ OldStack = (VOID*)((UINTN)TemporaryMemoryBase + HeapSize);\r
NewStack = (VOID*)(UINTN)PermanentMemoryBase;\r
\r
//\r
// Migrate the temporary memory stack to permanent memory stack.\r
//\r
- CopyMem (NewStack, OldStack, CopySize >> 1);\r
+ CopyMem (NewStack, OldStack, CopySize - HeapSize);\r
\r
//\r
// Migrate the temporary memory heap to permanent memory heap.\r
//\r
- CopyMem (NewHeap, OldHeap, CopySize >> 1);\r
+ CopyMem (NewHeap, OldHeap, HeapSize);\r
\r
SecSwitchStack ((UINTN)NewStack - (UINTN)OldStack);\r
\r