EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index
Data Structures | Defines | Enumerations | Functions | Variables

EmbeddedPkg/GdbStub/GdbStubInternal.h File Reference

#include <Uefi.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/PcdLib.h>
#include <Library/GdbSerialLib.h>
#include <Library/PrintLib.h>
#include <Protocol/DebugSupport.h>
#include <Protocol/SerialIo.h>
#include <Protocol/LoadedImage.h>
#include <Guid/DebugImageInfoTable.h>
#include <IndustryStandard/PeImage.h>

Go to the source code of this file.

Data Structures

struct  GDB_SERIAL_DEVICE_PATH
struct  GDB_SERIAL_DEV
struct  EFI_EXCEPTION_TYPE_ENTRY

Defines

#define MAX_BUF_SIZE   2000
#define MAX_ADDR_SIZE   32
#define MAX_REG_NUM_BUF_SIZE   32
#define MAX_LENGTH_SIZE   32
#define MAX_T_SIGNAL_SIZE   64
#define TF_BIT   0x00000100
#define GDB_SIGILL   4
#define GDB_SIGTRAP   5
#define GDB_SIGEMT   7
#define GDB_SIGFPE   8
#define GDB_SIGSEGV   11
#define GDB_EBADMEMADDRBUFSIZE   11
#define GDB_EBADMEMLENGBUFSIZE   12
#define GDB_EBADMEMLENGTH   13
#define GDB_EBADMEMDATA   14
#define GDB_EBADMEMDATASIZE   15
#define GDB_EBADBUFSIZE   21
#define GDB_EINVALIDARG   31
#define GDB_ENOSPACE   41
#define GDB_EINVALIDBRKPOINTTYPE   51
#define GDB_EINVALIDREGNUM   61
#define GDB_EUNKNOWN   255
#define GDB_STDIN   0x00
#define GDB_STDOUT   0x01
#define GDB_STDERR   0x02
#define GDB_SERIAL_DEV_SIGNATURE   SIGNATURE_32 ('g', 'd', 'b', 's')
#define GDB_SERIAL_DEV_FROM_THIS(a)   CR (a, GDB_SERIAL_DEV, SerialIo, GDB_SERIAL_DEV_SIGNATURE)

Enumerations

enum  BREAK_TYPE {
  InstructionExecution, DataWrite, DataRead, DataReadWrite,
  SoftwareBreakpoint, NotSupported, InstructionExecution, DataWrite,
  DataRead, DataReadWrite, SoftwareBreakpoint, NotSupported
}

Functions

