1 /* Generic simulator halt/restart.
2 Copyright (C) 1997 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 #include "sim-assert.h"
31 sim_engine_halt (SIM_DESC sd,
33 sim_cpu *next_cpu, /* NULL - use default */
38 sim_engine *engine = STATE_ENGINE (sd);
39 ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
40 if (engine->jmpbuf != NULL)
42 jmp_buf *halt_buf = engine->jmpbuf;
43 engine->last_cpu = last_cpu;
44 engine->next_cpu = next_cpu;
45 engine->reason = reason;
46 engine->sigrc = sigrc;
47 SIM_ENGINE_HALT_HOOK (sd, last_cpu, cia);
48 longjmp(*halt_buf, 1);
51 sim_io_error (sd, "sim_halt - bad long jump");
58 sim_engine_restart (SIM_DESC sd,
63 sim_engine *engine = STATE_ENGINE (sd);
64 ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
65 if (engine->jmpbuf != NULL)
67 jmp_buf *halt_buf = engine->jmpbuf;
68 engine->last_cpu = last_cpu;
69 engine->next_cpu = next_cpu;
70 SIM_ENGINE_RESTART_HOOK (sd, last_cpu, cia);
71 longjmp(*halt_buf, 2);
74 sim_io_error (sd, "sim_restart - bad long jump");
78 /* Generic error code */
81 sim_engine_abort (SIM_DESC sd,
87 ASSERT (sd == NULL || STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
92 vfprintf (stderr, fmt, ap);
94 fprintf (stderr, "\nQuit\n");
97 else if (STATE_ENGINE (sd)->jmpbuf == NULL)
101 sim_io_evprintf (sd, fmt, ap);
103 sim_io_eprintf (sd, "\n");
104 sim_io_error (sd, "Quit Simulator");
110 sim_io_evprintf (sd, fmt, ap);
112 sim_io_eprintf (sd, "\n");
113 sim_engine_halt (sd, cpu, NULL, cia, sim_stopped, SIGABRT);
118 /* Generic next/last cpu */
121 sim_engine_last_cpu_nr (SIM_DESC sd)
123 sim_engine *engine = STATE_ENGINE (sd);
124 if (engine->last_cpu != NULL)
125 return engine->last_cpu - STATE_CPU (sd, 0);
127 return MAX_NR_PROCESSORS;
131 sim_engine_next_cpu_nr (SIM_DESC sd)
133 sim_engine *engine = STATE_ENGINE (sd);
134 if (engine->next_cpu != NULL)
135 return engine->next_cpu - STATE_CPU (sd, 0);
137 return sim_engine_last_cpu_nr (sd) + 1;