]>
Commit | Line | Data |
---|---|---|
18b144ea | 1 | /** @file\r |
2 | Command header of for Debug Agent library instance.\r | |
3 | \r | |
77695f4d | 4 | Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r |
85f7e110 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
18b144ea | 6 | \r |
7 | **/\r | |
8 | \r | |
9 | #ifndef _DEBUG_AGENT_H_\r | |
10 | #define _DEBUG_AGENT_H_\r | |
11 | \r | |
12 | #include <Register/LocalApic.h>\r | |
18b144ea | 13 | #include <Guid/DebugAgentGuid.h>\r |
8cc26df4 JF |
14 | #include <Guid/VectorHandoffTable.h>\r |
15 | #include <Ppi/VectorHandoffInfo.h>\r | |
18b144ea | 16 | #include <Library/BaseLib.h>\r |
17 | #include <Library/BaseMemoryLib.h>\r | |
18 | #include <Library/ResetSystemLib.h>\r | |
19 | #include <Library/IoLib.h>\r | |
20 | #include <Library/HobLib.h>\r | |
21 | #include <Library/DebugCommunicationLib.h>\r | |
22 | #include <Library/DebugAgentLib.h>\r | |
23 | #include <Library/PcdLib.h>\r | |
24 | #include <Library/SynchronizationLib.h>\r | |
25 | #include <Library/LocalApicLib.h>\r | |
e2104834 | 26 | #include <Library/DebugLib.h>\r |
b4ebbaff | 27 | #include <Library/TimerLib.h>\r |
93c0bdec | 28 | #include <Library/PrintLib.h>\r |
b422b62c | 29 | #include <Library/PeCoffGetEntryPointLib.h>\r |
30 | #include <Library/PeCoffExtraActionLib.h>\r | |
a742e186 | 31 | #include <Register/ArchitecturalMsr.h>\r |
18b144ea | 32 | \r |
33 | #include <TransferProtocol.h>\r | |
34 | #include <ImageDebugSupport.h>\r | |
35 | \r | |
36 | #include "DebugMp.h"\r | |
37 | #include "DebugTimer.h"\r | |
38 | #include "ArchDebugSupport.h"\r | |
8cc26df4 | 39 | #include "DebugException.h"\r |
18b144ea | 40 | \r |
b422b62c | 41 | //\r |
42 | // These macros may be already defined in DebugAgentLib.h\r | |
43 | //\r | |
c1e126b1 MK |
44 | #define DEBUG_AGENT_INIT_PEI 9\r |
45 | #define DEBUG_AGENT_INIT_DXE_LOAD 10\r | |
46 | #define DEBUG_AGENT_INIT_DXE_UNLOAD 11\r | |
47 | #define DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64 12\r | |
b422b62c | 48 | \r |
c1e126b1 MK |
49 | #define DEBUG_INT1_VECTOR DEBUG_EXCEPT_DEBUG\r |
50 | #define DEBUG_INT3_VECTOR DEBUG_EXCEPT_BREAKPOINT\r | |
51 | #define DEBUG_TIMER_VECTOR 32\r | |
52 | #define DEBUG_MAILBOX_VECTOR 33\r | |
18b144ea | 53 | \r |
b422b62c | 54 | //\r |
55 | // Timeout value for reading packet (unit is microsecond)\r | |
56 | //\r | |
c1e126b1 MK |
57 | #define READ_PACKET_TIMEOUT (500 * 1000)\r |
58 | #define DEBUG_TIMER_INTERVAL (100 * 1000)\r | |
b422b62c | 59 | \r |
c1e126b1 MK |
60 | #define SOFT_INTERRUPT_SIGNATURE SIGNATURE_32('S','O','F','T')\r |
61 | #define SYSTEM_RESET_SIGNATURE SIGNATURE_32('S','Y','S','R')\r | |
62 | #define MEMORY_READY_SIGNATURE SIGNATURE_32('M','E','M','R')\r | |
18b144ea | 63 | \r |
c1e126b1 MK |
64 | extern UINTN Exception0Handle;\r |
65 | extern UINTN TimerInterruptHandle;\r | |
66 | extern UINT32 ExceptionStubHeaderSize;\r | |
67 | extern BOOLEAN mSkipBreakpoint;\r | |
68 | extern EFI_VECTOR_HANDOFF_INFO mVectorHandoffInfoDebugAgent[];\r | |
69 | extern UINTN mVectorHandoffInfoCount;\r | |
b422b62c | 70 | \r |
93c0bdec | 71 | //\r |
72 | // CPU exception information issued by debug agent\r | |
73 | //\r | |
74 | typedef struct {\r | |
75 | //\r | |
76 | // This field is used to save CPU content before executing HOST command\r | |
77 | //\r | |
c1e126b1 | 78 | BASE_LIBRARY_JUMP_BUFFER JumpBuffer;\r |
93c0bdec | 79 | //\r |
ff8ad584 | 80 | // This field returns the exception information issued by the HOST command\r |
93c0bdec | 81 | //\r |
c1e126b1 | 82 | DEBUG_DATA_RESPONSE_GET_EXCEPTION ExceptionContent;\r |
93c0bdec | 83 | } DEBUG_AGENT_EXCEPTION_BUFFER;\r |
18b144ea | 84 | \r |
b422b62c | 85 | #define DEBUG_AGENT_FLAG_HOST_ATTACHED BIT0\r |
86 | #define DEBUG_AGENT_FLAG_AGENT_IN_PROGRESS BIT1\r | |
87 | #define DEBUG_AGENT_FLAG_MEMORY_READY BIT2\r | |
88 | #define DEBUG_AGENT_FLAG_STEPPING BIT3\r | |
89 | #define DEBUG_AGENT_FLAG_CHECK_MAILBOX_IN_HOB BIT4\r | |
0a488765 | 90 | #define DEBUG_AGENT_FLAG_INIT_ARCH BIT5|BIT6\r |
5d51ba26 | 91 | #define DEBUG_AGENT_FLAG_INTERRUPT_FLAG BIT7\r |
b422b62c | 92 | #define DEBUG_AGENT_FLAG_BREAK_ON_NEXT_SMI BIT32\r |
93 | #define DEBUG_AGENT_FLAG_PRINT_ERROR_LEVEL (BIT33|BIT34|BIT35|BIT36)\r | |
94 | #define DEBUG_AGENT_FLAG_BREAK_BOOT_SCRIPT BIT37\r | |
95 | \r | |
96 | #define DEBUG_MAILBOX_DEBUG_FLAG_INDEX 1\r | |
97 | #define DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX 2\r | |
98 | #define DEBUG_MAILBOX_EXCEPTION_BUFFER_POINTER_INDEX 3\r | |
99 | #define DEBUG_MAILBOX_LAST_ACK 4\r | |
100 | #define DEBUG_MAILBOX_SEQUENCE_NO_INDEX 5\r | |
101 | #define DEBUG_MAILBOX_HOST_SEQUENCE_NO_INDEX 6\r | |
08021523 | 102 | #define DEBUG_MAILBOX_DEBUG_TIMER_FREQUENCY 7\r |
93c0bdec | 103 | \r |
b422b62c | 104 | #pragma pack(1)\r |
105 | typedef union {\r | |
106 | struct {\r | |
107 | //\r | |
108 | // Lower 32 bits to store the status of DebugAgent\r | |
109 | //\r | |
c1e126b1 MK |
110 | UINT32 HostAttached : 1; // 1: HOST is attached\r |
111 | UINT32 AgentInProgress : 1; // 1: Debug Agent is communicating with HOST\r | |
112 | UINT32 MemoryReady : 1; // 1: Memory is ready\r | |
113 | UINT32 SteppingFlag : 1; // 1: Agent is running stepping command\r | |
114 | UINT32 CheckMailboxInHob : 1; // 1: Need to check mailbox saved in HOB\r | |
115 | UINT32 InitArch : 2; // value of DEBUG_DATA_RESPONSE_ARCH_MODE\r | |
116 | UINT32 InterruptFlag : 1; // 1: EFLAGS.IF is set\r | |
117 | UINT32 Reserved1 : 24;\r | |
b422b62c | 118 | //\r |
119 | // Higher 32bits to control the behavior of DebugAgent\r | |
120 | //\r | |
c1e126b1 MK |
121 | UINT32 BreakOnNextSmi : 1; // 1: Break on next SMI\r |
122 | UINT32 PrintErrorLevel : 4; // Bitmask of print error level for debug message\r | |
123 | UINT32 BreakOnBootScript : 1; // 1: Break before executing boot script\r | |
124 | UINT32 Reserved2 : 26;\r | |
b422b62c | 125 | } Bits;\r |
c1e126b1 | 126 | UINT64 Uint64;\r |
93c0bdec | 127 | } DEBUG_AGENT_FLAG;\r |
128 | \r | |
18b144ea | 129 | typedef struct {\r |
c1e126b1 MK |
130 | DEBUG_AGENT_FLAG DebugFlag;\r |
131 | UINT64 DebugPortHandle;\r | |
93c0bdec | 132 | //\r |
133 | // Pointer to DEBUG_AGENT_EXCEPTION_BUFFER\r | |
134 | //\r | |
c1e126b1 MK |
135 | UINT64 ExceptionBufferPointer;\r |
136 | UINT8 LastAck; // The last ack packet type\r | |
137 | UINT8 SequenceNo;\r | |
138 | UINT8 HostSequenceNo;\r | |
139 | UINT32 DebugTimerFrequency;\r | |
140 | UINT8 CheckSum; // Mailbox checksum\r | |
141 | UINT8 ToBeCheckSum; // To be Mailbox checksum at the next\r | |
18b144ea | 142 | } DEBUG_AGENT_MAILBOX;\r |
143 | #pragma pack()\r | |
144 | \r | |
b422b62c | 145 | ///\r |
146 | /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.\r | |
147 | ///\r | |
148 | typedef union {\r | |
149 | struct {\r | |
c1e126b1 MK |
150 | UINT32 OffsetLow : 16; ///< Offset bits 15..0.\r |
151 | UINT32 Selector : 16; ///< Selector.\r | |
152 | UINT32 Reserved_0 : 8; ///< Reserved.\r | |
153 | UINT32 GateType : 8; ///< Gate Type. See #defines above.\r | |
154 | UINT32 OffsetHigh : 16; ///< Offset bits 31..16.\r | |
b422b62c | 155 | } Bits;\r |
c1e126b1 | 156 | UINT64 Uint64;\r |
b422b62c | 157 | } IA32_IDT_ENTRY;\r |
158 | \r | |
18b144ea | 159 | typedef union {\r |
160 | struct {\r | |
c1e126b1 MK |
161 | UINT32 LimitLow : 16;\r |
162 | UINT32 BaseLow : 16;\r | |
163 | UINT32 BaseMid : 8;\r | |
164 | UINT32 Type : 4;\r | |
165 | UINT32 System : 1;\r | |
166 | UINT32 Dpl : 2;\r | |
167 | UINT32 Present : 1;\r | |
168 | UINT32 LimitHigh : 4;\r | |
169 | UINT32 Software : 1;\r | |
170 | UINT32 Reserved : 1;\r | |
171 | UINT32 DefaultSize : 1;\r | |
172 | UINT32 Granularity : 1;\r | |
173 | UINT32 BaseHigh : 8;\r | |
18b144ea | 174 | } Bits;\r |
c1e126b1 | 175 | UINT64 Uint64;\r |
18b144ea | 176 | } IA32_GDT;\r |
177 | \r | |
18b144ea | 178 | /**\r |
179 | Initialize IDT entries to support source level debug.\r | |
180 | \r | |
181 | **/\r | |
182 | VOID\r | |
183 | InitializeDebugIdt (\r | |
184 | VOID\r | |
185 | );\r | |
186 | \r | |
18b144ea | 187 | /**\r |
188 | Read register value from saved CPU context.\r | |
189 | \r | |
190 | @param[in] CpuContext Pointer to saved CPU context.\r | |
191 | @param[in] Index Register index value.\r | |
18b144ea | 192 | @param[in] Width Data width to read.\r |
193 | \r | |
194 | @return The address of register value.\r | |
195 | \r | |
196 | **/\r | |
197 | UINT8 *\r | |
198 | ArchReadRegisterBuffer (\r | |
c1e126b1 MK |
199 | IN DEBUG_CPU_CONTEXT *CpuContext,\r |
200 | IN UINT8 Index,\r | |
201 | IN UINT8 *Width\r | |
18b144ea | 202 | );\r |
203 | \r | |
204 | /**\r | |
205 | Send packet with response data to HOST.\r | |
206 | \r | |
d9044ec5 RN |
207 | @param[in] Data Pointer to response data buffer.\r |
208 | @param[in] DataSize Size of response data in byte.\r | |
209 | @param[in, out] DebugHeader Pointer to a buffer for creating response packet and receiving ACK packet,\r | |
210 | to minimize the stack usage.\r | |
18b144ea | 211 | \r |
212 | @retval RETURN_SUCCESS Response data was sent successfully.\r | |
213 | @retval RETURN_DEVICE_ERROR Cannot receive DEBUG_COMMAND_OK from HOST.\r | |
214 | \r | |
215 | **/\r | |
216 | RETURN_STATUS\r | |
217 | SendDataResponsePacket (\r | |
c1e126b1 MK |
218 | IN UINT8 *Data,\r |
219 | IN UINT16 DataSize,\r | |
220 | IN OUT DEBUG_PACKET_HEADER *DebugHeader\r | |
18b144ea | 221 | );\r |
222 | \r | |
223 | /**\r | |
93c0bdec | 224 | Check if HOST is attached based on Mailbox.\r |
18b144ea | 225 | \r |
93c0bdec | 226 | @retval TRUE HOST is attached.\r |
227 | @retval FALSE HOST is not attached.\r | |
18b144ea | 228 | \r |
229 | **/\r | |
93c0bdec | 230 | BOOLEAN\r |
231 | IsHostAttached (\r | |
232 | VOID\r | |
18b144ea | 233 | );\r |
234 | \r | |
235 | /**\r | |
93c0bdec | 236 | Get Debug Agent Mailbox pointer.\r |
18b144ea | 237 | \r |
93c0bdec | 238 | @return Mailbox pointer.\r |
18b144ea | 239 | \r |
240 | **/\r | |
93c0bdec | 241 | DEBUG_AGENT_MAILBOX *\r |
242 | GetMailboxPointer (\r | |
243 | VOID\r | |
18b144ea | 244 | );\r |
245 | \r | |
246 | /**\r | |
93c0bdec | 247 | Get debug port handle.\r |
18b144ea | 248 | \r |
93c0bdec | 249 | @return Debug port handle.\r |
18b144ea | 250 | \r |
251 | **/\r | |
93c0bdec | 252 | DEBUG_PORT_HANDLE\r |
253 | GetDebugPortHandle (\r | |
254 | VOID\r | |
18b144ea | 255 | );\r |
256 | \r | |
257 | /**\r | |
93c0bdec | 258 | Read the Attach/Break-in symbols from the debug port.\r |
18b144ea | 259 | \r |
93c0bdec | 260 | @param[in] Handle Pointer to Debug Port handle.\r |
261 | @param[out] BreakSymbol Returned break symbol.\r | |
18b144ea | 262 | \r |
93c0bdec | 263 | @retval EFI_SUCCESS Read the symbol in BreakSymbol.\r |
264 | @retval EFI_NOT_FOUND No read the break symbol.\r | |
18b144ea | 265 | \r |
266 | **/\r | |
93c0bdec | 267 | EFI_STATUS\r |
268 | DebugReadBreakSymbol (\r | |
c1e126b1 MK |
269 | IN DEBUG_PORT_HANDLE Handle,\r |
270 | OUT UINT8 *BreakSymbol\r | |
18b144ea | 271 | );\r |
272 | \r | |
273 | /**\r | |
93c0bdec | 274 | Prints a debug message to the debug port if the specified error level is enabled.\r |
18b144ea | 275 | \r |
93c0bdec | 276 | If any bit in ErrorLevel is also set in Mainbox, then print the message specified\r |
277 | by Format and the associated variable argument list to the debug port.\r | |
18b144ea | 278 | \r |
93c0bdec | 279 | @param[in] ErrorLevel The error level of the debug message.\r |
280 | @param[in] Format Format string for the debug message to print.\r | |
77695f4d | 281 | @param[in] ... Variable argument list whose contents are accessed\r |
93c0bdec | 282 | based on the format string specified by Format.\r |
18b144ea | 283 | \r |
284 | **/\r | |
93c0bdec | 285 | VOID\r |
286 | EFIAPI\r | |
287 | DebugAgentMsgPrint (\r | |
c1e126b1 MK |
288 | IN UINT8 ErrorLevel,\r |
289 | IN CHAR8 *Format,\r | |
93c0bdec | 290 | ...\r |
18b144ea | 291 | );\r |
b422b62c | 292 | \r |
293 | /**\r | |
294 | Trigger one software interrupt to debug agent to handle it.\r | |
295 | \r | |
296 | @param[in] Signature Software interrupt signature.\r | |
297 | \r | |
298 | **/\r | |
299 | VOID\r | |
300 | TriggerSoftInterrupt (\r | |
c1e126b1 | 301 | IN UINT32 Signature\r |
b422b62c | 302 | );\r |
303 | \r | |
304 | /**\r | |
305 | Check if debug agent support multi-processor.\r | |
306 | \r | |
307 | @retval TRUE Multi-processor is supported.\r | |
308 | @retval FALSE Multi-processor is not supported.\r | |
309 | \r | |
310 | **/\r | |
311 | BOOLEAN\r | |
312 | MultiProcessorDebugSupport (\r | |
313 | VOID\r | |
314 | );\r | |
315 | \r | |
316 | /**\r | |
317 | Find and report module image info to HOST.\r | |
77695f4d | 318 | \r |
b422b62c | 319 | @param[in] AlignSize Image aligned size.\r |
77695f4d | 320 | \r |
b422b62c | 321 | **/\r |
77695f4d | 322 | VOID\r |
b422b62c | 323 | FindAndReportModuleImageInfo (\r |
c1e126b1 | 324 | IN UINTN AlignSize\r |
b422b62c | 325 | );\r |
326 | \r | |
327 | /**\r | |
328 | Read IDT entry to check if IDT entries are setup by Debug Agent.\r | |
329 | \r | |
330 | @retval TRUE IDT entries were setup by Debug Agent.\r | |
331 | @retval FALSE IDT entries were not setup by Debug Agent.\r | |
332 | \r | |
333 | **/\r | |
77695f4d | 334 | BOOLEAN\r |
b422b62c | 335 | IsDebugAgentInitialzed (\r |
336 | VOID\r | |
337 | );\r | |
338 | \r | |
339 | /**\r | |
12e4c407 | 340 | Calculate Mailbox checksum and update the checksum field.\r |
b422b62c | 341 | \r |
342 | @param[in] Mailbox Debug Agent Mailbox pointer.\r | |
343 | \r | |
344 | **/\r | |
345 | VOID\r | |
346 | UpdateMailboxChecksum (\r | |
c1e126b1 | 347 | IN DEBUG_AGENT_MAILBOX *Mailbox\r |
b422b62c | 348 | );\r |
349 | \r | |
350 | /**\r | |
351 | Verify Mailbox checksum.\r | |
352 | \r | |
353 | If checksum error, print debug message and run init dead loop.\r | |
354 | \r | |
355 | @param[in] Mailbox Debug Agent Mailbox pointer.\r | |
356 | \r | |
357 | **/\r | |
77695f4d | 358 | VOID\r |
b422b62c | 359 | VerifyMailboxChecksum (\r |
c1e126b1 | 360 | IN DEBUG_AGENT_MAILBOX *Mailbox\r |
b422b62c | 361 | );\r |
362 | \r | |
363 | /**\r | |
364 | Set debug flag in mailbox.\r | |
365 | \r | |
366 | @param[in] FlagMask Debug flag mask value.\r | |
367 | @param[in] FlagValue Debug flag value.\r | |
368 | \r | |
369 | **/\r | |
77695f4d | 370 | VOID\r |
b422b62c | 371 | SetDebugFlag (\r |
c1e126b1 MK |
372 | IN UINT64 FlagMask,\r |
373 | IN UINT32 FlagValue\r | |
b422b62c | 374 | );\r |
375 | \r | |
376 | /**\r | |
377 | Get debug flag in mailbox.\r | |
378 | \r | |
379 | @param[in] FlagMask Debug flag mask value.\r | |
77695f4d | 380 | \r |
b422b62c | 381 | @return Debug flag value.\r |
382 | \r | |
383 | **/\r | |
384 | UINT32\r | |
385 | GetDebugFlag (\r | |
c1e126b1 | 386 | IN UINT64 FlagMask\r |
b422b62c | 387 | );\r |
388 | \r | |
389 | /**\r | |
390 | Update Mailbox content by index.\r | |
391 | \r | |
392 | @param[in] Mailbox Debug Agent Mailbox pointer.\r | |
393 | @param[in] Index Mailbox content index.\r | |
394 | @param[in] Value Value to be set into mail box.\r | |
77695f4d | 395 | \r |
b422b62c | 396 | **/\r |
397 | VOID\r | |
77695f4d | 398 | UpdateMailboxContent (\r |
c1e126b1 MK |
399 | IN DEBUG_AGENT_MAILBOX *Mailbox,\r |
400 | IN UINTN Index,\r | |
401 | IN UINT64 Value\r | |
b422b62c | 402 | );\r |
403 | \r | |
404 | /**\r | |
405 | Retrieve exception handler from IDT table by ExceptionNum.\r | |
406 | \r | |
407 | @param[in] ExceptionNum Exception number\r | |
77695f4d | 408 | \r |
b422b62c | 409 | @return Exception handler\r |
410 | \r | |
411 | **/\r | |
412 | VOID *\r | |
413 | GetExceptionHandlerInIdtEntry (\r | |
c1e126b1 | 414 | IN UINTN ExceptionNum\r |
b422b62c | 415 | );\r |
416 | \r | |
417 | /**\r | |
418 | Set exception handler in IDT table by ExceptionNum.\r | |
419 | \r | |
420 | @param[in] ExceptionNum Exception number\r | |
77695f4d | 421 | @param[in] ExceptionHandler Exception Handler to be set\r |
b422b62c | 422 | \r |
423 | **/\r | |
424 | VOID\r | |
425 | SetExceptionHandlerInIdtEntry (\r | |
c1e126b1 MK |
426 | IN UINTN ExceptionNum,\r |
427 | IN VOID *ExceptionHandler\r | |
b422b62c | 428 | );\r |
429 | \r | |
430 | /**\r | |
431 | Prints a debug message to the debug output device if the specified error level is enabled.\r | |
432 | \r | |
77695f4d LG |
433 | If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function\r |
434 | GetDebugPrintErrorLevel (), then print the message specified by Format and the\r | |
b422b62c | 435 | associated variable argument list to the debug output device.\r |
436 | \r | |
437 | If Format is NULL, then ASSERT().\r | |
438 | \r | |
439 | @param[in] ErrorLevel The error level of the debug message.\r | |
440 | @param[in] IsSend Flag of debug message to declare that the data is being sent or being received.\r | |
77695f4d | 441 | @param[in] Data Variable argument list whose contents are accessed\r |
b422b62c | 442 | @param[in] Length based on the format string specified by Format.\r |
443 | \r | |
444 | **/\r | |
445 | VOID\r | |
446 | EFIAPI\r | |
447 | DebugAgentDataMsgPrint (\r | |
c1e126b1 MK |
448 | IN UINT8 ErrorLevel,\r |
449 | IN BOOLEAN IsSend,\r | |
450 | IN UINT8 *Data,\r | |
451 | IN UINT8 Length\r | |
b422b62c | 452 | );\r |
453 | \r | |
454 | /**\r | |
d6d4a81f | 455 | Read remaining debug packet except for the start symbol\r |
b422b62c | 456 | \r |
457 | @param[in] Handle Pointer to Debug Port handle.\r | |
458 | @param[in, out] DebugHeader Debug header buffer including start symbol.\r | |
459 | \r | |
460 | @retval EFI_SUCCESS Read the symbol in BreakSymbol.\r | |
461 | @retval EFI_CRC_ERROR CRC check fail.\r | |
462 | @retval EFI_TIMEOUT Timeout occurs when reading debug packet.\r | |
463 | \r | |
464 | **/\r | |
465 | EFI_STATUS\r | |
466 | ReadRemainingBreakPacket (\r | |
c1e126b1 MK |
467 | IN DEBUG_PORT_HANDLE Handle,\r |
468 | IN OUT DEBUG_PACKET_HEADER *DebugHeader\r | |
b422b62c | 469 | );\r |
470 | \r | |
08021523 JF |
471 | /**\r |
472 | Read data from debug channel and save the data in buffer.\r | |
473 | \r | |
474 | Reads NumberOfBytes data bytes from a debug device into the buffer\r | |
475 | specified by Buffer. The number of bytes actually read is returned.\r | |
476 | If the return value is less than NumberOfBytes, then the rest operation failed.\r | |
477 | If NumberOfBytes is zero, then return 0.\r | |
478 | \r | |
479 | @param Handle Debug port handle.\r | |
480 | @param Buffer Pointer to the data buffer to store the data read from the debug device.\r | |
481 | @param NumberOfBytes Number of bytes which will be read.\r | |
482 | @param Timeout Timeout value for reading from debug device. It unit is Microsecond.\r | |
483 | \r | |
484 | @retval 0 Read data failed, no data is to be read.\r | |
485 | @retval >0 Actual number of bytes read from debug device.\r | |
486 | \r | |
487 | **/\r | |
488 | UINTN\r | |
489 | DebugAgentReadBuffer (\r | |
c1e126b1 MK |
490 | IN DEBUG_PORT_HANDLE Handle,\r |
491 | IN OUT UINT8 *Buffer,\r | |
492 | IN UINTN NumberOfBytes,\r | |
493 | IN UINTN Timeout\r | |
08021523 JF |
494 | );\r |
495 | \r | |
18b144ea | 496 | #endif\r |