2 Command header of for Debug Agent library instance.
4 Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _DEBUG_AGENT_H_
16 #define _DEBUG_AGENT_H_
18 #include <Register/LocalApic.h>
20 #include <Guid/DebugAgentGuid.h>
22 #include <Library/BaseLib.h>
23 #include <Library/BaseMemoryLib.h>
24 #include <Library/ResetSystemLib.h>
25 #include <Library/IoLib.h>
26 #include <Library/HobLib.h>
27 #include <Library/DebugCommunicationLib.h>
28 #include <Library/DebugAgentLib.h>
29 #include <Library/PcdLib.h>
30 #include <Library/SynchronizationLib.h>
31 #include <Library/LocalApicLib.h>
32 #include <Library/DebugLib.h>
33 #include <Library/TimerLib.h>
34 #include <Library/PrintLib.h>
36 #include <TransferProtocol.h>
37 #include <ImageDebugSupport.h>
40 #include "DebugTimer.h"
41 #include "ArchDebugSupport.h"
43 #define DEBUG_INT1_VECTOR 1
44 #define DEBUG_INT3_VECTOR 3
45 #define DEBUG_TIMER_VECTOR 32
46 #define DEBUG_MAILBOX_VECTOR 33
48 #define SOFT_INTERRUPT_SIGNATURE SIGNATURE_32('S','O','F','T')
49 #define SYSTEM_RESET_SIGNATURE SIGNATURE_32('S','Y','S','R')
50 #define MEMORY_READY_SIGNATURE SIGNATURE_32('M','E','M','R')
52 extern UINTN Exception0Handle
;
53 extern UINTN TimerInterruptHandle
;
54 extern UINT16 ExceptionStubHeaderSize
;
57 // CPU exception information issued by debug agent
61 // This field is used to save CPU content before executing HOST command
63 BASE_LIBRARY_JUMP_BUFFER JumpBuffer
;
65 // This filed returens the exception information issued by HOST command
67 DEBUG_DATA_RESPONSE_GET_EXCEPTION ExceptionContent
;
68 } DEBUG_AGENT_EXCEPTION_BUFFER
;
73 // Lower 32 bits to store the status of DebugAgent
75 UINT32 HostAttached
: 1; // 1: HOST is attached
76 UINT32 AgentInProgress
: 1; // 1: Debug Agent is communicating with HOST
77 UINT32 MemoryReady
: 1; // 1: Memory is ready
78 UINT32 SteppingFlag
: 1; // 1: Agent is running stepping command
79 UINT32 Reserved1
: 28;
82 // Higher 32bits to control the behavior of DebugAgent
84 UINT32 BreakOnNextSmi
: 1; // 1: Break on next SMI
85 UINT32 PrintErrorLevel
: 8; // Bitmask of print error level for debug message
86 UINT32 Reserved2
: 23;
90 DEBUG_AGENT_FLAG DebugFlag
;
91 UINT64 DebugPortHandle
;
93 // Pointer to DEBUG_AGENT_EXCEPTION_BUFFER
95 UINT64 ExceptionBufferPointer
;
96 } DEBUG_AGENT_MAILBOX
;
101 UINT32 LimitLow
: 16;
108 UINT32 LimitHigh
: 4;
111 UINT32 DefaultSize
: 1;
112 UINT32 Granularity
: 1;
119 Caller provided function to be invoked at the end of DebugPortInitialize().
121 Refer to the descrption for DebugPortInitialize() for more details.
123 @param[in] Context The first input argument of DebugPortInitialize().
124 @param[in] DebugPortHandle Debug port handle created by Debug Communication Libary.
129 InitializeDebugAgentPhase2 (
131 IN DEBUG_PORT_HANDLE DebugPortHandle
135 Initialize IDT entries to support source level debug.
144 Read register value from saved CPU context.
146 @param[in] CpuContext Pointer to saved CPU context.
147 @param[in] Index Register index value.
148 @param[in] Width Data width to read.
150 @return The address of register value.
154 ArchReadRegisterBuffer (
155 IN DEBUG_CPU_CONTEXT
*CpuContext
,
161 Send packet with response data to HOST.
163 @param[in] Data Pointer to response data buffer.
164 @param[in] DataSize Size of response data in byte.
166 @retval RETURN_SUCCESS Response data was sent successfully.
167 @retval RETURN_DEVICE_ERROR Cannot receive DEBUG_COMMAND_OK from HOST.
171 SendDataResponsePacket (
177 Check if HOST is attached based on Mailbox.
179 @retval TRUE HOST is attached.
180 @retval FALSE HOST is not attached.
189 Get Debug Agent Mailbox pointer.
191 @return Mailbox pointer.
194 DEBUG_AGENT_MAILBOX
*
200 Get debug port handle.
202 @return Debug port handle.
211 Read the Attach/Break-in symbols from the debug port.
213 @param[in] Handle Pointer to Debug Port handle.
214 @param[out] BreakSymbol Returned break symbol.
216 @retval EFI_SUCCESS Read the symbol in BreakSymbol.
217 @retval EFI_NOT_FOUND No read the break symbol.
221 DebugReadBreakSymbol (
222 IN DEBUG_PORT_HANDLE Handle
,
223 OUT UINT8
*BreakSymbol
227 Prints a debug message to the debug port if the specified error level is enabled.
229 If any bit in ErrorLevel is also set in Mainbox, then print the message specified
230 by Format and the associated variable argument list to the debug port.
232 @param[in] ErrorLevel The error level of the debug message.
233 @param[in] Format Format string for the debug message to print.
234 @param[in] ... Variable argument list whose contents are accessed
235 based on the format string specified by Format.