2 * Exception Handling support specific for AArch64
4 * Copyright (c) 2016 HP Development Company, L.P.
5 * Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
7 * SPDX-License-Identifier: BSD-2-Clause-Patent
13 #include <Chipset/AArch64.h>
14 #include <Library/MemoryAllocationLib.h>
15 #include <Protocol/DebugSupport.h> // for MAX_AARCH64_EXCEPTION
17 UINTN gMaxExceptionNumber
= MAX_AARCH64_EXCEPTION
;
18 EFI_EXCEPTION_CALLBACK gExceptionHandlers
[MAX_AARCH64_EXCEPTION
+ 1] = { 0 };
19 EFI_EXCEPTION_CALLBACK gDebuggerExceptionHandlers
[MAX_AARCH64_EXCEPTION
+ 1] = { 0 };
20 PHYSICAL_ADDRESS gExceptionVectorAlignmentMask
= ARM_VECTOR_TABLE_ALIGNMENT
;
21 UINTN gDebuggerNoHandlerValue
= 0; // todo: define for AArch64
23 #define EL0_STACK_SIZE EFI_PAGES_TO_SIZE(2)
24 STATIC UINTN mNewStackBase
[EL0_STACK_SIZE
/ sizeof (UINTN
)];
33 IN UINTN VectorBaseAddress
38 // Round down sp by 16 bytes alignment
40 (VOID
*)(((UINTN
)mNewStackBase
+ EL0_STACK_SIZE
) & ~0xFUL
)
43 if (ArmReadCurrentEL () == AARCH64_EL2
) {
44 HcrReg
= ArmReadHcr ();
46 // Trap General Exceptions. All exceptions that would be routed to EL1 are routed to EL2
47 HcrReg
|= ARM_HCR_TGE
;
52 return RETURN_SUCCESS
;