UINTN MaxEfiException (VOID)
UINTN MaxRegisterCount (VOID)
BOOLEAN CheckIsa (IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa)
VOID GdbSendTSignal (IN EFI_SYSTEM_CONTEXT SystemContext, IN UINT8 GdbExceptionType)
UINT8 ConvertEFItoGDBtype (IN EFI_EXCEPTION_TYPE EFIExceptionType)
VOID EmptyBuffer (IN CHAR8 *Buf)
INTN HexCharToInt (IN CHAR8 Char)
VOID EFIAPI SendError (IN UINT8 ErrorNum)
VOID SendSuccess (VOID)
VOID SendNotSupported (VOID)
VOID ReadNthRegister (IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *InBuffer)
VOID ReadGeneralRegisters (IN EFI_SYSTEM_CONTEXT SystemContext)
VOID WriteNthRegister (IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *InBuffer)
VOID WriteGeneralRegisters (IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *InBuffer)
VOID ReadFromMemory (IN CHAR8 *PacketData)
VOID WriteToMemory (IN CHAR8 *PacketData)
VOID ContinueAtAddress (IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *PacketData)
VOID SingleStep (IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *PacketData)
VOID AddSingleStep (IN EFI_SYSTEM_CONTEXT SystemContext)
VOID RemoveSingleStep (IN EFI_SYSTEM_CONTEXT SystemContext)
VOID EFIAPI InsertBreakPoint (IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *PacketData)
VOID EFIAPI RemoveBreakPoint (IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *PacketData)
VOID EFIAPI GdbExceptionHandler (IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
VOID EFIAPI GdbPeriodicCallBack (IN OUT EFI_SYSTEM_CONTEXT SystemContext)
VOID GdbInitializeSerialConsole (VOID)
UINTN SendPacket (IN CHAR8 *PacketData)
UINTN ReceivePacket (OUT CHAR8 *PacketData, IN UINTN PacketDataSize)
INTN GdbRead (IN INTN FileDescriptor, OUT VOID *Buffer, IN UINTN Count)
INTN GdbWrite (IN INTN FileDescriptor, OUT CONST VOID *Buffer, IN UINTN Count)
UINTNFindPointerToRegister (IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber)
CHAR8BasicReadRegister (IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber, IN CHAR8 *OutBufPtr)
VOID TransferFromInBufToMem (IN UINTN Length, IN UINT8 *Address, IN CHAR8 *NewData)
VOID TransferFromMemToOutBufAndSend (IN UINTN Length, IN UINT8 *Address)
CHAR8BasicWriteRegister (IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber, IN CHAR8 *InBufPtr)
VOID PrintReg (EFI_SYSTEM_CONTEXT SystemContext)
UINTN ParseBreakpointPacket (IN CHAR8 *PacketData, OUT UINTN *Type, OUT UINTN *Address, OUT UINTN *Length)
UINTN GetBreakpointDataAddress (IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN BreakpointNumber)
UINTN GetBreakpointDetected (IN EFI_SYSTEM_CONTEXT SystemContext)
BREAK_TYPE GetBreakpointType (IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN BreakpointNumber)
UINTN ConvertLengthData (IN UINTN Length)
EFI_STATUS FindNextFreeDebugRegister (IN EFI_SYSTEM_CONTEXT SystemContext, OUT UINTN *Register)
EFI_STATUS EnableDebugRegister (IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN Register, IN UINTN Address, IN UINTN Length, IN UINTN Type)
EFI_STATUS FindMatchingDebugRegister (IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN Address, IN UINTN Length, IN UINTN Type, OUT UINTN *Register)
EFI_STATUS DisableDebugRegister (IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN Register)
VOID InitializeProcessor (VOID)
BOOLEAN ValidateAddress (IN VOID *Address)
BOOLEAN ValidateException (IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)

Variables

CONST CHAR8 mHexToStr []
EFI_EXCEPTION_TYPE_ENTRY gExceptionType []
BOOLEAN gCtrlCBreakFlag
BOOLEAN gProcessingFPacket
UINTN gRegisterOffsets []

Detailed Description

Private include file for GDB stub

Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.

This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file GdbStubInternal.h.


Define Documentation

#define GDB_EBADBUFSIZE   21

Definition at line 78 of file GdbStubInternal.h.

#define GDB_EBADMEMADDRBUFSIZE   11

Definition at line 73 of file GdbStubInternal.h.

#define GDB_EBADMEMDATA   14

Definition at line 76 of file GdbStubInternal.h.

#define GDB_EBADMEMDATASIZE   15

Definition at line 77 of file GdbStubInternal.h.

#define GDB_EBADMEMLENGBUFSIZE   12

Definition at line 74 of file GdbStubInternal.h.

#define GDB_EBADMEMLENGTH   13

Definition at line 75 of file GdbStubInternal.h.

#define GDB_EINVALIDARG   31

Definition at line 79 of file GdbStubInternal.h.

#define GDB_EINVALIDBRKPOINTTYPE   51

Definition at line 81 of file GdbStubInternal.h.

#define GDB_EINVALIDREGNUM   61

Definition at line 82 of file GdbStubInternal.h.

#define GDB_ENOSPACE   41

Definition at line 80 of file GdbStubInternal.h.

#define GDB_EUNKNOWN   255

Definition at line 83 of file GdbStubInternal.h.

#define GDB_SERIAL_DEV_FROM_THIS (   a)    CR (a, GDB_SERIAL_DEV, SerialIo, GDB_SERIAL_DEV_SIGNATURE)

Definition at line 132 of file GdbStubInternal.h.

#define GDB_SERIAL_DEV_SIGNATURE   SIGNATURE_32 ('g', 'd', 'b', 's')

Definition at line 104 of file GdbStubInternal.h.

#define GDB_SIGEMT   7

Definition at line 64 of file GdbStubInternal.h.

#define GDB_SIGFPE   8

Definition at line 65 of file GdbStubInternal.h.

#define GDB_SIGILL   4

Definition at line 62 of file GdbStubInternal.h.

#define GDB_SIGSEGV   11

Definition at line 66 of file GdbStubInternal.h.

#define GDB_SIGTRAP   5

Definition at line 63 of file GdbStubInternal.h.

#define GDB_STDERR   0x02

Definition at line 91 of file GdbStubInternal.h.

#define GDB_STDIN   0x00

Definition at line 89 of file GdbStubInternal.h.

#define GDB_STDOUT   0x01

Definition at line 90 of file GdbStubInternal.h.

#define MAX_ADDR_SIZE   32

Definition at line 44 of file GdbStubInternal.h.

#define MAX_BUF_SIZE   2000

Definition at line 41 of file GdbStubInternal.h.

#define MAX_LENGTH_SIZE   32

Definition at line 50 of file GdbStubInternal.h.

#define MAX_REG_NUM_BUF_SIZE   32

Definition at line 47 of file GdbStubInternal.h.

#define MAX_T_SIGNAL_SIZE   64

Definition at line 53 of file GdbStubInternal.h.

#define TF_BIT   0x00000100

Definition at line 56 of file GdbStubInternal.h.


Enumeration Type Documentation

enum BREAK_TYPE
Enumerator:
InstructionExecution 
DataWrite 
DataRead 
DataReadWrite 
SoftwareBreakpoint 
NotSupported 
InstructionExecution 
DataWrite 
DataRead 
DataReadWrite 
SoftwareBreakpoint 
NotSupported 

Definition at line 197 of file GdbStubInternal.h.


Function Documentation

VOID AddSingleStep ( IN EFI_SYSTEM_CONTEXT  SystemContext)

Insert Single Step in the SystemContext

Parameters:
SystemContextRegister content at time of the exception

Definition at line 404 of file Processor.c.

CHAR8* BasicReadRegister ( IN EFI_SYSTEM_CONTEXT  SystemContext,
IN UINTN  RegNumber,
IN CHAR8 OutBufPtr 
)

Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr

Parameters:
SystemContextRegister content at time of the exception
RegNumberthe number of the register that we want to read
OutBufPtrpointer to the output buffer's end. the new data will be added from this point on.
Return values:
thepointer to the next character of the output buffer that is available to be written on.

Definition at line 163 of file Processor.c.

CHAR8* BasicWriteRegister ( IN EFI_SYSTEM_CONTEXT  SystemContext,
IN UINTN  RegNumber,
IN CHAR8 InBufPtr 
)

Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr

Parameters:
SystemContextRegister content at time of the exception
RegNumberthe number of the register that we want to write
InBufPtrpointer to the output buffer. the new data will be extracted from the input buffer from this point on.
Return values:
thepointer to the next character of the input buffer that can be used

Definition at line 264 of file Processor.c.

Check to see if the ISA is supported. ISA = Instruction Set Architecture

Return values:
TRUEif Isa is supported, FALSE otherwise.

Check to see if the ISA is supported. ISA = Instruction Set Architecture

Return values:
TRUEif Isa is supported

Definition at line 123 of file Processor.c.

VOID ContinueAtAddress ( IN EFI_SYSTEM_CONTEXT  SystemContext,
IN CHAR8 PacketData 
)

‘c [addr ]’ Continue. addr is Address to resume. If addr is omitted, resume at current Address.

Parameters:
SystemContextRegister content at time of the exception
*PacketDataPointer to PacketData

Continue. addr is Address to resume. If addr is omitted, resume at current Address.

Parameters:
SystemContextRegister content at time of the exception

‘c [addr ]’ Continue. addr is Address to resume. If addr is omitted, resume at current Address.

Parameters:
SystemContextRegister content at time of the exception

Definition at line 463 of file Processor.c.

UINT8 ConvertEFItoGDBtype ( IN EFI_EXCEPTION_TYPE  EFIExceptionType)

Translates the EFI mapping to GDB mapping

Parameters:
EFIExceptionTypeEFI Exception that is being processed
Return values:
UINTNthat corresponds to EFIExceptionType's GDB exception type number

Definition at line 595 of file GdbStub.c.

UINTN ConvertLengthData ( IN UINTN  Length)

Parses Length and returns the length which DR7 LENn field accepts. For example: If we receive 1-Byte length then we should return 0. Zero gets written to DR7 LENn field.

Parameters:
LengthBreakpoint length in Bytes (1 byte, 2 byte, 4 byte)
Return values:
LengthAppropriate converted values which DR7 LENn field accepts.

Definition at line 549 of file Processor.c.

EFI_STATUS DisableDebugRegister ( IN EFI_SYSTEM_CONTEXT  SystemContext,
IN UINTN  Register 
)

Disables the particular debug register.

Parameters:
SystemContextRegister content at time of the exception
RegisterRegister to be disabled
Return values:
EFI_STATUSAppropriate status value.

Definition at line 753 of file Processor.c.

VOID EmptyBuffer ( IN CHAR8 Buf)

Empties the given buffer

Parameters:
*Bufpointer to the first element in buffer to be emptied

Empties the given buffer

Parameters:
Bufpointer to the first element in buffer to be emptied

Definition at line 409 of file GdbStub.c.

EFI_STATUS EnableDebugRegister ( IN EFI_SYSTEM_CONTEXT  SystemContext,
IN UINTN  Register,
IN UINTN  Address,
IN UINTN  Length,
IN UINTN  Type 
)

Enables the debug register. Writes Address value to appropriate DR0-3 register. Sets LENn, Gn, RWn bits in DR7 register.

Parameters:
SystemContextRegister content at time of the exception
RegisterRegister value (0 - 3)
AddressBreakpoint address value
TypeBreakpoint type (Instruction, Data write, Data read or write etc.)
Return values:
EFI_STATUSAppropriate status value.

Definition at line 615 of file Processor.c.

EFI_STATUS FindMatchingDebugRegister ( IN EFI_SYSTEM_CONTEXT  SystemContext,
IN UINTN  Address,
IN UINTN  Length,
IN UINTN  Type,
OUT UINTN Register 
)

Returns register number 0 - 3 for the maching debug register. This function compares incoming Address, Type, Length and if there is a match then it returns the appropriate register number. In case of mismatch, function returns EFI_NOT_FOUND message.

Parameters:
SystemContextRegister content at time of the exception
AddressBreakpoint address value
LengthBreakpoint length value
TypeBreakpoint type (Instruction, Data write, Data read or write etc.)
RegisterRegister value to be returned
Return values:
EFI_STATUSAppropriate status value.

Definition at line 692 of file Processor.c.

EFI_STATUS FindNextFreeDebugRegister ( IN EFI_SYSTEM_CONTEXT  SystemContext,
OUT UINTN Register 
)

Finds the next free debug register. If all the registers are occupied then EFI_OUT_OF_RESOURCES is returned.

Parameters:
SystemContextRegister content at time of the exception
RegisterRegister value (0 - 3 for the first free debug register)
Return values:
EFI_STATUSAppropriate status value.

Definition at line 576 of file Processor.c.

UINTN* FindPointerToRegister ( IN EFI_SYSTEM_CONTEXT  SystemContext,
IN UINTN  RegNumber 
)

This takes in the register number and the System Context, and returns a pointer to the RegNumber-th register in gdb ordering It is, by default, set to find the register pointer of the ARM member

Parameters:
SystemContextRegister content at time of the exception
RegNumberThe register to which we want to find a pointer
Return values:
thepointer to the RegNumber-th pointer

This takes in the register number and the System Context, and returns a pointer to the RegNumber-th register in gdb ordering It is, by default, set to find the register pointer of the IA32 member

Parameters:
SystemContextRegister content at time of the exception
RegNumberThe register to which we want to find a pointer
Return values:
thepointer to the RegNumber-th pointer

This takes in the register number and the System Context, and returns a pointer to the RegNumber-th register in gdb ordering It is, by default, set to find the register pointer of the X64 member

Parameters:
SystemContextRegister content at time of the exception
RegNumberThe register to which we want to find a pointer
Return values:
thepointer to the RegNumber-th pointer

Definition at line 143 of file Processor.c.

VOID EFIAPI GdbExceptionHandler ( IN EFI_EXCEPTION_TYPE  ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT  SystemContext 
)

Exception Hanldler for GDB. It will be called for all exceptions registered via the gExceptionType[] array.

Parameters:
ExceptionTypeException that is being processed
SystemContextRegister content at time of the exception

Definition at line 1111 of file GdbStub.c.

VOID GdbInitializeSerialConsole ( VOID  )

Make two serail consoles: 1) StdIn and StdOut via GDB. 2) StdErr via GDB.

