4 #include "remote-sim.h"
9 #define MEM_SIZE 18 /* V850 memory size is 18 bits XXX */
11 host_callback
*v850_callback
;
16 static struct hash_entry
*lookup_hash
PARAMS ((uint32 ins
));
21 struct hash_entry
*next
;
27 struct hash_entry hash_table
[MAX_HASH
+1];
33 if ((insn
& 0x0600) == 0
34 || (insn
& 0x0700) == 0x0200)
35 return (insn
& 0x07e0) >> 5;
36 if ((insn
& 0x0700) == 0x0300
37 || (insn
& 0x0700) == 0x0400
38 || (insn
& 0x0700) == 0x0500)
39 return (insn
& 0x0780) >> 7;
40 if ((insn
& 0x0700) == 0x0600)
41 return (insn
& 0x07e0) >> 5;
42 if ((insn
& 0x0780) == 0x0700)
43 return (insn
& 0x07e0) >> 5;
44 if ((insn
& 0x07c0) == 0x0780)
45 return (insn
& 0x07c0) >> 6;
46 if ((insn
& 0x07E0) == 0x07C0)
47 return (insn
& 0x07e0) >> 5;
48 return (insn
& 0x07e0) >> 5;
51 static struct hash_entry
*
57 h
= &hash_table
[hash(ins
)];
59 while ( (ins
& h
->mask
) != h
->opcode
)
63 printf ("ERROR looking up hash for %x\n",ins
);
83 return (a
[1] << 8) + (a
[0]);
91 return (a
[3]<<24) + (a
[2]<<16) + (a
[1]<<8) + (a
[0]);
104 put_half (addr
, data
)
110 a
[1] = (data
>> 8) & 0xff;
114 put_word (addr
, data
)
120 a
[1] = (data
>> 8) & 0xff;
121 a
[2] = (data
>> 16) & 0xff;
122 a
[3] = (data
>> 24) & 0xff;
129 struct hash_entry
*h
;
131 h
= lookup_hash (insn
);
133 OP
[1] = (insn
>> 11) & 0x1f;
141 struct hash_entry
*h
;
143 h
= lookup_hash (insn
);
144 OP
[0] = (((insn
& 0x70) >> 4) | ((insn
& 0xf800) >> 8)) << 1;
152 struct hash_entry
*h
;
154 h
= lookup_hash (insn
);
155 OP
[0] = (insn
>> 11) & 0x1f;
156 OP
[1] = (insn
& 0x7f);
164 struct hash_entry
*h
;
166 h
= lookup_hash (insn
);
167 OP
[0] = (((insn
& 0x3f) << 15) | ((insn
>> 17) & 0x7fff)) << 1;
168 OP
[1] = (insn
>> 11) & 0x1f;
176 struct hash_entry
*h
;
178 h
= lookup_hash (insn
);
179 OP
[0] = (insn
>> 16) & 0xffff;
181 OP
[2] = (insn
>> 11) & 0x1f;
189 struct hash_entry
*h
;
191 h
= lookup_hash (insn
);
193 OP
[1] = (insn
>> 11) & 0x1f;
194 OP
[2] = (insn
>> 16) & 0xffff;
202 struct hash_entry
*h
;
204 h
= lookup_hash (insn
);
206 OP
[1] = (insn
>> 11) & 0x7;
207 OP
[2] = (insn
>> 16) & 0xffff;
212 do_formats_9_10 (insn
)
215 struct hash_entry
*h
;
217 h
= lookup_hash (insn
);
219 OP
[1] = (insn
>> 11) & 0x1f;
233 State
.mem
= (uint8
*)calloc(1,1<<MEM_SIZE
);
236 fprintf (stderr
,"Memory allocation failed.\n");
249 sim_write (addr
, buffer
, size
)
251 unsigned char *buffer
;
257 for (i
= 0; i
< size
; i
++)
259 State
.mem
[i
+addr
] = buffer
[i
];
269 struct hash_entry
*h
, *prev
;
271 printf ("sim_open %s\n",args
);
273 /* put all the opcodes in the hash table */
274 for (s
= Simops
; s
->func
; s
++)
276 h
= &hash_table
[hash(s
->opcode
)];
278 /* go to the last entry in the chain */
284 h
->next
= calloc(1,sizeof(struct hash_entry
));
289 h
->opcode
= s
->opcode
;
305 printf ("sim_set_profile %d\n",n
);
309 sim_set_profile_size (n
)
312 printf ("sim_set_profile_size %d\n",n
);
316 sim_resume (step
, siggnal
)
325 State
.exception
= SIGTRAP
;
333 opcode
= (inst
& 0x07e0) >> 5;
334 if ((opcode
& 0x30) == 0
335 || (opcode
& 0x38) == 0x10)
337 do_format_1_2 (inst
& 0xffff);
340 else if ((opcode
& 0x3C) == 0x18
341 || (opcode
& 0x3C) == 0x1C
342 || (opcode
& 0x3C) == 0x20
343 || (opcode
& 0x3C) == 0x24
344 || (opcode
& 0x3C) == 0x28)
346 do_format_4 (inst
& 0xffff);
349 else if ((opcode
& 0x3C) == 0x2C)
351 do_format_3 (inst
& 0xffff);
352 /* No PC update, it's done in the instruction. */
354 else if ((opcode
& 0x38) == 0x30)
359 else if ((opcode
& 0x3C) == 0x38)
364 else if ((opcode
& 0x3E) == 0x3C)
367 /* No PC update, it's done in the instruction. */
369 else if ((opcode
& 0x3F) == 0x3E)
376 do_formats_9_10 (inst
);
380 while (!State
.exception
);
386 printf ("sim_trace\n");
394 printf ("sim_info\n");
398 sim_create_inferior (start_address
, argv
, env
)
399 SIM_ADDR start_address
;
420 /* All the code for exiting, signals, etc needs to be revamped. */
422 This is enough to get c
-torture limping though
. */
424 sim_stop_reason (reason
, sigrc
)
425 enum sim_stop
*reason
;
429 *reason
= sim_stopped
;
430 if (State
.exception
== SIGQUIT
)
433 *sigrc
= State
.exception
;
437 sim_fetch_register (rn
, memory
)
439 unsigned char *memory
;
441 *(uint32
*)memory
= State
.regs
[rn
];
445 sim_store_register (rn
, memory
)
447 unsigned char *memory
;
449 State
.regs
[rn
]= *(uint32
*)memory
;
452 sim_read (addr
, buffer
, size
)
454 unsigned char *buffer
;
458 for (i
= 0; i
< size
; i
++)
460 buffer
[i
] = State
.mem
[addr
+ i
];
469 printf("sim_do_command: %s\n",cmd
);
473 sim_load (prog
, from_tty
)
477 /* Return nonzero so GDB will handle it. */