TianoCore EDK2 master
Loading...
Searching...
No Matches
AArch64Exception.c
Go to the documentation of this file.
1
11#include <Uefi.h>
12
13#include <AArch64/AArch64.h>
15#include <Protocol/DebugSupport.h> // for MAX_AARCH64_EXCEPTION
16
17UINTN gMaxExceptionNumber = MAX_AARCH64_EXCEPTION;
18EFI_EXCEPTION_CALLBACK gExceptionHandlers[MAX_AARCH64_EXCEPTION + 1] = { 0 };
19EFI_EXCEPTION_CALLBACK gDebuggerExceptionHandlers[MAX_AARCH64_EXCEPTION + 1] = { 0 };
20PHYSICAL_ADDRESS gExceptionVectorAlignmentMask = ARM_VECTOR_TABLE_ALIGNMENT;
21UINTN gDebuggerNoHandlerValue = 0; // todo: define for AArch64
22
23#define EL0_STACK_SIZE EFI_PAGES_TO_SIZE(2)
24STATIC UINTN mNewStackBase[EL0_STACK_SIZE / sizeof (UINTN)];
25
26VOID
27RegisterEl0Stack (
28 IN VOID *Stack
29 );
30
31RETURN_STATUS
32ArchVectorConfig (
33 IN UINTN VectorBaseAddress
34 )
35{
36 UINTN HcrReg;
37
38 // Round down sp by 16 bytes alignment
39 RegisterEl0Stack (
40 (VOID *)(((UINTN)mNewStackBase + EL0_STACK_SIZE) & ~0xFUL)
41 );
42
43 if (ArmReadCurrentEL () == AARCH64_EL2) {
44 HcrReg = ArmReadHcr ();
45
46 // Trap General Exceptions. All exceptions that would be routed to EL1 are routed to EL2
47 HcrReg |= ARM_HCR_TGE;
48
49 ArmWriteHcr (HcrReg);
50 }
51
52 return RETURN_SUCCESS;
53}
UINT64 UINTN
#define STATIC
Definition: Base.h:264
#define RETURN_SUCCESS
Definition: Base.h:1066
#define IN
Definition: Base.h:279
#define MAX_AARCH64_EXCEPTION
Definition: DebugSupport.h:525
VOID(EFIAPI * EFI_EXCEPTION_CALLBACK)(IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
Definition: DebugSupport.h:816