aboutsummaryrefslogtreecommitdiff
path: root/sim/m68hc11/interp.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-04-13 02:07:23 -0400
committerMike Frysinger <vapier@gentoo.org>2015-04-13 02:07:23 -0400
commitbea3f671c5734eb96a02055fbaa0c938ad535b66 (patch)
tree4f2e6335b998ce6b5daa088bbc8d8fc91650f1b9 /sim/m68hc11/interp.c
parent8ac57fbde478b8e8fb0ba169f620d713be319260 (diff)
downloadgdb-bea3f671c5734eb96a02055fbaa0c938ad535b66.zip
gdb-bea3f671c5734eb96a02055fbaa0c938ad535b66.tar.gz
gdb-bea3f671c5734eb96a02055fbaa0c938ad535b66.tar.bz2
sim: m68hc11: convert to sim-cpu
Make cpu allocation fully dynamic so we can leverage the common sim-cpu and its APIs.
Diffstat (limited to 'sim/m68hc11/interp.c')
-rw-r--r--sim/m68hc11/interp.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/sim/m68hc11/interp.c b/sim/m68hc11/interp.c
index 3100659..659001a 100644
--- a/sim/m68hc11/interp.c
+++ b/sim/m68hc11/interp.c
@@ -417,18 +417,39 @@ sim_prepare_for_program (SIM_DESC sd, bfd* abfd)
return SIM_RC_OK;
}
+static sim_cia
+m68hc11_pc_get (sim_cpu *cpu)
+{
+ return cpu_get_pc (cpu);
+}
+
+static void
+m68hc11_pc_set (sim_cpu *cpu, sim_cia pc)
+{
+ cpu_set_pc (cpu, pc);
+}
+
SIM_DESC
sim_open (SIM_OPEN_KIND kind, host_callback *callback,
bfd *abfd, char **argv)
{
+ int i;
SIM_DESC sd;
sim_cpu *cpu;
sd = sim_state_alloc (kind, callback);
- cpu = STATE_CPU (sd, 0);
SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
+ /* The cpu data is kept in a separately allocated chunk of memory. */
+ if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
+ {
+ free_state (sd);
+ return 0;
+ }
+
+ cpu = STATE_CPU (sd, 0);
+
/* for compatibility */
current_alignment = NONSTRICT_ALIGNMENT;
current_target_byte_order = BIG_ENDIAN;
@@ -482,7 +503,15 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
return 0;
}
- /* Fudge our descriptor. */
+ /* CPU specific initialization. */
+ for (i = 0; i < MAX_NR_PROCESSORS; ++i)
+ {
+ SIM_CPU *cpu = STATE_CPU (sd, i);
+
+ CPU_PC_FETCH (cpu) = m68hc11_pc_get;
+ CPU_PC_STORE (cpu) = m68hc11_pc_set;
+ }
+
return sd;
}
@@ -679,12 +708,6 @@ sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
return 2;
}
-sim_cia
-sim_pc_get (sim_cpu *cpu)
-{
- return CIA_GET (cpu);
-}
-
/* Halt the simulator after just one instruction */
static void