Add parameter to allow enabling/disabling selftests via configure
[external/binutils.git] / sim / frv / sim-if.c
index 66dd551..405bef2 100644 (file)
@@ -1,22 +1,21 @@
 /* Main simulator entry points specific to the FRV.
-   Copyright (C) 1998, 1999, 2000, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1998-2018 Free Software Foundation, Inc.
    Contributed by Red Hat.
 
 This file is part of the GNU simulators.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc.,
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #define WANT_CPU
 #define WANT_CPU_FRVBF
@@ -31,10 +30,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 static void free_state (SIM_DESC);
 static void print_frv_misc_cpu (SIM_CPU *cpu, int verbose);
-
-/* Records simulator descriptor so utilities like frv_dump_regs can be
-   called from gdb.  */
-SIM_DESC current_state;
 \f
 /* Cover function of sim_state_free to free the cpu buffers as well.  */
 
@@ -54,7 +49,7 @@ sim_open (kind, callback, abfd, argv)
      SIM_OPEN_KIND kind;
      host_callback *callback;
      bfd *abfd;
-     char **argv;
+     char * const *argv;
 {
   char c;
   int i;
@@ -88,31 +83,13 @@ sim_open (kind, callback, abfd, argv)
      augment the meaning of an option.  */
   sim_add_option_table (sd, NULL, frv_options);
 
-  /* 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)
     {
       free_state (sd);
       return 0;
     }
 
-#if 0
-  /* Allocate a handler for the control registers and other devices
-     if no memory for that range has been allocated by the user.
-     All are allocated in one chunk to keep things from being
-     unnecessarily complicated.  */
-  if (sim_core_read_buffer (sd, NULL, read_map, &c, FRV_DEVICE_ADDR, 1) == 0)
-    sim_core_attach (sd, NULL,
-                    0 /*level*/,
-                    access_read_write,
-                    0 /*space ???*/,
-                    FRV_DEVICE_ADDR, FRV_DEVICE_LEN /*nr_bytes*/,
-                    0 /*modulo*/,
-                    &frv_devices,
-                    NULL /*buffer*/);
-#endif
-
   /* Allocate core managed memory if none specified by user.
      Use address 4 here in case the user wanted address 0 unmapped.  */
   if (sim_core_read_buffer (sd, NULL, read_map, &c, 4, 1) == 0)
@@ -192,15 +169,11 @@ sim_open (kind, callback, abfd, argv)
       frv_initialize (cpu, sd);
     }
 
-  /* Store in a global so things like sparc32_dump_regs can be invoked
-     from the gdb command line.  */
-  current_state = sd;
-
   return sd;
 }
 
 void
-sim_close (sd, quitting)
+frv_sim_close (sd, quitting)
      SIM_DESC sd;
      int quitting;
 {
@@ -212,17 +185,14 @@ sim_close (sd, quitting)
       frv_cache_term (CPU_INSN_CACHE (cpu));
       frv_cache_term (CPU_DATA_CACHE (cpu));
     }
-
-  frv_cgen_cpu_close (CPU_CPU_DESC (STATE_CPU (sd, 0)));
-  sim_module_uninstall (sd);
 }
 \f
 SIM_RC
 sim_create_inferior (sd, abfd, argv, envp)
      SIM_DESC sd;
      bfd *abfd;
-     char **argv;
-     char **envp;
+     char * const *argv;
+     char * const *envp;
 {
   SIM_CPU *current_cpu = STATE_CPU (sd, 0);
   SIM_ADDR addr;
@@ -233,19 +203,15 @@ sim_create_inferior (sd, abfd, argv, envp)
     addr = 0;
   sim_pc_set (current_cpu, addr);
 
-#if 0
-  STATE_ARGV (sd) = sim_copy_argv (argv);
-  STATE_ENVP (sd) = sim_copy_argv (envp);
-#endif
+  /* Standalone mode (i.e. `run`) will take care of the argv for us in
+     sim_open() -> sim_parse_args().  But in debug mode (i.e. 'target sim'
+     with `gdb`), we need to handle it because the user can change the
+     argv on the fly via gdb's 'run'.  */
+  if (STATE_PROG_ARGV (sd) != argv)
+    {
+      freeargv (STATE_PROG_ARGV (sd));
+      STATE_PROG_ARGV (sd) = dupargv (argv);
+    }
 
   return SIM_RC_OK;
 }
-
-void
-sim_do_command (sd, cmd)
-     SIM_DESC sd;
-     char *cmd;
-{ 
-  if (sim_args_command (sd, cmd) != SIM_RC_OK)
-    sim_io_eprintf (sd, "Unknown command `%s'\n", cmd);
-}