sim: arm/cr16/d10v/h8300/microblaze/sh: fill out sim-cpu pc fetch/store helpers
authorMike Frysinger <vapier@gentoo.org>
Fri, 17 Apr 2015 06:16:10 +0000 (02:16 -0400)
committerMike Frysinger <vapier@gentoo.org>
Fri, 17 Apr 2015 06:22:16 +0000 (02:22 -0400)
This makes the common sim-cpu logic work.

13 files changed:
sim/arm/ChangeLog
sim/arm/wrapper.c
sim/cr16/ChangeLog
sim/cr16/interp.c
sim/d10v/ChangeLog
sim/d10v/interp.c
sim/h8300/ChangeLog
sim/h8300/compile.c
sim/h8300/sim-main.h
sim/microblaze/ChangeLog
sim/microblaze/interp.c
sim/sh/ChangeLog
sim/sh/interp.c

index c98903d42b742d973ae1f27f666a2b87499fc5ea..01105f868799e8df11a6db506750d7ff974f1d79 100644 (file)
@@ -1,3 +1,9 @@
+2015-04-17  Mike Frysinger  <vapier@gentoo.org>
+
+       * wrapper.c (arm_pc_get, arm_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 dd3cfe2e2856e4bb47586ec9889102589fcfb26c..d69daa3b2720a34de3a8d7a9a5ce8927befa181b 100644 (file)
@@ -800,6 +800,18 @@ sim_target_parse_arg_array (char ** argv)
   sim_target_parse_command_line (i, argv);
 }
 