These console show up on the remote system running GDB

Make two serial consoles: 1) StdIn and StdOut via GDB. 2) StdErr via GDB.

These console show up on the remote system running GDB

Definition at line 510 of file SerialIo.c.

VOID EFIAPI GdbPeriodicCallBack ( IN OUT EFI_SYSTEM_CONTEXT  SystemContext)

Periodic callback for GDB. This function is used to catch a ctrl-c or other break in type command from GDB.

Parameters:
SystemContextRegister content at time of the call

Definition at line 1220 of file GdbStub.c.

INTN GdbRead ( IN INTN  FileDescriptor,
OUT VOID *  Buffer,
IN UINTN  Count 
)

Read data from a FileDescriptor. On success number of bytes read is returned. Zero indicates the end of a file. On error -1 is returned. If count is zero, GdbRead returns zero.

Parameters:
FileDescriptorDevice to talk to.
BufferBuffer to hold Count bytes that were read
CountNumber of bytes to transfer.
Return values:
-1Error
{other}Number of bytes read.

Definition at line 120 of file SerialIo.c.

VOID GdbSendTSignal ( IN EFI_SYSTEM_CONTEXT  SystemContext,
IN UINT8  GdbExceptionType 
)

Send the T signal with the given exception type (in gdb order) and possibly with n:r pairs related to the watchpoints

