- keep additional information for decoded instructions
[openocd.git] / src / target / arm_disassembler.h
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
23 #include "types.h"
24
25 enum arm_instruction_type
26 {
27 ARM_UNKNOWN_INSTUCTION,
28
29 /* Branch instructions */
30 ARM_B,
31 ARM_BL,
32 ARM_BX,
33 ARM_BLX,
34
35 /* Data processing instructions */
36 ARM_AND,
37 ARM_EOR,
38 ARM_SUB,
39 ARM_RSB,
40 ARM_ADD,
41 ARM_ADC,
42 ARM_SBC,
43 ARM_RSC,
44 ARM_TST,
45 ARM_TEQ,
46 ARM_CMP,
47 ARM_CMN,
48 ARM_ORR,
49 ARM_MOV,
50 ARM_BIC,
51 ARM_MVN,
52
53 /* Load/store instructions */
54 ARM_LDR,
55 ARM_LDRB,
56 ARM_LDRT,
57 ARM_LDRBT,
58
59 ARM_LDRH,
60 ARM_LDRSB,
61 ARM_LDRSH,
62
63 ARM_LDM,
64
65 ARM_STR,
66 ARM_STRB,
67 ARM_STRT,
68 ARM_STRBT,
69
70 ARM_STRH,
71
72 ARM_STM,
73
74 /* Status register access instructions */
75 ARM_MRS,
76 ARM_MSR,
77
78 /* Multiply instructions */
79 ARM_MUL,
80 ARM_MLA,
81 ARM_SMULL,
82 ARM_SMLAL,
83 ARM_UMULL,
84 ARM_UMLAL,
85
86 /* Miscellaneous instructions */
87 ARM_CLZ,
88
89 /* Exception generating instructions */
90 ARM_BKPT,
91 ARM_SWI,
92
93 /* Coprocessor instructions */
94 ARM_CDP,
95 ARM_LDC,
96 ARM_STC,
97 ARM_MCR,
98 ARM_MRC,
99
100 /* Semaphore instructions */
101 ARM_SWP,
102 ARM_SWPB,
103
104 /* Enhanced DSP extensions */
105 ARM_MCRR,
106 ARM_MRRC,
107 ARM_PLD,
108 ARM_QADD,
109 ARM_QDADD,
110 ARM_QSUB,
111 ARM_QDSUB,
112 ARM_SMLAxy,
113 ARM_SMLALxy,
114 ARM_SMLAWy,
115 ARM_SMULxy,
116 ARM_SMULWy,
117 ARM_LDRD,
118 ARM_STRD,
119
120 ARM_UNDEFINED_INSTRUCTION = 0xffffffff,
121 };
122
123 typedef struct arm_b_bl_bx_blx_instr_s
124 {
125 int reg_operand;
126 u32 target_address;
127 } arm_b_bl_bx_blx_instr_t;
128
129 typedef struct arm_data_proc_instr_s
130 {
131 int variant; /* 0: immediate, 1: immediate_shift, 2: register_shift */
132 u8 S;
133 u8 Rn;
134 u8 Rd;
135 union
136 {
137 struct {
138 u8 immediate;
139 } immediate;
140 struct {
141 u8 Rm;
142 u8 shift;
143 u8 shift_imm;
144 } immediate_shift;
145 struct {
146 u8 Rm;
147 u8 shift;
148 u8 Rs;
149 } register_shift;
150 } shifter_operand;
151 } arm_data_proc_instr_t;
152
153 typedef struct arm_load_store_instr_s
154 {
155 u8 Rd;
156 u8 Rn;
157 u8 U;
158 int index_mode; /* 0: offset, 1: pre-indexed, 2: post-indexed */
159 int offset_mode; /* 0: immediate, 1: (scaled) register */
160 union
161 {
162 u32 offset;
163 struct {
164 u8 Rm;
165 u8 shift;
166 u8 shift_imm;
167 } reg;
168 } offset;
169 } arm_load_store_instr_t;
170
171 typedef struct arm_load_store_multiple_instr_s
172 {
173 u8 Rn;
174 u32 register_list;
175 u8 addressing_mode; /* 0: IA, 1: IB, 2: DA, 3: DB */
176 u8 S;
177 u8 W;
178 } arm_load_store_multiple_instr_t;
179
180 typedef struct arm_instruction_s
181 {
182 enum arm_instruction_type type;
183 char text[128];
184 u32 opcode;
185
186 union {
187 arm_b_bl_bx_blx_instr_t b_bl_bx_blx;
188 arm_data_proc_instr_t data_proc;
189 arm_load_store_instr_t load_store;
190 arm_load_store_multiple_instr_t load_store_multiple;
191 } info;
192
193 } arm_instruction_t;
194
195 extern int evaluate_opcode(u32 opcode, u32 address, arm_instruction_t *instruction);
196
197 #define COND(opcode) (arm_condition_strings[(opcode & 0xf0000000)>>28])
198
199 #endif /* ARM_DISASSEMBLER_H */

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)