]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h
UefiCpuPkg/LocalApic.h: Remove duplicated/conflicted definitions
[mirror_edk2.git] / SourceLevelDebugPkg / Library / DebugAgent / DebugAgentCommon / DebugAgent.h
index 9671ca4efe39e31ec70a83579a0684e1f09d3edc..e09ead9cf07433ea259af116b844a727ce9e0729 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Command header of for Debug Agent library instance.\r
 \r
-  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2016, 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
@@ -16,9 +16,9 @@
 #define _DEBUG_AGENT_H_\r
 \r
 #include <Register/LocalApic.h>\r
-\r
 #include <Guid/DebugAgentGuid.h>\r
-\r
+#include <Guid/VectorHandoffTable.h>\r
+#include <Ppi/VectorHandoffInfo.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/ResetSystemLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/SynchronizationLib.h>\r
 #include <Library/LocalApicLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/TimerLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/PeCoffGetEntryPointLib.h>\r
+#include <Library/PeCoffExtraActionLib.h>\r
+#include <Register/ArchitecturalMsr.h>\r
 \r
 #include <TransferProtocol.h>\r
 #include <ImageDebugSupport.h>\r
 #include "DebugMp.h"\r
 #include "DebugTimer.h"\r
 #include "ArchDebugSupport.h"\r
-\r
-#define DEBUG_AGENT_REVISION            ((0 << 16) | 01)\r
-#define DEBUG_AGENT_CAPABILITIES        0\r
-\r
-#define DEBUG_INT1_VECTOR               1\r
-#define DEBUG_INT3_VECTOR               3\r
+#include "DebugException.h"\r
+\r
+//\r
+// These macros may be already defined in DebugAgentLib.h\r
+//\r
+#define DEBUG_AGENT_INIT_PEI                     9\r
+#define DEBUG_AGENT_INIT_DXE_LOAD               10\r
+#define DEBUG_AGENT_INIT_DXE_UNLOAD             11\r
+#define DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64    12\r
+\r
+#define DEBUG_INT1_VECTOR               DEBUG_EXCEPT_DEBUG\r
+#define DEBUG_INT3_VECTOR               DEBUG_EXCEPT_BREAKPOINT\r
 #define DEBUG_TIMER_VECTOR              32\r
 #define DEBUG_MAILBOX_VECTOR            33\r
 \r
+//\r
+//  Timeout value for reading packet (unit is microsecond)\r
+//\r
+#define READ_PACKET_TIMEOUT     (500 * 1000)\r
+#define DEBUG_TIMER_INTERVAL    (100 * 1000)\r
+\r
 #define SOFT_INTERRUPT_SIGNATURE    SIGNATURE_32('S','O','F','T')\r
 #define SYSTEM_RESET_SIGNATURE      SIGNATURE_32('S','Y','S','R')\r
 #define MEMORY_READY_SIGNATURE      SIGNATURE_32('M','E','M','R')\r
 \r
 extern UINTN  Exception0Handle;\r
 extern UINTN  TimerInterruptHandle;\r