Parameters:
SystemContextRegister content at time of the exception
GdbExceptionTypeGDB exception type

Definition at line 501 of file GdbStub.c.

INTN GdbWrite ( IN INTN  FileDescriptor,
OUT CONST VOID *  Buffer,
IN UINTN  Count 
)

Write data to a FileDescriptor. On success number of bytes written is returned. Zero indicates nothing was written. On error -1 is returned.

Parameters:
FileDescriptorDevice to talk to.
BufferBuffer to hold Count bytes that are to be written
CountNumber of bytes to transfer.
Return values:
-1Error
{other}Number of bytes written.

Definition at line 203 of file SerialIo.c.

UINTN GetBreakpointDataAddress ( IN EFI_SYSTEM_CONTEXT  SystemContext,
IN UINTN  BreakpointNumber 
)

Returns breakpoint data address from DR0-DR3 based on the input breakpoint number

Parameters:
SystemContextRegister content at time of the exception
BreakpointNumberBreakpoint number
Return values:
AddressData address from DR0-DR3 based on the breakpoint number.

Definition at line 491 of file Processor.c.

UINTN GetBreakpointDetected ( IN EFI_SYSTEM_CONTEXT  SystemContext)

Returns currently detected breakpoint value based on the register DR6 B0-B3 field. If no breakpoint is detected then it returns 0.

