Home | History | Annotate | Download | only in AArch64
      1 /** @file
      2 *  Exception Handling support specific for AArch64
      3 *
      4 *  Copyright (c) 2016 HP Development Company, L.P.
      5 *
      6 *  This program and the accompanying materials
      7 *  are licensed and made available under the terms and conditions of the BSD License
      8 *  which accompanies this distribution.  The full text of the license may be found at
      9 *  http://opensource.org/licenses/bsd-license.php
     10 *
     11 *  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     12 *  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     13 *
     14 **/
     15 
     16 #include <Uefi.h>
     17 
     18 #include <Chipset/AArch64.h>
     19 
     20 #include <Protocol/DebugSupport.h> // for MAX_AARCH64_EXCEPTION
     21 
     22 UINTN                   gMaxExceptionNumber = MAX_AARCH64_EXCEPTION;
     23 EFI_EXCEPTION_CALLBACK  gExceptionHandlers[MAX_AARCH64_EXCEPTION + 1] = { 0 };
     24 EFI_EXCEPTION_CALLBACK  gDebuggerExceptionHandlers[MAX_AARCH64_EXCEPTION + 1] = { 0 };
     25 PHYSICAL_ADDRESS        gExceptionVectorAlignmentMask = ARM_VECTOR_TABLE_ALIGNMENT;
     26 UINTN                   gDebuggerNoHandlerValue = 0; // todo: define for AArch64
     27 
     28 RETURN_STATUS ArchVectorConfig(
     29   IN  UINTN       VectorBaseAddress
     30   )
     31 {
     32   UINTN             HcrReg;
     33 
     34   if (ArmReadCurrentEL() == AARCH64_EL2) {
     35     HcrReg = ArmReadHcr();
     36 
     37     // Trap General Exceptions. All exceptions that would be routed to EL1 are routed to EL2
     38     HcrReg |= ARM_HCR_TGE;
     39 
     40     ArmWriteHcr(HcrReg);
     41   }
     42 
     43   return RETURN_SUCCESS;
     44 }
     45