ubsan: moxie: left shift of negative value
[deliverable/binutils-gdb.git] / sim / m32r / traps.c
index b52e5f085be918c60587ceed9a06afa5991b5e6b..ec2e57b2b4035e382438afad3947b1e16f765637 100644 (file)
@@ -1,6 +1,5 @@
 /* m32r exception, interrupt, and trap (EIT) support
-   Copyright (C) 1998, 2003, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 1998-2019 Free Software Foundation, Inc.
    Contributed by Cygnus Solutions.
 
    This file is part of GDB, the GNU debugger.
@@ -19,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "sim-main.h"
+#include "sim-syscall.h"
 #include "targ-vals.h"
 
 #define TRAP_FLUSH_CACHE 12
@@ -93,28 +93,6 @@ m32r_core_signal (SIM_DESC sd, SIM_CPU *current_cpu, sim_cia cia,
                     transfer, sig);
 }
 \f
-/* Read/write functions for system call interface.  */
-
-static int
-syscall_read_mem (host_callback *cb, struct cb_syscall *sc,
-                 unsigned long taddr, char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
-
-  return sim_core_read_buffer (sd, cpu, read_map, buf, taddr, bytes);
-}
-
-static int
-syscall_write_mem (host_callback *cb, struct cb_syscall *sc,
-                  unsigned long taddr, const char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
-
-  return sim_core_write_buffer (sd, cpu, write_map, buf, taddr, bytes);
-}
-
 /* Trap support.
    The result is the pc address to continue at.
    Preprocessing like saving the various registers has already been done.  */
@@ -125,18 +103,6 @@ m32r_trap (SIM_CPU *current_cpu, PCADDR pc, int num)
   SIM_DESC sd = CPU_STATE (current_cpu);
   host_callback *cb = STATE_CALLBACK (sd);
 
-#ifdef SIM_HAVE_BREAKPOINTS
-  /* Check for breakpoints "owned" by the simulator first, regardless
-     of --environment.  */
-  if (num == TRAP_BREAKPOINT)
-    {
-      /* First try sim-break.c.  If it's a breakpoint the simulator "owns"
-        it doesn't return.  Otherwise it returns and let's us try.  */
-      sim_handle_breakpoint (sd, current_cpu, pc);
-      /* Fall through.  */
-    }
-#endif
-
   if (STATE_ENVIRONMENT (sd) == OPERATING_ENVIRONMENT)
     {
       /* The new pc is the trap vector entry.
@@ -151,27 +117,20 @@ m32r_trap (SIM_CPU *current_cpu, PCADDR pc, int num)
     {
     case TRAP_SYSCALL :
       {
-       CB_SYSCALL s;
-
-       CB_SYSCALL_INIT (&s);
-       s.func = m32rbf_h_gr_get (current_cpu, 0);
-       s.arg1 = m32rbf_h_gr_get (current_cpu, 1);
-       s.arg2 = m32rbf_h_gr_get (current_cpu, 2);
-       s.arg3 = m32rbf_h_gr_get (current_cpu, 3);
-
-       if (s.func == TARGET_SYS_exit)
-         {
-           sim_engine_halt (sd, current_cpu, NULL, pc, sim_exited, s.arg1);
-         }
-
-       s.p1 = (PTR) sd;
-       s.p2 = (PTR) current_cpu;
-       s.read_mem = syscall_read_mem;
-       s.write_mem = syscall_write_mem;
-       cb_syscall (cb, &s);
-       m32rbf_h_gr_set (current_cpu, 2, s.errcode);
-       m32rbf_h_gr_set (current_cpu, 0, s.result);
-       m32rbf_h_gr_set (current_cpu, 1, s.result2);
+       long result, result2;
+       int errcode;
+
+       sim_syscall_multi (current_cpu,
+                          m32rbf_h_gr_get (current_cpu, 0),
+                          m32rbf_h_gr_get (current_cpu, 1),
+                          m32rbf_h_gr_get (current_cpu, 2),
+                          m32rbf_h_gr_get (current_cpu, 3),
+                          m32rbf_h_gr_get (current_cpu, 4),
+                          &result, &result2, &errcode);
+
+       m32rbf_h_gr_set (current_cpu, 2, errcode);
+       m32rbf_h_gr_set (current_cpu, 0, result);
+       m32rbf_h_gr_set (current_cpu, 1, result2);
        break;
       }
 
This page took 0.024194 seconds and 4 git commands to generate.