Parameters:
SystemContextRegister content at time of the exception
Return values:
{1-4}Currently detected breakpoint value
0No breakpoint detected.

Definition at line 500 of file Processor.c.

BREAK_TYPE GetBreakpointType ( IN EFI_SYSTEM_CONTEXT  SystemContext,
IN UINTN  BreakpointNumber 
)

Returns Breakpoint type (InstructionExecution, DataWrite, DataRead or DataReadWrite) based on the Breakpoint number

Parameters:
SystemContextRegister content at time of the exception
BreakpointNumberBreakpoint number
Return values:
BREAK_TYPEBreakpoint type value read from register DR7 RWn field For unknown value, it returns NotSupported.

Returns Breakpoint type (InstructionExecution, DataWrite, DataRead or DataReadWrite) based on the Breakpoint number

Parameters:
SystemContextRegister content at time of the exception
BreakpointNumberBreakpoint number
Return values:
BREAK_TYPEBreakpoint type value read from register DR7 RWn field. For unknown value, it returns NotSupported.

Definition at line 508 of file Processor.c.

INTN HexCharToInt ( IN CHAR8  Char)

Converts an 8-bit Hex Char into a INTN.

Parameters:
Char- the hex character to be converted into UINTN
Return values:
aINTN, from 0 to 15, that corressponds to Char -1 if Char is not a hex character

