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
#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
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
\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