summaryrefslogtreecommitdiffstats
path: root/ArmPkg/Library
diff options
context:
space:
mode:
Diffstat (limited to 'ArmPkg/Library')
-rw-r--r--ArmPkg/Library/ArmExceptionLib/AArch64/AArch64Exception.c8
-rw-r--r--ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S11
-rw-r--r--ArmPkg/Library/ArmExceptionLib/Arm/ArmException.c11
-rw-r--r--ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c165
-rw-r--r--ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf8
-rw-r--r--ArmPkg/Library/ArmExceptionLib/ArmRelocateExceptionLib.inf58
6 files changed, 21 insertions, 240 deletions
diff --git a/ArmPkg/Library/ArmExceptionLib/AArch64/AArch64Exception.c b/ArmPkg/Library/ArmExceptionLib/AArch64/AArch64Exception.c
index b0c2e39cd9..1ae16ae3e4 100644
--- a/ArmPkg/Library/ArmExceptionLib/AArch64/AArch64Exception.c
+++ b/ArmPkg/Library/ArmExceptionLib/AArch64/AArch64Exception.c
@@ -14,11 +14,9 @@
#include <Library/MemoryAllocationLib.h>
#include <Protocol/DebugSupport.h> // for MAX_AARCH64_EXCEPTION
-UINTN gMaxExceptionNumber = MAX_AARCH64_EXCEPTION;
-EFI_EXCEPTION_CALLBACK gExceptionHandlers[MAX_AARCH64_EXCEPTION + 1] = { 0 };
-EFI_EXCEPTION_CALLBACK gDebuggerExceptionHandlers[MAX_AARCH64_EXCEPTION + 1] = { 0 };
-PHYSICAL_ADDRESS gExceptionVectorAlignmentMask = ARM_VECTOR_TABLE_ALIGNMENT;
-UINTN gDebuggerNoHandlerValue = 0; // todo: define for AArch64
+UINTN gMaxExceptionNumber = MAX_AARCH64_EXCEPTION;
+EFI_EXCEPTION_CALLBACK gExceptionHandlers[MAX_AARCH64_EXCEPTION + 1] = { 0 };
+PHYSICAL_ADDRESS gExceptionVectorAlignmentMask = ARM_VECTOR_TABLE_ALIGNMENT;
#define EL0_STACK_SIZE EFI_PAGES_TO_SIZE(2)
STATIC UINTN mNewStackBase[EL0_STACK_SIZE / sizeof (UINTN)];
diff --git a/ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S b/ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S
index 5dc6899773..714ead608f 100644
--- a/ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S
+++ b/ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S
@@ -109,12 +109,7 @@ GCC_ASM_EXPORT(CommonCExceptionHandler)
// exception vector initialization method is used.
//
-#if defined(ARM_RELOCATE_VECTORS)
-GCC_ASM_EXPORT(ExceptionHandlersStart)
-ASM_PFX(ExceptionHandlersStart):
-#else
VECTOR_BASE(ExceptionHandlersStart)
-#endif
.macro ExceptionEntry, val, sp=SPx
//
@@ -168,13 +163,7 @@ VECTOR_BASE(ExceptionHandlersStart)
mov x0, #\val
// Jump to our general handler to deal with all the common parts and process the exception.
-#if defined(ARM_RELOCATE_VECTORS)
- ldr x1, =ASM_PFX(CommonExceptionEntry)
- br x1
- .ltorg
-#else
b ASM_PFX(CommonExceptionEntry)
-#endif
.endm
//
diff --git a/ArmPkg/Library/ArmExceptionLib/Arm/ArmException.c b/ArmPkg/Library/ArmExceptionLib/Arm/ArmException.c
index 7652b97b43..ddff3e8f32 100644
--- a/ArmPkg/Library/ArmExceptionLib/Arm/ArmException.c
+++ b/ArmPkg/Library/ArmExceptionLib/Arm/ArmException.c
@@ -17,14 +17,9 @@
#include <Protocol/DebugSupport.h> // for MAX_ARM_EXCEPTION
-UINTN gMaxExceptionNumber = MAX_ARM_EXCEPTION;
-EFI_EXCEPTION_CALLBACK gExceptionHandlers[MAX_ARM_EXCEPTION + 1] = { 0 };
-EFI_EXCEPTION_CALLBACK gDebuggerExceptionHandlers[MAX_ARM_EXCEPTION + 1] = { 0 };
-PHYSICAL_ADDRESS gExceptionVectorAlignmentMask = ARM_VECTOR_TABLE_ALIGNMENT;
-
-// Exception handler contains branch to vector location (jmp $) so no handler
-// NOTE: This code assumes vectors are ARM and not Thumb code
-UINTN gDebuggerNoHandlerValue = 0xEAFFFFFE;
+UINTN gMaxExceptionNumber = MAX_ARM_EXCEPTION;
+EFI_EXCEPTION_CALLBACK gExceptionHandlers[MAX_ARM_EXCEPTION + 1] = { 0 };
+PHYSICAL_ADDRESS gExceptionVectorAlignmentMask = ARM_VECTOR_TABLE_ALIGNMENT;
RETURN_STATUS
ArchVectorConfig (
diff --git a/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c b/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c
index 03ed24794a..9832aba4b3 100644
--- a/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c
+++ b/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c
@@ -21,19 +21,6 @@
#include <Library/DebugLib.h>
#include <Library/DefaultExceptionHandlerLib.h>
-STATIC
-RETURN_STATUS
-CopyExceptionHandlers (
- IN PHYSICAL_ADDRESS BaseAddress
- );
-
-EFI_STATUS
-EFIAPI
-RegisterExceptionHandler (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
- );
-
VOID
ExceptionHandlersStart (
VOID
@@ -52,21 +39,7 @@ ArchVectorConfig (
// these globals are provided by the architecture specific source (Arm or AArch64)
extern UINTN gMaxExceptionNumber;
extern EFI_EXCEPTION_CALLBACK gExceptionHandlers[];
-extern EFI_EXCEPTION_CALLBACK gDebuggerExceptionHandlers[];
extern PHYSICAL_ADDRESS gExceptionVectorAlignmentMask;
-extern UINTN gDebuggerNoHandlerValue;
-
-// A compiler flag adjusts the compilation of this library to a variant where
-// the vectors are relocated (copied) to another location versus using the
-// vectors in-place. Since this effects an assembly .align directive we must
-// address this at library build time. Since this affects the build of the
-// library we cannot represent this in a PCD since PCDs are evaluated on
-// a per-module basis.
-#if defined (ARM_RELOCATE_VECTORS)
-STATIC CONST BOOLEAN gArmRelocateVectorTable = TRUE;
-#else
-STATIC CONST BOOLEAN gArmRelocateVectorTable = FALSE;
-#endif
/**
Initializes all CPU exceptions entries and provides the default exception handlers.
@@ -90,107 +63,26 @@ InitializeCpuExceptionHandlers (
IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL
)
{
- RETURN_STATUS Status;
- UINT64 VectorBase;
-
- Status = EFI_SUCCESS;
+ UINT64 VectorBase;
- // if we are requested to copy exception handlers to another location
- if (gArmRelocateVectorTable) {
- VectorBase = PcdGet64 (PcdCpuVectorBaseAddress);
- Status = CopyExceptionHandlers (VectorBase);
- } else {
- // use VBAR to point to where our exception handlers are
+ // use VBAR to point to where our exception handlers are
- // The vector table must be aligned for the architecture. If this
- // assertion fails ensure the appropriate FFS alignment is in effect,
- // which can be accomplished by ensuring the proper Align=X statement
- // in the platform packaging rules. For ARM Align=32 is required and
- // for AArch64 Align=4K is required. Align=Auto can be used but this
- // is known to cause an issue with populating the reset vector area
- // for encapsulated FVs.
- ASSERT (((UINTN)ExceptionHandlersStart & gExceptionVectorAlignmentMask) == 0);
+ // The vector table must be aligned for the architecture. If this
+ // assertion fails ensure the appropriate FFS alignment is in effect,
+ // which can be accomplished by ensuring the proper Align=X statement
+ // in the platform packaging rules. For ARM Align=32 is required and
+ // for AArch64 Align=4K is required. Align=Auto can be used but this
+ // is known to cause an issue with populating the reset vector area
+ // for encapsulated FVs.
+ ASSERT (((UINTN)ExceptionHandlersStart & gExceptionVectorAlignmentMask) == 0);
- // We do not copy the Exception Table at PcdGet64(PcdCpuVectorBaseAddress). We just set Vector
- // Base Address to point into CpuDxe code.
- VectorBase = (UINT64)(UINTN)ExceptionHandlersStart;
+ VectorBase = (UINT64)(UINTN)ExceptionHandlersStart;
- Status = RETURN_SUCCESS;
- }
+ // call the architecture-specific routine to prepare for the new vector
+ // configuration to take effect
+ ArchVectorConfig ((UINTN)VectorBase);
- if (!RETURN_ERROR (Status)) {
- // call the architecture-specific routine to prepare for the new vector
- // configuration to take effect
- ArchVectorConfig ((UINTN)VectorBase);
-
- ArmWriteVBar ((UINTN)VectorBase);
- }
-
- return RETURN_SUCCESS;
-}
-
-/**
-Copies exception handlers to the specified address.
-
-Caller should try to get an array of interrupt and/or exception vectors that are in use and need to
-persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.
-If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.
-If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.
-
-@param[in] VectorInfo Pointer to reserved vector list.
-
-@retval EFI_SUCCESS CPU Exception Entries have been successfully initialized
-with default exception handlers.
-@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
-@retval EFI_UNSUPPORTED This function is not supported.
-
-**/
-STATIC
-RETURN_STATUS
-CopyExceptionHandlers (
- IN PHYSICAL_ADDRESS BaseAddress
- )
-{
- RETURN_STATUS Status;
- UINTN Length;
- UINTN Index;
- UINT32 *VectorBase;
-
- // ensure that the destination value specifies an address meeting the vector alignment requirements
- ASSERT ((BaseAddress & gExceptionVectorAlignmentMask) == 0);
-
- //
- // Copy an implementation of the exception vectors to PcdCpuVectorBaseAddress.
- //
- Length = (UINTN)ExceptionHandlersEnd - (UINTN)ExceptionHandlersStart;
-
- VectorBase = (UINT32 *)(UINTN)BaseAddress;
-
- if (FeaturePcdGet (PcdDebuggerExceptionSupport) == TRUE) {
- // Save existing vector table, in case debugger is already hooked in
- CopyMem ((VOID *)gDebuggerExceptionHandlers, (VOID *)VectorBase, sizeof (EFI_EXCEPTION_CALLBACK)* (gMaxExceptionNumber+1));
- }
-
- // Copy our assembly code into the page that contains the exception vectors.
- CopyMem ((VOID *)VectorBase, (VOID *)(UINTN)ExceptionHandlersStart, Length);
-
- //
- // Initialize the C entry points for interrupts
- //
- for (Index = 0; Index <= gMaxExceptionNumber; Index++) {
- if (!FeaturePcdGet (PcdDebuggerExceptionSupport) ||
- (gDebuggerExceptionHandlers[Index] == 0) || (gDebuggerExceptionHandlers[Index] == (VOID *)gDebuggerNoHandlerValue))
- {
- Status = RegisterExceptionHandler (Index, NULL);
- ASSERT_EFI_ERROR (Status);
- } else {
- // If the debugger has already hooked put its vector back
- VectorBase[Index] = (UINT32)(UINTN)gDebuggerExceptionHandlers[Index];
- }
- }
-
- // Flush Caches since we updated executable stuff
- InvalidateInstructionCacheRange ((VOID *)(UINTN)BaseAddress, Length);
+ ArmWriteVBar ((UINTN)VectorBase);
return RETURN_SUCCESS;
}
@@ -239,33 +131,6 @@ RegisterCpuInterruptHandler (
return RETURN_SUCCESS;
}
-/**
-Register exception handler.
-
-@param This A pointer to the SMM_CPU_SERVICE_PROTOCOL instance.
-@param ExceptionType Defines which interrupt or exception to hook. Type EFI_EXCEPTION_TYPE and
-the valid values for this parameter are defined in EFI_DEBUG_SUPPORT_PROTOCOL
-of the UEFI 2.0 specification.
-@param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER
-that is called when a processor interrupt occurs.
-If this parameter is NULL, then the handler will be uninstalled.
-
-@retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.
-@retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was previously installed.
-@retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not previously installed.
-@retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported.
-
-**/
-EFI_STATUS
-EFIAPI
-RegisterExceptionHandler (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
- )
-{
- return RegisterCpuInterruptHandler (ExceptionType, InterruptHandler);
-}
-
VOID
EFIAPI
CommonCExceptionHandler (
diff --git a/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf b/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf
index 68ed1c5c59..611b49b99c 100644
--- a/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf
+++ b/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf
@@ -7,12 +7,6 @@
# alignment must be propagated into the parent FFS/FV through FDF build rules
# for the relevant module types (i.e. Align=Auto).
#
-# Note that using this library instance can cause growth to the size of the FV
-# due to the padding added by the build tools to meet the vector alignment
-# requirements and may not be desirable for space-sensitive FVs (uncompressed /
-# XIP components). The alternative library instance, ArmRelocateExceptionLib
-# should be considered for these applications.
-#
# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
# Copyright (c) 2016 HP Development Company, L.P.
#
@@ -53,5 +47,3 @@
MemoryAllocationLib
[Pcd]
- gArmTokenSpaceGuid.PcdDebuggerExceptionSupport
- gArmTokenSpaceGuid.PcdCpuVectorBaseAddress
diff --git a/ArmPkg/Library/ArmExceptionLib/ArmRelocateExceptionLib.inf b/ArmPkg/Library/ArmExceptionLib/ArmRelocateExceptionLib.inf
deleted file mode 100644
index ca70daa284..0000000000
--- a/ArmPkg/Library/ArmExceptionLib/ArmRelocateExceptionLib.inf
+++ /dev/null
@@ -1,58 +0,0 @@
-## @file
-# Instance of CpuExceptionHandlerLib Library for ARM/AArch64 architectures
-#
-# This library instance is used when exception vectors must be relocated to
-# a specific address. The address is specified by PcdCpuVectorBaseAddress.
-# Since the alignment requirement for in-place exception handlers causes
-# image size to increase, this instance is useful for modules that need to
-# minimize space used in their FV (like XIP modules). See ArmExceptionLib.inf
-# for the in-place exception handler alternative.
-#
-# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
-# Copyright (c) 2016 HP Development Company, L.P.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = ArmRelocateExceptionLib
- FILE_GUID = 62AA447A-1FBA-429E-9E0D-CE0D2D8DCF58
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = CpuExceptionHandlerLib
-
-[Sources.common]
- ArmExceptionLib.c
-
-[Sources.Arm]
- Arm/ArmException.c
- Arm/ExceptionSupport.S | GCC
-
-[Sources.AARCH64]
- AArch64/AArch64Exception.c
- AArch64/ExceptionSupport.S
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- ArmPkg/ArmPkg.dec
-
-[LibraryClasses]
- ArmLib
- DebugLib
- DefaultExceptionHandlerLib
- BaseMemoryLib
- CacheMaintenanceLib
-
-[Pcd]
- gArmTokenSpaceGuid.PcdDebuggerExceptionSupport
- gArmTokenSpaceGuid.PcdCpuVectorBaseAddress
-
-[BuildOptions]
- # We must pass a define to specify that we are relocating vectors so the
- # vector alignment is relaxed (space savings); note that this must be done
- # as a define and not a PCD since it affects assembly directives.
- *_*_*_PP_FLAGS = -DARM_RELOCATE_VECTORS
- *_*_*_CC_FLAGS = -DARM_RELOCATE_VECTORS