sim: v850: convert to sim-cpu
authorMike Frysinger <vapier@gentoo.org>
Mon, 13 Apr 2015 06:11:24 +0000 (02:11 -0400)
committerMike Frysinger <vapier@gentoo.org>
Mon, 13 Apr 2015 06:11:50 +0000 (02:11 -0400)
Make cpu allocation fully dynamic so we can leverage the common
sim-cpu and its APIs.

sim/v850/ChangeLog
sim/v850/Makefile.in
sim/v850/interp.c
sim/v850/sim-main.h

index 21518e0c53e246044da41358674e0607426cc027..9a5e907f865ecc7e94b1e46a6bab9e60fa9f44a4 100644 (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.
index 726ed5e06f22a606393ee6ae9244072a027e95ed..e78fda955dd08b3f14549c7b33849f56402db1a1 100644 (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 \
index 04f3f2fd0ca84bd2f666077f64dd0a391a9a7baa..36da1328223635a2e546ac8841bc89c384f9d8f5 100644 (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;
-}
index 505b19ea5fd6d6f1a5a50d7f5be2ded80f88407e..102c91785b66e55463890bc453019030be041332 100644 (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;
This page took 0.028191 seconds and 4 git commands to generate.