+static sim_cia
+arm_pc_get (sim_cpu *cpu)
+{
+  return PC;
+}
+
+static void
+arm_pc_set (sim_cpu *cpu, sim_cia pc)
+{
+  ARMul_SetPC (state, pc);
+}
+
 static void
 free_state (SIM_DESC sd)
 {
@@ -815,6 +827,7 @@ sim_open (SIM_OPEN_KIND kind,
          struct bfd *abfd,
          char **argv)
 {
+  int i;
   SIM_DESC sd = sim_state_alloc (kind, cb);
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
@@ -866,6 +879,15 @@ sim_open (SIM_OPEN_KIND kind,
       return 0;
     }
 
+  /* CPU specific initialization.  */
+  for (i = 0; i < MAX_NR_PROCESSORS; ++i)
+    {
+      SIM_CPU *cpu = STATE_CPU (sd, i);
+
+      CPU_PC_FETCH (cpu) = arm_pc_get;
+      CPU_PC_STORE (cpu) = arm_pc_set;
+    }
+
   sim_callback = cb;
 
   sim_target_parse_arg_array (argv);
index 4aa642964128f4881397c4db400460e8acc03b29..1a6cd1457b2b5adb85aa496082d43db26d0263d0 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-17  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (cr16_pc_get, cr16_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 86fd28081a00500b5b0bbfeead1f325f25c3aa07..6e31e1a51c422ed0f18804518df02745d99523fe 100644 (file)
@@ -737,6 +737,18 @@ sim_read (SIM_DESC sd, SIM_ADDR addr, unsigned char *buffer, int size)
   return xfer_mem (sd, addr, buffer, size, 0);
 }
 
+static sim_cia
+cr16_pc_get (sim_cpu *cpu)
+{
+  return PC;
+}
+
+static void
+cr16_pc_set (sim_cpu *cpu, sim_cia pc)
+{
+  SET_PC (pc);
+}
+
 static void
 free_state (SIM_DESC sd)
 {
@@ -807,6 +819,15 @@ sim_open (SIM_OPEN_KIND kind, struct host_callback_struct *cb, struct bfd *abfd,
       return 0;
     }
 
+  /* CPU specific initialization.  */
+  for (i = 0; i < MAX_NR_PROCESSORS; ++i)
+    {
+      SIM_CPU *cpu = STATE_CPU (sd, i);
+
+      CPU_PC_FETCH (cpu) = cr16_pc_get;
+      CPU_PC_STORE (cpu) = cr16_pc_set;
+    }
+
   trace_sd = sd;
   cr16_callback = cb;
 
index 4ce1df84aa5835f14ea05bbef0ed67bc8c9212c2..0cf06d7b6d0066e51bd56145850fae224fe6835b 100644 (file)
@@ -1,3 +1,9 @@
+2015-04-17  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (d10v_pc_get, d10v_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 7fc0745e35bd8c3c0fe0cda719158c9fbf5c7765..b975561442308c6e9c72261a6337c566c3c8520a 100644 (file)
@@ -722,6 +722,18 @@ sim_read (SIM_DESC sd, SIM_ADDR addr, unsigned char *buffer, int size)
   return xfer_mem( addr, buffer, size, 0);
 }
 
+static sim_cia
+d10v_pc_get (sim_cpu *cpu)
+{
+  return PC;
+}
+
+static void
+d10v_pc_set (sim_cpu *cpu, sim_cia pc)
+{
+  SET_PC (pc);
+}
+
 static void
 free_state (SIM_DESC sd)
 {
@@ -740,6 +752,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
   struct hash_entry *h;
   static int init_p = 0;
   char **p;
+  int i;
   SIM_DESC sd = sim_state_alloc (kind, cb);
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
@@ -791,6 +804,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) = d10v_pc_get;
+      CPU_PC_STORE (cpu) = d10v_pc_set;
+    }
+
   trace_sd = sd;
   d10v_callback = cb;
   old_segment_mapping = 0;
index eaf30889876e9c50417ef8ea96be4d0ad28acbd2..f414847a8b819e357280714d3b8c7993bc07423e 100644 (file)
@@ -1,3 +1,10 @@
+2015-04-17  Mike Frysinger  <vapier@gentoo.org>
+
+       * compile.c (h8300_pc_get, h8300_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): Define.
+
 2015-04-15  Mike Frysinger  <vapier@gentoo.org>
 
        * Makefile.in (SIM_OBJS): Delete sim-cpu.o.
index e14c3ab625530f909d91447ccc76f8165ffb0113..d084b5d4de0a4227f239e3af64ea2d83b8dccbdd 100644 (file)
@@ -4865,6 +4865,18 @@ set_h8300h (unsigned long machine)
     h8300_normal_mode = 1;
 }
 
+static sim_cia
+h8300_pc_get (sim_cpu *cpu)
+{
+  return cpu->pc;
+}
+
+static void
+h8300_pc_set (sim_cpu *cpu, sim_cia pc)
+{
+  cpu->pc = pc;
+}
+
 /* Cover function of sim_state_free to free the cpu buffers as well.  */
 
 static void
@@ -4883,6 +4895,7 @@ sim_open (SIM_OPEN_KIND kind,
          struct bfd *abfd, 
          char **argv)
 {
+  int i;
   SIM_DESC sd;
   sim_cpu *cpu;
 
@@ -4947,6 +4960,15 @@ sim_open (SIM_OPEN_KIND kind,
       return 0;
     }
 
+  /* CPU specific initialization.  */
+  for (i = 0; i < MAX_NR_PROCESSORS; ++i)
+    {
+      SIM_CPU *cpu = STATE_CPU (sd, i);
+
+      CPU_PC_FETCH (cpu) = h8300_pc_get;
+      CPU_PC_STORE (cpu) = h8300_pc_set;
+    }
+
   /*  sim_hw_configure (sd); */
 
   /* FIXME: Much of the code in sim_load can be moved here.  */
index 8b075052f124d6f3c2c1c405a0c2d6ea181396fc..e428d804532fbb778011a9894b95fc217444b375 100644 (file)
@@ -91,6 +91,8 @@ enum h8_typecodes {
 /* Define sim_cia.  */
 typedef unsigned32 sim_cia;
 
+typedef struct _sim_cpu SIM_CPU;
+
 #include "sim-base.h"
 
 /* Structure used to describe addressing */
index 9fd188c1fd70038fc1018370439b37478713c3d3..42233017c7692f4f4df1c8adcce2140ca31b9431 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-17  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (microblaze_pc_get, microblaze_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 9e95e1ea725e4eb1cde8738f823fa690bd7ac8d4..aa8634e3d8809c614af8ca240329eda9d6c6be74 100644 (file)
@@ -633,6 +633,18 @@ sim_info (SIM_DESC sd, int verbose)
                             (CPU.cycles) ? CPU.cycles+2 : 0);
 }
 
+static sim_cia
+microblaze_pc_get (sim_cpu *cpu)
+{
+  return cpu->microblaze_cpu.spregs[0];
+}
+
+static void
+microblaze_pc_set (sim_cpu *cpu, sim_cia pc)
+{
+  cpu->microblaze_cpu.spregs[0] = pc;
+}
+
 static void
 free_state (SIM_DESC sd)
 {
@@ -706,6 +718,9 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
       SIM_CPU *cpu = STATE_CPU (sd, i);
       int osize = sim_memory_size;
 
+      CPU_PC_FETCH (cpu) = microblaze_pc_get;
+      CPU_PC_STORE (cpu) = microblaze_pc_set;
+
       set_initial_gprs (cpu);
 
       /* Discard and reacquire memory -- start with a clean slate.  */
index 9b5c69e2a7bc7c6a0edfddf53c7e1826d964de81..fc359ed7c7fb84c76da26f7a361d8ff61435611e 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-17  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (sh_pc_get, sh_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 13f6e65ee5c21398a940a5620f262b09a27c6aaa..2f02e69382c7e39073be5a0bb7e30d1e001ede28 100644 (file)
@@ -2373,6 +2373,18 @@ sim_info (SIM_DESC sd, int verbose)
     }
 }
 
+static sim_cia
+sh_pc_get (sim_cpu *cpu)
+{
+  return saved_state.asregs.pc;
+}
+
+static void
+sh_pc_set (sim_cpu *cpu, sim_cia pc)
+{
+  saved_state.asregs.pc = pc;
+}
+
 static void
 free_state (SIM_DESC sd)
 {
@@ -2448,6 +2460,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) = sh_pc_get;
+      CPU_PC_STORE (cpu) = sh_pc_set;
+    }
+
   for (p = argv + 1; *p != NULL; ++p)
     {
       if (isdigit (**p))
This page took 0.03389 seconds and 4 git commands to generate.