+2021-05-17 Mike Frysinger <vapier@gentoo.org>
+
+ * compile.c (h8_get_state): Change sd to H8300_SIM_STATE.
+ (h8_set_state): Likewise.
+ (h8_get_stats): Likewise.
+ (h8_increment_stats): Likewise.
+ (init_pointers): Likewise.
+ (step_once): Likewise.
+ (sim_info): Likewise.
+ (sim_open): Likewise.
+ (sim_load): Likewise.
+ * sim-main.h (SIM_HAVE_COMMON_SIM_STATE): Define.
+ (struct sim_state): Delete.
+ (struct h8300_sim_state): New struct.
+ (H8300_SIM_STATE): Define.
+
2021-05-16 Mike Frysinger <vapier@gentoo.org>
* compile.c: Replace config.h include with defs.h.
static enum h8300_sim_state
h8_get_state (SIM_DESC sd)
{
- return sd -> state;
+ return H8300_SIM_STATE (sd)->state;
}
static void
h8_set_state (SIM_DESC sd, enum h8300_sim_state val)
{
- sd -> state = val;
+ H8300_SIM_STATE (sd)->state = val;
}
#endif
static unsigned int
static int
h8_get_stats (SIM_DESC sd, int idx)
{
- return sd -> stats[idx];
+ return H8300_SIM_STATE (sd)->stats[idx];
}
static void
h8_increment_stats (SIM_DESC sd, int idx)
{
- sd -> stats[idx] ++;
+ H8300_SIM_STATE (sd)->stats[idx] ++;
}
#endif /* ADEBUG */
static void
init_pointers (SIM_DESC sd)
{
+ struct h8300_sim_state *state = H8300_SIM_STATE (sd);
+
if (init_pointers_needed)
{
int i;
h8_set_memory_buf (sd, (unsigned char *)
calloc (sizeof (char), memory_size));
- sd->memory_size = memory_size;
+ state->memory_size = memory_size;
h8_set_mask (sd, memory_size - 1);
int trace = 0;
int intMask = 0;
int oldmask;
+ const struct h8300_sim_state *state = H8300_SIM_STATE (sd);
host_callback *sim_callback = STATE_CALLBACK (sd);
init_pointers (sd);
void
sim_info (SIM_DESC sd, int verbose)
{
+ const struct h8300_sim_state *state = H8300_SIM_STATE (sd);
double timetaken = (double) h8_get_ticks (sd) / (double) now_persec ();
double virttime = h8_get_cycles (sd) / 10.0e6;
SIM_DESC sd;
sim_cpu *cpu;
- sd = sim_state_alloc (kind, callback);
+ sd = sim_state_alloc_extra (kind, callback, sizeof (struct h8300_sim_state));
/* The cpu data is kept in a separately allocated chunk of memory. */
if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
SIM_RC
sim_load (SIM_DESC sd, const char *prog, bfd *abfd, int from_tty)
{
+ struct h8300_sim_state *state = H8300_SIM_STATE (sd);
bfd *prog_bfd;
/* FIXME: The code below that sets a specific variant of the H8/300
h8_set_memory_buf (sd, (unsigned char *)
calloc (sizeof (char), memory_size));
- sd->memory_size = memory_size;
+ state->memory_size = memory_size;
/* `msize' must be a power of two. */
if ((memory_size & (memory_size - 1)) != 0)
#ifndef SIM_MAIN_H
#define SIM_MAIN_H
+#define SIM_HAVE_COMMON_SIM_STATE
+
#define DEBUG
/* These define the size of main memory for the simulator.
sim_cpu_base base;
};
-/* The sim_state struct. */
-struct sim_state {
- sim_cpu *cpu[MAX_NR_PROCESSORS];
+struct h8300_sim_state {
unsigned long memory_size;
#ifdef ADEBUG
int stats[O_LAST];
#endif
- sim_state_base base;
};
+#define H8300_SIM_STATE(sd) ((struct h8300_sim_state *) STATE_ARCH_DATA (sd))
/* The current state of the processor; registers, memory, etc. */