UINTN Index;\r
BOOLEAN Enabled;\r
EFI_PHYSICAL_ADDRESS Base;\r
+ UINT32 *VectorBase;\r
\r
//\r
// Disable interrupts\r
Cpu->GetInterruptState (Cpu, &Enabled);\r
Cpu->DisableInterrupt (Cpu);\r
\r
- //\r
- // Initialize the C entry points for interrupts\r
- //\r
- for (Index = 0; Index <= MAX_ARM_EXCEPTION; Index++) {\r
- Status = RegisterInterruptHandler (Index, NULL);\r
- ASSERT_EFI_ERROR (Status);\r
- \r
- Status = RegisterDebuggerInterruptHandler (Index, NULL);\r
- ASSERT_EFI_ERROR (Status);\r
- }\r
\r
//\r
// Copy an implementation of the ARM exception vectors to PcdCpuVectorBaseAddress.\r
// Reserve space for the exception handlers\r
//\r
Base = (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdCpuVectorBaseAddress);\r
+ VectorBase = (UINT32 *)(UINTN)Base;\r
Status = gBS->AllocatePages (AllocateAddress, EfiBootServicesCode, EFI_SIZE_TO_PAGES (Length), &Base);\r
// If the request was for memory that's not in the memory map (which is often the case for 0x00000000\r
// on embedded systems, for example, we don't want to hang up. So we'll check here for a status of \r
ASSERT_EFI_ERROR (Status);\r
}\r
\r
- CopyMem ((VOID *)(UINTN)PcdGet32 (PcdCpuVectorBaseAddress), (VOID *)ExceptionHandlersStart, Length);\r
+ // Save existing vector table, in case debugger is already hooked in\r
+ CopyMem ((VOID *)gDebuggerExceptionHandlers, (VOID *)VectorBase, sizeof (gDebuggerExceptionHandlers));\r
+\r
+ //\r
+ // Initialize the C entry points for interrupts\r
+ //\r
+ for (Index = 0; Index <= MAX_ARM_EXCEPTION; Index++) {\r
+ Status = RegisterInterruptHandler (Index, NULL);\r
+ ASSERT_EFI_ERROR (Status);\r
+ \r
+ if (VectorBase[Index] == 0xEAFFFFFE) {\r
+ // Exception handler contains branch to vector location (jmp $) so no handler\r
+ // NOTE: This code assumes vectors are ARM and not Thumb code\r
+ gDebuggerExceptionHandlers[Index] = NULL;\r
+ }\r
+ }\r
+\r
+ // Copy our assembly code into the page that contains the exception vectors. \r
+ CopyMem ((VOID *)VectorBase, (VOID *)ExceptionHandlersStart, Length);\r
\r
//\r
// Patch in the common Assembly exception handler\r
MmioWrite32 (INTCPS_MIR(0), 0xFFFFFFFF);\r
MmioWrite32 (INTCPS_MIR(1), 0xFFFFFFFF);\r
MmioWrite32 (INTCPS_MIR(2), 0xFFFFFFFF);\r
- MmioWrite32 (INTCPS_CONTROL, INTCPS_CONTROL_NEWIRQAGR);\r
+ MmioOr32 (INTCPS_CONTROL, INTCPS_CONTROL_NEWIRQAGR);\r
\r
Status = gBS->InstallMultipleProtocolInterfaces(&gHardwareInterruptHandle,\r
&gHardwareInterruptProtocolGuid, &gHardwareInterruptProtocol,\r