armemu.h revision 1.6 1 1.1 christos /* armemu.h -- ARMulator emulation macros: ARM6 Instruction Emulator.
2 1.1 christos Copyright (C) 1994 Advanced RISC Machines Ltd.
3 1.1 christos
4 1.1 christos This program is free software; you can redistribute it and/or modify
5 1.1 christos it under the terms of the GNU General Public License as published by
6 1.1 christos the Free Software Foundation; either version 3 of the License, or
7 1.1 christos (at your option) any later version.
8 1.1 christos
9 1.1 christos This program is distributed in the hope that it will be useful,
10 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
11 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 1.1 christos GNU General Public License for more details.
13 1.1 christos
14 1.1 christos You should have received a copy of the GNU General Public License
15 1.1 christos along with this program; if not, see <http://www.gnu.org/licenses/>. */
16 1.1 christos
17 1.6 christos #include "armdefs.h"
18 1.6 christos
19 1.1 christos extern ARMword isize;
20 1.3 christos extern int trace;
21 1.3 christos extern int disas;
22 1.3 christos extern int trace_funcs;
23 1.3 christos extern void print_insn (ARMword);
24 1.1 christos
25 1.1 christos /* Condition code values. */
26 1.1 christos #define EQ 0
27 1.1 christos #define NE 1
28 1.1 christos #define CS 2
29 1.1 christos #define CC 3
30 1.1 christos #define MI 4
31 1.1 christos #define PL 5
32 1.1 christos #define VS 6
33 1.1 christos #define VC 7
34 1.1 christos #define HI 8
35 1.1 christos #define LS 9
36 1.1 christos #define GE 10
37 1.1 christos #define LT 11
38 1.1 christos #define GT 12
39 1.1 christos #define LE 13
40 1.1 christos #define AL 14
41 1.1 christos #define NV 15
42 1.1 christos
43 1.1 christos /* Shift Opcodes. */
44 1.1 christos #define LSL 0
45 1.1 christos #define LSR 1
46 1.1 christos #define ASR 2
47 1.1 christos #define ROR 3
48 1.1 christos
49 1.1 christos /* Macros to twiddle the status flags and mode. */
50 1.1 christos #define NBIT ((unsigned)1L << 31)
51 1.1 christos #define ZBIT (1L << 30)
52 1.1 christos #define CBIT (1L << 29)
53 1.1 christos #define VBIT (1L << 28)
54 1.1 christos #define SBIT (1L << 27)
55 1.3 christos #define GE0 (1L << 16)
56 1.3 christos #define GE1 (1L << 17)
57 1.3 christos #define GE2 (1L << 18)
58 1.3 christos #define GE3 (1L << 19)
59 1.1 christos #define IBIT (1L << 7)
60 1.1 christos #define FBIT (1L << 6)
61 1.1 christos #define IFBITS (3L << 6)
62 1.1 christos #define R15IBIT (1L << 27)
63 1.1 christos #define R15FBIT (1L << 26)
64 1.1 christos #define R15IFBITS (3L << 26)
65 1.1 christos
66 1.1 christos #define POS(i) ( (~(i)) >> 31 )
67 1.1 christos #define NEG(i) ( (i) >> 31 )
68 1.1 christos
69 1.1 christos #ifdef MODET /* Thumb support. */
70 1.1 christos /* ??? This bit is actually in the low order bit of the PC in the hardware.
71 1.1 christos It isn't clear if the simulator needs to model that or not. */
72 1.1 christos #define TBIT (1L << 5)
73 1.1 christos #define TFLAG state->TFlag
74 1.1 christos #define SETT state->TFlag = 1
75 1.1 christos #define CLEART state->TFlag = 0
76 1.1 christos #define ASSIGNT(res) state->TFlag = res
77 1.1 christos #define INSN_SIZE (TFLAG ? 2 : 4)
78 1.1 christos #else
79 1.1 christos #define INSN_SIZE 4
80 1.1 christos #endif
81 1.1 christos
82 1.1 christos #define NFLAG state->NFlag
83 1.1 christos #define SETN state->NFlag = 1
84 1.1 christos #define CLEARN state->NFlag = 0
85 1.1 christos #define ASSIGNN(res) state->NFlag = res
86 1.1 christos
87 1.1 christos #define ZFLAG state->ZFlag
88 1.1 christos #define SETZ state->ZFlag = 1
89 1.1 christos #define CLEARZ state->ZFlag = 0
90 1.1 christos #define ASSIGNZ(res) state->ZFlag = res
91 1.1 christos
92 1.1 christos #define CFLAG state->CFlag
93 1.1 christos #define SETC state->CFlag = 1
94 1.1 christos #define CLEARC state->CFlag = 0
95 1.1 christos #define ASSIGNC(res) state->CFlag = res
96 1.1 christos
97 1.1 christos #define VFLAG state->VFlag
98 1.1 christos #define SETV state->VFlag = 1
99 1.1 christos #define CLEARV state->VFlag = 0
100 1.1 christos #define ASSIGNV(res) state->VFlag = res
101 1.1 christos
102 1.1 christos #define SFLAG state->SFlag
103 1.1 christos #define SETS state->SFlag = 1
104 1.1 christos #define CLEARS state->SFlag = 0
105 1.1 christos #define ASSIGNS(res) state->SFlag = res
106 1.1 christos
107 1.1 christos #define IFLAG (state->IFFlags >> 1)
108 1.1 christos #define FFLAG (state->IFFlags & 1)
109 1.1 christos #define IFFLAGS state->IFFlags
110 1.1 christos #define ASSIGNINT(res) state->IFFlags = (((res) >> 6) & 3)
111 1.1 christos #define ASSIGNR15INT(res) state->IFFlags = (((res) >> 26) & 3) ;
112 1.1 christos
113 1.1 christos #define PSR_FBITS (0xff000000L)
114 1.1 christos #define PSR_SBITS (0x00ff0000L)
115 1.1 christos #define PSR_XBITS (0x0000ff00L)
116 1.1 christos #define PSR_CBITS (0x000000ffL)
117 1.1 christos
118 1.1 christos #if defined MODE32 || defined MODET
119 1.1 christos #define CCBITS (0xf8000000L)
120 1.1 christos #else
121 1.1 christos #define CCBITS (0xf0000000L)
122 1.1 christos #endif
123 1.1 christos
124 1.1 christos #define INTBITS (0xc0L)
125 1.1 christos
126 1.1 christos #if defined MODET && defined MODE32
127 1.1 christos #define PCBITS (0xffffffffL)
128 1.1 christos #else
129 1.1 christos #define PCBITS (0xfffffffcL)
130 1.1 christos #endif
131 1.1 christos
132 1.1 christos #define MODEBITS (0x1fL)
133 1.1 christos #define R15INTBITS (3L << 26)
134 1.1 christos
135 1.1 christos #if defined MODET && defined MODE32
136 1.1 christos #define R15PCBITS (0x03ffffffL)
137 1.1 christos #else
138 1.1 christos #define R15PCBITS (0x03fffffcL)
139 1.1 christos #endif
140 1.1 christos
141 1.1 christos #define R15PCMODEBITS (0x03ffffffL)
142 1.1 christos #define R15MODEBITS (0x3L)
143 1.1 christos
144 1.1 christos #ifdef MODE32
145 1.1 christos #define PCMASK PCBITS
146 1.1 christos #define PCWRAP(pc) (pc)
147 1.1 christos #else
148 1.1 christos #define PCMASK R15PCBITS
149 1.1 christos #define PCWRAP(pc) ((pc) & R15PCBITS)
150 1.1 christos #endif
151 1.1 christos
152 1.1 christos #define PC (state->Reg[15] & PCMASK)
153 1.1 christos #define R15CCINTMODE (state->Reg[15] & (CCBITS | R15INTBITS | R15MODEBITS))
154 1.1 christos #define R15INT (state->Reg[15] & R15INTBITS)
155 1.1 christos #define R15INTPC (state->Reg[15] & (R15INTBITS | R15PCBITS))
156 1.1 christos #define R15INTPCMODE (state->Reg[15] & (R15INTBITS | R15PCBITS | R15MODEBITS))
157 1.1 christos #define R15INTMODE (state->Reg[15] & (R15INTBITS | R15MODEBITS))
158 1.1 christos #define R15PC (state->Reg[15] & R15PCBITS)
159 1.1 christos #define R15PCMODE (state->Reg[15] & (R15PCBITS | R15MODEBITS))
160 1.1 christos #define R15MODE (state->Reg[15] & R15MODEBITS)
161 1.1 christos
162 1.1 christos #define ECC ((NFLAG << 31) | (ZFLAG << 30) | (CFLAG << 29) | (VFLAG << 28) | (SFLAG << 27))
163 1.1 christos #define EINT (IFFLAGS << 6)
164 1.1 christos #define ER15INT (IFFLAGS << 26)
165 1.1 christos #define EMODE (state->Mode)
166 1.1 christos
167 1.1 christos #ifdef MODET
168 1.1 christos #define CPSR (ECC | EINT | EMODE | (TFLAG << 5))
169 1.1 christos #else
170 1.1 christos #define CPSR (ECC | EINT | EMODE)
171 1.1 christos #endif
172 1.1 christos
173 1.1 christos #ifdef MODE32
174 1.1 christos #define PATCHR15
175 1.1 christos #else
176 1.1 christos #define PATCHR15 state->Reg[15] = ECC | ER15INT | EMODE | R15PC
177 1.1 christos #endif
178 1.1 christos
179 1.1 christos #define GETSPSR(bank) (ARMul_GetSPSR (state, EMODE))
180 1.1 christos #define SETPSR_F(d,s) d = ((d) & ~PSR_FBITS) | ((s) & PSR_FBITS)
181 1.1 christos #define SETPSR_S(d,s) d = ((d) & ~PSR_SBITS) | ((s) & PSR_SBITS)
182 1.1 christos #define SETPSR_X(d,s) d = ((d) & ~PSR_XBITS) | ((s) & PSR_XBITS)
183 1.1 christos #define SETPSR_C(d,s) d = ((d) & ~PSR_CBITS) | ((s) & PSR_CBITS)
184 1.1 christos
185 1.1 christos #define SETR15PSR(s) \
186 1.1 christos do \
187 1.1 christos { \
188 1.1 christos if (state->Mode == USER26MODE) \
189 1.1 christos { \
190 1.1 christos state->Reg[15] = ((s) & CCBITS) | R15PC | ER15INT | EMODE; \
191 1.1 christos ASSIGNN ((state->Reg[15] & NBIT) != 0); \
192 1.1 christos ASSIGNZ ((state->Reg[15] & ZBIT) != 0); \
193 1.1 christos ASSIGNC ((state->Reg[15] & CBIT) != 0); \
194 1.1 christos ASSIGNV ((state->Reg[15] & VBIT) != 0); \
195 1.1 christos } \
196 1.1 christos else \
197 1.1 christos { \
198 1.1 christos state->Reg[15] = R15PC | ((s) & (CCBITS | R15INTBITS | R15MODEBITS)); \
199 1.1 christos ARMul_R15Altered (state); \
200 1.1 christos } \
201 1.1 christos } \
202 1.1 christos while (0)
203 1.1 christos
204 1.1 christos #define SETABORT(i, m, d) \
205 1.1 christos do \
206 1.1 christos { \
207 1.1 christos int SETABORT_mode = (m); \
208 1.1 christos \
209 1.1 christos ARMul_SetSPSR (state, SETABORT_mode, ARMul_GetCPSR (state)); \
210 1.1 christos ARMul_SetCPSR (state, ((ARMul_GetCPSR (state) & ~(EMODE | TBIT)) \
211 1.1 christos | (i) | SETABORT_mode)); \
212 1.1 christos state->Reg[14] = temp - (d); \
213 1.1 christos } \
214 1.1 christos while (0)
215 1.1 christos
216 1.1 christos #ifndef MODE32
217 1.1 christos #define VECTORS 0x20
218 1.1 christos #define LEGALADDR 0x03ffffff
219 1.1 christos #define VECTORACCESS(address) (address < VECTORS && ARMul_MODE26BIT && state->prog32Sig)
220 1.1 christos #define ADDREXCEPT(address) (address > LEGALADDR && !state->data32Sig)
221 1.1 christos #endif
222 1.1 christos
223 1.1 christos #define INTERNALABORT(address) \
224 1.1 christos do \
225 1.1 christos { \
226 1.1 christos if (address < VECTORS) \
227 1.1 christos state->Aborted = ARMul_DataAbortV; \
228 1.1 christos else \
229 1.1 christos state->Aborted = ARMul_AddrExceptnV; \
230 1.1 christos } \
231 1.1 christos while (0)
232 1.1 christos
233 1.1 christos #ifdef MODE32
234 1.1 christos #define TAKEABORT ARMul_Abort (state, ARMul_DataAbortV)
235 1.1 christos #else
236 1.1 christos #define TAKEABORT \
237 1.1 christos do \
238 1.1 christos { \
239 1.1 christos if (state->Aborted == ARMul_AddrExceptnV) \
240 1.1 christos ARMul_Abort (state, ARMul_AddrExceptnV); \
241 1.1 christos else \
242 1.1 christos ARMul_Abort (state, ARMul_DataAbortV); \
243 1.1 christos } \
244 1.1 christos while (0)
245 1.1 christos #endif
246 1.1 christos
247 1.1 christos #define CPTAKEABORT \
248 1.1 christos do \
249 1.1 christos { \
250 1.1 christos if (!state->Aborted) \
251 1.1 christos ARMul_Abort (state, ARMul_UndefinedInstrV); \
252 1.1 christos else if (state->Aborted == ARMul_AddrExceptnV) \
253 1.1 christos ARMul_Abort (state, ARMul_AddrExceptnV); \
254 1.1 christos else \
255 1.1 christos ARMul_Abort (state, ARMul_DataAbortV); \
256 1.1 christos } \
257 1.1 christos while (0);
258 1.1 christos
259 1.1 christos
260 1.1 christos /* Different ways to start the next instruction. */
261 1.1 christos #define SEQ 0
262 1.1 christos #define NONSEQ 1
263 1.1 christos #define PCINCEDSEQ 2
264 1.1 christos #define PCINCEDNONSEQ 3
265 1.1 christos #define PRIMEPIPE 4
266 1.1 christos #define RESUME 8
267 1.1 christos
268 1.1 christos #define NORMALCYCLE state->NextInstr = 0
269 1.1 christos #define BUSUSEDN state->NextInstr |= 1 /* The next fetch will be an N cycle. */
270 1.1 christos #define BUSUSEDINCPCS \
271 1.1 christos do \
272 1.1 christos { \
273 1.1 christos if (! state->is_v4) \
274 1.1 christos { \
275 1.1 christos /* A standard PC inc and an S cycle. */ \
276 1.1 christos state->Reg[15] += isize; \
277 1.1 christos state->NextInstr = (state->NextInstr & 0xff) | 2; \
278 1.1 christos } \
279 1.1 christos } \
280 1.1 christos while (0)
281 1.1 christos
282 1.1 christos #define BUSUSEDINCPCN \
283 1.1 christos do \
284 1.1 christos { \
285 1.1 christos if (state->is_v4) \
286 1.1 christos BUSUSEDN; \
287 1.1 christos else \
288 1.1 christos { \
289 1.1 christos /* A standard PC inc and an N cycle. */ \
290 1.1 christos state->Reg[15] += isize; \
291 1.1 christos state->NextInstr |= 3; \
292 1.1 christos } \
293 1.1 christos } \
294 1.1 christos while (0)
295 1.1 christos
296 1.1 christos #define INCPC \
297 1.1 christos do \
298 1.1 christos { \
299 1.1 christos /* A standard PC inc. */ \
300 1.1 christos state->Reg[15] += isize; \
301 1.1 christos state->NextInstr |= 2; \
302 1.1 christos } \
303 1.1 christos while (0)
304 1.1 christos
305 1.1 christos #define FLUSHPIPE state->NextInstr |= PRIMEPIPE
306 1.1 christos
307 1.1 christos /* Cycle based emulation. */
308 1.1 christos
309 1.1 christos #define OUTPUTCP(i,a,b)
310 1.1 christos #define NCYCLE
311 1.1 christos #define SCYCLE
312 1.1 christos #define ICYCLE
313 1.1 christos #define CCYCLE
314 1.1 christos #define NEXTCYCLE(c)
315 1.1 christos
316 1.1 christos /* Macros to extract parts of instructions. */
317 1.1 christos #define DESTReg (BITS (12, 15))
318 1.1 christos #define LHSReg (BITS (16, 19))
319 1.1 christos #define RHSReg (BITS ( 0, 3))
320 1.1 christos
321 1.1 christos #define DEST (state->Reg[DESTReg])
322 1.1 christos
323 1.1 christos #ifdef MODE32
324 1.1 christos #ifdef MODET
325 1.1 christos #define LHS ((LHSReg == 15) ? (state->Reg[15] & 0xFFFFFFFC): (state->Reg[LHSReg]))
326 1.1 christos #else
327 1.1 christos #define LHS (state->Reg[LHSReg])
328 1.1 christos #endif
329 1.1 christos #else
330 1.1 christos #define LHS ((LHSReg == 15) ? R15PC : (state->Reg[LHSReg]))
331 1.1 christos #endif
332 1.1 christos
333 1.1 christos #define MULDESTReg (BITS (16, 19))
334 1.1 christos #define MULLHSReg (BITS ( 0, 3))
335 1.1 christos #define MULRHSReg (BITS ( 8, 11))
336 1.1 christos #define MULACCReg (BITS (12, 15))
337 1.1 christos
338 1.1 christos #define DPImmRHS (ARMul_ImmedTable[BITS(0, 11)])
339 1.1 christos #define DPSImmRHS temp = BITS(0,11) ; \
340 1.1 christos rhs = ARMul_ImmedTable[temp] ; \
341 1.1 christos if (temp > 255) /* There was a shift. */ \
342 1.1 christos ASSIGNC (rhs >> 31) ;
343 1.1 christos
344 1.1 christos #ifdef MODE32
345 1.1 christos #define DPRegRHS ((BITS (4,11) == 0) ? state->Reg[RHSReg] \
346 1.1 christos : GetDPRegRHS (state, instr))
347 1.1 christos #define DPSRegRHS ((BITS (4,11) == 0) ? state->Reg[RHSReg] \
348 1.1 christos : GetDPSRegRHS (state, instr))
349 1.1 christos #else
350 1.1 christos #define DPRegRHS ((BITS (0, 11) < 15) ? state->Reg[RHSReg] \
351 1.1 christos : GetDPRegRHS (state, instr))
352 1.1 christos #define DPSRegRHS ((BITS (0, 11) < 15) ? state->Reg[RHSReg] \
353 1.1 christos : GetDPSRegRHS (state, instr))
354 1.1 christos #endif
355 1.1 christos
356 1.1 christos #define LSBase state->Reg[LHSReg]
357 1.1 christos #define LSImmRHS (BITS(0,11))
358 1.1 christos
359 1.1 christos #ifdef MODE32
360 1.1 christos #define LSRegRHS ((BITS (4, 11) == 0) ? state->Reg[RHSReg] \
361 1.1 christos : GetLSRegRHS (state, instr))
362 1.1 christos #else
363 1.1 christos #define LSRegRHS ((BITS (0, 11) < 15) ? state->Reg[RHSReg] \
364 1.1 christos : GetLSRegRHS (state, instr))
365 1.1 christos #endif
366 1.1 christos
367 1.1 christos #define LSMNumRegs ((ARMword) ARMul_BitList[BITS (0, 7)] + \
368 1.1 christos (ARMword) ARMul_BitList[BITS (8, 15)] )
369 1.1 christos #define LSMBaseFirst ((LHSReg == 0 && BIT (0)) || \
370 1.1 christos (BIT (LHSReg) && BITS (0, LHSReg - 1) == 0))
371 1.1 christos
372 1.1 christos #define SWAPSRC (state->Reg[RHSReg])
373 1.1 christos
374 1.1 christos #define LSCOff (BITS (0, 7) << 2)
375 1.1 christos #define CPNum BITS (8, 11)
376 1.1 christos
377 1.1 christos /* Determine if access to coprocessor CP is permitted.
378 1.1 christos The XScale has a register in CP15 which controls access to CP0 - CP13. */
379 1.1 christos #define CP_ACCESS_ALLOWED(STATE, CP) \
380 1.1 christos ( ((CP) >= 14) \
381 1.1 christos || (! (STATE)->is_XScale) \
382 1.1 christos || (read_cp15_reg (15, 0, 1) & (1 << (CP))))
383 1.1 christos
384 1.1 christos /* Macro to rotate n right by b bits. */
385 1.1 christos #define ROTATER(n, b) (((n) >> (b)) | ((n) << (32 - (b))))
386 1.1 christos
387 1.1 christos /* Macros to store results of instructions. */
388 1.1 christos #define WRITEDEST(d) \
389 1.1 christos do \
390 1.1 christos { \
391 1.1 christos if (DESTReg == 15) \
392 1.1 christos WriteR15 (state, d); \
393 1.1 christos else \
394 1.1 christos DEST = d; \
395 1.1 christos } \
396 1.1 christos while (0)
397 1.1 christos
398 1.1 christos #define WRITESDEST(d) \
399 1.1 christos do \
400 1.1 christos { \
401 1.1 christos if (DESTReg == 15) \
402 1.1 christos WriteSR15 (state, d); \
403 1.1 christos else \
404 1.1 christos { \
405 1.1 christos DEST = d; \
406 1.1 christos ARMul_NegZero (state, d); \
407 1.1 christos } \
408 1.1 christos } \
409 1.1 christos while (0)
410 1.1 christos
411 1.1 christos #define WRITEDESTB(d) \
412 1.1 christos do \
413 1.1 christos { \
414 1.1 christos if (DESTReg == 15) \
415 1.3 christos WriteR15Load (state, d); \
416 1.1 christos else \
417 1.1 christos DEST = d; \
418 1.1 christos } \
419 1.1 christos while (0)
420 1.1 christos
421 1.1 christos #define BYTETOBUS(data) ((data & 0xff) | \
422 1.1 christos ((data & 0xff) << 8) | \
423 1.1 christos ((data & 0xff) << 16) | \
424 1.1 christos ((data & 0xff) << 24))
425 1.1 christos
426 1.1 christos #define BUSTOBYTE(address, data) \
427 1.1 christos do \
428 1.1 christos { \
429 1.1 christos if (state->bigendSig) \
430 1.1 christos temp = (data >> (((address ^ 3) & 3) << 3)) & 0xff; \
431 1.1 christos else \
432 1.1 christos temp = (data >> ((address & 3) << 3)) & 0xff; \
433 1.1 christos } \
434 1.1 christos while (0)
435 1.1 christos
436 1.1 christos #define LOADMULT(instr, address, wb) LoadMult (state, instr, address, wb)
437 1.1 christos #define LOADSMULT(instr, address, wb) LoadSMult (state, instr, address, wb)
438 1.1 christos #define STOREMULT(instr, address, wb) StoreMult (state, instr, address, wb)
439 1.1 christos #define STORESMULT(instr, address, wb) StoreSMult (state, instr, address, wb)
440 1.1 christos
441 1.1 christos #define POSBRANCH ((instr & 0x7fffff) << 2)
442 1.1 christos #define NEGBRANCH ((0xff000000 |(instr & 0xffffff)) << 2)
443 1.1 christos
444 1.1 christos
445 1.1 christos /* Values for Emulate. */
446 1.1 christos #define STOP 0 /* stop */
447 1.1 christos #define CHANGEMODE 1 /* change mode */
448 1.1 christos #define ONCE 2 /* execute just one interation */
449 1.1 christos #define RUN 3 /* continuous execution */
450 1.1 christos
451 1.1 christos /* Stuff that is shared across modes. */
452 1.1 christos extern unsigned ARMul_MultTable[]; /* Number of I cycles for a mult. */
453 1.1 christos extern ARMword ARMul_ImmedTable[]; /* Immediate DP LHS values. */
454 1.1 christos extern char ARMul_BitList[]; /* Number of bits in a byte table. */
455 1.1 christos
456 1.1 christos #define EVENTLISTSIZE 1024L
457 1.1 christos
458 1.1 christos /* Thumb support. */
459 1.1 christos typedef enum
460 1.1 christos {
461 1.1 christos t_undefined, /* Undefined Thumb instruction. */
462 1.1 christos t_decoded, /* Instruction decoded to ARM equivalent. */
463 1.1 christos t_branch /* Thumb branch (already processed). */
464 1.1 christos }
465 1.1 christos tdstate;
466 1.1 christos
467 1.5 christos #define t_resolved t_branch
468 1.5 christos
469 1.5 christos /* Macros to scrutinize instructions. The dummy do loop is to keep the compiler
470 1.5 christos happy when the statement is used in an otherwise empty else statement. */
471 1.5 christos #define UNDEF_Test do { ; } while (0)
472 1.5 christos #define UNDEF_Shift do { ; } while (0)
473 1.5 christos #define UNDEF_MSRPC do { ; } while (0)
474 1.5 christos #define UNDEF_MRSPC do { ; } while (0)
475 1.5 christos #define UNDEF_MULPCDest do { ; } while (0)
476 1.5 christos #define UNDEF_MULDestEQOp1 do { ; } while (0)
477 1.5 christos #define UNDEF_LSRBPC do { ; } while (0)
478 1.5 christos #define UNDEF_LSRBaseEQOffWb do { ; } while (0)
479 1.5 christos #define UNDEF_LSRBaseEQDestWb do { ; } while (0)
480 1.5 christos #define UNDEF_LSRPCBaseWb do { ; } while (0)
481 1.5 christos #define UNDEF_LSRPCOffWb do { ; } while (0)
482 1.5 christos #define UNDEF_LSMNoRegs do { ; } while (0)
483 1.5 christos #define UNDEF_LSMPCBase do { ; } while (0)
484 1.5 christos #define UNDEF_LSMUserBankWb do { ; } while (0)
485 1.5 christos #define UNDEF_LSMBaseInListWb do { ; } while (0)
486 1.5 christos #define UNDEF_SWPPC do { ; } while (0)
487 1.5 christos #define UNDEF_CoProHS do { ; } while (0)
488 1.5 christos #define UNDEF_MCRPC do { ; } while (0)
489 1.5 christos #define UNDEF_LSCPCBaseWb do { ; } while (0)
490 1.5 christos #define UNDEF_UndefNotBounced do { ; } while (0)
491 1.5 christos #define UNDEF_ShortInt do { ; } while (0)
492 1.5 christos #define UNDEF_IllegalMode do { ; } while (0)
493 1.5 christos #define UNDEF_Prog32SigChange do { ; } while (0)
494 1.5 christos #define UNDEF_Data32SigChange do { ; } while (0)
495 1.1 christos
496 1.1 christos /* Prototypes for exported functions. */
497 1.1 christos extern unsigned ARMul_NthReg (ARMword, unsigned);
498 1.1 christos extern int AddOverflow (ARMword, ARMword, ARMword);
499 1.1 christos extern int SubOverflow (ARMword, ARMword, ARMword);
500 1.1 christos extern ARMword ARMul_Emulate26 (ARMul_State *);
501 1.1 christos extern ARMword ARMul_Emulate32 (ARMul_State *);
502 1.1 christos extern unsigned IntPending (ARMul_State *);
503 1.1 christos extern void ARMul_CPSRAltered (ARMul_State *);
504 1.1 christos extern void ARMul_R15Altered (ARMul_State *);
505 1.1 christos extern ARMword ARMul_GetPC (ARMul_State *);
506 1.1 christos extern ARMword ARMul_GetNextPC (ARMul_State *);
507 1.1 christos extern ARMword ARMul_GetR15 (ARMul_State *);
508 1.1 christos extern ARMword ARMul_GetCPSR (ARMul_State *);
509 1.1 christos extern void ARMul_EnvokeEvent (ARMul_State *);
510 1.1 christos extern unsigned long ARMul_Time (ARMul_State *);
511 1.1 christos extern void ARMul_NegZero (ARMul_State *, ARMword);
512 1.1 christos extern void ARMul_SetPC (ARMul_State *, ARMword);
513 1.1 christos extern void ARMul_SetR15 (ARMul_State *, ARMword);
514 1.1 christos extern void ARMul_SetCPSR (ARMul_State *, ARMword);
515 1.1 christos extern ARMword ARMul_GetSPSR (ARMul_State *, ARMword);
516 1.1 christos extern void ARMul_Abort26 (ARMul_State *, ARMword);
517 1.1 christos extern void ARMul_Abort32 (ARMul_State *, ARMword);
518 1.1 christos extern ARMword ARMul_MRC (ARMul_State *, ARMword);
519 1.1 christos extern void ARMul_CDP (ARMul_State *, ARMword);
520 1.1 christos extern void ARMul_LDC (ARMul_State *, ARMword, ARMword);
521 1.1 christos extern void ARMul_STC (ARMul_State *, ARMword, ARMword);
522 1.1 christos extern void ARMul_MCR (ARMul_State *, ARMword, ARMword);
523 1.1 christos extern void ARMul_SetSPSR (ARMul_State *, ARMword, ARMword);
524 1.1 christos extern ARMword ARMul_SwitchMode (ARMul_State *, ARMword, ARMword);
525 1.1 christos extern ARMword ARMul_Align (ARMul_State *, ARMword, ARMword);
526 1.1 christos extern ARMword ARMul_SwitchMode (ARMul_State *, ARMword, ARMword);
527 1.1 christos extern void ARMul_MSRCpsr (ARMul_State *, ARMword, ARMword);
528 1.1 christos extern void ARMul_SubOverflow (ARMul_State *, ARMword, ARMword, ARMword);
529 1.1 christos extern void ARMul_AddOverflow (ARMul_State *, ARMword, ARMword, ARMword);
530 1.1 christos extern void ARMul_SubCarry (ARMul_State *, ARMword, ARMword, ARMword);
531 1.1 christos extern void ARMul_AddCarry (ARMul_State *, ARMword, ARMword, ARMword);
532 1.1 christos extern tdstate ARMul_ThumbDecode (ARMul_State *, ARMword, ARMword, ARMword *);
533 1.1 christos extern ARMword ARMul_GetReg (ARMul_State *, unsigned, unsigned);
534 1.1 christos extern void ARMul_SetReg (ARMul_State *, unsigned, unsigned, ARMword);
535 1.1 christos extern void ARMul_ScheduleEvent (ARMul_State *, unsigned long, unsigned (*) (ARMul_State *));
536 1.1 christos /* Coprocessor support functions. */
537 1.1 christos extern unsigned ARMul_CoProInit (ARMul_State *);
538 1.1 christos extern void ARMul_CoProExit (ARMul_State *);
539 1.1 christos extern void ARMul_CoProAttach (ARMul_State *, unsigned, ARMul_CPInits *, ARMul_CPExits *,
540 1.1 christos ARMul_LDCs *, ARMul_STCs *, ARMul_MRCs *, ARMul_MCRs *,
541 1.1 christos ARMul_CDPs *, ARMul_CPReads *, ARMul_CPWrites *);
542 1.1 christos extern void ARMul_CoProDetach (ARMul_State *, unsigned);
543 1.1 christos extern ARMword read_cp15_reg (unsigned, unsigned, unsigned);
544 1.1 christos
545 1.1 christos extern unsigned DSPLDC4 (ARMul_State *, unsigned, ARMword, ARMword);
546 1.1 christos extern unsigned DSPMCR4 (ARMul_State *, unsigned, ARMword, ARMword);
547 1.1 christos extern unsigned DSPMRC4 (ARMul_State *, unsigned, ARMword, ARMword *);
548 1.1 christos extern unsigned DSPSTC4 (ARMul_State *, unsigned, ARMword, ARMword *);
549 1.1 christos extern unsigned DSPCDP4 (ARMul_State *, unsigned, ARMword);
550 1.1 christos extern unsigned DSPMCR5 (ARMul_State *, unsigned, ARMword, ARMword);
551 1.1 christos extern unsigned DSPMRC5 (ARMul_State *, unsigned, ARMword, ARMword *);
552 1.1 christos extern unsigned DSPLDC5 (ARMul_State *, unsigned, ARMword, ARMword);
553 1.1 christos extern unsigned DSPSTC5 (ARMul_State *, unsigned, ARMword, ARMword *);
554 1.1 christos extern unsigned DSPCDP5 (ARMul_State *, unsigned, ARMword);
555 1.1 christos extern unsigned DSPMCR6 (ARMul_State *, unsigned, ARMword, ARMword);
556 1.1 christos extern unsigned DSPMRC6 (ARMul_State *, unsigned, ARMword, ARMword *);
557 1.1 christos extern unsigned DSPCDP6 (ARMul_State *, unsigned, ARMword);
558