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