From: Mike Frysinger Date: Mon, 13 Apr 2015 06:11:24 +0000 (-0400) Subject: sim: v850: convert to sim-cpu X-Git-Tag: gdb-7.10-release~826 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=14c9ad2edb6e0bb0b560fa45699b83d85aa28b94;p=external%2Fbinutils.git sim: v850: convert to sim-cpu Make cpu allocation fully dynamic so we can leverage the common sim-cpu and its APIs. --- diff --git a/sim/v850/ChangeLog b/sim/v850/ChangeLog index 21518e0..9a5e907 100644 --- a/sim/v850/ChangeLog +++ b/sim/v850/ChangeLog @@ -1,3 +1,14 @@ +2015-04-13 Mike Frysinger + + * 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 * Makefile.in (SIM_OBJS): Delete sim-engine.o and sim-hrw.o. diff --git a/sim/v850/Makefile.in b/sim/v850/Makefile.in index 726ed5e..e78fda9 100644 --- a/sim/v850/Makefile.in +++ b/sim/v850/Makefile.in @@ -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 \ diff --git a/sim/v850/interp.c b/sim/v850/interp.c index 04f3f2f..36da132 100644 --- a/sim/v850/interp.c +++ b/sim/v850/interp.c @@ -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; -} diff --git a/sim/v850/sim-main.h b/sim/v850/sim-main.h index 505b19e..102c917 100644 --- a/sim/v850/sim-main.h +++ b/sim/v850/sim-main.h @@ -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;