diff options
author | Jeff Fan <jeff.fan@intel.com> | 2015-04-27 05:23:43 +0000 |
---|---|---|
committer | vanjeff <vanjeff@Edk2> | 2015-04-27 05:23:43 +0000 |
commit | 994140183fc622631d305a216b3fbfa776137b8e (patch) | |
tree | 71bbf5cf0524e9193247e224d5520baf29f46489 /SourceLevelDebugPkg/Library/DebugAgent | |
parent | 5d51ba26317032f198654539249e946c24e911df (diff) | |
download | edk2-994140183fc622631d305a216b3fbfa776137b8e.tar.gz edk2-994140183fc622631d305a216b3fbfa776137b8e.tar.bz2 edk2-994140183fc622631d305a216b3fbfa776137b8e.zip |
SourceLevelDebugPkg/DebugAgent: Clear/Restore EFLAGS.IF
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
Diffstat (limited to 'SourceLevelDebugPkg/Library/DebugAgent')
-rw-r--r-- | SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c index f51ad4b456..7f597352f1 100644 --- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c +++ b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c @@ -785,7 +785,7 @@ CommandGo ( }
/**
- Exectue Stepping command.
+ Execute Stepping command.
@param[in] CpuContext Pointer to saved CPU context.
@@ -800,6 +800,39 @@ CommandStepping ( Eflags = (IA32_EFLAGS32 *) &CpuContext->Eflags;
Eflags->Bits.TF = 1;
Eflags->Bits.RF = 1;
+ //
+ // Save and clear EFLAGS.IF to avoid interrupt happen when executing Stepping
+ //
+ SetDebugFlag (DEBUG_AGENT_FLAG_INTERRUPT_FLAG, Eflags->Bits.IF);
+ Eflags->Bits.IF = 0;
+ //
+ // Set Stepping Flag
+ //
+ SetDebugFlag (DEBUG_AGENT_FLAG_STEPPING, 1);
+}
+
+/**
+ Do some cleanup after Stepping command done.
+
+ @param[in] CpuContext Pointer to saved CPU context.
+
+**/
+VOID
+CommandSteppingCleanup (
+ IN DEBUG_CPU_CONTEXT *CpuContext
+ )
+{
+ IA32_EFLAGS32 *Eflags;
+
+ Eflags = (IA32_EFLAGS32 *) &CpuContext->Eflags;
+ //
+ // Restore EFLAGS.IF
+ //
+ Eflags->Bits.IF = GetDebugFlag (DEBUG_AGENT_FLAG_INTERRUPT_FLAG);
+ //
+ // Clear Stepping flag
+ //
+ SetDebugFlag (DEBUG_AGENT_FLAG_STEPPING, 0);
}
/**
@@ -2066,10 +2099,6 @@ CommandCommunication ( }
mDebugMpContext.BreakAtCpuIndex = (UINT32) (-1);
- //
- // Set Stepping Flag
- //
- SetDebugFlag (DEBUG_AGENT_FLAG_STEPPING, 1);
ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
//
// Executing stepping command directly without sending ACK packet,
@@ -2405,11 +2434,11 @@ InterruptProcess ( if (MultiProcessorDebugSupport()) {
mDebugMpContext.BreakAtCpuIndex = ProcessorIndex;
}
- SendAckPacket (DEBUG_COMMAND_OK);
//
- // Clear Stepping Flag
+ // Clear Stepping Flag and restore EFLAGS.IF
//
- SetDebugFlag (DEBUG_AGENT_FLAG_STEPPING, 0);
+ CommandSteppingCleanup (CpuContext);
+ SendAckPacket (DEBUG_COMMAND_OK);
CommandCommunication (Vector, CpuContext, BreakReceived);
break;
@@ -2582,6 +2611,10 @@ InterruptProcess ( if (MultiProcessorDebugSupport()) {
mDebugMpContext.BreakAtCpuIndex = ProcessorIndex;
}
+ //
+ // Clear Stepping flag and restore EFLAGS.IF
+ //
+ CommandSteppingCleanup (CpuContext);
SendAckPacket (DEBUG_COMMAND_OK);
} else {
//
|