* objcopy.c: Move new struct and variable definitions to top of
[deliverable/binutils-gdb.git] / include / remote-sim.h
1 /* This file defines the interface between the simulator and gdb.
2 Copyright (C) 1993, 1994, 1996, 1997 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20 #if !defined (REMOTE_SIM_H)
21 #define REMOTE_SIM_H 1
22
23 /* This file is used when building stand-alone simulators, so isolate this
24 file from gdb. */
25
26 /* Pick up CORE_ADDR_TYPE if defined (from gdb), otherwise use same value as
27 gdb does (unsigned int - from defs.h). */
28
29 #ifndef CORE_ADDR_TYPE
30 typedef unsigned int SIM_ADDR;
31 #else
32 typedef CORE_ADDR_TYPE SIM_ADDR;
33 #endif
34
35
36 /* Semi-opaque type used as result of sim_open and passed back to all
37 other routines. "desc" is short for "descriptor".
38 It is up to each simulator to define `sim_state'. */
39
40 typedef struct sim_state *SIM_DESC;
41
42
43 /* Values for `kind' arg to sim_open. */
44
45 typedef enum {
46 SIM_OPEN_STANDALONE, /* simulator used standalone (run.c) */
47 SIM_OPEN_DEBUG /* simulator used by debugger (gdb) */
48 } SIM_OPEN_KIND;
49
50
51 /* Return codes from various functions. */
52
53 typedef enum {
54 SIM_RC_FAIL = 0,
55 SIM_RC_OK = 1,
56 SIM_RC_UNKNOWN_BREAKPOINT = 2,
57 SIM_RC_INSUFFICIENT_RESOURCES = 3,
58 SIM_RC_DUPLICATE_BREAKPOINT = 4
59 } SIM_RC;
60
61
62 /* The bfd struct, as an opaque type. */
63
64 struct _bfd;
65
66
67 /* Main simulator entry points. */
68
69
70 /* Create a fully initialized simulator instance.
71
72 (This function is called when the simulator is selected from the
73 gdb command line.)
74
75 KIND specifies how the simulator shall be used. Currently there
76 are only two kinds: stand-alone and debug.
77
78 CALLBACK specifies a standard host callback (defined in callback.h).
79
80 ABFD, when non NULL, designates a target program. The program is
81 not loaded.
82
83 ARGV is a standard ARGV pointer such as that passed from the
84 command line. The syntax of the argument list is is assumed to be
85 ``SIM-PROG { SIM-OPTION } [ TARGET-PROGRAM { TARGET-OPTION } ]''.
86 The trailing TARGET-PROGRAM and args are only valid for a
87 stand-alone simulator.
88
89 On success, the result is a non NULL descriptor that shall be
90 passed to the other sim_foo functions. While the simulator
91 configuration can be parameterized by (in decreasing precedence)
92 ARGV's SIM-OPTION, ARGV's TARGET-PROGRAM and the ABFD argument, the
93 successful creation of the simulator shall not dependent on the
94 presence of any of these arguments/options.
95
96 Hardware simulator: The created simulator shall be sufficiently
97 initialized to handle, with out restrictions any client requests
98 (including memory reads/writes, register fetch/stores and a
99 resume).
100
101 Process simulator: that process is not created until a call to
102 sim_create_inferior. FIXME: What should the state of the simulator
103 be? */
104
105 SIM_DESC sim_open PARAMS ((SIM_OPEN_KIND kind, struct host_callback_struct *callback, struct _bfd *abfd, char **argv));
106
107
108 /* Destory a simulator instance.
109
110 QUITTING is non-zero if we cannot hang on errors.
111
112 This may involve freeing target memory and closing any open files
113 and mmap'd areas. You cannot assume sim_kill has already been
114 called. */
115
116 void sim_close PARAMS ((SIM_DESC sd, int quitting));
117
118
119 /* Load program PROG into the simulators memory.
120
121 If ABFD is non-NULL, the bfd for the file has already been opened.
122 The result is a return code indicating success.
123
124 Hardware simulator: Normally, each program section is written into
125 memory according to that sections LMA using physical (direct)
126 addressing. The exception being systems, such as PPC/CHRP, which
127 support more complicated program loaders. A call to this function
128 should not effect the state of the processor registers. Multiple
129 calls to this function are permitted and have an accumulative
130 effect.
131
132 Process simulator: Calls to this function may be ignored.
133
134 FIXME: Most hardware simulators load the image at the VMA using
135 virtual addressing.
136
137 FIXME: For some hardware targets, before a loaded program can be
138 executed, it requires the manipulation of VM registers and tables.
139 Such manipulation should probably (?) occure in
140 sim_create_inferior. */
141
142 SIM_RC sim_load PARAMS ((SIM_DESC sd, char *prog, struct _bfd *abfd, int from_tty));
143
144
145 /* Prepare to run the simulated program.
146
147 ABFD, if not NULL, provides initial processor state information.
148 ARGV and ENV, if non NULL, are NULL terminated lists of pointers.
149
150 Hardware simulator: This function shall initialize the processor
151 registers to a known value. The program counter and possibly stack
152 pointer shall be set using information obtained from ABFD (or
153 hardware reset defaults). ARGV and ENV, dependant on the target
154 ABI, may be written to memory.
155
156 Process simulator: After a call to this function, a new process
157 instance shall exist. The TEXT, DATA, BSS and stack regions shall
158 all be initialized, ARGV and ENV shall be written to process
159 address space (according to the applicable ABI) and the program
160 counter and stack pointer set accordingly. */
161
162 SIM_RC sim_create_inferior PARAMS ((SIM_DESC sd, struct _bfd *abfd, char **argv, char **env));
163
164
165 /* Fetch LENGTH bytes of the simulated program's memory. Start fetch
166 at virtual address MEM and store in BUF. Result is number of bytes
167 read, or zero if error. */
168
169 int sim_read PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length));
170
171
172 /* Store LENGTH bytes from BUF into the simulated program's
173 memory. Store bytes starting at virtual address MEM. Result is
174 number of bytes write, or zero if error. */
175
176 int sim_write PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length));
177
178
179 /* Fetch register REGNO and store the raw (target endian) value in
180 BUF. */
181
182 void sim_fetch_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf));
183
184
185 /* Store register REGNO from the raw (target endian) value in BUF. */
186
187 void sim_store_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf));
188
189
190 /* Print whatever statistics the simulator has collected.
191
192 VERBOSE is currently unused and must always be zero. */
193
194 void sim_info PARAMS ((SIM_DESC sd, int verbose));
195
196
197 /* Run (or resume) the simulated program. */
198
199 void sim_resume PARAMS ((SIM_DESC sd, int step, int siggnal));
200
201
202 /* Asynchronous request to stop the simulation.
203 A nonzero return indicates that the simulator is able to handle
204 the request */
205
206 int sim_stop PARAMS ((SIM_DESC sd));
207
208
209 /* Fetch the REASON why the program stopped.
210
211 SIM_EXITED: The program has terminated. SIGRC indicates the target
212 dependant exit status.
213
214 SIM_STOPPED: The program has stopped. SIGRC uses the host's signal
215 numbering as a way of identifying the reaon: program interrupted by
216 user via a sim_stop request (SIGINT); a breakpoint instruction
217 (SIGTRAP); a completed single step (SIGTRAP); an internal error
218 condition (SIGABRT); an illegal instruction (SIGILL); Access to an
219 undefined memory region (SIGSEGV); Mis-aligned memory access
220 (SIGBUS).
221
222 SIM_SIGNALLED: The simulator encountered target code that requires
223 the signal SIGRC to be delivered to the simulated program.
224
225 SIM_RUNNING, SIM_POLLING: The return of one of these values
226 indicates a problem internal to the simulator. */
227
228 enum sim_stop { sim_running, sim_polling, sim_exited, sim_stopped, sim_signalled };
229
230 void sim_stop_reason PARAMS ((SIM_DESC sd, enum sim_stop *reason, int *sigrc));
231
232
233 /* Passthru for other commands that the simulator might support.
234 Simulators should be prepared to deal with any combination of NULL
235 or empty CMD. */
236
237 void sim_do_command PARAMS ((SIM_DESC sd, char *cmd));
238
239 /* Call these functions to set and clear breakpoints at ADDR. */
240
241 SIM_RC sim_set_breakpoint PARAMS ((SIM_DESC sd, SIM_ADDR addr));
242 SIM_RC sim_clear_breakpoint PARAMS ((SIM_DESC sd, SIM_ADDR addr));
243 SIM_RC sim_clear_all_breakpoints PARAMS ((SIM_DESC sd));
244
245 /* These functions are used to enable and disable breakpoints. */
246
247 SIM_RC sim_enable_breakpoint PARAMS ((SIM_DESC sd, SIM_ADDR addr));
248 SIM_RC sim_disable_breakpoint PARAMS ((SIM_DESC sd, SIM_ADDR addr));
249 SIM_RC sim_enable_all_breakpoints PARAMS ((SIM_DESC sd));
250 SIM_RC sim_disable_all_breakpoints PARAMS ((SIM_DESC sd));
251 \f
252
253 /* Provide simulator with a default (global) host_callback_struct.
254 THIS PROCEDURE IS DEPRECIATED.
255 GDB and NRUN do not use this interface.
256 This procedure does not take a SIM_DESC argument as it is
257 used before sim_open. */
258
259 void sim_set_callbacks PARAMS ((struct host_callback_struct *));
260
261
262 /* Set the size of the simulator memory array.
263 THIS PROCEDURE IS DEPRECIATED.
264 GDB and NRUN do not use this interface.
265 This procedure does not take a SIM_DESC argument as it is
266 used before sim_open. */
267
268 void sim_size PARAMS ((int i));
269
270
271 /* Run a simulation with tracing enabled.
272 THIS PROCEDURE IS DEPRECIATED.
273 GDB and NRUN do not use this interface.
274 This procedure does not take a SIM_DESC argument as it is
275 used before sim_open. */
276
277 int sim_trace PARAMS ((SIM_DESC sd));
278
279
280 /* Configure the size of the profile buffer.
281 THIS PROCEDURE IS DEPRECIATED.
282 GDB and NRUN do not use this interface.
283 This procedure does not take a SIM_DESC argument as it is
284 used before sim_open. */
285
286 void sim_set_profile_size PARAMS ((int n));
287
288
289 /* Kill the running program.
290 THIS PROCEDURE IS DEPRECIATED.
291 GDB and NRUN do not use this interface.
292 This procedure will be replaced as part of the introduction of
293 multi-cpu simulators. */
294
295 void sim_kill PARAMS ((SIM_DESC sd));
296
297 #endif /* !defined (REMOTE_SIM_H) */
This page took 0.045605 seconds and 4 git commands to generate.