2 Command header of for Debug Agent library instance.
4 Copyright (c) 2010, 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>
33 #include <TransferProtocol.h>
34 #include <ImageDebugSupport.h>
37 #include "DebugTimer.h"
38 #include "ArchDebugSupport.h"
40 #define DEBUG_AGENT_REVISION ((0 << 16) | 01)
41 #define DEBUG_AGENT_CAPABILITIES 0
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
;
58 UINT32 HostPresent
: 1;
59 UINT32 BreakOnNextSmi
: 1;
67 DEBUG_AGENT_FLAG DebugFlag
;
68 UINT64 DebugPortHandle
;
69 } DEBUG_AGENT_MAILBOX
;
84 UINT32 DefaultSize
: 1;
85 UINT32 Granularity
: 1;
92 Caller provided function to be invoked at the end of DebugPortInitialize().
94 Refer to the descrption for DebugPortInitialize() for more details.
96 @param[in] Context The first input argument of DebugPortInitialize().
97 @param[in] DebugPortHandle Debug port handle created by Debug Communication Libary.
102 InitializeDebugAgentPhase2 (
104 IN DEBUG_PORT_HANDLE DebugPortHandle
108 Initialize IDT entries to support source level debug.
117 Write specified register into save CPU context.
119 @param[in] CpuContext Pointer to saved CPU context.
120 @param[in] Index Register index value.
121 @param[in] Offset Offset in register address range
122 @param[in] Width Data width to read.
123 @param[in] RegisterBuffer Pointer to input buffer with data.
127 ArchWriteRegisterBuffer (
128 IN DEBUG_CPU_CONTEXT
*CpuContext
,
132 IN UINT8
*RegisterBuffer
136 Read register value from saved CPU context.
138 @param[in] CpuContext Pointer to saved CPU context.
139 @param[in] Index Register index value.
140 @param[in] Offset Offset in register address range
141 @param[in] Width Data width to read.
143 @return The address of register value.
147 ArchReadRegisterBuffer (
148 IN DEBUG_CPU_CONTEXT
*CpuContext
,
155 Send packet with response data to HOST.
157 @param[in] CpuContext Pointer to saved CPU context.
158 @param[in] Data Pointer to response data buffer.
159 @param[in] DataSize Size of response data in byte.
161 @retval RETURN_SUCCESS Response data was sent successfully.
162 @retval RETURN_DEVICE_ERROR Cannot receive DEBUG_COMMAND_OK from HOST.
166 SendDataResponsePacket (
167 IN DEBUG_CPU_CONTEXT
*CpuContext
,
173 Read segment selector by register index.
175 @param[in] CpuContext Pointer to saved CPU context.
176 @param[in] RegisterIndex Register Index.
178 @return Value of segment selector.
182 ReadRegisterSelectorByIndex (
183 IN DEBUG_CPU_CONTEXT
*CpuContext
,
184 IN UINT8 RegisterIndex
188 Read group register of common registers.
190 @param[in] CpuContext Pointer to saved CPU context.
191 @param[in] RegisterGroup Pointer to Group registers.
196 IN DEBUG_CPU_CONTEXT
*CpuContext
,
197 IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP
*RegisterGroup
201 Read group register of Segment Base.
203 @param[in] CpuContext Pointer to saved CPU context.
204 @param[in] RegisterGroupSegBase Pointer to Group registers.
208 ReadRegisterGroupSegBase (
209 IN DEBUG_CPU_CONTEXT
*CpuContext
,
210 IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP_SEGBASE
*RegisterGroupSegBase
214 Read gourp register of Segment Limit.
216 @param[in] CpuContext Pointer to saved CPU context.
217 @param[in] RegisterGroupSegLim Pointer to Group registers.
221 ReadRegisterGroupSegLim (
222 IN DEBUG_CPU_CONTEXT
*CpuContext
,
223 IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP_SEGLIM
*RegisterGroupSegLim
227 Read group register by group index.
229 @param[in] CpuContext Pointer to saved CPU context.
230 @param[in] GroupIndex Group Index.
232 @retval RETURN_SUCCESS Read successfully.
233 @retval RETURN_NOT_SUPPORTED Group index cannot be supported.
237 ArchReadRegisterGroup (
238 IN DEBUG_CPU_CONTEXT
*CpuContext
,
243 Send acknowledge packet to HOST.
245 @param AckCommand Type of Acknowledge packet.
254 Receive acknowledge packet OK from HOST in specified time.
256 @param[in] Timeout Time out value to wait for acknowlege from HOST.
257 The unit is microsecond.
258 @param[out] BreakReceived If BreakReceived is not NULL,
259 TRUE is retured if break-in symbol received.
260 FALSE is retured if break-in symbol not received.
262 @retval RETRUEN_SUCCESS Succeed to receive acknowlege packet from HOST,
263 the type of acknowlege packet saved in Ack.
264 @retval RETURN_TIMEOUT Specified timeout value was up.
270 OUT BOOLEAN
*BreakReceived OPTIONAL
274 Check if HOST is connected based on Mailbox.
276 @retval TRUE HOST is connected.
277 @retval FALSE HOST is not connected.
286 Get Debug Agent Mailbox pointer.
288 @return Mailbox pointer.
291 DEBUG_AGENT_MAILBOX
*
297 Get debug port handle.
299 @return Debug port handle.