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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [binutils-2.18.50/] [include/] [gdb/] [remote-sim.h] - Blame information for rev 816

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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