Rizin
unix-like reverse engineering framework and cli tools
tms320_dasm.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2014 Ilya V. Matveychikov <i.matveychikov@milabs.ru>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #ifndef __TMS320_DASM_H__
5 #define __TMS320_DASM_H__
6 
7 #define IDA_COMPATIBLE_MODE 1
8 
9 /* forward declarations */
10 
11 struct tms320_instruction;
12 typedef struct tms320_instruction insn_item_t;
13 
16 
19 
22 
23 typedef enum {
24  TMS320_FLAG_E = 0x10,
31 
41 
49 
52 
57 
61 
65 
70 
77 
82 } insn_flag_e;
83 
85 #define i_list_last(x) !(((x)->i_list || (x)->m_list || (x)->f_list || (x)->syntax))
87 
90 
91  char *syntax;
92 };
93 
95 #define m_list_last(x) !(((x)->f || (x)->n || (x)->v))
96  ut8 f, n, v; /* from, number, value */
97 };
98 
100 #define f_list_last(x) !(((x)->f || (x)->v))
101  ut8 f, v; /* from, value */
102 };
103 
108 };
109 
110 /*
111  * TMS320 dasm instance
112  */
113 
114 typedef struct {
117 
118  union {
122  };
123 
124 #define TMS320_S_INVAL 0x01
127  char syntax[1024];
128 
129 #define def_field(name, size) \
130  unsigned int bf_##name##_valid : 1; \
131  unsigned int bf_##name##_value : size
132 
133  struct {
134  def_field(E, 1);
135  def_field(R, 1);
136  def_field(U, 1);
137  def_field(u, 1);
138  def_field(g, 1);
139  def_field(r, 1);
140  def_field(t, 1);
141 
142  def_field(k3, 3);
143  def_field(k4, 4);
144  def_field(k5, 5);
145  def_field(k6, 6);
146  def_field(k8, 8);
147  def_field(k12, 12);
148  def_field(k16, 16);
149 
150  def_field(l1, 1);
151  def_field(l3, 3);
152  def_field(l7, 7);
153  def_field(l16, 16);
154 
155  def_field(K8, 8);
156  def_field(K16, 16);
157 
158  def_field(L7, 7);
159  def_field(L8, 8);
160  def_field(L16, 16);
161 
162  def_field(P8, 8);
163  def_field(P24, 24);
164 
165  def_field(D16, 16);
166 
167  def_field(SHFT, 4);
168  def_field(SHIFTW, 6);
169 
170  def_field(ss, 2);
171  def_field(dd, 2);
172 
173  def_field(uu, 2);
174  def_field(cc, 2);
175  def_field(mm, 2);
176  def_field(vv, 2);
177  def_field(tt, 2);
178 
179  def_field(FSSS, 4);
180  def_field(FDDD, 4);
181  def_field(XSSS, 4);
182  def_field(XDDD, 4);
183  def_field(XACS, 4);
184  def_field(XACD, 4);
185 
186  def_field(CCCCCCC, 7);
187  def_field(AAAAAAAI, 8);
188 
189  def_field(SS, 2);
190  def_field(SS2, 2);
191  def_field(DD, 2);
192  def_field(DD2, 2);
193 
194  // aggregates
195 
196  def_field(Xmem_mmm, 3);
197  def_field(Xmem_reg, 3);
198 
199  def_field(Ymem_mmm, 3);
200  def_field(Ymem_reg, 3);
201 
202  // qualifiers
203 
204  def_field(q_lr, 1);
205  def_field(q_cr, 1);
206  } f;
207  HtUP *map;
208 
209 #define TMS320_F_CPU_C54X 0x0000001
210 #define TMS320_F_CPU_C55X 0x0000002
211 #define TMS320_F_CPU_C55X_PLUS 0x0000003
212 #define TMS320_F_CPU_MASK 0x00000FF
214 #define tms320_f_get_cpu(d) ((d)->features & TMS320_F_CPU_MASK)
215 #define tms320_f_set_cpu(d, v) ((d)->features = ((d)->features & ~TMS320_F_CPU_MASK) | (v))
216 } tms320_dasm_t;
217 
218 #define field_valid(d, name) \
219  (d)->f.bf_##name##_valid
220 #define field_value(d, name) \
221  (d)->f.bf_##name##_value
222 
223 #ifdef _MSC_VER
224 #define set_field_value(d, name, value) \
225  { \
226  field_valid(d, name) = 1; \
227  field_value(d, name) = value; \
228  }
229 #else
230 #define set_field_value(d, name, value) \
231  ({ \
232  field_valid(d, name) = 1; \
233  field_value(d, name) = value; \
234  })
235 #endif
236 
237 #define LIST_END \
238  { 0 }
239 
240 #define INSN_MASK(af, an, av) \
241  { .f = af, .n = an, .v = av }
242 #define INSN_FLAG(af, av) \
243  { .f = af, .v = TMS320_FLAG_##av }
244 #define INSN_SYNTAX(...) (char *)#__VA_ARGS__
245 
246 extern int tms320_dasm(tms320_dasm_t *, const ut8 *, int);
247 
248 extern int tms320_dasm_init(tms320_dasm_t *);
249 extern int tms320_dasm_fini(tms320_dasm_t *);
250 
251 #endif /* __TMS320_DASM_H__ */
#define R(x, b, m)
Definition: arc.h:168
#define r
Definition: crypto_rc6.c:12
uint32_t ut32
struct @667 g
voidpf stream
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
#define f(i)
Definition: sha256.c:46
insn_head_t * head
Definition: tms320_dasm.h:115
insn_item_t * insn
Definition: tms320_dasm.h:116
insn_flag_t * f_list
Definition: tms320_dasm.h:89
insn_mask_t * m_list
Definition: tms320_dasm.h:88
insn_item_t * i_list
Definition: tms320_dasm.h:86
int tms320_dasm(tms320_dasm_t *, const ut8 *, int)
Definition: tms320_dasm.c:1154
insn_flag_e
Definition: tms320_dasm.h:23
@ TMS320_FLAG_l3
Definition: tms320_dasm.h:54
@ TMS320_FLAG_k4
Definition: tms320_dasm.h:43
@ TMS320_FLAG_SS
Definition: tms320_dasm.h:39
@ TMS320_FLAG_XSSS
Definition: tms320_dasm.h:73
@ TMS320_FLAG_XDDD
Definition: tms320_dasm.h:74
@ TMS320_FLAG_l7
Definition: tms320_dasm.h:55
@ TMS320_FLAG_FSSS
Definition: tms320_dasm.h:71
@ TMS320_FLAG_YY
Definition: tms320_dasm.h:81
@ TMS320_FLAG_FDDD
Definition: tms320_dasm.h:72
@ TMS320_FLAG_uu
Definition: tms320_dasm.h:32
@ TMS320_FLAG_k16
Definition: tms320_dasm.h:48
@ TMS320_FLAG_k12
Definition: tms320_dasm.h:47
@ TMS320_FLAG_r
Definition: tms320_dasm.h:29
@ TMS320_FLAG_E
Definition: tms320_dasm.h:24
@ TMS320_FLAG_SHIFTW
Definition: tms320_dasm.h:67
@ TMS320_FLAG_vv
Definition: tms320_dasm.h:36
@ TMS320_FLAG_mm
Definition: tms320_dasm.h:33
@ TMS320_FLAG_l16
Definition: tms320_dasm.h:56
@ TMS320_FLAG_DD
Definition: tms320_dasm.h:40
@ TMS320_FLAG_g
Definition: tms320_dasm.h:28
@ TMS320_FLAG_XXX
Definition: tms320_dasm.h:78
@ TMS320_FLAG_K8
Definition: tms320_dasm.h:50
@ TMS320_FLAG_XACD
Definition: tms320_dasm.h:76
@ TMS320_FLAG_P24
Definition: tms320_dasm.h:63
@ TMS320_FLAG_t
Definition: tms320_dasm.h:30
@ TMS320_FLAG_dd
Definition: tms320_dasm.h:38
@ TMS320_FLAG_K16
Definition: tms320_dasm.h:51
@ TMS320_FLAG_k8
Definition: tms320_dasm.h:46
@ TMS320_FLAG_cc
Definition: tms320_dasm.h:34
@ TMS320_FLAG_ss
Definition: tms320_dasm.h:37
@ TMS320_FLAG_u
Definition: tms320_dasm.h:27
@ TMS320_FLAG_L8
Definition: tms320_dasm.h:59
@ TMS320_FLAG_Y
Definition: tms320_dasm.h:80
@ TMS320_FLAG_AAAAAAAI
Definition: tms320_dasm.h:69
@ TMS320_FLAG_XACS
Definition: tms320_dasm.h:75
@ TMS320_FLAG_tt
Definition: tms320_dasm.h:35
@ TMS320_FLAG_MMM
Definition: tms320_dasm.h:79
@ TMS320_FLAG_k6
Definition: tms320_dasm.h:45
@ TMS320_FLAG_L7
Definition: tms320_dasm.h:58
@ TMS320_FLAG_k3
Definition: tms320_dasm.h:42
@ TMS320_FLAG_L16
Definition: tms320_dasm.h:60
@ TMS320_FLAG_U
Definition: tms320_dasm.h:26
@ TMS320_FLAG_D16
Definition: tms320_dasm.h:64
@ TMS320_FLAG_l1
Definition: tms320_dasm.h:53
@ TMS320_FLAG_SHFT
Definition: tms320_dasm.h:66
@ TMS320_FLAG_R
Definition: tms320_dasm.h:25
@ TMS320_FLAG_CCCCCCC
Definition: tms320_dasm.h:68
@ TMS320_FLAG_k5
Definition: tms320_dasm.h:44
@ TMS320_FLAG_P8
Definition: tms320_dasm.h:62
int tms320_dasm_init(tms320_dasm_t *)
Definition: tms320_dasm.c:1181
int tms320_dasm_fini(tms320_dasm_t *)
Definition: tms320_dasm.c:1202
#define def_field(name, size)
Definition: tms320_dasm.h:129
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode dd[]
Definition: z80_tab.h:844
#define E
Definition: zip_err_str.c:12