Converts an 8-bit Hex Char into a INTN.

Parameters:
Charthe hex character to be converted into UINTN
Return values:
aINTN, from 0 to 15, that corressponds to Char -1 if Char is not a hex character

Definition at line 425 of file GdbStub.c.

VOID InitializeProcessor ( VOID  )

Definition at line 660 of file Processor.c.

VOID EFIAPI InsertBreakPoint ( IN EFI_SYSTEM_CONTEXT  SystemContext,
IN CHAR8 PacketData 
)

‘Z1, [addr], [length]’ ‘Z2, [addr], [length]’ ‘Z3, [addr], [length]’ ‘Z4, [addr], [length]’

Insert hardware breakpoint/watchpoint at address addr of size length

Parameters:
SystemContextRegister content at time of the exception
*PacketDataPointer to the Payload data for the packet

Definition at line 595 of file Processor.c.

UINTN MaxEfiException ( VOID  )

Return the number of entries in the gExceptionType[]

Return values:
UINTN,thenumber of entries in the gExceptionType[] array.

Definition at line 93 of file Processor.c.

UINTN MaxRegisterCount ( VOID  )

Return the number of entries in the gRegisters[]

Return values:
UINTN,thenumber of entries (registers) in the gRegisters[] array.

Definition at line 107 of file Processor.c.

UINTN ParseBreakpointPacket ( IN CHAR8 PacketData,
OUT UINTN Type,
OUT UINTN Address,
OUT UINTN Length 
)

Parses breakpoint packet data and captures Breakpoint type, Address and length. In case of an error, function returns particular error code. Returning 0 meaning no error.

Parameters:
PacketDataPointer to the payload data for the packet.
TypeBreakpoint type
AddressBreakpoint address
LengthBreakpoint length in Bytes (1 byte, 2 byte, 4 byte)
Return values:
1Success
{other}Particular error code

Definition at line 741 of file GdbStub.c.

VOID PrintReg ( EFI_SYSTEM_CONTEXT  SystemContext)
VOID ReadFromMemory ( IN CHAR8 PacketData)

