]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SourceLevelDebugPkg/DebugAgent: Clear/Restore EFLAGS.IF
authorJeff Fan <jeff.fan@intel.com>
Mon, 27 Apr 2015 05:23:43 +0000 (05:23 +0000)
committervanjeff <vanjeff@Edk2>
Mon, 27 Apr 2015 05:23:43 +0000 (05:23 +0000)
Clear EFLAGS.IF before executing Stepping command and save original
value in DEBUG_AGENT_FLAG. It could avoid pending interrupt issued
during executing Stepping command. Restore EFLAGS.IF after Stepping
command execution finished.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17204 6f19259b-4bc3-4df7-8a09-765794883524

SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c

index f51ad4b4565dc4e4c482f3440babad3fb80dcef5..7f597352f1f2f8cd59e67d8eee9ac4067eac3b06 100644 (file)
@@ -785,7 +785,7 @@ CommandGo (
 }\r
 \r
 /**\r
-  Exectue Stepping command.\r
+  Execute Stepping command.\r
 \r
   @param[in] CpuContext        Pointer to saved CPU context.\r
 \r
@@ -800,6 +800,39 @@ CommandStepping (
   Eflags = (IA32_EFLAGS32 *) &CpuContext->Eflags;\r
   Eflags->Bits.TF = 1;\r
   Eflags->Bits.RF = 1;\r
+  //\r
+  // Save and clear EFLAGS.IF to avoid interrupt happen when executing Stepping\r
+  //\r
+  SetDebugFlag (DEBUG_AGENT_FLAG_INTERRUPT_FLAG, Eflags->Bits.IF);\r
+  Eflags->Bits.IF = 0;\r
+  //\r
+  // Set Stepping Flag\r
+  //\r
+  SetDebugFlag (DEBUG_AGENT_FLAG_STEPPING, 1);\r
+}\r
+\r
+/**\r
+  Do some cleanup after Stepping command done.\r
+\r
+  @param[in] CpuContext        Pointer to saved CPU context.\r
+\r
+**/\r
+VOID\r
+CommandSteppingCleanup (\r
+  IN DEBUG_CPU_CONTEXT          *CpuContext\r
+  )\r
+{\r
+  IA32_EFLAGS32                *Eflags;\r
+\r
+  Eflags = (IA32_EFLAGS32 *) &CpuContext->Eflags;\r
+  //\r
+  // Restore EFLAGS.IF\r
+  //\r
+  Eflags->Bits.IF = GetDebugFlag (DEBUG_AGENT_FLAG_INTERRUPT_FLAG);\r
+  //\r
+  // Clear Stepping flag\r
+  //\r
+  SetDebugFlag (DEBUG_AGENT_FLAG_STEPPING, 0);\r
 }\r
 \r
 /**\r
@@ -2066,10 +2099,6 @@ CommandCommunication (
       }\r
 \r
       mDebugMpContext.BreakAtCpuIndex = (UINT32) (-1);\r
-      //\r
-      // Set Stepping Flag\r
-      //\r
-      SetDebugFlag (DEBUG_AGENT_FLAG_STEPPING, 1);\r
       ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);\r
       //\r
       // Executing stepping command directly without sending ACK packet,\r
@@ -2405,11 +2434,11 @@ InterruptProcess (
       if (MultiProcessorDebugSupport()) {\r
         mDebugMpContext.BreakAtCpuIndex = ProcessorIndex;\r
       }\r
-      SendAckPacket (DEBUG_COMMAND_OK);\r
       //\r
-      // Clear Stepping Flag\r
+      // Clear Stepping Flag and restore EFLAGS.IF\r
       //\r
-      SetDebugFlag (DEBUG_AGENT_FLAG_STEPPING, 0);\r
+      CommandSteppingCleanup (CpuContext);\r
+      SendAckPacket (DEBUG_COMMAND_OK);\r
       CommandCommunication (Vector, CpuContext, BreakReceived);\r
       break;\r
 \r
@@ -2582,6 +2611,10 @@ InterruptProcess (
         if (MultiProcessorDebugSupport()) {\r
           mDebugMpContext.BreakAtCpuIndex = ProcessorIndex;\r
         }\r
+        //\r
+        // Clear Stepping flag and restore EFLAGS.IF\r
+        //\r
+        CommandSteppingCleanup (CpuContext);\r
         SendAckPacket (DEBUG_COMMAND_OK);\r
       } else {\r
         //\r