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_PAGES 2
29 RETURN_STATUS
ArchVectorConfig(
30 IN UINTN VectorBaseAddress
36 Stack
= AllocatePages (EL0_STACK_PAGES
);
38 return RETURN_OUT_OF_RESOURCES
;
41 RegisterEl0Stack ((UINT8
*)Stack
+ EFI_PAGES_TO_SIZE (EL0_STACK_PAGES
));
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
;