/* This file defines the interface between the simulator and gdb.
- Copyright (C) 1993, 1994, 1996, 1997 Free Software Foundation, Inc.
+ Copyright 1993, 1994, 1996, 1997, 1998, 2000
+ Free Software Foundation, Inc.
This file is part of GDB.
#if !defined (REMOTE_SIM_H)
#define REMOTE_SIM_H 1
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* This file is used when building stand-alone simulators, so isolate this
file from gdb. */
If ABFD is non-NULL, the bfd for the file has already been opened.
The result is a return code indicating success.
- Hardware simulator: A call to this function should not effect the
- state of the processor registers. Multiple calls to this function
- are permitted and have an accumulative effect.
+ Hardware simulator: Normally, each program section is written into
+ memory according to that sections LMA using physical (direct)
+ addressing. The exception being systems, such as PPC/CHRP, which
+ support more complicated program loaders. A call to this function
+ should not effect the state of the processor registers. Multiple
+ calls to this function are permitted and have an accumulative
+ effect.
Process simulator: Calls to this function may be ignored.
- FIXME: Some hardware targets, before a loaded program can be
- executed, require the manipulation of VM registers and tables.
+ FIXME: Most hardware simulators load the image at the VMA using
+ virtual addressing.
+
+ FIXME: For some hardware targets, before a loaded program can be
+ executed, it requires the manipulation of VM registers and tables.
Such manipulation should probably (?) occure in
sim_create_inferior. */
SIM_RC sim_create_inferior PARAMS ((SIM_DESC sd, struct _bfd *abfd, char **argv, char **env));
-/* Read LENGTH bytes of the simulated program's memory and store in
- BUF. Result is number of bytes read, or zero if error. */
+/* Fetch LENGTH bytes of the simulated program's memory. Start fetch
+ at virtual address MEM and store in BUF. Result is number of bytes
+ read, or zero if error. */
int sim_read PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length));
-/* Store LENGTH bytes from BUF in the simulated program's memory.
- Result is number of bytes write, or zero if error. */
+/* Store LENGTH bytes from BUF into the simulated program's
+ memory. Store bytes starting at virtual address MEM. Result is
+ number of bytes write, or zero if error. */
int sim_write PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length));
-/* Fetch register REGNO and store the raw (target endian) value in
- BUF. */
+/* Fetch register REGNO storing its raw (target endian) value in the
+ LENGTH byte buffer BUF. Return the actual size of the register or
+ zero if REGNO is not applicable.
+
+ Legacy implementations ignore LENGTH and always return -1.
+
+ If LENGTH does not match the size of REGNO no data is transfered
+ (the actual register size is still returned). */
-void sim_fetch_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf));
+int sim_fetch_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf, int length));
-/* Store register REGNO from the raw (target endian) value in BUF. */
+/* Store register REGNO from the raw (target endian) value in BUF.
+ Return the actual size of the register or zero if REGNO is not
+ applicable.
-void sim_store_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf));
+ Legacy implementations ignore LENGTH and always return -1.
+
+ If LENGTH does not match the size of REGNO no data is transfered
+ (the actual register size is still returned). */
+
+int sim_store_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf, int length));
/* Print whatever statistics the simulator has collected.
void sim_info PARAMS ((SIM_DESC sd, int verbose));
-/* Run (or resume) the simulated program. */
+/* Run (or resume) the simulated program.
+
+ STEP, when non-zero indicates that only a single simulator cycle
+ should be emulated.
+
+ SIGGNAL, if non-zero is a (HOST) SIGRC value indicating the type of
+ event (hardware interrupt, signal) to be delivered to the simulated
+ program.
+
+ Hardware simulator: If the SIGRC value returned by
+ sim_stop_reason() is passed back to the simulator via SIGGNAL then
+ the hardware simulator shall correctly deliver the hardware event
+ indicated by that signal. If a value of zero is passed in then the
+ simulation will continue as if there were no outstanding signal.
+ The effect of any other SIGGNAL value is is implementation
+ dependant.
+
+ Process simulator: If SIGRC is non-zero then the corresponding
+ signal is delivered to the simulated program and execution is then
+ continued. A zero SIGRC value indicates that the program should
+ continue as normal. */
void sim_resume PARAMS ((SIM_DESC sd, int step, int siggnal));
SIM_EXITED: The program has terminated. SIGRC indicates the target
dependant exit status.
- SIM_STOPPED: The program has stopped. SIGRC indicates the reason:
- program interrupted by user via a sim_stop request (SIGINT); a
- breakpoint instruction (SIGTRAP); a completed step (SIGTRAP); an
- internal error condition (SIGABRT).
+ SIM_STOPPED: The program has stopped. SIGRC uses the host's signal
+ numbering as a way of identifying the reaon: program interrupted by
+ user via a sim_stop request (SIGINT); a breakpoint instruction
+ (SIGTRAP); a completed single step (SIGTRAP); an internal error
+ condition (SIGABRT); an illegal instruction (SIGILL); Access to an
+ undefined memory region (SIGSEGV); Mis-aligned memory access
+ (SIGBUS). For some signals information in addition to the signal
+ number may be retained by the simulator (e.g. offending address),
+ that information is not directly accessable via this interface.
- SIM_SIGNALLED: The simulator encountered target code that requires
- the signal SIGRC to be delivered to the simulated program.
+ SIM_SIGNALLED: The program has been terminated by a signal. The
+ simulator has encountered target code that causes the the program
+ to exit with signal SIGRC.
SIM_RUNNING, SIM_POLLING: The return of one of these values
indicates a problem internal to the simulator. */
void sim_size PARAMS ((int i));
-/* Run a simulation with tracing enabled.
+/* Single-step simulator with tracing enabled.
THIS PROCEDURE IS DEPRECIATED.
+ THIS PROCEDURE IS EVEN MORE DEPRECATED THAN SIM_SET_TRACE
GDB and NRUN do not use this interface.
- This procedure does not take a SIM_DESC argument as it is
- used before sim_open. */
+ This procedure returns: ``0'' indicating that the simulator should
+ be continued using sim_trace() calls; ``1'' indicating that the
+ simulation has finished. */
int sim_trace PARAMS ((SIM_DESC sd));
+/* Enable tracing.
+ THIS PROCEDURE IS DEPRECIATED.
+ GDB and NRUN do not use this interface.
+ This procedure returns: ``0'' indicating that the simulator should
+ be continued using sim_trace() calls; ``1'' indicating that the
+ simulation has finished. */
+
+void sim_set_trace PARAMS ((void));
+
+
/* Configure the size of the profile buffer.
THIS PROCEDURE IS DEPRECIATED.
GDB and NRUN do not use this interface.
void sim_kill PARAMS ((SIM_DESC sd));
+#ifdef __cplusplus
+}
+#endif
+
#endif /* !defined (REMOTE_SIM_H) */