TianoCore EDK2 master
Loading...
Searching...
No Matches
Processor.c File Reference
#include <GdbStubInternal.h>

Go to the source code of this file.

Functions

VOID PrintReg (IN EFI_SYSTEM_CONTEXT SystemContext)
 
VOID PrintDRreg (IN EFI_SYSTEM_CONTEXT SystemContext)
 
UINTN MaxEfiException (VOID)
 
UINTN MaxRegisterCount (VOID)
 
BOOLEAN CheckIsa (IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa)
 
UINTNFindPointerToRegister (IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber)
 
CHAR8 * BasicReadRegister (IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber, IN CHAR8 *OutBufPtr)
 
VOID EFIAPI ReadNthRegister (IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *InBuffer)
 
VOID EFIAPI ReadGeneralRegisters (IN EFI_SYSTEM_CONTEXT SystemContext)
 
CHAR8 * BasicWriteRegister (IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber, IN CHAR8 *InBufPtr)
 
VOID EFIAPI WriteNthRegister (IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *InBuffer)
 
VOID EFIAPI WriteGeneralRegisters (IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *InBuffer)
 
VOID AddSingleStep (IN EFI_SYSTEM_CONTEXT SystemContext)
 
VOID RemoveSingleStep (IN EFI_SYSTEM_CONTEXT SystemContext)
 
VOID EFIAPI ContinueAtAddress (IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *PacketData)
 
VOID EFIAPI SingleStep (IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *PacketData)
 
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 EFIAPI InsertBreakPoint (IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *PacketData)
 
VOID EFIAPI RemoveBreakPoint (IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *PacketData)
 
VOID InitializeProcessor (VOID)
 
BOOLEAN ValidateAddress (IN VOID *Address)
 
BOOLEAN ValidateException (IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
 

Variables

EFI_EXCEPTION_TYPE_ENTRY gExceptionType []
 
UINTN gRegisterOffsets []
 

Detailed Description

Processor specific parts of the GDB stub

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

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file Processor.c.

Function Documentation

◆ AddSingleStep()

VOID AddSingleStep ( IN EFI_SYSTEM_CONTEXT  SystemContext)

Insert Single Step in the SystemContext

Parameters
SystemContextRegister content at time of the exception

Definition at line 359 of file Processor.c.

◆ BasicReadRegister()

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 158 of file Processor.c.

◆ BasicWriteRegister()

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 241 of file Processor.c.

◆ CheckIsa()

BOOLEAN CheckIsa ( IN EFI_INSTRUCTION_SET_ARCHITECTURE  Isa)

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

Return values
TRUEif Isa is supported, FALSE otherwise.

Definition at line 122 of file Processor.c.

◆ ContinueAtAddress()

VOID EFIAPI 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

Definition at line 387 of file Processor.c.

◆ ConvertLengthData()

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 530 of file Processor.c.

◆ DisableDebugRegister()

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 740 of file Processor.c.

◆ EnableDebugRegister()

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 598 of file Processor.c.

◆ FindMatchingDebugRegister()

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 matching 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 675 of file Processor.c.

◆ FindNextFreeDebugRegister()

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 560 of file Processor.c.

◆ FindPointerToRegister()

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 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

Definition at line 138 of file Processor.c.

◆ GetBreakpointDataAddress()

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 427 of file Processor.c.

◆ GetBreakpointDetected()

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 460 of file Processor.c.

◆ GetBreakpointType()

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.

Definition at line 496 of file Processor.c.

◆ InitializeProcessor()

VOID InitializeProcessor ( VOID  )

Definition at line 951 of file Processor.c.

◆ InsertBreakPoint()

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 795 of file Processor.c.

◆ MaxEfiException()

UINTN MaxEfiException ( VOID  )

Return the number of entries in the gExceptionType[]

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

Definition at line 94 of file Processor.c.

◆ MaxRegisterCount()

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.

◆ PrintDRreg()

VOID PrintDRreg ( IN EFI_SYSTEM_CONTEXT  SystemContext)

Definition at line 76 of file Processor.c.

◆ PrintReg()

VOID PrintReg ( IN EFI_SYSTEM_CONTEXT  SystemContext)

Definition at line 58 of file Processor.c.

◆ ReadGeneralRegisters()

VOID EFIAPI 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

Definition at line 214 of file Processor.c.

◆ ReadNthRegister()

VOID EFIAPI 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
InBufferPointer to the input buffer received from gdb server

Definition at line 184 of file Processor.c.

◆ RemoveBreakPoint()

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
*PacketDataPointer to the Payload data for the packet

Definition at line 879 of file Processor.c.

◆ RemoveSingleStep()

VOID RemoveSingleStep ( IN EFI_SYSTEM_CONTEXT  SystemContext)

Remove Single Step in the SystemContext

Parameters
SystemContextRegister content at time of the exception

Definition at line 372 of file Processor.c.

◆ SingleStep()

VOID EFIAPI 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

Definition at line 405 of file Processor.c.

◆ ValidateAddress()

BOOLEAN ValidateAddress ( IN VOID *  Address)

Definition at line 958 of file Processor.c.

◆ ValidateException()

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

Definition at line 966 of file Processor.c.

◆ WriteGeneralRegisters()

VOID EFIAPI 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

Definition at line 324 of file Processor.c.

◆ WriteNthRegister()

VOID EFIAPI 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
InBufferPointer to the input buffer received from gdb server

Definition at line 285 of file Processor.c.

Variable Documentation

◆ gExceptionType

EFI_EXCEPTION_TYPE_ENTRY gExceptionType[]
Initial value:
= {
{ EXCEPT_IA32_DIVIDE_ERROR, GDB_SIGFPE },
{ EXCEPT_IA32_DEBUG, GDB_SIGTRAP },
{ EXCEPT_IA32_NMI, GDB_SIGEMT },
{ EXCEPT_IA32_BREAKPOINT, GDB_SIGTRAP },
{ EXCEPT_IA32_OVERFLOW, GDB_SIGSEGV },
{ EXCEPT_IA32_BOUND, GDB_SIGSEGV },
{ EXCEPT_IA32_INVALID_OPCODE, GDB_SIGILL },
{ EXCEPT_IA32_DOUBLE_FAULT, GDB_SIGEMT },
{ EXCEPT_IA32_STACK_FAULT, GDB_SIGSEGV },
{ EXCEPT_IA32_GP_FAULT, GDB_SIGSEGV },
{ EXCEPT_IA32_PAGE_FAULT, GDB_SIGSEGV },
{ EXCEPT_IA32_FP_ERROR, GDB_SIGEMT },
{ EXCEPT_IA32_ALIGNMENT_CHECK, GDB_SIGEMT },
{ EXCEPT_IA32_MACHINE_CHECK, GDB_SIGEMT }
}
#define EXCEPT_IA32_DIVIDE_ERROR
Definition: DebugSupport.h:40

Definition at line 16 of file Processor.c.

◆ gRegisterOffsets