1e57a462 |
1 | /** @file\r |
2 | Private include file for GDB stub\r |
3 | \r |
4 | Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r |
5 | \r |
6 | This program and the accompanying materials\r |
7 | are licensed and made available under the terms and conditions of the BSD License\r |
8 | which accompanies this distribution. The full text of the license may be found at\r |
9 | http://opensource.org/licenses/bsd-license.php\r |
10 | \r |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r |
13 | \r |
14 | **/\r |
15 | \r |
16 | #ifndef __GDB_STUB_INTERNAL__\r |
17 | #define __GDB_STUB_INTERNAL__\r |
18 | \r |
19 | #include <Uefi.h>\r |
20 | #include <Library/BaseLib.h>\r |
21 | #include <Library/BaseMemoryLib.h>\r |
22 | #include <Library/MemoryAllocationLib.h>\r |
23 | #include <Library/DebugLib.h>\r |
24 | #include <Library/UefiLib.h>\r |
25 | #include <Library/UefiBootServicesTableLib.h>\r |
26 | #include <Library/PcdLib.h>\r |
27 | #include <Library/GdbSerialLib.h>\r |
28 | #include <Library/PrintLib.h>\r |
29 | \r |
30 | #include <Protocol/DebugSupport.h>\r |
31 | #include <Protocol/SerialIo.h>\r |
32 | #include <Protocol/LoadedImage.h>\r |
33 | #include <Protocol/LoadedImage.h>\r |
34 | #include <Guid/DebugImageInfoTable.h>\r |
35 | #include <IndustryStandard/PeImage.h>\r |
36 | \r |
37 | extern CONST CHAR8 mHexToStr[];\r |
38 | \r |
39 | // maximum size of input and output buffers\r |
40 | // This value came from the show remote command of the gdb we tested against \r |
41 | #define MAX_BUF_SIZE 2000\r |
42 | \r |
43 | // maximum size of address buffer\r |
44 | #define MAX_ADDR_SIZE 32\r |
45 | \r |
46 | // maximum size of register number buffer\r |
47 | #define MAX_REG_NUM_BUF_SIZE 32\r |
48 | \r |
49 | // maximum size of length buffer\r |
50 | #define MAX_LENGTH_SIZE 32\r |
51 | \r |
52 | // maximum size of T signal members\r |
53 | #define MAX_T_SIGNAL_SIZE 64\r |
54 | \r |
55 | // the mask used to clear all the cache\r |
56 | #define TF_BIT 0x00000100\r |
57 | \r |
58 | \r |
59 | //\r |
60 | // GDB Signal definitions - generic names for interrupts\r |
61 | //\r |
62 | #define GDB_SIGILL 4 // Illegal instruction \r |
63 | #define GDB_SIGTRAP 5 // Trace Trap (Breakpoint and SingleStep)\r |
64 | #define GDB_SIGEMT 7 // Emulator Trap\r |
65 | #define GDB_SIGFPE 8 // Floating point exception\r |
6f711615 |
66 | #define GDB_SIGSEGV 11 // Segment violation, page fault\r |
1e57a462 |
67 | \r |
68 | \r |
69 | //\r |
70 | // GDB File I/O Error values, zero means no error\r |
71 | // Includes all general GDB Unix like error values\r |
72 | //\r |
73 | #define GDB_EBADMEMADDRBUFSIZE 11 // the buffer that stores memory Address to be read from/written to is not the right size\r |
74 | #define GDB_EBADMEMLENGBUFSIZE 12 // the buffer that stores Length is not the right size \r |
75 | #define GDB_EBADMEMLENGTH 13 // Length, the given number of bytes to read or write, is not the right size\r |
76 | #define GDB_EBADMEMDATA 14 // one of the bytes or nibbles of the memory is leess than 0 \r |
77 | #define GDB_EBADMEMDATASIZE 15 // the memory data, 'XX..', is too short or too long\r |
78 | #define GDB_EBADBUFSIZE 21 // the buffer created is not the correct size\r |
79 | #define GDB_EINVALIDARG 31 // argument is invalid\r |
80 | #define GDB_ENOSPACE 41 //\r |
81 | #define GDB_EINVALIDBRKPOINTTYPE 51 // the breakpoint type is not recognized\r |
82 | #define GDB_EINVALIDREGNUM 61 // given register number is not valid: either <0 or >=Number of Registers\r |
83 | #define GDB_EUNKNOWN 255 // unknown\r |
84 | \r |
85 | \r |
86 | //\r |
87 | // These devices are open by GDB so we can just read and write to them\r |
88 | //\r |
89 | #define GDB_STDIN 0x00\r |
90 | #define GDB_STDOUT 0x01\r |
91 | #define GDB_STDERR 0x02\r |
92 | \r |
93 | //\r |
94 | //Define Register size for different architectures\r |
95 | //\r |
96 | #if defined (MDE_CPU_IA32) \r |
97 | #define REG_SIZE 32\r |
98 | #elif defined (MDE_CPU_X64)\r |
99 | #define REG_SIZE 64\r |
100 | #elif defined (MDE_CPU_ARM)\r |
101 | #define REG_SIZE 32\r |
102 | #endif\r |
103 | \r |
104 | #define GDB_SERIAL_DEV_SIGNATURE SIGNATURE_32 ('g', 'd', 'b', 's')\r |
105 | \r |
106 | typedef struct {\r |
107 | VENDOR_DEVICE_PATH VendorDevice;\r |
108 | UINT32 Index; // Suport more than one\r |
109 | EFI_DEVICE_PATH_PROTOCOL End;\r |
110 | } GDB_SERIAL_DEVICE_PATH;\r |
111 | \r |
112 | //\r |
113 | // Name: SERIAL_DEV\r |
114 | // Purpose: To provide device specific information\r |
115 | // Fields:\r |
116 | // Signature UINTN: The identity of the serial device\r |
117 | // SerialIo SERIAL_IO_PROTOCOL: Serial I/O protocol interface\r |
118 | // SerialMode SERIAL_IO_MODE:\r |
119 | // DevicePath EFI_DEVICE_PATH_PROTOCOL *: Device path of the serial device\r |
120 | //\r |
121 | typedef struct {\r |
122 | UINTN Signature;\r |
123 | EFI_HANDLE Handle;\r |
124 | EFI_SERIAL_IO_PROTOCOL SerialIo;\r |
125 | EFI_SERIAL_IO_MODE SerialMode;\r |
126 | GDB_SERIAL_DEVICE_PATH DevicePath;\r |
127 | INTN InFileDescriptor;\r |
128 | INTN OutFileDescriptor;\r |
129 | } GDB_SERIAL_DEV;\r |
130 | \r |
131 | \r |
132 | #define GDB_SERIAL_DEV_FROM_THIS(a) CR (a, GDB_SERIAL_DEV, SerialIo, GDB_SERIAL_DEV_SIGNATURE)\r |
133 | \r |
134 | \r |
135 | typedef struct {\r |
136 | EFI_EXCEPTION_TYPE Exception;\r |
137 | UINT8 SignalNo;\r |
138 | } EFI_EXCEPTION_TYPE_ENTRY;\r |
139 | \r |
140 | \r |
141 | #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r |
142 | \r |
143 | //\r |
144 | // Byte packed structure for DR6\r |
145 | // 32-bits on IA-32\r |
146 | // 64-bits on X64. The upper 32-bits on X64 are reserved\r |
147 | //\r |
148 | typedef union {\r |
149 | struct {\r |
150 | UINT32 B0:1; // Breakpoint condition detected\r |
151 | UINT32 B1:1; // Breakpoint condition detected\r |
152 | UINT32 B2:1; // Breakpoint condition detected\r |
153 | UINT32 B3:1; // Breakpoint condition detected\r |
154 | UINT32 Reserved_1:9; // Reserved \r |
155 | UINT32 BD:1; // Debug register access detected\r |
156 | UINT32 BS:1; // Single step\r |
157 | UINT32 BT:1; // Task switch\r |
158 | UINT32 Reserved_2:16; // Reserved\r |
159 | } Bits;\r |
160 | UINTN UintN;\r |
161 | } IA32_DR6;\r |
162 | \r |
163 | //\r |
164 | // Byte packed structure for DR7\r |
165 | // 32-bits on IA-32\r |
166 | // 64-bits on X64. The upper 32-bits on X64 are reserved\r |
167 | //\r |
168 | typedef union {\r |
169 | struct {\r |
170 | UINT32 L0:1; // Local breakpoint enable\r |
171 | UINT32 G0:1; // Global breakpoint enable\r |
172 | UINT32 L1:1; // Local breakpoint enable\r |
173 | UINT32 G1:1; // Global breakpoint enable\r |
174 | UINT32 L2:1; // Local breakpoint enable\r |
175 | UINT32 G2:1; // Global breakpoint enable\r |
176 | UINT32 L3:1; // Local breakpoint enable\r |
177 | UINT32 G3:1; // Global breakpoint enable\r |
178 | UINT32 LE:1; // Local exact breakpoint enable\r |
179 | UINT32 GE:1; // Global exact breakpoint enable\r |
180 | UINT32 Reserved_1:3; // Reserved\r |
181 | UINT32 GD:1; // Global detect enable\r |
182 | UINT32 Reserved_2:2; // Reserved\r |
183 | UINT32 RW0:2; // Read/Write field\r |
184 | UINT32 LEN0:2; // Length field\r |
185 | UINT32 RW1:2; // Read/Write field\r |
186 | UINT32 LEN1:2; // Length field\r |
187 | UINT32 RW2:2; // Read/Write field\r |
188 | UINT32 LEN2:2; // Length field\r |
189 | UINT32 RW3:2; // Read/Write field\r |
190 | UINT32 LEN3:2; // Length field\r |
191 | } Bits;\r |
192 | UINTN UintN;\r |
193 | } IA32_DR7;\r |
194 | \r |
195 | #endif /* if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64) */\r |
196 | \r |
197 | typedef enum {\r |
198 | InstructionExecution, //Hardware breakpoint\r |
199 | DataWrite, //watch\r |
200 | DataRead, //rwatch\r |
201 | DataReadWrite, //awatch\r |
202 | SoftwareBreakpoint, //Software breakpoint\r |
203 | NotSupported\r |
204 | } BREAK_TYPE;\r |
205 | \r |
206 | //\r |
207 | // Array of exception types that need to be hooked by the debugger\r |
208 | //\r |
209 | extern EFI_EXCEPTION_TYPE_ENTRY gExceptionType[];\r |
210 | \r |
211 | //\r |
212 | // Set TRUE if F Reply package signals a ctrl-c. We can not process the Ctrl-c\r |
213 | // here we need to wait for the periodic callback to do this. \r |
214 | //\r |
215 | extern BOOLEAN gCtrlCBreakFlag;\r |
216 | \r |
217 | //\r |
218 | // If the periodic callback is called while we are processing an F packet we need\r |
219 | // to let the callback know to not read from the serail stream as it could steal\r |
220 | // characters from the F reponse packet\r |
221 | //\r |
222 | extern BOOLEAN gProcessingFPacket;\r |
223 | \r |
224 | \r |
225 | // The offsets of registers SystemContext.\r |
226 | // The fields in the array are in the gdb ordering.\r |
227 | //\r |
228 | extern UINTN gRegisterOffsets[];\r |
229 | \r |
230 | /**\r |
231 | Return the number of entries in the gExceptionType[]\r |
232 | \r |
233 | @retval UINTN, the number of entries in the gExceptionType[] array. \r |
234 | **/\r |
235 | UINTN\r |
236 | MaxEfiException (\r |
237 | VOID\r |
238 | );\r |
239 | \r |
240 | \r |
241 | /**\r |
242 | Return the number of entries in the gRegisters[]\r |
243 | \r |
244 | @retval UINTN, the number of entries (registers) in the gRegisters[] array. \r |
245 | **/\r |
246 | UINTN\r |
247 | MaxRegisterCount (\r |
248 | VOID\r |
249 | );\r |
250 | \r |
251 | \r |
252 | /**\r |
253 | Check to see if the ISA is supported. \r |
254 | ISA = Instruction Set Architecture\r |
255 | \r |
256 | @retval TRUE if Isa is supported,\r |
257 | FALSE otherwise.\r |
258 | **/\r |
259 | BOOLEAN\r |
260 | CheckIsa (\r |
261 | IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa\r |
262 | );\r |
263 | \r |
264 | \r |
265 | /**\r |
266 | Send the T signal with the given exception type (in gdb order) and possibly with n:r pairs related to the watchpoints\r |
267 | \r |
268 | @param SystemContext Register content at time of the exception\r |
269 | @param GdbExceptionType GDB exception type\r |
270 | **/\r |
271 | \r |
272 | VOID\r |
273 | GdbSendTSignal (\r |
274 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
275 | IN UINT8 GdbExceptionType\r |
276 | );\r |
277 | \r |
278 | \r |
279 | /**\r |
280 | Translates the EFI mapping to GDB mapping\r |
281 | \r |
282 | @param EFIExceptionType EFI Exception that is being processed\r |
283 | @retval UINTN that corresponds to EFIExceptionType's GDB exception type number\r |
284 | **/\r |
285 | UINT8\r |
286 | ConvertEFItoGDBtype ( \r |
287 | IN EFI_EXCEPTION_TYPE EFIExceptionType\r |
288 | );\r |
289 | \r |
290 | \r |
291 | /**\r |
292 | Empties the given buffer \r |
293 | @param *Buf pointer to the first element in buffer to be emptied\r |
294 | **/\r |
295 | VOID\r |
296 | EmptyBuffer ( \r |
297 | IN CHAR8 *Buf\r |
298 | );\r |
299 | \r |
300 | \r |
301 | /**\r |
302 | Converts an 8-bit Hex Char into a INTN.\r |
303 | \r |
304 | @param Char - the hex character to be converted into UINTN\r |
305 | @retval a INTN, from 0 to 15, that corressponds to Char\r |
306 | -1 if Char is not a hex character\r |
307 | **/\r |
308 | INTN\r |
309 | HexCharToInt (\r |
310 | IN CHAR8 Char\r |
311 | );\r |
312 | \r |
313 | \r |
314 | /** 'E NN'\r |
315 | Send an error with the given error number after converting to hex.\r |
316 | The error number is put into the buffer in hex. '255' is the biggest errno we can send.\r |
317 | ex: 162 will be sent as A2.\r |
318 | \r |
319 | @param errno the error number that will be sent\r |
320 | **/\r |
321 | VOID\r |
322 | EFIAPI\r |
323 | SendError (\r |
324 | IN UINT8 ErrorNum\r |
325 | );\r |
326 | \r |
327 | \r |
328 | /**\r |
329 | Send 'OK' when the function is done executing successfully.\r |
330 | **/\r |
331 | VOID\r |
332 | SendSuccess (\r |
333 | VOID\r |
334 | );\r |
335 | \r |
336 | \r |
337 | /**\r |
338 | Send empty packet to specify that particular command/functionality is not supported.\r |
339 | **/\r |
340 | VOID\r |
341 | SendNotSupported (\r |
342 | VOID\r |
343 | );\r |
344 | \r |
345 | /** ‘p n’ \r |
346 | Reads the n-th register's value into an output buffer and sends it as a packet \r |
347 | @param SystemContext Register content at time of the exception\r |
348 | @param InBuffer This is the input buffer received from gdb server\r |
349 | **/\r |
350 | VOID\r |
351 | ReadNthRegister (\r |
352 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
353 | IN CHAR8 *InBuffer\r |
354 | );\r |
355 | \r |
356 | \r |
357 | /** ‘g’ \r |
358 | Reads the general registers into an output buffer and sends it as a packet \r |
359 | @param SystemContext Register content at time of the exception\r |
360 | **/\r |
361 | VOID\r |
362 | ReadGeneralRegisters ( \r |
363 | IN EFI_SYSTEM_CONTEXT SystemContext\r |
364 | );\r |
365 | \r |
366 | \r |
367 | /** ‘P n...=r...’\r |
368 | Writes the new value of n-th register received into the input buffer to the n-th register\r |
369 | @param SystemContext Register content at time of the exception\r |
370 | @param InBuffer This is the input buffer received from gdb server\r |
371 | **/\r |
372 | VOID\r |
373 | WriteNthRegister (\r |
374 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
375 | IN CHAR8 *InBuffer\r |
376 | );\r |
377 | \r |
378 | \r |
379 | /** ‘G XX...’\r |
380 | Writes the new values received into the input buffer to the general registers\r |
381 | @param SystemContext Register content at time of the exception\r |
382 | @param InBuffer Pointer to the input buffer received from gdb server\r |
383 | **/\r |
384 | \r |
385 | VOID\r |
386 | WriteGeneralRegisters (\r |
387 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
388 | IN CHAR8 *InBuffer\r |
389 | );\r |
390 | \r |
391 | \r |
392 | /** ‘m addr,length ’\r |
393 | Find the Length of the area to read and the start addres. Finally, pass them to \r |
394 | another function, TransferFromMemToOutBufAndSend, that will read from that memory space and \r |
395 | send it as a packet.\r |
396 | \r |
397 | @param *PacketData Pointer to Payload data for the packet\r |
398 | **/\r |
399 | VOID\r |
400 | ReadFromMemory (\r |
401 | IN CHAR8 *PacketData\r |
402 | );\r |
403 | \r |
404 | \r |
405 | /** ‘M addr,length :XX...’\r |
406 | Find the Length of the area in bytes to write and the start addres. Finally, pass them to \r |
407 | another function, TransferFromInBufToMem, that will write to that memory space the info in\r |
408 | the input buffer.\r |
409 | \r |
410 | @param PacketData Pointer to Payload data for the packet\r |
411 | **/\r |
412 | VOID\r |
413 | WriteToMemory (\r |
414 | IN CHAR8 *PacketData\r |
415 | );\r |
416 | \r |
417 | \r |
418 | /** ‘c [addr ]’ \r |
419 | Continue. addr is Address to resume. If addr is omitted, resume at current \r |
420 | Address.\r |
421 | \r |
422 | @param SystemContext Register content at time of the exception \r |
423 | @param *PacketData Pointer to PacketData\r |
424 | **/\r |
425 | \r |
426 | VOID\r |
427 | ContinueAtAddress (\r |
428 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
429 | IN CHAR8 *PacketData\r |
430 | );\r |
431 | \r |
432 | \r |
433 | /** ‘s [addr ]’\r |
434 | Single step. addr is the Address at which to resume. If addr is omitted, resume \r |
435 | at same Address.\r |
436 | \r |
437 | @param SystemContext Register content at time of the exception\r |
438 | @param PacketData Pointer to Payload data for the packet\r |
439 | **/\r |
440 | VOID\r |
441 | SingleStep (\r |
442 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
443 | IN CHAR8 *PacketData\r |
444 | );\r |
445 | \r |
446 | /** \r |
447 | Insert Single Step in the SystemContext\r |
448 | \r |
449 | @param SystemContext Register content at time of the exception\r |
450 | **/\r |
451 | VOID\r |
452 | AddSingleStep (\r |
453 | IN EFI_SYSTEM_CONTEXT SystemContext\r |
454 | );\r |
455 | \r |
456 | /** \r |
457 | Remove Single Step in the SystemContext\r |
458 | \r |
459 | @param SystemContext Register content at time of the exception\r |
460 | **/\r |
461 | VOID\r |
462 | RemoveSingleStep (\r |
463 | IN EFI_SYSTEM_CONTEXT SystemContext\r |
464 | );\r |
465 | \r |
466 | \r |
467 | /**\r |
468 | ‘Z1, [addr], [length]’\r |
469 | ‘Z2, [addr], [length]’\r |
470 | ‘Z3, [addr], [length]’\r |
471 | ‘Z4, [addr], [length]’\r |
472 | \r |
473 | Insert hardware breakpoint/watchpoint at address addr of size length\r |
474 | \r |
475 | @param SystemContext Register content at time of the exception\r |
476 | @param *PacketData Pointer to the Payload data for the packet\r |
477 | \r |
478 | **/\r |
479 | VOID\r |
480 | EFIAPI\r |
481 | InsertBreakPoint(\r |
482 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
483 | IN CHAR8 *PacketData\r |
484 | );\r |
485 | \r |
486 | \r |
487 | /**\r |
488 | ‘z1, [addr], [length]’\r |
489 | ‘z2, [addr], [length]’\r |
490 | ‘z3, [addr], [length]’\r |
491 | ‘z4, [addr], [length]’\r |
492 | \r |
493 | Remove hardware breakpoint/watchpoint at address addr of size length\r |
494 | \r |
495 | @param SystemContext Register content at time of the exception\r |
496 | @param *PacketData Pointer to the Payload data for the packet\r |
497 | \r |
498 | **/\r |
499 | VOID\r |
500 | EFIAPI\r |
501 | RemoveBreakPoint(\r |
502 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
503 | IN CHAR8 *PacketData\r |
504 | );\r |
505 | \r |
506 | \r |
507 | /**\r |
508 | Exception Hanldler for GDB. It will be called for all exceptions\r |
509 | registered via the gExceptionType[] array.\r |
510 | \r |
511 | @param ExceptionType Exception that is being processed\r |
512 | @param SystemContext Register content at time of the exception \r |
513 | \r |
514 | **/\r |
515 | VOID\r |
516 | EFIAPI\r |
517 | GdbExceptionHandler ( \r |
518 | IN EFI_EXCEPTION_TYPE ExceptionType, \r |
519 | IN OUT EFI_SYSTEM_CONTEXT SystemContext \r |
520 | );\r |
521 | \r |
522 | \r |
523 | /**\r |
524 | Periodic callback for GDB. This function is used to catch a ctrl-c or other \r |
525 | break in type command from GDB.\r |
526 | \r |
527 | @param SystemContext Register content at time of the call\r |
528 | \r |
529 | **/\r |
530 | VOID\r |
531 | EFIAPI\r |
532 | GdbPeriodicCallBack ( \r |
533 | IN OUT EFI_SYSTEM_CONTEXT SystemContext \r |
534 | );\r |
535 | \r |
536 | \r |
537 | /**\r |
538 | Make two serail consoles: 1) StdIn and StdOut via GDB. 2) StdErr via GDB.\r |
539 | \r |
540 | These console show up on the remote system running GDB\r |
541 | \r |
542 | **/\r |
543 | \r |
544 | VOID\r |
545 | GdbInitializeSerialConsole (\r |
546 | VOID\r |
547 | );\r |
548 | \r |
549 | \r |
550 | /**\r |
551 | Send a GDB Remote Serial Protocol Packet\r |
552 | \r |
553 | $PacketData#checksum PacketData is passed in and this function adds the packet prefix '$', \r |
554 | the packet teminating character '#' and the two digit checksum.\r |
555 | \r |
556 | If an ack '+' is not sent resend the packet, but timeout eventually so we don't end up \r |
557 | in an infinit loop. This is so if you unplug the debugger code just keeps running\r |
558 | \r |
559 | @param PacketData Payload data for the packet \r |
560 | \r |
561 | @retval Number of bytes of packet data sent.\r |
562 | \r |
563 | **/\r |
564 | UINTN\r |
565 | SendPacket (\r |
566 | IN CHAR8 *PacketData\r |
567 | );\r |
568 | \r |
569 | \r |
570 | /**\r |
571 | Receive a GDB Remote Serial Protocol Packet\r |
572 | \r |
573 | $PacketData#checksum PacketData is passed in and this function adds the packet prefix '$', \r |
574 | the packet teminating character '#' and the two digit checksum.\r |
575 | \r |
576 | If host re-starts sending a packet without ending the previous packet, only the last valid packet is proccessed.\r |
577 | (In other words, if received packet is '$12345$12345$123456#checksum', only '$123456#checksum' will be processed.)\r |
578 | \r |
579 | If an ack '+' is not sent resend the packet\r |
580 | \r |
581 | @param PacketData Payload data for the packet \r |
582 | \r |
583 | @retval Number of bytes of packet data received.\r |
584 | \r |
585 | **/\r |
586 | UINTN\r |
587 | ReceivePacket (\r |
588 | OUT CHAR8 *PacketData,\r |
589 | IN UINTN PacketDataSize\r |
590 | );\r |
591 | \r |
592 | \r |
593 | /**\r |
594 | Read data from a FileDescriptor. On success number of bytes read is returned. Zero indicates \r |
595 | the end of a file. On error -1 is returned. If count is zero, GdbRead returns zero.\r |
596 | \r |
597 | @param FileDescriptor Device to talk to.\r |
598 | @param Buffer Buffer to hold Count bytes that were read\r |
599 | @param Count Number of bytes to transfer. \r |
600 | \r |
601 | @retval -1 Error\r |
602 | @retval {other} Number of bytes read.\r |
603 | \r |
604 | **/\r |
605 | INTN\r |
606 | GdbRead (\r |
607 | IN INTN FileDescriptor,\r |
608 | OUT VOID *Buffer,\r |
609 | IN UINTN Count\r |
610 | );\r |
611 | \r |
612 | \r |
613 | /**\r |
614 | Write data to a FileDescriptor. On success number of bytes written is returned. Zero indicates \r |
615 | nothing was written. On error -1 is returned. \r |
616 | \r |
617 | @param FileDescriptor Device to talk to.\r |
618 | @param Buffer Buffer to hold Count bytes that are to be written\r |
619 | @param Count Number of bytes to transfer. \r |
620 | \r |
621 | @retval -1 Error\r |
622 | @retval {other} Number of bytes written.\r |
623 | \r |
624 | **/\r |
625 | INTN\r |
626 | GdbWrite (\r |
627 | IN INTN FileDescriptor,\r |
628 | OUT CONST VOID *Buffer,\r |
629 | IN UINTN Count\r |
630 | );\r |
631 | \r |
632 | UINTN * \r |
633 | FindPointerToRegister (\r |
634 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
635 | IN UINTN RegNumber \r |
636 | );\r |
637 | \r |
638 | CHAR8 * \r |
639 | BasicReadRegister (\r |
640 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
641 | IN UINTN RegNumber,\r |
642 | IN CHAR8 *OutBufPtr\r |
643 | );\r |
644 | \r |
645 | VOID\r |
646 | TransferFromInBufToMem (\r |
647 | IN UINTN Length,\r |
648 | IN UINT8 *Address,\r |
649 | IN CHAR8 *NewData\r |
650 | );\r |
651 | \r |
652 | VOID\r |
653 | TransferFromMemToOutBufAndSend (\r |
654 | IN UINTN Length,\r |
655 | IN UINT8 *Address\r |
656 | );\r |
657 | \r |
658 | CHAR8 *\r |
659 | BasicWriteRegister (\r |
660 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
661 | IN UINTN RegNumber,\r |
662 | IN CHAR8 *InBufPtr\r |
663 | );\r |
664 | \r |
665 | VOID \r |
666 | PrintReg (\r |
667 | EFI_SYSTEM_CONTEXT SystemContext\r |
668 | );\r |
669 | \r |
670 | UINTN\r |
671 | ParseBreakpointPacket (\r |
672 | IN CHAR8 *PacketData,\r |
673 | OUT UINTN *Type,\r |
674 | OUT UINTN *Address,\r |
675 | OUT UINTN *Length\r |
676 | );\r |
677 | \r |
678 | UINTN\r |
679 | GetBreakpointDataAddress (\r |
680 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
681 | IN UINTN BreakpointNumber \r |
682 | );\r |
683 | \r |
684 | UINTN\r |
685 | GetBreakpointDetected (\r |
686 | IN EFI_SYSTEM_CONTEXT SystemContext\r |
687 | );\r |
688 | \r |
689 | BREAK_TYPE\r |
690 | GetBreakpointType (\r |
691 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
692 | IN UINTN BreakpointNumber \r |
693 | );\r |
694 | \r |
695 | UINTN\r |
696 | ConvertLengthData (\r |
697 | IN UINTN Length\r |
698 | );\r |
699 | \r |
700 | EFI_STATUS\r |
701 | FindNextFreeDebugRegister (\r |
702 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
703 | OUT UINTN *Register\r |
704 | );\r |
705 | \r |
706 | EFI_STATUS\r |
707 | EnableDebugRegister (\r |
708 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
709 | IN UINTN Register,\r |
710 | IN UINTN Address,\r |
711 | IN UINTN Length,\r |
712 | IN UINTN Type\r |
713 | );\r |
714 | \r |
715 | EFI_STATUS\r |
716 | FindMatchingDebugRegister (\r |
717 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
718 | IN UINTN Address,\r |
719 | IN UINTN Length,\r |
720 | IN UINTN Type,\r |
721 | OUT UINTN *Register\r |
722 | );\r |
723 | \r |
724 | EFI_STATUS\r |
725 | DisableDebugRegister (\r |
726 | IN EFI_SYSTEM_CONTEXT SystemContext,\r |
727 | IN UINTN Register\r |
728 | );\r |
729 | \r |
730 | VOID\r |
731 | InitializeProcessor (\r |
732 | VOID\r |
733 | );\r |
734 | \r |
735 | BOOLEAN\r |
736 | ValidateAddress (\r |
737 | IN VOID *Address\r |
738 | );\r |
739 | \r |
740 | BOOLEAN\r |
741 | ValidateException (\r |
742 | IN EFI_EXCEPTION_TYPE ExceptionType, \r |
743 | IN OUT EFI_SYSTEM_CONTEXT SystemContext \r |
744 | );\r |
745 | \r |
746 | #endif\r |