-extern UINT16 ExceptionStubHeaderSize;\r
+extern UINT32 ExceptionStubHeaderSize;\r
+extern BOOLEAN mSkipBreakpoint;\r
+extern EFI_VECTOR_HANDOFF_INFO mVectorHandoffInfoDebugAgent[];\r
+extern UINTN                   mVectorHandoffInfoCount;\r
+\r
+//\r
+// CPU exception information issued by debug agent\r
+//\r
+typedef struct {\r
+  //\r
+  // This field is used to save CPU content before executing HOST command\r
+  //\r
+  BASE_LIBRARY_JUMP_BUFFER            JumpBuffer;\r
+  //\r
+  // This field returns the exception information issued by the HOST command\r
+  //\r
+  DEBUG_DATA_RESPONSE_GET_EXCEPTION   ExceptionContent;\r
+} DEBUG_AGENT_EXCEPTION_BUFFER;\r
+\r
+#define DEBUG_AGENT_FLAG_HOST_ATTACHED         BIT0\r
+#define DEBUG_AGENT_FLAG_AGENT_IN_PROGRESS     BIT1\r
+#define DEBUG_AGENT_FLAG_MEMORY_READY          BIT2\r
+#define DEBUG_AGENT_FLAG_STEPPING              BIT3\r
+#define DEBUG_AGENT_FLAG_CHECK_MAILBOX_IN_HOB  BIT4\r
+#define DEBUG_AGENT_FLAG_INIT_ARCH             BIT5|BIT6\r
+#define DEBUG_AGENT_FLAG_INTERRUPT_FLAG        BIT7\r
+#define DEBUG_AGENT_FLAG_BREAK_ON_NEXT_SMI     BIT32\r
+#define DEBUG_AGENT_FLAG_PRINT_ERROR_LEVEL     (BIT33|BIT34|BIT35|BIT36)\r
+#define DEBUG_AGENT_FLAG_BREAK_BOOT_SCRIPT     BIT37\r
+\r
+#define DEBUG_MAILBOX_DEBUG_FLAG_INDEX                1\r
+#define DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX         2\r
+#define DEBUG_MAILBOX_EXCEPTION_BUFFER_POINTER_INDEX  3\r
+#define DEBUG_MAILBOX_LAST_ACK                        4\r
+#define DEBUG_MAILBOX_SEQUENCE_NO_INDEX               5\r
+#define DEBUG_MAILBOX_HOST_SEQUENCE_NO_INDEX          6\r
+#define DEBUG_MAILBOX_DEBUG_TIMER_FREQUENCY           7\r
 \r
+#pragma pack(1)\r
 typedef union {\r
   struct {\r
-    UINT32  HostPresent      : 1;\r
-    UINT32  BreakOnNextSmi   : 1;\r
-    UINT32  Reserved         : 30;\r
+    //\r
+    // Lower 32 bits to store the status of DebugAgent\r
+    //\r
+    UINT32  HostAttached      : 1;   // 1: HOST is attached\r
+    UINT32  AgentInProgress   : 1;   // 1: Debug Agent is communicating with HOST\r
+    UINT32  MemoryReady       : 1;   // 1: Memory is ready\r
+    UINT32  SteppingFlag      : 1;   // 1: Agent is running stepping command\r
+    UINT32  CheckMailboxInHob : 1;   // 1: Need to check mailbox saved in HOB\r
+    UINT32  InitArch          : 2;   // value of DEBUG_DATA_RESPONSE_ARCH_MODE\r
+    UINT32  InterruptFlag     : 1;   // 1: EFLAGS.IF is set\r
+    UINT32  Reserved1         : 24;\r
+    //\r
+    // Higher 32bits to control the behavior of DebugAgent\r
+    //\r
+    UINT32  BreakOnNextSmi    : 1;   // 1: Break on next SMI\r
+    UINT32  PrintErrorLevel   : 4;   // Bitmask of print error level for debug message\r
+    UINT32  BreakOnBootScript : 1;   // 1: Break before executing boot script \r
+    UINT32  Reserved2         : 26;\r
   } Bits;\r
-  UINT32  Uint32;\r
+  UINT64  Uint64;\r
 } DEBUG_AGENT_FLAG;\r
 \r
-#pragma pack(1)\r
 typedef struct {\r
   DEBUG_AGENT_FLAG           DebugFlag;\r
   UINT64                     DebugPortHandle;\r
+  //\r
+  // Pointer to DEBUG_AGENT_EXCEPTION_BUFFER\r
+  //\r
+  UINT64                     ExceptionBufferPointer;\r
+  UINT8                      LastAck;      // The last ack packet type\r
+  UINT8                      SequenceNo;\r
+  UINT8                      HostSequenceNo;\r
+  UINT32                     DebugTimerFrequency;\r
+  UINT8                      CheckSum;     // Mailbox checksum\r
+  UINT8                      ToBeCheckSum; // To be Mailbox checksum at the next\r
 } DEBUG_AGENT_MAILBOX;\r
 #pragma pack()\r
 \r
