diff options
author | Mike Frysinger <vapier@gentoo.org> | 2015-04-13 02:07:23 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2015-04-13 02:07:23 -0400 |
commit | bea3f671c5734eb96a02055fbaa0c938ad535b66 (patch) | |
tree | 4f2e6335b998ce6b5daa088bbc8d8fc91650f1b9 /sim | |
parent | 8ac57fbde478b8e8fb0ba169f620d713be319260 (diff) | |
download | gdb-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')
-rw-r--r-- | sim/m68hc11/ChangeLog | 11 | ||||
-rw-r--r-- | sim/m68hc11/Makefile.in | 1 | ||||
-rw-r--r-- | sim/m68hc11/interp.c | 39 | ||||
-rw-r--r-- | sim/m68hc11/sim-main.h | 8 |
4 files changed, 48 insertions, 11 deletions
diff --git a/sim/m68hc11/ChangeLog b/sim/m68hc11/ChangeLog index 36190a2..73adccb 100644 --- a/sim/m68hc11/ChangeLog +++ b/sim/m68hc11/ChangeLog @@ -1,3 +1,14 @@ +2015-04-13 Mike Frysinger <vapier@gentoo.org> + + * Makefile.in (SIM_OBJS): Add sim-cpu.o. + * interp.c (m68hc11_pc_get, m68hc11_pc_set): New functions. + (sim_open): Declare new local var i. Call sim_cpu_alloc_all. + Call CPU_PC_FETCH & CPU_PC_STORE for all cpus. + (sim_pc_get): Delete. + * sim-main.h (SIM_CPU): Define. + (STATE_CPU): Drop &. + (struct sim_state): Change cpu to an array of pointers. + 2015-04-06 Mike Frysinger <vapier@gentoo.org> * Makefile.in (SIM_OBJS): Delete sim-engine.o and sim-hrw.o. diff --git a/sim/m68hc11/Makefile.in b/sim/m68hc11/Makefile.in index 9b931a1..7db3897 100644 --- a/sim/m68hc11/Makefile.in +++ b/sim/m68hc11/Makefile.in @@ -22,6 +22,7 @@ M68HC11_OBJS = interp.o m68hc11int.o m68hc12int.o \ SIM_OBJS = $(M68HC11_OBJS) \ $(SIM_NEW_COMMON_OBJS) \ + sim-cpu.o \ sim-load.o \ sim-hload.o \ sim-stop.o \ 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 diff --git a/sim/m68hc11/sim-main.h b/sim/m68hc11/sim-main.h index 3973159..be3fc3d 100644 --- a/sim/m68hc11/sim-main.h +++ b/sim/m68hc11/sim-main.h @@ -28,6 +28,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ typedef address_word sim_cia; +typedef struct _sim_cpu SIM_CPU; + #include "sim-signal.h" #include "sim-base.h" @@ -576,13 +578,13 @@ extern void m68hc11cpu_set_port (struct hw *me, sim_cpu *cpu, #define CIA_SET(CPU,VAL) (cpu_set_pc ((CPU), (VAL))) #if (WITH_SMP) -#define STATE_CPU(sd,n) (&(sd)->cpu[n]) +#define STATE_CPU(sd,n) ((sd)->cpu[n]) #else -#define STATE_CPU(sd,n) (&(sd)->cpu[0]) +#define STATE_CPU(sd,n) ((sd)->cpu[0]) #endif struct sim_state { - sim_cpu cpu[MAX_NR_PROCESSORS]; + sim_cpu *cpu[MAX_NR_PROCESSORS]; device *devices; sim_state_base base; }; |