sim: v850: 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:
Mike Frysinger 2015-04-13 02:11:24 -04:00
parent 7bebb329bb
commit 14c9ad2edb
4 changed files with 42 additions and 9 deletions

View File

@ -1,3 +1,14 @@
2015-04-13 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Add sim-cpu.o.
* interp.c (v850_pc_get, v850_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.
(struct sim_state): Change cpu to an array of pointers.
(STATE_CPU): Drop &.
2015-04-06 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-engine.o and sim-hrw.o.

View File

@ -23,6 +23,7 @@ SIM_OBJS = \
$(SIM_NEW_COMMON_OBJS) \
simops.o interp.o \
itable.o semantics.o idecode.o icache.o engine.o irun.o support.o \
sim-cpu.o \
sim-hload.o \
sim-resume.o \
sim-reason.o \

View File

@ -184,6 +184,17 @@ get_insn_name (sim_cpu *cpu, int i)
uint32 OP[4];
static sim_cia
v850_pc_get (sim_cpu *cpu)
{
return PC;
}
static void
v850_pc_set (sim_cpu *cpu, sim_cia pc)
{
PC = pc;
}
SIM_DESC
sim_open (SIM_OPEN_KIND kind,
@ -191,11 +202,16 @@ sim_open (SIM_OPEN_KIND kind,
struct bfd * abfd,
char ** argv)
{
int i;
SIM_DESC sd = sim_state_alloc (kind, cb);
int mach;
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)
return 0;
/* for compatibility */
simulator = sd;
@ -283,6 +299,15 @@ sim_open (SIM_OPEN_KIND kind,
break;
}
/* CPU specific initialization. */
for (i = 0; i < MAX_NR_PROCESSORS; ++i)
{
SIM_CPU *cpu = STATE_CPU (sd, i);
CPU_PC_FETCH (cpu) = v850_pc_get;
CPU_PC_STORE (cpu) = v850_pc_set;
}
return sd;
}
@ -324,9 +349,3 @@ sim_store_register (SIM_DESC sd,
State.regs[rn] = T2H_4 (*(unsigned32 *) memory);
return length;
}
sim_cia
sim_pc_get (sim_cpu *cpu)
{
return PC;
}

View File

@ -19,6 +19,8 @@
typedef address_word sim_cia;
typedef struct _sim_cpu SIM_CPU;
#include "sim-base.h"
#include "simops.h"
@ -63,11 +65,11 @@ struct _sim_cpu
#define CIA_SET(CPU,VAL) ((CPU)->reg.pc = (VAL))
struct sim_state {
sim_cpu cpu[MAX_NR_PROCESSORS];
sim_cpu *cpu[MAX_NR_PROCESSORS];
#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
#if 0
SIM_ADDR rom_size;