/* GDB Simulator wrapper for Or1ksim, the OpenRISC architectural simulator
|
/* GDB Simulator wrapper for Or1ksim, the OpenRISC architectural simulator
|
|
|
Copyright 1988-2008, Free Software Foundation, Inc.
|
Copyright 1988-2008, Free Software Foundation, Inc.
|
Copyright (C) 2010 Embecosm Limited
|
Copyright (C) 2010 Embecosm Limited
|
|
|
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
|
|
This file is part of GDB.
|
This file is part of GDB.
|
|
|
This program is free software; you can redistribute it and/or modify it
|
This program is free software; you can redistribute it and/or modify it
|
under the terms of the GNU General Public License as published by the Free
|
under the terms of the GNU General Public License as published by the Free
|
Software Foundation; either version 3 of the License, or (at your option)
|
Software Foundation; either version 3 of the License, or (at your option)
|
any later version.
|
any later version.
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
more details.
|
more details.
|
|
|
You should have received a copy of the GNU General Public License along
|
You should have received a copy of the GNU General Public License along
|
with this program. If not, see <http://www.gnu.org/licenses/>. */
|
with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
/* This is a wrapper for Or1ksim, suitable for use as a GDB simulator.
|
/* This is a wrapper for Or1ksim, suitable for use as a GDB simulator.
|
|
|
The code tries to follow the GDB coding style.
|
The code tries to follow the GDB coding style.
|
|
|
Commenting is Doxygen compatible. */
|
Commenting is Doxygen compatible. */
|
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
|
|
#include <errno.h>
|
#include <errno.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <signal.h>
|
#include <signal.h>
|
#include <string.h>
|
#include <string.h>
|
#include <sys/socket.h>
|
#include <sys/socket.h>
|
#include <sys/types.h>
|
#include <sys/types.h>
|
#include <sys/un.h>
|
#include <sys/un.h>
|
#include <unistd.h>
|
#include <unistd.h>
|
|
|
#include "ansidecl.h"
|
#include "ansidecl.h"
|
#include "gdb/callback.h"
|
#include "gdb/callback.h"
|
#include "gdb/remote-sim.h"
|
#include "gdb/remote-sim.h"
|
#include "sim-utils.h"
|
#include "sim-utils.h"
|
#include "targ-vals.h"
|
#include "targ-vals.h"
|
|
|
#include "or1ksim.h"
|
#include "or1ksim.h"
|
#include "or32sim.h"
|
#include "or32sim.h"
|
|
|
/* Define this to turn on debug messages */
|
/* Define this to turn on debug messages */
|
/* #define OR32_SIM_DEBUG */
|
/* #define OR32_SIM_DEBUG */
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
/*!Create a fully initialized simulator instance.
|
/*!Create a fully initialized simulator instance.
|
|
|
This function is called when the simulator is selected from the gdb command
|
This function is called when the simulator is selected from the gdb command
|
line.
|
line.
|
|
|
While the simulator configuration can be parameterized by (in decreasing
|
While the simulator configuration can be parameterized by (in decreasing
|
precedence) argv's SIM-OPTION, argv's TARGET-PROGRAM and the abfd argument,
|
precedence) argv's SIM-OPTION, argv's TARGET-PROGRAM and the abfd argument,
|
the successful creation of the simulator shall not dependent on the
|
the successful creation of the simulator shall not dependent on the
|
presence of any of these arguments/options.
|
presence of any of these arguments/options.
|
|
|
For a hardware simulator the created simulator shall be sufficiently
|
For a hardware simulator the created simulator shall be sufficiently
|
initialized to handle, without restrictions any client requests (including
|
initialized to handle, without restrictions any client requests (including
|
memory reads/writes, register fetch/stores and a resume).
|
memory reads/writes, register fetch/stores and a resume).
|
|
|
For a process simulator, the process is not created until a call to
|
For a process simulator, the process is not created until a call to
|
sim_create_inferior.
|
sim_create_inferior.
|
|
|
We do the following on a first call.
|
We do the following on a first call.
|
- parse the options
|
- parse the options
|
-
|
-
|
@todo Eventually we should use the option parser built into the GDB
|
@todo Eventually we should use the option parser built into the GDB
|
simulator (see common/sim-options.h). However since this is minimally
|
simulator (see common/sim-options.h). However since this is minimally
|
documented, and we have only the one option, for now we do it
|
documented, and we have only the one option, for now we do it
|
ourselves.
|
ourselves.
|
|
|
@note We seem to capable of being called twice. We use the static
|
@note We seem to capable of being called twice. We use the static
|
"global_sd" variable to keep track of this. Second and subsequent
|
"global_sd" variable to keep track of this. Second and subsequent
|
calls do nothing, but return the previously opened simulator
|
calls do nothing, but return the previously opened simulator
|
description.
|
description.
|
|
|
@param[in] kind Specifies how the simulator shall be used. Currently
|
@param[in] kind Specifies how the simulator shall be used. Currently
|
there are only two kinds: stand-alone and debug.
|
there are only two kinds: stand-alone and debug.
|
|
|
@param[in] callback Specifies a standard host callback (defined in
|
@param[in] callback Specifies a standard host callback (defined in
|
callback.h).
|
callback.h).
|
|
|
@param[in] abfd When non NULL, designates a target program. The
|
@param[in] abfd When non NULL, designates a target program. The
|
program is not loaded.
|
program is not loaded.
|
|
|
@param[in] argv A standard ARGV pointer such as that passed from the
|
@param[in] argv A standard ARGV pointer such as that passed from the
|
command line. The syntax of the argument list is is
|
command line. The syntax of the argument list is is
|
assumed to be ``SIM-PROG { SIM-OPTION } [
|
assumed to be ``SIM-PROG { SIM-OPTION } [
|
TARGET-PROGRAM { TARGET-OPTION } ]''.
|
TARGET-PROGRAM { TARGET-OPTION } ]''.
|
|
|
The trailing TARGET-PROGRAM and args are only valid
|
The trailing TARGET-PROGRAM and args are only valid
|
for a stand-alone simulator.
|
for a stand-alone simulator.
|
|
|
The argument list is null terminated!
|
The argument list is null terminated!
|
|
|
@return On success, the result is a non NULL descriptor that shall be
|
@return On success, the result is a non NULL descriptor that shall be
|
passed to the other sim_foo functions. */
|
passed to the other sim_foo functions. */
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
SIM_DESC
|
SIM_DESC
|
sim_open (SIM_OPEN_KIND kind,
|
sim_open (SIM_OPEN_KIND kind,
|
struct host_callback_struct *callback,
|
struct host_callback_struct *callback,
|
struct bfd *abfd,
|
struct bfd *abfd,
|
char *argv[])
|
char *argv[])
|
{
|
{
|
/*!A global record of the simulator description */
|
/*!A global record of the simulator description */
|
static SIM_DESC static_sd = NULL;
|
static SIM_DESC static_sd = NULL;
|
|
|
#ifdef OR32_SIM_DEBUG
|
#ifdef OR32_SIM_DEBUG
|
printf ("sim_open called\n");
|
printf ("sim_open called\n");
|
#endif
|
#endif
|
|
|
/* If static_sd is not yet allocated, we allocate it and mark the simulator
|
/* If static_sd is not yet allocated, we allocate it and mark the simulator
|
as not yet open. This is the only time we can process any custom
|
as not yet open. This is the only time we can process any custom
|
arguments and only time we initialize the simulator. */
|
arguments and only time we initialize the simulator. */
|
if (NULL == static_sd)
|
if (NULL == static_sd)
|
{
|
{
|
int local_argc; /* Our local argv with extra args */
|
int local_argc; /* Our local argv with extra args */
|
char **local_argv;
|
char **local_argv;
|
|
|
int argc; /* How many args originally */
|
int argc; /* How many args originally */
|
int i; /* For local argv */
|
int i; /* For local argv */
|
int mem_defined_p = 0; /* Have we requested a memory size? */
|
int mem_defined_p = 0; /* Have we requested a memory size? */
|
|
|
int res; /* Result of initialization */
|
int res; /* Result of initialization */
|
|
|
static_sd = (SIM_DESC) malloc (sizeof (*static_sd));
|
static_sd = (SIM_DESC) malloc (sizeof (*static_sd));
|
static_sd->sim_open = 0;
|
static_sd->sim_open = 0;
|
|
|
/* Count the number of arguments and see if we have specified either a
|
/* Count the number of arguments and see if we have specified either a
|
config file or a memory size. */
|
config file or a memory size. */
|
for (argc = 1; NULL != argv[argc]; argc++)
|
for (argc = 1; NULL != argv[argc]; argc++)
|
{
|
{
|
#ifdef OR32_SIM_DEBUG
|
#ifdef OR32_SIM_DEBUG
|
printf ("argv[%d] = %s\n", argc, argv[argc]);
|
printf ("argv[%d] = %s\n", argc, argv[argc]);
|
#endif
|
#endif
|
if ((0 == strcmp (argv[argc], "-f")) ||
|
if ((0 == strcmp (argv[argc], "-f")) ||
|
(0 == strcmp (argv[argc], "-file")) ||
|
(0 == strcmp (argv[argc], "-file")) ||
|
(0 == strcmp (argv[argc], "-m")) ||
|
(0 == strcmp (argv[argc], "-m")) ||
|
(0 == strcmp (argv[argc], "-memory")))
|
(0 == strcmp (argv[argc], "-memory")))
|
{
|
{
|
mem_defined_p = 1;
|
mem_defined_p = 1;
|
}
|
}
|
}
|
}
|
|
|
/* If we have no memory defined, we give it a default 8MB. We also always
|
/* If we have no memory defined, we give it a default 8MB. We also always
|
run quiet. So we must define our own argument vector */
|
run quiet. So we must define our own argument vector */
|
local_argc = mem_defined_p ? argc + 1 : argc + 3;
|
local_argc = mem_defined_p ? argc + 1 : argc + 3;
|
local_argv = malloc ((local_argc + 1) * sizeof (char *));
|
local_argv = malloc ((local_argc + 1) * sizeof (char *));
|
|
|
for (i = 0 ; i < argc; i++)
|
for (i = 0 ; i < argc; i++)
|
{
|
{
|
local_argv[i] = argv[i];
|
local_argv[i] = argv[i];
|
}
|
}
|
|
|
local_argv[i++] = "--quiet";
|
local_argv[i++] = "--quiet";
|
|
|
if (!mem_defined_p)
|
if (!mem_defined_p)
|
{
|
{
|
local_argv[i++] = "--memory";
|
local_argv[i++] = "--memory";
|
local_argv[i++] = "8M";
|
local_argv[i++] = "8M";
|
}
|
}
|
|
|
local_argv[i] = NULL;
|
local_argv[i] = NULL;
|
|
|
/* Try to initialize, then we can free the local argument vector. If we
|
/* Try to initialize, then we can free the local argument vector. If we
|
fail to initialize return NULL to indicate that failure. */
|
fail to initialize return NULL to indicate that failure. */
|
res = or1ksim_init (local_argc, local_argv, NULL, NULL, NULL);
|
res = or1ksim_init (local_argc, local_argv, NULL, NULL, NULL);
|
free (local_argv);
|
free (local_argv);
|
|
|
if (res)
|
if (res)
|
{
|
{
|
return NULL; /* Failure */
|
return NULL; /* Failure */
|
}
|
}
|
}
|
}
|
|
|
/* We have either initialized a new simulator, or already have an intialized
|
/* We have either initialized a new simulator, or already have an intialized
|
simulator. Populate the descriptor and stall the processor, the return
|
simulator. Populate the descriptor and stall the processor, the return
|
the descriptor. */
|
the descriptor. */
|
static_sd->callback = callback;
|
static_sd->callback = callback;
|
static_sd->is_debug = (kind == SIM_OPEN_DEBUG);
|
static_sd->is_debug = (kind == SIM_OPEN_DEBUG);
|
static_sd->myname = (char *)xstrdup (argv[0]);
|
static_sd->myname = (char *)xstrdup (argv[0]);
|
static_sd->sim_open = 1;
|
static_sd->sim_open = 1;
|
static_sd->last_reason = sim_running;
|
static_sd->last_reason = sim_running;
|
static_sd->last_rc = TARGET_SIGNAL_NONE;
|
static_sd->last_rc = TARGET_SIGNAL_NONE;
|
static_sd->entry_point = OR32_RESET_EXCEPTION;
|
static_sd->entry_point = OR32_RESET_EXCEPTION;
|
static_sd->resume_npc = OR32_RESET_EXCEPTION;
|
static_sd->resume_npc = OR32_RESET_EXCEPTION;
|
|
|
or1ksim_set_stall_state (0);
|
or1ksim_set_stall_state (0);
|
|
|
return static_sd;
|
return static_sd;
|
|
|
} /* sim_open () */
|
} /* sim_open () */
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
/*!Destroy a simulator instance.
|
/*!Destroy a simulator instance.
|
|
|
We never actually close the simulator, because we have no way to
|
We never actually close the simulator, because we have no way to
|
reinitialize it. Instead we just stall the processor and mark it closed.
|
reinitialize it. Instead we just stall the processor and mark it closed.
|
|
|
@param[in] sd Simulation descriptor from sim_open ().
|
@param[in] sd Simulation descriptor from sim_open ().
|
@param[in] quitting Non-zero if we cannot hang on errors. */
|
@param[in] quitting Non-zero if we cannot hang on errors. */
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
void
|
void
|
sim_close (SIM_DESC sd,
|
sim_close (SIM_DESC sd,
|
int quitting)
|
int quitting)
|
{
|
{
|
#ifdef OR32_SIM_DEBUG
|
#ifdef OR32_SIM_DEBUG
|
printf ("sim_close called\n");
|
printf ("sim_close called\n");
|
#endif
|
#endif
|
|
|
if (NULL == sd)
|
if (NULL == sd)
|
{
|
{
|
fprintf (stderr,
|
fprintf (stderr,
|
"Warning: Attempt to close non-open simulation: ignored.\n");
|
"Warning: Attempt to close non-open simulation: ignored.\n");
|
}
|
}
|
else
|
else
|
{
|
{
|
free (sd->myname);
|
free (sd->myname);
|
sd->sim_open = 0;
|
sd->sim_open = 0;
|
or1ksim_set_stall_state (0);
|
or1ksim_set_stall_state (0);
|
}
|
}
|
} /* sim_close () */
|
} /* sim_close () */
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
/*!Load program PROG into the simulators memory.
|
/*!Load program PROG into the simulators memory.
|
|
|
Hardware simulator: Normally, each program section is written into
|
Hardware simulator: Normally, each program section is written into
|
memory according to that sections LMA using physical (direct)
|
memory according to that sections LMA using physical (direct)
|
addressing. The exception being systems, such as PPC/CHRP, which
|
addressing. The exception being systems, such as PPC/CHRP, which
|
support more complicated program loaders. A call to this function
|
support more complicated program loaders. A call to this function
|
should not effect the state of the processor registers. Multiple
|
should not effect the state of the processor registers. Multiple
|
calls to this function are permitted and have an accumulative
|
calls to this function are permitted and have an accumulative
|
effect.
|
effect.
|
|
|
Process simulator: Calls to this function may be ignored.
|
Process simulator: Calls to this function may be ignored.
|
|
|
@todo Most hardware simulators load the image at the VMA using
|
@todo Most hardware simulators load the image at the VMA using
|
virtual addressing.
|
virtual addressing.
|
|
|
@todo For some hardware targets, before a loaded program can be executed,
|
@todo For some hardware targets, before a loaded program can be executed,
|
it requires the manipulation of VM registers and tables. Such
|
it requires the manipulation of VM registers and tables. Such
|
manipulation should probably (?) occure in sim_create_inferior ().
|
manipulation should probably (?) occure in sim_create_inferior ().
|
|
|
@param[in] sd Simulation descriptor from sim_open ().
|
@param[in] sd Simulation descriptor from sim_open ().
|
@param[in] prog The name of the program
|
@param[in] prog The name of the program
|
@param[in] abfd If non-NULL, the BFD for the file has already been
|
@param[in] abfd If non-NULL, the BFD for the file has already been
|
opened.
|
opened.
|
@param[in] from_tty Not sure what this does. Probably indicates this is a
|
@param[in] from_tty Not sure what this does. Probably indicates this is a
|
command line load? Anyway we don't use it.
|
command line load? Anyway we don't use it.
|
|
|
@return A return code indicating success. */
|
@return A return code indicating success. */
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
SIM_RC
|
SIM_RC
|
sim_load (SIM_DESC sd,
|
sim_load (SIM_DESC sd,
|
char *prog,
|
char *prog,
|
struct bfd *abfd,
|
struct bfd *abfd,
|
int from_tty)
|
int from_tty)
|
{
|
{
|
bfd *prog_bfd;
|
bfd *prog_bfd;
|
|
|
#ifdef OR32_SIM_DEBUG
|
#ifdef OR32_SIM_DEBUG
|
printf ("sim_load called\n");
|
printf ("sim_load called\n");
|
#endif
|
#endif
|
|
|
/* Use the built in loader, which will in turn use our write function. */
|
/* Use the built in loader, which will in turn use our write function. */
|
prog_bfd = sim_load_file (sd, sd->myname, sd->callback, prog, abfd,
|
prog_bfd = sim_load_file (sd, sd->myname, sd->callback, prog, abfd,
|
sd->is_debug, 0, sim_write);
|
sd->is_debug, 0, sim_write);
|
|
|
if (NULL == prog_bfd)
|
if (NULL == prog_bfd)
|
{
|
{
|
return SIM_RC_FAIL;
|
return SIM_RC_FAIL;
|
}
|
}
|
|
|
/* If the BFD was not already open, then close the loaded program. */
|
/* If the BFD was not already open, then close the loaded program. */
|
if (NULL == abfd)
|
if (NULL == abfd)
|
{
|
{
|
bfd_close (prog_bfd);
|
bfd_close (prog_bfd);
|
}
|
}
|
|
|
return SIM_RC_OK;
|
return SIM_RC_OK;
|
|
|
} /* sim_load () */
|
} /* sim_load () */
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
/*!Prepare to run the simulated program.
|
/*!Prepare to run the simulated program.
|
|
|
Hardware simulator: This function shall initialize the processor
|
Hardware simulator: This function shall initialize the processor
|
registers to a known value. The program counter and possibly stack
|
registers to a known value. The program counter and possibly stack
|
pointer shall be set using information obtained from ABFD (or
|
pointer shall be set using information obtained from ABFD (or
|
hardware reset defaults). ARGV and ENV, dependant on the target
|
hardware reset defaults). ARGV and ENV, dependant on the target
|
ABI, may be written to memory.
|
ABI, may be written to memory.
|
|
|
Process simulator: After a call to this function, a new process
|
Process simulator: After a call to this function, a new process
|
instance shall exist. The TEXT, DATA, BSS and stack regions shall
|
instance shall exist. The TEXT, DATA, BSS and stack regions shall
|
all be initialized, ARGV and ENV shall be written to process
|
all be initialized, ARGV and ENV shall be written to process
|
address space (according to the applicable ABI) and the program
|
address space (according to the applicable ABI) and the program
|
counter and stack pointer set accordingly.
|
counter and stack pointer set accordingly.
|
|
|
ABFD, if not NULL, provides initial processor state information.
|
ABFD, if not NULL, provides initial processor state information.
|
ARGV and ENV, if non NULL, are NULL terminated lists of pointers.
|
ARGV and ENV, if non NULL, are NULL terminated lists of pointers.
|
|
|
We perform the following steps:
|
We perform the following steps:
|
- stall the processor
|
- stall the processor
|
- set the entry point to the entry point in the BFD, or the reset
|
- set the entry point to the entry point in the BFD, or the reset
|
vector if the BFD is not available.
|
vector if the BFD is not available.
|
- set the resumption NPC to the reset vector. We always do this, to ensure
|
- set the resumption NPC to the reset vector. We always do this, to ensure
|
the library is initialized.
|
the library is initialized.
|
|
|
@param[in] sd Simulation descriptor from sim_open ().
|
@param[in] sd Simulation descriptor from sim_open ().
|
@param[in] abfd If non-NULL provides initial processor state information.
|
@param[in] abfd If non-NULL provides initial processor state information.
|
@param[in] argv Vector of arguments to the program. We don't use this
|
@param[in] argv Vector of arguments to the program. We don't use this
|
@param[in] env Vector of environment data. We don't use this.
|
@param[in] env Vector of environment data. We don't use this.
|
|
|
@return A return code indicating success. */
|
@return A return code indicating success. */
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
SIM_RC
|
SIM_RC
|
sim_create_inferior (SIM_DESC sd,
|
sim_create_inferior (SIM_DESC sd,
|
struct bfd *abfd,
|
struct bfd *abfd,
|
char **argv ATTRIBUTE_UNUSED,
|
char **argv ATTRIBUTE_UNUSED,
|
char **env ATTRIBUTE_UNUSED)
|
char **env ATTRIBUTE_UNUSED)
|
{
|
{
|
#ifdef OR32_SIM_DEBUG
|
#ifdef OR32_SIM_DEBUG
|
printf ("sim_create_inferior called\n");
|
printf ("sim_create_inferior called\n");
|
#endif
|
#endif
|
|
|
or1ksim_set_stall_state (1);
|
or1ksim_set_stall_state (1);
|
sd->entry_point = (NULL == abfd) ? OR32_RESET_EXCEPTION :
|
sd->entry_point = (NULL == abfd) ? OR32_RESET_EXCEPTION :
|
bfd_get_start_address (abfd);
|
bfd_get_start_address (abfd);
|
sd->resume_npc = OR32_RESET_EXCEPTION;
|
sd->resume_npc = OR32_RESET_EXCEPTION;
|
|
|
return SIM_RC_OK;
|
return SIM_RC_OK;
|
|
|
} /* sim_create_inferior () */
|
} /* sim_create_inferior () */
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
/*!Fetch bytes from the simulated program's memory.
|
/*!Fetch bytes from the simulated program's memory.
|
|
|
@param[in] sd Simulation descriptor from sim_open (). We don't use
|
@param[in] sd Simulation descriptor from sim_open (). We don't use
|
this.
|
this.
|
@param[in] mem The address in memory to fetch from.
|
@param[in] mem The address in memory to fetch from.
|
@param[out] buf Where to put the read data
|
@param[out] buf Where to put the read data
|
@param[in] len Number of bytes to fetch
|
@param[in] len Number of bytes to fetch
|
|
|
@return Number of bytes read, or zero if error. */
|
@return Number of bytes read, or zero if error. */
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
int
|
int
|
sim_read (SIM_DESC sd ATTRIBUTE_UNUSED,
|
sim_read (SIM_DESC sd ATTRIBUTE_UNUSED,
|
SIM_ADDR mem,
|
SIM_ADDR mem,
|
unsigned char *buf,
|
unsigned char *buf,
|
int len)
|
int len)
|
{
|
{
|
int res = or1ksim_read_mem (mem, buf, len);
|
int res = or1ksim_read_mem (mem, buf, len);
|
|
|
#ifdef OR32_SIM_DEBUG
|
#ifdef OR32_SIM_DEBUG
|
printf ("Reading %d bytes from 0x%08p\n", len, mem);
|
printf ("Reading %d bytes from 0x%08p\n", len, mem);
|
#endif
|
#endif
|
|
|
return res;
|
return res;
|
|
|
} /* sim_read () */
|
} /* sim_read () */
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
/*!Store bytes to the simulated program's memory.
|
/*!Store bytes to the simulated program's memory.
|
|
|
@param[in] sd Simulation descriptor from sim_open (). We don't use
|
@param[in] sd Simulation descriptor from sim_open (). We don't use
|
this.
|
this.
|
@param[in] mem The address in memory to write to.
|
@param[in] mem The address in memory to write to.
|
@param[in] buf The data to write
|
@param[in] buf The data to write
|
@param[in] len Number of bytes to write
|
@param[in] len Number of bytes to write
|
|
|
@return Number of byte written, or zero if error. */
|
@return Number of byte written, or zero if error. */
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
int
|
int
|
sim_write (SIM_DESC sd ATTRIBUTE_UNUSED,
|
sim_write (SIM_DESC sd ATTRIBUTE_UNUSED,
|
SIM_ADDR mem,
|
SIM_ADDR mem,
|
unsigned char *buf,
|
unsigned char *buf,
|
int len)
|
int len)
|
{
|
{
|
#ifdef OR32_SIM_DEBUG
|
#ifdef OR32_SIM_DEBUG
|
printf ("Writing %d bytes to 0x%08p\n", len, mem);
|
printf ("Writing %d bytes to 0x%08p\n", len, mem);
|
#endif
|
#endif
|
|
|
return or1ksim_write_mem ((unsigned int) mem, buf, len);
|
return or1ksim_write_mem ((unsigned int) mem, buf, len);
|
|
|
} /* sim_write () */
|
} /* sim_write () */
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
/*!Fetch a register from the simulation
|
/*!Fetch a register from the simulation
|
|
|
We get the register back as a 32-bit value. However we must convert it to a
|
We get the register back as a 32-bit value. However we must convert it to a
|
character array <em>in target endian order</em>.
|
character array <em>in target endian order</em>.
|
|
|
The exception is if the register is the NPC, which is only written just
|
The exception is if the register is the NPC, which is only written just
|
before resumption, to avoid pipeline confusion. It is fetched from the SD.
|
before resumption, to avoid pipeline confusion. It is fetched from the SD.
|
|
|
@param[in] sd Simulation descriptor from sim_open (). We don't use
|
@param[in] sd Simulation descriptor from sim_open (). We don't use
|
this.
|
this.
|
@param[in] regno The register to fetch
|
@param[in] regno The register to fetch
|
@param[out] buf Buffer of length bytes to store the result. Data is
|
@param[out] buf Buffer of length bytes to store the result. Data is
|
only transferred if length matches the register length
|
only transferred if length matches the register length
|
(the actual register size is still returned).
|
(the actual register size is still returned).
|
@param[in] len Size of buf, which should match the size of the
|
@param[in] len Size of buf, which should match the size of the
|
register.
|
register.
|
|
|
@return The actual size of the register, or zero if regno is not
|
@return The actual size of the register, or zero if regno is not
|
applicable. Legacy implementations return -1.
|
applicable. Legacy implementations return -1.
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
int
|
int
|
sim_fetch_register (SIM_DESC sd,
|
sim_fetch_register (SIM_DESC sd,
|
int regno,
|
int regno,
|
unsigned char *buf,
|
unsigned char *buf,
|
int len)
|
int len)
|
{
|
{
|
unsigned long int regval;
|
unsigned long int regval;
|
int res;
|
int res;
|
|
|
#ifdef OR32_SIM_DEBUG
|
#ifdef OR32_SIM_DEBUG
|
printf ("sim_fetch_register (regno=%d\n) called\n", regno);
|
printf ("sim_fetch_register (regno=%d\n) called\n", regno);
|
#endif
|
#endif
|
if (4 != len)
|
if (4 != len)
|
{
|
{
|
fprintf (stderr, "Invalid register length %d\n");
|
fprintf (stderr, "Invalid register length %d\n");
|
return 0;
|
return 0;
|
}
|
}
|
|
|
if (OR32_NPC_REGNUM == regno)
|
if (OR32_NPC_REGNUM == regno)
|
{
|
{
|
regval = sd->resume_npc;
|
regval = sd->resume_npc;
|
res = 4;
|
res = 4;
|
}
|
}
|
else
|
else
|
{
|
{
|
int res = or1ksim_read_reg (regno, ®val) ? 4 : 0;
|
int res = or1ksim_read_reg (regno, ®val) ? 4 : 0;
|
}
|
}
|
|
|
/* Convert to target (big) endian */
|
/* Convert to target (big) endian */
|
if (res)
|
if (res)
|
{
|
{
|
buf[0] = (regval >> 24) & 0xff;
|
buf[0] = (regval >> 24) & 0xff;
|
buf[1] = (regval >> 16) & 0xff;
|
buf[1] = (regval >> 16) & 0xff;
|
buf[2] = (regval >> 8) & 0xff;
|
buf[2] = (regval >> 8) & 0xff;
|
buf[3] = regval & 0xff;
|
buf[3] = regval & 0xff;
|
|
|
return 4; /* Success */
|
return 4; /* Success */
|
}
|
}
|
else
|
else
|
{
|
{
|
return 0; /* Failure */
|
return 0; /* Failure */
|
}
|
}
|
} /* sim_fetch_register () */
|
} /* sim_fetch_register () */
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
/*!Store a register to the simulation
|
/*!Store a register to the simulation
|
|
|
We write the register back as a 32-bit value. However we must convert it from
|
We write the register back as a 32-bit value. However we must convert it from
|
a character array <em>in target endian order</em>.
|
a character array <em>in target endian order</em>.
|
|
|
The exception is if the register is the NPC, which is only written just
|
The exception is if the register is the NPC, which is only written just
|
before resumption, to avoid pipeline confusion. It is saved in the SD.
|
before resumption, to avoid pipeline confusion. It is saved in the SD.
|
|
|
@param[in] sd Simulation descriptor from sim_open (). We don't use
|
@param[in] sd Simulation descriptor from sim_open (). We don't use
|
this.
|
this.
|
@param[in] regno The register to store
|
@param[in] regno The register to store
|
@param[in] buf Buffer of length bytes with the data to store. Data is
|
@param[in] buf Buffer of length bytes with the data to store. Data is
|
only transferred if length matches the register length
|
only transferred if length matches the register length
|
(the actual register size is still returned).
|
(the actual register size is still returned).
|
@param[in] len Size of buf, which should match the size of the
|
@param[in] len Size of buf, which should match the size of the
|
register.
|
register.
|
|
|
@return The actual size of the register, or zero if regno is not
|
@return The actual size of the register, or zero if regno is not
|
applicable. Legacy implementations return -1.
|
applicable. Legacy implementations return -1.
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
int
|
int
|
sim_store_register (SIM_DESC sd,
|
sim_store_register (SIM_DESC sd,
|
int regno,
|
int regno,
|
unsigned char *buf,
|
unsigned char *buf,
|
int len)
|
int len)
|
{
|
{
|
unsigned int regval;
|
unsigned int regval;
|
|
|
#ifdef OR32_SIM_DEBUG
|
#ifdef OR32_SIM_DEBUG
|
printf ("sim_store_register (regno=%d\n) called\n", regno);
|
printf ("sim_store_register (regno=%d\n) called\n", regno);
|
#endif
|
#endif
|
|
|
if (4 != len)
|
if (4 != len)
|
{
|
{
|
fprintf (stderr, "Invalid register length %d\n");
|
fprintf (stderr, "Invalid register length %d\n");
|
return 0;
|
return 0;
|
}
|
}
|
|
|
/* Convert from target (big) endian */
|
/* Convert from target (big) endian */
|
regval = (((unsigned int) buf[0]) << 24) |
|
regval = (((unsigned int) buf[0]) << 24) |
|
(((unsigned int) buf[1]) << 16) |
|
(((unsigned int) buf[1]) << 16) |
|
(((unsigned int) buf[2]) << 8) |
|
(((unsigned int) buf[2]) << 8) |
|
(((unsigned int) buf[3]) );
|
(((unsigned int) buf[3]) );
|
|
|
#ifdef OR32_SIM_DEBUG
|
#ifdef OR32_SIM_DEBUG
|
printf ("Writing register 0x%02x, value 0x%08x\n", regno, regval);
|
printf ("Writing register 0x%02x, value 0x%08x\n", regno, regval);
|
#endif
|
#endif
|
|
|
if (OR32_NPC_REGNUM == regno)
|
if (OR32_NPC_REGNUM == regno)
|
{
|
{
|
sd->resume_npc = regval;
|
sd->resume_npc = regval;
|
return 4; /* Reg length in bytes */
|
return 4; /* Reg length in bytes */
|
}
|
}
|
else
|
else
|
{
|
{
|
return or1ksim_write_reg (regno, regval) ? 4 : 0;
|
return or1ksim_write_reg (regno, regval) ? 4 : 0;
|
}
|
}
|
} /* sim_store_register () */
|
} /* sim_store_register () */
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
/* Print whatever statistics the simulator has collected.
|
/* Print whatever statistics the simulator has collected.
|
|
|
@param[in] sd Simulation descriptor from sim_open (). We don't use
|
@param[in] sd Simulation descriptor from sim_open (). We don't use
|
this.
|
this.
|
@param[in] verbose Currently unused, and should always be zero. */
|
@param[in] verbose Currently unused, and should always be zero. */
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
void
|
void
|
sim_info (SIM_DESC sd ATTRIBUTE_UNUSED,
|
sim_info (SIM_DESC sd ATTRIBUTE_UNUSED,
|
int verbose ATTRIBUTE_UNUSED)
|
int verbose ATTRIBUTE_UNUSED)
|
{
|
{
|
} /* sim_info () */
|
} /* sim_info () */
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
/*!Run (or resume) the simulated program.
|
/*!Run (or resume) the simulated program.
|
|
|
Hardware simulator: If the SIGRC value returned by
|
Hardware simulator: If the SIGRC value returned by
|
sim_stop_reason() is passed back to the simulator via siggnal then
|
sim_stop_reason() is passed back to the simulator via siggnal then
|
the hardware simulator shall correctly deliver the hardware event
|
the hardware simulator shall correctly deliver the hardware event
|
indicated by that signal. If a value of zero is passed in then the
|
indicated by that signal. If a value of zero is passed in then the
|
simulation will continue as if there were no outstanding signal.
|
simulation will continue as if there were no outstanding signal.
|
The effect of any other siggnal value is is implementation
|
The effect of any other siggnal value is is implementation
|
dependant.
|
dependant.
|
|
|
Process simulator: If SIGRC is non-zero then the corresponding
|
Process simulator: If SIGRC is non-zero then the corresponding
|
signal is delivered to the simulated program and execution is then
|
signal is delivered to the simulated program and execution is then
|
continued. A zero SIGRC value indicates that the program should
|
continued. A zero SIGRC value indicates that the program should
|
continue as normal.
|
continue as normal.
|
|
|
We carry out the following
|
We carry out the following
|
- Clear the debug reason register
|
- Clear the debug reason register
|
- Clear watchpoing break generation in debug mode register 2
|
- Clear watchpoing break generation in debug mode register 2
|
- Set the debug unit to handle TRAP exceptions
|
- Set the debug unit to handle TRAP exceptions
|
- If stepping, set the single step trigger in debug mode register 1
|
- If stepping, set the single step trigger in debug mode register 1
|
- Write the resume_npc if it differs from the actual NPC.
|
- Write the resume_npc if it differs from the actual NPC.
|
- Unstall the processor
|
- Unstall the processor
|
- Run the processor.
|
- Run the processor.
|
|
|
On execution completion, we determine the reason for the halt. If it is a
|
On execution completion, we determine the reason for the halt. If it is a
|
breakpoint, we mark the resumption NPC to be the PPC (so we redo the NPC
|
breakpoint, we mark the resumption NPC to be the PPC (so we redo the NPC
|
location).
|
location).
|
|
|
@param[in] sd Simulation descriptor from sim_open ().
|
@param[in] sd Simulation descriptor from sim_open ().
|
@param[in] step When non-zero indicates that only a single simulator
|
@param[in] step When non-zero indicates that only a single simulator
|
cycle should be emulated.
|
cycle should be emulated.
|
@param[in] siggnal If non-zero is a (HOST) SIGRC value indicating the type
|
@param[in] siggnal If non-zero is a (HOST) SIGRC value indicating the type
|
of event (hardware interrupt, signal) to be delivered
|
of event (hardware interrupt, signal) to be delivered
|
to the simulated program. */
|
to the simulated program. */
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
void
|
void
|
sim_resume (SIM_DESC sd,
|
sim_resume (SIM_DESC sd,
|
int step,
|
int step,
|
int siggnal)
|
int siggnal)
|
{
|
{
|
unsigned long int npc; /* Next Program Counter */
|
unsigned long int npc; /* Next Program Counter */
|
unsigned long int drr; /* Debug Reason Register */
|
unsigned long int drr; /* Debug Reason Register */
|
unsigned long int dsr; /* Debug Stop Register */
|
unsigned long int dsr; /* Debug Stop Register */
|
unsigned long int dmr1; /* Debug Mode Register 1*/
|
unsigned long int dmr1; /* Debug Mode Register 1*/
|
unsigned long int dmr2; /* Debug Mode Register 2*/
|
unsigned long int dmr2; /* Debug Mode Register 2*/
|
|
|
unsigned long int retval; /* Return value on Or1ksim exit */
|
unsigned long int retval; /* Return value on Or1ksim exit */
|
|
|
int res; /* Result of a run. */
|
int res; /* Result of a run. */
|
|
|
#ifdef OR32_SIM_DEBUG
|
#ifdef OR32_SIM_DEBUG
|
printf ("sim_resume called\n");
|
printf ("sim_resume called\n");
|
#endif
|
#endif
|
|
|
/* Clear Debug Reason Register and watchpoint break generation in Debug Mode
|
/* Clear Debug Reason Register and watchpoint break generation in Debug Mode
|
Register 2 */
|
Register 2 */
|
(void) or1ksim_write_spr (OR32_SPR_DRR, 0);
|
(void) or1ksim_write_spr (OR32_SPR_DRR, 0);
|
|
|
(void) or1ksim_read_spr (OR32_SPR_DMR2, &dmr2);
|
(void) or1ksim_read_spr (OR32_SPR_DMR2, &dmr2);
|
dmr2 &= ~OR32_SPR_DMR2_WGB;
|
dmr2 &= ~OR32_SPR_DMR2_WGB;
|
(void) or1ksim_write_spr (OR32_SPR_DMR2, dmr2);
|
(void) or1ksim_write_spr (OR32_SPR_DMR2, dmr2);
|
|
|
/* Set debug unit to handle TRAP exceptions */
|
/* Set debug unit to handle TRAP exceptions */
|
(void) or1ksim_read_spr (OR32_SPR_DSR, &dsr);
|
(void) or1ksim_read_spr (OR32_SPR_DSR, &dsr);
|
dsr |= OR32_SPR_DSR_TE;
|
dsr |= OR32_SPR_DSR_TE;
|
(void) or1ksim_write_spr (OR32_SPR_DSR, dsr);
|
(void) or1ksim_write_spr (OR32_SPR_DSR, dsr);
|
|
|
/* Set the single step trigger in Debug Mode Register 1 if we are
|
/* Set the single step trigger in Debug Mode Register 1 if we are
|
stepping. Otherwise clear it! */
|
stepping. Otherwise clear it! */
|
if (step)
|
if (step)
|
{
|
{
|
(void) or1ksim_read_spr (OR32_SPR_DMR1, &dmr1);
|
(void) or1ksim_read_spr (OR32_SPR_DMR1, &dmr1);
|
dmr1 |= OR32_SPR_DMR1_ST;
|
dmr1 |= OR32_SPR_DMR1_ST;
|
(void) or1ksim_write_spr (OR32_SPR_DMR1, dmr1);
|
(void) or1ksim_write_spr (OR32_SPR_DMR1, dmr1);
|
}
|
}
|
else
|
else
|
{
|
{
|
(void) or1ksim_read_spr (OR32_SPR_DMR1, &dmr1);
|
(void) or1ksim_read_spr (OR32_SPR_DMR1, &dmr1);
|
dmr1 &= ~OR32_SPR_DMR1_ST;
|
dmr1 &= ~OR32_SPR_DMR1_ST;
|
(void) or1ksim_write_spr (OR32_SPR_DMR1, dmr1);
|
(void) or1ksim_write_spr (OR32_SPR_DMR1, dmr1);
|
}
|
}
|
|
|
/* Set the NPC if it has changed */
|
/* Set the NPC if it has changed */
|
(void) or1ksim_read_reg (OR32_NPC_REGNUM, &npc);
|
(void) or1ksim_read_reg (OR32_NPC_REGNUM, &npc);
|
|
|
#ifdef OR32_SIM_DEBUG
|
#ifdef OR32_SIM_DEBUG
|
printf (" npc = 0x%08lx, resume_npc = 0x%08lx\n", npc, sd->resume_npc);
|
printf (" npc = 0x%08lx, resume_npc = 0x%08lx\n", npc, sd->resume_npc);
|
#endif
|
#endif
|
|
|
if (npc != sd->resume_npc)
|
if (npc != sd->resume_npc)
|
{
|
{
|
(void) or1ksim_write_reg (OR32_NPC_REGNUM, sd->resume_npc);
|
(void) or1ksim_write_reg (OR32_NPC_REGNUM, sd->resume_npc);
|
}
|
}
|
|
|
/* Unstall and run */
|
/* Unstall and run */
|
or1ksim_set_stall_state (0);
|
or1ksim_set_stall_state (0);
|
res = or1ksim_run (-1.0);
|
res = or1ksim_run (-1.0);
|
|
|
/* Determine the reason for stopping. If we hit a breakpoint, then the
|
/* Determine the reason for stopping. If we hit a breakpoint, then the
|
resumption NPC must be set to the PPC to allow re-execution of the
|
resumption NPC must be set to the PPC to allow re-execution of the
|
trapped instruction. */
|
trapped instruction. */
|
switch (res)
|
switch (res)
|
{
|
{
|
case OR1KSIM_RC_HALTED:
|
case OR1KSIM_RC_HALTED:
|
sd->last_reason = sim_exited;
|
sd->last_reason = sim_exited;
|
(void) or1ksim_read_reg (OR32_FIRST_ARG_REGNUM, &retval);
|
(void) or1ksim_read_reg (OR32_FIRST_ARG_REGNUM, &retval);
|
sd->last_rc = (unsigned int) retval;
|
sd->last_rc = (unsigned int) retval;
|
sd->resume_npc = OR32_RESET_EXCEPTION;
|
sd->resume_npc = OR32_RESET_EXCEPTION;
|
break;
|
break;
|
|
|
case OR1KSIM_RC_BRKPT:
|
case OR1KSIM_RC_BRKPT:
|
sd->last_reason = sim_stopped;
|
sd->last_reason = sim_stopped;
|
sd->last_rc = TARGET_SIGNAL_TRAP;
|
sd->last_rc = TARGET_SIGNAL_TRAP;
|
|
|
/* This could have been a breakpoint or single step. */
|
/* This could have been a breakpoint or single step. */
|
if (step)
|
if (step)
|
{
|
{
|
(void) or1ksim_read_reg (OR32_NPC_REGNUM, &(sd->resume_npc));
|
(void) or1ksim_read_reg (OR32_NPC_REGNUM, &(sd->resume_npc));
|
}
|
}
|
else
|
else
|
{
|
{
|
(void) or1ksim_read_reg (OR32_PPC_REGNUM, &(sd->resume_npc));
|
(void) or1ksim_read_reg (OR32_PPC_REGNUM, &(sd->resume_npc));
|
}
|
}
|
|
|
break;
|
break;
|
|
|
case OR1KSIM_RC_OK:
|
case OR1KSIM_RC_OK:
|
/* Should not happen */
|
/* Should not happen */
|
fprintf (stderr, "Ooops. Didn't expect OK return from Or1ksim.\n");
|
fprintf (stderr, "Ooops. Didn't expect OK return from Or1ksim.\n");
|
|
|
sd->last_reason = sim_running; /* Should trigger an error! */
|
sd->last_reason = sim_running; /* Should trigger an error! */
|
sd->last_rc = TARGET_SIGNAL_NONE;
|
sd->last_rc = TARGET_SIGNAL_NONE;
|
(void) or1ksim_read_reg (OR32_NPC_REGNUM, &(sd->resume_npc));
|
(void) or1ksim_read_reg (OR32_NPC_REGNUM, &(sd->resume_npc));
|
break;
|
break;
|
}
|
}
|
} /* sim_resume () */
|
} /* sim_resume () */
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
/*!Asynchronous request to stop the simulation.
|
/*!Asynchronous request to stop the simulation.
|
|
|
@param[in] sd Simulation descriptor from sim_open (). We don't use this.
|
@param[in] sd Simulation descriptor from sim_open (). We don't use this.
|
|
|
@return Non-zero indicates that the simulator is able to handle the
|
@return Non-zero indicates that the simulator is able to handle the
|
request. */
|
request. */
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
int sim_stop (SIM_DESC sd ATTRIBUTE_UNUSED)
|
int sim_stop (SIM_DESC sd ATTRIBUTE_UNUSED)
|
{
|
{
|
#ifdef OR32_SIM_DEBUG
|
#ifdef OR32_SIM_DEBUG
|
printf ("sim_stop called\n");
|
printf ("sim_stop called\n");
|
#endif
|
#endif
|
|
|
return 0; /* We don't support this */
|
return 0; /* We don't support this */
|
|
|
} /* sim_stop () */
|
} /* sim_stop () */
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
/*!Fetch the REASON why the program stopped.
|
/*!Fetch the REASON why the program stopped.
|
|
|
The reason enumeration indicates why:
|
The reason enumeration indicates why:
|
|
|
- sim_exited: The program has terminated. sigrc indicates the target
|
- sim_exited: The program has terminated. sigrc indicates the target
|
dependant exit status.
|
dependant exit status.
|
|
|
- sim_stopped: The program has stopped. sigrc uses the host's signal
|
- sim_stopped: The program has stopped. sigrc uses the host's signal
|
numbering as a way of identifying the reaon: program
|
numbering as a way of identifying the reaon: program
|
interrupted by user via a sim_stop request (SIGINT); a
|
interrupted by user via a sim_stop request (SIGINT); a
|
breakpoint instruction (SIGTRAP); a completed single step
|
breakpoint instruction (SIGTRAP); a completed single step
|
(SIGTRAP); an internal error condition (SIGABRT); an
|
(SIGTRAP); an internal error condition (SIGABRT); an
|
illegal instruction (SIGILL); Access to an undefined
|
illegal instruction (SIGILL); Access to an undefined
|
memory region (SIGSEGV); Mis-aligned memory access
|
memory region (SIGSEGV); Mis-aligned memory access
|
(SIGBUS).
|
(SIGBUS).
|
|
|
For some signals information in addition to the signal
|
For some signals information in addition to the signal
|
number may be retained by the simulator (e.g. offending
|
number may be retained by the simulator (e.g. offending
|
address), that information is not directly accessable via
|
address), that information is not directly accessable via
|
this interface.
|
this interface.
|
|
|
- sim_signalled: The program has been terminated by a signal. The
|
- sim_signalled: The program has been terminated by a signal. The
|
simulator has encountered target code that causes the the
|
simulator has encountered target code that causes the the
|
program to exit with signal sigrc.
|
program to exit with signal sigrc.
|
|
|
- sim_running:
|
- sim_running:
|
- sim_polling: The return of one of these values indicates a problem
|
- sim_polling: The return of one of these values indicates a problem
|
internal to the simulator.
|
internal to the simulator.
|
|
|
@param[in] sd Simulation descriptor from sim_open ().
|
@param[in] sd Simulation descriptor from sim_open ().
|
@param[out] reason The reason for stopping
|
@param[out] reason The reason for stopping
|
@param[out] sigrc Supplementary information for some values of reason. */
|
@param[out] sigrc Supplementary information for some values of reason. */
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
void
|
void
|
sim_stop_reason (SIM_DESC sd,
|
sim_stop_reason (SIM_DESC sd,
|
enum sim_stop *reason,
|
enum sim_stop *reason,
|
int *sigrc)
|
int *sigrc)
|
{
|
{
|
*reason = sd->last_reason;
|
*reason = sd->last_reason;
|
*sigrc = sd->last_rc;
|
*sigrc = sd->last_rc;
|
|
|
} /* sim_stop_reason () */
|
} /* sim_stop_reason () */
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
/* Passthru for other commands that the simulator might support.
|
/* Passthru for other commands that the simulator might support.
|
|
|
Simulators should be prepared to deal with any combination of NULL
|
Simulators should be prepared to deal with any combination of NULL
|
or empty command.
|
or empty command.
|
|
|
This implementation currently does nothing.
|
This implementation currently does nothing.
|
|
|
@param[in] sd Simulation descriptor from sim_open (). We don't use this.
|
@param[in] sd Simulation descriptor from sim_open (). We don't use this.
|
@param[in] cmd The command to pass through. */
|
@param[in] cmd The command to pass through. */
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
void
|
void
|
sim_do_command (SIM_DESC sd ATTRIBUTE_UNUSED,
|
sim_do_command (SIM_DESC sd ATTRIBUTE_UNUSED,
|
char *cmd ATTRIBUTE_UNUSED)
|
char *cmd ATTRIBUTE_UNUSED)
|
{
|
{
|
} /* sim_do_command () */
|
} /* sim_do_command () */
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
/* Set the default host_callback_struct
|
/* Set the default host_callback_struct
|
|
|
@note Deprecated, but implemented, since it is still required for linking.
|
@note Deprecated, but implemented, since it is still required for linking.
|
|
|
This implementation currently does nothing.
|
This implementation currently does nothing.
|
|
|
@param[in] ptr The host_callback_struct pointer. Unused here. */
|
@param[in] ptr The host_callback_struct pointer. Unused here. */
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
void
|
void
|
sim_set_callbacks (struct host_callback_struct *ptr ATTRIBUTE_UNUSED)
|
sim_set_callbacks (struct host_callback_struct *ptr ATTRIBUTE_UNUSED)
|
{
|
{
|
} /* sim_set_callbacks () */
|
} /* sim_set_callbacks () */
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
/* Set the size of the simulator memory array.
|
/* Set the size of the simulator memory array.
|
|
|
@note Deprecated, but implemented, since it is still required for linking.
|
@note Deprecated, but implemented, since it is still required for linking.
|
|
|
This implementation currently does nothing.
|
This implementation currently does nothing.
|
|
|
@param[in] size The memory size to use. Unused here. */
|
@param[in] size The memory size to use. Unused here. */
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
void
|
void
|
sim_size (int size ATTRIBUTE_UNUSED)
|
sim_size (int size ATTRIBUTE_UNUSED)
|
{
|
{
|
} /* sim_size () */
|
} /* sim_size () */
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
/* Single step the simulator with tracing enabled.
|
/* Single step the simulator with tracing enabled.
|
|
|
@note Deprecated, but implemented, since it is still required for linking.
|
@note Deprecated, but implemented, since it is still required for linking.
|
|
|
This implementation currently does nothing.
|
This implementation currently does nothing.
|
|
|
@param[in] sd The simulator description struct. Unused here. */
|
@param[in] sd The simulator description struct. Unused here. */
|
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
void
|
void
|
sim_trace (SIM_DESC sd ATTRIBUTE_UNUSED)
|
sim_trace (SIM_DESC sd ATTRIBUTE_UNUSED)
|
{
|
{
|
} /* sim_trace () */
|
} /* sim_trace () */
|
|
|