aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
Diffstat (limited to 'sim')
-rw-r--r--sim/arm/ChangeLog3
-rw-r--r--sim/common/.Sanitize1
-rw-r--r--sim/common/ChangeLog22
-rw-r--r--sim/common/Make-common.in117
-rw-r--r--sim/common/sim-config.c60
-rw-r--r--sim/common/sim-config.h3
-rw-r--r--sim/common/sim-utils.c52
-rw-r--r--sim/common/sim-utils.h70
-rw-r--r--sim/d10v/ChangeLog4
-rw-r--r--sim/d10v/interp.c18
-rw-r--r--sim/erc32/ChangeLog6
-rw-r--r--sim/h8300/ChangeLog5
-rw-r--r--sim/h8300/compile.c16
-rw-r--r--sim/m32r/ChangeLog6
-rw-r--r--sim/m32r/Makefile.in86
-rw-r--r--sim/m32r/sim-if.c30
-rw-r--r--sim/mips/ChangeLog11
-rw-r--r--sim/mips/Makefile.in43
-rw-r--r--sim/mips/interp.c197
-rw-r--r--sim/mn10300/ChangeLog3
-rw-r--r--sim/ppc/ChangeLog4
-rw-r--r--sim/ppc/sim_calls.c19
-rw-r--r--sim/sh/ChangeLog3
-rw-r--r--sim/sh/interp.c8
-rw-r--r--sim/tic80/ChangeLog10
-rw-r--r--sim/tic80/Makefile.in1
-rw-r--r--sim/tic80/sim-calls.c41
-rw-r--r--sim/v850/ChangeLog3
-rw-r--r--sim/v850/interp.c8
-rw-r--r--sim/w65/ChangeLog1
-rw-r--r--sim/w65/interp.c12
31 files changed, 553 insertions, 310 deletions
diff --git a/sim/arm/ChangeLog b/sim/arm/ChangeLog
index d71637f..9b78e9e 100644
--- a/sim/arm/ChangeLog
+++ b/sim/arm/ChangeLog
@@ -1,6 +1,9 @@
Tue Aug 26 10:37:27 1997 Andrew Cagney <cagney@b1.cygnus.com>
* wrapper.c (sim_kill): Delete.
+ (sim_create_inferior): Add ABFD argument.
+ (sim_load): Move setting of PC from here.
+ (sim_create_inferior): To here.
Mon Aug 25 17:50:22 1997 Andrew Cagney <cagney@b1.cygnus.com>
diff --git a/sim/common/.Sanitize b/sim/common/.Sanitize
index d5deb38..8687f1d 100644
--- a/sim/common/.Sanitize
+++ b/sim/common/.Sanitize
@@ -64,6 +64,7 @@ sim-events.c
sim-events.h
sim-fpu.c
sim-fpu.h
+sim-hload.c
sim-inline.c
sim-inline.h
sim-io.c
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index b4dd678..9693743 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,25 @@
+Wed Aug 27 11:55:35 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * sim-utils.c (sim_analyze_program): Add prog_name argument.
+ Update STATE_PROG_BFD when needed with a dup'd copy of the
+ program.
+
+ * sim-config.c (sim_config): Delete ABFD argument, use
+ STATE_PROG_BFD directly.
+
+Tue Aug 26 12:55:26 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * run.c (main): Pass the open ABFD to sim_create_inferior.
+
+ * nrun.c (main): Determine prog_bfd. Pass to sim_create_inferior
+ and sim_load.
+ (bfd.h): Include.
+
+ * sim-hload.c (sim_load): New file. Implement generic sim_load for
+ hardware only simulator targets.
+
+ * Make-common.in (sim-hload.o): Add rule.
+
Wed Aug 27 09:51:42 1997 Andrew Cagney <cagney@b1.cygnus.com>
* sim-utils.c (sim_copy_argv): Rewrite to match malloc strategy
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 7db8ba7..4e15424 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -132,7 +132,7 @@ all: libsim.a run $(SIM_EXTRA_ALL)
libsim.a: $(LIB_OBJS)
rm -f libsim.a
- $(AR) $(ARFLAGS) libsim.a $(LIB_OBJS)
+ $(AR) $(AR_FLAGS) libsim.a $(LIB_OBJS)
$(RANLIB) libsim.a
run: $(SIM_RUN_OBJS) libsim.a $(LIBDEPS)
@@ -181,6 +181,9 @@ sim_main_headers = \
$(srcdir)/../common/sim-trace.h \
$(srcdir)/../common/sim-profile.h \
$(srcdir)/../common/sim-engine.h \
+ $(srcdir)/../common/sim-events.h \
+ $(srcdir)/../common/sim-watch.h \
+ $(srcdir)/../common/sim-assert.h \
tconfig.h
sim-assert_h = $(srcdir)/../common/sim-assert.h
@@ -209,69 +212,41 @@ BUILT_SRC_FROM_COMMON= \
sim-config.c \
sim-io.c
-sim-abort.o: sim-abort.c \
+sim-abort.o: $(srcdir)/../common/sim-abort.c \
$(SIM_EXTRA_DEPS)
-sim-abort.c: $(srcdir)/../common/sim-abort.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-abort.c $(ALL_CFLAGS)
-sim-bits.o: sim-bits.c $(sim-bits_h) $(sim-n-bits_h) $(sim-assert_h) \
+sim-bits.o: $(srcdir)/../common/sim-bits.c $(sim-bits_h) $(sim-n-bits_h) \
$(SIM_EXTRA_DEPS)
-sim-bits.c: $(srcdir)/../common/sim-bits.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-bits.c $(ALL_CFLAGS)
-sim-config.o: sim-config.c $(sim-config_h) $(sim-nconfig_h) $(sim-assert_h) \
+sim-config.o: $(srcdir)/../common/sim-config.c $(sim-config_h) $(sim-nconfig_h) \
$(SIM_EXTRA_DEPS)
-sim-config.c: $(srcdir)/../common/sim-config.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-config.c $(ALL_CFLAGS)
-sim-core.o: sim-core.c $(sim-core_h) $(sim-n-core_h) \
+sim-core.o: $(srcdir)/../common/sim-core.c $(sim-core_h) $(sim-n-core_h) \
$(SIM_EXTRA_DEPS)
-sim-core.c: $(srcdir)/../common/sim-core.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-core.c $(ALL_CFLAGS)
-sim-endian.o: sim-endian.c $(sim-endian_h) $(sim-n-endian_h) $(sim-assert_h) \
+sim-endian.o: $(srcdir)/../common/sim-endian.c $(sim-endian_h) $(sim-n-endian_h) \
$(SIM_EXTRA_DEPS)
-sim-endian.c: $(srcdir)/../common/sim-endian.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-endian.c $(ALL_CFLAGS)
-sim-engine.o: sim-engine.c $(sim_main_headers) $(sim-engine_h) $(sim-assert_h) \
+sim-engine.o: $(srcdir)/../common/sim-engine.c $(sim_main_headers) $(sim-engine_h) \
$(SIM_EXTRA_DEPS)
-sim-engine.c: $(srcdir)/../common/sim-engine.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-engine.c $(ALL_CFLAGS)
-sim-events.o: sim-events.c $(sim-events_h) $(sim-assert_h) \
+sim-events.o: $(srcdir)/../common/sim-events.c $(sim-events_h) \
$(SIM_EXTRA_DEPS)
-sim-events.c: $(srcdir)/../common/sim-events.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-events.c $(ALL_CFLAGS)
-sim-fpu.o: sim-fpu.c $(sim-fpu_h) $(sim-assert_h) \
+sim-fpu.o: $(srcdir)/../common/sim-fpu.c $(sim-fpu_h) \
$(SIM_EXTRA_DEPS)
-sim-fpu.c: $(srcdir)/../common/sim-fpu.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-fpu.c $(ALL_CFLAGS)
+
+sim-hload.o: $(srcdir)/../common/sim-hload.c $(sim-assert_h) \
+ $(SIM_EXTRA_DEPS)
+ $(CC) -c $(srcdir)/../common/sim-hload.c $(ALL_CFLAGS)
sim-inline.c: $(srcdir)/../common/sim-inline.c
rm -f $@ tmp-$@
@@ -279,13 +254,9 @@ sim-inline.c: $(srcdir)/../common/sim-inline.c
cat $(srcdir)/../common/$@ >> tmp-$@
$(srcdir)/../../move-if-change tmp-$@ $@
-sim-io.o: sim-io.c $(sim_main_headers) $(sim-io_h) $(sim-assert_h) \
+sim-io.o: $(srcdir)/../common/sim-io.c $(sim_main_headers) $(sim-io_h) \
$(SIM_EXTRA_DEPS)
-sim-io.c: $(srcdir)/../common/sim-io.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-io.c $(ALL_CFLAGS)
sim-module.o: $(srcdir)/../common/sim-module.c $(sim_main_headers) \
$(sim-io_h) $(SIM_EXTRA_DEPS)
@@ -295,37 +266,21 @@ sim-options.o: $(srcdir)/../common/sim-options.c $(sim_main_headers) \
$(sim-options_h) $(sim-io_h) $(SIM_EXTRA_DEPS)
$(CC) -c $(srcdir)/../common/sim-options.c $(ALL_CFLAGS)
-sim-reason.o: sim-reason.c $(sim_main_headers) $(sim-assert_h) \
+sim-reason.o: $(srcdir)/../common/sim-reason.c $(sim_main_headers) \
$(SIM_EXTRA_DEPS)
-sim-reason.c: $(srcdir)/../common/sim-reason.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-reason.c $(ALL_CFLAGS)
-sim-resume.o: sim-resume.c $(sim_main_headers) $(sim-assert_h) \
+sim-resume.o: $(srcdir)/../common/sim-resume.c $(sim_main_headers) \
$(SIM_EXTRA_DEPS)
-sim-resume.c: $(srcdir)/../common/sim-resume.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-resume.c $(ALL_CFLAGS)
-sim-run.o: sim-run.c $(sim_main_headers) $(sim-assert_h) \
+sim-run.o: $(srcdir)/../common/sim-run.c $(sim_main_headers) \
$(SIM_EXTRA_DEPS)
-sim-run.c: $(srcdir)/../common/sim-run.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-run.c $(ALL_CFLAGS)
-sim-stop.o: sim-stop.c $(sim_main_headers) $(sim-assert_h) \
+sim-stop.o: $(srcdir)/../common/sim-stop.c $(sim_main_headers) \
$(SIM_EXTRA_DEPS)
-sim-stop.c: $(srcdir)/../common/sim-stop.c
- rm -f $@ tmp-$@
- echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
- cat $(srcdir)/../common/$@ >> tmp-$@
- $(srcdir)/../../move-if-change tmp-$@ $@
+ $(CC) -c $(srcdir)/../common/sim-stop.c $(ALL_CFLAGS)
sim-trace.o: $(srcdir)/../common/sim-trace.c $(sim_main_headers) \
$(sim-options_h) $(sim-io_h) $(SIM_EXTRA_DEPS)
@@ -343,6 +298,10 @@ sim-utils.o: $(srcdir)/../common/sim-utils.c $(sim_main_headers) \
$(SIM_EXTRA_DEPS)
$(CC) -c $(srcdir)/../common/sim-utils.c $(ALL_CFLAGS)
+sim-watch.o: $(srcdir)/../common/sim-watch.c $(sim_main_headers) \
+ $(SIM_EXTRA_DEPS)
+ $(CC) -c $(srcdir)/../common/sim-watch.c $(ALL_CFLAGS)
+
sim-load.o: $(srcdir)/../common/sim-load.c
$(CC) -c $(srcdir)/../common/sim-load.c $(ALL_CFLAGS)
diff --git a/sim/common/sim-config.c b/sim/common/sim-config.c
index 5f2efc3..04ad95f 100644
--- a/sim/common/sim-config.c
+++ b/sim/common/sim-config.c
@@ -132,45 +132,15 @@ config_floating_point_to_a (int floating_point)
SIM_RC
-sim_config (SIM_DESC sd,
- struct _bfd *abfd)
+sim_config (SIM_DESC sd)
{
int prefered_target_byte_order;
- /* clone the bfd struct (or open prog_name directly) */
- {
- const char *prog_name;
- if (STATE_PROG_ARGV (sd) == NULL)
- {
- if (abfd != NULL)
- prog_name = bfd_get_filename (abfd);
- else
- prog_name = NULL;
- }
- else
- prog_name = *STATE_PROG_ARGV (sd);
- if (prog_name != NULL)
- {
- abfd = bfd_openr (prog_name, 0);
- if (abfd == NULL)
- {
- sim_io_eprintf (sd, "%s: can't open \"%s\": %s\n",
- STATE_MY_NAME (sd),
- prog_name,
- bfd_errmsg (bfd_get_error ()));
- return SIM_RC_FAIL;
- }
- STATE_PROG_BFD (sd) = abfd;
- }
- else
- STATE_PROG_BFD (sd) = NULL;
- }
-
/* extract all relevant information */
- if (abfd == NULL)
+ if (STATE_PROG_BFD (sd) == NULL)
prefered_target_byte_order = 0;
else
- prefered_target_byte_order = (bfd_little_endian(abfd)
+ prefered_target_byte_order = (bfd_little_endian(STATE_PROG_BFD (sd))
? LITTLE_ENDIAN
: BIG_ENDIAN);
@@ -210,16 +180,16 @@ sim_config (SIM_DESC sd,
/* verify the target byte order */
if (CURRENT_TARGET_BYTE_ORDER == 0)
{
- sim_io_eprintf (sd, "target byte order unspecified");
+ sim_io_eprintf (sd, "Target byte order unspecified\n");
return SIM_RC_FAIL;
}
if (CURRENT_TARGET_BYTE_ORDER != current_target_byte_order)
- sim_io_eprintf (sd, "target (%s) and configured (%s) byte order in conflict",
+ sim_io_eprintf (sd, "Target (%s) and configured (%s) byte order in conflict\n",
config_byte_order_to_a (current_target_byte_order),
config_byte_order_to_a (CURRENT_TARGET_BYTE_ORDER));
if (prefered_target_byte_order != 0
&& CURRENT_TARGET_BYTE_ORDER != prefered_target_byte_order)
- sim_io_eprintf (sd, "target (%s) and specified (%s) byte order in conflict",
+ sim_io_eprintf (sd, "Target (%s) and specified (%s) byte order in conflict\n",
config_byte_order_to_a (CURRENT_TARGET_BYTE_ORDER),
config_byte_order_to_a (prefered_target_byte_order));
@@ -233,12 +203,12 @@ sim_config (SIM_DESC sd,
/* verify the stdio */
if (CURRENT_STDIO == 0)
{
- sim_io_eprintf (sd, "target standard IO unspecified");
+ sim_io_eprintf (sd, "Target standard IO unspecified\n");
return SIM_RC_FAIL;
}
if (CURRENT_STDIO != current_stdio)
{
- sim_io_eprintf (sd, "target (%s) and configured (%s) standard IO in conflict",
+ sim_io_eprintf (sd, "Target (%s) and configured (%s) standard IO in conflict\n",
config_stdio_to_a (CURRENT_STDIO),
config_stdio_to_a (current_stdio));
return SIM_RC_FAIL;
@@ -249,7 +219,7 @@ sim_config (SIM_DESC sd,
if (WITH_TARGET_WORD_MSB != 0
&& WITH_TARGET_WORD_MSB != (WITH_TARGET_WORD_BITSIZE - 1))
{
- sim_io_eprintf (sd, "target bitsize (%d) contradicts target most significant bit (%d)",
+ sim_io_eprintf (sd, "Target bitsize (%d) contradicts target most significant bit (%d)\n",
WITH_TARGET_WORD_BITSIZE, WITH_TARGET_WORD_MSB);
return SIM_RC_FAIL;
}
@@ -281,12 +251,12 @@ sim_config (SIM_DESC sd,
/* verify the environment */
if (CURRENT_ENVIRONMENT == 0)
{
- sim_io_eprintf (sd, "target environment unspecified");
+ sim_io_eprintf (sd, "Target environment unspecified\n");
return SIM_RC_FAIL;
}
if (CURRENT_ENVIRONMENT != current_environment)
{
- sim_io_eprintf (sd, "target (%s) and configured (%s) environment in conflict",
+ sim_io_eprintf (sd, "Target (%s) and configured (%s) environment in conflict\n",
config_environment_to_a (CURRENT_ENVIRONMENT),
config_environment_to_a (current_environment));
return SIM_RC_FAIL;
@@ -310,12 +280,12 @@ sim_config (SIM_DESC sd,
/* verify the alignment */
if (CURRENT_ALIGNMENT == 0)
{
- sim_io_eprintf (sd, "target alignment unspecified");
+ sim_io_eprintf (sd, "Target alignment unspecified\n");
return SIM_RC_FAIL;
}
if (CURRENT_ALIGNMENT != current_alignment)
{
- sim_io_eprintf (sd, "target (%s) and configured (%s) alignment in conflict",
+ sim_io_eprintf (sd, "Target (%s) and configured (%s) alignment in conflict\n",
config_alignment_to_a (CURRENT_ALIGNMENT),
config_alignment_to_a (current_alignment));
return SIM_RC_FAIL;
@@ -332,12 +302,12 @@ sim_config (SIM_DESC sd,
/* verify the floating point */
if (CURRENT_FLOATING_POINT == 0)
{
- sim_io_eprintf (sd, "target floating-point unspecified");
+ sim_io_eprintf (sd, "Target floating-point unspecified\n");
return SIM_RC_FAIL;
}
if (CURRENT_FLOATING_POINT != current_floating_point)
{
- sim_io_eprintf (sd, "target (%s) and configured (%s) floating-point in conflict",
+ sim_io_eprintf (sd, "Target (%s) and configured (%s) floating-point in conflict\n",
config_alignment_to_a (CURRENT_FLOATING_POINT),
config_alignment_to_a (current_floating_point));
return SIM_RC_FAIL;
diff --git a/sim/common/sim-config.h b/sim/common/sim-config.h
index 157eb1d..59a8c37 100644
--- a/sim/common/sim-config.h
+++ b/sim/common/sim-config.h
@@ -546,8 +546,7 @@ extern int current_stdio;
/* complete/verify/print the simulator configuration */
extern SIM_RC sim_config
-(SIM_DESC sd,
- struct _bfd *abfd);
+(SIM_DESC sd);
extern void print_sim_config (SIM_DESC sd);
diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c
index e0432f8..a0b582d 100644
--- a/sim/common/sim-utils.c
+++ b/sim/common/sim-utils.c
@@ -119,9 +119,7 @@ char **
sim_copy_argv (argv)
char **argv;
{
- int i;
int argc;
- int len;
char **copy;
if (argv == NULL)
@@ -149,16 +147,56 @@ sim_copy_argv (argv)
return copy;
}
-/* Analyze a bfd and set various fields in the state struct. */
+/* Analyze a prog_name/prog_bfd and set various fields in the state
+ struct. */
-void
-sim_analyze_program (sd, prog_bfd)
+SIM_RC
+sim_analyze_program (sd, prog_name, prog_bfd)
SIM_DESC sd;
+ char *prog_name;
bfd *prog_bfd;
{
asection *s;
-
SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
+
+ if (prog_bfd != NULL)
+ {
+ if (prog_bfd == STATE_PROG_BFD (sd))
+ /* already analyzed */
+ return SIM_RC_OK;
+ else
+ /* duplicate needed, save the name of the file to be re-opened */
+ prog_name = bfd_get_filename (prog_bfd);
+ }
+
+ /* do we need to duplicate anything? */
+ if (prog_name == NULL)
+ return SIM_RC_OK;
+
+ /* open a new copy of the prog_bfd */
+ prog_bfd = bfd_openr (prog_name, 0);
+ if (prog_bfd == NULL)
+ {
+ sim_io_eprintf (sd, "%s: can't open \"%s\": %s\n",
+ STATE_MY_NAME (sd),
+ prog_name,
+ bfd_errmsg (bfd_get_error ()));
+ return SIM_RC_FAIL;
+ }
+ if (!bfd_check_format (prog_bfd, bfd_object))
+ {
+ sim_io_eprintf (sd, "%s: \"%s\" is not an object file: %s\n",
+ STATE_MY_NAME (sd),
+ prog_name,
+ bfd_errmsg (bfd_get_error ()));
+ bfd_close (prog_bfd);
+ return SIM_RC_FAIL;
+ }
+
+
+ /* update the sim structure */
+ if (STATE_PROG_BFD (sd) != NULL)
+ bfd_close (STATE_PROG_BFD (sd));
STATE_PROG_BFD (sd) = prog_bfd;
STATE_START_ADDR (sd) = bfd_get_start_address (prog_bfd);
@@ -170,6 +208,8 @@ sim_analyze_program (sd, prog_bfd)
STATE_TEXT_END (sd) = STATE_TEXT_START (sd) + bfd_section_size (prog_bfd, s);
break;
}
+
+ return SIM_RC_OK;
}
/* Simulator timing support. */
diff --git a/sim/common/sim-utils.h b/sim/common/sim-utils.h
new file mode 100644
index 0000000..5fc3efd
--- /dev/null
+++ b/sim/common/sim-utils.h
@@ -0,0 +1,70 @@
+/* Miscellaneous simulator utilities.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ Contributed by Cygnus Support.
+
+This file is part of GDB, the GNU debugger.
+
+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 Software Foundation; either version 2, 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.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef SIM_UTILS_H
+#define SIM_UTILS_H
+
+/* Memory management with an allocator that clears memory before use. */
+
+void *zalloc (unsigned long size);
+
+#define ZALLOC(TYPE) (TYPE*)zalloc(sizeof (TYPE))
+
+void zfree(void*);
+
+/* Turn VALUE into a string with commas. */
+char *sim_add_commas (char *, int, unsigned long);
+
+/* Utilities for elapsed time reporting. */
+
+/* Opaque type, known only inside sim_elapsed_time_foo fns. */
+typedef unsigned long SIM_ELAPSED_TIME;
+
+/* Get reference point for future call to sim_time_elapsed. */
+SIM_ELAPSED_TIME sim_elapsed_time_get (void);
+
+/* Elapsed time in milliseconds since START. */
+unsigned long sim_elapsed_time_since (SIM_ELAPSED_TIME start);
+
+/* Utilities for manipulating the load image. */
+
+SIM_RC sim_analyze_program (SIM_DESC sd, char *prog_name,
+ struct _bfd *prog_bfd);
+
+char **sim_copy_argv (char **argv);
+
+/* Load program PROG into the simulator.
+ If PROG_BFD is non-NULL, the file has already been opened.
+ If VERBOSE_P is non-zero statistics are printed of each loaded section
+ and the transfer rate (for consistency with gdb).
+ If this fails an error message is printed and NULL is returned.
+ If it succeeds the bfd is returned. */
+
+struct _bfd *sim_load_file (SIM_DESC sd, const char *myname,
+ host_callback *callback, char *prog,
+ struct _bfd *prog_bfd, int verbose_p);
+
+/* These are defined in callback.c as cover functions to the vprintf
+ callbacks. */
+
+void sim_cb_printf (host_callback *, const char *, ...);
+void sim_cb_eprintf (host_callback *, const char *, ...);
+
+#endif
diff --git a/sim/d10v/ChangeLog b/sim/d10v/ChangeLog
index b535424..1c315db 100644
--- a/sim/d10v/ChangeLog
+++ b/sim/d10v/ChangeLog
@@ -1,6 +1,10 @@
Tue Aug 26 10:37:49 1997 Andrew Cagney <cagney@b1.cygnus.com>
* interp.c (sim_kill): Delete.
+ (sim_create_inferior): Add ABFD argument.
+ (sim_load): Move setting of PC from here.
+ (sim_create_inferior): To here.
+ (start_address): Delete variable.
Mon Aug 25 17:50:22 1997 Andrew Cagney <cagney@b1.cygnus.com>
diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c
index 0add87a..5dfb100 100644
--- a/sim/d10v/interp.c
+++ b/sim/d10v/interp.c
@@ -14,7 +14,6 @@ enum _leftright { LEFT_FIRST, RIGHT_FIRST };
static char *myname;
static SIM_OPEN_KIND sim_kind;
-static bfd_vma start_address;
int d10v_debug;
host_callback *d10v_callback;
unsigned long ins_type_counters[ (int)INS_MAX ];
@@ -797,20 +796,26 @@ sim_info (sd, verbose)
}
SIM_RC
-sim_create_inferior (sd, argv, env)
+sim_create_inferior (sd, abfd, argv, env)
SIM_DESC sd;
+ struct _bfd *abfd;
char **argv;
char **env;
{
-#ifdef DEBUG
- if (d10v_debug)
- (*d10v_callback->printf_filtered) (d10v_callback, "sim_create_inferior: PC=0x%x\n", start_address);
-#endif
+ bfd_vma start_address;
/* reset all state information */
memset (&State.regs, 0, (int)&State.imem - (int)&State.regs[0]);
/* set PC */
+ if (abfd != NULL)
+ start_address = bfd_get_start_address (prog_bfd);
+ else
+ start_address = 0xffc0 << 2;
+#ifdef DEBUG
+ if (d10v_debug)
+ (*d10v_callback->printf_filtered) (d10v_callback, "sim_create_inferior: PC=0x%lx\n", (long) start_address);
+#endif
PC = start_address >> 2;
/* cpu resets imap0 to 0 and imap1 to 0x7f, but D10V-EVA board */
@@ -924,7 +929,6 @@ sim_load (sd, prog, abfd, from_tty)
sim_kind == SIM_OPEN_DEBUG);
if (prog_bfd == NULL)
return SIM_RC_FAIL;
- start_address = bfd_get_start_address (prog_bfd);
prog_bfd_was_opened_p = abfd == NULL;
return SIM_RC_OK;
}
diff --git a/sim/erc32/ChangeLog b/sim/erc32/ChangeLog
index 9841d32..a357458 100644
--- a/sim/erc32/ChangeLog
+++ b/sim/erc32/ChangeLog
@@ -1,6 +1,12 @@
Tue Aug 26 10:38:20 1997 Andrew Cagney <cagney@b1.cygnus.com>
+ * float.c (__setfpucw): Compile on any i386 target. Not just NT.
+
* interf.c (sim_kill): Delete.
+ (sim_create_inferior): Add ABFD argument. Initialize PC from ABFD
+ argument.
+ (sim_load): Don't save start address.
+ (start_address): Delete variable.
Mon Aug 25 17:50:22 1997 Andrew Cagney <cagney@b1.cygnus.com>
diff --git a/sim/h8300/ChangeLog b/sim/h8300/ChangeLog
index 47b8e22..920424b 100644
--- a/sim/h8300/ChangeLog
+++ b/sim/h8300/ChangeLog
@@ -1,6 +1,11 @@
Tue Aug 26 10:38:43 1997 Andrew Cagney <cagney@b1.cygnus.com>
* compile.c (sim_kill): Delete.
+ (sim_create_inferior): Add ABFD argument.
+ (sim_load): Move setting of PC from here.
+ (sim_create_inferior): To here.
+ (sim_open, sim_load, set_h8300h): Add fixme explaining why much of
+ the sim_load code should be moved to sim_open.
Mon Aug 25 17:50:22 1997 Andrew Cagney <cagney@b1.cygnus.com>
diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c
index 370fe4605..08dbbcc 100644
--- a/sim/h8300/compile.c
+++ b/sim/h8300/compile.c
@@ -2009,6 +2009,9 @@ void
set_h8300h (flag)
int flag;
{
+ /* FIXME: Much of the code in sim_load can be moved to sim_open.
+ This function being replaced by a sim_open:ARGV configuration
+ option */
h8300hmode = flag;
}
@@ -2019,6 +2022,8 @@ sim_open (kind, ptr, abfd, argv)
struct _bfd *abfd;
char **argv;
{
+ /* FIXME: Much of the code in sim_load can be moved here */
+
sim_kind = kind;
myname = argv[0];
sim_callback = ptr;
@@ -2045,6 +2050,9 @@ sim_load (sd, prog, abfd, from_tty)
{
bfd *prog_bfd;
+ /* FIXME: The code below that sets a specific variant of the h8/300
+ being simulated should be moved to sim_open(). */
+
/* See if the file is for the h8/300 or h8/300h. */
/* ??? This may not be the most efficient way. The z8k simulator
does this via a different mechanism (INIT_EXTRA_SYMTAB_INFO). */
@@ -2109,7 +2117,6 @@ sim_load (sd, prog, abfd, from_tty)
return SIM_RC_FAIL;
}
- cpu.pc = bfd_get_start_address (prog_bfd);
/* Close the bfd if we opened it. */
if (abfd == NULL && prog_bfd != NULL)
bfd_close (prog_bfd);
@@ -2117,11 +2124,16 @@ sim_load (sd, prog, abfd, from_tty)
}
SIM_RC
-sim_create_inferior (sd, argv, env)
+sim_create_inferior (sd, abfd, argv, env)
SIM_DESC sd;
+ struct _bfd *abfd;
char **argv;
char **env;
{
+ if (abfd != NULL)
+ cpu.pc = bfd_get_start_address (abfd);
+ else
+ cpu.pc = 0;
return SIM_RC_OK;
}
diff --git a/sim/m32r/ChangeLog b/sim/m32r/ChangeLog
index 7d17acb..242fdd1 100644
--- a/sim/m32r/ChangeLog
+++ b/sim/m32r/ChangeLog
@@ -1,6 +1,12 @@
Tue Aug 26 10:39:42 1997 Andrew Cagney <cagney@b1.cygnus.com>
* sim-if.c (sim_kill): Delete.
+ (sim_create_inferior): Add ABFD argument.
+ (sim_load): Move setting of PC from here.
+ (sim_create_inferior): To here.
+ (sim_load): Delete, use sim-hload.c instead.
+
+ * Makefile.in (SIM_OBJS): Add sim-hload.o module.
Mon Aug 25 17:50:22 1997 Andrew Cagney <cagney@b1.cygnus.com>
diff --git a/sim/m32r/Makefile.in b/sim/m32r/Makefile.in
new file mode 100644
index 0000000..3870f19
--- /dev/null
+++ b/sim/m32r/Makefile.in
@@ -0,0 +1,86 @@
+# Makefile template for Configure for the m32r simulator
+# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+# Contributed by Cygnus Support.
+#
+# This file is part of GDB, the GNU debugger.
+#
+# 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 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.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+## COMMON_PRE_CONFIG_FRAG
+
+SIM_OBJS = sim-if.o m32r.o mainloop.o \
+ decode.o extract.o semantics.o seman-cache.o model.o \
+ sim-io.o sim-utils.o sim-load.o sim-abort.o sim-watch.o \
+ sim-module.o sim-options.o sim-trace.o sim-profile.o sim-model.o \
+ sim-core.o sim-events.o sim-endian.o sim-bits.o sim-config.o \
+ sim-hload.o \
+ cgen-utils.o cgen-trace.o cgen-scache.o
+
+# Extra headers included by sim-main.h.
+SIM_EXTRA_DEPS = \
+ $(srcdir)/../common/cgen-types.h \
+ $(srcdir)/../common/cgen-sim.h \
+ $(srcdir)/../common/cgen-trace.h \
+ arch-defs.h
+
+SIM_ENDIAN = @sim_endian@
+SIM_HOSTENDIAN = @sim_hostendian@
+SIM_SCACHE = @sim_scache@
+SIM_DEFAULT_MODEL = @sim_default_model@
+SIM_EXTRA_CFLAGS = \
+ $(SIM_ENDIAN) $(SIM_HOSTENDIAN) \
+ $(SIM_SCACHE) $(SIM_DEFAULT_MODEL)
+
+SIM_RUN_OBJS = nrun.o
+SIM_EXTRA_CLEAN = m32r-clean
+
+## COMMON_POST_CONFIG_FRAG
+
+CPU = m32r
+MAIN_INCLUDE_DEPS = \
+ sim-main.h \
+ $(srcdir)/../common/sim-config.h \
+ $(srcdir)/../common/sim-base.h \
+ $(srcdir)/../common/sim-basics.h \
+ $(srcdir)/../common/sim-module.h \
+ $(srcdir)/../common/sim-trace.h \
+ $(srcdir)/../common/sim-profile.h \
+ tconfig.h
+INCLUDE_DEPS = $(MAIN_INCLUDE_DEPS) $(SIM_EXTRA_DEPS) cpu-sim.h
+OPS_INCLUDE_DEPS = mem-ops.h sem-ops.h
+
+sim-if.o: sim-if.c $(INCLUDE_DEPS) $(srcdir)/../common/sim-core.h
+m32r.o: m32r.c $(INCLUDE_DEPS) $(OPS_INCLUDE_DEPS)
+
+# FIXME: Use of `mono' is wip.
+mainloop.c: $(srcdir)/../common/genmloop.sh mainloop.in
+ rm -f mainloop.c
+ $(SHELL) $(srcdir)/../common/genmloop.sh mono $(CPU) $(srcdir)/mainloop.in >mainloop.c
+mainloop.o: mainloop.c sem-switch.c $(INCLUDE_DEPS) $(OPS_INCLUDE_DEPS) \
+ $(srcdir)/../common/cgen-scache.h
+
+decode.o: decode.c decode.h $(INCLUDE_DEPS) $(OPS_INCLUDE_DEPS) cpu-opc.h
+extract.o: extract.c decode.h $(INCLUDE_DEPS) $(OPS_INCLUDE_DEPS)
+semantics.o: semantics.c decode.h $(INCLUDE_DEPS) $(OPS_INCLUDE_DEPS)
+model.o: model.c $(INCLUDE_DEPS) cpu-opc.h
+
+# wip
+#extr-cache.o: extract.c $(INCLUDE_DEPS) $(OPS_INCLUDE_DEPS)
+# $(CC) -c $(srcdir)/extract.c -o extr-cache.o -DSCACHE_P $(ALL_CFLAGS)
+seman-cache.o: semantics.c decode.h $(INCLUDE_DEPS) $(OPS_INCLUDE_DEPS)
+ $(CC) -c $(srcdir)/semantics.c -o seman-cache.o -DSCACHE_P $(ALL_CFLAGS)
+
+m32r-clean:
+ rm -f mainloop.c
diff --git a/sim/m32r/sim-if.c b/sim/m32r/sim-if.c
index 7f4e102..a273347 100644
--- a/sim/m32r/sim-if.c
+++ b/sim/m32r/sim-if.c
@@ -100,31 +100,9 @@ sim_close (sd, quitting)
}
SIM_RC
-sim_load (sd, prog, abfd, from_tty)
- SIM_DESC sd;
- char *prog;
- bfd *abfd;
- int from_tty;
-{
- extern bfd *sim_load_file (); /* ??? Don't know where this should live. */
- bfd *prog_bfd;
-
- prog_bfd = sim_load_file (sd, STATE_MY_NAME (sd),
- STATE_CALLBACK (sd),
- prog,
- /* pass NULL for abfd, we always open our own */
- NULL,
- STATE_OPEN_KIND (sd) == SIM_OPEN_DEBUG);
- if (prog_bfd == NULL)
- return SIM_RC_FAIL;
- sim_analyze_program (sd, prog_bfd);
- STATE_CPU_CPU (sd, 0)->pc = STATE_START_ADDR (sd);
- return SIM_RC_OK;
-}
-
-SIM_RC
-sim_create_inferior (sd, argv, envp)
+sim_create_inferior (sd, abfd, argv, envp)
SIM_DESC sd;
+ struct _bfd *abfd;
char **argv;
char **envp;
{
@@ -132,6 +110,10 @@ sim_create_inferior (sd, argv, envp)
STATE_ARGV (sd) = sim_copy_argv (argv);
STATE_ENVP (sd) = sim_copy_argv (envp);
#endif
+ if (abfd != NULL)
+ STATE_CPU_CPU (sd, 0)->pc = bfd_get_start_address (abfd);
+ else
+ STATE_CPU_CPU (sd, 0)->pc = 0;
return SIM_RC_OK;
}
diff --git a/sim/mips/ChangeLog b/sim/mips/ChangeLog
index b7ee324..93859ad 100644
--- a/sim/mips/ChangeLog
+++ b/sim/mips/ChangeLog
@@ -1,6 +1,17 @@
+Wed Aug 27 14:12:27 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * interp.c (sim_open): Add call to sim_analyze_program, update
+ call to sim_config.
+
Tue Aug 26 10:40:07 1997 Andrew Cagney <cagney@b1.cygnus.com>
* interp.c (sim_kill): Delete.
+ (sim_create_inferior): Add ABFD argument. Set PC from same.
+ (sim_load): Move code initializing trap handlers from here.
+ (sim_open): To here.
+ (sim_load): Delete, use sim-hload.c.
+
+ * Makefile.in (SIM_OBJS): Add sim-hload.o module.
Mon Aug 25 17:50:22 1997 Andrew Cagney <cagney@b1.cygnus.com>
diff --git a/sim/mips/Makefile.in b/sim/mips/Makefile.in
index 31ef4f5..e5f97e7 100644
--- a/sim/mips/Makefile.in
+++ b/sim/mips/Makefile.in
@@ -3,15 +3,52 @@
## COMMON_PRE_CONFIG_FRAG
-SIM_OBJS = interp.o
+srcdir=@srcdir@
+srcroot=$(srcdir)/../../
+
+SIM_OBJS = interp.o \
+ sim-load.o \
+ sim-utils.o \
+ sim-hload.o \
+ sim-io.o \
+ sim-config.o \
+ sim-endian.o \
+ sim-engine.o \
+ sim-stop.o \
+ sim-resume.o \
+ sim-reason.o \
+ sim-events.o \
+ sim-module.o \
+ sim-trace.o \
+ sim-options.o \
+ sim-core.o \
+ sim-watch.o
+
+# List of flags to always pass to $(CC).
+SIM_WARNINGS=@sim_warnings@
+SIM_ENDIAN=@sim_endian@
+SIM_HOSTENDIAN=@sim_hostendian@
+SIM_INLINE=@sim_inline@
+
# FIXME: Hack to find syscall.h? Better support for syscall.h
# is in progress.
-SIM_EXTRA_CFLAGS = -I$(srcdir)/../../newlib/libc/sys/idt
+SIM_EXTRA_CFLAGS = \
+ $(SIM_WARNINGS) \
+ $(SIM_ENDIAN) \
+ $(SIM_HOSTENDIAN) \
+ $(SIM_INLINE) \
+ -I$(srcdir)/../../newlib/libc/sys/idt
+
SIM_EXTRA_CLEAN = clean-extra
+# List of main object files for `run'.
+SIM_RUN_OBJS = nrun.o
+
+
+
## COMMON_POST_CONFIG_FRAG
-interp.o: interp.c engine.c support.h config.h
+interp.o: $(srcdir)/interp.c engine.c $(srcdir)/support.h config.h
engine.c: gencode
./gencode @SIMCONF@ > $@
diff --git a/sim/mips/interp.c b/sim/mips/interp.c
index 0ff5df8..6ace9e3 100644
--- a/sim/mips/interp.c
+++ b/sim/mips/interp.c
@@ -820,9 +820,20 @@ sim_open (kind, cb, abfd, argv)
return 0;
}
+ /* check for/establish the a reference program image */
+ if (sim_analyze_program (sd,
+ (STATE_PROG_ARGV (sd) != NULL
+ ? *STATE_PROG_ARGV (sd)
+ : NULL),
+ abfd) != SIM_RC_OK)
+ {
+ sim_module_uninstall (sd);
+ return 0;
+ }
+
/* Configure/verify the target byte order and other runtime
configuration options */
- if (sim_config (sd, abfd) != SIM_RC_OK)
+ if (sim_config (sd) != SIM_RC_OK)
{
sim_module_uninstall (sd);
return 0;
@@ -921,6 +932,82 @@ sim_open (kind, cb, abfd, argv)
open_trace();
#endif /* TRACE */
+ /* Write the monitor trap address handlers into the monitor (eeprom)
+ address space. This can only be done once the target endianness
+ has been determined. */
+ {
+ unsigned loop;
+ /* Entry into the IDT monitor is via fixed address vectors, and
+ not using machine instructions. To avoid clashing with use of
+ the MIPS TRAP system, we place our own (simulator specific)
+ "undefined" instructions into the relevant vector slots. */
+ for (loop = 0; (loop < monitor_size); loop += 4) {
+ uword64 vaddr = (monitor_base + loop);
+ uword64 paddr;
+ int cca;
+ if (AddressTranslation(vaddr, isDATA, isSTORE, &paddr, &cca, isTARGET, isRAW))
+ StoreMemory(cca, AccessLength_WORD,
+ (RSVD_INSTRUCTION | (((loop >> 2) & RSVD_INSTRUCTION_ARG_MASK) << RSVD_INSTRUCTION_ARG_SHIFT)),
+ 0, paddr, vaddr, isRAW);
+ }
+ /* The PMON monitor uses the same address space, but rather than
+ branching into it the address of a routine is loaded. We can
+ cheat for the moment, and direct the PMON routine to IDT style
+ instructions within the monitor space. This relies on the IDT
+ monitor not using the locations from 0xBFC00500 onwards as its
+ entry points.*/
+ for (loop = 0; (loop < 24); loop++)
+ {
+ uword64 vaddr = (monitor_base + 0x500 + (loop * 4));
+ uword64 paddr;
+ int cca;
+ unsigned int value = ((0x500 - 8) / 8); /* default UNDEFINED reason code */
+ switch (loop)
+ {
+ case 0: /* read */
+ value = 7;
+ break;
+
+ case 1: /* write */
+ value = 8;
+ break;
+
+ case 2: /* open */
+ value = 6;
+ break;
+
+ case 3: /* close */
+ value = 10;
+ break;
+
+ case 5: /* printf */
+ value = ((0x500 - 16) / 8); /* not an IDT reason code */
+ break;
+
+ case 8: /* cliexit */
+ value = 17;
+ break;
+
+ case 11: /* flush_cache */
+ value = 28;
+ break;
+ }
+ /* FIXME - should monitor_base be SIM_ADDR?? */
+ value = ((unsigned int)monitor_base + (value * 8));
+ if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&cca,isTARGET,isRAW))
+ StoreMemory(cca,AccessLength_WORD,value,0,paddr,vaddr,isRAW);
+ else
+ sim_error("Failed to write to monitor space 0x%s",pr_addr(vaddr));
+
+ /* The LSI MiniRISC PMON has its vectors at 0x200, not 0x500. */
+ vaddr -= 0x300;
+ if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&cca,isTARGET,isRAW))
+ StoreMemory(cca,AccessLength_WORD,value,0,paddr,vaddr,isRAW);
+ else
+ sim_error("Failed to write to monitor space 0x%s",pr_addr(vaddr));
+ }
+ }
+
return sd;
}
@@ -1308,108 +1395,11 @@ sim_info (sd,verbose)
}
}
-SIM_RC
-sim_load (sd,prog,abfd,from_tty)
- SIM_DESC sd;
- char *prog;
- bfd *abfd;
- int from_tty;
-{
- bfd *prog_bfd;
-
- prog_bfd = sim_load_file (sd,
- STATE_MY_NAME (sd),
- callback,
- prog,
- /* pass NULL for abfd, we always open our own */
- NULL,
- STATE_OPEN_KIND (sd) == SIM_OPEN_DEBUG);
- if (prog_bfd == NULL)
- return SIM_RC_FAIL;
- sim_analyze_program (sd, prog_bfd);
-
- /* (re) Write the monitor trap address handlers into the monitor
- (eeprom) address space. This can only be done once the target
- endianness has been determined. */
- {
- unsigned loop;
- /* Entry into the IDT monitor is via fixed address vectors, and
- not using machine instructions. To avoid clashing with use of
- the MIPS TRAP system, we place our own (simulator specific)
- "undefined" instructions into the relevant vector slots. */
- for (loop = 0; (loop < monitor_size); loop += 4) {
- uword64 vaddr = (monitor_base + loop);
- uword64 paddr;
- int cca;
- if (AddressTranslation(vaddr, isDATA, isSTORE, &paddr, &cca, isTARGET, isRAW))
- StoreMemory(cca, AccessLength_WORD,
- (RSVD_INSTRUCTION | (((loop >> 2) & RSVD_INSTRUCTION_ARG_MASK) << RSVD_INSTRUCTION_ARG_SHIFT)),
- 0, paddr, vaddr, isRAW);
- }
- /* The PMON monitor uses the same address space, but rather than
- branching into it the address of a routine is loaded. We can
- cheat for the moment, and direct the PMON routine to IDT style
- instructions within the monitor space. This relies on the IDT
- monitor not using the locations from 0xBFC00500 onwards as its
- entry points.*/
- for (loop = 0; (loop < 24); loop++)
- {
- uword64 vaddr = (monitor_base + 0x500 + (loop * 4));
- uword64 paddr;
- int cca;
- unsigned int value = ((0x500 - 8) / 8); /* default UNDEFINED reason code */
- switch (loop)
- {
- case 0: /* read */
- value = 7;
- break;
-
- case 1: /* write */
- value = 8;
- break;
-
- case 2: /* open */
- value = 6;
- break;
-
- case 3: /* close */
- value = 10;
- break;
-
- case 5: /* printf */
- value = ((0x500 - 16) / 8); /* not an IDT reason code */
- break;
-
- case 8: /* cliexit */
- value = 17;
- break;
-
- case 11: /* flush_cache */
- value = 28;
- break;
- }
- /* FIXME - should monitor_base be SIM_ADDR?? */
- value = ((unsigned int)monitor_base + (value * 8));
- if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&cca,isTARGET,isRAW))
- StoreMemory(cca,AccessLength_WORD,value,0,paddr,vaddr,isRAW);
- else
- sim_error("Failed to write to monitor space 0x%s",pr_addr(vaddr));
-
- /* The LSI MiniRISC PMON has its vectors at 0x200, not 0x500. */
- vaddr -= 0x300;
- if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&cca,isTARGET,isRAW))
- StoreMemory(cca,AccessLength_WORD,value,0,paddr,vaddr,isRAW);
- else
- sim_error("Failed to write to monitor space 0x%s",pr_addr(vaddr));
- }
- }
-
- return SIM_RC_OK;
-}
SIM_RC
-sim_create_inferior (sd, argv,env)
+sim_create_inferior (sd, abfd, argv,env)
SIM_DESC sd;
+ struct _bfd *abfd;
char **argv;
char **env;
{
@@ -1426,10 +1416,13 @@ sim_create_inferior (sd, argv,env)
patterns (e.g. simulating ROM monitors). */
#if 1
- PC = (uword64) STATE_START_ADDR(sd);
+ if (abfd != NULL)
+ PC = (unsigned64) bfd_get_start_address(abfd);
+ else
+ PC = 0; /* ???? */
#else
/* TODO: Sort this properly. SIM_ADDR may already be a 64bit value: */
- PC = SIGNEXTEND(bfd_get_start_address(prog_bfd),32);
+ PC = SIGNEXTEND(bfd_get_start_address(abfd),32);
#endif
/* Prepare to execute the program to be simulated */
diff --git a/sim/mn10300/ChangeLog b/sim/mn10300/ChangeLog
index 2ccb40c..3a1cae7 100644
--- a/sim/mn10300/ChangeLog
+++ b/sim/mn10300/ChangeLog
@@ -1,6 +1,9 @@
Tue Aug 26 10:41:07 1997 Andrew Cagney <cagney@b1.cygnus.com>
* interp.c (sim_kill): Delete.
+ (sim_create_inferior): Add ABFD argument.
+ (sim_load): Move setting of PC from here.
+ (sim_create_inferior): To here.
Mon Aug 25 17:50:22 1997 Andrew Cagney <cagney@b1.cygnus.com>
diff --git a/sim/ppc/ChangeLog b/sim/ppc/ChangeLog
index 1b6ad7c..9efa7a8 100644
--- a/sim/ppc/ChangeLog
+++ b/sim/ppc/ChangeLog
@@ -11,6 +11,10 @@ Wed Aug 27 10:15:48 1997 Andrew Cagney <cagney@b1.cygnus.com>
Tue Aug 26 10:41:35 1997 Andrew Cagney <cagney@b1.cygnus.com>
* sim_calls.c (sim_kill): Delete.
+ (sim_create_inferior): Add ABFD argument.
+ (entry_point): Delete variable.
+ (sim_load): Move setting of PC from here.
+ (sim_create_inferior): To here.
Mon Aug 25 16:17:06 1997 Andrew Cagney <cagney@b1.cygnus.com>
diff --git a/sim/ppc/sim_calls.c b/sim/ppc/sim_calls.c
index 228b7c7..7b6c4d4 100644
--- a/sim/ppc/sim_calls.c
+++ b/sim/ppc/sim_calls.c
@@ -53,10 +53,6 @@ static device *root_device;
static const char *register_names[] = REGISTER_NAMES;
static host_callback *callbacks;
-/* For communication between sim_load and sim_create_inferior.
- This can be made to go away, please do. */
-static unsigned_word entry_point;
-
SIM_DESC
sim_open (SIM_OPEN_KIND kind,
host_callback *callback,
@@ -114,9 +110,7 @@ sim_load (SIM_DESC sd, char *prog, bfd *abfd, int from_tty)
psim_init(simulator);
/* get the start address */
- if (abfd != NULL)
- entry_point = bfd_get_start_address (abfd);
- else
+ if (abfd == NULL)
{
abfd = bfd_openr (argv[0], 0);
if (abfd == NULL)
@@ -129,7 +123,6 @@ sim_load (SIM_DESC sd, char *prog, bfd *abfd, int from_tty)
error ("psim: \"%s\" is not an object file: %s\n",
argv[0], errmsg);
}
- entry_point = bfd_get_start_address (abfd);
bfd_close (abfd);
}
@@ -199,10 +192,18 @@ sim_info (SIM_DESC sd, int verbose)
SIM_RC
-sim_create_inferior (SIM_DESC sd, char **argv, char **envp)
+sim_create_inferior (SIM_DESC sd,
+ struct _bfd *abfd,
+ char **argv,
+ char **envp)
{
+ unsigned_word entry_point;
TRACE(trace_gdb, ("sim_create_inferior(start_address=0x%x, ...)\n",
entry_point));
+ if (abfd != NULL)
+ entry_point = bfd_get_start_address (abfd);
+ else
+ entry_point = 0xfff00000; /* ??? */
psim_init(simulator);
psim_stack(simulator, argv, envp);
diff --git a/sim/sh/ChangeLog b/sim/sh/ChangeLog
index 7eed84e..d1a38ba 100644
--- a/sim/sh/ChangeLog
+++ b/sim/sh/ChangeLog
@@ -1,6 +1,9 @@
Tue Aug 26 10:41:55 1997 Andrew Cagney <cagney@b1.cygnus.com>
* interp.c (sim_kill): Delete.
+ (sim_create_inferior): Add ABFD argument.
+ (sim_load): Move setting of PC from here.
+ (sim_create_inferior): To here.
Mon Aug 25 17:50:22 1997 Andrew Cagney <cagney@b1.cygnus.com>
diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index d9ae631..da50d24 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -1242,18 +1242,22 @@ sim_load (sd, prog, abfd, from_tty)
sim_kind == SIM_OPEN_DEBUG);
if (prog_bfd == NULL)
return SIM_RC_FAIL;
- saved_state.asregs.pc = bfd_get_start_address (prog_bfd);
if (abfd == NULL)
bfd_close (prog_bfd);
return SIM_RC_OK;
}
SIM_RC
-sim_create_inferior (sd, argv, env)
+sim_create_inferior (sd, abfd, argv, env)
SIM_DESC sd;
+ struct _bfd *abfd;
char **argv;
char **env;
{
+ if (abfd != NULL)
+ saved_state.asregs.pc = bfd_get_start_address (abfd);
+ else
+ saved_state.asregs.pc = 0;
return SIM_RC_OK;
}
diff --git a/sim/tic80/ChangeLog b/sim/tic80/ChangeLog
index 76c95b7..2d18e39 100644
--- a/sim/tic80/ChangeLog
+++ b/sim/tic80/ChangeLog
@@ -1,6 +1,14 @@
-Tue Aug 26 10:42:13 1997 Andrew Cagney <cagney@b1.cygnus.com>
+Wed Aug 27 13:41:24 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * sim-calls.c (sim_open): Add call to sim_analyze_program, update
+ call to sim_config.
* sim-calls.c (sim_kill): Delete.
+ (sim_create_inferior): Add ABFD argument. Initialize PC from ABFD
+ and not SD.
+ (sim_load): Delete, use sim-hload.c.
+
+ * Makefile.in (SIM_OBJS): Add sim-hload.o module.
Mon Aug 25 17:50:22 1997 Andrew Cagney <cagney@b1.cygnus.com>
diff --git a/sim/tic80/Makefile.in b/sim/tic80/Makefile.in
index 605418f..570f208 100644
--- a/sim/tic80/Makefile.in
+++ b/sim/tic80/Makefile.in
@@ -15,6 +15,7 @@ SIM_OBJS = sim-endian.o sim-bits.o sim-config.o \
sim-calls.o \
sim-events.o \
sim-core.o \
+ sim-hload.o \
sim-io.o \
sim-utils.o \
sim-load.o \
diff --git a/sim/tic80/sim-calls.c b/sim/tic80/sim-calls.c
index b6f6620..095ddf1 100644
--- a/sim/tic80/sim-calls.c
+++ b/sim/tic80/sim-calls.c
@@ -74,8 +74,19 @@ sim_open (SIM_OPEN_KIND kind,
return 0;
}
- /* establish the simulator configuration */
- if (sim_config (sd, abfd) != SIM_RC_OK)
+ /* check for/establish the a reference program image */
+ if (sim_analyze_program (sd,
+ (STATE_PROG_ARGV (sd) != NULL
+ ? *STATE_PROG_ARGV (sd)
+ : NULL),
+ abfd) != SIM_RC_OK)
+ {
+ sim_module_uninstall (sd);
+ return 0;
+ }
+
+ /* establish any remaining configuration options */
+ if (sim_config (sd) != SIM_RC_OK)
{
sim_module_uninstall (sd);
return 0;
@@ -126,24 +137,6 @@ sim_close (SIM_DESC sd, int quitting)
}
-SIM_RC
-sim_load (SIM_DESC sd, char *prog, bfd *abfd, int from_tty)
-{
- bfd *prog_bfd;
-
- prog_bfd = sim_load_file (sd, STATE_MY_NAME (sd),
- STATE_CALLBACK (sd),
- prog,
- /* pass NULL for abfd, we always open our own */
- NULL,
- STATE_OPEN_KIND (sd) == SIM_OPEN_DEBUG);
- if (prog_bfd == NULL)
- return SIM_RC_FAIL;
- sim_analyze_program (sd, prog_bfd);
- return SIM_RC_OK;
-}
-
-
int
sim_read (SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)
{
@@ -217,11 +210,15 @@ sim_info (SIM_DESC sd, int verbose)
SIM_RC
sim_create_inferior (SIM_DESC sd,
+ struct _bfd *abfd,
char **argv,
char **envp)
{
- STATE_CPU (sd, 0)->cia.ip = STATE_START_ADDR(sd);
- STATE_CPU (sd, 0)->cia.dp = (STATE_START_ADDR(sd)
+ if (abfd != NULL)
+ STATE_CPU (sd, 0)->cia.ip = bfd_get_start_address (abfd);
+ else
+ STATE_CPU (sd, 0)->cia.ip = 0;
+ STATE_CPU (sd, 0)->cia.dp = (STATE_CPU (sd, 0)->cia.ip
+ sizeof (instruction_word));
STATE_CPU (sd, 0)->cr[IE_CR] |= IE_CR_IE;
STATE_CPU (sd, 0)->reg[1] = TIC80_MEM_START + TIC80_MEM_SIZE - 16;
diff --git a/sim/v850/ChangeLog b/sim/v850/ChangeLog
index ccc876d..b6400b8 100644
--- a/sim/v850/ChangeLog
+++ b/sim/v850/ChangeLog
@@ -1,6 +1,9 @@
Tue Aug 26 10:42:38 1997 Andrew Cagney <cagney@b1.cygnus.com>
* interp.c (sim_kill): Delete.
+ (sim_create_inferior): Add ABFD argument.
+ (sim_load): Move setting of PC from here.
+ (sim_create_inferior): To here.
Mon Aug 25 17:50:22 1997 Andrew Cagney <cagney@b1.cygnus.com>
diff --git a/sim/v850/interp.c b/sim/v850/interp.c
index b98a64c..387b6dc 100644
--- a/sim/v850/interp.c
+++ b/sim/v850/interp.c
@@ -663,11 +663,16 @@ sim_info (sd, verbose)
}
SIM_RC
-sim_create_inferior (sd, argv, env)
+sim_create_inferior (sd, abfd, argv, env)
SIM_DESC sd;
+ struct _bfd *abfd;
char **argv;
char **env;
{
+ if (abfd == NULL)
+ PC = bfd_get_start_address (prog_bfd);
+ else
+ PC = 0; /* ??? */
return SIM_RC_OK;
}
@@ -917,7 +922,6 @@ sim_load (sd, prog, abfd, from_tty)
sim_kind == SIM_OPEN_DEBUG);
if (prog_bfd == NULL)
return SIM_RC_FAIL;
- PC = bfd_get_start_address (prog_bfd);
prog_bfd_was_opened_p = abfd == NULL;
return SIM_RC_OK;
}
diff --git a/sim/w65/ChangeLog b/sim/w65/ChangeLog
index 5f42c3b..ecc66ed 100644
--- a/sim/w65/ChangeLog
+++ b/sim/w65/ChangeLog
@@ -1,6 +1,7 @@
Tue Aug 26 10:43:11 1997 Andrew Cagney <cagney@b1.cygnus.com>
* interp.c (sim_kill): Delete.
+ (sim_create_inferior): Add ABFD argument. Set PC from same.
Mon Aug 25 16:34:33 1997 Andrew Cagney <cagney@b1.cygnus.com>
diff --git a/sim/w65/interp.c b/sim/w65/interp.c
index f2080de..6416b25 100644
--- a/sim/w65/interp.c
+++ b/sim/w65/interp.c
@@ -360,14 +360,18 @@ sim_load (prog, from_tty)
void
-sim_create_inferior (start_address, argv, env)
- SIM_ADDR start_address;
+sim_create_inferior (abfd, argv, env)
+ struct _bfd *abfd;
char **argv;
char **env;
{
- /* ??? We assume this is a 4 byte quantity. */
+ SIM_ADDR start_address;
int pc;
-
+ if (abfd != NULL)
+ start_address = bfd_get_start_address (abfd);
+ else
+ start_address = 0; /*??*/
+ /* ??? We assume this is a 4 byte quantity. */
pc = start_address;
sim_store_register (16, (unsigned char *) &pc);
}