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