‘m addr,length ’ Find the Length of the area to read and the start addres. Finally, pass them to another function, TransferFromMemToOutBufAndSend, that will read from that memory space and send it as a packet.

Parameters:
*PacketDataPointer to Payload data for the packet
VOID ReadGeneralRegisters ( IN EFI_SYSTEM_CONTEXT  SystemContext)

‘g’ Reads the general registers into an output buffer and sends it as a packet

Parameters:
SystemContextRegister content at time of the exception

Reads the general registers into an output buffer and sends it as a packet

Parameters:
SystemContextRegister content at time of the exception

Definition at line 234 of file Processor.c.

VOID ReadNthRegister ( IN EFI_SYSTEM_CONTEXT  SystemContext,
IN CHAR8 InBuffer 
)

‘p n’ Reads the n-th register's value into an output buffer and sends it as a packet

Parameters:
SystemContextRegister content at time of the exception
InBufferThis is the input buffer received from gdb server

Reads the n-th register's value into an output buffer and sends it as a packet

Parameters:
SystemContextRegister content at time of the exception
InBufferPointer to the input buffer received from gdb server

‘p n’ Reads the n-th register's value into an output buffer and sends it as a packet

Parameters:
SystemContextRegister content at time of the exception
InBufferPointer to the input buffer received from gdb server

Definition at line 204 of file Processor.c.

UINTN ReceivePacket ( OUT CHAR8 PacketData,
IN UINTN  PacketDataSize 
)

Receive a GDB Remote Serial Protocol Packet

$PacketData::checksum PacketData is passed in and this function adds the packet prefix '$', the packet teminating character '#' and the two digit checksum.

If host re-starts sending a packet without ending the previous packet, only the last valid packet is proccessed. (In other words, if received packet is '$12345$12345$123456#checksum', only '$123456#checksum' will be processed.)

If an ack '+' is not sent resend the packet

Parameters:
PacketDataPayload data for the packet
Return values:
Numberof bytes of packet data received.

Definition at line 344 of file GdbStub.c.

VOID EFIAPI RemoveBreakPoint ( IN EFI_SYSTEM_CONTEXT  SystemContext,
IN CHAR8 PacketData 
)

‘z1, [addr], [length]’ ‘z2, [addr], [length]’ ‘z3, [addr], [length]’ ‘z4, [addr], [length]’

Remove hardware breakpoint/watchpoint at address addr of size length

Parameters:
SystemContextRegister content at time of the exception
*PacketDataPointer to the Payload data for the packet

‘z1, [addr], [length]’ ‘z2, [addr], [length]’ ‘z3, [addr], [length]’ ‘z4, [addr], [length]’

Remove hardware breakpoint/watchpoint at address addr of size length

Parameters:
*PacketDataPointer to the Payload data for the packet

Definition at line 628 of file Processor.c.

VOID RemoveSingleStep ( IN EFI_SYSTEM_CONTEXT  SystemContext)

Remove Single Step in the SystemContext

Parameters:
SystemContextRegister content at time of the exception

Definition at line 435 of file Processor.c.

VOID EFIAPI SendError ( IN UINT8  ErrorNum)

'E NN' Send an error with the given error number after converting to hex. The error number is put into the buffer in hex. '255' is the biggest errno we can send. ex: 162 will be sent as A2.

Parameters:
errnothe error number that will be sent

Definition at line 452 of file GdbStub.c.

VOID SendNotSupported ( VOID  )

Send empty packet to specify that particular command/functionality is not supported.

Definition at line 485 of file GdbStub.c.

UINTN SendPacket ( IN CHAR8 PacketData)

Send a GDB Remote Serial Protocol Packet

$PacketData::checksum PacketData is passed in and this function adds the packet prefix '$', the packet teminating character '#' and the two digit checksum.

If an ack '+' is not sent resend the packet, but timeout eventually so we don't end up in an infinit loop. This is so if you unplug the debugger code just keeps running

