* remote-sim.h (SIM_OPEN_KIND, SIM_RC): New enums.
[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 /* 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
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
53 /* Main simulator entry points. */
54
55 /* Initialize the simulator. This function is called when the simulator
56 is selected from the command line. ARGV is passed from the command line
57 and can be used to select whatever run time options the simulator provides.
58 ARGV is the standard NULL terminated array of pointers, with argv[0]
59 being the program name.
60 The result is a descriptor that must be passed back to the other sim_foo
61 functions. */
62
63 SIM_DESC sim_open PARAMS ((SIM_OPEN_KIND kind, char **argv));
64
65 /* Terminate usage of the simulator. This may involve freeing target memory
66 and closing any open files and mmap'd areas. You cannot assume sim_kill
67 has already been called.
68 QUITTING is non-zero if we cannot hang on errors. */
69
70 void sim_close PARAMS ((SIM_DESC sd, int quitting));
71
72 /* Load program PROG into the simulator.
73 Return non-zero if you wish the caller to handle it
74 (it is done this way because most simulators can use gr_load_image,
75 but defining it as a callback seems awkward). */
76
77 int sim_load PARAMS ((SIM_DESC sd, char *prog, int from_tty));
78
79 /* Prepare to run the simulated program.
80 START_ADDRESS is, yes, you guessed it, the start address of the program.
81 ARGV and ENV are NULL terminated lists of pointers.
82 Gdb will set the start address via sim_store_register as well, but
83 standalone versions of existing simulators are not set up to cleanly call
84 sim_store_register, so the START_ADDRESS argument is there as a
85 workaround. */
86
87 void sim_create_inferior PARAMS ((SIM_DESC sd, SIM_ADDR start_address,
88 char **argv, char **env));
89
90 /* Kill the running program.
91 This may involve closing any open files and deleting any mmap'd areas. */
92
93 void sim_kill PARAMS ((SIM_DESC sd));
94
95 /* Read LENGTH bytes of the simulated program's memory and store in BUF.
96 Result is number of bytes read, or zero if error. */
97
98 int sim_read PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length));
99
100 /* Store LENGTH bytes from BUF in the simulated program's memory.
101 Result is number of bytes write, or zero if error. */
102
103 int sim_write PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length));
104
105 /* Fetch register REGNO and store the raw value in BUF. */
106
107 void sim_fetch_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf));
108
109 /* Store register REGNO from BUF (in raw format). */
110
111 void sim_store_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf));
112
113 /* Print some interesting information about the simulator.
114 VERBOSE is non-zero for the wordy version. */
115
116 void sim_info PARAMS ((SIM_DESC sd, int verbose));
117
118 /* Fetch why the program stopped.
119 SIGRC will contain either the argument to exit() or the signal number. */
120
121 enum sim_stop { sim_exited, sim_stopped, sim_signalled };
122
123 void sim_stop_reason PARAMS ((SIM_DESC sd, enum sim_stop *reason, int *sigrc));
124
125 /* Run (or resume) the program. */
126
127 void sim_resume PARAMS ((SIM_DESC sd, int step, int siggnal));
128
129 /* Passthru for other commands that the simulator might support.
130 If SD is NULL, the command is to be interpreted as refering to
131 the global state, however the simulator defines that. */
132
133 void sim_do_command PARAMS ((SIM_DESC sd, char *cmd));
134
135 /* Provide simulator with a standard host_callback_struct.
136 If SD is NULL, the command is to be interpreted as refering to
137 the global state, however the simulator defines that. */
138
139 void sim_set_callbacks PARAMS ((SIM_DESC sd, struct host_callback_struct *));
140
141 #endif /* !defined (REMOTE_SIM_H) */