4 #include "remote-sim.h"
17 #define MEM_SIZE 18 /* V850 memory size is 18 bits XXX */
19 host_callback
*v850_callback
;
25 static struct hash_entry
*lookup_hash
PARAMS ((uint32 ins
));
26 static long hash
PARAMS ((long));
27 static void do_format_1_2
PARAMS ((uint32
));
28 static void do_format_3
PARAMS ((uint32
));
29 static void do_format_4
PARAMS ((uint32
));
30 static void do_format_5
PARAMS ((uint32
));
31 static void do_format_6
PARAMS ((uint32
));
32 static void do_format_7
PARAMS ((uint32
));
33 static void do_format_8
PARAMS ((uint32
));
34 static void do_format_9_10
PARAMS ((uint32
));
35 static void init_system
PARAMS ((void));
40 struct hash_entry
*next
;
46 struct hash_entry hash_table
[MAX_HASH
+1];
53 if ((insn
& 0x0600) == 0
54 || (insn
& 0x0700) == 0x0200
55 || (insn
& 0x0700) == 0x0600
56 || (insn
& 0x0780) == 0x0700)
57 return (insn
& 0x07e0) >> 5;
58 if ((insn
& 0x0700) == 0x0300
59 || (insn
& 0x0700) == 0x0400
60 || (insn
& 0x0700) == 0x0500)
61 return (insn
& 0x0780) >> 7;
62 if ((insn
& 0x07c0) == 0x0780)
63 return (insn
& 0x07c0) >> 6;
64 return (insn
& 0x07e0) >> 5;
67 static struct hash_entry
*
73 h
= &hash_table
[hash(ins
)];
75 while ((ins
& h
->mask
) != h
->opcode
)
79 (*v850_callback
->printf_filtered
) (v850_callback
, "ERROR looking up hash for %x\n", ins
);
99 return (a
[1] << 8) + (a
[0]);
107 return (a
[3]<<24) + (a
[2]<<16) + (a
[1]<<8) + (a
[0]);
111 put_byte (addr
, data
)
120 put_half (addr
, data
)
126 a
[1] = (data
>> 8) & 0xff;
130 put_word (addr
, data
)
136 a
[1] = (data
>> 8) & 0xff;
137 a
[2] = (data
>> 16) & 0xff;
138 a
[3] = (data
>> 24) & 0xff;
145 struct hash_entry
*h
;
147 h
= lookup_hash (insn
);
149 OP
[1] = (insn
>> 11) & 0x1f;
157 struct hash_entry
*h
;
159 h
= lookup_hash (insn
);
160 OP
[0] = (((insn
& 0x70) >> 4) | ((insn
& 0xf800) >> 8)) << 1;
168 struct hash_entry
*h
;
170 h
= lookup_hash (insn
);
171 OP
[0] = (insn
>> 11) & 0x1f;
172 OP
[1] = (insn
& 0x7f);
180 struct hash_entry
*h
;
182 h
= lookup_hash (insn
);
183 OP
[0] = (((insn
& 0x3f) << 15) | ((insn
>> 17) & 0x7fff)) << 1;
184 OP
[1] = (insn
>> 11) & 0x1f;
192 struct hash_entry
*h
;
194 h
= lookup_hash (insn
);
195 OP
[0] = (insn
>> 16) & 0xffff;
197 OP
[2] = (insn
>> 11) & 0x1f;
205 struct hash_entry
*h
;
207 h
= lookup_hash (insn
);
209 OP
[1] = (insn
>> 11) & 0x1f;
210 OP
[2] = (insn
>> 16) & 0xffff;
218 struct hash_entry
*h
;
220 h
= lookup_hash (insn
);
222 OP
[1] = (insn
>> 11) & 0x7;
223 OP
[2] = (insn
>> 16) & 0xffff;
228 do_format_9_10 (insn
)
231 struct hash_entry
*h
;
233 h
= lookup_hash (insn
);
235 OP
[1] = (insn
>> 11) & 0x1f;
249 State
.mem
= (uint8
*)calloc(1,1<<MEM_SIZE
);
252 (*v850_callback
->printf_filtered
) (v850_callback
, "Memory allocation failed.\n");
265 sim_write (addr
, buffer
, size
)
267 unsigned char *buffer
;
273 for (i
= 0; i
< size
; i
++)
275 State
.mem
[i
+addr
] = buffer
[i
];
285 struct hash_entry
*h
;
289 if (strcmp (args
, "-t") == 0)
293 (*v850_callback
->printf_filtered
) (v850_callback
, "ERROR: unsupported option(s): %s\n",args
);
296 /* put all the opcodes in the hash table */
297 for (s
= Simops
; s
->func
; s
++)
299 h
= &hash_table
[hash(s
->opcode
)];
301 /* go to the last entry in the chain */
307 h
->next
= calloc(1,sizeof(struct hash_entry
));
312 h
->opcode
= s
->opcode
;
328 (*v850_callback
->printf_filtered
) (v850_callback
, "sim_set_profile %d\n", n
);
332 sim_set_profile_size (n
)
335 (*v850_callback
->printf_filtered
) (v850_callback
, "sim_set_profile_size %d\n", n
);
339 sim_resume (step
, siggnal
)
348 State
.exception
= SIGTRAP
;
356 opcode
= (inst
& 0x07e0) >> 5;
357 if ((opcode
& 0x30) == 0
358 || (opcode
& 0x38) == 0x10)
360 do_format_1_2 (inst
& 0xffff);
363 else if ((opcode
& 0x3C) == 0x18
364 || (opcode
& 0x3C) == 0x1C
365 || (opcode
& 0x3C) == 0x20
366 || (opcode
& 0x3C) == 0x24
367 || (opcode
& 0x3C) == 0x28)
369 do_format_4 (inst
& 0xffff);
372 else if ((opcode
& 0x3C) == 0x2C)
374 do_format_3 (inst
& 0xffff);
375 /* No PC update, it's done in the instruction. */
377 else if ((opcode
& 0x38) == 0x30)
382 else if ((opcode
& 0x3C) == 0x38)
387 else if ((opcode
& 0x3E) == 0x3C)
390 /* No PC update, it's done in the instruction. */
392 else if ((opcode
& 0x3F) == 0x3E)
399 do_format_9_10 (inst
);
403 while (!State
.exception
);
422 (*v850_callback
->printf_filtered
) (v850_callback
, "sim_info\n");
426 sim_create_inferior (start_address
, argv
, env
)
427 SIM_ADDR start_address
;
448 /* All the code for exiting, signals, etc needs to be revamped.
450 This is enough to get c-torture limping though. */
452 sim_stop_reason (reason
, sigrc
)
453 enum sim_stop
*reason
;
457 *reason
= sim_stopped
;
458 if (State
.exception
== SIGQUIT
)
461 *sigrc
= State
.exception
;
465 sim_fetch_register (rn
, memory
)
467 unsigned char *memory
;
469 put_word (memory
, State
.regs
[rn
]);
473 sim_store_register (rn
, memory
)
475 unsigned char *memory
;
477 State
.regs
[rn
] = get_word (memory
);
481 sim_read (addr
, buffer
, size
)
483 unsigned char *buffer
;
487 for (i
= 0; i
< size
; i
++)
489 buffer
[i
] = State
.mem
[addr
+ i
];
498 (*v850_callback
->printf_filtered
) (v850_callback
, "sim_do_command: %s\n", cmd
);
502 sim_load (prog
, from_tty
)
506 /* Return nonzero so GDB will handle it. */
This page took 0.041334 seconds and 4 git commands to generate.