1 |
147 |
jeremybenn |
/* GDB Simulator wrapper for Or1ksim, the OpenRISC architectural simulator
|
2 |
|
|
|
3 |
|
|
Copyright 1988-2008, Free Software Foundation, Inc.
|
4 |
|
|
Copyright (C) 2010 Embecosm Limited
|
5 |
|
|
|
6 |
|
|
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
7 |
|
|
|
8 |
|
|
This file is part of GDB.
|
9 |
|
|
|
10 |
|
|
This program is free software; you can redistribute it and/or modify it
|
11 |
|
|
under the terms of the GNU General Public License as published by the Free
|
12 |
|
|
Software Foundation; either version 3 of the License, or (at your option)
|
13 |
|
|
any later version.
|
14 |
|
|
|
15 |
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
16 |
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
17 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
18 |
|
|
more details.
|
19 |
|
|
|
20 |
|
|
You should have received a copy of the GNU General Public License along
|
21 |
|
|
with this program. If not, see <http://www.gnu.org/licenses/>. */
|
22 |
|
|
|
23 |
|
|
/*---------------------------------------------------------------------------*/
|
24 |
|
|
/* This is a wrapper for Or1ksim, suitable for use as a GDB simulator.
|
25 |
|
|
|
26 |
|
|
The code tries to follow the GDB coding style.
|
27 |
|
|
|
28 |
|
|
Commenting is Doxygen compatible. */
|
29 |
|
|
/*---------------------------------------------------------------------------*/
|
30 |
|
|
|
31 |
|
|
#include <errno.h>
|
32 |
|
|
#include <stdlib.h>
|
33 |
|
|
#include <stdio.h>
|
34 |
|
|
#include <signal.h>
|
35 |
|
|
#include <sys/socket.h>
|
36 |
|
|
#include <sys/types.h>
|
37 |
|
|
#include <sys/un.h>
|
38 |
|
|
#include <unistd.h>
|
39 |
|
|
|
40 |
|
|
#include "ansidecl.h"
|
41 |
|
|
#include "gdb/callback.h"
|
42 |
|
|
#include "gdb/remote-sim.h"
|
43 |
|
|
#include "sim-utils.h"
|
44 |
|
|
#include "targ-vals.h"
|
45 |
|
|
|
46 |
|
|
#include "or1ksim.h"
|
47 |
|
|
#include "or32sim.h"
|
48 |
|
|
|
49 |
|
|
/*!A global record of the simulator description */
|
50 |
|
|
static SIM_DESC global_sd = NULL;
|
51 |
|
|
|
52 |
|
|
/*!The last reason we stopped */
|
53 |
|
|
enum sim_stop last_reason = sim_running;
|
54 |
|
|
|
55 |
|
|
/*!The last return code from a resume/step call */
|
56 |
|
|
static unsigned long int last_rc = 0;
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
/* ------------------------------------------------------------------------- */
|
60 |
|
|
/*!Create a fully initialized simulator instance.
|
61 |
|
|
|
62 |
|
|
This function is called when the simulator is selected from the gdb command
|
63 |
|
|
line.
|
64 |
|
|
|
65 |
|
|
While the simulator configuration can be parameterized by (in decreasing
|
66 |
|
|
precedence) argv's SIM-OPTION, argv's TARGET-PROGRAM and the abfd argument,
|
67 |
|
|
the successful creation of the simulator shall not dependent on the
|
68 |
|
|
presence of any of these arguments/options.
|
69 |
|
|
|
70 |
|
|
For a hardware simulator the created simulator shall be sufficiently
|
71 |
|
|
initialized to handle, without restrictions any client requests (including
|
72 |
|
|
memory reads/writes, register fetch/stores and a resume).
|
73 |
|
|
|
74 |
|
|
For a process simulator, the process is not created until a call to
|
75 |
|
|
sim_create_inferior.
|
76 |
|
|
|
77 |
|
|
This function creates a socket pair, which will be used to communicate to
|
78 |
|
|
and from the process model, then forks off a process to run the SystemC
|
79 |
|
|
model. Communication is via RSP packets across the socket pair, but with
|
80 |
|
|
simplified hand-shaking.
|
81 |
|
|
|
82 |
|
|
@note We seem to capable of being called twice. We use the static
|
83 |
|
|
"global_sd" variable to keep track of this. Second and subsequent
|
84 |
|
|
calls do nothing, but return the previously opened simulator
|
85 |
|
|
description.
|
86 |
|
|
|
87 |
|
|
@param[in] kind Specifies how the simulator shall be used. Currently
|
88 |
|
|
there are only two kinds: stand-alone and debug.
|
89 |
|
|
|
90 |
|
|
@param[in] callback Specifies a standard host callback (defined in
|
91 |
|
|
callback.h).
|
92 |
|
|
|
93 |
|
|
@param[in] abfd When non NULL, designates a target program. The
|
94 |
|
|
program is not loaded.
|
95 |
|
|
|
96 |
|
|
@param[in] argv A standard ARGV pointer such as that passed from the
|
97 |
|
|
command line. The syntax of the argument list is is
|
98 |
|
|
assumed to be ``SIM-PROG { SIM-OPTION } [
|
99 |
|
|
TARGET-PROGRAM { TARGET-OPTION } ]''.
|
100 |
|
|
|
101 |
|
|
The trailing TARGET-PROGRAM and args are only valid
|
102 |
|
|
for a stand-alone simulator.
|
103 |
|
|
|
104 |
|
|
The argument list is null terminated!
|
105 |
|
|
|
106 |
|
|
@return On success, the result is a non NULL descriptor that shall be
|
107 |
|
|
passed to the other sim_foo functions. */
|
108 |
|
|
/* ------------------------------------------------------------------------- */
|
109 |
|
|
SIM_DESC
|
110 |
|
|
sim_open (SIM_OPEN_KIND kind,
|
111 |
|
|
struct host_callback_struct *callback,
|
112 |
|
|
struct bfd *abfd,
|
113 |
|
|
char *argv[])
|
114 |
|
|
{
|
115 |
|
|
int argc;
|
116 |
|
|
char *config_file;
|
117 |
|
|
char *image_file;
|
118 |
|
|
|
119 |
|
|
/* If the global_sd is currently set, we just return it. */
|
120 |
|
|
if (NULL != global_sd)
|
121 |
|
|
{
|
122 |
|
|
return global_sd;
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
/* Eventually we should use the option parser built into the GDB simulator
|
126 |
|
|
(see common/sim-options.h). However since this is minimally documented,
|
127 |
|
|
and we have only the one option, for now we do it ourselves. */
|
128 |
|
|
|
129 |
|
|
/* Count the number of arguments */
|
130 |
|
|
for (argc = 0; NULL != argv[argc]; argc++)
|
131 |
|
|
{
|
132 |
216 |
jeremybenn |
/* printf ("argv[%d] = %s\n", argc, argv[argc]); */
|
133 |
147 |
jeremybenn |
}
|
134 |
|
|
|
135 |
|
|
/* Configuration file may be passed using the -f <filename> */
|
136 |
|
|
if ((argc > 2) && (0 == strcmp (argv[1], "-f")))
|
137 |
|
|
{
|
138 |
|
|
config_file = argv[2];
|
139 |
|
|
image_file = argc > 3 ? argv[3] : NULL;
|
140 |
|
|
}
|
141 |
|
|
else
|
142 |
|
|
{
|
143 |
|
|
config_file = NULL;
|
144 |
|
|
image_file = argc > 1 ? argv[1] : NULL;
|
145 |
|
|
}
|
146 |
|
|
|
147 |
|
|
/* Initialize the simulator. No class image nor upcalls */
|
148 |
|
|
if (0 == or1ksim_init (config_file, image_file, NULL, NULL, NULL))
|
149 |
|
|
{
|
150 |
|
|
global_sd = (SIM_DESC) malloc (sizeof (*global_sd));
|
151 |
|
|
|
152 |
|
|
global_sd->callback = callback;
|
153 |
|
|
global_sd->is_debug = (kind == SIM_OPEN_DEBUG);
|
154 |
|
|
global_sd->myname = (char *)xstrdup (argv[0]);
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
return global_sd;
|
158 |
|
|
|
159 |
|
|
} /* sim_open () */
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
/* ------------------------------------------------------------------------- */
|
163 |
|
|
/*!Destroy a simulator instance.
|
164 |
|
|
|
165 |
|
|
This may involve freeing target memory and closing any open files and
|
166 |
|
|
mmap'd areas.
|
167 |
|
|
|
168 |
|
|
We cannot assume sim_kill () has already been called.
|
169 |
|
|
|
170 |
|
|
@param[in] sd Simulation descriptor from sim_open ().
|
171 |
|
|
@param[in] quitting Non-zero if we cannot hang on errors. */
|
172 |
|
|
/* ------------------------------------------------------------------------- */
|
173 |
|
|
void
|
174 |
|
|
sim_close (SIM_DESC sd,
|
175 |
|
|
int quitting)
|
176 |
|
|
{
|
177 |
|
|
if (NULL != sd)
|
178 |
|
|
{
|
179 |
|
|
free (sd->myname);
|
180 |
|
|
free (sd);
|
181 |
|
|
}
|
182 |
|
|
} /* sim_close () */
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
/* ------------------------------------------------------------------------- */
|
186 |
|
|
/*!Load program PROG into the simulators memory.
|
187 |
|
|
|
188 |
|
|
Hardware simulator: Normally, each program section is written into
|
189 |
|
|
memory according to that sections LMA using physical (direct)
|
190 |
|
|
addressing. The exception being systems, such as PPC/CHRP, which
|
191 |
|
|
support more complicated program loaders. A call to this function
|
192 |
|
|
should not effect the state of the processor registers. Multiple
|
193 |
|
|
calls to this function are permitted and have an accumulative
|
194 |
|
|
effect.
|
195 |
|
|
|
196 |
|
|
Process simulator: Calls to this function may be ignored.
|
197 |
|
|
|
198 |
|
|
@todo Most hardware simulators load the image at the VMA using
|
199 |
|
|
virtual addressing.
|
200 |
|
|
|
201 |
|
|
@todo For some hardware targets, before a loaded program can be executed,
|
202 |
|
|
it requires the manipulation of VM registers and tables. Such
|
203 |
|
|
manipulation should probably (?) occure in sim_create_inferior ().
|
204 |
|
|
|
205 |
|
|
@param[in] sd Simulation descriptor from sim_open ().
|
206 |
|
|
@param[in] prog The name of the program
|
207 |
|
|
@param[in] abfd If non-NULL, the BFD for the file has already been
|
208 |
|
|
opened.
|
209 |
|
|
@param[in] from_tty Not sure what this does. Probably indicates this is a
|
210 |
|
|
command line load? Anyway we don't use it.
|
211 |
|
|
|
212 |
|
|
@return A return code indicating success. */
|
213 |
|
|
/* ------------------------------------------------------------------------- */
|
214 |
|
|
SIM_RC
|
215 |
|
|
sim_load (SIM_DESC sd,
|
216 |
|
|
char *prog,
|
217 |
|
|
struct bfd *abfd,
|
218 |
|
|
int from_tty)
|
219 |
|
|
{
|
220 |
|
|
bfd *prog_bfd;
|
221 |
|
|
|
222 |
|
|
/* Use the built in loader, which will in turn use our write function. */
|
223 |
|
|
prog_bfd = sim_load_file (sd, sd->myname, sd->callback, prog, abfd,
|
224 |
|
|
sd->is_debug, 0, sim_write);
|
225 |
|
|
|
226 |
|
|
if (NULL == prog_bfd)
|
227 |
|
|
{
|
228 |
|
|
return SIM_RC_FAIL;
|
229 |
|
|
}
|
230 |
|
|
|
231 |
|
|
/* If the BFD was not already open, then close the loaded program. */
|
232 |
|
|
if (NULL == abfd)
|
233 |
|
|
{
|
234 |
|
|
bfd_close (prog_bfd);
|
235 |
|
|
}
|
236 |
|
|
|
237 |
|
|
return SIM_RC_OK;
|
238 |
|
|
|
239 |
|
|
} /* sim_load () */
|
240 |
|
|
|
241 |
|
|
|
242 |
|
|
/* ------------------------------------------------------------------------- */
|
243 |
|
|
/*!Prepare to run the simulated program.
|
244 |
|
|
|
245 |
|
|
Hardware simulator: This function shall initialize the processor
|
246 |
|
|
registers to a known value. The program counter and possibly stack
|
247 |
|
|
pointer shall be set using information obtained from ABFD (or
|
248 |
|
|
hardware reset defaults). ARGV and ENV, dependant on the target
|
249 |
|
|
ABI, may be written to memory.
|
250 |
|
|
|
251 |
|
|
Process simulator: After a call to this function, a new process
|
252 |
|
|
instance shall exist. The TEXT, DATA, BSS and stack regions shall
|
253 |
|
|
all be initialized, ARGV and ENV shall be written to process
|
254 |
|
|
address space (according to the applicable ABI) and the program
|
255 |
|
|
counter and stack pointer set accordingly.
|
256 |
|
|
|
257 |
|
|
ABFD, if not NULL, provides initial processor state information.
|
258 |
|
|
ARGV and ENV, if non NULL, are NULL terminated lists of pointers.
|
259 |
|
|
|
260 |
|
|
@param[in] sd Simulation descriptor from sim_open ().
|
261 |
|
|
@param[in] abfd If non-NULL provides initial processor state information.
|
262 |
|
|
@param[in] argv Vector of arguments to the program. We don't use this
|
263 |
|
|
@param[in] env Vector of environment data. We don't use this.
|
264 |
|
|
|
265 |
|
|
@return A return code indicating success. */
|
266 |
|
|
/* ------------------------------------------------------------------------- */
|
267 |
|
|
SIM_RC
|
268 |
|
|
sim_create_inferior (SIM_DESC sd,
|
269 |
|
|
struct bfd *abfd,
|
270 |
|
|
char **argv ATTRIBUTE_UNUSED,
|
271 |
|
|
char **env ATTRIBUTE_UNUSED)
|
272 |
|
|
{
|
273 |
|
|
/* We set the starting PC if we have that data */
|
274 |
|
|
unsigned long int pc = (NULL == abfd) ? 0 : bfd_get_start_address (abfd);
|
275 |
|
|
unsigned char *pc_ptr = (unsigned char *)(&pc);
|
276 |
|
|
|
277 |
|
|
sim_store_register (sd, OR32_NPC_REGNUM, pc_ptr, sizeof (pc));
|
278 |
|
|
return SIM_RC_OK;
|
279 |
|
|
|
280 |
|
|
} /* sim_create_inferior () */
|
281 |
|
|
|
282 |
|
|
|
283 |
|
|
/* ------------------------------------------------------------------------- */
|
284 |
|
|
/*!Fetch bytes from the simulated program's memory.
|
285 |
|
|
|
286 |
|
|
@param[in] sd Simulation descriptor from sim_open (). We don't use
|
287 |
|
|
this.
|
288 |
|
|
@param[in] mem The address in memory to fetch from.
|
289 |
|
|
@param[out] buf Where to put the read data
|
290 |
|
|
@param[in] len Number of bytes to fetch
|
291 |
|
|
|
292 |
|
|
@return Number of bytes read, or zero if error. */
|
293 |
|
|
/* ------------------------------------------------------------------------- */
|
294 |
|
|
int
|
295 |
|
|
sim_read (SIM_DESC sd ATTRIBUTE_UNUSED,
|
296 |
|
|
SIM_ADDR mem,
|
297 |
|
|
unsigned char *buf,
|
298 |
|
|
int len)
|
299 |
|
|
{
|
300 |
|
|
return or1ksim_read_mem (buf, (unsigned int) mem, len);
|
301 |
|
|
|
302 |
|
|
} /* sim_read () */
|
303 |
|
|
|
304 |
|
|
|
305 |
|
|
/* ------------------------------------------------------------------------- */
|
306 |
|
|
/*!Store bytes to the simulated program's memory.
|
307 |
|
|
|
308 |
|
|
@param[in] sd Simulation descriptor from sim_open (). We don't use
|
309 |
|
|
this.
|
310 |
|
|
@param[in] mem The address in memory to write to.
|
311 |
|
|
@param[in] buf The data to write
|
312 |
|
|
@param[in] len Number of bytes to write
|
313 |
|
|
|
314 |
|
|
@return Number of byte written, or zero if error. */
|
315 |
|
|
/* ------------------------------------------------------------------------- */
|
316 |
|
|
int
|
317 |
|
|
sim_write (SIM_DESC sd ATTRIBUTE_UNUSED,
|
318 |
|
|
SIM_ADDR mem,
|
319 |
|
|
unsigned char *buf,
|
320 |
|
|
int len)
|
321 |
|
|
{
|
322 |
|
|
return or1ksim_write_mem (buf, (unsigned int) mem, len);
|
323 |
|
|
|
324 |
|
|
} /* sim_write () */
|
325 |
|
|
|
326 |
|
|
|
327 |
|
|
/* ------------------------------------------------------------------------- */
|
328 |
|
|
/*!Fetch a register from the simulation
|
329 |
|
|
|
330 |
|
|
@param[in] sd Simulation descriptor from sim_open (). We don't use
|
331 |
|
|
this.
|
332 |
|
|
@param[in] regno The register to fetch
|
333 |
|
|
@param[out] buf Buffer of length bytes to store the result. Data is
|
334 |
|
|
only transferred if length matches the register length
|
335 |
|
|
(the actual register size is still returned).
|
336 |
|
|
@param[in] len Size of buf, which should match the size of the
|
337 |
|
|
register.
|
338 |
|
|
|
339 |
|
|
@return The actual size of the register, or zero if regno is not
|
340 |
|
|
applicable. Legacy implementations return -1.
|
341 |
|
|
/* ------------------------------------------------------------------------- */
|
342 |
|
|
int
|
343 |
|
|
sim_fetch_register (SIM_DESC sd ATTRIBUTE_UNUSED,
|
344 |
|
|
int regno,
|
345 |
|
|
unsigned char *buf,
|
346 |
|
|
int len)
|
347 |
|
|
{
|
348 |
|
|
return or1ksim_read_reg (buf, regno, len);
|
349 |
|
|
|
350 |
|
|
} /* sim_fetch_register () */
|
351 |
|
|
|
352 |
|
|
|
353 |
|
|
/* ------------------------------------------------------------------------- */
|
354 |
|
|
/*!Store a register to the simulation
|
355 |
|
|
|
356 |
|
|
@param[in] sd Simulation descriptor from sim_open (). We don't use
|
357 |
|
|
this.
|
358 |
|
|
@param[in] regno The register to store
|
359 |
|
|
@param[in] buf Buffer of length bytes with the data to store. Data is
|
360 |
|
|
only transferred if length matches the register length
|
361 |
|
|
(the actual register size is still returned).
|
362 |
|
|
@param[in] len Size of buf, which should match the size of the
|
363 |
|
|
register.
|
364 |
|
|
|
365 |
|
|
@return The actual size of the register, or zero if regno is not
|
366 |
|
|
applicable. Legacy implementations return -1.
|
367 |
|
|
/* ------------------------------------------------------------------------- */
|
368 |
|
|
int
|
369 |
|
|
sim_store_register (SIM_DESC sd ATTRIBUTE_UNUSED,
|
370 |
|
|
int regno,
|
371 |
|
|
unsigned char *buf,
|
372 |
|
|
int len)
|
373 |
|
|
{
|
374 |
|
|
return or1ksim_write_reg (buf, regno, len);
|
375 |
|
|
|
376 |
|
|
} /* sim_store_register () */
|
377 |
|
|
|
378 |
|
|
|
379 |
|
|
/* ------------------------------------------------------------------------- */
|
380 |
|
|
/* Print whatever statistics the simulator has collected.
|
381 |
|
|
|
382 |
|
|
@param[in] sd Simulation descriptor from sim_open (). We don't use
|
383 |
|
|
this.
|
384 |
|
|
@param[in] verbose Currently unused, and should always be zero. */
|
385 |
|
|
/* ------------------------------------------------------------------------- */
|
386 |
|
|
void
|
387 |
|
|
sim_info (SIM_DESC sd ATTRIBUTE_UNUSED,
|
388 |
|
|
int verbose ATTRIBUTE_UNUSED)
|
389 |
|
|
{
|
390 |
|
|
} /* sim_info () */
|
391 |
|
|
|
392 |
|
|
|
393 |
|
|
/* ------------------------------------------------------------------------- */
|
394 |
|
|
/*!Run (or resume) the simulated program.
|
395 |
|
|
|
396 |
|
|
Hardware simulator: If the SIGRC value returned by
|
397 |
|
|
sim_stop_reason() is passed back to the simulator via siggnal then
|
398 |
|
|
the hardware simulator shall correctly deliver the hardware event
|
399 |
|
|
indicated by that signal. If a value of zero is passed in then the
|
400 |
|
|
simulation will continue as if there were no outstanding signal.
|
401 |
|
|
The effect of any other siggnal value is is implementation
|
402 |
|
|
dependant.
|
403 |
|
|
|
404 |
|
|
Process simulator: If SIGRC is non-zero then the corresponding
|
405 |
|
|
signal is delivered to the simulated program and execution is then
|
406 |
|
|
continued. A zero SIGRC value indicates that the program should
|
407 |
|
|
continue as normal.
|
408 |
|
|
|
409 |
|
|
@param[in] sd Simulation descriptor from sim_open ().
|
410 |
|
|
@param[in] step When non-zero indicates that only a single simulator
|
411 |
|
|
cycle should be emulated.
|
412 |
|
|
@param[in] siggnal If non-zero is a (HOST) SIGRC value indicating the type
|
413 |
|
|
of event (hardware interrupt, signal) to be delivered
|
414 |
|
|
to the simulated program. */
|
415 |
|
|
/* ------------------------------------------------------------------------- */
|
416 |
|
|
void
|
417 |
|
|
sim_resume (SIM_DESC sd,
|
418 |
|
|
int step,
|
419 |
|
|
int siggnal)
|
420 |
|
|
{
|
421 |
|
|
int res;
|
422 |
|
|
|
423 |
|
|
res = step ? or1ksim_step () : or1ksim_run (-1.0);
|
424 |
|
|
|
425 |
|
|
switch (res)
|
426 |
|
|
{
|
427 |
|
|
case OR1KSIM_RC_HALTED:
|
428 |
|
|
last_reason = sim_exited;
|
429 |
|
|
(void) sim_fetch_register (sd, OR32_FIRST_ARG_REGNUM,
|
430 |
|
|
(unsigned char *) &last_rc, 4);
|
431 |
|
|
break;
|
432 |
|
|
|
433 |
|
|
case OR1KSIM_RC_BRKPT:
|
434 |
|
|
last_reason = sim_stopped;
|
435 |
|
|
last_rc = TARGET_SIGNAL_TRAP;
|
436 |
|
|
break;
|
437 |
|
|
}
|
438 |
|
|
} /* sim_resume () */
|
439 |
|
|
|
440 |
|
|
|
441 |
|
|
/* ------------------------------------------------------------------------- */
|
442 |
|
|
/*!Asynchronous request to stop the simulation.
|
443 |
|
|
|
444 |
|
|
@param[in] sd Simulation descriptor from sim_open (). We don't use this.
|
445 |
|
|
|
446 |
|
|
@return Non-zero indicates that the simulator is able to handle the
|
447 |
|
|
request. */
|
448 |
|
|
/* ------------------------------------------------------------------------- */
|
449 |
|
|
int sim_stop (SIM_DESC sd ATTRIBUTE_UNUSED)
|
450 |
|
|
{
|
451 |
|
|
return 0; /* We don't support this */
|
452 |
|
|
|
453 |
|
|
} /* sim_stop () */
|
454 |
|
|
|
455 |
|
|
|
456 |
|
|
/* ------------------------------------------------------------------------- */
|
457 |
|
|
/*!Fetch the REASON why the program stopped.
|
458 |
|
|
|
459 |
|
|
The reason enumeration indicates why:
|
460 |
|
|
|
461 |
|
|
- sim_exited: The program has terminated. sigrc indicates the target
|
462 |
|
|
dependant exit status.
|
463 |
|
|
|
464 |
|
|
- sim_stopped: The program has stopped. sigrc uses the host's signal
|
465 |
|
|
numbering as a way of identifying the reaon: program
|
466 |
|
|
interrupted by user via a sim_stop request (SIGINT); a
|
467 |
|
|
breakpoint instruction (SIGTRAP); a completed single step
|
468 |
|
|
(SIGTRAP); an internal error condition (SIGABRT); an
|
469 |
|
|
illegal instruction (SIGILL); Access to an undefined
|
470 |
|
|
memory region (SIGSEGV); Mis-aligned memory access
|
471 |
|
|
(SIGBUS).
|
472 |
|
|
|
473 |
|
|
For some signals information in addition to the signal
|
474 |
|
|
number may be retained by the simulator (e.g. offending
|
475 |
|
|
address), that information is not directly accessable via
|
476 |
|
|
this interface.
|
477 |
|
|
|
478 |
|
|
- sim_signalled: The program has been terminated by a signal. The
|
479 |
|
|
simulator has encountered target code that causes the the
|
480 |
|
|
program to exit with signal sigrc.
|
481 |
|
|
|
482 |
|
|
- sim_running:
|
483 |
|
|
- sim_polling: The return of one of these values indicates a problem
|
484 |
|
|
internal to the simulator.
|
485 |
|
|
|
486 |
|
|
@param[in] sd Simulation descriptor from sim_open (). We don't use
|
487 |
|
|
this.
|
488 |
|
|
@param[out] reason The reason for stopping
|
489 |
|
|
@param[out] sigrc Supplementary information for some values of reason. */
|
490 |
|
|
/* ------------------------------------------------------------------------- */
|
491 |
|
|
void
|
492 |
|
|
sim_stop_reason (SIM_DESC sd ATTRIBUTE_UNUSED,
|
493 |
|
|
enum sim_stop *reason,
|
494 |
|
|
int *sigrc)
|
495 |
|
|
{
|
496 |
|
|
*reason = last_reason;
|
497 |
|
|
*sigrc = last_rc;
|
498 |
|
|
|
499 |
|
|
} /* sim_stop_reason () */
|
500 |
|
|
|
501 |
|
|
|
502 |
|
|
/* ------------------------------------------------------------------------- */
|
503 |
|
|
/* Passthru for other commands that the simulator might support.
|
504 |
|
|
|
505 |
|
|
Simulators should be prepared to deal with any combination of NULL
|
506 |
|
|
or empty command.
|
507 |
|
|
|
508 |
|
|
This implementation currently does nothing.
|
509 |
|
|
|
510 |
|
|
@param[in] sd Simulation descriptor from sim_open (). We don't use this.
|
511 |
|
|
@param[in] cmd The command to pass through. */
|
512 |
|
|
/* ------------------------------------------------------------------------- */
|
513 |
|
|
void
|
514 |
|
|
sim_do_command (SIM_DESC sd ATTRIBUTE_UNUSED,
|
515 |
|
|
char *cmd ATTRIBUTE_UNUSED)
|
516 |
|
|
{
|
517 |
|
|
} /* sim_do_command () */
|
518 |
|
|
|
519 |
|
|
|
520 |
|
|
/* ------------------------------------------------------------------------- */
|
521 |
|
|
/* Set the default host_callback_struct
|
522 |
|
|
|
523 |
|
|
@note Deprecated, but implemented, since it is still required for linking.
|
524 |
|
|
|
525 |
|
|
This implementation currently does nothing.
|
526 |
|
|
|
527 |
|
|
@param[in] ptr The host_callback_struct pointer. Unused here. */
|
528 |
|
|
/* ------------------------------------------------------------------------- */
|
529 |
|
|
void
|
530 |
|
|
sim_set_callbacks (struct host_callback_struct *ptr ATTRIBUTE_UNUSED)
|
531 |
|
|
{
|
532 |
|
|
} /* sim_set_callbacks () */
|
533 |
|
|
|
534 |
|
|
|
535 |
|
|
/* ------------------------------------------------------------------------- */
|
536 |
|
|
/* Set the size of the simulator memory array.
|
537 |
|
|
|
538 |
|
|
@note Deprecated, but implemented, since it is still required for linking.
|
539 |
|
|
|
540 |
|
|
This implementation currently does nothing.
|
541 |
|
|
|
542 |
|
|
@param[in] size The memory size to use. Unused here. */
|
543 |
|
|
/* ------------------------------------------------------------------------- */
|
544 |
|
|
void
|
545 |
|
|
sim_size (int size ATTRIBUTE_UNUSED)
|
546 |
|
|
{
|
547 |
|
|
} /* sim_size () */
|
548 |
|
|
|
549 |
|
|
|
550 |
|
|
/* ------------------------------------------------------------------------- */
|
551 |
|
|
/* Single step the simulator with tracing enabled.
|
552 |
|
|
|
553 |
|
|
@note Deprecated, but implemented, since it is still required for linking.
|
554 |
|
|
|
555 |
|
|
This implementation currently does nothing.
|
556 |
|
|
|
557 |
|
|
@param[in] sd The simulator description struct. Unused here. */
|
558 |
|
|
/* ------------------------------------------------------------------------- */
|
559 |
|
|
void
|
560 |
|
|
sim_trace (SIM_DESC sd ATTRIBUTE_UNUSED)
|
561 |
|
|
{
|
562 |
|
|
} /* sim_trace () */
|