This commit was generated by cvs2svn to track changes on a CVS vendor
[external/binutils.git] / sim / common / sim-engine.h
1 /* Generic simulator halt/resume.
2    Copyright (C) 1997 Free Software Foundation, Inc.
3    Contributed by Cygnus Support.
4
5 This file is part of GDB, the GNU debugger.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
20
21 #ifndef SIM_ENGINE_H
22 #define SIM_ENGINE_H
23
24
25 typedef struct _sim_engine sim_engine;
26 struct _sim_engine
27 {
28   void *jmpbuf;
29   sim_cpu *last_cpu;
30   sim_cpu *next_cpu;
31   enum sim_stop reason;
32   sim_event *stepper;
33   int sigrc;
34 };
35
36
37
38 /* Halt the simulator *now* */
39
40 extern void sim_engine_halt
41 (SIM_DESC sd,
42  sim_cpu *last_cpu,
43  sim_cpu *next_cpu, /* NULL -> succ (last_cpu) or event-mgr */
44  sim_cia cia,
45  enum sim_stop reason,
46  int sigrc);
47
48 /* Halt hook - allow target specific operation when halting a
49    simulator */
50
51 #if !defined (SIM_ENGINE_HALT_HOOK)
52 #define SIM_ENGINE_HALT_HOOK(SD, LAST_CPU, CIA) if ((LAST_CPU) != NULL) (LAST_CPU)->cia = cia
53 #endif
54
55
56
57 /* restart the simulator *now* */
58
59 extern void sim_engine_restart
60 (SIM_DESC sd,
61  sim_cpu *last_cpu,
62  sim_cpu *next_cpu,
63  sim_cia cia);
64
65 /* Restart hook - allow target specific operation when restarting a
66    simulator */
67
68 #if !defined (SIM_ENGINE_RESTART_HOOK)
69 #define SIM_ENGINE_RESTART_HOOK(SD, LAST_CPU, CIA) SIM_ENGINE_HALT_HOOK(SD, LAST_CPU, CIA)
70 #endif
71
72
73
74
75 /* Abort the simulator *now*.
76
77    This function is NULL safe.  It can be called when either of SD or
78    CIA are NULL.
79
80    This function is setjmp/longjmp safe.  It can be called when of
81    the sim_engine setjmp/longjmp buffer has not been established.
82
83    Simulators that are using components such as sim-core but are not
84    yet using this sim-engine module should link in file sim-abort.o
85    which implements a non setjmp/longjmp version of
86    sim_engine_abort. */
87
88 extern void sim_engine_abort
89 (SIM_DESC sd,
90  sim_cpu *cpu,
91  sim_cia cia,
92  const char *fmt,
93  ...);
94
95 /* No abort hook - when possible this function exits using the
96    engine_halt function (and SIM_ENGINE_HALT_HOOK). */
97
98
99
100
101 /* Called by the generic sim_resume to run the simulation within the
102    above safty net.
103
104    An example implementation of sim_engine_run can be found in the
105    file sim-run.c */
106
107 extern void sim_engine_run
108 (SIM_DESC sd,
109  int next_cpu_nr,
110  int siggnal); /* most simulators ignore siggnal */
111
112
113
114 /* Determine the state of next/last cpu when the simulator was last
115    halted - a value >= nr-cpus indicates that the event-queue was
116    next/last. */
117
118 extern int sim_engine_next_cpu_nr (SIM_DESC sd);
119 extern int sim_engine_last_cpu_nr (SIM_DESC sd);
120
121
122 #endif