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
29 typedef unsigned8 uint8;
30 typedef signed16 int16;
31 typedef unsigned16 uint16;
32 typedef signed32 int32;
33 typedef unsigned32 uint32;
34 typedef unsigned32 reg_t;
37 /* The current state of the processor; registers, memory, etc. */
39 typedef struct _v850_regs {
40 reg_t regs[32]; /* general-purpose registers */
41 reg_t sregs[32]; /* system registers, including psw */
43 int dummy_mem; /* where invalid accesses go */
49 /* ... simulator specific members ... */
51 /* ... base type ... */
55 #define CPU_CIA(CPU) ((CPU)->reg.pc)
58 sim_cpu cpu[MAX_NR_PROCESSORS];
60 #define STATE_CPU(sd,n) (&(sd)->cpu[n])
62 #define STATE_CPU(sd,n) (&(sd)->cpu[0])
74 /* For compatibility, until all functions converted to passing
75 SIM_DESC as an argument */
76 extern SIM_DESC simulator;
79 #define V850_ROM_SIZE 0x8000
80 #define V850_LOW_END 0x200000
81 #define V850_HIGH_START 0xffe000
84 #define SIG_V850_EXIT -1 /* indication of a normal exit */
88 /* Because we are still using the old semantic table, provide compat
89 macro's that store the instruction where the old simops expects
93 OP[0] = inst & 0x1f; /* RRRRR -> reg1 */
94 OP[1] = (inst >> 11) & 0x1f; /* rrrrr -> reg2 */
95 OP[2] = (inst >> 16) & 0xffff; /* wwwww -> reg3 */
101 OP[0] = instruction_0 & 0x1f; \
102 OP[1] = (instruction_0 >> 11) & 0x1f; \
104 OP[3] = instruction_0
106 #define COMPAT_1(CALL) \
113 OP[0] = instruction_0 & 0x1f; \
114 OP[1] = (instruction_0 >> 11) & 0x1f; \
115 OP[2] = instruction_1; \
116 OP[3] = (instruction_1 << 16) | instruction_0
118 #define COMPAT_2(CALL) \
125 extern struct simops Simops[];
128 #define State (STATE_CPU (simulator, 0)->reg)
129 #define PC (State.pc)
130 #define SP (State.regs[3])
131 #define EP (State.regs[30])
133 #define EIPC (State.sregs[0])
134 #define EIPSW (State.sregs[1])
135 #define FEPC (State.sregs[2])
136 #define FEPSW (State.sregs[3])
137 #define ECR (State.sregs[4])
138 #define PSW (State.sregs[5])
139 /* start-sanitize-v850e */
140 #define CTPC (State.sregs[16])
141 #define CTPSW (State.sregs[17])
142 /* end-sanitize-v850e */
143 #define DBPC (State.sregs[18])
144 #define DBPSW (State.sregs[19])
145 /* start-sanitize-v850e */
146 #define CTBP (State.sregs[20])
147 /* end-sanitize-v850e */
149 /* start-sanitize-v850eq */
150 #define PSW_US BIT32 (8)
151 /* end-sanitize-v850eq */
161 #define SEXT3(x) ((((x)&0x7)^(~0x3))+0x4)
163 /* sign-extend a 4-bit number */
164 #define SEXT4(x) ((((x)&0xf)^(~0x7))+0x8)
166 /* sign-extend a 5-bit number */
167 #define SEXT5(x) ((((x)&0x1f)^(~0xf))+0x10)
169 /* sign-extend a 9-bit number */
170 #define SEXT9(x) ((((x)&0x1ff)^(~0xff))+0x100)
172 /* sign-extend a 22-bit number */
173 #define SEXT22(x) ((((x)&0x3fffff)^(~0x1fffff))+0x200000)
175 /* sign extend a 40 bit number */
176 #define SEXT40(x) ((((x) & UNSIGNED64 (0xffffffffff)) \
177 ^ (~UNSIGNED64 (0x7fffffffff))) \
178 + UNSIGNED64 (0x8000000000))
180 /* sign extend a 44 bit number */
181 #define SEXT44(x) ((((x) & UNSIGNED64 (0xfffffffffff)) \
182 ^ (~ UNSIGNED64 (0x7ffffffffff))) \
183 + UNSIGNED64 (0x80000000000))
185 /* sign extend a 60 bit number */
186 #define SEXT60(x) ((((x) & UNSIGNED64 (0xfffffffffffffff)) \
187 ^ (~ UNSIGNED64 (0x7ffffffffffffff))) \
188 + UNSIGNED64 (0x800000000000000))
190 /* No sign extension */
193 #define INC_ADDR(x,i) x = ((State.MD && x == MOD_E) ? MOD_S : (x)+(i))
195 #define RLW(x) load_mem (x, 4)
206 /* Function declarations. */
209 sim_core_read_aligned_2 (STATE_CPU (sd, 0), \
210 PC, sim_core_execute_map, (EA))
212 #define IMEM_IMMED(EA,N) \
213 sim_core_read_aligned_2 (STATE_CPU (sd, 0), \
214 PC, sim_core_execute_map, (EA) + (N) * 2)
216 #define load_mem(ADDR,LEN) \
217 sim_core_read_unaligned_##LEN (STATE_CPU (simulator, 0), \
218 PC, sim_core_read_map, (ADDR))
220 #define store_mem(ADDR,LEN,DATA) \
221 sim_core_write_unaligned_##LEN (STATE_CPU (simulator, 0), \
222 PC, sim_core_write_map, (ADDR), (DATA))
225 /* Debug/tracing calls */
252 /* start-sanitize-v850e */
256 /* end-sanitize-v850e */
257 /* start-sanitize-v850eq */
262 /* end-sanitize-v850eq */
266 void trace_input PARAMS ((char *name, enum op_types type, int size));
267 void trace_output PARAMS ((enum op_types result));
269 #define trace_input(NAME, IN1, IN2)
270 #define trace_output(RESULT)
274 /* start-sanitize-v850eq */
275 extern void divun ( unsigned int N,
276 unsigned long int als,
277 unsigned long int sfi,
278 unsigned long int * quotient_ptr,
279 unsigned long int * remainder_ptr,
280 boolean * overflow_ptr
282 extern void divn ( unsigned int N,
283 unsigned long int als,
284 unsigned long int sfi,
285 signed long int * quotient_ptr,
286 signed long int * remainder_ptr,
287 boolean * overflow_ptr
289 /* end-sanitize-v850eq */
290 /* start-sanitize-v850e */
291 extern int type1_regs[];
292 extern int type2_regs[];
293 /* end-sanitize-v850e */
294 /* start-sanitize-v850eq */
295 extern int type3_regs[];
296 /* end-sanitize-v850eq */