daily update
[external/binutils.git] / sim / cris / sim-if.c
index 507ba57..33a7c34 100644 (file)
@@ -1,22 +1,21 @@
 /* Main simulator entry points specific to the CRIS.
-   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
    Contributed by Axis Communications.
 
 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/>.  */
 
 /* Based on the fr30 file, mixing in bits from the i960 and pruning of
    dead code.  */
@@ -78,7 +77,11 @@ static CGEN_DISASSEMBLER cris_disassemble_insn;
 static char cris_bare_iron = 0;
 
 /* Whether 0x9000000xx have simulator-specific meanings.  */
-static char cris_have_900000xxif = 0;
+char cris_have_900000xxif = 0;
+
+/* What to do when we face a more or less unknown syscall.  */
+enum cris_unknown_syscall_action_type cris_unknown_syscall_action
+  = CRIS_USYSC_MSG_STOP;
 
 /* Records simulator descriptor so utilities like cris_dump_regs can be
    called from gdb.  */
@@ -90,6 +93,7 @@ typedef enum {
   OPTION_CRIS_TRACE,
   OPTION_CRIS_NAKED,
   OPTION_CRIS_900000XXIF,
+  OPTION_CRIS_UNKNOWN_SYSCALL
 } CRIS_OPTIONS;
 
 static const OPTION cris_options[] =
@@ -108,6 +112,10 @@ static const OPTION cris_options[] =
   { {"cris-900000xx", no_argument, NULL, OPTION_CRIS_900000XXIF},
      '\0', NULL, "Define addresses at 0x900000xx with simulator semantics",
      cris_option_handler, NULL },
+  { {"cris-unknown-syscall", required_argument, NULL,
+     OPTION_CRIS_UNKNOWN_SYSCALL},
+     '\0', "stop|enosys|enosys-quiet", "Action at an unknown system call",
+     cris_option_handler, NULL },
   { {NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL, NULL }
 };
 \f
@@ -152,9 +160,9 @@ cris_option_handler (SIM_DESC sd, sim_cpu *cpu ATTRIBUTE_UNUSED, int opt,
          *tracefp = FLAG_CRIS_MISC_PROFILE_ALL;
        else
          {
-           /* We'll actually never get here; the caller handles the
-              error case.  */
-           sim_io_eprintf (sd, "Unknown option `--cris-stats=%s'\n", arg);
+           /* Beware; the framework does not handle the error case;
+              we have to do it ourselves.  */
+           sim_io_eprintf (sd, "Unknown option `--cris-cycles=%s'\n", arg);
            return SIM_RC_FAIL;
          }
        break;
@@ -177,6 +185,21 @@ cris_option_handler (SIM_DESC sd, sim_cpu *cpu ATTRIBUTE_UNUSED, int opt,
        cris_have_900000xxif = 1;
        break;
 
+      case OPTION_CRIS_UNKNOWN_SYSCALL:
+       if (strcmp (arg, "enosys") == 0)
+         cris_unknown_syscall_action = CRIS_USYSC_MSG_ENOSYS;
+       else if (strcmp (arg, "enosys-quiet") == 0)
+         cris_unknown_syscall_action = CRIS_USYSC_QUIET_ENOSYS;
+       else if (strcmp (arg, "stop") == 0)
+         cris_unknown_syscall_action = CRIS_USYSC_MSG_STOP;
+       else
+         {
+           sim_io_eprintf (sd, "Unknown option `--cris-unknown-syscall=%s'\n",
+                           arg);
+           return SIM_RC_FAIL;
+         }
+       break;
+
       default:
        /* We'll actually never get here; the caller handles the error
           case.  */
@@ -506,7 +529,15 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
        memset (cpu->sighandler, 0, sizeof (cpu->sighandler));
        cpu->make_thread_cpu_data = NULL;
        cpu->thread_cpu_data_size = 0;
+#if WITH_HW
+       cpu->deliver_interrupt = NULL;
+#endif
       }
+#if WITH_HW
+    /* Always be cycle-accurate and call before/after functions if
+       with-hardware.  */
+    sim_profile_set_option (sd, "-model", PROFILE_MODEL_IDX, "on");
+#endif
   }
 
   /* Initialize various cgen things not done by common framework.