remove conflict indicator.
[deliverable/binutils-gdb.git] / sim / arm / armdefs.h
CommitLineData
c906108c
SS
1/* armdefs.h -- ARMulator common definitions: ARM6 Instruction Emulator.
2 Copyright (C) 1994 Advanced RISC Machines Ltd.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17
18#include <stdio.h>
19#include <stdlib.h>
20
21#define FALSE 0
22#define TRUE 1
23#define LOW 0
24#define HIGH 1
25#define LOWHIGH 1
26#define HIGHLOW 2
27
28#ifndef __STDC__
dfcd3bfb 29typedef char *VoidStar;
c906108c
SS
30#endif
31
dfcd3bfb 32typedef unsigned long ARMword; /* must be 32 bits wide */
f1129fb8 33typedef unsigned long long ARMdword; /* Must be at least 64 bits wide. */
dfcd3bfb
JM
34typedef struct ARMul_State ARMul_State;
35
36typedef unsigned ARMul_CPInits (ARMul_State * state);
37typedef unsigned ARMul_CPExits (ARMul_State * state);
38typedef unsigned ARMul_LDCs (ARMul_State * state, unsigned type,
39 ARMword instr, ARMword value);
40typedef unsigned ARMul_STCs (ARMul_State * state, unsigned type,
41 ARMword instr, ARMword * value);
42typedef unsigned ARMul_MRCs (ARMul_State * state, unsigned type,
43 ARMword instr, ARMword * value);
44typedef unsigned ARMul_MCRs (ARMul_State * state, unsigned type,
45 ARMword instr, ARMword value);
46typedef unsigned ARMul_CDPs (ARMul_State * state, unsigned type,
47 ARMword instr);
48typedef unsigned ARMul_CPReads (ARMul_State * state, unsigned reg,
49 ARMword * value);
50typedef unsigned ARMul_CPWrites (ARMul_State * state, unsigned reg,
51 ARMword value);
52
53struct ARMul_State
54{
55 ARMword Emulate; /* to start and stop emulation */
56 unsigned EndCondition; /* reason for stopping */
57 unsigned ErrorCode; /* type of illegal instruction */
58 ARMword Reg[16]; /* the current register file */
59 ARMword RegBank[7][16]; /* all the registers */
f1129fb8
NC
60 /* 40 bit accumulator. We always keep this 64 bits wide,
61 and move only 40 bits out of it in an MRA insn. */
62 ARMdword Accumulator;
dfcd3bfb
JM
63 ARMword Cpsr; /* the current psr */
64 ARMword Spsr[7]; /* the exception psr's */
65 ARMword NFlag, ZFlag, CFlag, VFlag, IFFlags; /* dummy flags for speed */
f1129fb8 66 ARMword SFlag;
c906108c 67#ifdef MODET
dfcd3bfb 68 ARMword TFlag; /* Thumb state */
c906108c 69#endif
dfcd3bfb
JM
70 ARMword Bank; /* the current register bank */
71 ARMword Mode; /* the current mode */
72 ARMword instr, pc, temp; /* saved register state */
73 ARMword loaded, decoded; /* saved pipeline state */
74 unsigned long NumScycles, NumNcycles, NumIcycles, NumCcycles, NumFcycles; /* emulated cycles used */
75 unsigned long NumInstrs; /* the number of instructions executed */
76 unsigned NextInstr;
77 unsigned VectorCatch; /* caught exception mask */
78 unsigned CallDebug; /* set to call the debugger */
79 unsigned CanWatch; /* set by memory interface if its willing to suffer the
80 overhead of checking for watchpoints on each memory
81 access */
82 unsigned MemReadDebug, MemWriteDebug;
83 unsigned long StopHandle;
84
85 unsigned char *MemDataPtr; /* admin data */
86 unsigned char *MemInPtr; /* the Data In bus */
87 unsigned char *MemOutPtr; /* the Data Out bus (which you may not need */
88 unsigned char *MemSparePtr; /* extra space */
89 ARMword MemSize;
90
91 unsigned char *OSptr; /* OS Handle */
92 char *CommandLine; /* Command Line from ARMsd */
93
94 ARMul_CPInits *CPInit[16]; /* coprocessor initialisers */
95 ARMul_CPExits *CPExit[16]; /* coprocessor finalisers */
96 ARMul_LDCs *LDC[16]; /* LDC instruction */
97 ARMul_STCs *STC[16]; /* STC instruction */
98 ARMul_MRCs *MRC[16]; /* MRC instruction */
99 ARMul_MCRs *MCR[16]; /* MCR instruction */
100 ARMul_CDPs *CDP[16]; /* CDP instruction */
101 ARMul_CPReads *CPRead[16]; /* Read CP register */
102 ARMul_CPWrites *CPWrite[16]; /* Write CP register */
103 unsigned char *CPData[16]; /* Coprocessor data */
104 unsigned char const *CPRegWords[16]; /* map of coprocessor register sizes */
105
106 unsigned EventSet; /* the number of events in the queue */
107 unsigned long Now; /* time to the nearest cycle */
108 struct EventNode **EventPtr; /* the event list */
109
110 unsigned Exception; /* enable the next four values */
111 unsigned Debug; /* show instructions as they are executed */
112 unsigned NresetSig; /* reset the processor */
113 unsigned NfiqSig;
114 unsigned NirqSig;
115
116 unsigned abortSig;
117 unsigned NtransSig;
118 unsigned bigendSig;
119 unsigned prog32Sig;
120 unsigned data32Sig;
121 unsigned lateabtSig;
122 ARMword Vector; /* synthesize aborts in cycle modes */
123 ARMword Aborted; /* sticky flag for aborts */
124 ARMword Reseted; /* sticky flag for Reset */
125 ARMword Inted, LastInted; /* sticky flags for interrupts */
126 ARMword Base; /* extra hand for base writeback */
127 ARMword AbortAddr; /* to keep track of Prefetch aborts */
128
129 const struct Dbg_HostosInterface *hostif;
130
3943c96b
NC
131 unsigned is_v4; /* Are we emulating a v4 architecture (or higher) ? */
132 unsigned is_v5; /* Are we emulating a v5 architecture ? */
f1129fb8
NC
133 unsigned is_v5e; /* Are we emulating a v5e architecture ? */
134 unsigned is_XScale; /* Are we emulating an XScale architecture ? */
3943c96b 135 unsigned verbose; /* Print various messages like the banner */
dfcd3bfb 136};
c906108c
SS
137
138#define ResetPin NresetSig
139#define FIQPin NfiqSig
140#define IRQPin NirqSig
141#define AbortPin abortSig
142#define TransPin NtransSig
143#define BigEndPin bigendSig
144#define Prog32Pin prog32Sig
145#define Data32Pin data32Sig
146#define LateAbortPin lateabtSig
147
148/***************************************************************************\
3943c96b 149* Properties of ARM we know about *
c906108c 150\***************************************************************************/
dfcd3bfb 151
c906108c
SS
152/* The bitflags */
153#define ARM_Fix26_Prop 0x01
154#define ARM_Nexec_Prop 0x02
155#define ARM_Debug_Prop 0x10
156#define ARM_Isync_Prop ARM_Debug_Prop
157#define ARM_Lock_Prop 0x20
3943c96b
NC
158#define ARM_v4_Prop 0x40
159#define ARM_v5_Prop 0x80
f1129fb8
NC
160#define ARM_v5e_Prop 0x100
161#define ARM_XScale_Prop 0x200
c906108c
SS
162
163/***************************************************************************\
164* Macros to extract instruction fields *
165\***************************************************************************/
166
dfcd3bfb
JM
167#define BIT(n) ( (ARMword)(instr>>(n))&1) /* bit n of instruction */
168#define BITS(m,n) ( (ARMword)(instr<<(31-(n))) >> ((31-(n))+(m)) ) /* bits m to n of instr */
169#define TOPBITS(n) (instr >> (n)) /* bits 31 to n of instr */
c906108c
SS
170
171/***************************************************************************\
172* The hardware vector addresses *
173\***************************************************************************/
174
175#define ARMResetV 0L
176#define ARMUndefinedInstrV 4L
177#define ARMSWIV 8L
178#define ARMPrefetchAbortV 12L
179#define ARMDataAbortV 16L
180#define ARMAddrExceptnV 20L
181#define ARMIRQV 24L
182#define ARMFIQV 28L
dfcd3bfb 183#define ARMErrorV 32L /* This is an offset, not an address ! */
c906108c
SS
184
185#define ARMul_ResetV ARMResetV
186#define ARMul_UndefinedInstrV ARMUndefinedInstrV
187#define ARMul_SWIV ARMSWIV
188#define ARMul_PrefetchAbortV ARMPrefetchAbortV
189#define ARMul_DataAbortV ARMDataAbortV
190#define ARMul_AddrExceptnV ARMAddrExceptnV
191#define ARMul_IRQV ARMIRQV
192#define ARMul_FIQV ARMFIQV
193
194/***************************************************************************\
195* Mode and Bank Constants *
196\***************************************************************************/
197
c1a72ffd
NC
198#define USER26MODE 0L
199#define FIQ26MODE 1L
200#define IRQ26MODE 2L
201#define SVC26MODE 3L
202#define USER32MODE 16L
203#define FIQ32MODE 17L
204#define IRQ32MODE 18L
205#define SVC32MODE 19L
c906108c
SS
206#define ABORT32MODE 23L
207#define UNDEF32MODE 27L
c1a72ffd 208#define SYSTEMMODE 31L
c906108c
SS
209
210#define ARM32BITMODE (state->Mode > 3)
211#define ARM26BITMODE (state->Mode <= 3)
212#define ARMMODE (state->Mode)
213#define ARMul_MODEBITS 0x1fL
214#define ARMul_MODE32BIT ARM32BITMODE
215#define ARMul_MODE26BIT ARM26BITMODE
216
217#define USERBANK 0
218#define FIQBANK 1
219#define IRQBANK 2
220#define SVCBANK 3
221#define ABORTBANK 4
222#define UNDEFBANK 5
223#define DUMMYBANK 6
b0eae074 224#define SYSTEMBANK USERBANK
c1a72ffd
NC
225
226#define BANK_CAN_ACCESS_SPSR(bank) \
227 ((bank) != USERBANK && (bank) != SYSTEMBANK && (bank) != DUMMYBANK)
c906108c
SS
228
229/***************************************************************************\
230* Definitons of things in the emulator *
231\***************************************************************************/
232
dfcd3bfb
JM
233extern void ARMul_EmulateInit (void);
234extern ARMul_State *ARMul_NewState (void);
235extern void ARMul_Reset (ARMul_State * state);
236extern ARMword ARMul_DoProg (ARMul_State * state);
237extern ARMword ARMul_DoInstr (ARMul_State * state);
c906108c
SS
238
239/***************************************************************************\
240* Definitons of things for event handling *
241\***************************************************************************/
242
dfcd3bfb
JM
243extern void ARMul_ScheduleEvent (ARMul_State * state, unsigned long delay,
244 unsigned (*func) ());
245extern void ARMul_EnvokeEvent (ARMul_State * state);
246extern unsigned long ARMul_Time (ARMul_State * state);
c906108c
SS
247
248/***************************************************************************\
249* Useful support routines *
250\***************************************************************************/
251
dfcd3bfb
JM
252extern ARMword ARMul_GetReg (ARMul_State * state, unsigned mode,
253 unsigned reg);
254extern void ARMul_SetReg (ARMul_State * state, unsigned mode, unsigned reg,
255 ARMword value);
256extern ARMword ARMul_GetPC (ARMul_State * state);
257extern ARMword ARMul_GetNextPC (ARMul_State * state);
258extern void ARMul_SetPC (ARMul_State * state, ARMword value);
259extern ARMword ARMul_GetR15 (ARMul_State * state);
260extern void ARMul_SetR15 (ARMul_State * state, ARMword value);
261
262extern ARMword ARMul_GetCPSR (ARMul_State * state);
263extern void ARMul_SetCPSR (ARMul_State * state, ARMword value);
264extern ARMword ARMul_GetSPSR (ARMul_State * state, ARMword mode);
265extern void ARMul_SetSPSR (ARMul_State * state, ARMword mode, ARMword value);
c906108c
SS
266
267/***************************************************************************\
268* Definitons of things to handle aborts *
269\***************************************************************************/
270
dfcd3bfb
JM
271extern void ARMul_Abort (ARMul_State * state, ARMword address);
272#define ARMul_ABORTWORD 0xefffffff /* SWI -1 */
c906108c
SS
273#define ARMul_PREFETCHABORT(address) if (state->AbortAddr == 1) \
274 state->AbortAddr = (address & ~3L)
275#define ARMul_DATAABORT(address) state->abortSig = HIGH ; \
276 state->Aborted = ARMul_DataAbortV ;
277#define ARMul_CLEARABORT state->abortSig = LOW
278
279/***************************************************************************\
280* Definitons of things in the memory interface *
281\***************************************************************************/
282
dfcd3bfb
JM
283extern unsigned ARMul_MemoryInit (ARMul_State * state,
284 unsigned long initmemsize);
285extern void ARMul_MemoryExit (ARMul_State * state);
286
287extern ARMword ARMul_LoadInstrS (ARMul_State * state, ARMword address,
288 ARMword isize);
289extern ARMword ARMul_LoadInstrN (ARMul_State * state, ARMword address,
290 ARMword isize);
291extern ARMword ARMul_ReLoadInstr (ARMul_State * state, ARMword address,
292 ARMword isize);
293
294extern ARMword ARMul_LoadWordS (ARMul_State * state, ARMword address);
295extern ARMword ARMul_LoadWordN (ARMul_State * state, ARMword address);
296extern ARMword ARMul_LoadHalfWord (ARMul_State * state, ARMword address);
297extern ARMword ARMul_LoadByte (ARMul_State * state, ARMword address);
298
299extern void ARMul_StoreWordS (ARMul_State * state, ARMword address,
300 ARMword data);
301extern void ARMul_StoreWordN (ARMul_State * state, ARMword address,
302 ARMword data);
303extern void ARMul_StoreHalfWord (ARMul_State * state, ARMword address,
304 ARMword data);
305extern void ARMul_StoreByte (ARMul_State * state, ARMword address,
306 ARMword data);
307
308extern ARMword ARMul_SwapWord (ARMul_State * state, ARMword address,
309 ARMword data);
310extern ARMword ARMul_SwapByte (ARMul_State * state, ARMword address,
311 ARMword data);
312
313extern void ARMul_Icycles (ARMul_State * state, unsigned number,
314 ARMword address);
315extern void ARMul_Ccycles (ARMul_State * state, unsigned number,
316 ARMword address);
317
318extern ARMword ARMul_ReadWord (ARMul_State * state, ARMword address);
319extern ARMword ARMul_ReadByte (ARMul_State * state, ARMword address);
320extern void ARMul_WriteWord (ARMul_State * state, ARMword address,
321 ARMword data);
322extern void ARMul_WriteByte (ARMul_State * state, ARMword address,
323 ARMword data);
324
325extern ARMword ARMul_MemAccess (ARMul_State * state, ARMword, ARMword,
326 ARMword, ARMword, ARMword, ARMword, ARMword,
327 ARMword, ARMword, ARMword);
c906108c
SS
328
329/***************************************************************************\
330* Definitons of things in the co-processor interface *
331\***************************************************************************/
332
333#define ARMul_FIRST 0
334#define ARMul_TRANSFER 1
335#define ARMul_BUSY 2
336#define ARMul_DATA 3
337#define ARMul_INTERRUPT 4
338#define ARMul_DONE 0
339#define ARMul_CANT 1
340#define ARMul_INC 3
341
dfcd3bfb
JM
342extern unsigned ARMul_CoProInit (ARMul_State * state);
343extern void ARMul_CoProExit (ARMul_State * state);
344extern void ARMul_CoProAttach (ARMul_State * state, unsigned number,
345 ARMul_CPInits * init, ARMul_CPExits * exit,
346 ARMul_LDCs * ldc, ARMul_STCs * stc,
347 ARMul_MRCs * mrc, ARMul_MCRs * mcr,
348 ARMul_CDPs * cdp,
349 ARMul_CPReads * read, ARMul_CPWrites * write);
350extern void ARMul_CoProDetach (ARMul_State * state, unsigned number);
c906108c
SS
351
352/***************************************************************************\
353* Definitons of things in the host environment *
354\***************************************************************************/
355
dfcd3bfb
JM
356extern unsigned ARMul_OSInit (ARMul_State * state);
357extern void ARMul_OSExit (ARMul_State * state);
358extern unsigned ARMul_OSHandleSWI (ARMul_State * state, ARMword number);
359extern ARMword ARMul_OSLastErrorP (ARMul_State * state);
c906108c 360
dfcd3bfb
JM
361extern ARMword ARMul_Debug (ARMul_State * state, ARMword pc, ARMword instr);
362extern unsigned ARMul_OSException (ARMul_State * state, ARMword vector,
363 ARMword pc);
364extern int rdi_log;
c906108c
SS
365
366/***************************************************************************\
367* Host-dependent stuff *
368\***************************************************************************/
369
370#ifdef macintosh
dfcd3bfb 371pascal void SpinCursor (short increment); /* copied from CursorCtl.h */
c906108c 372# define HOURGLASS SpinCursor( 1 )
dfcd3bfb 373# define HOURGLASS_RATE 1023 /* 2^n - 1 */
c906108c 374#endif
6d358e86
NC
375
376extern void ARMul_UndefInstr (ARMul_State *, ARMword);
377extern void ARMul_FixCPSR (ARMul_State *, ARMword, ARMword);
378extern void ARMul_FixSPSR (ARMul_State *, ARMword, ARMword);
379extern void ARMul_ConsolePrint (ARMul_State *, const char *, ...);
380extern void ARMul_SelectProcessor (ARMul_State *, unsigned);
This page took 0.082968 seconds and 4 git commands to generate.