+///\r
+/// Byte packed structure for an IA-32 Interrupt Gate Descriptor.\r
+///\r
+typedef union {\r
+  struct {\r
+    UINT32  OffsetLow:16;   ///< Offset bits 15..0.\r
+    UINT32  Selector:16;    ///< Selector.\r
+    UINT32  Reserved_0:8;   ///< Reserved.\r
+    UINT32  GateType:8;     ///< Gate Type.  See #defines above.\r
+    UINT32  OffsetHigh:16;  ///< Offset bits 31..16.\r
+  } Bits;\r
+  UINT64  Uint64;\r
+} IA32_IDT_ENTRY;\r
+\r
+\r
 typedef union {\r
   struct {\r
     UINT32  LimitLow    : 16;\r
@@ -88,22 +182,6 @@ typedef union {
   UINT64  Uint64;\r
 } IA32_GDT;\r
 \r
-/**\r
-  Caller provided function to be invoked at the end of DebugPortInitialize().\r
-\r
-  Refer to the descrption for DebugPortInitialize() for more details.\r
-\r
-  @param[in] Context           The first input argument of DebugPortInitialize().\r
-  @param[in] DebugPortHandle   Debug port handle created by Debug Communication Libary.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-InitializeDebugAgentPhase2 (\r
-  IN VOID                  *Context,\r
-  IN DEBUG_PORT_HANDLE     DebugPortHandle\r
-  );\r
-\r
 /**\r
   Initialize IDT entries to support source level debug.\r
 \r
@@ -113,31 +191,11 @@ InitializeDebugIdt (
   VOID\r
   );\r
 \r
-/**\r
-  Write specified register into save CPU context.\r
-\r
-  @param[in] CpuContext         Pointer to saved CPU context.\r
-  @param[in] Index              Register index value.\r
-  @param[in] Offset             Offset in register address range\r
-  @param[in] Width              Data width to read.\r
-  @param[in] RegisterBuffer     Pointer to input buffer with data.\r
-\r
-**/\r
-VOID\r
-ArchWriteRegisterBuffer (\r
-  IN DEBUG_CPU_CONTEXT               *CpuContext,\r
-  IN UINT8                           Index,\r
-  IN UINT8                           Offset,\r
-  IN UINT8                           Width,\r
-  IN UINT8                           *RegisterBuffer\r
-  );\r
-\r
 /**\r
   Read register value from saved CPU context.\r
 \r
   @param[in] CpuContext         Pointer to saved CPU context.\r
   @param[in] Index              Register index value.\r
-  @param[in] Offset             Offset in register address range\r
   @param[in] Width              Data width to read.\r
 \r
   @return The address of register value.\r
@@ -147,16 +205,16 @@ UINT8 *
 ArchReadRegisterBuffer (\r
   IN DEBUG_CPU_CONTEXT               *CpuContext,\r
   IN UINT8                           Index,\r
-  IN UINT8                           Offset,\r
   IN UINT8                           *Width\r
   );\r
 \r
 /**\r
   Send packet with response data to HOST.\r
 \r
-  @param[in] CpuContext  Pointer to saved CPU context.\r
-  @param[in] Data        Pointer to response data buffer.\r
-  @param[in] DataSize    Size of response data in byte.\r
+  @param[in]      Data        Pointer to response data buffer.\r
+  @param[in]      DataSize    Size of response data in byte.\r
+  @param[in, out] DebugHeader Pointer to a buffer for creating response packet and receiving ACK packet,\r
+                              to minimize the stack usage.\r
 \r
   @retval RETURN_SUCCESS      Response data was sent successfully.\r
   @retval RETURN_DEVICE_ERROR Cannot receive DEBUG_COMMAND_OK from HOST.\r
@@ -164,144 +222,282 @@ ArchReadRegisterBuffer (
 **/\r
 RETURN_STATUS\r
 SendDataResponsePacket (\r
-  IN DEBUG_CPU_CONTEXT    *CpuContext,\r
-  IN UINT8                *Data,\r
-  IN UINT16               DataSize\r
+  IN UINT8                   *Data,\r
+  IN UINT16                  DataSize,\r
+  IN OUT DEBUG_PACKET_HEADER *DebugHeader\r
   );\r
 \r
 /**\r
-  Read segment selector by register index.\r
+  Check if HOST is attached based on Mailbox.\r
+\r
+  @retval TRUE        HOST is attached.\r
+  @retval FALSE       HOST is not attached.\r
+\r
+**/\r
+BOOLEAN\r
+IsHostAttached (\r
+  VOID\r
+  );\r
 \r
-  @param[in] CpuContext           Pointer to saved CPU context.\r
-  @param[in] RegisterIndex        Register Index.\r
+/**\r
+  Get Debug Agent Mailbox pointer.\r
 \r
-  @return Value of segment selector.\r
+  @return Mailbox pointer.\r
 \r
 **/\r
-UINT64\r
-ReadRegisterSelectorByIndex (\r
-  IN DEBUG_CPU_CONTEXT                       *CpuContext,\r
-  IN UINT8                                   RegisterIndex\r
+DEBUG_AGENT_MAILBOX *\r
+GetMailboxPointer (\r
+  VOID\r
   );\r
 \r
 /**\r
-  Read group register of common registers.\r
+  Get debug port handle.\r
 \r
-  @param[in] CpuContext           Pointer to saved CPU context.\r
-  @param[in] RegisterGroup        Pointer to Group registers.\r
+  @return Debug port handle.\r
+\r
+**/\r
+DEBUG_PORT_HANDLE\r
+GetDebugPortHandle (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Read the Attach/Break-in symbols from the debug port.\r
+\r
+  @param[in]  Handle         Pointer to Debug Port handle.\r
+  @param[out] BreakSymbol    Returned break symbol.\r
+\r
+  @retval EFI_SUCCESS        Read the symbol in BreakSymbol.\r
+  @retval EFI_NOT_FOUND      No read the break symbol.\r
+\r
+**/\r
+EFI_STATUS\r
+DebugReadBreakSymbol (\r
+  IN  DEBUG_PORT_HANDLE      Handle,\r
+  OUT UINT8                  *BreakSymbol\r
+  );\r
+\r
+/**\r
+  Prints a debug message to the debug port if the specified error level is enabled.\r
+\r
+  If any bit in ErrorLevel is also set in Mainbox, then print the message specified\r
+  by Format and the associated variable argument list to the debug port.\r
+\r
+  @param[in] ErrorLevel  The error level of the debug message.\r
+  @param[in] Format      Format string for the debug message to print.\r
+  @param[in] ...         Variable argument list whose contents are accessed \r
+                         based on the format string specified by Format.\r
 \r
 **/\r
 VOID\r
-ReadRegisterGroup (\r
-  IN DEBUG_CPU_CONTEXT                       *CpuContext,\r
-  IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP  *RegisterGroup\r
+EFIAPI\r
+DebugAgentMsgPrint (\r
+  IN UINT8         ErrorLevel,\r
+  IN CHAR8         *Format,\r
+  ...\r
   );\r
 \r
 /**\r
-  Read group register of Segment Base.\r
+  Trigger one software interrupt to debug agent to handle it.\r
 \r
-  @param[in] CpuContext           Pointer to saved CPU context.\r
-  @param[in] RegisterGroupSegBase Pointer to Group registers.\r
+  @param[in] Signature       Software interrupt signature.\r
 \r
 **/\r
 VOID\r
-ReadRegisterGroupSegBase (\r
-  IN DEBUG_CPU_CONTEXT                              *CpuContext,\r
-  IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP_SEGBASE *RegisterGroupSegBase\r
+TriggerSoftInterrupt (\r
+  IN UINT32                 Signature\r
   );\r
 \r
 /**\r
-  Read gourp register of Segment Limit.\r
+  Check if debug agent support multi-processor.\r
+\r
+  @retval TRUE    Multi-processor is supported.\r
+  @retval FALSE   Multi-processor is not supported.\r
 \r
-  @param[in] CpuContext           Pointer to saved CPU context.\r
-  @param[in] RegisterGroupSegLim  Pointer to Group registers.\r
+**/\r
+BOOLEAN\r
+MultiProcessorDebugSupport (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Find and report module image info to HOST.\r
+  \r
+  @param[in] AlignSize      Image aligned size.\r
+  \r
+**/\r
+VOID \r
+FindAndReportModuleImageInfo (\r
+  IN UINTN          AlignSize                   \r
+  );\r
+\r
+/**\r
+  Read IDT entry to check if IDT entries are setup by Debug Agent.\r
+\r
+  @retval  TRUE     IDT entries were setup by Debug Agent.\r
+  @retval  FALSE    IDT entries were not setup by Debug Agent.\r
+\r
+**/\r
+BOOLEAN \r
+IsDebugAgentInitialzed (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Calculate Mailbox checksum and update the checksum field.\r
+\r
+  @param[in]  Mailbox  Debug Agent Mailbox pointer.\r
 \r
 **/\r
 VOID\r
-ReadRegisterGroupSegLim (\r
-  IN DEBUG_CPU_CONTEXT                             *CpuContext,\r
-  IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP_SEGLIM *RegisterGroupSegLim\r
+UpdateMailboxChecksum (\r
+  IN DEBUG_AGENT_MAILBOX    *Mailbox\r
   );\r
 \r
 /**\r
-  Read group register by group index.\r
+  Verify Mailbox checksum.\r
 \r
-  @param[in] CpuContext           Pointer to saved CPU context.\r
-  @param[in] GroupIndex           Group Index.\r
+  If checksum error, print debug message and run init dead loop.\r
 \r
-  @retval RETURN_SUCCESS         Read successfully.\r
-  @retval RETURN_NOT_SUPPORTED   Group index cannot be supported.\r
+  @param[in]  Mailbox  Debug Agent Mailbox pointer.\r
 \r
 **/\r
-RETURN_STATUS\r
-ArchReadRegisterGroup (\r
-  IN DEBUG_CPU_CONTEXT                             *CpuContext,\r
-  IN UINT8                                         GroupIndex\r
+VOID \r
+VerifyMailboxChecksum (\r
+  IN DEBUG_AGENT_MAILBOX    *Mailbox\r
+  );\r
+\r
+/**\r
+  Set debug flag in mailbox.\r
+\r
+  @param[in]  FlagMask      Debug flag mask value.\r
+  @param[in]  FlagValue     Debug flag value.\r
+\r
+**/\r
+VOID \r
+SetDebugFlag (\r
+  IN UINT64                 FlagMask,\r
+  IN UINT32                 FlagValue                          \r
   );\r
 \r
 /**\r
-  Send acknowledge packet to HOST.\r
+  Get debug flag in mailbox.\r
 \r
-  @param AckCommand    Type of Acknowledge packet.\r
+  @param[in]  FlagMask      Debug flag mask value.\r
+  \r
+  @return Debug flag value.\r
 \r
+**/\r
+UINT32\r
+GetDebugFlag (\r
+  IN UINT64                 FlagMask\r
+  );\r
+\r
+/**\r
+  Update Mailbox content by index.\r
+\r
+  @param[in]  Mailbox  Debug Agent Mailbox pointer.\r
+  @param[in]  Index    Mailbox content index.\r
+  @param[in]  Value    Value to be set into mail box.\r
+  \r
 **/\r
 VOID\r
-SendAckPacket (\r
-  IN UINT8                AckCommand\r
+UpdateMailboxContent ( \r
+  IN DEBUG_AGENT_MAILBOX    *Mailbox,\r
+  IN UINTN                  Index,\r
+  IN UINT64                 Value\r
   );\r
 \r
 /**\r
-  Receive acknowledge packet OK from HOST in specified time.\r
+  Retrieve exception handler from IDT table by ExceptionNum.\r
+\r
+  @param[in]  ExceptionNum    Exception number\r
\r
+  @return Exception handler\r
+\r
+**/\r
+VOID *\r
+GetExceptionHandlerInIdtEntry (\r
+  IN UINTN             ExceptionNum\r
+  );\r
 \r
-  @param[in]  Timeout       Time out value to wait for acknowlege from HOST.\r
-                            The unit is microsecond.\r
-  @param[out] BreakReceived If BreakReceived is not NULL,\r
-                            TRUE is retured if break-in symbol received.\r
-                            FALSE is retured if break-in symbol not received.\r
+/**\r
+  Set exception handler in IDT table by ExceptionNum.\r
 \r
-  @retval  RETRUEN_SUCCESS  Succeed to receive acknowlege packet from HOST,\r
-                            the type of acknowlege packet saved in Ack.\r
-  @retval  RETURN_TIMEOUT   Specified timeout value was up.\r
+  @param[in]  ExceptionNum      Exception number\r
+  @param[in]  ExceptionHandler  Exception Handler to be set \r
 \r
 **/\r
-RETURN_STATUS\r
-WaitForAckPacketOK (\r
-  IN  UINTN                     Timeout,\r
-  OUT BOOLEAN                   *BreakReceived OPTIONAL\r
+VOID\r
+SetExceptionHandlerInIdtEntry (\r
+  IN UINTN             ExceptionNum,\r
+  IN VOID              *ExceptionHandler\r
   );\r
 \r
 /**\r
-  Check if HOST is connected based on Mailbox.\r
+  Prints a debug message to the debug output device if the specified error level is enabled.\r
 \r
-  @retval TRUE        HOST is connected.\r
-  @retval FALSE       HOST is not connected.\r
+  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function \r
+  GetDebugPrintErrorLevel (), then print the message specified by Format and the \r
+  associated variable argument list to the debug output device.\r
+\r
+  If Format is NULL, then ASSERT().\r
+\r
+  @param[in] ErrorLevel  The error level of the debug message.\r
+  @param[in] IsSend      Flag of debug message to declare that the data is being sent or being received.\r
+  @param[in] Data        Variable argument list whose contents are accessed \r
+  @param[in] Length      based on the format string specified by Format.\r
 \r
 **/\r
-BOOLEAN\r
-IsHostConnected (\r
-  VOID\r
+VOID\r
+EFIAPI\r
+DebugAgentDataMsgPrint (\r
+  IN UINT8             ErrorLevel,\r
+  IN BOOLEAN           IsSend,\r
+  IN UINT8             *Data,\r
+  IN UINT8             Length  \r
   );\r
 \r
 /**\r
-  Get Debug Agent Mailbox pointer.\r
+  Read remaing debug packet except for the start symbol\r
 \r
-  @return Mailbox pointer.\r
+  @param[in]      Handle        Pointer to Debug Port handle.\r
+  @param[in, out] DebugHeader   Debug header buffer including start symbol.\r
+\r
+  @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
 \r
 **/\r
-DEBUG_AGENT_MAILBOX *\r
-GetMailboxPointer (\r
-  VOID\r
+EFI_STATUS\r
+ReadRemainingBreakPacket (\r
+  IN     DEBUG_PORT_HANDLE      Handle,\r
+  IN OUT DEBUG_PACKET_HEADER    *DebugHeader\r
   );\r
 \r
 /**\r
-  Get debug port handle.\r
+  Read data from debug channel and save the data in buffer.\r
 \r
-  @return Debug port handle.\r
+  Reads NumberOfBytes data bytes from a debug device into the buffer\r
+  specified by Buffer. The number of bytes actually read is returned.\r
+  If the return value is less than NumberOfBytes, then the rest operation failed.\r
+  If NumberOfBytes is zero, then return 0.\r
+\r
+  @param  Handle           Debug port handle.\r
+  @param  Buffer           Pointer to the data buffer to store the data read from the debug device.\r
+  @param  NumberOfBytes    Number of bytes which will be read.\r
+  @param  Timeout          Timeout value for reading from debug device. It unit is Microsecond.\r
+\r
+  @retval 0                Read data failed, no data is to be read.\r
+  @retval >0               Actual number of bytes read from debug device.\r
 \r
 **/\r
-DEBUG_PORT_HANDLE\r
-GetDebugPortHandle (\r
-  VOID\r
+UINTN\r
+DebugAgentReadBuffer (\r
+  IN     DEBUG_PORT_HANDLE     Handle,\r
+  IN OUT UINT8                 *Buffer,\r
+  IN     UINTN                 NumberOfBytes,\r
+  IN     UINTN                 Timeout\r
   );\r
 \r
 #endif\r