2 * Exception Handling support specific for AArch64
4 * Copyright (c) 2016 HP Development Company, L.P.
6 * SPDX-License-Identifier: BSD-2-Clause-Patent
12 #include <Chipset/AArch64.h>
13 #include <Library/MemoryAllocationLib.h>
14 #include <Protocol/DebugSupport.h> // for MAX_AARCH64_EXCEPTION
16 UINTN gMaxExceptionNumber
= MAX_AARCH64_EXCEPTION
;
17 EFI_EXCEPTION_CALLBACK gExceptionHandlers
[MAX_AARCH64_EXCEPTION
+ 1] = { 0 };
18 EFI_EXCEPTION_CALLBACK gDebuggerExceptionHandlers
[MAX_AARCH64_EXCEPTION
+ 1] = { 0 };
19 PHYSICAL_ADDRESS gExceptionVectorAlignmentMask
= ARM_VECTOR_TABLE_ALIGNMENT
;
20 UINTN gDebuggerNoHandlerValue
= 0; // todo: define for AArch64
22 #define EL0_STACK_SIZE EFI_PAGES_TO_SIZE(2)
23 STATIC UINTN mNewStackBase
[EL0_STACK_SIZE
/ sizeof (UINTN
)];
30 RETURN_STATUS
ArchVectorConfig(
31 IN UINTN VectorBaseAddress
36 // Round down sp by 16 bytes alignment
38 (VOID
*)(((UINTN
)mNewStackBase
+ EL0_STACK_SIZE
) & ~0xFUL
)
41 if (ArmReadCurrentEL() == AARCH64_EL2
) {
42 HcrReg
= ArmReadHcr();
44 // Trap General Exceptions. All exceptions that would be routed to EL1 are routed to EL2
45 HcrReg
|= ARM_HCR_TGE
;
50 return RETURN_SUCCESS
;