Line 1... |
Line 1... |
/* toplevel.c -- Top level simulator source file
|
/* toplevel.c -- Top level simulator source file
|
|
|
Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
|
Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
|
|
Copyright (C) 2008 Embecosm Limited
|
|
|
This file is part of OpenRISC 1000 Architectural Simulator.
|
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
|
|
This program is free software; you can redistribute it and/or modify
|
This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator.
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
|
|
/* Simulator commands. Help and version output. SIGINT processing.
|
This program is free software; you can redistribute it and/or modify it
|
Stdout redirection is specific to linux (I need to fix this). */
|
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)
|
|
any later version.
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
more details.
|
|
|
/* System includes */
|
You should have received a copy of the GNU General Public License along
|
|
with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
#include <unistd.h>
|
/* This program is commented throughout in a fashion suitable for processing
|
|
with Doxygen. */
|
|
|
/* All the autoconf includes */
|
|
|
|
|
/* Autoconf and/or portability configuration */
|
#include "config.h"
|
#include "config.h"
|
|
|
#ifdef HAVE_INTTYPES_H
|
/* System includes */
|
#include <inttypes.h>
|
#include <stdlib.h>
|
#endif
|
#include <unistd.h>
|
|
#include <signal.h>
|
|
|
/* Package includes */
|
/* Package includes */
|
|
|
#include "or1ksim.h"
|
|
|
|
#include "port.h"
|
|
#include "arch.h"
|
|
#include "abstract.h"
|
|
#include "sim-config.h"
|
#include "sim-config.h"
|
#include "opcode/or32.h"
|
#include "toplevel-support.h"
|
#include "spr_defs.h"
|
|
#include "execute.h"
|
#include "execute.h"
|
#include "debug_unit.h"
|
|
#include "vapi.h"
|
|
#include "gdbcomm.h"
|
|
#include "sched.h"
|
|
#include "profiler.h"
|
|
#include "mprofiler.h"
|
|
|
|
/* Support routines declared in toplevel_support.c */
|
|
|
|
extern void ctrl_c( int signum );
|
|
extern void recalc_do_stats( void );
|
|
extern void sim_init( void );
|
|
extern void sim_done( void );
|
|
extern void do_scheduler( void );
|
|
|
|
|
|
/* Main function */
|
/*---------------------------------------------------------------------------*/
|
int main( int argc,
|
/*!Main function
|
|
|
|
Set up the standalone simulation. Initialize the default configuration and
|
|
register all the sections that may appear in a user configuration.
|
|
|
|
Then attempt to parse the args, configure the system from any configuration
|
|
file specified and print out the configuration used.
|
|
|
|
Add a signal hander, so ctrl-C will drop the user into the CLI.
|
|
|
|
The initialize the simulator, call the appropriate main simulator function
|
|
and when it returns tidy up.
|
|
|
|
@param[in] argc The number of arguments to the command
|
|
@param[in] argv The vector of argument strings
|
|
|
|
@return The return code required from the simulator. This is actually
|
|
achieved by calling exit() with the return code, rather than
|
|
returning an explict value. */
|
|
/*---------------------------------------------------------------------------*/
|
|
int
|
|
main (int argc,
|
char *argv[] )
|
char *argv[] )
|
{
|
{
|
srand(getpid());
|
srand(getpid());
|
init_defconfig();
|
init_defconfig();
|
reg_config_secs();
|
reg_config_secs();
|
if (parse_args(argc, argv)) {
|
|
PRINTF("Usage: %s [options] <filename>\n", argv[0]);
|
|
PRINTF("Options:\n");
|
|
PRINTF(" -v version and copyright note\n");
|
|
PRINTF(" -i enable interactive command prompt\n");
|
|
PRINTF(" --nosrv do not launch JTAG proxy server\n"); /* (CZ) */
|
|
PRINTF(" --srv <n> launch JTAG proxy server on port <n>; [random]\n"); /* (CZ) */
|
|
PRINTF(" -f or --file load script file [sim.cfg]\n");
|
|
PRINTF(" -d <debug config> Enable debug channels\n");
|
|
PRINTF(" --enable-profile enable profiling.\n");
|
|
PRINTF(" --enable-mprofile enable memory profiling.\n");
|
|
PRINTF("\nor : %s ", argv[0]);
|
|
mp_help ();
|
|
PRINTF("\nor : %s ", argv[0]);
|
|
prof_help ();
|
|
exit(-1);
|
|
}
|
|
|
|
/* Read configuration file. */
|
if (parse_args (argc, argv))
|
if (!runtime.sim.script_file_specified)
|
{
|
read_script_file ("sim.cfg");
|
exit (-1); /* Parse args will have printed any messages */
|
|
|
/* Overide parameters with command line ones */
|
|
if (runtime.simcmd.profile) config.sim.profile = 1;
|
|
if (runtime.simcmd.mprofile) config.sim.mprofile = 1;
|
|
|
|
if (!runtime.sim.script_file_specified && config.sim.verbose) {
|
|
fprintf( stderr,
|
|
"WARNING: No config file read, assuming default configuration.\n");
|
|
}
|
}
|
|
|
config.ext.class_ptr = NULL; /* SystemC linkage disabled here. */
|
|
config.ext.read_up = NULL;
|
|
config.ext.write_up = NULL;
|
|
|
|
print_config();
|
print_config();
|
signal(SIGINT, ctrl_c);
|
signal(SIGINT, ctrl_c);
|
|
|
runtime.sim.hush = 1;
|
runtime.sim.hush = 1;
|
recalc_do_stats();
|
do_stats = config.cpu.superscalar ||
|
|
config.cpu.dependstats ||
|
|
config.sim.history ||
|
|
config.sim.exe_log;
|
|
|
sim_init ();
|
sim_init ();
|
|
|
#if DYNAMIC_EXECUTION
|
#if DYNAMIC_EXECUTION
|
dyn_main();
|
dyn_main();
|
#else
|
#else
|
exec_main();
|
exec_main();
|
#endif
|
#endif
|
|
|
sim_done();
|
sim_done();
|
|
exit (0);
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|