diff options
Diffstat (limited to 'SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h')
-rw-r--r-- | SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h | 212 |
1 files changed, 74 insertions, 138 deletions
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h index 22bdaa637f..61448448d4 100644 --- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h +++ b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h @@ -31,6 +31,7 @@ #include <Library/LocalApicLib.h>
#include <Library/DebugLib.h>
#include <Library/TimerLib.h>
+#include <Library/PrintLib.h>
#include <TransferProtocol.h>
#include <ImageDebugSupport.h>
@@ -39,9 +40,6 @@ #include "DebugTimer.h"
#include "ArchDebugSupport.h"
-#define DEBUG_AGENT_REVISION ((0 << 16) | 01)
-#define DEBUG_AGENT_CAPABILITIES 0
-
#define DEBUG_INT1_VECTOR 1
#define DEBUG_INT3_VECTOR 3
#define DEBUG_TIMER_VECTOR 32
@@ -55,19 +53,46 @@ extern UINTN Exception0Handle; extern UINTN TimerInterruptHandle;
extern UINT16 ExceptionStubHeaderSize;
-typedef union {
- struct {
- UINT32 HostPresent : 1;
- UINT32 BreakOnNextSmi : 1;
- UINT32 Reserved : 30;
- } Bits;
- UINT32 Uint32;
-} DEBUG_AGENT_FLAG;
+//
+// CPU exception information issued by debug agent
+//
+typedef struct {
+ //
+ // This field is used to save CPU content before executing HOST command
+ //
+ BASE_LIBRARY_JUMP_BUFFER JumpBuffer;
+ //
+ // This filed returens the exception information issued by HOST command
+ //
+ DEBUG_DATA_RESPONSE_GET_EXCEPTION ExceptionContent;
+} DEBUG_AGENT_EXCEPTION_BUFFER;
#pragma pack(1)
typedef struct {
+ //
+ // Lower 32 bits to store the status of DebugAgent
+ //
+ UINT32 HostAttached : 1; // 1: HOST is attached
+ UINT32 AgentInProgress : 1; // 1: Debug Agent is communicating with HOST
+ UINT32 MemoryReady : 1; // 1: Memory is ready
+ UINT32 SteppingFlag : 1; // 1: Agent is running stepping command
+ UINT32 Reserved1 : 28;
+
+ //
+ // Higher 32bits to control the behavior of DebugAgent
+ //
+ UINT32 BreakOnNextSmi : 1; // 1: Break on next SMI
+ UINT32 PrintErrorLevel : 8; // Bitmask of print error level for debug message
+ UINT32 Reserved2 : 23;
+} DEBUG_AGENT_FLAG;
+
+typedef struct {
DEBUG_AGENT_FLAG DebugFlag;
UINT64 DebugPortHandle;
+ //
+ // Pointer to DEBUG_AGENT_EXCEPTION_BUFFER
+ //
+ UINT64 ExceptionBufferPointer;
} DEBUG_AGENT_MAILBOX;
#pragma pack()
@@ -116,30 +141,10 @@ InitializeDebugIdt ( );
/**
- Write specified register into save CPU context.
-
- @param[in] CpuContext Pointer to saved CPU context.
- @param[in] Index Register index value.
- @param[in] Offset Offset in register address range
- @param[in] Width Data width to read.
- @param[in] RegisterBuffer Pointer to input buffer with data.
-
-**/
-VOID
-ArchWriteRegisterBuffer (
- IN DEBUG_CPU_CONTEXT *CpuContext,
- IN UINT8 Index,
- IN UINT8 Offset,
- IN UINT8 Width,
- IN UINT8 *RegisterBuffer
- );
-
-/**
Read register value from saved CPU context.
@param[in] CpuContext Pointer to saved CPU context.
@param[in] Index Register index value.
- @param[in] Offset Offset in register address range
@param[in] Width Data width to read.
@return The address of register value.
@@ -149,14 +154,12 @@ UINT8 * ArchReadRegisterBuffer (
IN DEBUG_CPU_CONTEXT *CpuContext,
IN UINT8 Index,
- IN UINT8 Offset,
IN UINT8 *Width
);
/**
Send packet with response data to HOST.
- @param[in] CpuContext Pointer to saved CPU context.
@param[in] Data Pointer to response data buffer.
@param[in] DataSize Size of response data in byte.
@@ -166,145 +169,78 @@ ArchReadRegisterBuffer ( **/
RETURN_STATUS
SendDataResponsePacket (
- IN DEBUG_CPU_CONTEXT *CpuContext,
IN UINT8 *Data,
IN UINT16 DataSize
);
/**
- Read segment selector by register index.
-
- @param[in] CpuContext Pointer to saved CPU context.
- @param[in] RegisterIndex Register Index.
+ Check if HOST is attached based on Mailbox.
- @return Value of segment selector.
+ @retval TRUE HOST is attached.
+ @retval FALSE HOST is not attached.
**/
-UINT64
-ReadRegisterSelectorByIndex (
- IN DEBUG_CPU_CONTEXT *CpuContext,
- IN UINT8 RegisterIndex
- );
-
-/**
- Read group register of common registers.
-
- @param[in] CpuContext Pointer to saved CPU context.
- @param[in] RegisterGroup Pointer to Group registers.
-
-**/
-VOID
-ReadRegisterGroup (
- IN DEBUG_CPU_CONTEXT *CpuContext,
- IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP *RegisterGroup
- );
-
-/**
- Read group register of Segment Base.
-
- @param[in] CpuContext Pointer to saved CPU context.
- @param[in] RegisterGroupSegBase Pointer to Group registers.
-
-**/
-VOID
-ReadRegisterGroupSegBase (
- IN DEBUG_CPU_CONTEXT *CpuContext,
- IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP_SEGBASE *RegisterGroupSegBase
- );
-
-/**
- Read gourp register of Segment Limit.
-
- @param[in] CpuContext Pointer to saved CPU context.
- @param[in] RegisterGroupSegLim Pointer to Group registers.
-
-**/
-VOID
-ReadRegisterGroupSegLim (
- IN DEBUG_CPU_CONTEXT *CpuContext,
- IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP_SEGLIM *RegisterGroupSegLim
+BOOLEAN
+IsHostAttached (
+ VOID
);
/**
- Read group register by group index.
-
- @param[in] CpuContext Pointer to saved CPU context.
- @param[in] GroupIndex Group Index.
+ Get Debug Agent Mailbox pointer.
- @retval RETURN_SUCCESS Read successfully.
- @retval RETURN_NOT_SUPPORTED Group index cannot be supported.
+ @return Mailbox pointer.
**/
-RETURN_STATUS
-ArchReadRegisterGroup (
- IN DEBUG_CPU_CONTEXT *CpuContext,
- IN UINT8 GroupIndex
+DEBUG_AGENT_MAILBOX *
+GetMailboxPointer (
+ VOID
);
/**
- Send acknowledge packet to HOST.
+ Get debug port handle.
- @param AckCommand Type of Acknowledge packet.
+ @return Debug port handle.
**/
-VOID
-SendAckPacket (
- IN UINT8 AckCommand
+DEBUG_PORT_HANDLE
+GetDebugPortHandle (
+ VOID
);
/**
- Receive acknowledge packet OK from HOST in specified time.
-
- @param[in] Timeout Time out value to wait for acknowlege from HOST.
- The unit is microsecond.
- @param[out] BreakReceived If BreakReceived is not NULL,
- TRUE is retured if break-in symbol received.
- FALSE is retured if break-in symbol not received.
-
- @retval RETRUEN_SUCCESS Succeed to receive acknowlege packet from HOST,
- the type of acknowlege packet saved in Ack.
- @retval RETURN_TIMEOUT Specified timeout value was up.
-
-**/
-RETURN_STATUS
-WaitForAckPacketOK (
- IN UINTN Timeout,
- OUT BOOLEAN *BreakReceived OPTIONAL
- );
+ Read the Attach/Break-in symbols from the debug port.
-/**
- Check if HOST is connected based on Mailbox.
+ @param[in] Handle Pointer to Debug Port handle.
+ @param[out] BreakSymbol Returned break symbol.
- @retval TRUE HOST is connected.
- @retval FALSE HOST is not connected.
+ @retval EFI_SUCCESS Read the symbol in BreakSymbol.
+ @retval EFI_NOT_FOUND No read the break symbol.
**/
-BOOLEAN
-IsHostConnected (
- VOID
+EFI_STATUS
+DebugReadBreakSymbol (
+ IN DEBUG_PORT_HANDLE Handle,
+ OUT UINT8 *BreakSymbol
);
/**
- Get Debug Agent Mailbox pointer.
+ Prints a debug message to the debug port if the specified error level is enabled.
- @return Mailbox pointer.
+ If any bit in ErrorLevel is also set in Mainbox, then print the message specified
+ by Format and the associated variable argument list to the debug port.
-**/
-DEBUG_AGENT_MAILBOX *
-GetMailboxPointer (
- VOID
- );
-
-/**
- Get debug port handle.
-
- @return Debug port handle.
+ @param[in] ErrorLevel The error level of the debug message.
+ @param[in] Format Format string for the debug message to print.
+ @param[in] ... Variable argument list whose contents are accessed
+ based on the format string specified by Format.
**/
-DEBUG_PORT_HANDLE
-GetDebugPortHandle (
- VOID
+VOID
+EFIAPI
+DebugAgentMsgPrint (
+ IN UINT8 ErrorLevel,
+ IN CHAR8 *Format,
+ ...
);
-
#endif
|