You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

200 lines
4.1 KiB

  1. /***************************************************************************
  2. * Copyright (C) 2006 by Dominic Rath *
  3. * Dominic.Rath@gmx.de *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation; either version 2 of the License, or *
  8. * (at your option) any later version. *
  9. * *
  10. * This program is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU General Public License *
  16. * along with this program; if not, write to the *
  17. * Free Software Foundation, Inc., *
  18. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  19. ***************************************************************************/
  20. #ifndef ARM_DISASSEMBLER_H
  21. #define ARM_DISASSEMBLER_H
  22. #include "types.h"
  23. enum arm_instruction_type
  24. {
  25. ARM_UNKNOWN_INSTUCTION,
  26. /* Branch instructions */
  27. ARM_B,
  28. ARM_BL,
  29. ARM_BX,
  30. ARM_BLX,
  31. /* Data processing instructions */
  32. ARM_AND,
  33. ARM_EOR,
  34. ARM_SUB,
  35. ARM_RSB,
  36. ARM_ADD,
  37. ARM_ADC,
  38. ARM_SBC,
  39. ARM_RSC,
  40. ARM_TST,
  41. ARM_TEQ,
  42. ARM_CMP,
  43. ARM_CMN,
  44. ARM_ORR,
  45. ARM_MOV,
  46. ARM_BIC,
  47. ARM_MVN,
  48. /* Load/store instructions */
  49. ARM_LDR,
  50. ARM_LDRB,
  51. ARM_LDRT,
  52. ARM_LDRBT,
  53. ARM_LDRH,
  54. ARM_LDRSB,
  55. ARM_LDRSH,
  56. ARM_LDM,
  57. ARM_STR,
  58. ARM_STRB,
  59. ARM_STRT,
  60. ARM_STRBT,
  61. ARM_STRH,
  62. ARM_STM,
  63. /* Status register access instructions */
  64. ARM_MRS,
  65. ARM_MSR,
  66. /* Multiply instructions */
  67. ARM_MUL,
  68. ARM_MLA,
  69. ARM_SMULL,
  70. ARM_SMLAL,
  71. ARM_UMULL,
  72. ARM_UMLAL,
  73. /* Miscellaneous instructions */
  74. ARM_CLZ,
  75. /* Exception generating instructions */
  76. ARM_BKPT,
  77. ARM_SWI,
  78. /* Coprocessor instructions */
  79. ARM_CDP,
  80. ARM_LDC,
  81. ARM_STC,
  82. ARM_MCR,
  83. ARM_MRC,
  84. /* Semaphore instructions */
  85. ARM_SWP,
  86. ARM_SWPB,
  87. /* Enhanced DSP extensions */
  88. ARM_MCRR,
  89. ARM_MRRC,
  90. ARM_PLD,
  91. ARM_QADD,
  92. ARM_QDADD,
  93. ARM_QSUB,
  94. ARM_QDSUB,
  95. ARM_SMLAxy,
  96. ARM_SMLALxy,
  97. ARM_SMLAWy,
  98. ARM_SMULxy,
  99. ARM_SMULWy,
  100. ARM_LDRD,
  101. ARM_STRD,
  102. ARM_UNDEFINED_INSTRUCTION = 0xffffffff,
  103. };
  104. typedef struct arm_b_bl_bx_blx_instr_s
  105. {
  106. int reg_operand;
  107. u32 target_address;
  108. } arm_b_bl_bx_blx_instr_t;
  109. typedef struct arm_data_proc_instr_s
  110. {
  111. int variant; /* 0: immediate, 1: immediate_shift, 2: register_shift */
  112. u8 S;
  113. u8 Rn;
  114. u8 Rd;
  115. union
  116. {
  117. struct {
  118. u8 immediate;
  119. } immediate;
  120. struct {
  121. u8 Rm;
  122. u8 shift;
  123. u8 shift_imm;
  124. } immediate_shift;
  125. struct {
  126. u8 Rm;
  127. u8 shift;
  128. u8 Rs;
  129. } register_shift;
  130. } shifter_operand;
  131. } arm_data_proc_instr_t;
  132. typedef struct arm_load_store_instr_s
  133. {
  134. u8 Rd;
  135. u8 Rn;
  136. u8 U;
  137. int index_mode; /* 0: offset, 1: pre-indexed, 2: post-indexed */
  138. int offset_mode; /* 0: immediate, 1: (scaled) register */
  139. union
  140. {
  141. u32 offset;
  142. struct {
  143. u8 Rm;
  144. u8 shift;
  145. u8 shift_imm;
  146. } reg;
  147. } offset;
  148. } arm_load_store_instr_t;
  149. typedef struct arm_load_store_multiple_instr_s
  150. {
  151. u8 Rn;
  152. u32 register_list;
  153. u8 addressing_mode; /* 0: IA, 1: IB, 2: DA, 3: DB */
  154. u8 S;
  155. u8 W;
  156. } arm_load_store_multiple_instr_t;
  157. typedef struct arm_instruction_s
  158. {
  159. enum arm_instruction_type type;
  160. char text[128];
  161. u32 opcode;
  162. union {
  163. arm_b_bl_bx_blx_instr_t b_bl_bx_blx;
  164. arm_data_proc_instr_t data_proc;
  165. arm_load_store_instr_t load_store;
  166. arm_load_store_multiple_instr_t load_store_multiple;
  167. } info;
  168. } arm_instruction_t;
  169. extern int evaluate_opcode(u32 opcode, u32 address, arm_instruction_t *instruction);
  170. #define COND(opcode) (arm_condition_strings[(opcode & 0xf0000000)>>28])
  171. #endif /* ARM_DISASSEMBLER_H */