*\r
* Copyright (c) 2016 HP Development Company, L.P.\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
#include <Uefi.h>\r
\r
#include <Chipset/AArch64.h>\r
-\r
+#include <Library/MemoryAllocationLib.h>\r
#include <Protocol/DebugSupport.h> // for MAX_AARCH64_EXCEPTION\r
\r
UINTN gMaxExceptionNumber = MAX_AARCH64_EXCEPTION;\r
PHYSICAL_ADDRESS gExceptionVectorAlignmentMask = ARM_VECTOR_TABLE_ALIGNMENT;\r
UINTN gDebuggerNoHandlerValue = 0; // todo: define for AArch64\r
\r
+#define EL0_STACK_SIZE EFI_PAGES_TO_SIZE(2)\r
+STATIC UINTN mNewStackBase[EL0_STACK_SIZE / sizeof (UINTN)];\r
+\r
+VOID\r
+RegisterEl0Stack (\r
+ IN VOID *Stack\r
+ );\r
+\r
RETURN_STATUS ArchVectorConfig(\r
IN UINTN VectorBaseAddress\r
)\r
{\r
UINTN HcrReg;\r
\r
+ // Round down sp by 16 bytes alignment\r
+ RegisterEl0Stack (\r
+ (VOID *)(((UINTN)mNewStackBase + EL0_STACK_SIZE) & ~0xFUL)\r
+ );\r
+\r
if (ArmReadCurrentEL() == AARCH64_EL2) {\r
HcrReg = ArmReadHcr();\r
\r