]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: avr/mcore/moxie: fill out sim-cpu pc fetch/store helpers
authorMike Frysinger <vapier@gentoo.org>
Thu, 16 Apr 2015 06:07:33 +0000 (02:07 -0400)
committerMike Frysinger <vapier@gentoo.org>
Thu, 16 Apr 2015 06:13:50 +0000 (02:13 -0400)
This makes the common sim-cpu logic work.

sim/avr/ChangeLog
sim/avr/interp.c
sim/mcore/ChangeLog
sim/mcore/interp.c
sim/moxie/ChangeLog
sim/moxie/interp.c
sim/moxie/sim-main.h

index 0dd4faf6bcef39b50c990010885f9e101cdbff19..2d8ddf21b26d1c09c8e9fd24ae172bb034e1796a 100644 (file)
@@ -1,3 +1,9 @@
+2015-04-16  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (avr_pc_get, avr_pc_set): New functions.
+       (sim_open): Declare new local var i.  Call CPU_PC_FETCH &
+       CPU_PC_STORE for all cpus.
+
 2015-04-15  Mike Frysinger  <vapier@gentoo.org>
 
        * Makefile.in (SIM_OBJS): Delete sim-cpu.o.
index d16993598bc60d85f8247a684c0f18c06e757a83..a6588d3de4fc2b93979572ed583cf80ec164ee7a 100644 (file)
@@ -1663,6 +1663,18 @@ sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
   return 0;
 }
 
+static sim_cia
+avr_pc_get (sim_cpu *cpu)
+{
+  return pc;
+}
+
+static void
+avr_pc_set (sim_cpu *cpu, sim_cia _pc)
+{
+  pc = _pc;
+}
+
 static void
 free_state (SIM_DESC sd)
 {
@@ -1675,6 +1687,7 @@ free_state (SIM_DESC sd)
 SIM_DESC
 sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
 {
+  int i;
   SIM_DESC sd = sim_state_alloc (kind, cb);
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
@@ -1729,6 +1742,15 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
       return 0;
     }
 
+  /* CPU specific initialization.  */
+  for (i = 0; i < MAX_NR_PROCESSORS; ++i)
+    {
+      SIM_CPU *cpu = STATE_CPU (sd, i);
+
+      CPU_PC_FETCH (cpu) = avr_pc_get;
+      CPU_PC_STORE (cpu) = avr_pc_set;
+    }
+
   /* Clear all the memory.  */
   memset (sram, 0, sizeof (sram));
   memset (flash, 0, sizeof (flash));
index 152864e8db5f8ce07fc1b2ad381a6485d2b2ef0e..a00954ceb94c76b7f57f4b282c7b23887e7f6d68 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-16  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (mcore_pc_get, mcore_pc_set): New functions.
+       (sim_open): Call CPU_PC_FETCH & CPU_PC_STORE for all cpus.
+
 2015-04-15  Mike Frysinger  <vapier@gentoo.org>
 
        * Makefile.in (SIM_OBJS): Delete sim-cpu.o.
index b99988c38fbfc9341dd70e59617981b89297f7ec..fc1131bdda85c6e3ef960baebbf2eb26c3cb2c5b 100644 (file)
@@ -1779,6 +1779,18 @@ sim_info (SIM_DESC sd, int verbose)
 #endif
 }
 
+static sim_cia
+mcore_pc_get (sim_cpu *cpu)
+{
+  return cpu->pc;
+}
+
+static void
+mcore_pc_set (sim_cpu *cpu, sim_cia pc)
+{
+  cpu->pc = pc;
+}
+
 static void
 free_state (SIM_DESC sd)
 {
@@ -1856,6 +1868,10 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
   for (i = 0; i < MAX_NR_PROCESSORS; ++i)
     {
       SIM_CPU *cpu = STATE_CPU (sd, i);
+
+      CPU_PC_FETCH (cpu) = mcore_pc_get;
+      CPU_PC_STORE (cpu) = mcore_pc_set;
+
       set_initial_gprs (cpu);  /* Reset the GPR registers.  */
     }
 
index b2cf6f6a59b199c92a181485ffd5f4273d1576da..6f7e55b7e36b7e33ce5ecf6dfb5fa073efcaa446 100644 (file)
@@ -1,3 +1,10 @@
+2015-04-16  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (moxie_pc_get, moxie_pc_set): New functions.
+       (sim_open): Declare new local var i.  Call CPU_PC_FETCH &
+       CPU_PC_STORE for all cpus.
+       * sim-main.h (SIM_CPU): New typedef.
+
 2015-04-15  Mike Frysinger  <vapier@gentoo.org>
 
        * Makefile.in (SIM_OBJS): Delete sim-cpu.o.
index 428a9d5f5090b6d6ea87ae699d30ebf1d9596794..fce6d81787934b89686a223e172d0f3fd7c3cc48 100644 (file)
@@ -1145,6 +1145,18 @@ sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
     return 0;
 }
 
+static sim_cia
+moxie_pc_get (sim_cpu *cpu)
+{
+  return cpu->registers[PCIDX];
+}
+
+static void
+moxie_pc_set (sim_cpu *cpu, sim_cia pc)
+{
+  cpu->registers[PCIDX] = pc;
+}
+
 static void
 free_state (SIM_DESC sd)
 {
@@ -1157,6 +1169,7 @@ free_state (SIM_DESC sd)
 SIM_DESC
 sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
 {
+  int i;
   SIM_DESC sd = sim_state_alloc (kind, cb);
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
@@ -1215,7 +1228,15 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
     }
 
   /* CPU specific initialization.  */
-  set_initial_gprs ();
+  for (i = 0; i < MAX_NR_PROCESSORS; ++i)
+    {
+      SIM_CPU *cpu = STATE_CPU (sd, i);
+
+      CPU_PC_FETCH (cpu) = moxie_pc_get;
+      CPU_PC_STORE (cpu) = moxie_pc_set;
+
+      set_initial_gprs ();     /* Reset the GPR registers.  */
+    }
 
   return sd;
 }
index 5a9f7c7119219bc1f91e8dcaf5a2ed71f5a2c96f..6a2174bc124205a295609228772bb20a1b45dbef 100644 (file)
@@ -24,6 +24,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-base.h"
 #include "bfd.h"