1 /* This file defines the interface between the simulator and gdb.
2 Copyright (C) 1993, 1994, 1996, 1997 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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. */
20 #if !defined (REMOTE_SIM_H)
21 #define REMOTE_SIM_H 1
23 /* This file is used when building stand-alone simulators, so isolate this
26 /* Pick up CORE_ADDR_TYPE if defined (from gdb), otherwise use same value as
27 gdb does (unsigned int - from defs.h). */
29 #ifndef CORE_ADDR_TYPE
30 typedef unsigned int SIM_ADDR
;
32 typedef CORE_ADDR_TYPE SIM_ADDR
;
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'. */
39 typedef struct sim_state
*SIM_DESC
;
41 /* Values for `kind' arg to sim_open. */
43 SIM_OPEN_STANDALONE
, /* simulator used standalone (run.c) */
44 SIM_OPEN_DEBUG
/* simulator used by debugger (gdb) */
47 /* Return codes from various functions. */
53 /* The bfd struct, as an opaque type. */
56 /* Main simulator entry points. */
58 /* Initialize the simulator. This function is called when the simulator
59 is selected from the gdb command line.
60 KIND specifies how the simulator will be used. Currently there are only
61 two kinds: standalone and debug.
62 ARGV is passed from the command line and can be used to select whatever
63 run time options the simulator provides. It is the standard NULL
64 terminated array of pointers, with argv[0] being the program name.
65 The result is a descriptor that must be passed back to the other sim_foo
68 SIM_DESC sim_open
PARAMS ((SIM_OPEN_KIND kind
, char **argv
));
70 /* Terminate usage of the simulator. This may involve freeing target memory
71 and closing any open files and mmap'd areas. You cannot assume sim_kill
72 has already been called.
73 QUITTING is non-zero if we cannot hang on errors. */
75 void sim_close
PARAMS ((SIM_DESC sd
, int quitting
));
77 /* Load program PROG into the simulator.
78 If ABFD is non-NULL, the bfd for the file has already been opened.
79 The result is a return code indicating success. */
81 SIM_RC sim_load
PARAMS ((SIM_DESC sd
, char *prog
, struct _bfd
*abfd
, int from_tty
));
83 /* Prepare to run the simulated program.
84 ARGV and ENV are NULL terminated lists of pointers. */
86 SIM_RC sim_create_inferior
PARAMS ((SIM_DESC sd
, char **argv
, char **env
));
88 /* Kill the running program.
89 This may involve closing any open files and deleting any mmap'd areas. */
91 void sim_kill
PARAMS ((SIM_DESC sd
));
93 /* Read LENGTH bytes of the simulated program's memory and store in BUF.
94 Result is number of bytes read, or zero if error. */
96 int sim_read
PARAMS ((SIM_DESC sd
, SIM_ADDR mem
, unsigned char *buf
, int length
));
98 /* Store LENGTH bytes from BUF in the simulated program's memory.
99 Result is number of bytes write, or zero if error. */
101 int sim_write
PARAMS ((SIM_DESC sd
, SIM_ADDR mem
, unsigned char *buf
, int length
));
103 /* Fetch register REGNO and store the raw value in BUF. */
105 void sim_fetch_register
PARAMS ((SIM_DESC sd
, int regno
, unsigned char *buf
));
107 /* Store register REGNO from BUF (in raw format). */
109 void sim_store_register
PARAMS ((SIM_DESC sd
, int regno
, unsigned char *buf
));
111 /* Print whatever statistics the simulator has collected.
112 VERBOSE is currently unused and must always be zero. */
114 void sim_info
PARAMS ((SIM_DESC sd
, int verbose
));
116 /* Fetch why the program stopped.
117 SIGRC will contain either the argument to exit() or the signal number. */
119 enum sim_stop
{ sim_exited
, sim_stopped
, sim_signalled
};
121 void sim_stop_reason
PARAMS ((SIM_DESC sd
, enum sim_stop
*reason
, int *sigrc
));
123 /* Run (or resume) the program. */
125 void sim_resume
PARAMS ((SIM_DESC sd
, int step
, int siggnal
));
127 /* Passthru for other commands that the simulator might support.
128 If SD is NULL, the command is to be interpreted as refering to
129 the global state, however the simulator defines that. */
131 void sim_do_command
PARAMS ((SIM_DESC sd
, char *cmd
));
133 /* Provide simulator with a standard host_callback_struct.
134 If SD is NULL, the command is to be interpreted as refering to
135 the global state, however the simulator defines that. */
137 void sim_set_callbacks
PARAMS ((SIM_DESC sd
, struct host_callback_struct
*));
140 /* NOTE: sim_size() and sim_trace() are going away */
142 void sim_size
PARAMS ((int i
));
144 int sim_trace
PARAMS ((SIM_DESC sd
));
147 #endif /* !defined (REMOTE_SIM_H) */