Commit | Line | Data |
---|---|---|
05e4e44f AC |
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 | ||
1fa0cc2d | 35 | |
05e4e44f AC |
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 | ||
1fa0cc2d | 42 | |
b0d8c28f | 43 | /* Values for `kind' arg to sim_open. */ |
1fa0cc2d | 44 | |
b0d8c28f DE |
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 | ||
1fa0cc2d | 50 | |
b0d8c28f | 51 | /* Return codes from various functions. */ |
1fa0cc2d | 52 | |
b0d8c28f DE |
53 | typedef enum { |
54 | SIM_RC_FAIL = 0, | |
55 | SIM_RC_OK = 1 | |
56 | } SIM_RC; | |
57 | ||
1fa0cc2d | 58 | |
a1cb1f4b | 59 | /* The bfd struct, as an opaque type. */ |
1fa0cc2d | 60 | |
a1cb1f4b DE |
61 | struct _bfd; |
62 | ||
8517f62b | 63 | |
05e4e44f AC |
64 | /* Main simulator entry points. */ |
65 | ||
8517f62b | 66 | |
247fccde AC |
67 | /* Create a fully initialized simulator instance. |
68 | ||
1fa0cc2d AC |
69 | (This function is called when the simulator is selected from the |
70 | gdb command line.) | |
247fccde | 71 | |
fafce69a AC |
72 | KIND specifies how the simulator shall be used. Currently there |
73 | are only two kinds: stand-alone and debug. | |
247fccde | 74 | |
1fa0cc2d | 75 | CALLBACK specifies a standard host callback (defined in callback.h). |
05e4e44f | 76 | |
247fccde AC |
77 | ABFD, when non NULL, designates a target program. The program is |
78 | not loaded. | |
79 | ||
80 | ARGV is a standard ARGV pointer such as that passed from the | |
81 | command line. The syntax of the argument list is is assumed to be | |
82 | ``SIM-PROG { SIM-OPTION } [ TARGET-PROGRAM { TARGET-OPTION } ]''. | |
fafce69a AC |
83 | The trailing TARGET-PROGRAM and args are only valid for a |
84 | stand-alone simulator. | |
247fccde AC |
85 | |
86 | On success, the result is a non NULL descriptor that shall be | |
87 | passed to the other sim_foo functions. While the simulator | |
88 | configuration can be parameterized by (in decreasing precedence) | |
89 | ARGV's SIM-OPTION, ARGV's TARGET-PROGRAM and the ABFD argument, the | |
90 | successful creation of the simulator shall not dependent on the | |
91 | presence of any of these arguments/options. | |
92 | ||
fafce69a AC |
93 | Hardware simulator: The created simulator shall be sufficiently |
94 | initialized to handle, with out restrictions any client requests | |
95 | (including memory reads/writes, register fetch/stores and a | |
96 | resume). | |
247fccde | 97 | |
fafce69a AC |
98 | Process simulator: that process is not created until a call to |
99 | sim_create_inferior. FIXME: What should the state of the simulator | |
100 | be? */ | |
247fccde AC |
101 | |
102 | SIM_DESC sim_open PARAMS ((SIM_OPEN_KIND kind, struct host_callback_struct *callback, struct _bfd *abfd, char **argv)); | |
05e4e44f | 103 | |
8517f62b | 104 | |
1fa0cc2d | 105 | /* Destory a simulator instance. |
247fccde AC |
106 | |
107 | QUITTING is non-zero if we cannot hang on errors. | |
108 | ||
1fa0cc2d AC |
109 | This may involve freeing target memory and closing any open files |
110 | and mmap'd areas. You cannot assume sim_kill has already been | |
247fccde | 111 | called. */ |
05e4e44f AC |
112 | |
113 | void sim_close PARAMS ((SIM_DESC sd, int quitting)); | |
114 | ||
8517f62b | 115 | |
247fccde AC |
116 | /* Load program PROG into the simulators memory. |
117 | ||
a1cb1f4b | 118 | If ABFD is non-NULL, the bfd for the file has already been opened. |
247fccde AC |
119 | The result is a return code indicating success. |
120 | ||
fafce69a AC |
121 | Hardware simulator: A call to this function should not effect the |
122 | state of the processor registers. Multiple calls to this function | |
123 | are permitted and have an accumulative effect. | |
247fccde | 124 | |
fafce69a AC |
125 | Process simulator: Calls to this function may be ignored. |
126 | ||
127 | FIXME: Some hardware targets, before a loaded program can be | |
128 | executed, require the manipulation of VM registers and tables. | |
129 | Such manipulation should probably (?) occure in | |
130 | sim_create_inferior. */ | |
05e4e44f | 131 | |
a1cb1f4b | 132 | SIM_RC sim_load PARAMS ((SIM_DESC sd, char *prog, struct _bfd *abfd, int from_tty)); |
05e4e44f | 133 | |
8517f62b | 134 | |
05e4e44f | 135 | /* Prepare to run the simulated program. |
247fccde | 136 | |
fafce69a AC |
137 | ABFD, if not NULL, provides initial processor state information. |
138 | ARGV and ENV, if non NULL, are NULL terminated lists of pointers. | |
247fccde | 139 | |
fafce69a AC |
140 | Hardware simulator: This function shall initialize the processor |
141 | registers to a known value. The program counter and possibly stack | |
142 | pointer shall be set using information obtained from ABFD (or | |
143 | hardware reset defaults). ARGV and ENV, dependant on the target | |
144 | ABI, may be written to memory. | |
247fccde | 145 | |
fafce69a AC |
146 | Process simulator: After a call to this function, a new process |
147 | instance shall exist. The TEXT, DATA, BSS and stack regions shall | |
148 | all be initialized, ARGV and ENV shall be written to process | |
149 | address space (according to the applicable ABI) and the program | |
150 | counter and stack pointer set accordingly. */ | |
05e4e44f | 151 | |
fafce69a | 152 | SIM_RC sim_create_inferior PARAMS ((SIM_DESC sd, struct _bfd *abfd, char **argv, char **env)); |
05e4e44f | 153 | |
8517f62b | 154 | |
247fccde AC |
155 | /* Read LENGTH bytes of the simulated program's memory and store in |
156 | BUF. Result is number of bytes read, or zero if error. */ | |
05e4e44f AC |
157 | |
158 | int sim_read PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)); | |
159 | ||
8517f62b | 160 | |
05e4e44f AC |
161 | /* Store LENGTH bytes from BUF in the simulated program's memory. |
162 | Result is number of bytes write, or zero if error. */ | |
163 | ||
164 | int sim_write PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)); | |
165 | ||
8517f62b | 166 | |
247fccde AC |
167 | /* Fetch register REGNO and store the raw (target endian) value in |
168 | BUF. */ | |
05e4e44f AC |
169 | |
170 | void sim_fetch_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf)); | |
171 | ||
8517f62b | 172 | |
1fa0cc2d | 173 | /* Store register REGNO from the raw (target endian) value in BUF. */ |
05e4e44f AC |
174 | |
175 | void sim_store_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf)); | |
176 | ||
8517f62b | 177 | |
a1cb1f4b | 178 | /* Print whatever statistics the simulator has collected. |
247fccde | 179 | |
a1cb1f4b | 180 | VERBOSE is currently unused and must always be zero. */ |
05e4e44f AC |
181 | |
182 | void sim_info PARAMS ((SIM_DESC sd, int verbose)); | |
183 | ||
05e4e44f | 184 | |
1fa0cc2d | 185 | /* Run (or resume) the simulated program. */ |
05e4e44f AC |
186 | |
187 | void sim_resume PARAMS ((SIM_DESC sd, int step, int siggnal)); | |
188 | ||
8517f62b AC |
189 | |
190 | /* Asynchronous request to stop the simulation. | |
191 | A nonzero return indicates that the simulator is able to handle | |
192 | the request */ | |
193 | ||
194 | int sim_stop PARAMS ((SIM_DESC sd)); | |
195 | ||
196 | ||
1fa0cc2d | 197 | /* Fetch the REASON why the program stopped. |
247fccde | 198 | |
1fa0cc2d AC |
199 | SIM_EXITED: The program has terminated. SIGRC indicates the target |
200 | dependant exit status. | |
247fccde | 201 | |
1fa0cc2d AC |
202 | SIM_STOPPED: The program has stopped. SIGRC indicates the reason: |
203 | program interrupted by user via a sim_stop request (SIGINT); a | |
204 | breakpoint instruction (SIGTRAP); a completed step (SIGTRAP); an | |
205 | internal error condition (SIGABRT). | |
247fccde | 206 | |
1fa0cc2d AC |
207 | SIM_SIGNALLED: The simulator encountered target code that requires |
208 | the signal SIGRC to be delivered to the simulated program. | |
247fccde | 209 | |
1fa0cc2d AC |
210 | SIM_RUNNING, SIM_POLLING: The return of one of these values |
211 | indicates a problem internal to the simulator. */ | |
212 | ||
213 | enum sim_stop { sim_running, sim_polling, sim_exited, sim_stopped, sim_signalled }; | |
214 | ||
215 | void sim_stop_reason PARAMS ((SIM_DESC sd, enum sim_stop *reason, int *sigrc)); | |
05e4e44f | 216 | |
8517f62b | 217 | |
1fa0cc2d AC |
218 | /* Passthru for other commands that the simulator might support. |
219 | Simulators should be prepared to deal with any combination of NULL | |
220 | or empty CMD. */ | |
221 | ||
05e4e44f | 222 | void sim_do_command PARAMS ((SIM_DESC sd, char *cmd)); |
247fccde | 223 | \f |
8517f62b | 224 | |
1fa0cc2d | 225 | /* Provide simulator with a default (global) host_callback_struct. |
247fccde | 226 | THIS PROCEDURE IS DEPRECIATED. |
aa02a0b0 | 227 | GDB and NRUN do not use this interface. |
1fa0cc2d AC |
228 | This procedure does not take a SIM_DESC argument as it is |
229 | used before sim_open. */ | |
230 | ||
ff82f214 AC |
231 | void sim_set_callbacks PARAMS ((struct host_callback_struct *)); |
232 | ||
24aa2b57 | 233 | |
1fa0cc2d | 234 | /* Set the size of the simulator memory array. |
247fccde | 235 | THIS PROCEDURE IS DEPRECIATED. |
aa02a0b0 | 236 | GDB and NRUN do not use this interface. |
1fa0cc2d AC |
237 | This procedure does not take a SIM_DESC argument as it is |
238 | used before sim_open. */ | |
239 | ||
ff82f214 | 240 | void sim_size PARAMS ((int i)); |
87e43259 | 241 | |
87e43259 | 242 | |
1fa0cc2d | 243 | /* Run a simulation with tracing enabled. |
247fccde | 244 | THIS PROCEDURE IS DEPRECIATED. |
aa02a0b0 | 245 | GDB and NRUN do not use this interface. |
1fa0cc2d AC |
246 | This procedure does not take a SIM_DESC argument as it is |
247 | used before sim_open. */ | |
248 | ||
87e43259 AC |
249 | int sim_trace PARAMS ((SIM_DESC sd)); |
250 | ||
251 | ||
1fa0cc2d | 252 | /* Configure the size of the profile buffer. |
247fccde | 253 | THIS PROCEDURE IS DEPRECIATED. |
aa02a0b0 | 254 | GDB and NRUN do not use this interface. |
1fa0cc2d AC |
255 | This procedure does not take a SIM_DESC argument as it is |
256 | used before sim_open. */ | |
50a2a691 | 257 | |
1fa0cc2d | 258 | void sim_set_profile_size PARAMS ((int n)); |
50a2a691 | 259 | |
aa02a0b0 AC |
260 | |
261 | /* Kill the running program. | |
247fccde | 262 | THIS PROCEDURE IS DEPRECIATED. |
aa02a0b0 AC |
263 | GDB and NRUN do not use this interface. |
264 | This procedure will be replaced as part of the introduction of | |
265 | multi-cpu simulators. */ | |
266 | ||
267 | void sim_kill PARAMS ((SIM_DESC sd)); | |
268 | ||
05e4e44f | 269 | #endif /* !defined (REMOTE_SIM_H) */ |