5 #include "mn10300_sim.h"
15 host_callback
*mn10300_callback
;
20 static struct hash_entry
*lookup_hash
PARAMS ((uint32 ins
));
21 static long hash
PARAMS ((long));
22 static void init_system
PARAMS ((void));
28 struct hash_entry
*next
;
34 struct hash_entry hash_table
[MAX_HASH
+1];
44 static struct hash_entry
*
50 h
= &hash_table
[hash(ins
)];
52 while ((ins
& h
->mask
) != h
->opcode
)
56 (*mn10300_callback
->printf_filtered
) (mn10300_callback
, "ERROR looking up hash for 0x%x, PC=0x%x\n", ins
, PC
);
64 /* FIXME These would more efficient to use than load_mem/store_mem,
65 but need to be changed to use the memory map. */
79 return (a
[1] << 8) + (a
[0]);
87 return (a
[3]<<24) + (a
[2]<<16) + (a
[1]<<8) + (a
[0]);
100 put_half (addr
, data
)
106 a
[1] = (data
>> 8) & 0xff;
110 put_word (addr
, data
)
116 a
[1] = (data
>> 8) & 0xff;
117 a
[2] = (data
>> 16) & 0xff;
118 a
[3] = (data
>> 24) & 0xff;
127 uint8
*p
= addr
+ State
.mem
;
134 return p
[1] << 8 | p
[0];
136 return p
[3] << 24 | p
[2] << 16 | p
[1] << 8 | p
[0];
143 store_mem (addr
, len
, data
)
148 uint8
*p
= addr
+ State
.mem
;
178 State
.mem
= (uint8
*) calloc (1, 1 << power
);
181 (*mn10300_callback
->printf_filtered
) (mn10300_callback
, "Allocation of main memory failed.\n");
194 sim_write (addr
, buffer
, size
)
196 unsigned char *buffer
;
203 for (i
= 0; i
< size
; i
++)
204 store_mem (addr
+ i
, 1, buffer
[i
]);
214 struct hash_entry
*h
;
218 if (strcmp (args
, "-t") == 0)
219 mn10300_debug
= DEBUG
;
222 (*mn10300_callback
->printf_filtered
) (mn10300_callback
, "ERROR: unsupported option(s): %s\n",args
);
225 /* put all the opcodes in the hash table */
226 for (s
= Simops
; s
->func
; s
++)
228 h
= &hash_table
[hash(s
->opcode
)];
230 /* go to the last entry in the chain */
236 h
->next
= calloc(1,sizeof(struct hash_entry
));
241 h
->opcode
= s
->opcode
;
257 (*mn10300_callback
->printf_filtered
) (mn10300_callback
, "sim_set_profile %d\n", n
);
261 sim_set_profile_size (n
)
264 (*mn10300_callback
->printf_filtered
) (mn10300_callback
, "sim_set_profile_size %d\n", n
);
268 sim_resume (step
, siggnal
)
273 struct interrupt_generator
*intgen
;
276 State
.exception
= SIGTRAP
;
282 /* Fetch the current instruction. */
285 opcode
= (inst
& 0x07e0) >> 5;
287 /* Decode the opcode field. */
288 if ((opcode
& 0x30) == 0
289 || (opcode
& 0x38) == 0x10)
293 while (!State
.exception
);
300 mn10300_debug
= DEBUG
;
310 (*mn10300_callback
->printf_filtered
) (mn10300_callback
, "sim_info\n");
314 sim_create_inferior (start_address
, argv
, env
)
315 SIM_ADDR start_address
;
329 sim_set_callbacks (p
)
332 mn10300_callback
= p
;
335 /* All the code for exiting, signals, etc needs to be revamped.
337 This is enough to get c-torture limping though. */
340 sim_stop_reason (reason
, sigrc
)
341 enum sim_stop
*reason
;
344 *reason
= sim_stopped
;
345 if (State
.exception
== SIGQUIT
)
348 *sigrc
= State
.exception
;
352 sim_fetch_register (rn
, memory
)
354 unsigned char *memory
;
356 put_word (memory
, State
.regs
[rn
]);
360 sim_store_register (rn
, memory
)
362 unsigned char *memory
;
364 State
.regs
[rn
] = get_word (memory
);
368 sim_read (addr
, buffer
, size
)
370 unsigned char *buffer
;
374 for (i
= 0; i
< size
; i
++)
375 buffer
[i
] = load_mem (addr
+ i
, 1);
384 (*mn10300_callback
->printf_filtered
) (mn10300_callback
, "\"%s\" is not a valid mn10300 simulator command.\n", cmd
);
388 sim_load (prog
, from_tty
)
392 /* Return nonzero so GDB will handle it. */
This page took 0.045246 seconds and 4 git commands to generate.