TianoCore EDK2 master
|
Go to the source code of this file.
Functions | |
UINT16 | CalculateCrc16 (IN UINT8 *Data, IN UINTN DataSize, IN UINT16 Crc) |
BOOLEAN | IsDebugAgentInitialzed (VOID) |
VOID | FindAndReportModuleImageInfo (IN UINTN AlignSize) |
VOID | TriggerSoftInterrupt (IN UINT32 Signature) |
VOID | UpdateMailboxChecksum (IN DEBUG_AGENT_MAILBOX *Mailbox) |
VOID | VerifyMailboxChecksum (IN DEBUG_AGENT_MAILBOX *Mailbox) |
VOID | UpdateMailboxContent (IN DEBUG_AGENT_MAILBOX *Mailbox, IN UINTN Index, IN UINT64 Value) |
UINTN | DebugAgentReadBuffer (IN DEBUG_PORT_HANDLE Handle, IN UINT8 *Buffer, IN UINTN NumberOfBytes, IN UINTN Timeout) |
VOID | SetDebugFlag (IN UINT64 FlagMask, IN UINT32 FlagValue) |
UINT32 | GetDebugFlag (IN UINT64 FlagMask) |
VOID | SendDebugMsgPacket (IN CHAR8 *Buffer, IN UINTN Length) |
VOID EFIAPI | DebugAgentMsgPrint (IN UINT8 ErrorLevel, IN CHAR8 *Format,...) |
VOID EFIAPI | DebugAgentDataMsgPrint (IN UINT8 ErrorLevel, IN BOOLEAN IsSend, IN UINT8 *Data, IN UINT8 Length) |
EFI_STATUS | ReadRemainingBreakPacket (IN DEBUG_PORT_HANDLE Handle, IN OUT DEBUG_PACKET_HEADER *DebugHeader) |
BOOLEAN | IsHostAttached (VOID) |
VOID | SetHostAttached (IN BOOLEAN Attached) |
RETURN_STATUS | SetDebugSetting (IN DEBUG_DATA_SET_DEBUG_SETTING *DebugSetting) |
VOID | CommandGo (IN DEBUG_CPU_CONTEXT *CpuContext) |
VOID | CommandStepping (IN DEBUG_CPU_CONTEXT *CpuContext) |
VOID | CommandSteppingCleanup (IN DEBUG_CPU_CONTEXT *CpuContext) |
VOID | SetDebugRegister (IN DEBUG_CPU_CONTEXT *CpuContext, IN DEBUG_DATA_SET_HW_BREAKPOINT *SetHwBreakpoint) |
VOID | ClearDebugRegister (IN DEBUG_CPU_CONTEXT *CpuContext, IN DEBUG_DATA_CLEAR_HW_BREAKPOINT *ClearHwBreakpoint) |
UINT16 | ArchReadFxStatOffset (IN UINT8 Index, OUT UINT8 *Width) |
UINT8 * | ArchReadRegisterBuffer (IN DEBUG_CPU_CONTEXT *CpuContext, IN UINT8 Index, OUT UINT8 *Width) |
VOID | SendPacketWithoutData (IN UINT8 CommandType, IN UINT8 SequenceNo) |
VOID | SendAckPacket (IN UINT8 AckCommand) |
UINT8 | DecompressDataInPlace (IN OUT UINT8 *Data, IN UINTN Length) |
RETURN_STATUS | ReceivePacket (OUT UINT8 *InputPacket, OUT BOOLEAN *BreakReceived, OUT BOOLEAN *IncompatibilityFlag OPTIONAL, IN UINTN Timeout, IN BOOLEAN SkipStartSymbol) |
RETURN_STATUS | SendCommandAndWaitForAckOK (IN UINT8 Command, IN UINTN Timeout, OUT BOOLEAN *BreakReceived OPTIONAL, OUT BOOLEAN *IncompatibilityFlag OPTIONAL) |
UINT8 | GetBreakCause (IN UINTN Vector, IN DEBUG_CPU_CONTEXT *CpuContext) |
VOID | CopyMemByWidth (OUT UINT8 *Dest, IN UINT8 *Src, IN UINT16 Count, IN UINT8 Width) |
VOID | CompressData (IN DEBUG_PORT_HANDLE Handle, IN UINT8 *Data, IN UINT8 Length, IN BOOLEAN Send, OUT UINTN *CompressedLength OPTIONAL, OUT UINT16 *CompressedCrc OPTIONAL) |
RETURN_STATUS | ReadMemoryAndSendResponsePacket (IN UINT8 *Data, IN UINT16 Count, IN UINT8 Width, IN DEBUG_PACKET_HEADER *DebugHeader) |
RETURN_STATUS | SendDataResponsePacket (IN UINT8 *Data, IN UINT16 DataSize, IN OUT DEBUG_PACKET_HEADER *DebugHeader) |
RETURN_STATUS | AttachHost (IN UINT8 BreakCause, IN UINTN Timeout, OUT BOOLEAN *BreakReceived) |
VOID | SendBreakPacketToHost (IN UINT8 BreakCause, IN UINT32 ProcessorIndex, OUT BOOLEAN *BreakReceived) |
VOID | CommandCommunication (IN UINTN Vector, IN OUT DEBUG_CPU_CONTEXT *CpuContext, IN BOOLEAN BreakReceived) |
VOID EFIAPI | InterruptProcess (IN UINT32 Vector, IN DEBUG_CPU_CONTEXT *CpuContext) |
Variables | |
GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 | mErrorMsgVersionAlert [] = "\rThe SourceLevelDebugPkg you are using requires a newer version of the Intel(R) UDK Debugger Tool.\r\n" |
GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 | mErrorMsgSendInitPacket [] = "\rSend INIT break packet and try to connect the HOST (Intel(R) UDK Debugger Tool v1.5) ...\r\n" |
GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 | mErrorMsgConnectOK [] = "HOST connection is successful!\r\n" |
GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 | mErrorMsgConnectFail [] = "HOST connection is failed!\r\n" |
GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 | mWarningMsgIngoreBreakpoint [] = "Ignore break point in SMM for SMI issued during DXE debugging!\r\n" |
GLOBAL_REMOVE_IF_UNREFERENCED EFI_VECTOR_HANDOFF_INFO | mVectorHandoffInfoDebugAgent [] |
GLOBAL_REMOVE_IF_UNREFERENCED UINTN | mVectorHandoffInfoCount = sizeof (mVectorHandoffInfoDebugAgent) / sizeof (EFI_VECTOR_HANDOFF_INFO) |
Common Debug Agent library implementation. It mainly includes the first C function called by exception/interrupt handlers, read/write debug packet to communication with HOST based on transfer protocol.
Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file DebugAgent.c.
Return the offset of FP / MMX / XMM registers in the FPU saved state by register index.
[in] | Index | Register index. |
[out] | Width | Register width returned. |
Definition at line 887 of file DebugAgent.c.
UINT8 * ArchReadRegisterBuffer | ( | IN DEBUG_CPU_CONTEXT * | CpuContext, |
IN UINT8 | Index, | ||
OUT UINT8 * | Width | ||
) |
Return the pointer of the register value in the CPU saved context.
[in] | CpuContext | Pointer to saved CPU context. |
[in] | Index | Register index value. |
[out] | Width | Data width to read. |
Definition at line 962 of file DebugAgent.c.
Try to attach the HOST.
Send init break packet to HOST: If no acknowledge received in specified Timeout, return RETURN_TIMEOUT. If received acknowledge, check the revision of HOST. Set Attach Flag if attach successfully.
[in] | BreakCause | Break cause of this break event. |
[in] | Timeout | Time out value to wait for acknowledge from HOST. The unit is microsecond. |
[out] | BreakReceived | If BreakReceived is not NULL, TRUE is returned if break-in symbol received. FALSE is returned if break-in symbol not received. |
Definition at line 1713 of file DebugAgent.c.
Calculate CRC16 for target data.
[in] | Data | The target data. |
[in] | DataSize | The target data size. |
[in] | Crc | Initial CRC. |
Definition at line 140 of file DebugAgent.c.
VOID ClearDebugRegister | ( | IN DEBUG_CPU_CONTEXT * | CpuContext, |
IN DEBUG_DATA_CLEAR_HW_BREAKPOINT * | ClearHwBreakpoint | ||
) |
Clear debug register for hardware breakpoint.
[in] | CpuContext | Pointer to saved CPU context. |
[in] | ClearHwBreakpoint | Hardware breakpoint to be cleared. |
Definition at line 851 of file DebugAgent.c.
VOID CommandCommunication | ( | IN UINTN | Vector, |
IN OUT DEBUG_CPU_CONTEXT * | CpuContext, | ||
IN BOOLEAN | BreakReceived | ||
) |
The main function to process communication with HOST.
It received the command packet from HOST, and sent response data packet to HOST.
[in] | Vector | Vector value of exception or interrupt. |
[in,out] | CpuContext | Pointer to saved CPU context. |
[in] | BreakReceived | TRUE means break-in symbol received. FALSE means break-in symbol not received. |
Definition at line 1819 of file DebugAgent.c.
VOID CommandGo | ( | IN DEBUG_CPU_CONTEXT * | CpuContext | ) |
Execute GO command.
[in] | CpuContext | Pointer to saved CPU context. |
Definition at line 739 of file DebugAgent.c.
VOID CommandStepping | ( | IN DEBUG_CPU_CONTEXT * | CpuContext | ) |
Execute Stepping command.
[in] | CpuContext | Pointer to saved CPU context. |
Definition at line 757 of file DebugAgent.c.
VOID CommandSteppingCleanup | ( | IN DEBUG_CPU_CONTEXT * | CpuContext | ) |
Do some cleanup after Stepping command done.
[in] | CpuContext | Pointer to saved CPU context. |
Definition at line 784 of file DebugAgent.c.
VOID CompressData | ( | IN DEBUG_PORT_HANDLE | Handle, |
IN UINT8 * | Data, | ||
IN UINT8 | Length, | ||
IN BOOLEAN | Send, | ||
OUT UINTN *CompressedLength | OPTIONAL, | ||
OUT UINT16 *CompressedCrc | OPTIONAL | ||
) |
Compress the data buffer but do not modify the original buffer.
The compressed data is directly send to the debug channel. Compressing in place doesn't work because the data may become larger during compressing phase. ("3 3 ..." --> "3 3 0 ...") The routine is expected to be called three times:
[in] | Handle | The debug channel handle to send the compressed data buffer. |
[in] | Data | The data buffer. |
[in] | Length | The length of the data buffer. |
[in] | Send | TRUE to send the compressed data buffer. |
[out] | CompressedLength | Return the length of the compressed data buffer. It may be larger than the Length in some cases. |
[out] | CompressedCrc | Return the CRC of the compressed data buffer. |
Definition at line 1460 of file DebugAgent.c.
Copy memory from source to destination with specified width.
[out] | Dest | A pointer to the destination buffer of the memory copy. |
[in] | Src | A pointer to the source buffer of the memory copy. |
[in] | Count | The number of data with specified width to copy from source to destination. |
[in] | Width | Data width in byte. |
Definition at line 1393 of file DebugAgent.c.
VOID EFIAPI DebugAgentDataMsgPrint | ( | IN UINT8 | ErrorLevel, |
IN BOOLEAN | IsSend, | ||
IN UINT8 * | Data, | ||
IN UINT8 | Length | ||
) |
Prints a debug message to the debug output device if the specified error level is enabled.
If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function GetDebugPrintErrorLevel (), then print the message specified by Format and the associated variable argument list to the debug output device.
If Format is NULL, then ASSERT().
[in] | ErrorLevel | The error level of the debug message. |
[in] | IsSend | Flag of debug message to declare that the data is being sent or being received. |
[in] | Data | Variable argument list whose contents are accessed |
[in] | Length | based on the format string specified by Format. |
Definition at line 561 of file DebugAgent.c.
Prints a debug message to the debug port if the specified error level is enabled.
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.
[in] | ErrorLevel | The error level of the debug message. |
[in] | Format | Format string for the debug message to print. |
[in] | ... | Variable argument list whose contents are accessed based on the format string specified by Format. |
Definition at line 518 of file DebugAgent.c.
UINTN DebugAgentReadBuffer | ( | IN DEBUG_PORT_HANDLE | Handle, |
IN UINT8 * | Buffer, | ||
IN UINTN | NumberOfBytes, | ||
IN UINTN | Timeout | ||
) |
Read data from debug device and save the data in buffer.
Reads NumberOfBytes data bytes from a debug device into the buffer specified by Buffer. The number of bytes actually read is returned. If the return value is less than NumberOfBytes, then the rest operation failed. If NumberOfBytes is zero, then return 0.
Handle | Debug port handle. |
Buffer | Pointer to the data buffer to store the data read from the debug device. |
NumberOfBytes | Number of bytes which will be read. |
Timeout | Timeout value for reading from debug device. It unit is Microsecond. |
0 | Read data failed, no data is to be read. |
>0 | Actual number of bytes read from debug device. |
Definition at line 367 of file DebugAgent.c.
Decompress the Data in place.
[in,out] | Data | The compressed data buffer. The buffer is assumed large enough to hold the uncompressed data. |
[in] | Length | The length of the compressed data buffer. |
Definition at line 1050 of file DebugAgent.c.
Find and report module image info to HOST.
[in] | AlignSize | Image aligned size. |
Definition at line 193 of file DebugAgent.c.
UINT8 GetBreakCause | ( | IN UINTN | Vector, |
IN DEBUG_CPU_CONTEXT * | CpuContext | ||
) |
Get current break cause.
[in] | Vector | Vector value of exception or interrupt. |
[in] | CpuContext | Pointer to save CPU context. |
Definition at line 1294 of file DebugAgent.c.
UINT32 GetDebugFlag | ( | IN UINT64 | FlagMask | ) |
Get debug flag in mailbox.
[in] | FlagMask | Debug flag mask value. |
Definition at line 458 of file DebugAgent.c.
VOID EFIAPI InterruptProcess | ( | IN UINT32 | Vector, |
IN DEBUG_CPU_CONTEXT * | CpuContext | ||
) |
C function called in interrupt handler.
[in] | Vector | Vector value of exception or interrupt. |
[in] | CpuContext | Pointer to save CPU context. |
Definition at line 2357 of file DebugAgent.c.
BOOLEAN IsDebugAgentInitialzed | ( | VOID | ) |
Read IDT entry to check if IDT entries are setup by Debug Agent.
TRUE | IDT entries were setup by Debug Agent. |
FALSE | IDT entries were not setup by Debug Agent. |
Definition at line 172 of file DebugAgent.c.
BOOLEAN IsHostAttached | ( | VOID | ) |
Check if HOST is attached based on Mailbox.
TRUE | HOST is attached. |
FALSE | HOST is not attached. |
Definition at line 676 of file DebugAgent.c.
RETURN_STATUS ReadMemoryAndSendResponsePacket | ( | IN UINT8 * | Data, |
IN UINT16 | Count, | ||
IN UINT8 | Width, | ||
IN DEBUG_PACKET_HEADER * | DebugHeader | ||
) |
Read memory with specified width and send packet with response data to HOST.
[in] | Data | Pointer to response data buffer. |
[in] | Count | The number of data with specified Width. |
[in] | Width | Data width in byte. |
[in] | DebugHeader | Pointer to a buffer for creating response packet and receiving ACK packet, to minimize the stack usage. |
RETURN_SUCCESS | Response data was sent successfully. |
Definition at line 1537 of file DebugAgent.c.
EFI_STATUS ReadRemainingBreakPacket | ( | IN DEBUG_PORT_HANDLE | Handle, |
IN OUT DEBUG_PACKET_HEADER * | DebugHeader | ||
) |
Read remaining debug packet except for the start symbol
[in] | Handle | Pointer to Debug Port handle. |
[in,out] | DebugHeader | Debug header buffer including start symbol. |
EFI_SUCCESS | Read the symbol in BreakSymbol. |
EFI_CRC_ERROR | CRC check fail. |
EFI_TIMEOUT | Timeout occurs when reading debug packet. |
EFI_DEVICE_ERROR | Receive the old or response packet. |
Definition at line 623 of file DebugAgent.c.
RETURN_STATUS ReceivePacket | ( | OUT UINT8 * | InputPacket, |
OUT BOOLEAN * | BreakReceived, | ||
OUT BOOLEAN *IncompatibilityFlag | OPTIONAL, | ||
IN UINTN | Timeout, | ||
IN BOOLEAN | SkipStartSymbol | ||
) |
Receive valid packet from HOST.
[out] | InputPacket | Buffer to receive packet. |
[out] | BreakReceived | TRUE means break-in symbol received. FALSE means break-in symbol not received. |
[out] | IncompatibilityFlag | If IncompatibilityFlag is not NULL, return TRUE: Compatible packet received. FALSE: Incompatible packet received. |
[in] | Timeout | Time out value to wait for acknowledge from HOST. The unit is microsecond. |
[in] | SkipStartSymbol | TRUE: Skip time out when reading start symbol. FALSE: Does not Skip time out when reading start symbol. |
RETURN_SUCCESS | A valid package was received in InputPacket. |
RETURN_TIMEOUT | Timeout occurs. |
Definition at line 1105 of file DebugAgent.c.
VOID SendAckPacket | ( | IN UINT8 | AckCommand | ) |
Send acknowledge packet to HOST.
[in] | AckCommand | Type of Acknowledge packet. |
Definition at line 1019 of file DebugAgent.c.
VOID SendBreakPacketToHost | ( | IN UINT8 | BreakCause, |
IN UINT32 | ProcessorIndex, | ||
OUT BOOLEAN * | BreakReceived | ||
) |
Send Break point packet to HOST.
Only the first breaking processor could sent BREAK_POINT packet.
[in] | BreakCause | Break cause of this break event. |
[in] | ProcessorIndex | Processor index value. |
[out] | BreakReceived | If BreakReceived is not NULL, TRUE is returned if break-in symbol received. FALSE is returned if break-in symbol not received. |
Definition at line 1771 of file DebugAgent.c.
RETURN_STATUS SendCommandAndWaitForAckOK | ( | IN UINT8 | Command, |
IN UINTN | Timeout, | ||
OUT BOOLEAN *BreakReceived | OPTIONAL, | ||
OUT BOOLEAN *IncompatibilityFlag | OPTIONAL | ||
) |
Receive acknowledge packet OK from HOST in specified time.
[in] | Command | The command type issued by TARGET. |
[in] | Timeout | Time out value to wait for acknowledge from HOST. The unit is microsecond. |
[out] | BreakReceived | If BreakReceived is not NULL, TRUE is returned if break-in symbol received. FALSE is returned if break-in symbol not received. |
[out] | IncompatibilityFlag | If IncompatibilityFlag is not NULL, return TRUE: Compatible packet received. FALSE: Incompatible packet received. |
RETURN_SUCCESS | Succeed to receive acknowledge packet from HOST, the type of acknowledge packet saved in Ack. |
RETURN_TIMEOUT | Specified timeout value was up. |
Definition at line 1224 of file DebugAgent.c.
RETURN_STATUS SendDataResponsePacket | ( | IN UINT8 * | Data, |
IN UINT16 | DataSize, | ||
IN OUT DEBUG_PACKET_HEADER * | DebugHeader | ||
) |
Send packet with response data to HOST.
[in] | Data | Pointer to response data buffer. |
[in] | DataSize | Size of response data in byte. |
[in,out] | DebugHeader | Pointer to a buffer for creating response packet and receiving ACK packet, to minimize the stack usage. |
RETURN_SUCCESS | Response data was sent successfully. |
Definition at line 1688 of file DebugAgent.c.
Send a debug message packet to the debug port.
[in] | Buffer | The debug message. |
[in] | Length | The length of debug message. |
Definition at line 479 of file DebugAgent.c.
Send the packet without data to HOST.
[in] | CommandType | Type of Command. |
[in] | SequenceNo | Sequence number. |
Definition at line 991 of file DebugAgent.c.
Set debug flag in mailbox.
[in] | FlagMask | Debug flag mask value. |
[in] | FlagValue | Debug flag value. |
Definition at line 435 of file DebugAgent.c.
VOID SetDebugRegister | ( | IN DEBUG_CPU_CONTEXT * | CpuContext, |
IN DEBUG_DATA_SET_HW_BREAKPOINT * | SetHwBreakpoint | ||
) |
Set debug register for hardware breakpoint.
[in] | CpuContext | Pointer to saved CPU context. |
[in] | SetHwBreakpoint | Hardware breakpoint to be set. |
Definition at line 809 of file DebugAgent.c.
RETURN_STATUS SetDebugSetting | ( | IN DEBUG_DATA_SET_DEBUG_SETTING * | DebugSetting | ) |
Set debug setting of Debug Agent in Mailbox.
DebugSetting | Pointer to Debug Setting defined by transfer protocol. |
RETURN_SUCCESS | The setting is set successfully. |
RETURN_UNSUPPORTED | The Key value is not supported. |
Definition at line 708 of file DebugAgent.c.
VOID SetHostAttached | ( | IN BOOLEAN | Attached | ) |
Set HOST connect flag in Mailbox.
[in] | Attached | Attach status. |
Definition at line 690 of file DebugAgent.c.
VOID TriggerSoftInterrupt | ( | IN UINT32 | Signature | ) |
Trigger one software interrupt to debug agent to handle it.
[in] | Signature | Software interrupt signature. |
Definition at line 218 of file DebugAgent.c.
VOID UpdateMailboxChecksum | ( | IN DEBUG_AGENT_MAILBOX * | Mailbox | ) |
Calculate Mailbox checksum and update the checksum field.
[in] | Mailbox | Debug Agent Mailbox pointer. |
Definition at line 257 of file DebugAgent.c.
VOID UpdateMailboxContent | ( | IN DEBUG_AGENT_MAILBOX * | Mailbox, |
IN UINTN | Index, | ||
IN UINT64 | Value | ||
) |
Update Mailbox content by index.
[in] | Mailbox | Debug Agent Mailbox pointer. |
[in] | Index | Mailbox content index. |
[in] | Value | Value to be set into Mailbox. |
Definition at line 300 of file DebugAgent.c.
VOID VerifyMailboxChecksum | ( | IN DEBUG_AGENT_MAILBOX * | Mailbox | ) |
Verify Mailbox checksum.
If checksum error, print debug message and run init dead loop.
[in] | Mailbox | Debug Agent Mailbox pointer. |
Definition at line 273 of file DebugAgent.c.
GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 mErrorMsgConnectFail[] = "HOST connection is failed!\r\n" |
Definition at line 18 of file DebugAgent.c.
GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 mErrorMsgConnectOK[] = "HOST connection is successful!\r\n" |
Definition at line 17 of file DebugAgent.c.
GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 mErrorMsgSendInitPacket[] = "\rSend INIT break packet and try to connect the HOST (Intel(R) UDK Debugger Tool v1.5) ...\r\n" |
Definition at line 16 of file DebugAgent.c.
GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 mErrorMsgVersionAlert[] = "\rThe SourceLevelDebugPkg you are using requires a newer version of the Intel(R) UDK Debugger Tool.\r\n" |
Definition at line 15 of file DebugAgent.c.
GLOBAL_REMOVE_IF_UNREFERENCED UINTN mVectorHandoffInfoCount = sizeof (mVectorHandoffInfoDebugAgent) / sizeof (EFI_VECTOR_HANDOFF_INFO) |
Definition at line 127 of file DebugAgent.c.
GLOBAL_REMOVE_IF_UNREFERENCED EFI_VECTOR_HANDOFF_INFO mVectorHandoffInfoDebugAgent[] |
Definition at line 24 of file DebugAgent.c.
GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 mWarningMsgIngoreBreakpoint[] = "Ignore break point in SMM for SMI issued during DXE debugging!\r\n" |
Definition at line 19 of file DebugAgent.c.