sim: unify SIM_CPU definition
[external/binutils.git] / sim / iq2000 / sim-main.h
1
2 /* Main header for the Vitesse IQ2000.  */
3
4 #ifndef SIM_MAIN_H
5 #define SIM_MAIN_H
6
7 #define USING_SIM_BASE_H /* FIXME: quick hack */
8
9 /* sim-basics.h includes config.h but cgen-types.h must be included before
10    sim-basics.h and cgen-types.h needs config.h.  */
11 #include "config.h"
12
13 #include "symcat.h"
14 #include "sim-basics.h"
15 #include "cgen-types.h"
16 #include "iq2000-desc.h"
17 #include "iq2000-opc.h"
18 #include "arch.h"
19
20 /* Pull in IQ2000_{DATA,INSN}_{MASK,VALUE}.  */
21 #include "elf/iq2000.h"
22
23 #include "sim-base.h"
24 #include "cgen-sim.h"
25 #include "iq2000-sim.h"
26 \f
27 /* The _sim_cpu struct.  */
28
29 struct _sim_cpu {
30   /* sim/common cpu base.  */
31   sim_cpu_base base;
32
33   /* Static parts of cgen.  */
34   CGEN_CPU cgen_cpu;
35
36   /* CPU specific parts go here.
37      Note that in files that don't need to access these pieces WANT_CPU_FOO
38      won't be defined and thus these parts won't appear.  This is ok in the
39      sense that things work.  It is a source of bugs though.
40      One has to of course be careful to not take the size of this
41      struct and no structure members accessed in non-cpu specific files can
42      go after here.  Oh for a better language.  */
43 #if defined (WANT_CPU_IQ2000BF)
44   IQ2000BF_CPU_DATA cpu_data;
45 #endif
46 };
47 \f
48 /* The sim_state struct.  */
49
50 struct sim_state {
51   sim_cpu *cpu[MAX_NR_PROCESSORS];
52
53   CGEN_STATE cgen_state;
54
55   sim_state_base base;
56 };
57 \f
58 /* Misc.  */
59
60 /* Catch address exceptions.  */
61 extern SIM_CORE_SIGNAL_FN iq2000_core_signal;
62 #define SIM_CORE_SIGNAL(SD,CPU,CIA,MAP,NR_BYTES,ADDR,TRANSFER,ERROR) \
63 iq2000_core_signal ((SD), (CPU), (CIA), (MAP), (NR_BYTES), (ADDR), \
64                   (TRANSFER), (ERROR))
65
66 /* Convert between CPU-internal addresses and sim_core addresses.  */
67 #define CPU2DATA(addr) (IQ2000_DATA_VALUE + (addr))
68 #define DATA2CPU(addr) ((addr) - IQ2000_DATA_VALUE)
69 #define CPU2INSN(addr) (IQ2000_INSN_VALUE + ((addr) & ~IQ2000_INSN_MASK))
70 #define INSN2CPU(addr) ((addr) - IQ2000_INSN_VALUE)
71 #define IQ2000_INSN_MEM_SIZE (CPU2INSN(0x800000) - CPU2INSN(0x0000))
72 #define IQ2000_DATA_MEM_SIZE (CPU2DATA(0x800000) - CPU2DATA(0x0000))
73
74 #endif /* SIM_MAIN_H */