]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix a bug in DebugAgent that hang happens when the ACK for GO is lost.
authorRuiyu Ni <ruiyu.ni@intel.com>
Mon, 10 Nov 2014 08:47:49 +0000 (08:47 +0000)
committerniruiyu <niruiyu@Edk2>
Mon, 10 Nov 2014 08:47:49 +0000 (08:47 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16322 6f19259b-4bc3-4df7-8a09-765794883524

SourceLevelDebugPkg/Include/TransferProtocol.h
SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c

index 53e9f7cf3689c26dd8b1e613eefaece6bb36d4a0..42add9164a831e2447c73e3c9e82e9c921c6ea56 100644 (file)
@@ -2,7 +2,7 @@
   Transfer protocol defintions used by debug agent and host. It is only\r
   intended to be used by Debug related module implementation.\r
 \r
-  Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -53,6 +53,8 @@ typedef struct {
 #define DEBUG_COMMAND_REQUEST      (0 << 7)\r
 #define DEBUG_COMMAND_RESPONSE     (1 << 7)\r
 \r
+#define IS_REQUEST(x)              (((x)->Command & DEBUG_COMMAND_RESPONSE) == 0)\r
+\r
 //\r
 // HOST initiated commands\r
 //\r
index a22494f3648f82100e3868be9f0977905846d58e..99878903b1d871076e4f9a85e671b8eb6c55a153 100644 (file)
@@ -605,19 +605,20 @@ ReadRemainingBreakPacket (
     return EFI_CRC_ERROR;\r
   }\r
   Mailbox = GetMailboxPointer();\r
-  if (((DebugHeader->Command & DEBUG_COMMAND_RESPONSE) == 0) &&\r
-       (DebugHeader->SequenceNo == (UINT8) (Mailbox->HostSequenceNo + 1))) {\r
-    //\r
-    // Only updagte HostSequenceNo for new command packet\r
-    //\r
-    UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_HOST_SEQUENCE_NO_INDEX, DebugHeader->SequenceNo);\r
-    return EFI_SUCCESS;\r
-  } else {\r
-    //\r
-    // If one old command or response packet received, skip it\r
-    //\r
-    return EFI_DEVICE_ERROR;\r
+  if (IS_REQUEST (DebugHeader)) {\r
+    if (DebugHeader->SequenceNo == (UINT8) (Mailbox->HostSequenceNo + 1)) {\r
+      //\r
+      // Only updagte HostSequenceNo for new command packet \r
+      //\r
+      UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_HOST_SEQUENCE_NO_INDEX, DebugHeader->SequenceNo);\r
+      return EFI_SUCCESS;\r
+    }\r
+    if (DebugHeader->SequenceNo == Mailbox->HostSequenceNo) {\r
+      return EFI_SUCCESS;\r
+    }\r
   }\r
+\r
+  return EFI_DEVICE_ERROR;\r
 }\r
 \r
 /**\r
@@ -1646,7 +1647,7 @@ CommandCommunication (
 \r
     DebugAgentMsgPrint (DEBUG_AGENT_INFO, "TARGET: Try to get command from HOST...\n");\r
     Status = ReceivePacket ((UINT8 *)DebugHeader, &BreakReceived, NULL, READ_PACKET_TIMEOUT, TRUE);\r
-    if (Status != RETURN_SUCCESS || (DebugHeader->Command & DEBUG_COMMAND_RESPONSE) != 0) {\r
+    if (Status != RETURN_SUCCESS || !IS_REQUEST (DebugHeader)) {\r
       DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "TARGET: Get command[%x] sequenceno[%x] returned status is [%x] \n", DebugHeader->Command, DebugHeader->SequenceNo, Status);\r
       DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "TARGET: Get command failed or it's response packet not expected! \n");\r
       ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);\r