]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Clean up using FIQ as ctrl-c checker so you can break in from the debugger.
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 21 Apr 2010 22:08:28 +0000 (22:08 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 21 Apr 2010 22:08:28 +0000 (22:08 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10390 6f19259b-4bc3-4df7-8a09-765794883524

EmbeddedPkg/Library/GdbDebugAgent/Arm/ExceptionSupport.ARMv6.S
EmbeddedPkg/Library/GdbDebugAgent/Arm/ExceptionSupport.ARMv6.asm
EmbeddedPkg/Library/GdbDebugAgent/Arm/Processor.c
EmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.inf

index bb4d17c5ad086e09aff7779532a1723430afd0f9..c85dc0b33beb4236b0c2dec7ebc8efc93810679c 100755 (executable)
@@ -94,7 +94,7 @@ ASM_PFX(Fiq):
 ASM_PFX(UndefinedInstructionEntry):
   sub       LR, LR, #4                @ Only -2 for Thumb, adjust in CommonExceptionEntry
   srsdb     #0x13!                    @ Store return state on SVC stack
-  cps       #0x13                     @ Switch to SVC for common stack
+  cpsid     f,#0x13                   @ Switch to SVC for common stack
   stmfd     SP!,{LR}                  @ Store the link register for the current mode
   sub       SP,SP,#0x20               @ Save space for SP, LR, PC, IFAR - CPSR
   stmfd     SP!,{R0-R12}              @ Store the register state
@@ -106,7 +106,7 @@ ASM_PFX(UndefinedInstructionEntry):
 ASM_PFX(SoftwareInterruptEntry):
   sub       LR, LR, #4                @ Only -2 for Thumb, adjust in CommonExceptionEntry
   srsdb     #0x13!                    @ Store return state on SVC stack
-                                      @ We are already in SVC mode
+  cpsid     f                         @ We are already in SVC mode
   stmfd     SP!,{LR}                  @ Store the link register for the current mode
   sub       SP,SP,#0x20               @ Save space for SP, LR, PC, IFAR - CPSR
   stmfd     SP!,{R0-R12}              @ Store the register state
@@ -118,7 +118,7 @@ ASM_PFX(SoftwareInterruptEntry):
 ASM_PFX(PrefetchAbortEntry):
   sub       LR,LR,#4
   srsdb     #0x13!                    @ Store return state on SVC stack
-  cps       #0x13                     @ Switch to SVC for common stack
+  cpsid     f,#0x13                   @ Switch to SVC for common stack
   stmfd     SP!,{LR}                  @ Store the link register for the current mode
   sub       SP,SP,#0x20               @ Save space for SP, LR, PC, IFAR - CPSR
   stmfd     SP!,{R0-R12}              @ Store the register state
@@ -130,7 +130,7 @@ ASM_PFX(PrefetchAbortEntry):
 ASM_PFX(DataAbortEntry):
   sub       LR,LR,#8
   srsdb     #0x13!                    @ Store return state on SVC stack
-  cps       #0x13                     @ Switch to SVC for common stack
+  cpsid     f,#0x13                   @ Switch to SVC for common stack
   stmfd     SP!,{LR}                  @ Store the link register for the current mode
   sub       SP,SP,#0x20               @ Save space for SP, LR, PC, IFAR - CPSR
   stmfd     SP!,{R0-R12}              @ Store the register state
@@ -141,7 +141,7 @@ ASM_PFX(DataAbortEntry):
 
 ASM_PFX(ReservedExceptionEntry):
   srsdb     #0x13!                    @ Store return state on SVC stack
-  cps       #0x13                     @ Switch to SVC for common stack
+  cpsid     f,#0x13                   @ Switch to SVC for common stack
   stmfd     SP!,{LR}                  @ Store the link register for the current mode
   sub       SP,SP,#0x20               @ Save space for SP, LR, PC, IFAR - CPSR
   stmfd     SP!,{R0-R12}              @ Store the register state
index 3dccf5b077201ef06f77e0e91951533c01add2cc..346867149ac8242f41fac859410b1497dbcc8441 100755 (executable)
@@ -95,7 +95,7 @@ Fiq
 UndefinedInstructionEntry
   sub       LR, LR, #4                ; Only -2 for Thumb, adjust in CommonExceptionEntry
   srsfd     #0x13!                    ; Store return state on SVC stack
-  cps       #0x13                     ; Switch to SVC for common stack
+  cpsid     f, #0x13                  ; Switch to SVC for common stack
   stmfd     SP!,{LR}                  ; Store the link register for the current mode
   sub       SP,SP,#0x20               ; Save space for SP, LR, PC, IFAR - CPSR
   stmfd     SP!,{R0-R12}              ; Store the register state
@@ -107,7 +107,7 @@ UndefinedInstructionEntry
 SoftwareInterruptEntry
   sub       LR, LR, #4                ; Only -2 for Thumb, adjust in CommonExceptionEntry
   srsfd     #0x13!                    ; Store return state on SVC stack
-                                      ; We are already in SVC mode
+  cpsid     f                         ; We are already in SVC mode
   stmfd     SP!,{LR}                  ; Store the link register for the current mode
   sub       SP,SP,#0x20               ; Save space for SP, LR, PC, IFAR - CPSR
   stmfd     SP!,{R0-R12}              ; Store the register state
@@ -119,7 +119,7 @@ SoftwareInterruptEntry
 PrefetchAbortEntry
   sub       LR,LR,#4
   srsfd     #0x13!                    ; Store return state on SVC stack
-  cps       #0x13                     ; Switch to SVC for common stack
+  cpsid     f, #0x13                  ; Switch to SVC for common stack
   stmfd     SP!,{LR}                  ; Store the link register for the current mode
   sub       SP,SP,#0x20               ; Save space for SP, LR, PC, IFAR - CPSR
   stmfd     SP!,{R0-R12}              ; Store the register state
@@ -131,7 +131,7 @@ PrefetchAbortEntry
 DataAbortEntry
   sub       LR,LR,#8
   srsfd     #0x13!                    ; Store return state on SVC stack
-  cps       #0x13                     ; Switch to SVC for common stack
+  cpsid     f, #0x13                  ; Switch to SVC for common stack
   stmfd     SP!,{LR}                  ; Store the link register for the current mode
   sub       SP,SP,#0x20               ; Save space for SP, LR, PC, IFAR - CPSR
   stmfd     SP!,{R0-R12}              ; Store the register state
@@ -142,7 +142,7 @@ DataAbortEntry
 
 ReservedExceptionEntry
   srsfd     #0x13!                    ; Store return state on SVC stack
-  cps       #0x13                     ; Switch to SVC for common stack
+  cpsid     f, #0x13                  ; Switch to SVC for common stack
   stmfd     SP!,{LR}                  ; Store the link register for the current mode
   sub       SP,SP,#0x20               ; Save space for SP, LR, PC, IFAR - CPSR
   stmfd     SP!,{R0-R12}              ; Store the register state
index e09e18d6c1c8eafa72a2c81f7e5797d4a8c30444..21c868aeb2b44fe55b19a183cbae7b609fd244ff 100755 (executable)
@@ -466,6 +466,33 @@ ProcessorSendTSignal (
   *TSignalPtr = '\0';
 }
 \r
+/**\r
+ FIQ state is only changed by FIQ exception. We don't want to take FIQ\r
+ ticks in the GDB stub. The stub disables FIQ on entry, but this is the \r
+ third instruction that executes in the execption handler. Thus we have\r
+ a crack we need to test for.\r
+\r
+ @param PC     PC of execption\r
+\r
+ @return  TRUE  We are in the GDB stub exception preamble \r
+ @return  FALSE We are not in GDB stub code\r
+ **/
+BOOLEAN
+InFiqCrack (
+  IN UINT32 PC
+  )
+{
+  UINT32 VectorBase = PcdGet32 (PcdCpuVectorBaseAddress);
+  UINT32 Length     = (UINTN)ExceptionHandlersEnd - (UINTN)ExceptionHandlersStart;
+
+  if ((PC >= VectorBase) && (PC <= (VectorBase + Length))) {
+    return TRUE;
+  }
+
+  return FALSE;
+}
+\r
+\r
 /**\r
  Check to see if this exception is related to ctrl-c handling.\r
 \r
@@ -486,6 +513,7 @@ ProcessorControlC (
   IN OUT EFI_SYSTEM_CONTEXT     SystemContext \r
   )\r
 {\r
+  CHAR8     Char;\r
   BOOLEAN   Return = TRUE;\r
 \r
   if (ExceptionType != EXCEPT_ARM_FIQ) {\r
@@ -493,6 +521,12 @@ ProcessorControlC (
     return FALSE;\r
   }\r
 \r
+  if (InFiqCrack (SystemContext.SystemContextArm->PC)) {\r
+    // We are in our own interrupt preable, so skip this tick.\r
+    // We never want to let gdb see the debug stub running if we can help it\r
+    return FALSE;\r
+  }\r
+\r
   while (TRUE) {
     if (!GdbIsCharAvailable ()) {
       //
@@ -502,7 +536,8 @@ ProcessorControlC (
       break;
     }
     
-    if (GdbGetChar () == 0x03) {
+    Char = GdbGetChar ();
+    if (Char == 0x03) {
       //
       // We have a ctrl-c so exit and process exception for ctrl-c
       //
@@ -527,7 +562,8 @@ ProcessorControlC (
 \r
   @param[in] EnableStatus    Enable/Disable.\r
 \r
-  @return FALSE always.\r
+  @retval TRUE  Debug timer interrupt were enabled on entry to this call.\r
+  @retval FALSE Debug timer interrupt were disabled on entry to this call.\r
 \r
 **/\r
 BOOLEAN\r
@@ -541,7 +577,7 @@ SaveAndSetDebugTimerInterrupt (
   FiqEnabled = ArmGetFiqState ();\r
 \r
   if (EnableStatus) {\r
-    DebugAgentTimerSetPeriod (100);\r
+    DebugAgentTimerSetPeriod (PcdGet32 (PcdGdbTimerPeriodMilliseconds));\r
     ArmEnableFiq ();\r
   } else {\r
     DebugAgentTimerSetPeriod (0);\r
@@ -551,6 +587,8 @@ SaveAndSetDebugTimerInterrupt (
   return FiqEnabled;\r
 }\r
 \r
+\r
+\r
 VOID\r
 GdbFPutString (\r
   IN CHAR8  *String\r
@@ -575,21 +613,14 @@ InitializeDebugAgent (
   UINTN                Offset;\r
   UINTN                Length;\r
   BOOLEAN              IrqEnabled;\r
-  BOOLEAN              FiqEnabled;\r
   UINT32               *VectorBase;\r
 \r
-    
+
   //\r
   // Disable interrupts\r
   //\r
   IrqEnabled = ArmGetInterruptState ();\r
   ArmDisableInterrupts ();\r
-\r
-  //\r
-  // EFI does not use the FIQ, but a debugger might so we must disable \r
-  // as we take over the exception vectors. \r
-  //\r
-  FiqEnabled = ArmGetFiqState ();\r
   ArmDisableFiq ();\r
 \r
   //\r
@@ -615,12 +646,9 @@ InitializeDebugAgent (
   // Flush Caches since we updated executable stuff\r
   InvalidateInstructionCacheRange ((VOID *)PcdGet32(PcdCpuVectorBaseAddress), Length);\r
 \r
+  // setup a timer so gdb can break in via ctrl-c\r
   DebugAgentTimerIntialize ();\r
 \r
-  if (FiqEnabled) {\r
-    ArmEnableFiq ();\r
-  }\r
-\r
   if (IrqEnabled) {\r
     ArmEnableInterrupts ();\r
   }\r
index 9ccb90bf4b14dc213f1fce99d73bf48f33edad04..ed006dcabdef42c119eea7313d46583299dbaaa9 100755 (executable)
@@ -64,6 +64,7 @@
 \r
 [FixedPcd.common]\r
   gEmbeddedTokenSpaceGuid.PcdGdbMaxPacketRetryCount\r
+  gEmbeddedTokenSpaceGuid.PcdGdbTimerPeriodMilliseconds\r
 \r
 [FixedPcd.arm]\r
   gArmTokenSpaceGuid.PcdCpuVectorBaseAddress\r