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 | |
1fa0cc2d AC |
67 | /* Create a simulator instance. |
68 | (This function is called when the simulator is selected from the | |
69 | gdb command line.) | |
38498962 DE |
70 | KIND specifies how the simulator will be used. Currently there are only |
71 | two kinds: standalone and debug. | |
1fa0cc2d | 72 | CALLBACK specifies a standard host callback (defined in callback.h). |
38498962 | 73 | ARGV is passed from the command line and can be used to select whatever |
a1cb1f4b DE |
74 | run time options the simulator provides. It is the standard NULL |
75 | terminated array of pointers, with argv[0] being the program name. | |
1fa0cc2d AC |
76 | The result is a descriptor that shall be passed to the other |
77 | sim_foo functions. */ | |
05e4e44f | 78 | |
24aa2b57 | 79 | SIM_DESC sim_open PARAMS ((SIM_OPEN_KIND kind, struct host_callback_struct *callback, char **argv)); |
05e4e44f | 80 | |
8517f62b | 81 | |
1fa0cc2d AC |
82 | /* Destory a simulator instance. |
83 | This may involve freeing target memory and closing any open files | |
84 | and mmap'd areas. You cannot assume sim_kill has already been | |
85 | called. | |
05e4e44f AC |
86 | QUITTING is non-zero if we cannot hang on errors. */ |
87 | ||
88 | void sim_close PARAMS ((SIM_DESC sd, int quitting)); | |
89 | ||
8517f62b | 90 | |
05e4e44f | 91 | /* Load program PROG into the simulator. |
a1cb1f4b DE |
92 | If ABFD is non-NULL, the bfd for the file has already been opened. |
93 | The result is a return code indicating success. */ | |
05e4e44f | 94 | |
a1cb1f4b | 95 | SIM_RC sim_load PARAMS ((SIM_DESC sd, char *prog, struct _bfd *abfd, int from_tty)); |
05e4e44f | 96 | |
8517f62b | 97 | |
05e4e44f | 98 | /* Prepare to run the simulated program. |
a1cb1f4b | 99 | ARGV and ENV are NULL terminated lists of pointers. */ |
05e4e44f | 100 | |
a1cb1f4b | 101 | SIM_RC sim_create_inferior PARAMS ((SIM_DESC sd, char **argv, char **env)); |
05e4e44f | 102 | |
8517f62b | 103 | |
05e4e44f AC |
104 | /* Read LENGTH bytes of the simulated program's memory and store in BUF. |
105 | Result is number of bytes read, or zero if error. */ | |
106 | ||
107 | int sim_read PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)); | |
108 | ||
8517f62b | 109 | |
05e4e44f AC |
110 | /* Store LENGTH bytes from BUF in the simulated program's memory. |
111 | Result is number of bytes write, or zero if error. */ | |
112 | ||
113 | int sim_write PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)); | |
114 | ||
8517f62b | 115 | |
1fa0cc2d | 116 | /* Fetch register REGNO and store the raw (target endian) value in BUF. */ |
05e4e44f AC |
117 | |
118 | void sim_fetch_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf)); | |
119 | ||
8517f62b | 120 | |
1fa0cc2d | 121 | /* Store register REGNO from the raw (target endian) value in BUF. */ |
05e4e44f AC |
122 | |
123 | void sim_store_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf)); | |
124 | ||
8517f62b | 125 | |
a1cb1f4b DE |
126 | /* Print whatever statistics the simulator has collected. |
127 | VERBOSE is currently unused and must always be zero. */ | |
05e4e44f AC |
128 | |
129 | void sim_info PARAMS ((SIM_DESC sd, int verbose)); | |
130 | ||
05e4e44f | 131 | |
1fa0cc2d | 132 | /* Run (or resume) the simulated program. */ |
05e4e44f AC |
133 | |
134 | void sim_resume PARAMS ((SIM_DESC sd, int step, int siggnal)); | |
135 | ||
8517f62b AC |
136 | |
137 | /* Asynchronous request to stop the simulation. | |
138 | A nonzero return indicates that the simulator is able to handle | |
139 | the request */ | |
140 | ||
141 | int sim_stop PARAMS ((SIM_DESC sd)); | |
142 | ||
143 | ||
1fa0cc2d AC |
144 | /* Fetch the REASON why the program stopped. |
145 | SIM_EXITED: The program has terminated. SIGRC indicates the target | |
146 | dependant exit status. | |
147 | SIM_STOPPED: The program has stopped. SIGRC indicates the reason: | |
148 | program interrupted by user via a sim_stop request (SIGINT); a | |
149 | breakpoint instruction (SIGTRAP); a completed step (SIGTRAP); an | |
150 | internal error condition (SIGABRT). | |
151 | SIM_SIGNALLED: The simulator encountered target code that requires | |
152 | the signal SIGRC to be delivered to the simulated program. | |
153 | SIM_RUNNING, SIM_POLLING: The return of one of these values | |
154 | indicates a problem internal to the simulator. */ | |
155 | ||
156 | enum sim_stop { sim_running, sim_polling, sim_exited, sim_stopped, sim_signalled }; | |
157 | ||
158 | void sim_stop_reason PARAMS ((SIM_DESC sd, enum sim_stop *reason, int *sigrc)); | |
05e4e44f | 159 | |
8517f62b | 160 | |
1fa0cc2d AC |
161 | /* Passthru for other commands that the simulator might support. |
162 | Simulators should be prepared to deal with any combination of NULL | |
163 | or empty CMD. */ | |
164 | ||
05e4e44f AC |
165 | void sim_do_command PARAMS ((SIM_DESC sd, char *cmd)); |
166 | ||
8517f62b | 167 | |
1fa0cc2d AC |
168 | /* Provide simulator with a default (global) host_callback_struct. |
169 | THIS PROCEDURE IS IS DEPRECIATED. | |
aa02a0b0 | 170 | GDB and NRUN do not use this interface. |
1fa0cc2d AC |
171 | This procedure does not take a SIM_DESC argument as it is |
172 | used before sim_open. */ | |
173 | ||
ff82f214 AC |
174 | void sim_set_callbacks PARAMS ((struct host_callback_struct *)); |
175 | ||
24aa2b57 | 176 | |
1fa0cc2d AC |
177 | /* Set the size of the simulator memory array. |
178 | THIS PROCEDURE IS IS DEPRECIATED. | |
aa02a0b0 | 179 | GDB and NRUN do not use this interface. |
1fa0cc2d AC |
180 | This procedure does not take a SIM_DESC argument as it is |
181 | used before sim_open. */ | |
182 | ||
ff82f214 | 183 | void sim_size PARAMS ((int i)); |
87e43259 | 184 | |
87e43259 | 185 | |
1fa0cc2d AC |
186 | /* Run a simulation with tracing enabled. |
187 | THIS PROCEDURE IS IS DEPRECIATED. | |
aa02a0b0 | 188 | GDB and NRUN do not use this interface. |
1fa0cc2d AC |
189 | This procedure does not take a SIM_DESC argument as it is |
190 | used before sim_open. */ | |
191 | ||
87e43259 AC |
192 | int sim_trace PARAMS ((SIM_DESC sd)); |
193 | ||
194 | ||
1fa0cc2d AC |
195 | /* Configure the size of the profile buffer. |
196 | THIS PROCEDURE IS IS DEPRECIATED. | |
aa02a0b0 | 197 | GDB and NRUN do not use this interface. |
1fa0cc2d AC |
198 | This procedure does not take a SIM_DESC argument as it is |
199 | used before sim_open. */ | |
50a2a691 | 200 | |
1fa0cc2d | 201 | void sim_set_profile_size PARAMS ((int n)); |
50a2a691 | 202 | |
aa02a0b0 AC |
203 | |
204 | /* Kill the running program. | |
205 | THIS PROCEDURE IS IS DEPRECIATED. | |
206 | GDB and NRUN do not use this interface. | |
207 | This procedure will be replaced as part of the introduction of | |
208 | multi-cpu simulators. */ | |
209 | ||
210 | void sim_kill PARAMS ((SIM_DESC sd)); | |
211 | ||
212 | ||
05e4e44f | 213 | #endif /* !defined (REMOTE_SIM_H) */ |