]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - sim/m32r/m32r.c
sim: split sim-signal.h include out
[thirdparty/binutils-gdb.git] / sim / m32r / m32r.c
index 06e8ba275a4282646371ef455dfc65253fc6c9cc..3f8305ecd5e9b9f9998d6e879bd08433a00fa264 100644 (file)
@@ -1,5 +1,5 @@
 /* m32r simulator support code
-   Copyright (C) 1996-2015 Free Software Foundation, Inc.
+   Copyright (C) 1996-2021 Free Software Foundation, Inc.
    Contributed by Cygnus Support.
 
    This file is part of GDB, the GNU debugger.
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This must come before any other includes.  */
+#include "defs.h"
+
 #define WANT_CPU m32rbf
 #define WANT_CPU_M32RBF
 
 #include "sim-main.h"
 #include "cgen-mem.h"
 #include "cgen-ops.h"
+#include <stdlib.h>
+
+/* Return the size of REGNO in bytes.  */
+
+static int
+m32rbf_register_size (int regno)
+{
+  return 4;
+}
 
 /* Decode gdb ctrl register number.  */
 
@@ -48,6 +60,10 @@ m32r_decode_gdb_ctrl_regnum (int gdb_regnum)
 int
 m32rbf_fetch_register (SIM_CPU *current_cpu, int rn, unsigned char *buf, int len)
 {
+  int size = m32rbf_register_size (rn);
+  if (len != size)
+    return -1;
+
   if (rn < 16)
     SETTWI (buf, m32rbf_h_gr_get (current_cpu, rn));
   else
@@ -76,7 +92,7 @@ m32rbf_fetch_register (SIM_CPU *current_cpu, int rn, unsigned char *buf, int len
        return 0;
       }
 
-  return -1; /*FIXME*/
+  return size;
 }
 
 /* The contents of BUF are in target byte order.  */
@@ -84,6 +100,10 @@ m32rbf_fetch_register (SIM_CPU *current_cpu, int rn, unsigned char *buf, int len
 int
 m32rbf_store_register (SIM_CPU *current_cpu, int rn, unsigned char *buf, int len)
 {
+  int size = m32rbf_register_size (rn);
+  if (len != size)
+    return -1;
+
   if (rn < 16)
     m32rbf_h_gr_set (current_cpu, rn, GETTWI (buf));
   else
@@ -121,7 +141,7 @@ m32rbf_store_register (SIM_CPU *current_cpu, int rn, unsigned char *buf, int len
        return 0;
       }
 
-  return -1; /*FIXME*/
+  return size;
 }
 \f
 USI