sim: m68hc11: convert to sim-cpu
Make cpu allocation fully dynamic so we can leverage the common sim-cpu and its APIs.
This commit is contained in:
parent
8ac57fbde4
commit
bea3f671c5
@ -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.
|
||||
|
@ -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 \
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user