]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c
Update Debug Agent initialization message to change the version string from "1.3...
[mirror_edk2.git] / SourceLevelDebugPkg / Library / DebugAgent / DebugAgentCommon / DebugAgent.c
index eee1cc998c42851bae18f59156a5a2733bdd7f94..95306e5759e767d0d62980013af24c4f80555f42 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
 #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) ...\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
 \r
+//\r
+// Vector Handoff Info list used by Debug Agent for persist\r
+//\r
+EFI_VECTOR_HANDOFF_INFO mVectorHandoffInfoDebugAgent[] = {\r
+  {\r
+    DEBUG_EXCEPT_DIVIDE_ERROR,         // Vector 0\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_DEBUG,                // Vector 1\r
+    EFI_VECTOR_HANDOFF_DO_NOT_HOOK,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_NMI,                  // Vector 2\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_BREAKPOINT,           // Vector 3\r
+    EFI_VECTOR_HANDOFF_DO_NOT_HOOK,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_OVERFLOW,             // Vector 4\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_BOUND,                // Vector 5\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_INVALID_OPCODE,       // Vector 6\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_DOUBLE_FAULT,         // Vector 8\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_INVALID_TSS,          // Vector 10\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_SEG_NOT_PRESENT,      // Vector 11\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_STACK_FAULT,          // Vector 12\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_GP_FAULT,             // Vector 13\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+    {\r
+    DEBUG_EXCEPT_PAGE_FAULT,           // Vector 14\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_FP_ERROR,             // Vector 16\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_ALIGNMENT_CHECK,      // Vector 17\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_MACHINE_CHECK,        // Vector 18\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_SIMD,                 // Vector 19\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_TIMER_VECTOR,                // Vector 32\r
+    EFI_VECTOR_HANDOFF_DO_NOT_HOOK,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_MAILBOX_VECTOR,              // Vector 33\r
+    EFI_VECTOR_HANDOFF_DO_NOT_HOOK,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    0,\r
+    EFI_VECTOR_HANDOFF_LAST_ENTRY,\r
+    { 0 }\r
+  }\r
+};\r
+\r
+UINTN mVectorHandoffInfoCount = sizeof (mVectorHandoffInfoDebugAgent) / sizeof (EFI_VECTOR_HANDOFF_INFO);\r
+\r
 /**\r
   Calculate CRC16 for target data.\r
 \r
@@ -464,6 +572,7 @@ DebugAgentDataMsgPrint (
   @retval EFI_SUCCESS        Read the symbol in BreakSymbol.\r
   @retval EFI_CRC_ERROR      CRC check fail.\r
   @retval EFI_TIMEOUT        Timeout occurs when reading debug packet.\r
+  @retval EFI_DEVICE_ERROR   Receive the old or responsed packet.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -473,6 +582,8 @@ ReadRemainingBreakPacket (
   )\r
 {\r
   UINT16                     Crc;\r
+  DEBUG_AGENT_MAILBOX        *Mailbox;\r
+\r
   //\r
   // Has received start symbol, try to read the rest part\r
   //\r
@@ -491,9 +602,20 @@ ReadRemainingBreakPacket (
     DebugAgentDataMsgPrint (DEBUG_AGENT_VERBOSE, FALSE, (UINT8 *)DebugHeader, DebugHeader->Length);\r
     return EFI_CRC_ERROR;\r
   }\r
-\r
-  UpdateMailboxContent (GetMailboxPointer(), DEBUG_MAILBOX_HOST_SEQUENCE_NO_INDEX, DebugHeader->SequenceNo);\r
-  return EFI_SUCCESS;\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
+  }\r
 }\r
 \r
 /**\r