]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c
Fix a bug in DebugAgent that hang happens when the ACK for GO is lost.
[mirror_edk2.git] / SourceLevelDebugPkg / Library / DebugAgent / DebugAgentCommon / DebugAgent.c
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