arm_dyncom_thumb.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Copyright (C)
  2. * 2011 - Michael.Kang blackfin.kang@gmail.com
  3. * This program is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU General Public License
  5. * as published by the Free Software Foundation; either version 2
  6. * of the License, or (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  16. *
  17. */
  18. /**
  19. * @file arm_dyncom_thumb.h
  20. * @brief The thumb dyncom
  21. * @author Michael.Kang blackfin.kang@gmail.com
  22. * @version 78.77
  23. * @date 2011-11-07
  24. */
  25. #pragma once
  26. #include "common/common_types.h"
  27. enum class ThumbDecodeStatus {
  28. UNDEFINED, // Undefined Thumb instruction
  29. DECODED, // Instruction decoded to ARM equivalent
  30. BRANCH, // Thumb branch (already processed)
  31. UNINITIALIZED,
  32. };
  33. // Translates a Thumb mode instruction into its ARM equivalent.
  34. ThumbDecodeStatus TranslateThumbInstruction(u32 addr, u32 instr, u32* ainstr, u32* inst_size);
  35. static inline u32 GetThumbInstruction(u32 instr, u32 address) {
  36. // Normally you would need to handle instruction endianness,
  37. // however, it is fixed to little-endian on the MPCore, so
  38. // there's no need to check for this beforehand.
  39. if ((address & 0x3) != 0)
  40. return instr >> 16;
  41. return instr & 0xFFFF;
  42. }