OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [sim/] [common/] [sim-engine.h] - Blame information for rev 311

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
/* Generic simulator halt/resume.
2
   Copyright (C) 1997, 1998, 2007, 2008 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 3 of the License, or
10
(at your option) 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
18
along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
 
20
#ifndef SIM_ENGINE_H
21
#define SIM_ENGINE_H
22
 
23
 
24
typedef struct _sim_engine sim_engine;
25
struct _sim_engine
26
{
27
  void *jmpbuf;
28
  sim_cpu *last_cpu;
29
  sim_cpu *next_cpu;
30
  int nr_cpus;
31
  enum sim_stop reason;
32
  sim_event *stepper;
33
  int sigrc;
34
};
35
 
36
 
37
 
38
/* jmpval: 0 (initial use) start simulator
39
           1               halt simulator
40
           2               restart simulator
41
   This is required by the ISO C standard (the only time 0 is returned
42
   is at the initial call to setjmp). */
43
 
44
enum {
45
  sim_engine_start_jmpval,
46
  sim_engine_halt_jmpval,
47
  sim_engine_restart_jmpval,
48
};
49
 
50
 
51
/* Get/set the run state of CPU to REASON/SIGRC.
52
   REASON/SIGRC are the values returned by sim_stop_reason.  */
53
void sim_engine_get_run_state (SIM_DESC sd, enum sim_stop *reason, int *sigrc);
54
void sim_engine_set_run_state (SIM_DESC sd, enum sim_stop reason, int sigrc);
55
 
56
 
57
/* Halt the simulator *now* */
58
 
59
extern void sim_engine_halt
60
(SIM_DESC sd,
61
 sim_cpu *last_cpu, /* NULL -> in event-mgr */
62
 sim_cpu *next_cpu, /* NULL -> succ (last_cpu) or event-mgr */
63
 sim_cia cia,
64
 enum sim_stop reason,
65
 int sigrc) __attribute__ ((noreturn));
66
 
67
/* Halt hook - allow target specific operation when halting a
68
   simulator */
69
 
70
#if !defined (SIM_ENGINE_HALT_HOOK)
71
#define SIM_ENGINE_HALT_HOOK(SD, LAST_CPU, CIA) \
72
if ((LAST_CPU) != NULL) CIA_SET (LAST_CPU, CIA)
73
#endif
74
 
75
/* NB: If a port uses the SIM_CPU_EXCEPTION_* hooks, the default
76
   SIM_ENGINE_HALT_HOOK and SIM_ENGINE_RESUME_HOOK must not be used.
77
   They conflict in that the PC set by the HALT_HOOK may overwrite the
78
   proper one, as intended to be saved by the EXCEPTION_TRIGGER
79
   hook. */
80
 
81
 
82
/* restart the simulator *now* */
83
 
84
extern void sim_engine_restart
85
(SIM_DESC sd,
86
 sim_cpu *last_cpu, /* NULL -> in event-mgr */
87
 sim_cpu *next_cpu, /* NULL -> succ (last_cpu) or event-mgr */
88
 sim_cia cia);
89
 
90
/* Restart hook - allow target specific operation when restarting a
91
   simulator */
92
 
93
#if !defined (SIM_ENGINE_RESTART_HOOK)
94
#define SIM_ENGINE_RESTART_HOOK(SD, LAST_CPU, CIA) SIM_ENGINE_HALT_HOOK(SD, LAST_CPU, CIA)
95
#endif
96
 
97
 
98
 
99
 
100
/* Abort the simulator *now*.
101
 
102
   This function is NULL safe.  It can be called when either of SD or
103
   CIA are NULL.
104
 
105
   This function is setjmp/longjmp safe.  It can be called when of
106
   the sim_engine setjmp/longjmp buffer has not been established.
107
 
108
   Simulators that are using components such as sim-core but are not
109
   yet using this sim-engine module should link in file sim-abort.o
110
   which implements a non setjmp/longjmp version of
111
   sim_engine_abort. */
112
 
113
extern void sim_engine_abort
114
(SIM_DESC sd,
115
 sim_cpu *cpu,
116
 sim_cia cia,
117
 const char *fmt,
118
 ...) __attribute__ ((format (printf, 4, 5))) __attribute__ ((noreturn));
119
 
120
extern void sim_engine_vabort
121
(SIM_DESC sd,
122
 sim_cpu *cpu,
123
 sim_cia cia,
124
 const char *fmt,
125
 va_list ap) __attribute__ ((noreturn));
126
 
127
/* No abort hook - when possible this function exits using the
128
   engine_halt function (and SIM_ENGINE_HALT_HOOK). */
129
 
130
 
131
 
132
 
133
/* Called by the generic sim_resume to run the simulation within the
134
   above safty net.
135
 
136
   An example implementation of sim_engine_run can be found in the
137
   file sim-run.c */
138
 
139
extern void sim_engine_run
140
(SIM_DESC sd,
141
 int next_cpu_nr,
142
 int nr_cpus,
143
 int siggnal); /* most simulators ignore siggnal */
144
 
145
 
146
 
147
/* Determine the state of next/last cpu when the simulator was last
148
   halted - a value >= MAX_NR_PROCESSORS indicates that the
149
   event-queue was next/last. */
150
 
151
extern int sim_engine_next_cpu_nr (SIM_DESC sd);
152
extern int sim_engine_last_cpu_nr (SIM_DESC sd);
153
extern int sim_engine_nr_cpus (SIM_DESC sd);
154
 
155
 
156
/* Establish the simulator engine */
157
MODULE_INSTALL_FN sim_engine_install;
158
 
159
 
160
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.