]> git.karo-electronics.de Git - karo-tx-redboot.git/blob - packages/cygmon/v2_0/misc/bsp/arm/insn.h
Initial revision
[karo-tx-redboot.git] / packages / cygmon / v2_0 / misc / bsp / arm / insn.h
1 #ifndef __BSP_ARM_INSN_H__
2 #define __BSP_ARM_INSN_H__
3 //==========================================================================
4 //
5 //      insn.h
6 //
7 //      ARM(R) instruction descriptions.
8 //
9 //==========================================================================
10 //####ECOSGPLCOPYRIGHTBEGIN####
11 // -------------------------------------------
12 // This file is part of eCos, the Embedded Configurable Operating System.
13 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14 //
15 // eCos is free software; you can redistribute it and/or modify it under
16 // the terms of the GNU General Public License as published by the Free
17 // Software Foundation; either version 2 or (at your option) any later version.
18 //
19 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22 // for more details.
23 //
24 // You should have received a copy of the GNU General Public License along
25 // with eCos; if not, write to the Free Software Foundation, Inc.,
26 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27 //
28 // As a special exception, if other files instantiate templates or use macros
29 // or inline functions from this file, or you compile this file and link it
30 // with other works to produce a work based on this file, this file does not
31 // by itself cause the resulting work to be covered by the GNU General Public
32 // License. However the source code for this file must still be made available
33 // in accordance with section (3) of the GNU General Public License.
34 //
35 // This exception does not invalidate any other reasons why a work based on
36 // this file might be covered by the GNU General Public License.
37 //
38 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39 // at http://sources.redhat.com/ecos/ecos-license/
40 // -------------------------------------------
41 //####ECOSGPLCOPYRIGHTEND####
42 //==========================================================================
43 //#####DESCRIPTIONBEGIN####
44 //
45 // Author(s):    
46 // Contributors: gthomas
47 // Date:         1999-10-20
48 // Purpose:      ARM(R) instruction descriptions.
49 // Description:  ARM is a Registered Trademark of Advanced RISC Machines
50 //               Limited.
51 //               Other Brands and Trademarks are the property of their
52 //               respective owners.
53 //
54 //####DESCRIPTIONEND####
55 //
56 //=========================================================================
57
58
59 /* Data Processing Immediate Type */
60 struct dpi_type {
61     unsigned immediate   : 8;
62     unsigned rotate      : 4;
63     unsigned Rd          : 4;
64     unsigned Rn          : 4;
65     unsigned S_bit       : 1;
66     unsigned opcode      : 4;
67     unsigned rsv1        : 3;  /* == 001b */
68     unsigned cond        : 4;
69 };
70 #define DPI_RSV1_VALUE 0x1
71
72 /* Data Processing Immediate Shift Type */
73 struct dpis_type {
74     unsigned Rm          : 4;
75     unsigned rsv2        : 1;  /* == 0b */
76     unsigned shift       : 2;
77     unsigned shift_immed : 5;
78     unsigned Rd          : 4;
79     unsigned Rn          : 4;
80     unsigned S_bit       : 1;
81     unsigned opcode      : 4;
82     unsigned rsv1        : 3;  /* == 000b */
83     unsigned cond        : 4;
84 };
85 #define DPIS_RSV1_VALUE 0x0
86 #define DPIS_RSV2_VALUE 0x0
87
88 /* Data Processing Register Shift Type */
89 struct dprs_type {
90     unsigned Rm          : 4;
91     unsigned rsv3        : 1;  /* == 1b */
92     unsigned shift       : 2;
93     unsigned rsv2        : 1;  /* == 0b */
94     unsigned Rs          : 4;
95     unsigned Rd          : 4;
96     unsigned Rn          : 4;
97     unsigned S_bit       : 1;
98     unsigned opcode      : 4;
99     unsigned rsv1        : 3;  /* == 000b */
100     unsigned cond        : 4;
101 };
102 #define DPRS_RSV1_VALUE 0x0
103 #define DPRS_RSV2_VALUE 0x0
104 #define DPRS_RSV3_VALUE 0x1
105
106 /* Multiply Type */
107 struct m_type {
108     unsigned Rm          : 4;
109     unsigned rsv2        : 4;  /* == 1001b */
110     unsigned Rs          : 4;
111     unsigned Rn          : 4;
112     unsigned Rd          : 4;
113     unsigned S_bit       : 1;
114     unsigned A_bit       : 1;
115     unsigned rsv1        : 6;  /* == 000000b */
116     unsigned cond        : 4;
117 };
118 #define M_RSV1_VALUE 0x0
119 #define M_RSV2_VALUE 0x9
120
121 /* Multiply Long Type */
122 struct ml_type {
123     unsigned Rm          : 4;
124     unsigned rsv2        : 4;  /* == 1001b */
125     unsigned Rs          : 4;
126     unsigned RdLo        : 4;
127     unsigned RdHi        : 4;
128     unsigned S_bit       : 1;
129     unsigned A_bit       : 1;
130     unsigned U_bit       : 1;
131     unsigned rsv1        : 5;  /* == 00001b */
132     unsigned cond        : 4;
133 };
134 #define ML_RSV1_VALUE 0x1
135 #define ML_RSV2_VALUE 0x9
136
137 /* Move from status register Type */
138 struct mrs_type {
139     unsigned SBZ         : 12;
140     unsigned Rd          : 4;
141     unsigned SBO         : 4;
142     unsigned rsv2        : 2;  /* == 00b */
143     unsigned R_bit       : 1;
144     unsigned rsv1        : 5;  /* == 00010b */
145     unsigned cond        : 4;
146 };
147 #define MRS_RSV1_VALUE 0x2
148 #define MRS_RSV2_VALUE 0x0
149
150 /* Move Immediate to status register Type */
151 struct misr_type {
152     unsigned immediate   : 8;
153     unsigned rotate      : 4;
154     unsigned SBO         : 4;
155     unsigned mask        : 4;
156     unsigned rsv2        : 2;  /* == 10b */
157     unsigned R_bit       : 1;
158     unsigned rsv1        : 5;  /* == 00110b */
159     unsigned cond        : 4;
160 };
161 #define MISR_RSV1_VALUE 0x6
162 #define MISR_RSV2_VALUE 0x2
163
164 /* Move register to status register Type */
165 struct mrsr_type {
166     unsigned Rm          : 4;
167     unsigned rsv3        : 1;  /* == 0b */
168     unsigned SBZ         : 7;
169     unsigned SBO         : 4;
170     unsigned mask        : 4;
171     unsigned rsv2        : 2;  /* == 10b */
172     unsigned R_bit       : 1;
173     unsigned rsv1        : 5;  /* == 00010b */
174     unsigned cond        : 4;
175 };
176 #define MRSR_RSV1_VALUE 0x2
177 #define MRSR_RSV2_VALUE 0x2
178 #define MRSR_RSV3_VALUE 0x0
179
180 /* Branch/Exchange Type */
181 struct bx_type {
182     unsigned Rm          : 4;
183     unsigned rsv2        : 4;  /* == 0001b */
184     unsigned SBO3        : 4;
185     unsigned SBO2        : 4;
186     unsigned SBO1        : 4;
187     unsigned rsv1        : 8;  /* == 00010010b */
188     unsigned cond        : 4;
189 };
190 #define BX_RSV1_VALUE 0x12
191 #define BX_RSV2_VALUE 0x1
192
193 /* Load/Store Immediate Offset Type */
194 struct lsio_type {
195     unsigned immediate   : 12;
196     unsigned Rd          : 4;
197     unsigned Rn          : 4;
198     unsigned L_bit       : 1;
199     unsigned W_bit       : 1;
200     unsigned B_bit       : 1;
201     unsigned U_bit       : 1;
202     unsigned P_bit       : 1;
203     unsigned rsv1        : 3;  /* == 010b */
204     unsigned cond        : 4;
205 };
206 #define LSIO_RSV1_VALUE 0x2
207
208 /* Load/Store Register Offset Type */
209 struct lsro_type {
210     unsigned Rm          : 4;
211     unsigned rsv2        : 1;  /* == 0b */
212     unsigned shift       : 2;
213     unsigned shift_immed : 5;
214     unsigned Rd          : 4;
215     unsigned Rn          : 4;
216     unsigned L_bit       : 1;
217     unsigned W_bit       : 1;
218     unsigned B_bit       : 1;
219     unsigned U_bit       : 1;
220     unsigned P_bit       : 1;
221     unsigned rsv1        : 3;  /* == 011b */
222     unsigned cond        : 4;
223 };
224 #define LSRO_RSV1_VALUE 0x3
225 #define LSRO_RSV2_VALUE 0x0
226
227 /* Load/Store halfword/signed byte Immediate Offset Type */
228 struct lshwi_type {
229     unsigned Lo_Offset   : 4;
230     unsigned rsv4        : 1;  /* == 1b */
231     unsigned H_bit       : 1;
232     unsigned S_bit       : 1;
233     unsigned rsv3        : 1;  /* == 1b */
234     unsigned Hi_Offset   : 4;
235     unsigned Rd          : 4;
236     unsigned Rn          : 4;
237     unsigned L_bit       : 1;
238     unsigned W_bit       : 1;
239     unsigned rsv2        : 1;  /* == 1b */
240     unsigned U_bit       : 1;
241     unsigned P_bit       : 1;
242     unsigned rsv1        : 3;  /* == 000b */
243     unsigned cond        : 4;
244 };
245 #define LSHWI_RSV1_VALUE 0x0
246 #define LSHWI_RSV2_VALUE 0x1
247 #define LSHWI_RSV3_VALUE 0x1
248 #define LSHWI_RSV4_VALUE 0x1
249
250 /* Load/Store halfword/signed byte Register Offset Type */
251 struct lshwr_type {
252     unsigned Rm          : 4;
253     unsigned rsv4        : 1;  /* == 1b */
254     unsigned H_bit       : 1;
255     unsigned S_bit       : 1;
256     unsigned rsv3        : 1;  /* == 1b */
257     unsigned SBZ         : 4;
258     unsigned Rd          : 4;
259     unsigned Rn          : 4;
260     unsigned L_bit       : 1;
261     unsigned W_bit       : 1;
262     unsigned rsv2        : 1;  /* == 0b */
263     unsigned U_bit       : 1;
264     unsigned P_bit       : 1;
265     unsigned rsv1        : 3;  /* == 000b */
266     unsigned cond        : 4;
267 };
268 #define LSHWR_RSV1_VALUE 0x3
269 #define LSHWR_RSV2_VALUE 0x1
270 #define LSHWR_RSV3_VALUE 0x1
271 #define LSHWR_RSV4_VALUE 0x1
272
273 /* Swap/Swap Byte Type */
274 struct swap_type {
275     unsigned Rm          : 4;
276     unsigned rsv3        : 4;  /* == 1001b */
277     unsigned SBZ         : 4;
278     unsigned Rd          : 4;
279     unsigned Rn          : 4;
280     unsigned rsv2        : 2;  /* == 00b */
281     unsigned B_bit       : 1;
282     unsigned rsv1        : 5;  /* == 00010b */
283     unsigned cond        : 4;
284 };
285 #define SWAP_RSV1_VALUE 0x2
286 #define SWAP_RSV2_VALUE 0x0
287 #define SWAP_RSV3_VALUE 0x9
288
289 /* Load/Store Multiple Type */
290 struct lsm_type {
291     unsigned Reg_List    : 16 ;
292     unsigned Rn          : 4;
293     unsigned L_bit       : 1;
294     unsigned W_bit       : 1;
295     unsigned S_bit       : 1;
296     unsigned U_bit       : 1;
297     unsigned P_bit       : 1;
298     unsigned rsv1        : 3;  /* == 100b */
299     unsigned cond        : 4;
300 };
301 #define LSM_RSV1_VALUE 0x4
302
303 /* Coprocessor Data Processing Type */
304 struct cpdp_type {
305     unsigned CRm         : 4;
306     unsigned rsv2        : 1;  /* == 0b */
307     unsigned op2         : 3;
308     unsigned cp_num      : 4;
309     unsigned CRd         : 4;
310     unsigned CRn         : 4;
311     unsigned op1         : 4;
312     unsigned rsv1        : 4;  /* == 1110b */
313     unsigned cond        : 4;
314 };
315 #define CPDP_RSV1_VALUE 0xE
316 #define CPDP_RSV2_VALUE 0x0
317
318 /* Coprocessor Register Transfer Type */
319 struct cprt_type {
320     unsigned CRm         : 4;
321     unsigned rsv2        : 1;  /* == 1b */
322     unsigned op2         : 3;
323     unsigned cp_num      : 4;
324     unsigned Rd          : 4;
325     unsigned CRn         : 4;
326     unsigned L_bit       : 1;
327     unsigned op1         : 3;
328     unsigned rsv1        : 4;  /* == 1110b */
329     unsigned cond        : 4;
330 };
331 #define CPRT_RSV1_VALUE 0xE
332 #define CPRT_RSV2_VALUE 0x1
333
334 /* Coprocessor Load/Store Type */
335 struct cpls_type {
336     unsigned offset      : 8;
337     unsigned cp_num      : 4;
338     unsigned CRd         : 4;
339     unsigned Rn          : 4;
340     unsigned L_bit       : 1;
341     unsigned W_bit       : 1;
342     unsigned N_bit       : 1;
343     unsigned U_bit       : 1;
344     unsigned P_bit       : 1;
345     unsigned rsv1        : 3;  /* == 110b */
346     unsigned cond        : 4;
347 };
348 #define CPLS_RSV1_VALUE 0x6
349
350 /* Branch/Branch w/ Link Type */
351 struct bbl_type {
352     unsigned offset      : 24;
353     unsigned L_bit       : 1;
354     unsigned rsv1        : 3;  /* == 101b */
355     unsigned cond        : 4;
356 };
357 #define BBL_RSV1_VALUE 0x5
358
359 /* SWI Type */
360 struct swi_type {
361     unsigned swi_number  : 24;
362     unsigned rsv1        : 4;  /* == 1111b */
363     unsigned cond        : 4;
364 };
365 #define SWI_RSV1_VALUE 0xF
366
367 /* Undefined Instruction Type */
368 struct undef_type {
369     unsigned pad2        : 4;
370     unsigned rsv2        : 1;  /* == 1b */
371     unsigned pad1        : 20;
372     unsigned rsv1        : 3;  /* == 011b */
373     unsigned cond        : 4;
374 };
375 #define UNDEF_RSV1_VALUE 0x3
376 #define UNDEF_RSV2_VALUE 0x1
377
378 union arm_insn {
379     unsigned long          word;
380     struct dpi_type        dpi;
381     struct dpis_type       dpis;
382     struct dprs_type       dprs;
383     struct m_type          m;
384     struct ml_type         ml;
385     struct mrs_type        mrs;
386     struct misr_type       misr;
387     struct mrsr_type       mrsr;
388     struct bx_type         bx;
389     struct lsio_type       lsio;
390     struct lsro_type       lsro;
391     struct lshwi_type      lshwi;
392     struct lshwr_type      lshwr;
393     struct swap_type       swap;
394     struct lsm_type        lsm;
395     struct cpdp_type       cpdp;
396     struct cprt_type       cprt;
397     struct cpls_type       cpls;
398     struct bbl_type        bbl;
399     struct swi_type        swi;
400     struct undef_type      undef;
401 };
402
403 /*
404  * Conditional field values
405  */
406 #define COND_EQ     0x0
407 #define COND_NE     0x1
408 #define COND_CS_HI  0x2
409 #define COND_CC_LO  0x3
410 #define COND_MI     0x4
411 #define COND_PL     0x5
412 #define COND_VS     0x6
413 #define COND_VC     0x7
414 #define COND_HI     0x8
415 #define COND_LS     0x9
416 #define COND_GE     0xA
417 #define COND_LT     0xB
418 #define COND_GT     0xC
419 #define COND_LE     0xD
420 #define COND_AL     0xE
421 #define COND_NV     0xF
422
423 /*
424  * Data Processiong Opcode field values
425  */
426 #define DP_OPCODE_MOV  0xD
427 #define DP_OPCODE_MVN  0xF
428 #define DP_OPCODE_ADD  0x4
429 #define DP_OPCODE_ADC  0x5
430 #define DP_OPCODE_SUB  0x2
431 #define DP_OPCODE_SBC  0x6
432 #define DP_OPCODE_RSB  0x3
433 #define DP_OPCODE_RSC  0x7
434 #define DP_OPCODE_AND  0x0
435 #define DP_OPCODE_EOR  0x1
436 #define DP_OPCODE_ORR  0xC
437 #define DP_OPCODE_BIC  0xE
438 #define DP_OPCODE_CMP  0xA
439 #define DP_OPCODE_CMN  0xB
440 #define DP_OPCODE_TST  0x8
441 #define DP_OPCODE_TEQ  0x9
442
443 /*
444  * Shift field values
445  */
446 #define SHIFT_LSL   0x0
447 #define SHIFT_LSR   0x1
448 #define SHIFT_ASR   0x2
449 #define SHIFT_ROR   0x3
450 #define SHIFT_RRX   0x3    /* Special case: ROR(0) implies RRX */
451
452 /*
453  * Load/Store indexing definitions
454  */
455 #define LS_INDEX_POST      0x0
456 #define LS_INDEX_PRE       0x1
457
458 /*
459  * Load/Store offset operation definitions
460  */
461 #define LS_OFFSET_SUB      0x0
462 #define LS_OFFSET_ADD      0x1
463
464 /*
465  * Load/Store size definitions
466  */
467 #define LS_SIZE_WORD       0x0
468 #define LS_SIZE_BYTE       0x1
469
470 /*
471  * Load/Store Update definitions
472  */
473 #define LS_NO_UPDATE       0x0
474 #define LS_UPDATE          0x1
475
476 /*
477  * Load/Store Opcode definitions
478  */
479 #define LS_STORE           0x0
480 #define LS_LOAD            0x1
481
482 #endif // __BSP_ARM_INSN_H__