/** @file\r
Command header of for Debug Agent library instance.\r
\r
- Copyright (c) 2010 - 2013, 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
#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
// 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
\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
#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
#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
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 Reserved1 : 25;\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
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
/**\r
Send packet with response data to HOST.\r
\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
**/\r
RETURN_STATUS\r
SendDataResponsePacket (\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
);\r
\r
/**\r
- Caculate Mailbox checksum and update the checksum field.\r
+ Calculate Mailbox checksum and update the checksum field.\r
\r
@param[in] Mailbox Debug Agent Mailbox pointer.\r
\r
IN OUT DEBUG_PACKET_HEADER *DebugHeader\r
);\r
\r
+/**\r
+ Read data from debug channel and save the data in buffer.\r
+\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
+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
\r