ARM Packages: Removed trailing spaces
Trailing spaces create issue/warning when generating/applying patches. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ronald Cron <ronald.cron@arm.com> Reviewed-By: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15833 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
committed by
oliviermartin
parent
62d441fb17
commit
3402aac7d9
@@ -1,4 +1,4 @@
|
||||
#------------------------------------------------------------------------------
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Use ARMv6 instruction to operate on a single stack
|
||||
#
|
||||
@@ -19,7 +19,7 @@
|
||||
This is the stack constructed by the exception handler (low address to high address)
|
||||
# R0 - IFAR is EFI_SYSTEM_CONTEXT for ARM
|
||||
Reg Offset
|
||||
=== ======
|
||||
=== ======
|
||||
R0 0x00 # stmfd SP!,{R0-R12}
|
||||
R1 0x04
|
||||
R2 0x08
|
||||
@@ -41,14 +41,14 @@ This is the stack constructed by the exception handler (low address to high addr
|
||||
DFAR 0x48
|
||||
IFSR 0x4c
|
||||
IFAR 0x50
|
||||
|
||||
|
||||
LR 0x54 # SVC Link register (we need to restore it)
|
||||
|
||||
LR 0x58 # pushed by srsfd
|
||||
CPSR 0x5c
|
||||
|
||||
LR 0x58 # pushed by srsfd
|
||||
CPSR 0x5c
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
GCC_ASM_EXPORT(ExceptionHandlersStart)
|
||||
GCC_ASM_EXPORT(ExceptionHandlersEnd)
|
||||
@@ -175,55 +175,55 @@ ASM_PFX(CommonExceptionEntry):
|
||||
ASM_PFX(ExceptionHandlersEnd):
|
||||
|
||||
//
|
||||
// This code runs from CpuDxe driver loaded address. It is patched into
|
||||
// This code runs from CpuDxe driver loaded address. It is patched into
|
||||
// CommonExceptionEntry.
|
||||
//
|
||||
ASM_PFX(AsmCommonExceptionEntry):
|
||||
mrc p15, 0, R1, c6, c0, 2 @ Read IFAR
|
||||
str R1, [SP, #0x50] @ Store it in EFI_SYSTEM_CONTEXT_ARM.IFAR
|
||||
|
||||
str R1, [SP, #0x50] @ Store it in EFI_SYSTEM_CONTEXT_ARM.IFAR
|
||||
|
||||
mrc p15, 0, R1, c5, c0, 1 @ Read IFSR
|
||||
str R1, [SP, #0x4c] @ Store it in EFI_SYSTEM_CONTEXT_ARM.IFSR
|
||||
|
||||
|
||||
mrc p15, 0, R1, c6, c0, 0 @ Read DFAR
|
||||
str R1, [SP, #0x48] @ Store it in EFI_SYSTEM_CONTEXT_ARM.DFAR
|
||||
|
||||
|
||||
mrc p15, 0, R1, c5, c0, 0 @ Read DFSR
|
||||
str R1, [SP, #0x44] @ Store it in EFI_SYSTEM_CONTEXT_ARM.DFSR
|
||||
|
||||
ldr R1, [SP, #0x5c] @ srsdb saved pre-exception CPSR on the stack
|
||||
|
||||
ldr R1, [SP, #0x5c] @ srsdb saved pre-exception CPSR on the stack
|
||||
str R1, [SP, #0x40] @ Store it in EFI_SYSTEM_CONTEXT_ARM.CPSR
|
||||
|
||||
add R2, SP, #0x38 @ Make R2 point to EFI_SYSTEM_CONTEXT_ARM.LR
|
||||
and R3, R1, #0x1f @ Check CPSR to see if User or System Mode
|
||||
cmp R3, #0x1f @ if ((CPSR == 0x10) || (CPSR == 0x1df))
|
||||
cmpne R3, #0x10 @
|
||||
cmpne R3, #0x10 @
|
||||
stmeqed R2, {lr}^ @ save unbanked lr
|
||||
@ else
|
||||
@ else
|
||||
stmneed R2, {lr} @ save SVC lr
|
||||
|
||||
|
||||
ldr R5, [SP, #0x58] @ PC is the LR pushed by srsfd
|
||||
ldr R5, [SP, #0x58] @ PC is the LR pushed by srsfd
|
||||
@ Check to see if we have to adjust for Thumb entry
|
||||
sub r4, r0, #1 @ if (ExceptionType == 1 || ExceptionType ==2)) {
|
||||
cmp r4, #1 @ // UND & SVC have differnt LR adjust for Thumb
|
||||
cmp r4, #1 @ // UND & SVC have differnt LR adjust for Thumb
|
||||
bhi NoAdjustNeeded
|
||||
|
||||
tst r1, #0x20 @ if ((CPSR & T)) == T) { // Thumb Mode on entry
|
||||
|
||||
tst r1, #0x20 @ if ((CPSR & T)) == T) { // Thumb Mode on entry
|
||||
addne R5, R5, #2 @ PC += 2@
|
||||
str R5,[SP,#0x58] @ Update LR value pused by srsfd
|
||||
|
||||
str R5,[SP,#0x58] @ Update LR value pused by srsfd
|
||||
|
||||
NoAdjustNeeded:
|
||||
|
||||
str R5, [SP, #0x3c] @ Store it in EFI_SYSTEM_CONTEXT_ARM.PC
|
||||
|
||||
sub R1, SP, #0x60 @ We pused 0x60 bytes on the stack
|
||||
str R1, [SP, #0x34] @ Store it in EFI_SYSTEM_CONTEXT_ARM.SP
|
||||
|
||||
@ R0 is ExceptionType
|
||||
mov R1,SP @ R1 is SystemContext
|
||||
|
||||
/*
|
||||
sub R1, SP, #0x60 @ We pused 0x60 bytes on the stack
|
||||
str R1, [SP, #0x34] @ Store it in EFI_SYSTEM_CONTEXT_ARM.SP
|
||||
|
||||
@ R0 is ExceptionType
|
||||
mov R1,SP @ R1 is SystemContext
|
||||
|
||||
/*
|
||||
VOID
|
||||
EFIAPI
|
||||
GdbExceptionHandler (
|
||||
@@ -231,28 +231,28 @@ GdbExceptionHandler (
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext R1
|
||||
)
|
||||
|
||||
*/
|
||||
*/
|
||||
blx ASM_PFX(GdbExceptionHandler) @ Call exception handler
|
||||
|
||||
|
||||
ldr R1,[SP,#0x3c] @ EFI_SYSTEM_CONTEXT_ARM.PC
|
||||
str R1,[SP,#0x58] @ Store it back to srsfd stack slot so it can be restored
|
||||
str R1,[SP,#0x58] @ Store it back to srsfd stack slot so it can be restored
|
||||
|
||||
ldr R1,[SP,#0x40] @ EFI_SYSTEM_CONTEXT_ARM.CPSR
|
||||
str R1,[SP,#0x5c] @ Store it back to srsfd stack slot so it can be restored
|
||||
|
||||
str R1,[SP,#0x5c] @ Store it back to srsfd stack slot so it can be restored
|
||||
|
||||
add R3, SP, #0x54 @ Make R3 point to SVC LR saved on entry
|
||||
add R2, SP, #0x38 @ Make R2 point to EFI_SYSTEM_CONTEXT_ARM.LR
|
||||
and R1, R1, #0x1f @ Check to see if User or System Mode
|
||||
cmp R1, #0x1f @ if ((CPSR == 0x10) || (CPSR == 0x1f))
|
||||
cmpne R1, #0x10 @
|
||||
cmpne R1, #0x10 @
|
||||
ldmeqed R2, {lr}^ @ restore unbanked lr
|
||||
@ else
|
||||
ldmneed R3, {lr} @ restore SVC lr, via ldmfd SP!, {LR}
|
||||
|
||||
|
||||
ldmfd SP!,{R0-R12} @ Restore general purpose registers
|
||||
@ Exception handler can not change SP
|
||||
|
||||
|
||||
add SP,SP,#0x20 @ Clear out the remaining stack space
|
||||
ldmfd SP!,{LR} @ restore the link register for this context
|
||||
rfefd SP! @ return from exception via srsfd stack slot
|
||||
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Use ARMv6 instruction to operate on a single stack
|
||||
//
|
||||
@@ -21,7 +21,7 @@
|
||||
This is the stack constructed by the exception handler (low address to high address)
|
||||
# R0 - IFAR is EFI_SYSTEM_CONTEXT for ARM
|
||||
Reg Offset
|
||||
=== ======
|
||||
=== ======
|
||||
R0 0x00 # stmfd SP!,{R0-R12}
|
||||
R1 0x04
|
||||
R2 0x08
|
||||
@@ -43,15 +43,15 @@ This is the stack constructed by the exception handler (low address to high addr
|
||||
DFAR 0x48
|
||||
IFSR 0x4c
|
||||
IFAR 0x50
|
||||
|
||||
|
||||
LR 0x54 # SVC Link register (we need to restore it)
|
||||
|
||||
LR 0x58 # pushed by srsfd
|
||||
CPSR 0x5c
|
||||
|
||||
LR 0x58 # pushed by srsfd
|
||||
CPSR 0x5c
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
EXPORT ExceptionHandlersStart
|
||||
EXPORT ExceptionHandlersEnd
|
||||
EXPORT CommonExceptionEntry
|
||||
@@ -60,7 +60,7 @@ This is the stack constructed by the exception handler (low address to high addr
|
||||
|
||||
PRESERVE8
|
||||
AREA DxeExceptionHandlers, CODE, READONLY
|
||||
|
||||
|
||||
//
|
||||
// This code gets copied to the ARM vector table
|
||||
// ExceptionHandlersStart - ExceptionHandlersEnd gets copied
|
||||
@@ -101,7 +101,7 @@ UndefinedInstructionEntry
|
||||
stmfd SP!,{R0-R12} ; Store the register state
|
||||
|
||||
mov R0,#1 ; ExceptionType
|
||||
ldr R1,CommonExceptionEntry;
|
||||
ldr R1,CommonExceptionEntry;
|
||||
bx R1
|
||||
|
||||
SoftwareInterruptEntry
|
||||
@@ -173,55 +173,55 @@ CommonExceptionEntry
|
||||
ExceptionHandlersEnd
|
||||
|
||||
//
|
||||
// This code runs from CpuDxe driver loaded address. It is patched into
|
||||
// This code runs from CpuDxe driver loaded address. It is patched into
|
||||
// CommonExceptionEntry.
|
||||
//
|
||||
AsmCommonExceptionEntry
|
||||
mrc p15, 0, R1, c6, c0, 2 ; Read IFAR
|
||||
str R1, [SP, #0x50] ; Store it in EFI_SYSTEM_CONTEXT_ARM.IFAR
|
||||
|
||||
str R1, [SP, #0x50] ; Store it in EFI_SYSTEM_CONTEXT_ARM.IFAR
|
||||
|
||||
mrc p15, 0, R1, c5, c0, 1 ; Read IFSR
|
||||
str R1, [SP, #0x4c] ; Store it in EFI_SYSTEM_CONTEXT_ARM.IFSR
|
||||
|
||||
|
||||
mrc p15, 0, R1, c6, c0, 0 ; Read DFAR
|
||||
str R1, [SP, #0x48] ; Store it in EFI_SYSTEM_CONTEXT_ARM.DFAR
|
||||
|
||||
|
||||
mrc p15, 0, R1, c5, c0, 0 ; Read DFSR
|
||||
str R1, [SP, #0x44] ; Store it in EFI_SYSTEM_CONTEXT_ARM.DFSR
|
||||
|
||||
ldr R1, [SP, #0x5c] ; srsfd saved pre-exception CPSR on the stack
|
||||
|
||||
ldr R1, [SP, #0x5c] ; srsfd saved pre-exception CPSR on the stack
|
||||
str R1, [SP, #0x40] ; Store it in EFI_SYSTEM_CONTEXT_ARM.CPSR
|
||||
|
||||
add R2, SP, #0x38 ; Make R2 point to EFI_SYSTEM_CONTEXT_ARM.LR
|
||||
and R3, R1, #0x1f ; Check CPSR to see if User or System Mode
|
||||
cmp R3, #0x1f ; if ((CPSR == 0x10) || (CPSR == 0x1df))
|
||||
cmpne R3, #0x10 ;
|
||||
cmpne R3, #0x10 ;
|
||||
stmeqed R2, {lr}^ ; save unbanked lr
|
||||
; else
|
||||
; else
|
||||
stmneed R2, {lr} ; save SVC lr
|
||||
|
||||
|
||||
ldr R5, [SP, #0x58] ; PC is the LR pushed by srsfd
|
||||
ldr R5, [SP, #0x58] ; PC is the LR pushed by srsfd
|
||||
; Check to see if we have to adjust for Thumb entry
|
||||
sub r4, r0, #1 ; if (ExceptionType == 1 || ExceptionType ==2)) {
|
||||
cmp r4, #1 ; // UND & SVC have differnt LR adjust for Thumb
|
||||
cmp r4, #1 ; // UND & SVC have differnt LR adjust for Thumb
|
||||
bhi NoAdjustNeeded
|
||||
|
||||
tst r1, #0x20 ; if ((CPSR & T)) == T) { // Thumb Mode on entry
|
||||
|
||||
tst r1, #0x20 ; if ((CPSR & T)) == T) { // Thumb Mode on entry
|
||||
addne R5, R5, #2 ; PC += 2;
|
||||
str R5,[SP,#0x58] ; Update LR value pused by srsfd
|
||||
|
||||
str R5,[SP,#0x58] ; Update LR value pused by srsfd
|
||||
|
||||
NoAdjustNeeded
|
||||
|
||||
str R5, [SP, #0x3c] ; Store it in EFI_SYSTEM_CONTEXT_ARM.PC
|
||||
|
||||
sub R1, SP, #0x60 ; We pused 0x60 bytes on the stack
|
||||
str R1, [SP, #0x34] ; Store it in EFI_SYSTEM_CONTEXT_ARM.SP
|
||||
|
||||
; R0 is ExceptionType
|
||||
mov R1,SP ; R1 is SystemContext
|
||||
|
||||
/*
|
||||
sub R1, SP, #0x60 ; We pused 0x60 bytes on the stack
|
||||
str R1, [SP, #0x34] ; Store it in EFI_SYSTEM_CONTEXT_ARM.SP
|
||||
|
||||
; R0 is ExceptionType
|
||||
mov R1,SP ; R1 is SystemContext
|
||||
|
||||
/*
|
||||
VOID
|
||||
EFIAPI
|
||||
GdbExceptionHandler (
|
||||
@@ -231,29 +231,29 @@ GdbExceptionHandler (
|
||||
|
||||
*/
|
||||
blx GdbExceptionHandler ; Call exception handler
|
||||
|
||||
|
||||
ldr R1,[SP,#0x3c] ; EFI_SYSTEM_CONTEXT_ARM.PC
|
||||
str R1,[SP,#0x58] ; Store it back to srsfd stack slot so it can be restored
|
||||
str R1,[SP,#0x58] ; Store it back to srsfd stack slot so it can be restored
|
||||
|
||||
ldr R1,[SP,#0x40] ; EFI_SYSTEM_CONTEXT_ARM.CPSR
|
||||
str R1,[SP,#0x5c] ; Store it back to srsfd stack slot so it can be restored
|
||||
|
||||
str R1,[SP,#0x5c] ; Store it back to srsfd stack slot so it can be restored
|
||||
|
||||
add R3, SP, #0x54 ; Make R3 point to SVC LR saved on entry
|
||||
add R2, SP, #0x38 ; Make R2 point to EFI_SYSTEM_CONTEXT_ARM.LR
|
||||
and R1, R1, #0x1f ; Check to see if User or System Mode
|
||||
cmp R1, #0x1f ; if ((CPSR == 0x10) || (CPSR == 0x1f))
|
||||
cmpne R1, #0x10 ;
|
||||
cmpne R1, #0x10 ;
|
||||
ldmeqed R2, {lr}^ ; restore unbanked lr
|
||||
; else
|
||||
ldmneed R3, {lr} ; restore SVC lr, via ldmfd SP!, {LR}
|
||||
|
||||
|
||||
ldmfd SP!,{R0-R12} ; Restore general purpose registers
|
||||
; Exception handler can not change SP
|
||||
|
||||
|
||||
add SP,SP,#0x20 ; Clear out the remaining stack space
|
||||
ldmfd SP!,{LR} ; restore the link register for this context
|
||||
rfefd SP! ; return from exception via srsfd stack slot
|
||||
|
||||
|
||||
END
|
||||
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
Processor specific parts of the GDB stub
|
||||
|
||||
Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
|
||||
|
||||
|
||||
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
|
||||
@@ -48,8 +48,8 @@ AsmCommonExceptionEntry (
|
||||
//
|
||||
EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
|
||||
{ EXCEPT_ARM_SOFTWARE_INTERRUPT, GDB_SIGTRAP },
|
||||
{ EXCEPT_ARM_UNDEFINED_INSTRUCTION, GDB_SIGTRAP },
|
||||
{ EXCEPT_ARM_PREFETCH_ABORT, GDB_SIGTRAP },
|
||||
{ EXCEPT_ARM_UNDEFINED_INSTRUCTION, GDB_SIGTRAP },
|
||||
{ EXCEPT_ARM_PREFETCH_ABORT, GDB_SIGTRAP },
|
||||
{ EXCEPT_ARM_DATA_ABORT, GDB_SIGTRAP }, // GDB_SIGEMT
|
||||
{ EXCEPT_ARM_RESERVED, GDB_SIGTRAP }, // GDB_SIGILL
|
||||
{ EXCEPT_ARM_FIQ, GDB_SIGINT } // Used for ctrl-c
|
||||
@@ -113,8 +113,8 @@ UINTN gRegisterOffsets[] = {
|
||||
|
||||
/**
|
||||
Return the number of entries in the gExceptionType[]
|
||||
|
||||
@retval UINTN, the number of entries in the gExceptionType[] array.
|
||||
|
||||
@retval UINTN, the number of entries in the gExceptionType[] array.
|
||||
**/
|
||||
UINTN
|
||||
MaxEfiException (
|
||||
@@ -128,10 +128,10 @@ MaxEfiException (
|
||||
|
||||
|
||||
/**
|
||||
Check to see if the ISA is supported.
|
||||
Check to see if the ISA is supported.
|
||||
ISA = Instruction Set Architecture
|
||||
|
||||
@retval TRUE if Isa is supported
|
||||
@retval TRUE if Isa is supported
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
@@ -150,14 +150,14 @@ CheckIsa (
|
||||
/**
|
||||
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
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param RegNumber The register to which we want to find a pointer
|
||||
@retval the pointer to the RegNumber-th pointer
|
||||
**/
|
||||
**/
|
||||
UINTN *
|
||||
FindPointerToRegister(
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext,
|
||||
IN UINTN RegNumber
|
||||
IN UINTN RegNumber
|
||||
)
|
||||
{
|
||||
UINT8 *TempPtr;
|
||||
@@ -183,7 +183,7 @@ BasicReadRegister (
|
||||
{
|
||||
UINTN RegSize;
|
||||
CHAR8 Char;
|
||||
|
||||
|
||||
if (gRegisterOffsets[RegNumber] > 0xF00) {
|
||||
AsciiSPrint(OutBufPtr, 9, "00000000");
|
||||
OutBufPtr += 8;
|
||||
@@ -197,13 +197,13 @@ BasicReadRegister (
|
||||
Char = Char - 'A' + 'a';
|
||||
}
|
||||
*OutBufPtr++ = Char;
|
||||
|
||||
|
||||
Char = mHexToStr[(UINT8)((*FindPointerToRegister(SystemContext, RegNumber) >> RegSize) & 0xf)];
|
||||
if ((Char >= 'A') && (Char <= 'F')) {
|
||||
Char = Char - 'A' + 'a';
|
||||
}
|
||||
*OutBufPtr++ = Char;
|
||||
|
||||
|
||||
RegSize = RegSize + 8;
|
||||
}
|
||||
return OutBufPtr;
|
||||
@@ -211,7 +211,7 @@ BasicReadRegister (
|
||||
|
||||
|
||||
/**
|
||||
Reads the n-th register's value into an output buffer and sends it as a packet
|
||||
Reads the n-th register's value into an output buffer and sends it as a packet
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param InBuffer Pointer to the input buffer received from gdb server
|
||||
**/
|
||||
@@ -224,29 +224,29 @@ ReadNthRegister (
|
||||
UINTN RegNumber;
|
||||
CHAR8 OutBuffer[9]; // 1 reg=8 hex chars, and the end '\0' (escape seq)
|
||||
CHAR8 *OutBufPtr; // pointer to the output buffer
|
||||
|
||||
|
||||
RegNumber = AsciiStrHexToUintn (&InBuffer[1]);
|
||||
|
||||
|
||||
if (RegNumber >= (sizeof (gRegisterOffsets)/sizeof (UINTN))) {
|
||||
SendError (GDB_EINVALIDREGNUM);
|
||||
SendError (GDB_EINVALIDREGNUM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
OutBufPtr = OutBuffer;
|
||||
OutBufPtr = BasicReadRegister (SystemContext, RegNumber, OutBufPtr);
|
||||
|
||||
|
||||
*OutBufPtr = '\0'; // the end of the buffer
|
||||
SendPacket(OutBuffer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Reads the general registers into an output buffer and sends it as a packet
|
||||
Reads the general registers into an output buffer and sends it as a packet
|
||||
@param SystemContext Register content at time of the exception
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
ReadGeneralRegisters (
|
||||
ReadGeneralRegisters (
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||
)
|
||||
{
|
||||
@@ -254,13 +254,13 @@ ReadGeneralRegisters (
|
||||
// a UINT32 takes 8 ascii characters
|
||||
CHAR8 OutBuffer[(sizeof (gRegisterOffsets) * 2) + 1];
|
||||
CHAR8 *OutBufPtr;
|
||||
|
||||
|
||||
// It is not safe to allocate pool here....
|
||||
OutBufPtr = OutBuffer;
|
||||
for (Index = 0; Index < (sizeof (gRegisterOffsets)/sizeof (UINTN)); Index++) {
|
||||
OutBufPtr = BasicReadRegister (SystemContext, Index, OutBufPtr);
|
||||
}
|
||||
|
||||
|
||||
*OutBufPtr = '\0';
|
||||
SendPacket(OutBuffer);
|
||||
}
|
||||
@@ -283,7 +283,7 @@ BasicWriteRegister (
|
||||
UINTN RegSize;
|
||||
UINTN TempValue; // the value transferred from a hex char
|
||||
UINT32 NewValue; // the new value of the RegNumber-th Register
|
||||
|
||||
|
||||
if (gRegisterOffsets[RegNumber] > 0xF00) {
|
||||
return InBufPtr + 8;
|
||||
}
|
||||
@@ -292,21 +292,21 @@ BasicWriteRegister (
|
||||
RegSize = 0;
|
||||
while (RegSize < 32) {
|
||||
TempValue = HexCharToInt(*InBufPtr++);
|
||||
|
||||
|
||||
if ((INTN)TempValue < 0) {
|
||||
SendError (GDB_EBADMEMDATA);
|
||||
SendError (GDB_EBADMEMDATA);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
NewValue += (TempValue << (RegSize+4));
|
||||
TempValue = HexCharToInt(*InBufPtr++);
|
||||
|
||||
|
||||
if ((INTN)TempValue < 0) {
|
||||
SendError (GDB_EBADMEMDATA);
|
||||
SendError (GDB_EBADMEMDATA);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NewValue += (TempValue << RegSize);
|
||||
|
||||
NewValue += (TempValue << RegSize);
|
||||
RegSize = RegSize + 8;
|
||||
}
|
||||
*(FindPointerToRegister(SystemContext, RegNumber)) = NewValue;
|
||||
@@ -329,19 +329,19 @@ WriteNthRegister (
|
||||
CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE]; // put the 'n..' part of the message into this array
|
||||
CHAR8 *RegNumBufPtr;
|
||||
CHAR8 *InBufPtr; // pointer to the input buffer
|
||||
|
||||
|
||||
// find the register number to write
|
||||
InBufPtr = &InBuffer[1];
|
||||
RegNumBufPtr = RegNumBuffer;
|
||||
while (*InBufPtr != '=') {
|
||||
*RegNumBufPtr++ = *InBufPtr++;
|
||||
}
|
||||
}
|
||||
*RegNumBufPtr = '\0';
|
||||
RegNumber = AsciiStrHexToUintn (RegNumBuffer);
|
||||
|
||||
RegNumber = AsciiStrHexToUintn (RegNumBuffer);
|
||||
|
||||
// check if this is a valid Register Number
|
||||
if (RegNumber >= (sizeof (gRegisterOffsets)/sizeof (UINTN))) {
|
||||
SendError (GDB_EINVALIDREGNUM);
|
||||
SendError (GDB_EINVALIDREGNUM);
|
||||
return;
|
||||
}
|
||||
InBufPtr++; // skips the '=' character
|
||||
@@ -369,21 +369,21 @@ WriteGeneralRegisters (
|
||||
UINTN RegisterCount = (sizeof (gRegisterOffsets)/sizeof (UINTN));
|
||||
|
||||
MinLength = (RegisterCount * 8) + 1; // 'G' plus the registers in ASCII format
|
||||
|
||||
|
||||
if (AsciiStrLen(InBuffer) < MinLength) {
|
||||
//Bad message. Message is not the right length
|
||||
SendError (GDB_EBADBUFSIZE);
|
||||
//Bad message. Message is not the right length
|
||||
SendError (GDB_EBADBUFSIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
InBufPtr = &InBuffer[1];
|
||||
|
||||
|
||||
// Read the new values for the registers from the input buffer to an array, NewValueArray.
|
||||
// The values in the array are in the gdb ordering
|
||||
for(i = 0; i < RegisterCount; i++) {
|
||||
InBufPtr = BasicWriteRegister (SystemContext, i, InBufPtr);
|
||||
}
|
||||
|
||||
|
||||
SendSuccess ();
|
||||
}
|
||||
|
||||
@@ -391,10 +391,10 @@ WriteGeneralRegisters (
|
||||
|
||||
|
||||
/**
|
||||
Continue. addr is Address to resume. If addr is omitted, resume at current
|
||||
Continue. addr is Address to resume. If addr is omitted, resume at current
|
||||
Address.
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
@@ -405,15 +405,15 @@ ContinueAtAddress (
|
||||
{
|
||||
if (PacketData[1] != '\0') {
|
||||
SystemContext.SystemContextArm->PC = AsciiStrHexToUintn(&PacketData[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** ‘s [addr ]’
|
||||
Single step. addr is the Address at which to resume. If addr is omitted, resume
|
||||
Single step. addr is the Address at which to resume. If addr is omitted, resume
|
||||
at same Address.
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
@@ -448,9 +448,9 @@ RemoveBreakPoint (
|
||||
|
||||
|
||||
/**
|
||||
Send the T signal with the given exception type (in gdb order) and possibly
|
||||
Send the T signal with the given exception type (in gdb order) and possibly
|
||||
with n:r pairs related to the watchpoints
|
||||
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param GdbExceptionType GDB exception type
|
||||
**/
|
||||
@@ -467,13 +467,13 @@ ProcessorSendTSignal (
|
||||
|
||||
/**
|
||||
FIQ state is only changed by FIQ exception. We don't want to take FIQ
|
||||
ticks in the GDB stub. The stub disables FIQ on entry, but this is the
|
||||
ticks in the GDB stub. The stub disables FIQ on entry, but this is the
|
||||
third instruction that executes in the execption handler. Thus we have
|
||||
a crack we need to test for.
|
||||
|
||||
@param PC PC of execption
|
||||
|
||||
@return TRUE We are in the GDB stub exception preamble
|
||||
@return TRUE We are in the GDB stub exception preamble
|
||||
@return FALSE We are not in GDB stub code
|
||||
**/
|
||||
BOOLEAN
|
||||
@@ -495,21 +495,21 @@ InFiqCrack (
|
||||
/**
|
||||
Check to see if this exception is related to ctrl-c handling.
|
||||
|
||||
In this scheme we dedicate FIQ to the ctrl-c handler so it is
|
||||
independent of the rest of the system.
|
||||
|
||||
SaveAndSetDebugTimerInterrupt () can be used to
|
||||
In this scheme we dedicate FIQ to the ctrl-c handler so it is
|
||||
independent of the rest of the system.
|
||||
|
||||
SaveAndSetDebugTimerInterrupt () can be used to
|
||||
|
||||
@param ExceptionType Exception that is being processed
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param SystemContext Register content at time of the exception
|
||||
|
||||
@return TRUE This was a ctrl-c check that did not find a ctrl-c
|
||||
@return FALSE This was not a ctrl-c check or some one hit ctrl-c
|
||||
**/
|
||||
BOOLEAN
|
||||
ProcessorControlC (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
ProcessorControlC (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
)
|
||||
{
|
||||
CHAR8 Char;
|
||||
@@ -534,7 +534,7 @@ ProcessorControlC (
|
||||
Return = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Char = GdbGetChar ();
|
||||
if (Char == 0x03) {
|
||||
//
|
||||
@@ -622,7 +622,7 @@ InitializeDebugAgent (
|
||||
IN VOID *Context, OPTIONAL
|
||||
IN DEBUG_AGENT_CONTINUE Function OPTIONAL
|
||||
)
|
||||
{
|
||||
{
|
||||
UINTN Offset;
|
||||
UINTN Length;
|
||||
BOOLEAN IrqEnabled;
|
||||
@@ -647,7 +647,7 @@ InitializeDebugAgent (
|
||||
VectorBase = (UINT32 *)(UINTN)PcdGet32 (PcdCpuVectorBaseAddress);
|
||||
|
||||
|
||||
// Copy our assembly code into the page that contains the exception vectors.
|
||||
// Copy our assembly code into the page that contains the exception vectors.
|
||||
CopyMem ((VOID *)VectorBase, (VOID *)ExceptionHandlersStart, Length);
|
||||
|
||||
//
|
||||
|
@@ -34,7 +34,7 @@ CHAR8 gXferLibraryBuffer[2000];
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexToStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
|
||||
|
||||
|
||||
// add-symbol-file c:/work/edk2/Build/BeagleBoard/DEBUG_ARMGCC/ARM/BeagleBoardPkg/Sec/Sec/DEBUG/BeagleBoardSec.dll 0x80008360
|
||||
// add-symbol-file c:/work/edk2/Build/BeagleBoard/DEBUG_ARMGCC/ARM/BeagleBoardPkg/Sec/Sec/DEBUG/BeagleBoardSec.dll 0x80008360
|
||||
CHAR8 *qXferHack = "<library name=\"c:/work/edk2/Build/BeagleBoard/DEBUG_ARMGCC/ARM/BeagleBoardPkg/Sec/Sec/DEBUG/BeagleBoardSec.dll\"><segment address=\"0x80008360\"/></library>";
|
||||
|
||||
UINTN
|
||||
@@ -52,7 +52,7 @@ gXferObjectReadResponse (
|
||||
*OutBufPtr++ = Type;
|
||||
Count = 1;
|
||||
|
||||
// Binary data encoding
|
||||
// Binary data encoding
|
||||
OutBufPtr = gOutBuffer;
|
||||
while (*Str != '\0') {
|
||||
Char = *Str++;
|
||||
@@ -68,42 +68,42 @@ gXferObjectReadResponse (
|
||||
|
||||
*OutBufPtr = '\0' ; // the end of the buffer
|
||||
SendPacket (gOutBuffer);
|
||||
|
||||
|
||||
return Count;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
Process "qXfer:object:read:annex:offset,length" request.
|
||||
|
||||
Returns an XML document that contains loaded libraries. In our case it is
|
||||
|
||||
Returns an XML document that contains loaded libraries. In our case it is
|
||||
infomration in the EFI Debug Inmage Table converted into an XML document.
|
||||
|
||||
GDB will call with an arbitrary length (it can't know the real length and
|
||||
will reply with chunks of XML that are easy for us to deal with. Gdb will
|
||||
|
||||
GDB will call with an arbitrary length (it can't know the real length and
|
||||
will reply with chunks of XML that are easy for us to deal with. Gdb will
|
||||
keep calling until we say we are done. XML doc looks like:
|
||||
|
||||
|
||||
<library-list>
|
||||
<library name="/a/a/c/d.dSYM"><segment address="0x10000000"/></library>
|
||||
<library name="/a/m/e/e.pdb"><segment address="0x20000000"/></library>
|
||||
<library name="/a/l/f/f.dll"><segment address="0x30000000"/></library>
|
||||
</library-list>
|
||||
|
||||
Since we can not allocate memory in interupt context this module has
|
||||
|
||||
Since we can not allocate memory in interupt context this module has
|
||||
assumptions about how it will get called:
|
||||
1) Length will generally be max remote packet size (big enough)
|
||||
2) First Offset of an XML document read needs to be 0
|
||||
3) This code will return back small chunks of the XML document on every read.
|
||||
Each subseqent call will ask for the next availble part of the document.
|
||||
|
||||
|
||||
Note: The only variable size element in the XML is:
|
||||
" <library name=\"%s\"><segment address=\"%p\"/></library>\n" and it is
|
||||
" <library name=\"%s\"><segment address=\"%p\"/></library>\n" and it is
|
||||
based on the file path and name of the symbol file. If the symbol file name
|
||||
is bigger than the max gdb remote packet size we could update this code
|
||||
to respond back in chunks.
|
||||
|
||||
@param Offset offset into special data area
|
||||
@param Length number of bytes to read starting at Offset
|
||||
|
||||
@param Length number of bytes to read starting at Offset
|
||||
|
||||
**/
|
||||
VOID
|
||||
QxferLibrary (
|
||||
@@ -134,13 +134,13 @@ TransferFromInBufToMem (
|
||||
{
|
||||
CHAR8 c1;
|
||||
CHAR8 c2;
|
||||
|
||||
|
||||
while (Length-- > 0) {
|
||||
c1 = (CHAR8)HexCharToInt (*NewData++);
|
||||
c2 = (CHAR8)HexCharToInt (*NewData++);
|
||||
|
||||
if ((c1 < 0) || (c2 < 0)) {
|
||||
SendError (GDB_EBADMEMDATA);
|
||||
SendError (GDB_EBADMEMDATA);
|
||||
return;
|
||||
}
|
||||
*Address++ = (UINT8)((c1 << 4) + c2);
|
||||
@@ -171,7 +171,7 @@ TransferFromMemToOutBufAndSend (
|
||||
|
||||
OutBufPtr = OutBuffer;
|
||||
while (Length > 0) {
|
||||
|
||||
|
||||
Char = mHexToStr[*Address >> 4];
|
||||
if ((Char >= 'A') && (Char <= 'F')) {
|
||||
Char = Char - 'A' + 'a';
|
||||
@@ -196,16 +196,16 @@ TransferFromMemToOutBufAndSend (
|
||||
|
||||
/**
|
||||
Send a GDB Remote Serial Protocol Packet
|
||||
|
||||
$PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',
|
||||
|
||||
$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
|
||||
|
||||
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
|
||||
|
||||
@param PacketData Payload data for the packet
|
||||
@param PacketData Payload data for the packet
|
||||
|
||||
|
||||
|
||||
@retval Number of bytes of packet data sent.
|
||||
|
||||
**/
|
||||
@@ -219,7 +219,7 @@ SendPacket (
|
||||
CHAR8 *Ptr;
|
||||
CHAR8 TestChar;
|
||||
UINTN Count;
|
||||
|
||||
|
||||
Timeout = PcdGet32 (PcdGdbMaxPacketRetryCount);
|
||||
|
||||
Count = 0;
|
||||
@@ -231,38 +231,38 @@ SendPacket (
|
||||
// Only try a finite number of times so we don't get stuck in the loop
|
||||
return Count;
|
||||
}
|
||||
|
||||
|
||||
// Packet prefix
|
||||
GdbPutChar ('$');
|
||||
|
||||
|
||||
for (CheckSum = 0, Count =0 ; *Ptr != '\0'; Ptr++, Count++) {
|
||||
GdbPutChar (*Ptr);
|
||||
CheckSum = CheckSum + *Ptr;
|
||||
}
|
||||
|
||||
// Packet terminating character and checksum
|
||||
|
||||
// Packet terminating character and checksum
|
||||
GdbPutChar ('#');
|
||||
GdbPutChar (mHexToStr[CheckSum >> 4]);
|
||||
GdbPutChar (mHexToStr[CheckSum & 0x0F]);
|
||||
|
||||
|
||||
TestChar = GdbGetChar ();
|
||||
} while (TestChar != '+');
|
||||
|
||||
|
||||
return Count;
|
||||
}
|
||||
|
||||
/**
|
||||
Receive a GDB Remote Serial Protocol Packet
|
||||
|
||||
$PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',
|
||||
|
||||
$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
|
||||
|
||||
@param PacketData Payload data for the packet
|
||||
@param PacketData Payload data for the packet
|
||||
|
||||
@retval Number of bytes of packet data received.
|
||||
|
||||
@@ -278,16 +278,16 @@ ReceivePacket (
|
||||
CHAR8 Char;
|
||||
CHAR8 SumString[3];
|
||||
CHAR8 TestChar;
|
||||
|
||||
|
||||
ZeroMem (PacketData, PacketDataSize);
|
||||
|
||||
|
||||
for (;;) {
|
||||
// wait for the start of a packet
|
||||
TestChar = GdbGetChar ();
|
||||
while (TestChar != '$') {
|
||||
TestChar = GdbGetChar ();
|
||||
};
|
||||
|
||||
|
||||
retry:
|
||||
for (Index = 0, CheckSum = 0; Index < (PacketDataSize - 1); Index++) {
|
||||
Char = GdbGetChar ();
|
||||
@@ -307,14 +307,14 @@ ReceivePacket (
|
||||
continue;
|
||||
}
|
||||
|
||||
SumString[0] = GdbGetChar ();
|
||||
SumString[0] = GdbGetChar ();
|
||||
SumString[1] = GdbGetChar ();
|
||||
SumString[2] = '\0';
|
||||
|
||||
|
||||
if (AsciiStrHexToUintn (SumString) == CheckSum) {
|
||||
// Ack: Success
|
||||
GdbPutChar ('+');
|
||||
|
||||
|
||||
// Null terminate the callers string
|
||||
PacketData[Index] = '\0';
|
||||
return Index;
|
||||
@@ -323,27 +323,27 @@ ReceivePacket (
|
||||
GdbPutChar ('-');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Empties the given buffer
|
||||
Empties the given buffer
|
||||
@param Buf pointer to the first element in buffer to be emptied
|
||||
**/
|
||||
VOID
|
||||
EmptyBuffer (
|
||||
EmptyBuffer (
|
||||
IN CHAR8 *Buf
|
||||
)
|
||||
{
|
||||
{
|
||||
*Buf = '\0';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Converts an 8-bit Hex Char into a INTN.
|
||||
|
||||
|
||||
@param Char the hex character to be converted into UINTN
|
||||
@retval a INTN, from 0 to 15, that corressponds to Char
|
||||
-1 if Char is not a hex character
|
||||
@@ -360,7 +360,7 @@ HexCharToInt (
|
||||
} else if ((Char >= '0') && (Char <= '9')) {
|
||||
return Char - '0';
|
||||
} else { // if not a hex value, return a negative value
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ CHAR8 *gError = "E__";
|
||||
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.
|
||||
|
||||
|
||||
@param errno the error number that will be sent
|
||||
**/
|
||||
VOID
|
||||
@@ -385,7 +385,7 @@ SendError (
|
||||
//
|
||||
gError[1] = mHexToStr [ErrorNum >> 4];
|
||||
gError[2] = mHexToStr [ErrorNum & 0x0f];
|
||||
|
||||
|
||||
SendPacket (gError); // send buffer
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ VOID
|
||||
EFIAPI
|
||||
SendSuccess (
|
||||
VOID
|
||||
)
|
||||
)
|
||||
{
|
||||
SendPacket ("OK"); // send buffer
|
||||
}
|
||||
@@ -407,12 +407,12 @@ SendSuccess (
|
||||
/**
|
||||
Send empty packet to specify that particular command/functionality is not supported.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
VOID
|
||||
EFIAPI
|
||||
SendNotSupported (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
VOID
|
||||
)
|
||||
{
|
||||
SendPacket ("");
|
||||
}
|
||||
|
||||
@@ -422,17 +422,17 @@ SendNotSupported (
|
||||
|
||||
/**
|
||||
Translates the EFI mapping to GDB mapping
|
||||
|
||||
|
||||
@param EFIExceptionType EFI Exception that is being processed
|
||||
@retval UINTN that corresponds to EFIExceptionType's GDB exception type number
|
||||
**/
|
||||
UINT8
|
||||
ConvertEFItoGDBtype (
|
||||
ConvertEFItoGDBtype (
|
||||
IN EFI_EXCEPTION_TYPE EFIExceptionType
|
||||
)
|
||||
{
|
||||
{
|
||||
UINTN i;
|
||||
|
||||
|
||||
for (i=0; i < MaxEfiException() ; i++) {
|
||||
if (gExceptionType[i].Exception == EFIExceptionType) {
|
||||
return gExceptionType[i].SignalNo;
|
||||
@@ -443,8 +443,8 @@ ConvertEFItoGDBtype (
|
||||
|
||||
|
||||
/** "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
|
||||
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.
|
||||
**/
|
||||
|
||||
@@ -459,37 +459,37 @@ ReadFromMemory (
|
||||
CHAR8 AddressBuffer[MAX_ADDR_SIZE]; // the buffer that will hold the address in hex chars
|
||||
CHAR8 *AddrBufPtr; // pointer to the address buffer
|
||||
CHAR8 *InBufPtr; /// pointer to the input buffer
|
||||
|
||||
|
||||
AddrBufPtr = AddressBuffer;
|
||||
InBufPtr = &PacketData[1];
|
||||
while (*InBufPtr != ',') {
|
||||
*AddrBufPtr++ = *InBufPtr++;
|
||||
}
|
||||
*AddrBufPtr = '\0';
|
||||
|
||||
|
||||
InBufPtr++; // this skips ',' in the buffer
|
||||
|
||||
|
||||
/* Error checking */
|
||||
if (AsciiStrLen(AddressBuffer) >= MAX_ADDR_SIZE) {
|
||||
SendError (GDB_EBADMEMADDRBUFSIZE);
|
||||
SendError (GDB_EBADMEMADDRBUFSIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 2 = 'm' + ','
|
||||
if (AsciiStrLen(PacketData) - AsciiStrLen(AddressBuffer) - 2 >= MAX_LENGTH_SIZE) {
|
||||
SendError (GDB_EBADMEMLENGTH);
|
||||
SendError (GDB_EBADMEMLENGTH);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Address = AsciiStrHexToUintn (AddressBuffer);
|
||||
Length = AsciiStrHexToUintn (InBufPtr);
|
||||
|
||||
|
||||
TransferFromMemToOutBufAndSend (Length, (unsigned char *)Address);
|
||||
}
|
||||
|
||||
|
||||
/** "M addr,length :XX..."
|
||||
Find the Length of the area in bytes to write and the start addres. Finally, pass them to
|
||||
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.
|
||||
**/
|
||||
@@ -507,48 +507,48 @@ WriteToMemory (
|
||||
CHAR8 *AddrBufPtr; // pointer to the Address buffer
|
||||
CHAR8 *LengthBufPtr; // pointer to the Length buffer
|
||||
CHAR8 *InBufPtr; /// pointer to the input buffer
|
||||
|
||||
|
||||
AddrBufPtr = AddressBuffer;
|
||||
LengthBufPtr = LengthBuffer;
|
||||
InBufPtr = &PacketData[1];
|
||||
|
||||
|
||||
while (*InBufPtr != ',') {
|
||||
*AddrBufPtr++ = *InBufPtr++;
|
||||
}
|
||||
*AddrBufPtr = '\0';
|
||||
|
||||
|
||||
InBufPtr++; // this skips ',' in the buffer
|
||||
|
||||
|
||||
while (*InBufPtr != ':') {
|
||||
*LengthBufPtr++ = *InBufPtr++;
|
||||
}
|
||||
*LengthBufPtr = '\0';
|
||||
|
||||
|
||||
InBufPtr++; // this skips ':' in the buffer
|
||||
|
||||
|
||||
Address = AsciiStrHexToUintn (AddressBuffer);
|
||||
Length = AsciiStrHexToUintn (LengthBuffer);
|
||||
|
||||
|
||||
/* Error checking */
|
||||
|
||||
|
||||
//Check if Address is not too long.
|
||||
if (AsciiStrLen(AddressBuffer) >= MAX_ADDR_SIZE) {
|
||||
SendError (GDB_EBADMEMADDRBUFSIZE);
|
||||
SendError (GDB_EBADMEMADDRBUFSIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//Check if message length is not too long
|
||||
if (AsciiStrLen(LengthBuffer) >= MAX_LENGTH_SIZE) {
|
||||
SendError (GDB_EBADMEMLENGBUFSIZE);
|
||||
SendError (GDB_EBADMEMLENGBUFSIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Check if Message is not too long/short.
|
||||
// 3 = 'M' + ',' + ':'
|
||||
MessageLength = (AsciiStrLen(PacketData) - AsciiStrLen(AddressBuffer) - AsciiStrLen(LengthBuffer) - 3);
|
||||
if (MessageLength != (2*Length)) {
|
||||
//Message too long/short. New data is not the right size.
|
||||
SendError (GDB_EBADMEMDATASIZE);
|
||||
SendError (GDB_EBADMEMDATASIZE);
|
||||
return;
|
||||
}
|
||||
TransferFromInBufToMem (Length, (unsigned char *)Address, InBufPtr);
|
||||
@@ -623,7 +623,7 @@ ParseBreakpointPacket (
|
||||
|
||||
/**
|
||||
Send the T signal with the given exception type (in gdb order) and possibly with n:r pairs related to the watchpoints
|
||||
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param GdbExceptionType GDB exception type
|
||||
**/
|
||||
@@ -644,12 +644,12 @@ GdbSendTSignal (
|
||||
//
|
||||
// replace _, or previous value, with Exception type
|
||||
//
|
||||
*TSignalPtr++ = mHexToStr [GdbExceptionType >> 4];
|
||||
*TSignalPtr++ = mHexToStr [GdbExceptionType >> 4];
|
||||
*TSignalPtr++ = mHexToStr [GdbExceptionType & 0x0f];
|
||||
|
||||
|
||||
ProcessorSendTSignal (SystemContext, GdbExceptionType, TSignalPtr, sizeof (TSignalBuffer) - 2);
|
||||
|
||||
SendPacket (TSignalBuffer);
|
||||
SendPacket (TSignalBuffer);
|
||||
}
|
||||
|
||||
VOID
|
||||
@@ -666,7 +666,7 @@ GdbFWrite (
|
||||
|
||||
for( ; ; ) {
|
||||
ReceivePacket (gInBuffer, MAX_BUF_SIZE);
|
||||
|
||||
|
||||
switch (gInBuffer[0]) {
|
||||
case 'm':
|
||||
ReadFromMemory (gInBuffer);
|
||||
@@ -697,20 +697,20 @@ GdbFPutString (
|
||||
/**
|
||||
Exception Hanldler for GDB. It will be called for all exceptions
|
||||
registered via the gExceptionType[] array.
|
||||
|
||||
|
||||
@param ExceptionType Exception that is being processed
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param SystemContext Register content at time of the exception
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
GdbExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
GdbExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
)
|
||||
{
|
||||
UINT8 GdbExceptionType;
|
||||
CHAR8 *Ptr;
|
||||
|
||||
|
||||
if (ProcessorControlC (ExceptionType, SystemContext)) {
|
||||
// We tried to process a control C handler and there is nothing to do
|
||||
return;
|
||||
@@ -718,37 +718,37 @@ GdbExceptionHandler (
|
||||
|
||||
GdbExceptionType = ConvertEFItoGDBtype (ExceptionType);
|
||||
GdbSendTSignal (SystemContext, GdbExceptionType);
|
||||
|
||||
|
||||
for( ; ; ) {
|
||||
ReceivePacket (gInBuffer, MAX_BUF_SIZE);
|
||||
|
||||
|
||||
switch (gInBuffer[0]) {
|
||||
case '?':
|
||||
GdbSendTSignal (SystemContext, GdbExceptionType);
|
||||
break;
|
||||
|
||||
|
||||
case 'c':
|
||||
ContinueAtAddress (SystemContext, gInBuffer);
|
||||
ContinueAtAddress (SystemContext, gInBuffer);
|
||||
return;
|
||||
|
||||
case 'D':
|
||||
// gdb wants to disconnect so return "OK" packet since.
|
||||
// gdb wants to disconnect so return "OK" packet since.
|
||||
SendSuccess ();
|
||||
return;
|
||||
|
||||
case 'g':
|
||||
ReadGeneralRegisters (SystemContext);
|
||||
break;
|
||||
|
||||
|
||||
case 'G':
|
||||
WriteGeneralRegisters (SystemContext, gInBuffer);
|
||||
break;
|
||||
|
||||
|
||||
case 'H':
|
||||
//Return "OK" packet since we don't have more than one thread.
|
||||
//Return "OK" packet since we don't have more than one thread.
|
||||
SendSuccess ();
|
||||
break;
|
||||
|
||||
|
||||
case 'm':
|
||||
ReadFromMemory (gInBuffer);
|
||||
break;
|
||||
@@ -764,7 +764,7 @@ GdbExceptionHandler (
|
||||
//
|
||||
// Still debugging this code. Not used in Darwin
|
||||
//
|
||||
case 'q':
|
||||
case 'q':
|
||||
// General Query Packets
|
||||
if (AsciiStrnCmp (gInBuffer, "qSupported", 10) == 0) {
|
||||
// return what we currently support, we don't parse what gdb suports
|
||||
@@ -774,7 +774,7 @@ GdbExceptionHandler (
|
||||
// <20>qXfer:libraries:read::offset,length
|
||||
// gInBuffer[22] is offset string, ++Ptr is length string<6E>
|
||||
for (Ptr = &gInBuffer[22]; *Ptr != ','; Ptr++);
|
||||
|
||||
|
||||
// Not sure if multi-radix support is required. Currently only support decimal
|
||||
QxferLibrary (AsciiStrHexToUintn (&gInBuffer[22]), AsciiStrHexToUintn (++Ptr));
|
||||
} else if (AsciiStrnCmp (gInBuffer, "qOffsets", 8) == 0) {
|
||||
@@ -790,18 +790,18 @@ GdbExceptionHandler (
|
||||
break;
|
||||
|
||||
case 's':
|
||||
SingleStep (SystemContext, gInBuffer);
|
||||
SingleStep (SystemContext, gInBuffer);
|
||||
return;
|
||||
|
||||
|
||||
case 'z':
|
||||
RemoveBreakPoint (SystemContext, gInBuffer);
|
||||
break;
|
||||
|
||||
|
||||
case 'Z':
|
||||
InsertBreakPoint (SystemContext, gInBuffer);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
default:
|
||||
//Send empty packet
|
||||
SendNotSupported ();
|
||||
break;
|
||||
|
@@ -34,7 +34,7 @@
|
||||
extern CONST CHAR8 mHexToStr[];
|
||||
|
||||
// maximum size of input and output buffers
|
||||
// This value came from the show remote command of the gdb we tested against
|
||||
// This value came from the show remote command of the gdb we tested against
|
||||
#define MAX_BUF_SIZE 2000
|
||||
|
||||
// maximum size of address buffer
|
||||
@@ -57,11 +57,11 @@ extern CONST CHAR8 mHexToStr[];
|
||||
// GDB Signal definitions - generic names for interrupts
|
||||
//
|
||||
#define GDB_SIGINT 2 // Interrupt process via ctrl-c
|
||||
#define GDB_SIGILL 4 // Illegal instruction
|
||||
#define GDB_SIGILL 4 // Illegal instruction
|
||||
#define GDB_SIGTRAP 5 // Trace Trap (Breakpoint and SingleStep)
|
||||
#define GDB_SIGEMT 7 // Emulator Trap
|
||||
#define GDB_SIGFPE 8 // Floating point exception
|
||||
#define GDB_SIGSEGV 11 // Setgment violation, page fault
|
||||
#define GDB_SIGSEGV 11 // Setgment violation, page fault
|
||||
|
||||
|
||||
//
|
||||
@@ -69,9 +69,9 @@ extern CONST CHAR8 mHexToStr[];
|
||||
// Includes all general GDB Unix like error values
|
||||
//
|
||||
#define GDB_EBADMEMADDRBUFSIZE 11 // the buffer that stores memory Address to be read from/written to is not the right size
|
||||
#define GDB_EBADMEMLENGBUFSIZE 12 // the buffer that stores Length is not the right size
|
||||
#define GDB_EBADMEMLENGBUFSIZE 12 // the buffer that stores Length is not the right size
|
||||
#define GDB_EBADMEMLENGTH 13 // Length, the given number of bytes to read or write, is not the right size
|
||||
#define GDB_EBADMEMDATA 14 // one of the bytes or nibbles of the memory is leess than 0
|
||||
#define GDB_EBADMEMDATA 14 // one of the bytes or nibbles of the memory is leess than 0
|
||||
#define GDB_EBADMEMDATASIZE 15 // the memory data, 'XX..', is too short or too long
|
||||
#define GDB_EBADBUFSIZE 21 // the buffer created is not the correct size
|
||||
#define GDB_EINVALIDARG 31 // argument is invalid
|
||||
@@ -91,7 +91,7 @@ extern CONST CHAR8 mHexToStr[];
|
||||
//
|
||||
//Define Register size for different architectures
|
||||
//
|
||||
#if defined (MDE_CPU_IA32)
|
||||
#if defined (MDE_CPU_IA32)
|
||||
#define REG_SIZE 32
|
||||
#elif defined (MDE_CPU_X64)
|
||||
#define REG_SIZE 64
|
||||
@@ -119,7 +119,7 @@ typedef union {
|
||||
UINT32 B1:1; // Breakpoint condition detected
|
||||
UINT32 B2:1; // Breakpoint condition detected
|
||||
UINT32 B3:1; // Breakpoint condition detected
|
||||
UINT32 Reserved_1:9; // Reserved
|
||||
UINT32 Reserved_1:9; // Reserved
|
||||
UINT32 BD:1; // Debug register access detected
|
||||
UINT32 BS:1; // Single step
|
||||
UINT32 BT:1; // Task switch
|
||||
@@ -186,8 +186,8 @@ extern BOOLEAN gProcessingFPacket;
|
||||
|
||||
/**
|
||||
Return the number of entries in the gExceptionType[]
|
||||
|
||||
@retval UINTN, the number of entries in the gExceptionType[] array.
|
||||
|
||||
@retval UINTN, the number of entries in the gExceptionType[] array.
|
||||
**/
|
||||
UINTN
|
||||
MaxEfiException (
|
||||
@@ -196,9 +196,9 @@ MaxEfiException (
|
||||
|
||||
|
||||
/**
|
||||
Check to see if the ISA is supported.
|
||||
Check to see if the ISA is supported.
|
||||
ISA = Instruction Set Architecture
|
||||
|
||||
|
||||
@retval TRUE if Isa is supported,
|
||||
FALSE otherwise.
|
||||
**/
|
||||
@@ -210,7 +210,7 @@ CheckIsa (
|
||||
|
||||
/**
|
||||
Send the T signal with the given exception type (in gdb order) and possibly with n:r pairs related to the watchpoints
|
||||
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param GdbExceptionType GDB exception type
|
||||
**/
|
||||
@@ -224,29 +224,29 @@ GdbSendTSignal (
|
||||
|
||||
/**
|
||||
Translates the EFI mapping to GDB mapping
|
||||
|
||||
|
||||
@param EFIExceptionType EFI Exception that is being processed
|
||||
@retval UINTN that corresponds to EFIExceptionType's GDB exception type number
|
||||
**/
|
||||
UINT8
|
||||
ConvertEFItoGDBtype (
|
||||
ConvertEFItoGDBtype (
|
||||
IN EFI_EXCEPTION_TYPE EFIExceptionType
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Empties the given buffer
|
||||
Empties the given buffer
|
||||
@param *Buf pointer to the first element in buffer to be emptied
|
||||
**/
|
||||
VOID
|
||||
EmptyBuffer (
|
||||
EmptyBuffer (
|
||||
IN CHAR8 *Buf
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Converts an 8-bit Hex Char into a INTN.
|
||||
|
||||
|
||||
@param Char - the hex character to be converted into UINTN
|
||||
@retval a INTN, from 0 to 15, that corressponds to Char
|
||||
-1 if Char is not a hex character
|
||||
@@ -261,7 +261,7 @@ HexCharToInt (
|
||||
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.
|
||||
|
||||
|
||||
@param errno the error number that will be sent
|
||||
**/
|
||||
VOID
|
||||
@@ -288,8 +288,8 @@ SendNotSupported (
|
||||
VOID
|
||||
);
|
||||
|
||||
/** ‘p n’
|
||||
Reads the n-th register's value into an output buffer and sends it as a packet
|
||||
/** ‘p n’
|
||||
Reads the n-th register's value into an output buffer and sends it as a packet
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param InBuffer This is the input buffer received from gdb server
|
||||
**/
|
||||
@@ -300,12 +300,12 @@ ReadNthRegister (
|
||||
);
|
||||
|
||||
|
||||
/** ‘g’
|
||||
Reads the general registers into an output buffer and sends it as a packet
|
||||
/** ‘g’
|
||||
Reads the general registers into an output buffer and sends it as a packet
|
||||
@param SystemContext Register content at time of the exception
|
||||
**/
|
||||
VOID
|
||||
ReadGeneralRegisters (
|
||||
ReadGeneralRegisters (
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||
);
|
||||
|
||||
@@ -336,10 +336,10 @@ WriteGeneralRegisters (
|
||||
|
||||
|
||||
/** ‘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
|
||||
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.
|
||||
|
||||
|
||||
@param *PacketData Pointer to Payload data for the packet
|
||||
**/
|
||||
VOID
|
||||
@@ -349,10 +349,10 @@ ReadFromMemory (
|
||||
|
||||
|
||||
/** ‘M addr,length :XX...’
|
||||
Find the Length of the area in bytes to write and the start addres. Finally, pass them to
|
||||
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.
|
||||
|
||||
|
||||
@param PacketData Pointer to Payload data for the packet
|
||||
**/
|
||||
VOID
|
||||
@@ -361,11 +361,11 @@ WriteToMemory (
|
||||
);
|
||||
|
||||
|
||||
/** ‘c [addr ]’
|
||||
Continue. addr is Address to resume. If addr is omitted, resume at current
|
||||
/** ‘c [addr ]’
|
||||
Continue. addr is Address to resume. If addr is omitted, resume at current
|
||||
Address.
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param *PacketData Pointer to PacketData
|
||||
**/
|
||||
|
||||
@@ -377,9 +377,9 @@ ContinueAtAddress (
|
||||
|
||||
|
||||
/** ‘s [addr ]’
|
||||
Single step. addr is the Address at which to resume. If addr is omitted, resume
|
||||
Single step. addr is the Address at which to resume. If addr is omitted, resume
|
||||
at same Address.
|
||||
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param PacketData Pointer to Payload data for the packet
|
||||
**/
|
||||
@@ -389,27 +389,27 @@ SingleStep (
|
||||
IN CHAR8 *PacketData
|
||||
);
|
||||
|
||||
/**
|
||||
/**
|
||||
Insert Single Step in the SystemContext
|
||||
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
**/
|
||||
VOID
|
||||
AddSingleStep (
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
Remove Single Step in the SystemContext
|
||||
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
**/
|
||||
VOID
|
||||
RemoveSingleStep (
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
‘Z1, [addr], [length]’
|
||||
‘Z2, [addr], [length]’
|
||||
@@ -453,36 +453,36 @@ RemoveBreakPoint(
|
||||
/**
|
||||
Exception Hanldler for GDB. It will be called for all exceptions
|
||||
registered via the gExceptionType[] array.
|
||||
|
||||
|
||||
@param ExceptionType Exception that is being processed
|
||||
@param SystemContext Register content at time of the exception
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
GdbExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
GdbExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Periodic callback for GDB. This function is used to catch a ctrl-c or other
|
||||
Periodic callback for GDB. This function is used to catch a ctrl-c or other
|
||||
break in type command from GDB.
|
||||
|
||||
|
||||
@param SystemContext Register content at time of the call
|
||||
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
GdbPeriodicCallBack (
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
GdbPeriodicCallBack (
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Make two serail consoles: 1) StdIn and StdOut via GDB. 2) StdErr via GDB.
|
||||
|
||||
|
||||
These console show up on the remote system running GDB
|
||||
|
||||
**/
|
||||
@@ -495,15 +495,15 @@ GdbInitializeSerialConsole (
|
||||
|
||||
/**
|
||||
Send a GDB Remote Serial Protocol Packet
|
||||
|
||||
$PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',
|
||||
|
||||
$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
|
||||
|
||||
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
|
||||
|
||||
@param PacketData Payload data for the packet
|
||||
|
||||
@param PacketData Payload data for the packet
|
||||
|
||||
@retval Number of bytes of packet data sent.
|
||||
|
||||
**/
|
||||
@@ -511,21 +511,21 @@ UINTN
|
||||
SendPacket (
|
||||
IN CHAR8 *PacketData
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Receive a GDB Remote Serial Protocol Packet
|
||||
|
||||
$PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',
|
||||
|
||||
$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
|
||||
|
||||
@param PacketData Payload data for the packet
|
||||
|
||||
|
||||
@param PacketData Payload data for the packet
|
||||
|
||||
@retval Number of bytes of packet data received.
|
||||
|
||||
**/
|
||||
@@ -534,15 +534,15 @@ ReceivePacket (
|
||||
OUT CHAR8 *PacketData,
|
||||
IN UINTN PacketDataSize
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Read data from a FileDescriptor. On success number of bytes read is returned. Zero indicates
|
||||
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.
|
||||
|
||||
@param FileDescriptor Device to talk to.
|
||||
@param Buffer Buffer to hold Count bytes that were read
|
||||
@param Count Number of bytes to transfer.
|
||||
@param Count Number of bytes to transfer.
|
||||
|
||||
@retval -1 Error
|
||||
@retval {other} Number of bytes read.
|
||||
@@ -554,15 +554,15 @@ GdbRead (
|
||||
OUT 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.
|
||||
Write data to a FileDescriptor. On success number of bytes written is returned. Zero indicates
|
||||
nothing was written. On error -1 is returned.
|
||||
|
||||
@param FileDescriptor Device to talk to.
|
||||
@param Buffer Buffer to hold Count bytes that are to be written
|
||||
@param Count Number of bytes to transfer.
|
||||
@param Count Number of bytes to transfer.
|
||||
|
||||
@retval -1 Error
|
||||
@retval {other} Number of bytes written.
|
||||
@@ -575,13 +575,13 @@ GdbWrite (
|
||||
IN UINTN Count
|
||||
);
|
||||
|
||||
UINTN *
|
||||
UINTN *
|
||||
FindPointerToRegister (
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext,
|
||||
IN UINTN RegNumber
|
||||
IN UINTN RegNumber
|
||||
);
|
||||
|
||||
CHAR8 *
|
||||
CHAR8 *
|
||||
BasicReadRegister (
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext,
|
||||
IN UINTN RegNumber,
|
||||
@@ -608,7 +608,7 @@ BasicWriteRegister (
|
||||
IN CHAR8 *InBufPtr
|
||||
);
|
||||
|
||||
VOID
|
||||
VOID
|
||||
PrintReg (
|
||||
EFI_SYSTEM_CONTEXT SystemContext
|
||||
);
|
||||
@@ -624,7 +624,7 @@ ParseBreakpointPacket (
|
||||
UINTN
|
||||
GetBreakpointDataAddress (
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext,
|
||||
IN UINTN BreakpointNumber
|
||||
IN UINTN BreakpointNumber
|
||||
);
|
||||
|
||||
UINTN
|
||||
@@ -635,7 +635,7 @@ GetBreakpointDetected (
|
||||
BREAK_TYPE
|
||||
GetBreakpointType (
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext,
|
||||
IN UINTN BreakpointNumber
|
||||
IN UINTN BreakpointNumber
|
||||
);
|
||||
|
||||
UINTN
|
||||
@@ -680,7 +680,7 @@ InitializeProcessor (
|
||||
|
||||
/**
|
||||
Send the T signal with the given exception type (in gdb order) and possibly with n:r pairs related to the watchpoints
|
||||
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param GdbExceptionType GDB exception type
|
||||
**/
|
||||
@@ -694,17 +694,17 @@ ProcessorSendTSignal (
|
||||
|
||||
/**
|
||||
Check to see if this exception is related to ctrl-c handling.
|
||||
|
||||
|
||||
@param ExceptionType Exception that is being processed
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param SystemContext Register content at time of the exception
|
||||
|
||||
@return TRUE This was a ctrl-c check that did not find a ctrl-c
|
||||
@return FALSE This was not a ctrl-c check or some one hit ctrl-c
|
||||
**/
|
||||
BOOLEAN
|
||||
ProcessorControlC (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
ProcessorControlC (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
);
|
||||
|
||||
|
||||
|
@@ -51,10 +51,10 @@
|
||||
ArmPkg/ArmPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
DebugLib
|
||||
BaseMemoryLib
|
||||
PcdLib
|
||||
BaseLib
|
||||
DebugLib
|
||||
BaseMemoryLib
|
||||
PcdLib
|
||||
GdbSerialLib
|
||||
CacheMaintenanceLib
|
||||
DebugAgentTimerLib
|
||||
|
@@ -2,7 +2,7 @@
|
||||
Processor specific parts of the GDB stub
|
||||
|
||||
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
||||
|
||||
|
||||
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
|
||||
@@ -20,7 +20,7 @@
|
||||
// {EFI mapping, GDB mapping}
|
||||
//
|
||||
EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
|
||||
{ EXCEPT_IA32_DIVIDE_ERROR, GDB_SIGFPE },
|
||||
{ EXCEPT_IA32_DIVIDE_ERROR, GDB_SIGFPE },
|
||||
{ EXCEPT_IA32_DEBUG, GDB_SIGTRAP },
|
||||
{ EXCEPT_IA32_NMI, GDB_SIGEMT },
|
||||
{ EXCEPT_IA32_BREAKPOINT, GDB_SIGTRAP },
|
||||
@@ -62,7 +62,7 @@ UINTN gRegisterOffsets[] = {
|
||||
|
||||
|
||||
//Debug only..
|
||||
VOID
|
||||
VOID
|
||||
PrintReg (
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||
)
|
||||
@@ -80,7 +80,7 @@ PrintReg (
|
||||
}
|
||||
|
||||
//Debug only..
|
||||
VOID
|
||||
VOID
|
||||
PrintDRreg (
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||
)
|
||||
@@ -96,8 +96,8 @@ PrintDRreg (
|
||||
|
||||
/**
|
||||
Return the number of entries in the gExceptionType[]
|
||||
|
||||
@retval UINTN, the number of entries in the gExceptionType[] array.
|
||||
|
||||
@retval UINTN, the number of entries in the gExceptionType[] array.
|
||||
**/
|
||||
UINTN
|
||||
MaxEfiException (
|
||||
@@ -109,9 +109,9 @@ MaxEfiException (
|
||||
|
||||
|
||||
/**
|
||||
Check to see if the ISA is supported.
|
||||
Check to see if the ISA is supported.
|
||||
ISA = Instruction Set Architecture
|
||||
|
||||
|
||||
@retval TRUE if Isa is supported,
|
||||
FALSE otherwise.
|
||||
**/
|
||||
@@ -128,14 +128,14 @@ CheckIsa (
|
||||
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
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param RegNumber The register to which we want to find a pointer
|
||||
@retval the pointer to the RegNumber-th pointer
|
||||
**/
|
||||
UINTN *
|
||||
FindPointerToRegister(
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext,
|
||||
IN UINTN RegNumber
|
||||
IN UINTN RegNumber
|
||||
)
|
||||
{
|
||||
UINT8 *TempPtr;
|
||||
@@ -160,7 +160,7 @@ BasicReadRegister (
|
||||
)
|
||||
{
|
||||
UINTN RegSize;
|
||||
|
||||
|
||||
RegSize = 0;
|
||||
while (RegSize < REG_SIZE) {
|
||||
*OutBufPtr++ = mHexToStr[((*FindPointerToRegister(SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
|
||||
@@ -171,8 +171,8 @@ BasicReadRegister (
|
||||
}
|
||||
|
||||
|
||||
/** ‘p n’
|
||||
Reads the n-th register's value into an output buffer and sends it as a packet
|
||||
/** ‘p n’
|
||||
Reads the n-th register's value into an output buffer and sends it as a packet
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param InBuffer Pointer to the input buffer received from gdb server
|
||||
@@ -187,7 +187,7 @@ ReadNthRegister (
|
||||
UINTN RegNumber;
|
||||
CHAR8 OutBuffer[9]; // 1 reg=8 hex chars, and the end '\0' (escape seq)
|
||||
CHAR8 *OutBufPtr; // pointer to the output buffer
|
||||
|
||||
|
||||
RegNumber = AsciiStrHexToUintn (&InBuffer[1]);
|
||||
|
||||
if ((RegNumber < 0) || (RegNumber >= sizeof (gRegisterOffsets)/sizeof (UINTN))) {
|
||||
@@ -203,14 +203,14 @@ ReadNthRegister (
|
||||
}
|
||||
|
||||
|
||||
/** ‘g’
|
||||
Reads the general registers into an output buffer and sends it as a packet
|
||||
/** ‘g’
|
||||
Reads the general registers into an output buffer and sends it as a packet
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
ReadGeneralRegisters (
|
||||
ReadGeneralRegisters (
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||
)
|
||||
{
|
||||
@@ -219,7 +219,7 @@ ReadGeneralRegisters (
|
||||
CHAR8 *OutBufPtr; // pointer to the output buffer
|
||||
|
||||
OutBufPtr = OutBuffer;
|
||||
for(i = 0 ; i < sizeof (gRegisterOffsets)/sizeof (UINTN) ; i++) { // there are only 16 registers to read
|
||||
for(i = 0 ; i < sizeof (gRegisterOffsets)/sizeof (UINTN) ; i++) { // there are only 16 registers to read
|
||||
OutBufPtr = BasicReadRegister(SystemContext, i, OutBufPtr);
|
||||
}
|
||||
|
||||
@@ -246,26 +246,26 @@ BasicWriteRegister (
|
||||
UINTN RegSize;
|
||||
UINTN TempValue; // the value transferred from a hex char
|
||||
UINT32 NewValue; // the new value of the RegNumber-th Register
|
||||
|
||||
|
||||
NewValue = 0;
|
||||
RegSize = 0;
|
||||
while (RegSize < REG_SIZE) {
|
||||
TempValue = HexCharToInt(*InBufPtr++);
|
||||
|
||||
|
||||
if (TempValue < 0) {
|
||||
SendError (GDB_EBADMEMDATA);
|
||||
SendError (GDB_EBADMEMDATA);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NewValue += (TempValue << (RegSize+4));
|
||||
TempValue = HexCharToInt(*InBufPtr++);
|
||||
|
||||
|
||||
if (TempValue < 0) {
|
||||
SendError (GDB_EBADMEMDATA);
|
||||
SendError (GDB_EBADMEMDATA);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NewValue += (TempValue << RegSize);
|
||||
|
||||
NewValue += (TempValue << RegSize);
|
||||
RegSize = RegSize + 8;
|
||||
}
|
||||
*(FindPointerToRegister(SystemContext, RegNumber)) = NewValue;
|
||||
@@ -290,19 +290,19 @@ WriteNthRegister (
|
||||
CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE]; // put the 'n..' part of the message into this array
|
||||
CHAR8 *RegNumBufPtr;
|
||||
CHAR8 *InBufPtr; // pointer to the input buffer
|
||||
|
||||
|
||||
// find the register number to write
|
||||
InBufPtr = &InBuffer[1];
|
||||
RegNumBufPtr = RegNumBuffer;
|
||||
while (*InBufPtr != '=') {
|
||||
*RegNumBufPtr++ = *InBufPtr++;
|
||||
}
|
||||
}
|
||||
*RegNumBufPtr = '\0';
|
||||
RegNumber = AsciiStrHexToUintn (RegNumBuffer);
|
||||
RegNumber = AsciiStrHexToUintn (RegNumBuffer);
|
||||
|
||||
// check if this is a valid Register Number
|
||||
if ((RegNumber < 0) || (RegNumber >= sizeof (gRegisterOffsets)/sizeof (UINTN))) {
|
||||
SendError (GDB_EINVALIDREGNUM);
|
||||
SendError (GDB_EINVALIDREGNUM);
|
||||
return;
|
||||
}
|
||||
InBufPtr++; // skips the '=' character
|
||||
@@ -327,16 +327,16 @@ WriteGeneralRegisters (
|
||||
UINTN i;
|
||||
CHAR8 *InBufPtr; /// pointer to the input buffer
|
||||
|
||||
// check to see if the buffer is the right size which is
|
||||
// 1 (for 'G') + 16 (for 16 registers) * 8 ( for 8 hex chars each) = 129
|
||||
// check to see if the buffer is the right size which is
|
||||
// 1 (for 'G') + 16 (for 16 registers) * 8 ( for 8 hex chars each) = 129
|
||||
if (AsciiStrLen(InBuffer) != 129) { // 16 regs, 8 hex chars each, and the end '\0' (escape seq)
|
||||
//Bad message. Message is not the right length
|
||||
SendError (GDB_EBADBUFSIZE);
|
||||
//Bad message. Message is not the right length
|
||||
SendError (GDB_EBADBUFSIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
InBufPtr = &InBuffer[1];
|
||||
|
||||
|
||||
// Read the new values for the registers from the input buffer to an array, NewValueArray.
|
||||
// The values in the array are in the gdb ordering
|
||||
for(i=0; i < sizeof (gRegisterOffsets)/sizeof (UINTN); i++) { // there are only 16 registers to write
|
||||
@@ -346,11 +346,11 @@ WriteGeneralRegisters (
|
||||
SendSuccess();
|
||||
}
|
||||
|
||||
/** ‘c [addr ]’
|
||||
Continue. addr is Address to resume. If addr is omitted, resume at current
|
||||
/** ‘c [addr ]’
|
||||
Continue. addr is Address to resume. If addr is omitted, resume at current
|
||||
Address.
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
@@ -361,15 +361,15 @@ ContinueAtAddress (
|
||||
{
|
||||
if (PacketData[1] != '\0') {
|
||||
SystemContext.SystemContextIa32->Eip = AsciiStrHexToUintn (&PacketData[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** ‘s [addr ]’
|
||||
Single step. addr is the Address at which to resume. If addr is omitted, resume
|
||||
Single step. addr is the Address at which to resume. If addr is omitted, resume
|
||||
at same Address.
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
@@ -421,9 +421,9 @@ GetBreakpointDataAddress (
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
|
||||
@retval {1-4} Currently detected breakpoint value
|
||||
@retval {1-4} Currently detected breakpoint value
|
||||
@retval 0 No breakpoint detected.
|
||||
|
||||
|
||||
**/
|
||||
UINTN
|
||||
GetBreakpointDetected (
|
||||
@@ -444,7 +444,7 @@ GetBreakpointDetected (
|
||||
} else if (Dr6.Bits.B3 == 1) {
|
||||
BreakpointNumber = 4;
|
||||
} else {
|
||||
BreakpointNumber = 0; //No breakpoint detected
|
||||
BreakpointNumber = 0; //No breakpoint detected
|
||||
}
|
||||
|
||||
return BreakpointNumber;
|
||||
@@ -454,13 +454,13 @@ GetBreakpointDetected (
|
||||
/**
|
||||
Returns Breakpoint type (InstructionExecution, DataWrite, DataRead or DataReadWrite)
|
||||
based on the Breakpoint number
|
||||
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param BreakpointNumber Breakpoint number
|
||||
|
||||
|
||||
@retval BREAK_TYPE Breakpoint type value read from register DR7 RWn field
|
||||
For unknown value, it returns NotSupported.
|
||||
|
||||
|
||||
**/
|
||||
BREAK_TYPE
|
||||
GetBreakpointType (
|
||||
@@ -474,22 +474,22 @@ GetBreakpointType (
|
||||
Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
|
||||
|
||||
if (BreakpointNumber == 1) {
|
||||
Type = (BREAK_TYPE) Dr7.Bits.RW0;
|
||||
Type = (BREAK_TYPE) Dr7.Bits.RW0;
|
||||
} else if (BreakpointNumber == 2) {
|
||||
Type = (BREAK_TYPE) Dr7.Bits.RW1;
|
||||
Type = (BREAK_TYPE) Dr7.Bits.RW1;
|
||||
} else if (BreakpointNumber == 3) {
|
||||
Type = (BREAK_TYPE) Dr7.Bits.RW2;
|
||||
Type = (BREAK_TYPE) Dr7.Bits.RW2;
|
||||
} else if (BreakpointNumber == 4) {
|
||||
Type = (BREAK_TYPE) Dr7.Bits.RW3;
|
||||
Type = (BREAK_TYPE) Dr7.Bits.RW3;
|
||||
}
|
||||
|
||||
return Type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
Parses Length and returns the length which DR7 LENn field accepts.
|
||||
For example: If we receive 1-Byte length then we should return 0.
|
||||
For example: If we receive 1-Byte length then we should return 0.
|
||||
Zero gets written to DR7 LENn field.
|
||||
|
||||
@param Length Breakpoint length in Bytes (1 byte, 2 byte, 4 byte)
|
||||
@@ -502,7 +502,7 @@ ConvertLengthData (
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
if (Length == 1) { //1-Byte length
|
||||
if (Length == 1) { //1-Byte length
|
||||
return 0;
|
||||
} else if (Length == 2) { //2-Byte length
|
||||
return 1;
|
||||
@@ -515,8 +515,8 @@ ConvertLengthData (
|
||||
|
||||
|
||||
/**
|
||||
Finds the next free debug register. If all the registers are occupied then
|
||||
EFI_OUT_OF_RESOURCES is returned.
|
||||
Finds the next free debug register. If all the registers are occupied then
|
||||
EFI_OUT_OF_RESOURCES is returned.
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param Register Register value (0 - 3 for the first free debug register)
|
||||
@@ -553,11 +553,11 @@ FindNextFreeDebugRegister (
|
||||
/**
|
||||
Enables the debug register. Writes Address value to appropriate DR0-3 register.
|
||||
Sets LENn, Gn, RWn bits in DR7 register.
|
||||
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param Register Register value (0 - 3)
|
||||
@param Register Register value (0 - 3)
|
||||
@param Address Breakpoint address value
|
||||
@param Type Breakpoint type (Instruction, Data write, Data read
|
||||
@param Type Breakpoint type (Instruction, Data write, Data read
|
||||
or write etc.)
|
||||
|
||||
@retval EFI_STATUS Appropriate status value.
|
||||
@@ -577,15 +577,15 @@ EnableDebugRegister (
|
||||
//Convert length data
|
||||
Length = ConvertLengthData (Length);
|
||||
|
||||
//For Instruction execution, length should be 0
|
||||
//For Instruction execution, length should be 0
|
||||
//(Ref. Intel reference manual 18.2.4)
|
||||
if ((Type == 0) && (Length != 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
||||
//Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
|
||||
//software breakpoint. We should send empty packet in both these cases.
|
||||
if ((Type == (BREAK_TYPE)DataRead) ||
|
||||
if ((Type == (BREAK_TYPE)DataRead) ||
|
||||
(Type == (BREAK_TYPE)SoftwareBreakpoint)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
@@ -617,7 +617,7 @@ EnableDebugRegister (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//Update Dr7 with appropriate Gn, RWn and LENn bits
|
||||
//Update Dr7 with appropriate Gn, RWn and LENn bits
|
||||
SystemContext.SystemContextIa32->Dr7 = Dr7.UintN;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@@ -633,7 +633,7 @@ EnableDebugRegister (
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param Address Breakpoint address value
|
||||
@param Length Breakpoint length value
|
||||
@param Type Breakpoint type (Instruction, Data write,
|
||||
@param Type Breakpoint type (Instruction, Data write,
|
||||
Data read or write etc.)
|
||||
@param Register Register value to be returned
|
||||
|
||||
@@ -653,7 +653,7 @@ FindMatchingDebugRegister (
|
||||
|
||||
//Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
|
||||
//software breakpoint. We should send empty packet in both these cases.
|
||||
if ((Type == (BREAK_TYPE)DataRead) ||
|
||||
if ((Type == (BREAK_TYPE)DataRead) ||
|
||||
(Type == (BREAK_TYPE)SoftwareBreakpoint)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
@@ -663,24 +663,24 @@ FindMatchingDebugRegister (
|
||||
|
||||
Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
|
||||
|
||||
if ((Dr7.Bits.G0 == 1) &&
|
||||
if ((Dr7.Bits.G0 == 1) &&
|
||||
(Dr7.Bits.LEN0 == Length) &&
|
||||
(Dr7.Bits.RW0 == Type) &&
|
||||
(Dr7.Bits.RW0 == Type) &&
|
||||
(Address == SystemContext.SystemContextIa32->Dr0)) {
|
||||
*Register = 0;
|
||||
} else if ((Dr7.Bits.G1 == 1) &&
|
||||
} else if ((Dr7.Bits.G1 == 1) &&
|
||||
(Dr7.Bits.LEN1 == Length) &&
|
||||
(Dr7.Bits.RW1 == Type) &&
|
||||
(Dr7.Bits.RW1 == Type) &&
|
||||
(Address == SystemContext.SystemContextIa32->Dr1)) {
|
||||
*Register = 1;
|
||||
} else if ((Dr7.Bits.G2 == 1) &&
|
||||
} else if ((Dr7.Bits.G2 == 1) &&
|
||||
(Dr7.Bits.LEN2 == Length) &&
|
||||
(Dr7.Bits.RW2 == Type) &&
|
||||
(Dr7.Bits.RW2 == Type) &&
|
||||
(Address == SystemContext.SystemContextIa32->Dr2)) {
|
||||
*Register = 2;
|
||||
} else if ((Dr7.Bits.G3 == 1) &&
|
||||
} else if ((Dr7.Bits.G3 == 1) &&
|
||||
(Dr7.Bits.LEN3 == Length) &&
|
||||
(Dr7.Bits.RW3 == Type) &&
|
||||
(Dr7.Bits.RW3 == Type) &&
|
||||
(Address == SystemContext.SystemContextIa32->Dr3)) {
|
||||
*Register = 3;
|
||||
} else {
|
||||
@@ -704,12 +704,12 @@ FindMatchingDebugRegister (
|
||||
EFI_STATUS
|
||||
DisableDebugRegister (
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext,
|
||||
IN UINTN Register
|
||||
IN UINTN Register
|
||||
)
|
||||
{
|
||||
IA32_DR7 Dr7;
|
||||
UINTN Address = 0;
|
||||
|
||||
|
||||
//Read DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
|
||||
Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
|
||||
|
||||
@@ -863,15 +863,15 @@ RemoveBreakPoint (
|
||||
}
|
||||
|
||||
switch (Type) {
|
||||
|
||||
|
||||
case 0: //Software breakpoint
|
||||
BreakType = SoftwareBreakpoint;
|
||||
break;
|
||||
|
||||
|
||||
case 1: //Hardware breakpoint
|
||||
BreakType = InstructionExecution;
|
||||
break;
|
||||
|
||||
|
||||
case 2: //Write watchpoint
|
||||
BreakType = DataWrite;
|
||||
break;
|
||||
|
@@ -2,7 +2,7 @@
|
||||
Processor specific parts of the GDB stub
|
||||
|
||||
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
||||
|
||||
|
||||
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
|
||||
@@ -19,7 +19,7 @@
|
||||
// Array of exception types that need to be hooked by the debugger
|
||||
//
|
||||
EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
|
||||
{ EXCEPT_X64_DIVIDE_ERROR, GDB_SIGFPE },
|
||||
{ EXCEPT_X64_DIVIDE_ERROR, GDB_SIGFPE },
|
||||
{ EXCEPT_X64_DEBUG, GDB_SIGTRAP },
|
||||
{ EXCEPT_X64_NMI, GDB_SIGEMT },
|
||||
{ EXCEPT_X64_BREAKPOINT, GDB_SIGTRAP },
|
||||
@@ -37,7 +37,7 @@ EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
|
||||
|
||||
|
||||
// The offsets of registers SystemContextX64.
|
||||
// The fields in the array are in the gdb ordering.
|
||||
// The fields in the array are in the gdb ordering.
|
||||
// HAVE TO DOUBLE-CHECK THE ORDER of the 24 regs
|
||||
//
|
||||
UINTN gRegisterOffsets[] = {
|
||||
@@ -70,8 +70,8 @@ UINTN gRegisterOffsets[] = {
|
||||
|
||||
/**
|
||||
Return the number of entries in the gExceptionType[]
|
||||
|
||||
@retval UINTN, the number of entries in the gExceptionType[] array.
|
||||
|
||||
@retval UINTN, the number of entries in the gExceptionType[] array.
|
||||
**/
|
||||
UINTN
|
||||
MaxEfiException (
|
||||
@@ -84,8 +84,8 @@ MaxEfiException (
|
||||
|
||||
/**
|
||||
Return the number of entries in the gRegisters[]
|
||||
|
||||
@retval UINTN, the number of entries (registers) in the gRegisters[] array.
|
||||
|
||||
@retval UINTN, the number of entries (registers) in the gRegisters[] array.
|
||||
**/
|
||||
UINTN
|
||||
MaxRegisterCount (
|
||||
@@ -95,9 +95,9 @@ MaxRegisterCount (
|
||||
return sizeof (gRegisterOffsets)/sizeof (UINTN);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Check to see if the ISA is supported.
|
||||
Check to see if the ISA is supported.
|
||||
ISA = Instruction Set Architecture
|
||||
|
||||
@retval TRUE if Isa is supported
|
||||
@@ -114,14 +114,14 @@ CheckIsa (
|
||||
/**
|
||||
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
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param RegNumber The register to which we want to find a pointer
|
||||
@retval the pointer to the RegNumber-th pointer
|
||||
**/
|
||||
UINTN *
|
||||
FindPointerToRegister(
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext,
|
||||
IN UINTN RegNumber
|
||||
IN UINTN RegNumber
|
||||
)
|
||||
{
|
||||
UINT8 *TempPtr;
|
||||
@@ -145,7 +145,7 @@ BasicReadRegister (
|
||||
)
|
||||
{
|
||||
UINTN RegSize;
|
||||
|
||||
|
||||
RegSize = 0;
|
||||
while (RegSize < 64) {
|
||||
*OutBufPtr++ = mHexToStr[((*FindPointerToRegister(SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
|
||||
@@ -156,8 +156,8 @@ BasicReadRegister (
|
||||
}
|
||||
|
||||
|
||||
/** ‘p n’
|
||||
Reads the n-th register's value into an output buffer and sends it as a packet
|
||||
/** ‘p n’
|
||||
Reads the n-th register's value into an output buffer and sends it as a packet
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param InBuffer Pointer to the input buffer received from gdb server
|
||||
**/
|
||||
@@ -170,42 +170,42 @@ ReadNthRegister (
|
||||
UINTN RegNumber;
|
||||
CHAR8 OutBuffer[17]; // 1 reg=16 hex chars, and the end '\0' (escape seq)
|
||||
CHAR8 *OutBufPtr; // pointer to the output buffer
|
||||
|
||||
|
||||
RegNumber = AsciiStrHexToUintn (&InBuffer[1]);
|
||||
|
||||
|
||||
if ((RegNumber < 0) || (RegNumber >= MaxRegisterCount())) {
|
||||
SendError (GDB_EINVALIDREGNUM);
|
||||
SendError (GDB_EINVALIDREGNUM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
OutBufPtr = OutBuffer;
|
||||
OutBufPtr = BasicReadRegister(SystemContext, RegNumber, OutBufPtr);
|
||||
|
||||
|
||||
*OutBufPtr = '\0'; // the end of the buffer
|
||||
SendPacket (OutBuffer);
|
||||
}
|
||||
|
||||
|
||||
/** ‘g’
|
||||
Reads the general registers into an output buffer and sends it as a packet
|
||||
/** ‘g’
|
||||
Reads the general registers into an output buffer and sends it as a packet
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
ReadGeneralRegisters (
|
||||
ReadGeneralRegisters (
|
||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||
)
|
||||
{
|
||||
UINTN i;
|
||||
CHAR8 OutBuffer[385]; // 24 regs, 16 hex chars each, and the end '\0' (escape seq)
|
||||
CHAR8 *OutBufPtr; // pointer to the output buffer
|
||||
|
||||
|
||||
OutBufPtr = OutBuffer;
|
||||
for(i = 0 ; i < MaxRegisterCount() ; i++) { // there are only 24 registers to read
|
||||
for(i = 0 ; i < MaxRegisterCount() ; i++) { // there are only 24 registers to read
|
||||
OutBufPtr = BasicReadRegister(SystemContext, i, OutBufPtr);
|
||||
}
|
||||
|
||||
|
||||
*OutBufPtr = '\0'; // the end of the buffer
|
||||
SendPacket (OutBuffer);
|
||||
}
|
||||
@@ -229,26 +229,26 @@ BasicWriteRegister (
|
||||
UINTN RegSize;
|
||||
UINTN TempValue; // the value transferred from a hex char
|
||||
UINT64 NewValue; // the new value of the RegNumber-th Register
|
||||
|
||||
|
||||
NewValue = 0;
|
||||
RegSize = 0;
|
||||
while (RegSize < 64) {
|
||||
TempValue = HexCharToInt(*InBufPtr++);
|
||||
|
||||
|
||||
if (TempValue < 0) {
|
||||
SendError (GDB_EBADMEMDATA);
|
||||
SendError (GDB_EBADMEMDATA);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
NewValue += (TempValue << (RegSize+4));
|
||||
TempValue = HexCharToInt(*InBufPtr++);
|
||||
|
||||
|
||||
if (TempValue < 0) {
|
||||
SendError (GDB_EBADMEMDATA);
|
||||
SendError (GDB_EBADMEMDATA);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NewValue += (TempValue << RegSize);
|
||||
|
||||
NewValue += (TempValue << RegSize);
|
||||
RegSize = RegSize + 8;
|
||||
}
|
||||
*(FindPointerToRegister(SystemContext, RegNumber)) = NewValue;
|
||||
@@ -273,19 +273,19 @@ WriteNthRegister (
|
||||
CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE]; // put the 'n..' part of the message into this array
|
||||
CHAR8 *RegNumBufPtr;
|
||||
CHAR8 *InBufPtr; // pointer to the input buffer
|
||||
|
||||
|
||||
// find the register number to write
|
||||
InBufPtr = &InBuffer[1];
|
||||
RegNumBufPtr = RegNumBuffer;
|
||||
while (*InBufPtr != '=') {
|
||||
*RegNumBufPtr++ = *InBufPtr++;
|
||||
}
|
||||
}
|
||||
*RegNumBufPtr = '\0';
|
||||
RegNumber = AsciiStrHexToUintn (RegNumBuffer);
|
||||
RegNumber = AsciiStrHexToUintn (RegNumBuffer);
|
||||
|
||||
// check if this is a valid Register Number
|
||||
if ((RegNumber < 0) || (RegNumber >= MaxRegisterCount())) {
|
||||
SendError (GDB_EINVALIDREGNUM);
|
||||
SendError (GDB_EINVALIDREGNUM);
|
||||
return;
|
||||
}
|
||||
InBufPtr++; // skips the '=' character
|
||||
@@ -309,30 +309,30 @@ WriteGeneralRegisters (
|
||||
{
|
||||
UINTN i;
|
||||
CHAR8 *InBufPtr; /// pointer to the input buffer
|
||||
|
||||
// check to see if the buffer is the right size which is
|
||||
// 1 (for 'G') + 16 (for 16 registers) * 8 ( for 8 hex chars each) = 385
|
||||
|
||||
// check to see if the buffer is the right size which is
|
||||
// 1 (for 'G') + 16 (for 16 registers) * 8 ( for 8 hex chars each) = 385
|
||||
if (AsciiStrLen(InBuffer) != 385) { // 24 regs, 16 hex chars each, and the end '\0' (escape seq)
|
||||
//Bad message. Message is not the right length
|
||||
SendError (GDB_EBADBUFSIZE);
|
||||
//Bad message. Message is not the right length
|
||||
SendError (GDB_EBADBUFSIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
InBufPtr = &InBuffer[1];
|
||||
|
||||
|
||||
// Read the new values for the registers from the input buffer to an array, NewValueArray.
|
||||
// The values in the array are in the gdb ordering
|
||||
for(i=0; i < MaxRegisterCount(); i++) { // there are only 16 registers to write
|
||||
InBufPtr = BasicWriteRegister(SystemContext, i, InBufPtr);
|
||||
}
|
||||
|
||||
|
||||
SendSuccess();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
Insert Single Step in the SystemContext
|
||||
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
**/
|
||||
VOID
|
||||
@@ -343,11 +343,11 @@ AddSingleStep (
|
||||
SystemContext.SystemContextX64->Rflags |= TF_BIT; //Setting the TF bit.
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
|
||||
/**
|
||||
Remove Single Step in the SystemContext
|
||||
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
**/
|
||||
VOID
|
||||
@@ -360,11 +360,11 @@ RemoveSingleStep (
|
||||
|
||||
|
||||
|
||||
/** ‘c [addr ]’
|
||||
Continue. addr is Address to resume. If addr is omitted, resume at current
|
||||
/** ‘c [addr ]’
|
||||
Continue. addr is Address to resume. If addr is omitted, resume at current
|
||||
Address.
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
@@ -375,15 +375,15 @@ ContinueAtAddress (
|
||||
{
|
||||
if (PacketData[1] != '\0') {
|
||||
SystemContext.SystemContextX64->Rip = AsciiStrHexToUintn(&PacketData[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** ‘s [addr ]’
|
||||
Single step. addr is the Address at which to resume. If addr is omitted, resume
|
||||
Single step. addr is the Address at which to resume. If addr is omitted, resume
|
||||
at same Address.
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
@@ -395,19 +395,19 @@ SingleStep (
|
||||
if (PacketData[1] != '\0') {
|
||||
SystemContext.SystemContextX64->Rip = AsciiStrHexToUintn (&PacketData[1]);
|
||||
}
|
||||
|
||||
|
||||
AddSingleStep (SystemContext);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Returns breakpoint data address from DR0-DR3 based on the input breakpoint
|
||||
Returns breakpoint data address from DR0-DR3 based on the input breakpoint
|
||||
number
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param BreakpointNumber Breakpoint number
|
||||
|
||||
@retval Address Data address from DR0-DR3 based on the
|
||||
@retval Address Data address from DR0-DR3 based on the
|
||||
breakpoint number.
|
||||
|
||||
**/
|
||||
@@ -435,7 +435,7 @@ GetBreakpointDataAddress (
|
||||
}
|
||||
|
||||
/**
|
||||
Returns currently detected breakpoint value based on the register
|
||||
Returns currently detected breakpoint value based on the register
|
||||
DR6 B0-B3 field.
|
||||
If no breakpoint is detected then it returns 0.
|
||||
|
||||
@@ -471,13 +471,13 @@ GetBreakpointDetected (
|
||||
}
|
||||
|
||||
/**
|
||||
Returns Breakpoint type (InstructionExecution, DataWrite, DataRead
|
||||
Returns Breakpoint type (InstructionExecution, DataWrite, DataRead
|
||||
or DataReadWrite) based on the Breakpoint number
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param BreakpointNumber Breakpoint number
|
||||
|
||||
@retval BREAK_TYPE Breakpoint type value read from register DR7 RWn
|
||||
@retval BREAK_TYPE Breakpoint type value read from register DR7 RWn
|
||||
field. For unknown value, it returns NotSupported.
|
||||
|
||||
**/
|
||||
@@ -506,9 +506,9 @@ GetBreakpointType (
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
Parses Length and returns the length which DR7 LENn field accepts.
|
||||
For example: If we receive 1-Byte length then we should return 0.
|
||||
For example: If we receive 1-Byte length then we should return 0.
|
||||
Zero gets written to DR7 LENn field.
|
||||
|
||||
@param Length Breakpoint length in Bytes (1 byte, 2 byte, 4 byte)
|
||||
@@ -521,7 +521,7 @@ ConvertLengthData (
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
if (Length == 1) { //1-Byte length
|
||||
if (Length == 1) { //1-Byte length
|
||||
return 0;
|
||||
} else if (Length == 2) { //2-Byte length
|
||||
return 1;
|
||||
@@ -576,7 +576,7 @@ FindNextFreeDebugRegister (
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param Register Register value (0 - 3)
|
||||
@param Address Breakpoint address value
|
||||
@param Type Breakpoint type (Instruction, Data write,
|
||||
@param Type Breakpoint type (Instruction, Data write,
|
||||
Data read or write etc.)
|
||||
|
||||
@retval EFI_STATUS Appropriate status value.
|
||||
@@ -596,7 +596,7 @@ EnableDebugRegister (
|
||||
//Convert length data
|
||||
Length = ConvertLengthData (Length);
|
||||
|
||||
//For Instruction execution, length should be 0
|
||||
//For Instruction execution, length should be 0
|
||||
//(Ref. Intel reference manual 18.2.4)
|
||||
if ((Type == 0) && (Length != 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -604,7 +604,7 @@ EnableDebugRegister (
|
||||
|
||||
//Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
|
||||
//software breakpoint. We should send empty packet in both these cases.
|
||||
if ((Type == (BREAK_TYPE)DataRead) ||
|
||||
if ((Type == (BREAK_TYPE)DataRead) ||
|
||||
(Type == (BREAK_TYPE)SoftwareBreakpoint)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
@@ -643,14 +643,14 @@ EnableDebugRegister (
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Returns register number 0 - 3 for the maching debug register.
|
||||
This function compares incoming Address, Type, Length and
|
||||
/**
|
||||
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.
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param Address Breakpoint address value
|
||||
@param Address Breakpoint address value
|
||||
@param Length Breakpoint length value
|
||||
@param Type Breakpoint type (Instruction, Data write, Data read
|
||||
or write etc.)
|
||||
@@ -672,7 +672,7 @@ FindMatchingDebugRegister (
|
||||
|
||||
//Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
|
||||
//software breakpoint. We should send empty packet in both these cases.
|
||||
if ((Type == (BREAK_TYPE)DataRead) ||
|
||||
if ((Type == (BREAK_TYPE)DataRead) ||
|
||||
(Type == (BREAK_TYPE)SoftwareBreakpoint)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
@@ -682,24 +682,24 @@ FindMatchingDebugRegister (
|
||||
|
||||
Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
|
||||
|
||||
if ((Dr7.Bits.G0 == 1) &&
|
||||
if ((Dr7.Bits.G0 == 1) &&
|
||||
(Dr7.Bits.LEN0 == Length) &&
|
||||
(Dr7.Bits.RW0 == Type) &&
|
||||
(Dr7.Bits.RW0 == Type) &&
|
||||
(Address == SystemContext.SystemContextIa32->Dr0)) {
|
||||
*Register = 0;
|
||||
} else if ((Dr7.Bits.G1 == 1) &&
|
||||
} else if ((Dr7.Bits.G1 == 1) &&
|
||||
(Dr7.Bits.LEN1 == Length) &&
|
||||
(Dr7.Bits.RW1 == Type) &&
|
||||
(Dr7.Bits.RW1 == Type) &&
|
||||
(Address == SystemContext.SystemContextIa32->Dr1)) {
|
||||
*Register = 1;
|
||||
} else if ((Dr7.Bits.G2 == 1) &&
|
||||
} else if ((Dr7.Bits.G2 == 1) &&
|
||||
(Dr7.Bits.LEN2 == Length) &&
|
||||
(Dr7.Bits.RW2 == Type) &&
|
||||
(Dr7.Bits.RW2 == Type) &&
|
||||
(Address == SystemContext.SystemContextIa32->Dr2)) {
|
||||
*Register = 2;
|
||||
} else if ((Dr7.Bits.G3 == 1) &&
|
||||
} else if ((Dr7.Bits.G3 == 1) &&
|
||||
(Dr7.Bits.LEN3 == Length) &&
|
||||
(Dr7.Bits.RW3 == Type) &&
|
||||
(Dr7.Bits.RW3 == Type) &&
|
||||
(Address == SystemContext.SystemContextIa32->Dr3)) {
|
||||
*Register = 3;
|
||||
} else {
|
||||
@@ -884,15 +884,15 @@ RemoveBreakPoint (
|
||||
}
|
||||
|
||||
switch (Type) {
|
||||
|
||||
|
||||
case 0: //Software breakpoint
|
||||
BreakType = SoftwareBreakpoint;
|
||||
break;
|
||||
|
||||
|
||||
case 1: //Hardware breakpoint
|
||||
BreakType = InstructionExecution;
|
||||
break;
|
||||
|
||||
|
||||
case 2: //Write watchpoint
|
||||
BreakType = DataWrite;
|
||||
break;
|
||||
@@ -954,8 +954,8 @@ ValidateAddress (
|
||||
|
||||
BOOLEAN
|
||||
ValidateException (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
)
|
||||
{
|
||||
return TRUE;
|
||||
|
Reference in New Issue
Block a user