sim: enable hardware support by default
[binutils-gdb.git] / sim / v850 / interp.c
index f055149cce6366aaec99c3c2105e8d07fe207749..e72dab645dd94cf4024c864a82a5955b8840cc97 100644 (file)
@@ -4,17 +4,8 @@
 #include "sim-assert.h"
 #include "itable.h"
 
-#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
-#endif
-
-#ifdef HAVE_STRING_H
 #include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
 
 #include "bfd.h"
 
@@ -188,11 +179,14 @@ v850_pc_set (sim_cpu *cpu, sim_cia pc)
   PC = pc;
 }
 
+static int v850_reg_fetch (SIM_CPU *, int, unsigned char *, int);
+static int v850_reg_store (SIM_CPU *, int, unsigned char *, int);
+
 SIM_DESC
 sim_open (SIM_OPEN_KIND    kind,
          host_callback *  cb,
          struct bfd *     abfd,
-         char **          argv)
+         char * const *   argv)
 {
   int i;
   SIM_DESC sd = sim_state_alloc (kind, cb);
@@ -201,15 +195,13 @@ sim_open (SIM_OPEN_KIND    kind,
   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)
+  if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
     return 0;
 
   /* for compatibility */
   simulator = sd;
 
   /* FIXME: should be better way of setting up interrupts */
-  STATE_WATCHPOINTS (sd)->pc = &(PC);
-  STATE_WATCHPOINTS (sd)->sizeof_pc = sizeof (PC);
   STATE_WATCHPOINTS (sd)->interrupt_handler = do_interrupt;
   STATE_WATCHPOINTS (sd)->interrupt_names = interrupt_names;
 
@@ -231,9 +223,7 @@ sim_open (SIM_OPEN_KIND    kind,
   /* similarly if in the internal RAM region */
   sim_do_command (sd, "memory region 0xffe000,0x1000,1024");
 
-  /* getopt will print the error message so we just have to exit if this fails.
-     FIXME: Hmmm...  in the case of gdb we need getopt to call
-     print_filtered.  */
+  /* The parser will print an error message for us, so we silently return.  */
   if (sim_parse_args (sd, argv) != SIM_RC_OK)
     {
       /* Uninstall the modules to avoid memory leaks,
@@ -296,6 +286,8 @@ sim_open (SIM_OPEN_KIND    kind,
     {
       SIM_CPU *cpu = STATE_CPU (sd, i);
 
+      CPU_REG_FETCH (cpu) = v850_reg_fetch;
+      CPU_REG_STORE (cpu) = v850_reg_store;
       CPU_PC_FETCH (cpu) = v850_pc_get;
       CPU_PC_STORE (cpu) = v850_pc_set;
     }
@@ -306,8 +298,8 @@ sim_open (SIM_OPEN_KIND    kind,
 SIM_RC
 sim_create_inferior (SIM_DESC      sd,
                     struct bfd *  prog_bfd,
-                    char **       argv,
-                    char **       env)
+                    char * const *argv,
+                    char * const *env)
 {
   memset (&State, 0, sizeof (State));
   if (prog_bfd != NULL)
@@ -315,21 +307,15 @@ sim_create_inferior (SIM_DESC      sd,
   return SIM_RC_OK;
 }
 
-int
-sim_fetch_register (SIM_DESC         sd,
-                   int              rn,
-                   unsigned char *  memory,
-                   int              length)
+static int
+v850_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
   *(unsigned32*)memory = H2T_4 (State.regs[rn]);
   return -1;
 }
-int
-sim_store_register (SIM_DESC        sd,
-                   int             rn,
-                   unsigned char * memory,
-                   int             length)
+
+static int
+v850_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
   State.regs[rn] = T2H_4 (*(unsigned32 *) memory);
   return length;