\r
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
extern CONST CHAR8 mHexToStr[];\r
\r
// maximum size of input and output buffers\r
-// This value came from the show remote command of the gdb we tested against \r
+// This value came from the show remote command of the gdb we tested against\r
#define MAX_BUF_SIZE 2000\r
\r
// maximum size of address buffer\r
//\r
// GDB Signal definitions - generic names for interrupts\r
//\r
-#define GDB_SIGILL 4 // Illegal instruction \r
+#define GDB_SIGILL 4 // Illegal instruction\r
#define GDB_SIGTRAP 5 // Trace Trap (Breakpoint and SingleStep)\r
#define GDB_SIGEMT 7 // Emulator Trap\r
#define GDB_SIGFPE 8 // Floating point exception\r
// Includes all general GDB Unix like error values\r
//\r
#define GDB_EBADMEMADDRBUFSIZE 11 // the buffer that stores memory Address to be read from/written to is not the right size\r
-#define GDB_EBADMEMLENGBUFSIZE 12 // the buffer that stores Length is not the right size \r
+#define GDB_EBADMEMLENGBUFSIZE 12 // the buffer that stores Length is not the right size\r
#define GDB_EBADMEMLENGTH 13 // Length, the given number of bytes to read or write, is not the right size\r
-#define GDB_EBADMEMDATA 14 // one of the bytes or nibbles of the memory is leess than 0 \r
+#define GDB_EBADMEMDATA 14 // one of the bytes or nibbles of the memory is less than 0\r
#define GDB_EBADMEMDATASIZE 15 // the memory data, 'XX..', is too short or too long\r
#define GDB_EBADBUFSIZE 21 // the buffer created is not the correct size\r
#define GDB_EINVALIDARG 31 // argument is invalid\r
//\r
//Define Register size for different architectures\r
//\r
-#if defined (MDE_CPU_IA32) \r
+#if defined (MDE_CPU_IA32)\r
#define REG_SIZE 32\r
#elif defined (MDE_CPU_X64)\r
#define REG_SIZE 64\r
\r
typedef struct {\r
VENDOR_DEVICE_PATH VendorDevice;\r
- UINT32 Index; // Suport more than one\r
+ UINT32 Index; // Support more than one\r
EFI_DEVICE_PATH_PROTOCOL End;\r
} GDB_SERIAL_DEVICE_PATH;\r
\r
UINT32 B1:1; // Breakpoint condition detected\r
UINT32 B2:1; // Breakpoint condition detected\r
UINT32 B3:1; // Breakpoint condition detected\r
- UINT32 Reserved_1:9; // Reserved \r
+ UINT32 Reserved_1:9; // Reserved\r
UINT32 BD:1; // Debug register access detected\r
UINT32 BS:1; // Single step\r
UINT32 BT:1; // Task switch\r
\r
//\r
// Set TRUE if F Reply package signals a ctrl-c. We can not process the Ctrl-c\r
-// here we need to wait for the periodic callback to do this. \r
+// here we need to wait for the periodic callback to do this.\r
//\r
extern BOOLEAN gCtrlCBreakFlag;\r
\r
//\r
// If the periodic callback is called while we are processing an F packet we need\r
-// to let the callback know to not read from the serail stream as it could steal\r
-// characters from the F reponse packet\r
+// to let the callback know to not read from the serial stream as it could steal\r
+// characters from the F response packet\r
//\r
extern BOOLEAN gProcessingFPacket;\r
\r
\r
/**\r
Return the number of entries in the gExceptionType[]\r
- \r
- @retval UINTN, the number of entries in the gExceptionType[] array. \r
+\r
+ @retval UINTN, the number of entries in the gExceptionType[] array.\r
**/\r
UINTN\r
MaxEfiException (\r
\r
/**\r
Return the number of entries in the gRegisters[]\r
- \r
- @retval UINTN, the number of entries (registers) in the gRegisters[] array. \r
+\r
+ @retval UINTN, the number of entries (registers) in the gRegisters[] array.\r
**/\r
UINTN\r
MaxRegisterCount (\r
\r
\r
/**\r
- Check to see if the ISA is supported. \r
+ Check to see if the ISA is supported.\r
ISA = Instruction Set Architecture\r
- \r
+\r
@retval TRUE if Isa is supported,\r
FALSE otherwise.\r
**/\r
\r
/**\r
Send the T signal with the given exception type (in gdb order) and possibly with n:r pairs related to the watchpoints\r
- \r
+\r
@param SystemContext Register content at time of the exception\r
@param GdbExceptionType GDB exception type\r
**/\r
VOID\r
GdbSendTSignal (\r
IN EFI_SYSTEM_CONTEXT SystemContext,\r
- IN UINT8 GdbExceptionType\r
+ IN UINT8 GdbExceptionType\r
);\r
\r
\r
/**\r
Translates the EFI mapping to GDB mapping\r
- \r
+\r
@param EFIExceptionType EFI Exception that is being processed\r
@retval UINTN that corresponds to EFIExceptionType's GDB exception type number\r
**/\r
UINT8\r
-ConvertEFItoGDBtype ( \r
+ConvertEFItoGDBtype (\r
IN EFI_EXCEPTION_TYPE EFIExceptionType\r
);\r
\r
\r
/**\r
- Empties the given buffer \r
+ Empties the given buffer\r
@param *Buf pointer to the first element in buffer to be emptied\r
**/\r
VOID\r
-EmptyBuffer ( \r
+EmptyBuffer (\r
IN CHAR8 *Buf\r
);\r
\r
\r
/**\r
Converts an 8-bit Hex Char into a INTN.\r
- \r
+\r
@param Char - the hex character to be converted into UINTN\r
- @retval a INTN, from 0 to 15, that corressponds to Char\r
+ @retval a INTN, from 0 to 15, that corresponds to Char\r
-1 if Char is not a hex character\r
**/\r
INTN\r
Send an error with the given error number after converting to hex.\r
The error number is put into the buffer in hex. '255' is the biggest errno we can send.\r
ex: 162 will be sent as A2.\r
- \r
+\r
@param errno the error number that will be sent\r
**/\r
VOID\r
Send 'OK' when the function is done executing successfully.\r
**/\r
VOID\r
+EFIAPI\r
SendSuccess (\r
VOID\r
);\r
Send empty packet to specify that particular command/functionality is not supported.\r
**/\r
VOID\r
+EFIAPI\r
SendNotSupported (\r
VOID\r
);\r
\r
-/** ‘p n’ \r
- Reads the n-th register's value into an output buffer and sends it as a packet \r
+/** ‘p n’\r
+ Reads the n-th register's value into an output buffer and sends it as a packet\r
@param SystemContext Register content at time of the exception\r
@param InBuffer This is the input buffer received from gdb server\r
**/\r
);\r
\r
\r
-/** ‘g’ \r
- Reads the general registers into an output buffer and sends it as a packet \r
+/** ‘g’\r
+ Reads the general registers into an output buffer and sends it as a packet\r
@param SystemContext Register content at time of the exception\r
**/\r
VOID\r
-ReadGeneralRegisters ( \r
+EFIAPI\r
+ReadGeneralRegisters (\r
IN EFI_SYSTEM_CONTEXT SystemContext\r
);\r
\r
@param InBuffer This is the input buffer received from gdb server\r
**/\r
VOID\r
+EFIAPI\r
WriteNthRegister (\r
IN EFI_SYSTEM_CONTEXT SystemContext,\r
IN CHAR8 *InBuffer\r
**/\r
\r
VOID\r
+EFIAPI\r
WriteGeneralRegisters (\r
IN EFI_SYSTEM_CONTEXT SystemContext,\r
IN CHAR8 *InBuffer\r
\r
\r
/** ‘m addr,length ’\r
- Find the Length of the area to read and the start addres. Finally, pass them to \r
- another function, TransferFromMemToOutBufAndSend, that will read from that memory space and \r
+ Find the Length of the area to read and the start address. Finally, pass them to\r
+ another function, TransferFromMemToOutBufAndSend, that will read from that memory space and\r
send it as a packet.\r
- \r
+\r
@param *PacketData Pointer to Payload data for the packet\r
**/\r
VOID\r
+EFIAPI\r
ReadFromMemory (\r
IN CHAR8 *PacketData\r
);\r
\r
\r
/** ‘M addr,length :XX...’\r
- Find the Length of the area in bytes to write and the start addres. Finally, pass them to \r
+ Find the Length of the area in bytes to write and the start address. Finally, pass them to\r
another function, TransferFromInBufToMem, that will write to that memory space the info in\r
the input buffer.\r
- \r
+\r
@param PacketData Pointer to Payload data for the packet\r
**/\r
VOID\r
+EFIAPI\r
WriteToMemory (\r
IN CHAR8 *PacketData\r
);\r
\r
\r
-/** ‘c [addr ]’ \r
- Continue. addr is Address to resume. If addr is omitted, resume at current \r
+/** ‘c [addr ]’\r
+ Continue. addr is Address to resume. If addr is omitted, resume at current\r
Address.\r
- \r
- @param SystemContext Register content at time of the exception \r
+\r
+ @param SystemContext Register content at time of the exception\r
@param *PacketData Pointer to PacketData\r
**/\r
\r
VOID\r
+EFIAPI\r
ContinueAtAddress (\r
IN EFI_SYSTEM_CONTEXT SystemContext,\r
IN CHAR8 *PacketData\r
\r
\r
/** ‘s [addr ]’\r
- Single step. addr is the Address at which to resume. If addr is omitted, resume \r
+ Single step. addr is the Address at which to resume. If addr is omitted, resume\r
at same Address.\r
- \r
+\r
@param SystemContext Register content at time of the exception\r
@param PacketData Pointer to Payload data for the packet\r
**/\r
VOID\r
+EFIAPI\r
SingleStep (\r
IN EFI_SYSTEM_CONTEXT SystemContext,\r
IN CHAR8 *PacketData\r
);\r
\r
-/** \r
+/**\r
Insert Single Step in the SystemContext\r
- \r
+\r
@param SystemContext Register content at time of the exception\r
**/\r
VOID\r
AddSingleStep (\r
IN EFI_SYSTEM_CONTEXT SystemContext\r
);\r
- \r
-/** \r
+\r
+/**\r
Remove Single Step in the SystemContext\r
- \r
+\r
@param SystemContext Register content at time of the exception\r
**/\r
VOID\r
RemoveSingleStep (\r
IN EFI_SYSTEM_CONTEXT SystemContext\r
);\r
- \r
- \r
+\r
+\r
/**\r
‘Z1, [addr], [length]’\r
‘Z2, [addr], [length]’\r
\r
\r
/**\r
- Exception Hanldler for GDB. It will be called for all exceptions\r
+ Exception Handler for GDB. It will be called for all exceptions\r
registered via the gExceptionType[] array.\r
- \r
+\r
@param ExceptionType Exception that is being processed\r
- @param SystemContext Register content at time of the exception \r
- \r
+ @param SystemContext Register content at time of the exception\r
+\r
**/\r
VOID\r
EFIAPI\r
-GdbExceptionHandler ( \r
- IN EFI_EXCEPTION_TYPE ExceptionType, \r
- IN OUT EFI_SYSTEM_CONTEXT SystemContext \r
+GdbExceptionHandler (\r
+ IN EFI_EXCEPTION_TYPE ExceptionType,\r
+ IN OUT EFI_SYSTEM_CONTEXT SystemContext\r
);\r
\r
\r
/**\r
- Periodic callback for GDB. This function is used to catch a ctrl-c or other \r
+ Periodic callback for GDB. This function is used to catch a ctrl-c or other\r
break in type command from GDB.\r
- \r
+\r
@param SystemContext Register content at time of the call\r
- \r
+\r
**/\r
VOID\r
EFIAPI\r
-GdbPeriodicCallBack ( \r
- IN OUT EFI_SYSTEM_CONTEXT SystemContext \r
+GdbPeriodicCallBack (\r
+ IN OUT EFI_SYSTEM_CONTEXT SystemContext\r
);\r
\r
\r
/**\r
- Make two serail consoles: 1) StdIn and StdOut via GDB. 2) StdErr via GDB.\r
- \r
+ Make two serial consoles: 1) StdIn and StdOut via GDB. 2) StdErr via GDB.\r
+\r
These console show up on the remote system running GDB\r
\r
**/\r
\r
/**\r
Send a GDB Remote Serial Protocol Packet\r
- \r
- $PacketData#checksum PacketData is passed in and this function adds the packet prefix '$', \r
- the packet teminating character '#' and the two digit checksum.\r
- \r
- If an ack '+' is not sent resend the packet, but timeout eventually so we don't end up \r
- in an infinit loop. This is so if you unplug the debugger code just keeps running\r
-\r
- @param PacketData Payload data for the packet \r
- \r
+\r
+ $PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',\r
+ the packet terminating character '#' and the two digit checksum.\r
+\r
+ If an ack '+' is not sent resend the packet, but timeout eventually so we don't end up\r
+ in an infinite loop. This is so if you unplug the debugger code just keeps running\r
+\r
+ @param PacketData Payload data for the packet\r
+\r
@retval Number of bytes of packet data sent.\r
\r
**/\r
SendPacket (\r
IN CHAR8 *PacketData\r
);\r
- \r
+\r
\r
/**\r
Receive a GDB Remote Serial Protocol Packet\r
- \r
- $PacketData#checksum PacketData is passed in and this function adds the packet prefix '$', \r
- the packet teminating character '#' and the two digit checksum.\r
- \r
- If host re-starts sending a packet without ending the previous packet, only the last valid packet is proccessed.\r
+\r
+ $PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',\r
+ the packet terminating character '#' and the two digit checksum.\r
+\r
+ If host re-starts sending a packet without ending the previous packet, only the last valid packet is processed.\r
(In other words, if received packet is '$12345$12345$123456#checksum', only '$123456#checksum' will be processed.)\r
- \r
+\r
If an ack '+' is not sent resend the packet\r
- \r
- @param PacketData Payload data for the packet \r
- \r
+\r
+ @param PacketData Payload data for the packet\r
+\r
@retval Number of bytes of packet data received.\r
\r
**/\r
OUT CHAR8 *PacketData,\r
IN UINTN PacketDataSize\r
);\r
- \r
+\r
\r
/**\r
- Read data from a FileDescriptor. On success number of bytes read is returned. Zero indicates \r
+ Read data from a FileDescriptor. On success number of bytes read is returned. Zero indicates\r
the end of a file. On error -1 is returned. If count is zero, GdbRead returns zero.\r
\r
@param FileDescriptor Device to talk to.\r
@param Buffer Buffer to hold Count bytes that were read\r
- @param Count Number of bytes to transfer. \r
+ @param Count Number of bytes to transfer.\r
\r
@retval -1 Error\r
@retval {other} Number of bytes read.\r
OUT VOID *Buffer,\r
IN UINTN Count\r
);\r
- \r
+\r
\r
/**\r
- Write data to a FileDescriptor. On success number of bytes written is returned. Zero indicates \r
- nothing was written. On error -1 is returned. \r
+ Write data to a FileDescriptor. On success number of bytes written is returned. Zero indicates\r
+ nothing was written. On error -1 is returned.\r
\r
@param FileDescriptor Device to talk to.\r
@param Buffer Buffer to hold Count bytes that are to be written\r
- @param Count Number of bytes to transfer. \r
+ @param Count Number of bytes to transfer.\r
\r
@retval -1 Error\r
@retval {other} Number of bytes written.\r
IN UINTN Count\r
);\r
\r
-UINTN * \r
+UINTN *\r
FindPointerToRegister (\r
IN EFI_SYSTEM_CONTEXT SystemContext,\r
- IN UINTN RegNumber \r
+ IN UINTN RegNumber\r
);\r
\r
-CHAR8 * \r
+CHAR8 *\r
BasicReadRegister (\r
IN EFI_SYSTEM_CONTEXT SystemContext,\r
IN UINTN RegNumber,\r
IN CHAR8 *InBufPtr\r
);\r
\r
-VOID \r
+VOID\r
PrintReg (\r
EFI_SYSTEM_CONTEXT SystemContext\r
);\r
UINTN\r
GetBreakpointDataAddress (\r
IN EFI_SYSTEM_CONTEXT SystemContext,\r
- IN UINTN BreakpointNumber \r
+ IN UINTN BreakpointNumber\r
);\r
\r
UINTN\r
BREAK_TYPE\r
GetBreakpointType (\r
IN EFI_SYSTEM_CONTEXT SystemContext,\r
- IN UINTN BreakpointNumber \r
+ IN UINTN BreakpointNumber\r
);\r
\r
UINTN\r
\r
BOOLEAN\r
ValidateException (\r
- IN EFI_EXCEPTION_TYPE ExceptionType, \r
- IN OUT EFI_SYSTEM_CONTEXT SystemContext \r
+ IN EFI_EXCEPTION_TYPE ExceptionType,\r
+ IN OUT EFI_SYSTEM_CONTEXT SystemContext\r
);\r
\r
#endif\r