]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Drivers/CpuDxe/Exception.c
Remove hook for debugger. Should be implemented using the new library scheme.
[mirror_edk2.git] / ArmPkg / Drivers / CpuDxe / Exception.c
index f795c431a2dd8109edeabcb4a86e82f96f26080a..90a0045e825ddcfbe69e64bb31b0056cb42a05a6 100644 (file)
@@ -81,45 +81,6 @@ RegisterInterruptHandler (
 }\r
 \r
 \r
-/**\r
-  This function registers and enables the handler specified by InterruptHandler for a processor \r
-  interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the \r
-  handler for the processor interrupt or exception type specified by InterruptType is uninstalled. \r
-  The installed handler is called once for each processor interrupt or exception.\r
-\r
-  @param  InterruptType    A pointer to the processor's current interrupt state. Set to TRUE if interrupts\r
-                           are enabled and FALSE if interrupts are disabled.\r
-  @param  InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called\r
-                           when a processor interrupt occurs. If this parameter is NULL, then the handler\r
-                           will be uninstalled.\r
-\r
-  @retval EFI_SUCCESS           The handler for the processor interrupt was successfully installed or uninstalled.\r
-  @retval EFI_ALREADY_STARTED   InterruptHandler is not NULL, and a handler for InterruptType was\r
-                                previously installed.\r
-  @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not\r
-                                previously installed.\r
-  @retval EFI_UNSUPPORTED       The interrupt specified by InterruptType is not supported.\r
-\r
-**/\r
-EFI_STATUS\r
-RegisterDebuggerInterruptHandler (\r
-  IN EFI_EXCEPTION_TYPE             InterruptType,\r
-  IN EFI_CPU_INTERRUPT_HANDLER      InterruptHandler\r
-  )\r
-{\r
-  if (InterruptType > MAX_ARM_EXCEPTION) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if ((InterruptHandler != NULL) && (gDebuggerExceptionHandlers[InterruptType] != NULL)) {\r
-    return EFI_ALREADY_STARTED;\r
-  }\r
-\r
-  gDebuggerExceptionHandlers[InterruptType] = InterruptHandler;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
 \r
 \r
 VOID\r
@@ -129,33 +90,16 @@ CommonCExceptionHandler (
   IN OUT EFI_SYSTEM_CONTEXT           SystemContext\r
   )\r
 {\r
-  BOOLEAN Dispatched = FALSE;\r
\r
\r
+\r
   if (ExceptionType <= MAX_ARM_EXCEPTION) {\r
-    if (gDebuggerExceptionHandlers[ExceptionType]) {\r
-      //\r
-      // If DebugSupport hooked the interrupt call the handler. This does not disable \r
-      // the normal handler.\r
-      //\r
-      gDebuggerExceptionHandlers[ExceptionType] (ExceptionType, SystemContext);\r
-      Dispatched = TRUE;\r
-    }\r
     if (gExceptionHandlers[ExceptionType]) {\r
       gExceptionHandlers[ExceptionType] (ExceptionType, SystemContext);\r
-      Dispatched = TRUE;\r
+      return;\r
     }\r
   } else {\r
     DEBUG ((EFI_D_ERROR, "Unknown exception type %d from %08x\n", ExceptionType, SystemContext.SystemContextArm->PC));\r
     ASSERT (FALSE);\r
   }\r
-\r
-  if (Dispatched) {\r
-    //\r
-    // We did work so this was an expected ExceptionType\r
-    //\r
-    return;\r
-  }\r
   \r
   if (ExceptionType == EXCEPT_ARM_SOFTWARE_INTERRUPT) {\r
     //\r
@@ -217,20 +161,6 @@ InitializeExceptions (
   // 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
@@ -240,6 +170,21 @@ InitializeExceptions (
   Offset = (UINTN)CommonExceptionEntry - (UINTN)ExceptionHandlersStart;\r
   *(UINTN *) ((UINT8 *)(UINTN)PcdGet32 (PcdCpuVectorBaseAddress) + Offset) = (UINTN)AsmCommonExceptionEntry;\r
 \r
+  //\r
+  // Initialize the C entry points for interrupts\r
+  //\r
+  for (Index = 0; Index <= MAX_ARM_EXCEPTION; Index++) {\r
+    if ((gDebuggerExceptionHandlers[Index] == 0) || (gDebuggerExceptionHandlers[Index] == (VOID *)(UINTN)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
+      Status = RegisterInterruptHandler (Index, NULL);\r
+      ASSERT_EFI_ERROR (Status);\r
+    } else {\r
+      // If the debugger has alread hooked put its vector back\r
+      VectorBase[Index] = (UINT32)(UINTN)gDebuggerExceptionHandlers[Index];\r
+    }\r
+  }\r
+\r
   // Flush Caches since we updated executable stuff\r
   InvalidateInstructionCacheRange ((VOID *)PcdGet32(PcdCpuVectorBaseAddress), Length);\r
 \r