summaryrefslogtreecommitdiffstats
path: root/ArmPkg/Drivers/CpuDxe/Exception.c
diff options
context:
space:
mode:
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2010-03-05 00:57:07 +0000
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2010-03-05 00:57:07 +0000
commit41d478023f9fcc9a27bfc006cbc16b94d85ff98c (patch)
tree11beca0f1a5f1725f546a93c548ecb45b616841f /ArmPkg/Drivers/CpuDxe/Exception.c
parentd03171efd17327b51ffccd5edcd86b719395ba51 (diff)
downloadedk2-41d478023f9fcc9a27bfc006cbc16b94d85ff98c.tar.gz
edk2-41d478023f9fcc9a27bfc006cbc16b94d85ff98c.tar.bz2
edk2-41d478023f9fcc9a27bfc006cbc16b94d85ff98c.zip
Make these drivers more compatible with a projected Debug Agent Library implementation.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10196 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPkg/Drivers/CpuDxe/Exception.c')
-rw-r--r--ArmPkg/Drivers/CpuDxe/Exception.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/ArmPkg/Drivers/CpuDxe/Exception.c b/ArmPkg/Drivers/CpuDxe/Exception.c
index e313cf3fe9..d99d3d1d01 100644
--- a/ArmPkg/Drivers/CpuDxe/Exception.c
+++ b/ArmPkg/Drivers/CpuDxe/Exception.c
@@ -180,6 +180,7 @@ InitializeExceptions (
UINTN Index;
BOOLEAN Enabled;
EFI_PHYSICAL_ADDRESS Base;
+ UINT32 *VectorBase;
//
// Disable interrupts
@@ -187,16 +188,6 @@ InitializeExceptions (
Cpu->GetInterruptState (Cpu, &Enabled);
Cpu->DisableInterrupt (Cpu);
- //
- // Initialize the C entry points for interrupts
- //
- for (Index = 0; Index <= MAX_ARM_EXCEPTION; Index++) {
- Status = RegisterInterruptHandler (Index, NULL);
- ASSERT_EFI_ERROR (Status);
-
- Status = RegisterDebuggerInterruptHandler (Index, NULL);
- ASSERT_EFI_ERROR (Status);
- }
//
// Copy an implementation of the ARM exception vectors to PcdCpuVectorBaseAddress.
@@ -207,6 +198,7 @@ InitializeExceptions (
// Reserve space for the exception handlers
//
Base = (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdCpuVectorBaseAddress);
+ VectorBase = (UINT32 *)(UINTN)Base;
Status = gBS->AllocatePages (AllocateAddress, EfiBootServicesCode, EFI_SIZE_TO_PAGES (Length), &Base);
// If the request was for memory that's not in the memory map (which is often the case for 0x00000000
// on embedded systems, for example, we don't want to hang up. So we'll check here for a status of
@@ -215,7 +207,25 @@ InitializeExceptions (
ASSERT_EFI_ERROR (Status);
}
- CopyMem ((VOID *)(UINTN)PcdGet32 (PcdCpuVectorBaseAddress), (VOID *)ExceptionHandlersStart, Length);
+ // Save existing vector table, in case debugger is already hooked in
+ CopyMem ((VOID *)gDebuggerExceptionHandlers, (VOID *)VectorBase, sizeof (gDebuggerExceptionHandlers));
+
+ //
+ // Initialize the C entry points for interrupts
+ //
+ for (Index = 0; Index <= MAX_ARM_EXCEPTION; Index++) {
+ Status = RegisterInterruptHandler (Index, NULL);
+ ASSERT_EFI_ERROR (Status);
+
+ if (VectorBase[Index] == 0xEAFFFFFE) {
+ // Exception handler contains branch to vector location (jmp $) so no handler
+ // NOTE: This code assumes vectors are ARM and not Thumb code
+ gDebuggerExceptionHandlers[Index] = NULL;
+ }
+ }
+
+ // Copy our assembly code into the page that contains the exception vectors.
+ CopyMem ((VOID *)VectorBase, (VOID *)ExceptionHandlersStart, Length);
//
// Patch in the common Assembly exception handler