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>
35 #include <TransferProtocol.h>
36 #include <ImageDebugSupport.h>
39 #include "DebugTimer.h"
40 #include "ArchDebugSupport.h"
42 #define DEBUG_AGENT_REVISION ((0 << 16) | 01)
43 #define DEBUG_AGENT_CAPABILITIES 0
45 #define DEBUG_INT1_VECTOR 1
46 #define DEBUG_INT3_VECTOR 3
47 #define DEBUG_TIMER_VECTOR 32
48 #define DEBUG_MAILBOX_VECTOR 33
50 #define SOFT_INTERRUPT_SIGNATURE SIGNATURE_32('S','O','F','T')
51 #define SYSTEM_RESET_SIGNATURE SIGNATURE_32('S','Y','S','R')
52 #define MEMORY_READY_SIGNATURE SIGNATURE_32('M','E','M','R')
54 extern UINTN Exception0Handle
;
55 extern UINTN TimerInterruptHandle
;
56 extern UINT16 ExceptionStubHeaderSize
;
60 UINT32 HostPresent
: 1;
61 UINT32 BreakOnNextSmi
: 1;
69 DEBUG_AGENT_FLAG DebugFlag
;
70 UINT64 DebugPortHandle
;
71 } DEBUG_AGENT_MAILBOX
;
86 UINT32 DefaultSize
: 1;
87 UINT32 Granularity
: 1;
94 Caller provided function to be invoked at the end of DebugPortInitialize().
96 Refer to the descrption for DebugPortInitialize() for more details.
98 @param[in] Context The first input argument of DebugPortInitialize().
99 @param[in] DebugPortHandle Debug port handle created by Debug Communication Libary.
104 InitializeDebugAgentPhase2 (
106 IN DEBUG_PORT_HANDLE DebugPortHandle
110 Initialize IDT entries to support source level debug.
119 Write specified register into save CPU context.
121 @param[in] CpuContext Pointer to saved CPU context.
122 @param[in] Index Register index value.
123 @param[in] Offset Offset in register address range
124 @param[in] Width Data width to read.
125 @param[in] RegisterBuffer Pointer to input buffer with data.
129 ArchWriteRegisterBuffer (
130 IN DEBUG_CPU_CONTEXT
*CpuContext
,
134 IN UINT8
*RegisterBuffer
138 Read register value from saved CPU context.
140 @param[in] CpuContext Pointer to saved CPU context.
141 @param[in] Index Register index value.
142 @param[in] Offset Offset in register address range
143 @param[in] Width Data width to read.
145 @return The address of register value.
149 ArchReadRegisterBuffer (
150 IN DEBUG_CPU_CONTEXT
*CpuContext
,
157 Send packet with response data to HOST.
159 @param[in] CpuContext Pointer to saved CPU context.
160 @param[in] Data Pointer to response data buffer.
161 @param[in] DataSize Size of response data in byte.
163 @retval RETURN_SUCCESS Response data was sent successfully.
164 @retval RETURN_DEVICE_ERROR Cannot receive DEBUG_COMMAND_OK from HOST.
168 SendDataResponsePacket (
169 IN DEBUG_CPU_CONTEXT
*CpuContext
,
175 Read segment selector by register index.
177 @param[in] CpuContext Pointer to saved CPU context.
178 @param[in] RegisterIndex Register Index.
180 @return Value of segment selector.
184 ReadRegisterSelectorByIndex (
185 IN DEBUG_CPU_CONTEXT
*CpuContext
,
186 IN UINT8 RegisterIndex
190 Read group register of common registers.
192 @param[in] CpuContext Pointer to saved CPU context.
193 @param[in] RegisterGroup Pointer to Group registers.
198 IN DEBUG_CPU_CONTEXT
*CpuContext
,
199 IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP
*RegisterGroup
203 Read group register of Segment Base.
205 @param[in] CpuContext Pointer to saved CPU context.
206 @param[in] RegisterGroupSegBase Pointer to Group registers.
210 ReadRegisterGroupSegBase (
211 IN DEBUG_CPU_CONTEXT
*CpuContext
,
212 IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP_SEGBASE
*RegisterGroupSegBase
216 Read gourp register of Segment Limit.
218 @param[in] CpuContext Pointer to saved CPU context.
219 @param[in] RegisterGroupSegLim Pointer to Group registers.
223 ReadRegisterGroupSegLim (
224 IN DEBUG_CPU_CONTEXT
*CpuContext
,
225 IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP_SEGLIM
*RegisterGroupSegLim
229 Read group register by group index.
231 @param[in] CpuContext Pointer to saved CPU context.
232 @param[in] GroupIndex Group Index.
234 @retval RETURN_SUCCESS Read successfully.
235 @retval RETURN_NOT_SUPPORTED Group index cannot be supported.
239 ArchReadRegisterGroup (
240 IN DEBUG_CPU_CONTEXT
*CpuContext
,
245 Send acknowledge packet to HOST.
247 @param AckCommand Type of Acknowledge packet.
256 Receive acknowledge packet OK from HOST in specified time.
258 @param[in] Timeout Time out value to wait for acknowlege from HOST.
259 The unit is microsecond.
260 @param[out] BreakReceived If BreakReceived is not NULL,
261 TRUE is retured if break-in symbol received.
262 FALSE is retured if break-in symbol not received.
264 @retval RETRUEN_SUCCESS Succeed to receive acknowlege packet from HOST,
265 the type of acknowlege packet saved in Ack.
266 @retval RETURN_TIMEOUT Specified timeout value was up.
272 OUT BOOLEAN
*BreakReceived OPTIONAL
276 Check if HOST is connected based on Mailbox.
278 @retval TRUE HOST is connected.
279 @retval FALSE HOST is not connected.
288 Get Debug Agent Mailbox pointer.
290 @return Mailbox pointer.
293 DEBUG_AGENT_MAILBOX
*
299 Get debug port handle.
301 @return Debug port handle.