]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - sim/v850/sim-main.h
2 #define WITH_MODULO_MEMORY 1
3 #define WITH_WATCHPOINTS 1
4 #define WITH_TARGET_WORD_MSB 31
6 #include "sim-basics.h"
9 typedef address_word sim_cia
;
12 /* This simulator doesn't cache state */
13 #define SIM_ENGINE_HALT_HOOK(sd,last_cpu,cia) while (0)
14 #define SIM_ENGINE_RESTART_HOOK(sd,last_cpu,cia) while (0)
16 /* Get the number of instructions. FIXME: must be a more elegant way
19 #define MAX_INSNS (nr_itable_entries)
20 #define INSN_NAME(i) itable[(i)].name
25 typedef unsigned8 uint8
;
26 typedef signed16 int16
;
27 typedef unsigned16 uint16
;
28 typedef signed32 int32
;
29 typedef unsigned32 uint32
;
30 typedef unsigned32 reg_t
;
33 /* The current state of the processor; registers, memory, etc. */
35 typedef struct _v850_regs
{
36 reg_t regs
[32]; /* general-purpose registers */
37 reg_t sregs
[32]; /* system registers, including psw */
39 int dummy_mem
; /* where invalid accesses go */
45 /* ... simulator specific members ... */
47 /* ... base type ... */
51 #define CPU_CIA(CPU) ((CPU)->reg.pc)
54 sim_cpu cpu
[MAX_NR_PROCESSORS
];
56 #define STATE_CPU(sd,n) (&(sd)->cpu[n])
58 #define STATE_CPU(sd,n) (&(sd)->cpu[0])
70 /* For compatibility, until all functions converted to passing
71 SIM_DESC as an argument */
72 extern SIM_DESC simulator
;
75 #define V850_ROM_SIZE 0x8000
76 #define V850_LOW_END 0x200000
77 #define V850_HIGH_START 0xffe000
80 #define SIG_V850_EXIT -1 /* indication of a normal exit */
84 /* Because we are still using the old semantic table, provide compat
85 macro's that store the instruction where the old simops expects
90 OP
[1] = (inst
>> 11) & 0x1f;
91 OP
[2] = (inst
>> 16) & 0xffff;
95 #define COMPAT_1(CALL) \
97 OP[0] = instruction_0 & 0x1f; \
98 OP[1] = (instruction_0 >> 11) & 0x1f; \
100 OP[3] = instruction_0 ; \
104 #define COMPAT_2(CALL) \
106 OP[0] = instruction_0 & 0x1f; \
107 OP[1] = (instruction_0 >> 11) & 0x1f; \
108 OP[2] = instruction_1; \
109 OP[3] = (instruction_1 << 16) | instruction_0; \
115 extern struct simops Simops
[];
118 #define State (STATE_CPU (simulator, 0)->reg)
119 #define PC (State.pc)
120 #define SP (State.regs[3])
121 #define EP (State.regs[30])
123 #define EIPC (State.sregs[0])
124 #define EIPSW (State.sregs[1])
125 #define FEPC (State.sregs[2])
126 #define FEPSW (State.sregs[3])
127 #define ECR (State.sregs[4])
128 #define PSW (State.sregs[5])
129 /* start-sanitize-v850e */
130 #define CTPC (State.sregs[16])
131 #define CTPSW (State.sregs[17])
132 /* end-sanitize-v850e */
133 #define DBPC (State.sregs[18])
134 #define DBPSW (State.sregs[19])
135 /* start-sanitize-v850e */
136 #define CTBP (State.sregs[20])
137 /* end-sanitize-v850e */
148 #define SEXT3(x) ((((x)&0x7)^(~0x3))+0x4)
150 /* sign-extend a 4-bit number */
151 #define SEXT4(x) ((((x)&0xf)^(~0x7))+0x8)
153 /* sign-extend a 5-bit number */
154 #define SEXT5(x) ((((x)&0x1f)^(~0xf))+0x10)
156 /* sign-extend a 9-bit number */
157 #define SEXT9(x) ((((x)&0x1ff)^(~0xff))+0x100)
159 /* sign-extend a 22-bit number */
160 #define SEXT22(x) ((((x)&0x3fffff)^(~0x1fffff))+0x200000)
162 /* sign extend a 40 bit number */
163 #define SEXT40(x) ((((x) & UNSIGNED64 (0xffffffffff)) \
164 ^ (~UNSIGNED64 (0x7fffffffff))) \
165 + UNSIGNED64 (0x8000000000))
167 /* sign extend a 44 bit number */
168 #define SEXT44(x) ((((x) & UNSIGNED64 (0xfffffffffff)) \
169 ^ (~ UNSIGNED64 (0x7ffffffffff))) \
170 + UNSIGNED64 (0x80000000000))
172 /* sign extend a 60 bit number */
173 #define SEXT60(x) ((((x) & UNSIGNED64 (0xfffffffffffffff)) \
174 ^ (~ UNSIGNED64 (0x7ffffffffffffff))) \
175 + UNSIGNED64 (0x800000000000000))
177 /* No sign extension */
180 #define INC_ADDR(x,i) x = ((State.MD && x == MOD_E) ? MOD_S : (x)+(i))
182 #define RLW(x) load_mem (x, 4)
193 /* Function declarations. */
196 sim_core_read_aligned_2 (STATE_CPU (sd, 0), \
197 PC, sim_core_execute_map, (EA))
199 #define IMEM_IMMED(EA,N) \
200 sim_core_read_aligned_2 (STATE_CPU (sd, 0), \
201 PC, sim_core_execute_map, (EA) + (N) * 2)
203 #define load_mem(ADDR,LEN) \
204 sim_core_read_unaligned_##LEN (STATE_CPU (simulator, 0), \
205 PC, sim_core_read_map, (ADDR))
207 #define store_mem(ADDR,LEN,DATA) \
208 sim_core_write_unaligned_##LEN (STATE_CPU (simulator, 0), \
209 PC, sim_core_write_map, (ADDR), (DATA))