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 | ||
35 | /* Semi-opaque type used as result of sim_open and passed back to all | |
36 | other routines. "desc" is short for "descriptor". | |
37 | It is up to each simulator to define `sim_state'. */ | |
38 | ||
39 | typedef struct sim_state *SIM_DESC; | |
40 | ||
b0d8c28f DE |
41 | /* Values for `kind' arg to sim_open. */ |
42 | typedef enum { | |
43 | SIM_OPEN_STANDALONE, /* simulator used standalone (run.c) */ | |
44 | SIM_OPEN_DEBUG /* simulator used by debugger (gdb) */ | |
45 | } SIM_OPEN_KIND; | |
46 | ||
47 | /* Return codes from various functions. */ | |
48 | typedef enum { | |
49 | SIM_RC_FAIL = 0, | |
50 | SIM_RC_OK = 1 | |
51 | } SIM_RC; | |
52 | ||
a1cb1f4b DE |
53 | /* The bfd struct, as an opaque type. */ |
54 | struct _bfd; | |
55 | ||
8517f62b | 56 | |
05e4e44f AC |
57 | /* Main simulator entry points. */ |
58 | ||
8517f62b | 59 | |
05e4e44f | 60 | /* Initialize the simulator. This function is called when the simulator |
38498962 DE |
61 | is selected from the gdb command line. |
62 | KIND specifies how the simulator will be used. Currently there are only | |
63 | two kinds: standalone and debug. | |
64 | ARGV is passed from the command line and can be used to select whatever | |
a1cb1f4b DE |
65 | run time options the simulator provides. It is the standard NULL |
66 | terminated array of pointers, with argv[0] being the program name. | |
05e4e44f AC |
67 | The result is a descriptor that must be passed back to the other sim_foo |
68 | functions. */ | |
69 | ||
b0d8c28f | 70 | SIM_DESC sim_open PARAMS ((SIM_OPEN_KIND kind, char **argv)); |
05e4e44f | 71 | |
8517f62b | 72 | |
05e4e44f AC |
73 | /* Terminate usage of the simulator. This may involve freeing target memory |
74 | and closing any open files and mmap'd areas. You cannot assume sim_kill | |
75 | has already been called. | |
76 | QUITTING is non-zero if we cannot hang on errors. */ | |
77 | ||
78 | void sim_close PARAMS ((SIM_DESC sd, int quitting)); | |
79 | ||
8517f62b | 80 | |
05e4e44f | 81 | /* Load program PROG into the simulator. |
a1cb1f4b DE |
82 | If ABFD is non-NULL, the bfd for the file has already been opened. |
83 | The result is a return code indicating success. */ | |
05e4e44f | 84 | |
a1cb1f4b | 85 | SIM_RC sim_load PARAMS ((SIM_DESC sd, char *prog, struct _bfd *abfd, int from_tty)); |
05e4e44f | 86 | |
8517f62b | 87 | |
05e4e44f | 88 | /* Prepare to run the simulated program. |
a1cb1f4b | 89 | ARGV and ENV are NULL terminated lists of pointers. */ |
05e4e44f | 90 | |
a1cb1f4b | 91 | SIM_RC sim_create_inferior PARAMS ((SIM_DESC sd, char **argv, char **env)); |
05e4e44f | 92 | |
8517f62b | 93 | |
05e4e44f AC |
94 | /* Kill the running program. |
95 | This may involve closing any open files and deleting any mmap'd areas. */ | |
96 | ||
97 | void sim_kill PARAMS ((SIM_DESC sd)); | |
98 | ||
8517f62b | 99 | |
05e4e44f AC |
100 | /* Read LENGTH bytes of the simulated program's memory and store in BUF. |
101 | Result is number of bytes read, or zero if error. */ | |
102 | ||
103 | int sim_read PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)); | |
104 | ||
8517f62b | 105 | |
05e4e44f AC |
106 | /* Store LENGTH bytes from BUF in the simulated program's memory. |
107 | Result is number of bytes write, or zero if error. */ | |
108 | ||
109 | int sim_write PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)); | |
110 | ||
8517f62b | 111 | |
05e4e44f AC |
112 | /* Fetch register REGNO and store the raw value in BUF. */ |
113 | ||
114 | void sim_fetch_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf)); | |
115 | ||
8517f62b | 116 | |
05e4e44f AC |
117 | /* Store register REGNO from BUF (in raw format). */ |
118 | ||
119 | void sim_store_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf)); | |
120 | ||
8517f62b | 121 | |
a1cb1f4b DE |
122 | /* Print whatever statistics the simulator has collected. |
123 | VERBOSE is currently unused and must always be zero. */ | |
05e4e44f AC |
124 | |
125 | void sim_info PARAMS ((SIM_DESC sd, int verbose)); | |
126 | ||
05e4e44f | 127 | |
8517f62b AC |
128 | /* Fetch the reason why the program stopped. |
129 | SIM_EXITED: The program has terminated. SIGRC indicates the target | |
130 | dependant exit status. | |
131 | SIM_STOPPED: Any of a breakpoint (SIGTRAP), a completed step | |
132 | (SIGTRAP), a sim_stop request (SIGINT), or an internal error | |
133 | condition (SIGABRT) was encountered. | |
134 | SIM_SIGNALLED: The simulator encountered target code that requires | |
135 | the signal SIGRC to be delivered to the simulated program. | |
136 | SIM_RUNNING, SIM_POLLING: The return of one of these values | |
137 | indicates a problem internal to the simulator. */ | |
138 | ||
139 | enum sim_stop { sim_running, sim_polling, sim_exited, sim_stopped, sim_signalled }; | |
05e4e44f AC |
140 | |
141 | void sim_stop_reason PARAMS ((SIM_DESC sd, enum sim_stop *reason, int *sigrc)); | |
142 | ||
8517f62b | 143 | |
05e4e44f AC |
144 | /* Run (or resume) the program. */ |
145 | ||
146 | void sim_resume PARAMS ((SIM_DESC sd, int step, int siggnal)); | |
147 | ||
8517f62b AC |
148 | |
149 | /* Asynchronous request to stop the simulation. | |
150 | A nonzero return indicates that the simulator is able to handle | |
151 | the request */ | |
152 | ||
153 | int sim_stop PARAMS ((SIM_DESC sd)); | |
154 | ||
155 | ||
05e4e44f AC |
156 | /* Passthru for other commands that the simulator might support. |
157 | If SD is NULL, the command is to be interpreted as refering to | |
158 | the global state, however the simulator defines that. */ | |
159 | ||
8517f62b | 160 | |
05e4e44f AC |
161 | void sim_do_command PARAMS ((SIM_DESC sd, char *cmd)); |
162 | ||
8517f62b | 163 | |
05e4e44f AC |
164 | /* Provide simulator with a standard host_callback_struct. |
165 | If SD is NULL, the command is to be interpreted as refering to | |
166 | the global state, however the simulator defines that. */ | |
167 | ||
168 | void sim_set_callbacks PARAMS ((SIM_DESC sd, struct host_callback_struct *)); | |
169 | ||
87e43259 AC |
170 | |
171 | /* NOTE: sim_size() and sim_trace() are going away */ | |
172 | ||
2e61a3ad | 173 | void sim_size PARAMS ((SIM_DESC sd, int i)); |
87e43259 AC |
174 | |
175 | int sim_trace PARAMS ((SIM_DESC sd)); | |
176 | ||
177 | ||
05e4e44f | 178 | #endif /* !defined (REMOTE_SIM_H) */ |