diff options
Diffstat (limited to 'EmbeddedPkg/GdbStub/Arm')
-rw-r--r-- | EmbeddedPkg/GdbStub/Arm/Processor.c | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/EmbeddedPkg/GdbStub/Arm/Processor.c b/EmbeddedPkg/GdbStub/Arm/Processor.c index 38abb69d7e..80803b2d91 100644 --- a/EmbeddedPkg/GdbStub/Arm/Processor.c +++ b/EmbeddedPkg/GdbStub/Arm/Processor.c @@ -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
@@ -23,10 +23,10 @@ //
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_DATA_ABORT, GDB_SIGEMT },
-// { EXCEPT_ARM_RESERVED, GDB_SIGILL }
+// { EXCEPT_ARM_UNDEFINED_INSTRUCTION, GDB_SIGTRAP },
+// { EXCEPT_ARM_PREFETCH_ABORT, GDB_SIGTRAP },
+// { EXCEPT_ARM_DATA_ABORT, GDB_SIGEMT },
+// { EXCEPT_ARM_RESERVED, GDB_SIGILL }
};
// Shut up some annoying RVCT warnings
@@ -86,8 +86,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 (
@@ -100,8 +100,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 (
@@ -113,10 +113,10 @@ MaxRegisterCount ( /**
- 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
@@ -135,14 +135,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;
@@ -168,7 +168,7 @@ BasicReadRegister ( {
UINTN RegSize;
CHAR8 Char;
-
+
if (gRegisterOffsets[RegNumber] > 0xF00) {
AsciiSPrint (OutBufPtr, 9, "00000000");
OutBufPtr += 8;
@@ -182,13 +182,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;
@@ -196,7 +196,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
**/
@@ -209,29 +209,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 >= MaxRegisterCount ()) {
- 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
)
{
@@ -239,14 +239,14 @@ ReadGeneralRegisters ( CHAR8 *OutBuffer;
CHAR8 *OutBufPtr;
UINTN RegisterCount = MaxRegisterCount ();
-
+
// It is not safe to allocate pool here....
OutBuffer = AllocatePool ((RegisterCount * 8) + 1); // 8 bytes per register in string format plus a null to terminate
OutBufPtr = OutBuffer;
for (Index = 0; Index < RegisterCount; Index++) {
OutBufPtr = BasicReadRegister (SystemContext, Index, OutBufPtr);
}
-
+
*OutBufPtr = '\0';
SendPacket (OutBuffer);
FreePool (OutBuffer);
@@ -270,7 +270,7 @@ CHAR8 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;
}
@@ -279,21 +279,21 @@ CHAR8 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;
@@ -316,19 +316,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 >= MaxRegisterCount ()) {
- SendError (GDB_EINVALIDREGNUM);
+ SendError (GDB_EINVALIDREGNUM);
return;
}
InBufPtr++; // skips the '=' character
@@ -356,21 +356,21 @@ WriteGeneralRegisters ( UINTN RegisterCount = MaxRegisterCount ();
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 ();
}
@@ -395,9 +395,9 @@ typedef struct { LIST_ENTRY BreakpointList;
-/**
+/**
Insert Single Step in the SystemContext
-
+
@param SystemContext Register content at time of the exception
**/
VOID
@@ -410,11 +410,11 @@ AddSingleStep ( return;
}
mSingleStepActive = TRUE;
-
+
mSingleStepPC = SystemContext.SystemContextArm->PC;
mSingleStepDataSize = sizeof (UINT32);
- mSingleStepData = (*(UINT32 *)mSingleStepPC);
+ mSingleStepData = (*(UINT32 *)mSingleStepPC);
*(UINT32 *)mSingleStepPC = GDB_ARM_BKPT;
if (*(UINT32 *)mSingleStepPC != GDB_ARM_BKPT) {
// For some reason our breakpoint did not take
@@ -425,10 +425,10 @@ AddSingleStep ( //DEBUG((EFI_D_ERROR, "AddSingleStep at 0x%08x (was: 0x%08x is:0x%08x)\n", SystemContext.SystemContextArm->PC, mSingleStepData, *(UINT32 *)mSingleStepPC));
}
-
-/**
+
+/**
Remove Single Step in the SystemContext
-
+
@param SystemContext Register content at time of the exception
**/
VOID
@@ -439,7 +439,7 @@ RemoveSingleStep ( if (!mSingleStepActive) {
return;
}
-
+
if (mSingleStepDataSize == sizeof (UINT16)) {
*(UINT16 *)mSingleStepPC = (UINT16)mSingleStepData;
} else {
@@ -453,10 +453,10 @@ RemoveSingleStep ( /**
- 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
@@ -467,15 +467,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
@@ -554,7 +554,7 @@ SetBreakpoint ( Breakpoint->Signature = ARM_SOFTWARE_BREAKPOINT_SIGNATURE;
Breakpoint->Address = Address;
Breakpoint->Instruction = *(UINT32 *)Address;
-
+
// Add it to the list
InsertTailList (&BreakpointList, &Breakpoint->Link);
@@ -645,7 +645,7 @@ RemoveBreakPoint ( switch (Type) {
case 0: //Software breakpoint
break;
-
+
default:
SendError (GDB_EINVALIDBRKPOINTTYPE);
return;
@@ -679,13 +679,13 @@ 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
)
{
UINT32 ExceptionAddress;
UINT32 Instruction;
-
+
// Is it a debugger SWI?
ExceptionAddress = SystemContext.SystemContextArm->PC -= 4;
Instruction = *(UINT32 *)ExceptionAddress;
|