diff options
author | andrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-02-01 18:59:27 +0000 |
---|---|---|
committer | andrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-02-01 18:59:27 +0000 |
commit | f9f937d243c8c9615119be2f2b35821e7de80925 (patch) | |
tree | 9cad5d4666d93113120355e7267bf891830ae199 /ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c | |
parent | 097bd461c4219edb62f4595ce7ccc6ec3bb34db9 (diff) | |
download | edk2-f9f937d243c8c9615119be2f2b35821e7de80925.zip edk2-f9f937d243c8c9615119be2f2b35821e7de80925.tar.gz edk2-f9f937d243c8c9615119be2f2b35821e7de80925.tar.bz2 |
Move ARM disassembler into a library and out of the exception handler. Add a hook to call the lib from a platform specific EBL command on BeagleBoard.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9903 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c')
-rw-r--r-- | ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c b/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c index d59d103..25cb8ae 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);
}
}
|