]>
Commit | Line | Data |
---|---|---|
18b144ea | 1 | /** @file\r |
2 | Command header of for Debug Agent library instance.\r | |
3 | \r | |
b4ebbaff | 4 | Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r |
18b144ea | 5 | This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php.\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #ifndef _DEBUG_AGENT_H_\r | |
16 | #define _DEBUG_AGENT_H_\r | |
17 | \r | |
18 | #include <Register/LocalApic.h>\r | |
19 | \r | |
20 | #include <Guid/DebugAgentGuid.h>\r | |
21 | \r | |
22 | #include <Library/BaseLib.h>\r | |
23 | #include <Library/BaseMemoryLib.h>\r | |
24 | #include <Library/ResetSystemLib.h>\r | |
25 | #include <Library/IoLib.h>\r | |
26 | #include <Library/HobLib.h>\r | |
27 | #include <Library/DebugCommunicationLib.h>\r | |
28 | #include <Library/DebugAgentLib.h>\r | |
29 | #include <Library/PcdLib.h>\r | |
30 | #include <Library/SynchronizationLib.h>\r | |
31 | #include <Library/LocalApicLib.h>\r | |
e2104834 | 32 | #include <Library/DebugLib.h>\r |
b4ebbaff | 33 | #include <Library/TimerLib.h>\r |
18b144ea | 34 | \r |
35 | #include <TransferProtocol.h>\r | |
36 | #include <ImageDebugSupport.h>\r | |
37 | \r | |
38 | #include "DebugMp.h"\r | |
39 | #include "DebugTimer.h"\r | |
40 | #include "ArchDebugSupport.h"\r | |
41 | \r | |
42 | #define DEBUG_AGENT_REVISION ((0 << 16) | 01)\r | |
43 | #define DEBUG_AGENT_CAPABILITIES 0\r | |
44 | \r | |
45 | #define DEBUG_INT1_VECTOR 1\r | |
46 | #define DEBUG_INT3_VECTOR 3\r | |
47 | #define DEBUG_TIMER_VECTOR 32\r | |
48 | #define DEBUG_MAILBOX_VECTOR 33\r | |
49 | \r | |
50 | #define SOFT_INTERRUPT_SIGNATURE SIGNATURE_32('S','O','F','T')\r | |
51 | #define SYSTEM_RESET_SIGNATURE SIGNATURE_32('S','Y','S','R')\r | |
52 | #define MEMORY_READY_SIGNATURE SIGNATURE_32('M','E','M','R')\r | |
53 | \r | |
54 | extern UINTN Exception0Handle;\r | |
55 | extern UINTN TimerInterruptHandle;\r | |
56 | extern UINT16 ExceptionStubHeaderSize;\r | |
57 | \r | |
58 | typedef union {\r | |
59 | struct {\r | |
60 | UINT32 HostPresent : 1;\r | |
61 | UINT32 BreakOnNextSmi : 1;\r | |
62 | UINT32 Reserved : 30;\r | |
63 | } Bits;\r | |
64 | UINT32 Uint32;\r | |
65 | } DEBUG_AGENT_FLAG;\r | |
66 | \r | |
67 | #pragma pack(1)\r | |
68 | typedef struct {\r | |
69 | DEBUG_AGENT_FLAG DebugFlag;\r | |
70 | UINT64 DebugPortHandle;\r | |
71 | } DEBUG_AGENT_MAILBOX;\r | |
72 | #pragma pack()\r | |
73 | \r | |
74 | typedef union {\r | |
75 | struct {\r | |
76 | UINT32 LimitLow : 16;\r | |
77 | UINT32 BaseLow : 16;\r | |
78 | UINT32 BaseMid : 8;\r | |
79 | UINT32 Type : 4;\r | |
80 | UINT32 System : 1;\r | |
81 | UINT32 Dpl : 2;\r | |
82 | UINT32 Present : 1;\r | |
83 | UINT32 LimitHigh : 4;\r | |
84 | UINT32 Software : 1;\r | |
85 | UINT32 Reserved : 1;\r | |
86 | UINT32 DefaultSize : 1;\r | |
87 | UINT32 Granularity : 1;\r | |
88 | UINT32 BaseHigh : 8;\r | |
89 | } Bits;\r | |
90 | UINT64 Uint64;\r | |
91 | } IA32_GDT;\r | |
92 | \r | |
93 | /**\r | |
94 | Caller provided function to be invoked at the end of DebugPortInitialize().\r | |
95 | \r | |
96 | Refer to the descrption for DebugPortInitialize() for more details.\r | |
97 | \r | |
98 | @param[in] Context The first input argument of DebugPortInitialize().\r | |
99 | @param[in] DebugPortHandle Debug port handle created by Debug Communication Libary.\r | |
100 | \r | |
101 | **/\r | |
102 | VOID\r | |
103 | EFIAPI\r | |
104 | InitializeDebugAgentPhase2 (\r | |
105 | IN VOID *Context,\r | |
106 | IN DEBUG_PORT_HANDLE DebugPortHandle\r | |
107 | );\r | |
108 | \r | |
109 | /**\r | |
110 | Initialize IDT entries to support source level debug.\r | |
111 | \r | |
112 | **/\r | |
113 | VOID\r | |
114 | InitializeDebugIdt (\r | |
115 | VOID\r | |
116 | );\r | |
117 | \r | |
118 | /**\r | |
119 | Write specified register into save CPU context.\r | |
120 | \r | |
121 | @param[in] CpuContext Pointer to saved CPU context.\r | |
122 | @param[in] Index Register index value.\r | |
123 | @param[in] Offset Offset in register address range\r | |
124 | @param[in] Width Data width to read.\r | |
125 | @param[in] RegisterBuffer Pointer to input buffer with data.\r | |
126 | \r | |
127 | **/\r | |
128 | VOID\r | |
129 | ArchWriteRegisterBuffer (\r | |
130 | IN DEBUG_CPU_CONTEXT *CpuContext,\r | |
131 | IN UINT8 Index,\r | |
132 | IN UINT8 Offset,\r | |
133 | IN UINT8 Width,\r | |
134 | IN UINT8 *RegisterBuffer\r | |
135 | );\r | |
136 | \r | |
137 | /**\r | |
138 | Read register value from saved CPU context.\r | |
139 | \r | |
140 | @param[in] CpuContext Pointer to saved CPU context.\r | |
141 | @param[in] Index Register index value.\r | |
142 | @param[in] Offset Offset in register address range\r | |
143 | @param[in] Width Data width to read.\r | |
144 | \r | |
145 | @return The address of register value.\r | |
146 | \r | |
147 | **/\r | |
148 | UINT8 *\r | |
149 | ArchReadRegisterBuffer (\r | |
150 | IN DEBUG_CPU_CONTEXT *CpuContext,\r | |
151 | IN UINT8 Index,\r | |
152 | IN UINT8 Offset,\r | |
153 | IN UINT8 *Width\r | |
154 | );\r | |
155 | \r | |
156 | /**\r | |
157 | Send packet with response data to HOST.\r | |
158 | \r | |
159 | @param[in] CpuContext Pointer to saved CPU context.\r | |
160 | @param[in] Data Pointer to response data buffer.\r | |
161 | @param[in] DataSize Size of response data in byte.\r | |
162 | \r | |
163 | @retval RETURN_SUCCESS Response data was sent successfully.\r | |
164 | @retval RETURN_DEVICE_ERROR Cannot receive DEBUG_COMMAND_OK from HOST.\r | |
165 | \r | |
166 | **/\r | |
167 | RETURN_STATUS\r | |
168 | SendDataResponsePacket (\r | |
169 | IN DEBUG_CPU_CONTEXT *CpuContext,\r | |
170 | IN UINT8 *Data,\r | |
171 | IN UINT16 DataSize\r | |
172 | );\r | |
173 | \r | |
174 | /**\r | |
175 | Read segment selector by register index.\r | |
176 | \r | |
177 | @param[in] CpuContext Pointer to saved CPU context.\r | |
178 | @param[in] RegisterIndex Register Index.\r | |
179 | \r | |
180 | @return Value of segment selector.\r | |
181 | \r | |
182 | **/\r | |
183 | UINT64\r | |
184 | ReadRegisterSelectorByIndex (\r | |
185 | IN DEBUG_CPU_CONTEXT *CpuContext,\r | |
186 | IN UINT8 RegisterIndex\r | |
187 | );\r | |
188 | \r | |
189 | /**\r | |
190 | Read group register of common registers.\r | |
191 | \r | |
192 | @param[in] CpuContext Pointer to saved CPU context.\r | |
193 | @param[in] RegisterGroup Pointer to Group registers.\r | |
194 | \r | |
195 | **/\r | |
196 | VOID\r | |
197 | ReadRegisterGroup (\r | |
198 | IN DEBUG_CPU_CONTEXT *CpuContext,\r | |
199 | IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP *RegisterGroup\r | |
200 | );\r | |
201 | \r | |
202 | /**\r | |
203 | Read group register of Segment Base.\r | |
204 | \r | |
205 | @param[in] CpuContext Pointer to saved CPU context.\r | |
206 | @param[in] RegisterGroupSegBase Pointer to Group registers.\r | |
207 | \r | |
208 | **/\r | |
209 | VOID\r | |
210 | ReadRegisterGroupSegBase (\r | |
211 | IN DEBUG_CPU_CONTEXT *CpuContext,\r | |
212 | IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP_SEGBASE *RegisterGroupSegBase\r | |
213 | );\r | |
214 | \r | |
215 | /**\r | |
216 | Read gourp register of Segment Limit.\r | |
217 | \r | |
218 | @param[in] CpuContext Pointer to saved CPU context.\r | |
219 | @param[in] RegisterGroupSegLim Pointer to Group registers.\r | |
220 | \r | |
221 | **/\r | |
222 | VOID\r | |
223 | ReadRegisterGroupSegLim (\r | |
224 | IN DEBUG_CPU_CONTEXT *CpuContext,\r | |
225 | IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP_SEGLIM *RegisterGroupSegLim\r | |
226 | );\r | |
227 | \r | |
228 | /**\r | |
229 | Read group register by group index.\r | |
230 | \r | |
231 | @param[in] CpuContext Pointer to saved CPU context.\r | |
232 | @param[in] GroupIndex Group Index.\r | |
233 | \r | |
234 | @retval RETURN_SUCCESS Read successfully.\r | |
235 | @retval RETURN_NOT_SUPPORTED Group index cannot be supported.\r | |
236 | \r | |
237 | **/\r | |
238 | RETURN_STATUS\r | |
239 | ArchReadRegisterGroup (\r | |
240 | IN DEBUG_CPU_CONTEXT *CpuContext,\r | |
241 | IN UINT8 GroupIndex\r | |
242 | );\r | |
243 | \r | |
244 | /**\r | |
245 | Send acknowledge packet to HOST.\r | |
246 | \r | |
247 | @param AckCommand Type of Acknowledge packet.\r | |
248 | \r | |
249 | **/\r | |
250 | VOID\r | |
251 | SendAckPacket (\r | |
252 | IN UINT8 AckCommand\r | |
253 | );\r | |
254 | \r | |
255 | /**\r | |
256 | Receive acknowledge packet OK from HOST in specified time.\r | |
257 | \r | |
258 | @param[in] Timeout Time out value to wait for acknowlege from HOST.\r | |
259 | The unit is microsecond.\r | |
260 | @param[out] BreakReceived If BreakReceived is not NULL,\r | |
261 | TRUE is retured if break-in symbol received.\r | |
262 | FALSE is retured if break-in symbol not received.\r | |
263 | \r | |
264 | @retval RETRUEN_SUCCESS Succeed to receive acknowlege packet from HOST,\r | |
265 | the type of acknowlege packet saved in Ack.\r | |
266 | @retval RETURN_TIMEOUT Specified timeout value was up.\r | |
267 | \r | |
268 | **/\r | |
269 | RETURN_STATUS\r | |
270 | WaitForAckPacketOK (\r | |
271 | IN UINTN Timeout,\r | |
272 | OUT BOOLEAN *BreakReceived OPTIONAL\r | |
273 | );\r | |
274 | \r | |
275 | /**\r | |
276 | Check if HOST is connected based on Mailbox.\r | |
277 | \r | |
278 | @retval TRUE HOST is connected.\r | |
279 | @retval FALSE HOST is not connected.\r | |
280 | \r | |
281 | **/\r | |
282 | BOOLEAN\r | |
283 | IsHostConnected (\r | |
284 | VOID\r | |
285 | );\r | |
286 | \r | |
287 | /**\r | |
288 | Get Debug Agent Mailbox pointer.\r | |
289 | \r | |
290 | @return Mailbox pointer.\r | |
291 | \r | |
292 | **/\r | |
293 | DEBUG_AGENT_MAILBOX *\r | |
294 | GetMailboxPointer (\r | |
295 | VOID\r | |
296 | );\r | |
297 | \r | |
298 | /**\r | |
299 | Get debug port handle.\r | |
300 | \r | |
301 | @return Debug port handle.\r | |
302 | \r | |
303 | **/\r | |
304 | DEBUG_PORT_HANDLE\r | |
305 | GetDebugPortHandle (\r | |
306 | VOID\r | |
307 | );\r | |
308 | \r | |
309 | #endif\r | |
310 | \r |