1 /* Generic simulator halt/resume.
2 Copyright (C) 1997, 1998 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
5 This file is part of GDB, the GNU debugger.
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)
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.
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. */
25 typedef struct _sim_engine sim_engine
;
39 /* jmpval: 0 (initial use) start simulator
42 This is required by the ISO C standard (the only time 0 is returned
43 is at the initial call to setjmp). */
46 sim_engine_start_jmpval
,
47 sim_engine_halt_jmpval
,
48 sim_engine_restart_jmpval
,
52 /* Get/set the run state of CPU to REASON/SIGRC.
53 REASON/SIGRC are the values returned by sim_stop_reason. */
54 void sim_engine_get_run_state (SIM_DESC sd
, enum sim_stop
*reason
, int *sigrc
);
55 void sim_engine_set_run_state (SIM_DESC sd
, enum sim_stop reason
, int sigrc
);
58 /* Halt the simulator *now* */
60 extern void sim_engine_halt
62 sim_cpu
*last_cpu
, /* NULL -> in event-mgr */
63 sim_cpu
*next_cpu
, /* NULL -> succ (last_cpu) or event-mgr */
66 int sigrc
) __attribute__ ((noreturn
));
68 /* Halt hook - allow target specific operation when halting a
71 #if !defined (SIM_ENGINE_HALT_HOOK)
72 #define SIM_ENGINE_HALT_HOOK(SD, LAST_CPU, CIA) \
73 if ((LAST_CPU) != NULL) CIA_SET (LAST_CPU, CIA)
76 /* NB: If a port uses the SIM_CPU_EXCEPTION_* hooks, the default
77 SIM_ENGINE_HALT_HOOK and SIM_ENGINE_RESUME_HOOK must not be used.
78 They conflict in that the PC set by the HALT_HOOK may overwrite the
79 proper one, as intended to be saved by the EXCEPTION_TRIGGER
83 /* restart the simulator *now* */
85 extern void sim_engine_restart
87 sim_cpu
*last_cpu
, /* NULL -> in event-mgr */
88 sim_cpu
*next_cpu
, /* NULL -> succ (last_cpu) or event-mgr */
91 /* Restart hook - allow target specific operation when restarting a
94 #if !defined (SIM_ENGINE_RESTART_HOOK)
95 #define SIM_ENGINE_RESTART_HOOK(SD, LAST_CPU, CIA) SIM_ENGINE_HALT_HOOK(SD, LAST_CPU, CIA)
101 /* Abort the simulator *now*.
103 This function is NULL safe. It can be called when either of SD or
106 This function is setjmp/longjmp safe. It can be called when of
107 the sim_engine setjmp/longjmp buffer has not been established.
109 Simulators that are using components such as sim-core but are not
110 yet using this sim-engine module should link in file sim-abort.o
111 which implements a non setjmp/longjmp version of
114 extern void sim_engine_abort
119 ...) __attribute__ ((format (printf
, 4, 5))) __attribute__ ((noreturn
));
121 extern void sim_engine_vabort
126 va_list ap
) __attribute__ ((noreturn
));
128 /* No abort hook - when possible this function exits using the
129 engine_halt function (and SIM_ENGINE_HALT_HOOK). */
134 /* Called by the generic sim_resume to run the simulation within the
137 An example implementation of sim_engine_run can be found in the
140 extern void sim_engine_run
144 int siggnal
); /* most simulators ignore siggnal */
148 /* Determine the state of next/last cpu when the simulator was last
149 halted - a value >= MAX_NR_PROCESSORS indicates that the
150 event-queue was next/last. */
152 extern int sim_engine_next_cpu_nr (SIM_DESC sd
);
153 extern int sim_engine_last_cpu_nr (SIM_DESC sd
);
154 extern int sim_engine_nr_cpus (SIM_DESC sd
);
157 /* Establish the simulator engine */
158 MODULE_INSTALL_FN sim_engine_install
;