2 Command header of for Debug Agent library instance.
4 Copyright (c) 2010 - 2011, 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>
34 #include <TransferProtocol.h>
35 #include <ImageDebugSupport.h>
38 #include "DebugTimer.h"
39 #include "ArchDebugSupport.h"
41 #define DEBUG_AGENT_REVISION ((0 << 16) | 01)
42 #define DEBUG_AGENT_CAPABILITIES 0
44 #define DEBUG_INT1_VECTOR 1
45 #define DEBUG_INT3_VECTOR 3
46 #define DEBUG_TIMER_VECTOR 32
47 #define DEBUG_MAILBOX_VECTOR 33
49 #define SOFT_INTERRUPT_SIGNATURE SIGNATURE_32('S','O','F','T')
50 #define SYSTEM_RESET_SIGNATURE SIGNATURE_32('S','Y','S','R')
51 #define MEMORY_READY_SIGNATURE SIGNATURE_32('M','E','M','R')
53 extern UINTN Exception0Handle
;
54 extern UINTN TimerInterruptHandle
;
55 extern UINT16 ExceptionStubHeaderSize
;
59 UINT32 HostPresent
: 1;
60 UINT32 BreakOnNextSmi
: 1;
68 DEBUG_AGENT_FLAG DebugFlag
;
69 UINT64 DebugPortHandle
;
70 } DEBUG_AGENT_MAILBOX
;
85 UINT32 DefaultSize
: 1;
86 UINT32 Granularity
: 1;
93 Caller provided function to be invoked at the end of DebugPortInitialize().
95 Refer to the descrption for DebugPortInitialize() for more details.
97 @param[in] Context The first input argument of DebugPortInitialize().
98 @param[in] DebugPortHandle Debug port handle created by Debug Communication Libary.
103 InitializeDebugAgentPhase2 (
105 IN DEBUG_PORT_HANDLE DebugPortHandle
109 Initialize IDT entries to support source level debug.
118 Write specified register into save CPU context.
120 @param[in] CpuContext Pointer to saved CPU context.
121 @param[in] Index Register index value.
122 @param[in] Offset Offset in register address range
123 @param[in] Width Data width to read.
124 @param[in] RegisterBuffer Pointer to input buffer with data.
128 ArchWriteRegisterBuffer (
129 IN DEBUG_CPU_CONTEXT
*CpuContext
,
133 IN UINT8
*RegisterBuffer
137 Read register value from saved CPU context.
139 @param[in] CpuContext Pointer to saved CPU context.
140 @param[in] Index Register index value.
141 @param[in] Offset Offset in register address range
142 @param[in] Width Data width to read.
144 @return The address of register value.
148 ArchReadRegisterBuffer (
149 IN DEBUG_CPU_CONTEXT
*CpuContext
,
156 Send packet with response data to HOST.
158 @param[in] CpuContext Pointer to saved CPU context.
159 @param[in] Data Pointer to response data buffer.
160 @param[in] DataSize Size of response data in byte.
162 @retval RETURN_SUCCESS Response data was sent successfully.
163 @retval RETURN_DEVICE_ERROR Cannot receive DEBUG_COMMAND_OK from HOST.
167 SendDataResponsePacket (
168 IN DEBUG_CPU_CONTEXT
*CpuContext
,
174 Read segment selector by register index.
176 @param[in] CpuContext Pointer to saved CPU context.
177 @param[in] RegisterIndex Register Index.
179 @return Value of segment selector.
183 ReadRegisterSelectorByIndex (
184 IN DEBUG_CPU_CONTEXT
*CpuContext
,
185 IN UINT8 RegisterIndex
189 Read group register of common registers.
191 @param[in] CpuContext Pointer to saved CPU context.
192 @param[in] RegisterGroup Pointer to Group registers.
197 IN DEBUG_CPU_CONTEXT
*CpuContext
,
198 IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP
*RegisterGroup
202 Read group register of Segment Base.
204 @param[in] CpuContext Pointer to saved CPU context.
205 @param[in] RegisterGroupSegBase Pointer to Group registers.
209 ReadRegisterGroupSegBase (
210 IN DEBUG_CPU_CONTEXT
*CpuContext
,
211 IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP_SEGBASE
*RegisterGroupSegBase
215 Read gourp register of Segment Limit.
217 @param[in] CpuContext Pointer to saved CPU context.
218 @param[in] RegisterGroupSegLim Pointer to Group registers.
222 ReadRegisterGroupSegLim (
223 IN DEBUG_CPU_CONTEXT
*CpuContext
,
224 IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP_SEGLIM
*RegisterGroupSegLim
228 Read group register by group index.
230 @param[in] CpuContext Pointer to saved CPU context.
231 @param[in] GroupIndex Group Index.
233 @retval RETURN_SUCCESS Read successfully.
234 @retval RETURN_NOT_SUPPORTED Group index cannot be supported.
238 ArchReadRegisterGroup (
239 IN DEBUG_CPU_CONTEXT
*CpuContext
,
244 Send acknowledge packet to HOST.
246 @param AckCommand Type of Acknowledge packet.
255 Receive acknowledge packet OK from HOST in specified time.
257 @param[in] Timeout Time out value to wait for acknowlege from HOST.
258 The unit is microsecond.
259 @param[out] BreakReceived If BreakReceived is not NULL,
260 TRUE is retured if break-in symbol received.
261 FALSE is retured if break-in symbol not received.
263 @retval RETRUEN_SUCCESS Succeed to receive acknowlege packet from HOST,
264 the type of acknowlege packet saved in Ack.
265 @retval RETURN_TIMEOUT Specified timeout value was up.
271 OUT BOOLEAN
*BreakReceived OPTIONAL
275 Check if HOST is connected based on Mailbox.
277 @retval TRUE HOST is connected.
278 @retval FALSE HOST is not connected.
287 Get Debug Agent Mailbox pointer.
289 @return Mailbox pointer.
292 DEBUG_AGENT_MAILBOX
*
298 Get debug port handle.
300 @return Debug port handle.