]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c
Refine code to make it more safely.
[mirror_edk2.git] / SourceLevelDebugPkg / Library / DebugAgent / DebugAgentCommon / DebugAgent.c
index 91b29af82a001554f64279d90b7d9ef604803d6f..48bc38ca547cbb6fa1eb47477c23962899bde3b1 100644 (file)
@@ -4,7 +4,7 @@
   read/write debug packet to communication with HOST based on transfer\r
   protocol.\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
@@ -19,7 +19,7 @@
 #include "Ia32/DebugException.h"\r
 \r
 CHAR8 mErrorMsgVersionAlert[]       = "\rThe SourceLevelDebugPkg you are using requires a newer version of the Intel(R) UDK Debugger Tool.\r\n";\r
-CHAR8 mErrorMsgSendInitPacket[]     = "\rSend INIT break packet and try to connect the HOST (Intel(R) UDK Debugger Tool v1.3.1) ...\r\n";\r
+CHAR8 mErrorMsgSendInitPacket[]     = "\rSend INIT break packet and try to connect the HOST (Intel(R) UDK Debugger Tool v1.4) ...\r\n";\r
 CHAR8 mErrorMsgConnectOK[]          = "HOST connection is successful!\r\n";\r
 CHAR8 mErrorMsgConnectFail[]        = "HOST connection is failed!\r\n";\r
 CHAR8 mWarningMsgIngoreBreakpoint[] = "Ignore break point in SMM for SMI issued during DXE debugging!\r\n";\r
@@ -374,7 +374,6 @@ UpdateMailboxContent (
     Mailbox->SequenceNo = (UINT8) Value;\r
     break;\r
   case DEBUG_MAILBOX_HOST_SEQUENCE_NO_INDEX:\r
-    DebugAgentMsgPrint (DEBUG_AGENT_INFO, "Update HostSequenceNo to %x\n", Value);\r
     Mailbox->ToBeCheckSum = Mailbox->CheckSum + CalculateSum8 ((UINT8 *)&Mailbox->HostSequenceNo, sizeof(UINT8))\r
                                               - CalculateSum8 ((UINT8 *)&Value, sizeof(UINT8));\r
     Mailbox->HostSequenceNo = (UINT8) Value;\r
@@ -588,7 +587,7 @@ ReadRemainingBreakPacket (
   //\r
   // Has received start symbol, try to read the rest part\r
   //\r
-  if (DebugPortReadBuffer (Handle, &DebugHeader->Command, sizeof (DEBUG_PACKET_HEADER) - 1, READ_PACKET_TIMEOUT) == 0) {\r
+  if (DebugPortReadBuffer (Handle, (UINT8 *)DebugHeader + OFFSET_OF (DEBUG_PACKET_HEADER, Command), sizeof (DEBUG_PACKET_HEADER) - OFFSET_OF (DEBUG_PACKET_HEADER, Command), READ_PACKET_TIMEOUT) == 0) {\r
     //\r
     // Timeout occur, exit\r
     //\r
@@ -604,7 +603,7 @@ ReadRemainingBreakPacket (
     return EFI_CRC_ERROR;\r
   }\r
   Mailbox = GetMailboxPointer();\r
-  if (((DebugHeader->Command & DEBUG_COMMAND_RESPONSE) != 0) &&\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
@@ -1015,7 +1014,7 @@ ReceivePacket (
     //\r
     Received = DebugPortReadBuffer (\r
                  Handle,\r
-                 &DebugHeader->Command,\r
+                 (UINT8 *)DebugHeader + OFFSET_OF (DEBUG_PACKET_HEADER, Command),\r
                  OFFSET_OF (DEBUG_PACKET_HEADER, Length) + sizeof (DebugHeader->Length) - sizeof (DebugHeader->StartSymbol),\r
                  Timeout\r
                  );\r
@@ -2105,6 +2104,7 @@ InterruptProcess (
   UINT32                           IssuedViewPoint;\r
   DEBUG_AGENT_EXCEPTION_BUFFER     *ExceptionBuffer;\r
 \r
+  InputCharacter  = 0;\r
   ProcessorIndex  = 0;\r
   IssuedViewPoint = 0;\r
   BreakReceived   = FALSE;\r