]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - sim/common/sim-engine.h
Update year range in copyright notice of all files owned by the GDB project.
[thirdparty/binutils-gdb.git] / sim / common / sim-engine.h
index 57c43e95a62e74e1815e016d4d0a52c0c05a714d..3fd0a205e041e91c331b43bfaab913dec64d7303 100644 (file)
@@ -1,22 +1,21 @@
 /* Generic simulator halt/resume.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997-2015 Free Software Foundation, Inc.
    Contributed by Cygnus Support.
 
 This file is part of GDB, the GNU debugger.
 
 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/>.  */
 
 #ifndef SIM_ENGINE_H
 #define SIM_ENGINE_H
@@ -28,6 +27,7 @@ struct _sim_engine
   void *jmpbuf;
   sim_cpu *last_cpu;
   sim_cpu *next_cpu;
+  int nr_cpus;
   enum sim_stop reason;
   sim_event *stepper;
   int sigrc;
@@ -35,31 +35,56 @@ struct _sim_engine
 
 
 
+/* jmpval: 0 (initial use) start simulator
+           1               halt simulator
+           2               restart simulator
+   This is required by the ISO C standard (the only time 0 is returned
+   is at the initial call to setjmp). */
+
+enum {
+  sim_engine_start_jmpval,
+  sim_engine_halt_jmpval,
+  sim_engine_restart_jmpval,
+};
+
+
+/* Get/set the run state of CPU to REASON/SIGRC.
+   REASON/SIGRC are the values returned by sim_stop_reason.  */
+void sim_engine_get_run_state (SIM_DESC sd, enum sim_stop *reason, int *sigrc);
+void sim_engine_set_run_state (SIM_DESC sd, enum sim_stop reason, int sigrc);
+
+
 /* Halt the simulator *now* */
 
 extern void sim_engine_halt
 (SIM_DESC sd,
- sim_cpu *last_cpu,
+ sim_cpu *last_cpu, /* NULL -> in event-mgr */
  sim_cpu *next_cpu, /* NULL -> succ (last_cpu) or event-mgr */
  sim_cia cia,
  enum sim_stop reason,
- int sigrc);
+ int sigrc) __attribute__ ((noreturn));
 
 /* Halt hook - allow target specific operation when halting a
    simulator */
 
 #if !defined (SIM_ENGINE_HALT_HOOK)
-#define SIM_ENGINE_HALT_HOOK(SD, LAST_CPU, CIA) if ((LAST_CPU) != NULL) (LAST_CPU)->cia = cia
+#define SIM_ENGINE_HALT_HOOK(SD, LAST_CPU, CIA) \
+if ((LAST_CPU) != NULL) CIA_SET (LAST_CPU, CIA)
 #endif
 
+/* NB: If a port uses the SIM_CPU_EXCEPTION_* hooks, the default
+   SIM_ENGINE_HALT_HOOK and SIM_ENGINE_RESUME_HOOK must not be used.
+   They conflict in that the PC set by the HALT_HOOK may overwrite the
+   proper one, as intended to be saved by the EXCEPTION_TRIGGER
+   hook. */
 
 
 /* restart the simulator *now* */
 
 extern void sim_engine_restart
 (SIM_DESC sd,
- sim_cpu *last_cpu,
- sim_cpu *next_cpu,
+ sim_cpu *last_cpu, /* NULL -> in event-mgr */
+ sim_cpu *next_cpu, /* NULL -> succ (last_cpu) or event-mgr */
  sim_cia cia);
 
 /* Restart hook - allow target specific operation when restarting a
@@ -90,7 +115,14 @@ extern void sim_engine_abort
  sim_cpu *cpu,
  sim_cia cia,
  const char *fmt,
- ...);
+ ...) __attribute__ ((format (printf, 4, 5))) __attribute__ ((noreturn));
+
+extern void sim_engine_vabort
+(SIM_DESC sd,
+ sim_cpu *cpu,
+ sim_cia cia,
+ const char *fmt,
+ va_list ap) __attribute__ ((noreturn));
 
 /* No abort hook - when possible this function exits using the
    engine_halt function (and SIM_ENGINE_HALT_HOOK). */
@@ -107,16 +139,22 @@ extern void sim_engine_abort
 extern void sim_engine_run
 (SIM_DESC sd,
  int next_cpu_nr,
+ int nr_cpus,
  int siggnal); /* most simulators ignore siggnal */
 
 
 
 /* Determine the state of next/last cpu when the simulator was last
-   halted - a value >= nr-cpus indicates that the event-queue was
-   next/last. */
+   halted - a value >= MAX_NR_PROCESSORS indicates that the
+   event-queue was next/last. */
 
 extern int sim_engine_next_cpu_nr (SIM_DESC sd);
 extern int sim_engine_last_cpu_nr (SIM_DESC sd);
+extern int sim_engine_nr_cpus (SIM_DESC sd);
+
+
+/* Establish the simulator engine */
+MODULE_INSTALL_FN sim_engine_install;
 
 
 #endif