diff options
Diffstat (limited to 'ArmPkg')
4 files changed, 37 insertions, 8 deletions
diff --git a/ArmPkg/Include/Library/ArmDisassemblerLib.h b/ArmPkg/Include/Library/ArmDisassemblerLib.h index 6ba270fea3..4a3c68c2e3 100644 --- a/ArmPkg/Include/Library/ArmDisassemblerLib.h +++ b/ArmPkg/Include/Library/ArmDisassemblerLib.h @@ -24,6 +24,7 @@ @param OpCodePtrPtr Pointer to pointer of ARM Thumb instruction to disassemble. @param Thumb TRUE for Thumb(2), FALSE for ARM instruction stream + @param Extended TRUE dump hex for instruction too. @param Buf Buffer to sprintf disassembly into. @param Size Size of Buf in bytes. @@ -32,6 +33,7 @@ VOID DisassembleInstruction ( IN UINT8 **OpCodePtr, IN BOOLEAN Thumb, + IN BOOLEAN Extended, OUT CHAR8 *Buf, OUT UINTN Size ); diff --git a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c index 5b43f5542e..c3eecbcbcb 100644 --- a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c +++ b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c @@ -154,13 +154,15 @@ RotateRight ( @param OpCodePtr Pointer to pointer of ARM instruction to disassemble.
@param Buf Buffer to sprintf disassembly into.
@param Size Size of Buf in bytes.
+ @param Extended TRUE dump hex for instruction too.
**/
VOID
DisassembleArmInstruction (
IN UINT32 **OpCodePtr,
OUT CHAR8 *Buf,
- OUT UINTN Size
+ OUT UINTN Size,
+ IN BOOLEAN Extended
)
{
UINT32 OpCode = **OpCodePtr;
@@ -183,6 +185,13 @@ DisassembleArmInstruction ( Rd = (OpCode >> 12) & 0xf;
Rm = (OpCode & 0xf);
+
+ if (Extended) {
+ Index = AsciiSPrint (Buf, Size, "0x%08x ", OpCode);
+ Buf += Index;
+ Size -= Index;
+ }
+
// LDREX, STREX
if ((OpCode & 0x0fe000f0) == 0x01800090) {
if (L) {
diff --git a/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c b/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c index d59d1030fc..25cb8ae470 100644 --- a/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c +++ b/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c @@ -263,13 +263,15 @@ SignExtend ( @param OpCodePtrPtr Pointer to pointer of ARM Thumb instruction to disassemble.
@param Buf Buffer to sprintf disassembly into.
@param Size Size of Buf in bytes.
+ @param Extended TRUE dump hex for instruction too.
**/
VOID
DisassembleThumbInstruction (
IN UINT16 **OpCodePtrPtr,
OUT CHAR8 *Buf,
- OUT UINTN Size
+ OUT UINTN Size,
+ IN BOOLEAN Extended
)
{
UINT16 *OpCodePtr;
@@ -302,7 +304,11 @@ DisassembleThumbInstruction ( for (Index = 0; Index < sizeof (gOpThumb)/sizeof (THUMB_INSTRUCTIONS); Index++) {
if ((OpCode & gOpThumb[Index].Mask) == gOpThumb[Index].OpCode) {
- Offset = AsciiSPrint (Buf, Size, "%a", gOpThumb[Index].Start);
+ if (Extended) {
+ Offset = AsciiSPrint (Buf, Size, "0x%04x %a", OpCode, gOpThumb[Index].Start);
+ } else {
+ Offset = AsciiSPrint (Buf, Size, "%a", gOpThumb[Index].Start);
+ }
switch (gOpThumb[Index].AddressMode) {
case LOAD_STORE_FORMAT1:
// A6.5.1 <Rd>, [<Rn>, #<5_bit_offset>]
@@ -414,12 +420,21 @@ DisassembleThumbInstruction ( *OpCodePtrPtr += 1;
for (Index = 0; Index < sizeof (gOpThumb2)/sizeof (THUMB_INSTRUCTIONS); Index++) {
if ((OpCode32 & gOpThumb2[Index].Mask) == gOpThumb2[Index].OpCode) {
+ if (Extended) {
+ Offset = AsciiSPrint (Buf, Size, "0x%04x %a", OpCode32, gOpThumb2[Index].Start);
+ } else {
+ Offset = AsciiSPrint (Buf, Size, "%a", gOpThumb2[Index].Start);
+ }
+ switch (gOpThumb2[Index].AddressMode) {
+ }
}
}
#endif
// Unknown instruction is 16-bits
*OpCodePtrPtr -= 1;
- AsciiSPrint (Buf, Size, "0x%04x", OpCode);
+ if (!Extended) {
+ AsciiSPrint (Buf, Size, "0x%04x", OpCode);
+ }
}
@@ -428,7 +443,8 @@ VOID DisassembleArmInstruction (
IN UINT32 **OpCodePtr,
OUT CHAR8 *Buf,
- OUT UINTN Size
+ OUT UINTN Size,
+ IN BOOLEAN Extended
);
@@ -441,6 +457,7 @@ DisassembleArmInstruction ( @param OpCodePtrPtr Pointer to pointer of ARM Thumb instruction to disassemble.
@param Thumb TRUE for Thumb(2), FALSE for ARM instruction stream
+ @param Extended TRUE dump hex for instruction too.
@param Buf Buffer to sprintf disassembly into.
@param Size Size of Buf in bytes.
@@ -449,14 +466,15 @@ VOID DisassembleInstruction (
IN UINT8 **OpCodePtr,
IN BOOLEAN Thumb,
+ IN BOOLEAN Extended,
OUT CHAR8 *Buf,
OUT UINTN Size
)
{
if (Thumb) {
- DisassembleThumbInstruction ((UINT16 **)OpCodePtr, Buf, Size);
+ DisassembleThumbInstruction ((UINT16 **)OpCodePtr, Buf, Size, Extended);
} else {
- DisassembleArmInstruction ((UINT32 **)OpCodePtr, Buf, Size);
+ DisassembleArmInstruction ((UINT32 **)OpCodePtr, Buf, Size, Extended);
}
}
diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandler.c index b6fbb19f46..a0f327d654 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandler.c @@ -256,7 +256,7 @@ DefaultExceptionHandler ( // If we come from an image it is safe to show the instruction. We know it should not fault
DisAsm = (UINT8 *)(UINTN)SystemContext.SystemContextArm->PC;
- DisassembleInstruction (&DisAsm, (SystemContext.SystemContextArm->CPSR & BIT5) == BIT5, Buffer, sizeof (Buffer));
+ DisassembleInstruction (&DisAsm, (SystemContext.SystemContextArm->CPSR & BIT5) == BIT5, TRUE, Buffer, sizeof (Buffer));
DEBUG ((EFI_D_ERROR, "\n%a", Buffer));
}
|