Parameters:
PacketDataPayload data for the packet
Return values:
Numberof bytes of packet data sent.

Definition at line 286 of file GdbStub.c.

VOID SendSuccess ( VOID  )

Send 'OK' when the function is done executing successfully.

Definition at line 472 of file GdbStub.c.

VOID SingleStep ( IN EFI_SYSTEM_CONTEXT  SystemContext,
IN CHAR8 PacketData 
)

‘s [addr ]’ Single step. addr is the Address at which to resume. If addr is omitted, resume at same Address.

Parameters:
SystemContextRegister content at time of the exception
PacketDataPointer to Payload data for the packet

‘s [addr ]’ Single step. addr is the Address at which to resume. If addr is omitted, resume at same Address.

Parameters:
SystemContextRegister content at time of the exception

Definition at line 482 of file Processor.c.

VOID TransferFromInBufToMem ( IN UINTN  Length,
IN unsigned char *  Address,
IN CHAR8 NewData 
)

Transfer length bytes of input buffer, starting at Address, to memory.

Parameters:
lengththe number of the bytes to be transferred/written
*addressthe start address of the transferring/writing the memory
*new_datathe new data to be written to memory

Definition at line 196 of file GdbStub.c.

VOID TransferFromMemToOutBufAndSend ( IN UINTN  Length,
IN unsigned char *  Address 
)

Transfer Length bytes of memory starting at Address to an output buffer, OutBuffer. This function will finally send the buffer as a packet.

Parameters:
Lengththe number of the bytes to be transferred/read
*addresspointer to the start address of the transferring/reading the memory

Definition at line 230 of file GdbStub.c.

BOOLEAN ValidateAddress ( IN VOID *  Address)

Definition at line 669 of file Processor.c.

BOOLEAN ValidateException ( IN EFI_EXCEPTION_TYPE  ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT  SystemContext 
)

Definition at line 681 of file Processor.c.

VOID WriteGeneralRegisters ( IN EFI_SYSTEM_CONTEXT  SystemContext,
IN CHAR8 InBuffer 
)

‘G XX...’ Writes the new values received into the input buffer to the general registers

Parameters:
SystemContextRegister content at time of the exception
InBufferPointer to the input buffer received from gdb server

pointer to the input buffer

pointer to the input buffer

pointer to the input buffer

pointer to the input buffer

pointer to the input buffer

pointer to the input buffer

Definition at line 348 of file Processor.c.

VOID WriteNthRegister ( IN EFI_SYSTEM_CONTEXT  SystemContext,
IN CHAR8 InBuffer 
)

‘P n...=r...’ Writes the new value of n-th register received into the input buffer to the n-th register

Parameters:
SystemContextRegister content at time of the exception
InBufferThis is the input buffer received from gdb server

‘P n...=r...’ Writes the new value of n-th register received into the input buffer to the n-th register

Parameters:
SystemContextRegister content at time of the exception
InBufferPonter to the input buffer received from gdb server

Definition at line 310 of file Processor.c.

VOID WriteToMemory ( IN CHAR8 PacketData)

‘M addr,length :XX...’ Find the Length of the area in bytes to write and the start addres. Finally, pass them to another function, TransferFromInBufToMem, that will write to that memory space the info in the input buffer.

Parameters:
PacketDataPointer to Payload data for the packet

"M addr,length :XX..." Find the Length of the area in bytes to write and the start addres. Finally, pass them to another function, TransferFromInBufToMem, that will write to that memory space the info in the input buffer.

pointer to the input buffer

pointer to the input buffer

Definition at line 665 of file GdbStub.c.


Variable Documentation

Definition at line 27 of file SerialIo.c.

Definition at line 24 of file Processor.c.

Definition at line 34 of file SerialIo.c.

Definition at line 37 of file Processor.c.

CONST CHAR8 mHexToStr[]

Definition at line 47 of file GdbStub.c.

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines