Add real SIM_DESC arg to v850 simulator.
Add --enable-sim-warnings, use/fix errors. Add --enable-sim-endian, don't use. Add common modules. Don't yet use most.
This commit is contained in:
parent
80c651f02d
commit
9cdd2c6d72
@ -1,3 +1,69 @@
|
||||
Wed Sep 3 10:18:55 1997 Andrew Cagney <cagney@b1.cygnus.com>
|
||||
|
||||
* simops.c (utime.h): Include if available.
|
||||
(OP_10007E0): Check for UTIME function.
|
||||
(divun): Put parentheses around shift argument.
|
||||
(OP_640): Put parentheses around shift argument, was wrong.
|
||||
(OP_107F0): Return something.
|
||||
|
||||
* interp.c (sim_parse_number): Use strtoul not strtol.
|
||||
(sim_resume): Use sim_elapsed_time_get to keep track of the time.
|
||||
|
||||
* configure.in (SIM_AC_OPTION_WARNINGS): Add.
|
||||
(SIM_AC_OPTION_ENDIAN): Set to hardwired big.
|
||||
(SIM_AC_OPTION_HOST_ENDIAN): Add.
|
||||
(AC_CHECK_FUNCS): Add utime.
|
||||
(AC_CHECK_HEADERS): Add stdlib.h, string.h, strings.h, utime.h
|
||||
configure: Regenerate.
|
||||
|
||||
|
||||
* Makefile.in (SIM_RUN_OBJS): Use nrun.o.
|
||||
(SIM_OBJS): Add sim-io.o, sim-hload.o, sim-utils.o, sim-options.o,
|
||||
sim-config.o, sim-module.o, sim-events.o, sim-core.o,
|
||||
sim-endian.o, sim-engine.o, sim-trace.o, sim-profile.o
|
||||
(SIM_ENDIAN, SIM_WARNGINS): Define.
|
||||
|
||||
* simops.c (OP_10007E0): Use sim_io_* for transfers.
|
||||
|
||||
* interp.c (sim_resume): Pass sd around.
|
||||
|
||||
* simops.c (sim-main.h): Include.
|
||||
|
||||
* gencode.c (write_template): Generate #include sim-main.h.
|
||||
(write_opcodes): Ditto.
|
||||
|
||||
* interp.c (prog_bfd, prog_bfd_was_opened_p): Delete.
|
||||
(v850_callback): Ditto.
|
||||
(sim_kind, myname): Ditto.
|
||||
(lookup_hash): Pass SD. Use sim_io_error.
|
||||
(sim_set_memory_map): Pass in SD, use.
|
||||
(init_system): Pass in SD, use.
|
||||
(sim_open): Update.
|
||||
(sim_set_profile): Delete.
|
||||
(sim_set_profile_size): Delete.
|
||||
(do_interrupt): Pass in SD, use.
|
||||
(sim_info): Use sim_io_printf.
|
||||
(sim_create_inferior): Reset registers. Set PC from prog_bfd
|
||||
argument.
|
||||
(sim_load): Delete, use common/sim-hload.c
|
||||
(sim_size): Rename to sim_memory_init.
|
||||
(sim_write): Remove call to init_system.
|
||||
(init_system): Delete.
|
||||
(sim_set_callbacks): Delete.
|
||||
(sim_set_interrupt): Pass in SD, use.
|
||||
(start_time): Delete.
|
||||
|
||||
* v850_sim.h: Remove everything except `struct simops' from here.
|
||||
* sim-main.h: Move most to here.
|
||||
* gencode.c: Move #includes to here.
|
||||
|
||||
* sim-main.h(struct _sim_cpu): Rename struct _state.
|
||||
(#define PC, et.al.): Update
|
||||
(v850_callback): Delete. Replaced with SIM_DESC arg.
|
||||
(int8, uint8, int16, uint16, int32, uint32): Define types using
|
||||
unsigned8 et.al from common/sim-types.h.
|
||||
* sim-main.h (State): Define as STATE_CPU.
|
||||
|
||||
Mon Sep 1 12:07:55 1997 Andrew Cagney <cagney@b1.cygnus.com>
|
||||
|
||||
* configure.in: Check for time, chmod.
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Makefile template for Configure for the V850 sim library.
|
||||
# Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
||||
# Written by Cygnus Support.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
@ -16,13 +16,37 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
SIM_OBJS = interp.o table.o simops.o
|
||||
SIM_EXTRA_CFLAGS = -I$(srcdir)/../../newlib/libc/sys/sysnecv850
|
||||
## COMMON_PRE_CONFIG_FRAG
|
||||
|
||||
SIM_OBJS = interp.o table.o simops.o \
|
||||
sim-config.o \
|
||||
sim-core.o \
|
||||
sim-engine.o \
|
||||
sim-endian.o \
|
||||
sim-events.o \
|
||||
sim-hload.o \
|
||||
sim-io.o \
|
||||
sim-load.o \
|
||||
sim-module.o \
|
||||
sim-options.o \
|
||||
sim-profile.o \
|
||||
sim-trace.o \
|
||||
sim-utils.o
|
||||
SIM_RUN_OBJS = nrun.o
|
||||
|
||||
# List of flags to always pass to $(CC)
|
||||
SIM_WARNINGS=@sim_warnings@
|
||||
SIM_ENDIAN=@sim_endian@
|
||||
SIM_HOSTENDIAN=@sim_hostendian@
|
||||
SIM_EXTRA_CFLAGS = -I$(srcdir)/../../newlib/libc/sys/sysnecv850 \
|
||||
$(SIM_WARNINGS) \
|
||||
$(SIM_ENDIAN) \
|
||||
$(SIM_HOSTENDIAN)
|
||||
SIM_EXTRA_CLEAN = clean-extra
|
||||
|
||||
INCLUDE = v850_sim.h $(srcdir)/../../include/callback.h
|
||||
|
||||
@COMMON_MAKEFILE_FRAG@
|
||||
## COMMON_POST_CONFIG_FRAG
|
||||
|
||||
simops.h: gencode
|
||||
./gencode -h >$@
|
||||
|
244
sim/v850/configure
vendored
244
sim/v850/configure
vendored
@ -23,6 +23,12 @@ ac_help="$ac_help
|
||||
--enable-sim-trace=opts Enable tracing flags"
|
||||
ac_help="$ac_help
|
||||
--enable-sim-profile=opts Enable profiling flags"
|
||||
ac_help="$ac_help
|
||||
--enable-sim-endian=endian Specify target byte endian orientation."
|
||||
ac_help="$ac_help
|
||||
--enable-sim-hostendain=end Specify host byte endian orientation."
|
||||
ac_help="$ac_help
|
||||
--enable-sim-warnings=opts Extra CFLAGS for turning on compiler warnings"
|
||||
|
||||
# Initialize some variables set by options.
|
||||
# The variables have the same names as the options, with
|
||||
@ -532,7 +538,7 @@ fi
|
||||
|
||||
|
||||
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
|
||||
echo "configure:536: checking how to run the C preprocessor" >&5
|
||||
echo "configure:542: checking how to run the C preprocessor" >&5
|
||||
# On Suns, sometimes $CPP names a directory.
|
||||
if test -n "$CPP" && test -d "$CPP"; then
|
||||
CPP=
|
||||
@ -547,13 +553,13 @@ else
|
||||
# On the NeXT, cc -E runs the code through the compiler's parser,
|
||||
# not just through cpp.
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 551 "configure"
|
||||
#line 557 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <assert.h>
|
||||
Syntax Error
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:557: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:563: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out`
|
||||
if test -z "$ac_err"; then
|
||||
:
|
||||
@ -564,13 +570,13 @@ else
|
||||
rm -rf conftest*
|
||||
CPP="${CC-cc} -E -traditional-cpp"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 568 "configure"
|
||||
#line 574 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <assert.h>
|
||||
Syntax Error
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:574: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:580: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out`
|
||||
if test -z "$ac_err"; then
|
||||
:
|
||||
@ -643,7 +649,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
|
||||
fi
|
||||
|
||||
echo $ac_n "checking host system type""... $ac_c" 1>&6
|
||||
echo "configure:647: checking host system type" >&5
|
||||
echo "configure:653: checking host system type" >&5
|
||||
|
||||
host_alias=$host
|
||||
case "$host_alias" in
|
||||
@ -664,7 +670,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
|
||||
echo "$ac_t""$host" 1>&6
|
||||
|
||||
echo $ac_n "checking target system type""... $ac_c" 1>&6
|
||||
echo "configure:668: checking target system type" >&5
|
||||
echo "configure:674: checking target system type" >&5
|
||||
|
||||
target_alias=$target
|
||||
case "$target_alias" in
|
||||
@ -682,7 +688,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
|
||||
echo "$ac_t""$target" 1>&6
|
||||
|
||||
echo $ac_n "checking build system type""... $ac_c" 1>&6
|
||||
echo "configure:686: checking build system type" >&5
|
||||
echo "configure:692: checking build system type" >&5
|
||||
|
||||
build_alias=$build
|
||||
case "$build_alias" in
|
||||
@ -726,7 +732,7 @@ test "$program_transform_name" = "" && program_transform_name="s,x,x,"
|
||||
# Extract the first word of "gcc", so it can be a program name with args.
|
||||
set dummy gcc; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:730: checking for $ac_word" >&5
|
||||
echo "configure:736: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -755,7 +761,7 @@ if test -z "$CC"; then
|
||||
# Extract the first word of "cc", so it can be a program name with args.
|
||||
set dummy cc; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:759: checking for $ac_word" >&5
|
||||
echo "configure:765: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -803,7 +809,7 @@ fi
|
||||
fi
|
||||
|
||||
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
|
||||
echo "configure:807: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
|
||||
echo "configure:813: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
|
||||
|
||||
ac_ext=c
|
||||
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
|
||||
@ -813,11 +819,11 @@ ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS
|
||||
cross_compiling=$ac_cv_prog_cc_cross
|
||||
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 817 "configure"
|
||||
#line 823 "configure"
|
||||
#include "confdefs.h"
|
||||
main(){return(0);}
|
||||
EOF
|
||||
if { (eval echo configure:821: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
if { (eval echo configure:827: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
ac_cv_prog_cc_works=yes
|
||||
# If we can't run a trivial program, we are probably using a cross compiler.
|
||||
if (./conftest; exit) 2>/dev/null; then
|
||||
@ -837,12 +843,12 @@ if test $ac_cv_prog_cc_works = no; then
|
||||
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
|
||||
fi
|
||||
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
|
||||
echo "configure:841: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
|
||||
echo "configure:847: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
|
||||
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
|
||||
cross_compiling=$ac_cv_prog_cc_cross
|
||||
|
||||
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
|
||||
echo "configure:846: checking whether we are using GNU C" >&5
|
||||
echo "configure:852: checking whether we are using GNU C" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -851,7 +857,7 @@ else
|
||||
yes;
|
||||
#endif
|
||||
EOF
|
||||
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:855: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
|
||||
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:861: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
|
||||
ac_cv_prog_gcc=yes
|
||||
else
|
||||
ac_cv_prog_gcc=no
|
||||
@ -866,7 +872,7 @@ if test $ac_cv_prog_gcc = yes; then
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS=
|
||||
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
|
||||
echo "configure:870: checking whether ${CC-cc} accepts -g" >&5
|
||||
echo "configure:876: checking whether ${CC-cc} accepts -g" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -904,7 +910,7 @@ fi
|
||||
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
|
||||
# ./install, which can be erroneously created by make from ./install.sh.
|
||||
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
|
||||
echo "configure:908: checking for a BSD compatible install" >&5
|
||||
echo "configure:914: checking for a BSD compatible install" >&5
|
||||
if test -z "$INSTALL"; then
|
||||
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
@ -969,7 +975,7 @@ AR=${AR-ar}
|
||||
# Extract the first word of "ranlib", so it can be a program name with args.
|
||||
set dummy ranlib; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:973: checking for $ac_word" >&5
|
||||
echo "configure:979: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -1003,17 +1009,17 @@ for ac_hdr in stdlib.h string.h strings.h unistd.h time.h sys/time.h sys/resourc
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||
echo "configure:1007: checking for $ac_hdr" >&5
|
||||
echo "configure:1013: checking for $ac_hdr" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1012 "configure"
|
||||
#line 1018 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <$ac_hdr>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:1017: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:1023: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out`
|
||||
if test -z "$ac_err"; then
|
||||
rm -rf conftest*
|
||||
@ -1042,12 +1048,12 @@ done
|
||||
for ac_func in getrusage time
|
||||
do
|
||||
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
|
||||
echo "configure:1046: checking for $ac_func" >&5
|
||||
echo "configure:1052: checking for $ac_func" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1051 "configure"
|
||||
#line 1057 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func(); below. */
|
||||
@ -1070,7 +1076,7 @@ $ac_func();
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1074: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
if { (eval echo configure:1080: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_$ac_func=yes"
|
||||
else
|
||||
@ -1225,12 +1231,12 @@ fi
|
||||
|
||||
|
||||
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
|
||||
echo "configure:1229: checking return type of signal handlers" >&5
|
||||
echo "configure:1235: checking return type of signal handlers" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1234 "configure"
|
||||
#line 1240 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
@ -1247,7 +1253,7 @@ int main() {
|
||||
int i;
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1251: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:1257: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_type_signal=void
|
||||
else
|
||||
@ -1287,15 +1293,182 @@ sim_link_links="${sim_link_links} targ-vals.def"
|
||||
|
||||
|
||||
|
||||
|
||||
wire_endian="LITTLE_ENDIAN"
|
||||
default_endian="LITTLE_ENDIAN"
|
||||
default_sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN"
|
||||
# Check whether --enable-sim-endian or --disable-sim-endian was given.
|
||||
if test "${enable_sim_endian+set}" = set; then
|
||||
enableval="$enable_sim_endian"
|
||||
case "${enableval}" in
|
||||
b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
|
||||
l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
|
||||
yes) if test x"$wire_endian" != x; then
|
||||
sim_endian="-DWITH_TARGET_BYTE_ORDER=${wire_endian}"
|
||||
else
|
||||
echo "No hard-wired endian for target $target" 1>&6
|
||||
sim_endian="-DWITH_TARGET_BYTE_ORDER=0"
|
||||
fi;;
|
||||
no) if test x"$default_endian" != x; then
|
||||
sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${default_endian}"
|
||||
else
|
||||
echo "No default endian for target $target" 1>&6
|
||||
sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=0"
|
||||
fi;;
|
||||
*) { echo "configure: error: "Unknown value $enableval for --enable-sim-endian"" 1>&2; exit 1; }; sim_endian="";;
|
||||
esac
|
||||
if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
|
||||
echo "Setting endian flags = $sim_endian" 6>&1
|
||||
fi
|
||||
else
|
||||
sim_endian="${default_sim_endian}"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Check whether --enable-sim-hostendian or --disable-sim-hostendian was given.
|
||||
if test "${enable_sim_hostendian+set}" = set; then
|
||||
enableval="$enable_sim_hostendian"
|
||||
case "${enableval}" in
|
||||
no) sim_hostendian="-DWITH_HOST_BYTE_ORDER=0";;
|
||||
b*|B*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN";;
|
||||
l*|L*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN";;
|
||||
*) { echo "configure: error: "Unknown value $enableval for --enable-sim-hostendian"" 1>&2; exit 1; }; sim_hostendian="";;
|
||||
esac
|
||||
if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then
|
||||
echo "Setting hostendian flags = $sim_hostendian" 6>&1
|
||||
fi
|
||||
else
|
||||
|
||||
if test "x$cross_compiling" = "xno"; then
|
||||
echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
|
||||
echo "configure:1346: checking whether byte ordering is bigendian" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
ac_cv_c_bigendian=unknown
|
||||
# See if sys/param.h defines the BYTE_ORDER macro.
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1353 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
int main() {
|
||||
|
||||
#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
|
||||
bogus endian macros
|
||||
#endif
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1364: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
# It does; now see whether it defined to BIG_ENDIAN or not.
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1368 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
int main() {
|
||||
|
||||
#if BYTE_ORDER != BIG_ENDIAN
|
||||
not big endian
|
||||
#endif
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1379: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_c_bigendian=yes
|
||||
else
|
||||
echo "configure: failed program was:" >&5
|
||||
cat conftest.$ac_ext >&5
|
||||
rm -rf conftest*
|
||||
ac_cv_c_bigendian=no
|
||||
fi
|
||||
rm -f conftest*
|
||||
else
|
||||
echo "configure: failed program was:" >&5
|
||||
cat conftest.$ac_ext >&5
|
||||
fi
|
||||
rm -f conftest*
|
||||
if test $ac_cv_c_bigendian = unknown; then
|
||||
if test "$cross_compiling" = yes; then
|
||||
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1399 "configure"
|
||||
#include "confdefs.h"
|
||||
main () {
|
||||
/* Are we little or big endian? From Harbison&Steele. */
|
||||
union
|
||||
{
|
||||
long l;
|
||||
char c[sizeof (long)];
|
||||
} u;
|
||||
u.l = 1;
|
||||
exit (u.c[sizeof (long) - 1] == 1);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:1412: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_c_bigendian=no
|
||||
else
|
||||
echo "configure: failed program was:" >&5
|
||||
cat conftest.$ac_ext >&5
|
||||
rm -fr conftest*
|
||||
ac_cv_c_bigendian=yes
|
||||
fi
|
||||
rm -fr conftest*
|
||||
fi
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$ac_t""$ac_cv_c_bigendian" 1>&6
|
||||
if test $ac_cv_c_bigendian = yes; then
|
||||
cat >> confdefs.h <<\EOF
|
||||
#define WORDS_BIGENDIAN 1
|
||||
EOF
|
||||
|
||||
fi
|
||||
|
||||
if test $ac_cv_c_bigendian = yes; then
|
||||
sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN"
|
||||
else
|
||||
sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN"
|
||||
fi
|
||||
else
|
||||
sim_hostendian="-DWITH_HOST_BYTE_ORDER=0"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Check whether --enable-sim-warnings or --disable-sim-warnings was given.
|
||||
if test "${enable_sim_warnings+set}" = set; then
|
||||
enableval="$enable_sim_warnings"
|
||||
case "${enableval}" in
|
||||
yes) sim_warnings="-Werror -Wall -Wpointer-arith -Wmissing-prototypes -Wmissing-declarations ";;
|
||||
no) sim_warnings="-w";;
|
||||
*) sim_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
|
||||
esac
|
||||
if test x"$silent" != x"yes" && test x"$sim_warnings" != x""; then
|
||||
echo "Setting warning flags = $sim_warnings" 6>&1
|
||||
fi
|
||||
else
|
||||
sim_warnings=""
|
||||
fi
|
||||
|
||||
|
||||
|
||||
for ac_func in time
|
||||
do
|
||||
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
|
||||
echo "configure:1294: checking for $ac_func" >&5
|
||||
echo "configure:1467: checking for $ac_func" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1299 "configure"
|
||||
#line 1472 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func(); below. */
|
||||
@ -1318,7 +1491,7 @@ $ac_func();
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1322: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
if { (eval echo configure:1495: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_$ac_func=yes"
|
||||
else
|
||||
@ -1346,17 +1519,17 @@ for ac_hdr in unistd.h
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||
echo "configure:1350: checking for $ac_hdr" >&5
|
||||
echo "configure:1523: checking for $ac_hdr" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1355 "configure"
|
||||
#line 1528 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <$ac_hdr>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:1360: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:1533: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out`
|
||||
if test -z "$ac_err"; then
|
||||
rm -rf conftest*
|
||||
@ -1545,6 +1718,9 @@ s%@sim_debug@%$sim_debug%g
|
||||
s%@sim_stdio@%$sim_stdio%g
|
||||
s%@sim_trace@%$sim_trace%g
|
||||
s%@sim_profile@%$sim_profile%g
|
||||
s%@sim_endian@%$sim_endian%g
|
||||
s%@sim_hostendian@%$sim_hostendian%g
|
||||
s%@sim_warnings@%$sim_warnings%g
|
||||
|
||||
CEOF
|
||||
EOF
|
||||
|
@ -5,7 +5,11 @@ AC_INIT(Makefile.in)
|
||||
|
||||
SIM_AC_COMMON
|
||||
|
||||
AC_CHECK_FUNCS(time, chmod)
|
||||
AC_CHECK_HEADERS(unistd.h)
|
||||
SIM_AC_OPTION_ENDIAN(LITTLE_ENDIAN)
|
||||
SIM_AC_OPTION_HOSTENDIAN
|
||||
SIM_AC_OPTION_WARNINGS
|
||||
|
||||
AC_CHECK_FUNCS(time, chmod, utime)
|
||||
AC_CHECK_HEADERS(unistd.h stdlib.h string.h strings.h utime.h)
|
||||
|
||||
SIM_AC_OUTPUT
|
||||
|
@ -1,4 +1,8 @@
|
||||
#include "v850_sim.h"
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "ansidecl.h"
|
||||
#include "opcode/v850.h"
|
||||
#include <limits.h>
|
||||
|
||||
static void write_header PARAMS ((void));
|
||||
static void write_opcodes PARAMS ((void));
|
||||
@ -42,12 +46,13 @@ write_template ()
|
||||
struct v850_opcode *opcode;
|
||||
int i,j;
|
||||
|
||||
printf ("#include \"sim-main.h\"\n");
|
||||
printf ("#include \"v850_sim.h\"\n");
|
||||
printf ("#include \"simops.h\"\n");
|
||||
|
||||
for (opcode = (struct v850_opcode *)v850_opcodes; opcode->name; opcode++)
|
||||
{
|
||||
printf("/* %s */\nvoid\nOP_%X ()\n{\n", opcode->name, opcode->opcode);
|
||||
printf("/* %s */\nvoid\nOP_%X (void)\n{\n", opcode->name, opcode->opcode);
|
||||
|
||||
/* count operands */
|
||||
j = 0;
|
||||
@ -89,6 +94,7 @@ write_opcodes ()
|
||||
int numops;
|
||||
|
||||
/* write out opcode table */
|
||||
printf ("#include \"sim-main.h\"\n");
|
||||
printf ("#include \"v850_sim.h\"\n");
|
||||
printf ("#include \"simops.h\"\n\n");
|
||||
printf ("struct simops Simops[] = {\n");
|
||||
|
@ -1,8 +1,25 @@
|
||||
#include <signal.h>
|
||||
#include "sysdep.h"
|
||||
#include "sim-main.h"
|
||||
#include "sim-options.h"
|
||||
#include "v850_sim.h"
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "bfd.h"
|
||||
|
||||
#include "v850_sim.h"
|
||||
|
||||
/* For compatibility */
|
||||
SIM_DESC simulator;
|
||||
|
||||
enum interrupt_type
|
||||
{
|
||||
@ -66,27 +83,13 @@ static int have_nm_generator;
|
||||
|
||||
/* These default values correspond to expected usage for the chip. */
|
||||
|
||||
SIM_ADDR rom_size = 0x8000;
|
||||
SIM_ADDR low_end = 0x200000;
|
||||
SIM_ADDR high_start = 0xffe000;
|
||||
|
||||
SIM_ADDR high_base;
|
||||
|
||||
host_callback *v850_callback;
|
||||
|
||||
int v850_debug;
|
||||
|
||||
/* non-zero if we opened prog_bfd */
|
||||
static int prog_bfd_was_opened_p;
|
||||
bfd *prog_bfd;
|
||||
|
||||
static SIM_OPEN_KIND sim_kind;
|
||||
static char *myname;
|
||||
|
||||
uint32 OP[4];
|
||||
|
||||
static struct hash_entry *lookup_hash PARAMS ((uint32 ins));
|
||||
static struct hash_entry *lookup_hash PARAMS ((SIM_DESC sd, uint32 ins));
|
||||
static long hash PARAMS ((long));
|
||||
#if 0
|
||||
static void do_format_1_2 PARAMS ((uint32));
|
||||
static void do_format_3 PARAMS ((uint32));
|
||||
static void do_format_4 PARAMS ((uint32));
|
||||
@ -95,7 +98,7 @@ static void do_format_6 PARAMS ((uint32));
|
||||
static void do_format_7 PARAMS ((uint32));
|
||||
static void do_format_8 PARAMS ((uint32));
|
||||
static void do_format_9_10 PARAMS ((uint32));
|
||||
static void init_system PARAMS ((void));
|
||||
#endif
|
||||
|
||||
#define MAX_HASH 63
|
||||
|
||||
@ -132,7 +135,8 @@ hash(insn)
|
||||
}
|
||||
|
||||
static struct hash_entry *
|
||||
lookup_hash (ins)
|
||||
lookup_hash (sd, ins)
|
||||
SIM_DESC sd;
|
||||
uint32 ins;
|
||||
{
|
||||
struct hash_entry *h;
|
||||
@ -143,8 +147,8 @@ lookup_hash (ins)
|
||||
{
|
||||
if (h->next == NULL)
|
||||
{
|
||||
(*v850_callback->printf_filtered) (v850_callback, "ERROR looking up hash for 0x%x, PC=0x%x\n", ins, PC);
|
||||
exit(1);
|
||||
sim_io_error (sd, "ERROR looking up hash for 0x%lx, PC=0x%lx",
|
||||
(long) ins, (long) PC);
|
||||
}
|
||||
h = h->next;
|
||||
}
|
||||
@ -212,21 +216,22 @@ uint8 *
|
||||
map (addr)
|
||||
SIM_ADDR addr;
|
||||
{
|
||||
uint8 *p;
|
||||
|
||||
/* Mask down to 24 bits. */
|
||||
addr &= 0xffffff;
|
||||
|
||||
if (addr < low_end)
|
||||
if (addr < 0x100000)
|
||||
{
|
||||
/* "Mirror" the addresses below 1MB. */
|
||||
if (addr < 0x100000)
|
||||
addr &= (rom_size - 1);
|
||||
else
|
||||
addr += (rom_size - 0x100000);
|
||||
return (uint8 *) (addr + State.mem);
|
||||
addr = addr & (simulator->rom_size - 1);
|
||||
return (uint8 *) (addr + STATE_MEMORY (simulator));
|
||||
}
|
||||
else if (addr >= high_start)
|
||||
else if (addr < simulator->low_end)
|
||||
{
|
||||
/* chunk is just after the rom */
|
||||
addr = addr - 0x100000 + simulator->rom_size;
|
||||
return (uint8 *) (addr + STATE_MEMORY (simulator));
|
||||
}
|
||||
else if (addr >= simulator->high_start)
|
||||
{
|
||||
/* If in the peripheral I/O region, mirror 1K region across 4K,
|
||||
and similarly if in the internal RAM region. */
|
||||
@ -234,11 +239,16 @@ map (addr)
|
||||
addr &= 0xfff3ff;
|
||||
else if (addr >= 0xffe000)
|
||||
addr &= 0xffe3ff;
|
||||
return (uint8 *) (addr - high_start + high_base + State.mem);
|
||||
addr = addr - simulator->high_start + simulator->high_base;
|
||||
return (uint8 *) (STATE_MEMORY (simulator));
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "segmentation fault: access address: %x not below %x or above %x [ep = %x]\n", addr, low_end, high_start, State.regs[30]);
|
||||
sim_io_eprintf (simulator, "segmentation fault: access address: %lx not below %lx or above %lx [ep = %lx]\n",
|
||||
(long) addr,
|
||||
(long) simulator->low_end,
|
||||
(long) simulator->high_start,
|
||||
State.regs[30]);
|
||||
|
||||
/* Signal a memory error. */
|
||||
State.exception = SIGSEGV;
|
||||
@ -296,44 +306,55 @@ store_mem (addr, len, data)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sim_size (power)
|
||||
int power;
|
||||
|
||||
static void
|
||||
sim_memory_init (SIM_DESC sd)
|
||||
{
|
||||
int totsize;
|
||||
|
||||
if (State.mem)
|
||||
free (State.mem);
|
||||
|
||||
totsize = rom_size + (low_end - 0x100000) + (0x1000000 - high_start);
|
||||
|
||||
high_base = rom_size + (low_end - 0x100000);
|
||||
|
||||
State.mem = (uint8 *) calloc (1, totsize);
|
||||
if (!State.mem)
|
||||
if (STATE_MEMORY (sd))
|
||||
zfree (STATE_MEMORY (sd));
|
||||
|
||||
totsize = (simulator->rom_size
|
||||
+ (sd->low_end - 0x100000)
|
||||
+ (0x1000000 - sd->high_start));
|
||||
|
||||
sd->high_base = sd->rom_size + (sd->low_end - 0x100000);
|
||||
|
||||
STATE_MEMORY (sd) = zalloc (totsize);
|
||||
if (!STATE_MEMORY (sd))
|
||||
{
|
||||
(*v850_callback->printf_filtered) (v850_callback, "Allocation of main memory failed.\n");
|
||||
exit (1);
|
||||
sim_io_error (sd, "Allocation of main memory failed.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sim_set_memory_map (spec)
|
||||
static int
|
||||
sim_parse_number (str, rest)
|
||||
char *str, **rest;
|
||||
{
|
||||
if (str[0] == '0' && str[1] == 'x')
|
||||
return strtoul (str, rest, 16);
|
||||
else if (str[0] == '0')
|
||||
return strtoul (str, rest, 16);
|
||||
else
|
||||
return strtoul (str, rest, 10);
|
||||
}
|
||||
|
||||
static void
|
||||
sim_set_memory_map (sd, spec)
|
||||
SIM_DESC sd;
|
||||
char *spec;
|
||||
{
|
||||
char *reststr, *nreststr;
|
||||
SIM_ADDR new_low_end, new_high_start;
|
||||
|
||||
new_low_end = low_end;
|
||||
new_high_start = high_start;
|
||||
new_low_end = sd->low_end;
|
||||
new_high_start = sd->high_start;
|
||||
if (! strncmp (spec, "hole=", 5))
|
||||
{
|
||||
new_low_end = sim_parse_number (spec + 5, &reststr);
|
||||
if (new_low_end < 0x100000)
|
||||
{
|
||||
(*v850_callback->printf_filtered) (v850_callback,
|
||||
"Low end must be at least 0x100000\n");
|
||||
sim_io_printf (sd, "Low end must be at least 0x100000\n");
|
||||
return;
|
||||
}
|
||||
if (*reststr == ',')
|
||||
@ -342,48 +363,25 @@ sim_set_memory_map (spec)
|
||||
new_high_start = sim_parse_number (reststr, &nreststr);
|
||||
/* FIXME Check high_start also */
|
||||
}
|
||||
(*v850_callback->printf_filtered) (v850_callback,
|
||||
"Hole goes from 0x%x to 0x%x\n",
|
||||
new_low_end, new_high_start);
|
||||
sim_io_printf (sd, "Hole goes from 0x%x to 0x%x\n",
|
||||
new_low_end, new_high_start);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*v850_callback->printf_filtered) (v850_callback, "Invalid specification for memory map, must be `hole=<m>[,<n>]'\n");
|
||||
sim_io_printf (sd, "Invalid specification for memory map, must be `hole=<m>[,<n>]'\n");
|
||||
}
|
||||
|
||||
if (new_low_end != low_end || new_high_start != high_start)
|
||||
if (new_low_end != sd->low_end || new_high_start != sd->high_start)
|
||||
{
|
||||
low_end = new_low_end;
|
||||
high_start = new_high_start;
|
||||
if (State.mem)
|
||||
{
|
||||
(*v850_callback->printf_filtered) (v850_callback, "Reconfiguring memory (old contents will be lost)\n");
|
||||
sim_size (1);
|
||||
}
|
||||
sd->low_end = new_low_end;
|
||||
sd->high_start = new_high_start;
|
||||
sim_io_printf (sd, "Reconfiguring memory (old contents will be lost)\n");
|
||||
sim_memory_init (sd);
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse a number in hex, octal, or decimal form. */
|
||||
|
||||
int
|
||||
sim_parse_number (str, rest)
|
||||
char *str, **rest;
|
||||
{
|
||||
if (str[0] == '0' && str[1] == 'x')
|
||||
return strtol (str, rest, 16);
|
||||
else if (str[0] == '0')
|
||||
return strtol (str, rest, 16);
|
||||
else
|
||||
return strtol (str, rest, 10);
|
||||
}
|
||||
|
||||
static void
|
||||
init_system ()
|
||||
{
|
||||
if (!State.mem)
|
||||
sim_size(1);
|
||||
}
|
||||
|
||||
int
|
||||
sim_write (sd, addr, buffer, size)
|
||||
SIM_DESC sd;
|
||||
@ -393,14 +391,13 @@ sim_write (sd, addr, buffer, size)
|
||||
{
|
||||
int i;
|
||||
|
||||
init_system ();
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
store_mem (addr + i, 1, buffer[i]);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
SIM_DESC
|
||||
sim_open (kind, cb, abfd, argv)
|
||||
SIM_OPEN_KIND kind;
|
||||
@ -408,25 +405,58 @@ sim_open (kind, cb, abfd, argv)
|
||||
struct _bfd *abfd;
|
||||
char **argv;
|
||||
{
|
||||
SIM_DESC sd = sim_state_alloc (kind, cb);
|
||||
struct simops *s;
|
||||
struct hash_entry *h;
|
||||
char **p;
|
||||
|
||||
sim_kind = kind;
|
||||
myname = argv[0];
|
||||
v850_callback = cb;
|
||||
/* for compatibility */
|
||||
simulator = sd;
|
||||
|
||||
if (argv != NULL)
|
||||
sd->rom_size = V850_ROM_SIZE;
|
||||
sd->low_end = V850_LOW_END;
|
||||
sd->high_start = V850_HIGH_START;
|
||||
|
||||
/* Allocate memory */
|
||||
sim_memory_init (sd);
|
||||
|
||||
if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK)
|
||||
return 0;
|
||||
|
||||
/* getopt will print the error message so we just have to exit if this fails.
|
||||
FIXME: Hmmm... in the case of gdb we need getopt to call
|
||||
print_filtered. */
|
||||
if (sim_parse_args (sd, argv) != SIM_RC_OK)
|
||||
{
|
||||
for (p = argv + 1; *p; ++p)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (strcmp (*p, "-t") == 0)
|
||||
v850_debug = DEBUG;
|
||||
else
|
||||
#endif
|
||||
(*v850_callback->printf_filtered) (v850_callback, "ERROR: unsupported option(s): %s\n",*p);
|
||||
}
|
||||
/* Uninstall the modules to avoid memory leaks,
|
||||
file descriptor leaks, etc. */
|
||||
sim_module_uninstall (sd);
|
||||
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;
|
||||
}
|
||||
|
||||
/* establish any remaining configuration options */
|
||||
if (sim_config (sd) != SIM_RC_OK)
|
||||
{
|
||||
sim_module_uninstall (sd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sim_post_argv_init (sd) != SIM_RC_OK)
|
||||
{
|
||||
/* Uninstall the modules to avoid memory leaks,
|
||||
file descriptor leaks, etc. */
|
||||
sim_module_uninstall (sd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* put all the opcodes in the hash table */
|
||||
@ -448,8 +478,7 @@ sim_open (kind, cb, abfd, argv)
|
||||
h->opcode = s->opcode;
|
||||
}
|
||||
|
||||
/* fudge our descriptor for now */
|
||||
return (SIM_DESC) 1;
|
||||
return sd;
|
||||
}
|
||||
|
||||
|
||||
@ -458,27 +487,10 @@ sim_close (sd, quitting)
|
||||
SIM_DESC sd;
|
||||
int quitting;
|
||||
{
|
||||
if (prog_bfd != NULL && prog_bfd_was_opened_p)
|
||||
bfd_close (prog_bfd);
|
||||
sim_module_uninstall (sd);
|
||||
}
|
||||
|
||||
void
|
||||
sim_set_profile (n)
|
||||
int n;
|
||||
{
|
||||
(*v850_callback->printf_filtered) (v850_callback, "sim_set_profile %d\n", n);
|
||||
}
|
||||
|
||||
void
|
||||
sim_set_profile_size (n)
|
||||
int n;
|
||||
{
|
||||
(*v850_callback->printf_filtered) (v850_callback, "sim_set_profile_size %d\n", n);
|
||||
}
|
||||
|
||||
time_t start_time;
|
||||
|
||||
static void do_interrupt PARAMS ((enum interrupt_type));
|
||||
static void do_interrupt PARAMS ((SIM_DESC sd, enum interrupt_type));
|
||||
|
||||
int
|
||||
sim_stop (sd)
|
||||
@ -492,17 +504,18 @@ sim_resume (sd, step, siggnal)
|
||||
SIM_DESC sd;
|
||||
int step, siggnal;
|
||||
{
|
||||
uint32 inst, opcode;
|
||||
SIM_ELAPSED_TIME start_time;
|
||||
uint32 inst;
|
||||
reg_t oldpc;
|
||||
struct interrupt_generator *intgen;
|
||||
time_t now;
|
||||
|
||||
if (step)
|
||||
State.exception = SIGTRAP;
|
||||
else
|
||||
State.exception = 0;
|
||||
|
||||
time (&start_time);
|
||||
|
||||
start_time = sim_elapsed_time_get ();
|
||||
|
||||
do
|
||||
{
|
||||
@ -511,13 +524,13 @@ sim_resume (sd, step, siggnal)
|
||||
inst = RLW (PC);
|
||||
oldpc = PC;
|
||||
|
||||
h = lookup_hash (inst);
|
||||
h = lookup_hash (sd, inst);
|
||||
OP[0] = inst & 0x1f;
|
||||
OP[1] = (inst >> 11) & 0x1f;
|
||||
OP[2] = (inst >> 16) & 0xffff;
|
||||
OP[3] = inst;
|
||||
|
||||
// fprintf (stderr, "PC = %x, SP = %x\n", PC, SP );
|
||||
/* fprintf (stderr, "PC = %x, SP = %x\n", PC, SP ); */
|
||||
|
||||
if (inst == 0)
|
||||
{
|
||||
@ -529,7 +542,7 @@ sim_resume (sd, step, siggnal)
|
||||
|
||||
if (oldpc == PC)
|
||||
{
|
||||
fprintf (stderr, "simulator loop at %x\n", PC );
|
||||
sim_io_eprintf (sd, "simulator loop at %lx\n", (long) PC );
|
||||
break;
|
||||
}
|
||||
|
||||
@ -548,8 +561,9 @@ sim_resume (sd, step, siggnal)
|
||||
else if (intgen->cond_type == int_cond_time
|
||||
&& intgen->enabled)
|
||||
{
|
||||
time (&now);
|
||||
if (((long) now - (long) start_time) > intgen->time)
|
||||
SIM_ELAPSED_TIME delta;
|
||||
delta = sim_elapsed_time_since (start_time);
|
||||
if (delta > intgen->time)
|
||||
{
|
||||
intgen->enabled = 0;
|
||||
break;
|
||||
@ -557,19 +571,20 @@ sim_resume (sd, step, siggnal)
|
||||
}
|
||||
}
|
||||
if (intgen)
|
||||
do_interrupt (intgen->type);
|
||||
do_interrupt (sd, intgen->type);
|
||||
}
|
||||
else if (State.pending_nmi)
|
||||
{
|
||||
State.pending_nmi = 0;
|
||||
do_interrupt (int_nmi);
|
||||
do_interrupt (sd, int_nmi);
|
||||
}
|
||||
}
|
||||
while (!State.exception);
|
||||
}
|
||||
|
||||
static void
|
||||
do_interrupt (inttype)
|
||||
do_interrupt (sd, inttype)
|
||||
SIM_DESC sd;
|
||||
enum interrupt_type inttype;
|
||||
{
|
||||
/* Disable further interrupts. */
|
||||
@ -659,30 +674,22 @@ sim_info (sd, verbose)
|
||||
SIM_DESC sd;
|
||||
int verbose;
|
||||
{
|
||||
(*v850_callback->printf_filtered) (v850_callback, "sim_info\n");
|
||||
sim_io_printf (sd, "sim_info\n");
|
||||
}
|
||||
|
||||
SIM_RC
|
||||
sim_create_inferior (sd, abfd, argv, env)
|
||||
sim_create_inferior (sd, prog_bfd, argv, env)
|
||||
SIM_DESC sd;
|
||||
struct _bfd *abfd;
|
||||
struct _bfd *prog_bfd;
|
||||
char **argv;
|
||||
char **env;
|
||||
{
|
||||
if (abfd == NULL)
|
||||
memset (&State, 0, sizeof (State));
|
||||
if (prog_bfd != NULL)
|
||||
PC = bfd_get_start_address (prog_bfd);
|
||||
else
|
||||
PC = 0; /* ??? */
|
||||
return SIM_RC_OK;
|
||||
}
|
||||
|
||||
void
|
||||
sim_set_callbacks (p)
|
||||
host_callback *p;
|
||||
{
|
||||
v850_callback = p;
|
||||
}
|
||||
|
||||
/* All the code for exiting, signals, etc needs to be revamped.
|
||||
|
||||
This is enough to get c-torture limping though. */
|
||||
@ -739,8 +746,9 @@ sim_read (sd, addr, buffer, size)
|
||||
|
||||
int current_intgen_number = 1;
|
||||
|
||||
void
|
||||
sim_set_interrupt (spec)
|
||||
static void
|
||||
sim_set_interrupt (sd, spec)
|
||||
SIM_DESC sd;
|
||||
char *spec;
|
||||
{
|
||||
int i, num;
|
||||
@ -772,12 +780,12 @@ sim_set_interrupt (spec)
|
||||
}
|
||||
if (intgen->type == int_none)
|
||||
{
|
||||
(*v850_callback->printf_filtered) (v850_callback, "Interrupt type unknown; known types are\n");
|
||||
sim_io_printf (sd, "Interrupt type unknown; known types are\n");
|
||||
for (i = 0; i < num_int_types; ++i)
|
||||
{
|
||||
(*v850_callback->printf_filtered) (v850_callback, " %s", interrupt_names[i]);
|
||||
sim_io_printf (sd, " %s", interrupt_names[i]);
|
||||
}
|
||||
(*v850_callback->printf_filtered) (v850_callback, "\n");
|
||||
sim_io_printf (sd, "\n");
|
||||
free (intgen);
|
||||
return;
|
||||
}
|
||||
@ -798,7 +806,7 @@ sim_set_interrupt (spec)
|
||||
}
|
||||
else
|
||||
{
|
||||
(*v850_callback->printf_filtered) (v850_callback, "Condition type must be `pc' or `time'.\n");
|
||||
sim_io_printf (sd, "Condition type must be `pc' or `time'.\n");
|
||||
free (intgen);
|
||||
return;
|
||||
}
|
||||
@ -808,7 +816,7 @@ sim_set_interrupt (spec)
|
||||
intgen->enabled = 1;
|
||||
intgen->next = intgen_list;
|
||||
intgen_list = intgen;
|
||||
(*v850_callback->printf_filtered) (v850_callback, "Interrupt generator %d (NMI) at pc=0x%x, time=%d.\n", intgen_list->number, intgen_list->address, intgen_list->time);
|
||||
sim_io_printf (sd, "Interrupt generator %d (NMI) at pc=0x%x, time=%d.\n", intgen_list->number, intgen_list->address, intgen_list->time);
|
||||
}
|
||||
else if (*argv && !strcmp (*argv, "remove"))
|
||||
{
|
||||
@ -837,8 +845,7 @@ sim_set_interrupt (spec)
|
||||
if (tmpgen)
|
||||
free (tmpgen);
|
||||
else
|
||||
(*v850_callback->printf_filtered) (v850_callback,
|
||||
"No interrupt generator numbered %d, ignoring.\n", num);
|
||||
sim_io_printf (sd, "No interrupt generator numbered %d, ignoring.\n", num);
|
||||
}
|
||||
}
|
||||
else if (*argv && !strcmp (*argv, "info"))
|
||||
@ -846,24 +853,22 @@ sim_set_interrupt (spec)
|
||||
if (intgen_list)
|
||||
{
|
||||
for (intgen = intgen_list; intgen != NULL; intgen = intgen->next)
|
||||
(*v850_callback->printf_filtered) (v850_callback,
|
||||
"Interrupt generator %d (%s) at pc=0x%x/time=%d%s.\n",
|
||||
intgen->number,
|
||||
interrupt_names[intgen->type],
|
||||
intgen->address,
|
||||
intgen->time,
|
||||
(intgen->enabled ? "" : " (disabled)"));
|
||||
sim_io_printf (sd, "Interrupt generator %d (%s) at pc=0x%x/time=%d%s.\n",
|
||||
intgen->number,
|
||||
interrupt_names[intgen->type],
|
||||
intgen->address,
|
||||
intgen->time,
|
||||
(intgen->enabled ? "" : " (disabled)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
(*v850_callback->printf_filtered) (v850_callback, "No interrupt generators defined.\n");
|
||||
sim_io_printf (sd, "No interrupt generators defined.\n");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
(*v850_callback->printf_filtered) (v850_callback,
|
||||
"Invalid interrupt command, must be one of `add', `remove', or `info'.\n");
|
||||
sim_io_printf (sd, "Invalid interrupt command, must be one of `add', `remove', or `info'.\n");
|
||||
}
|
||||
/* Cache the presence of a non-maskable generator. */
|
||||
have_nm_generator = 0;
|
||||
@ -887,41 +892,22 @@ sim_do_command (sd, cmd)
|
||||
|
||||
if (! strncmp (cmd, mm_cmd, strlen (mm_cmd))
|
||||
&& strchr (" ", cmd[strlen(mm_cmd)]))
|
||||
sim_set_memory_map (cmd + strlen(mm_cmd) + 1);
|
||||
sim_set_memory_map (sd, cmd + strlen(mm_cmd) + 1);
|
||||
|
||||
else if (! strncmp (cmd, int_cmd, strlen (int_cmd))
|
||||
&& strchr (" ", cmd[strlen(int_cmd)]))
|
||||
sim_set_interrupt (cmd + strlen(int_cmd) + 1);
|
||||
sim_set_interrupt (sd, cmd + strlen(int_cmd) + 1);
|
||||
|
||||
else if (! strcmp (cmd, "help"))
|
||||
{
|
||||
(*v850_callback->printf_filtered) (v850_callback, "V850 simulator commands:\n\n");
|
||||
(*v850_callback->printf_filtered) (v850_callback, "interrupt add <inttype> { pc | time } <value> -- Set up an interrupt generator\n");
|
||||
(*v850_callback->printf_filtered) (v850_callback, "interrupt remove <n> -- Remove an existing interrupt generator\n");
|
||||
(*v850_callback->printf_filtered) (v850_callback, "interrupt info -- List all the interrupt generators\n");
|
||||
(*v850_callback->printf_filtered) (v850_callback, "memory-map hole=<m>,<n> -- Set the memory map to have a hole between <m> and <n>\n");
|
||||
(*v850_callback->printf_filtered) (v850_callback, "\n");
|
||||
sim_io_printf (sd, "V850 simulator commands:\n\n");
|
||||
sim_io_printf (sd, "interrupt add <inttype> { pc | time } <value> -- Set up an interrupt generator\n");
|
||||
sim_io_printf (sd, "interrupt remove <n> -- Remove an existing interrupt generator\n");
|
||||
sim_io_printf (sd, "interrupt info -- List all the interrupt generators\n");
|
||||
sim_io_printf (sd, "memory-map hole=<m>,<n> -- Set the memory map to have a hole between <m> and <n>\n");
|
||||
sim_io_printf (sd, "\n");
|
||||
}
|
||||
else
|
||||
(*v850_callback->printf_filtered) (v850_callback, "\"%s\" is not a valid V850 simulator command.\n",
|
||||
sim_io_printf (sd, "\"%s\" is not a valid V850 simulator command.\n",
|
||||
cmd);
|
||||
}
|
||||
|
||||
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. */
|
||||
|
||||
if (prog_bfd != NULL && prog_bfd_was_opened_p)
|
||||
bfd_close (prog_bfd);
|
||||
prog_bfd = sim_load_file (sd, myname, v850_callback, prog, abfd,
|
||||
sim_kind == SIM_OPEN_DEBUG);
|
||||
if (prog_bfd == NULL)
|
||||
return SIM_RC_FAIL;
|
||||
prog_bfd_was_opened_p = abfd == NULL;
|
||||
return SIM_RC_OK;
|
||||
}
|
||||
|
@ -1,9 +1,16 @@
|
||||
#include <signal.h>
|
||||
#include "sim-main.h"
|
||||
#include "v850_sim.h"
|
||||
#include "simops.h"
|
||||
|
||||
#ifdef HAVE_UTIME_H
|
||||
#include <utime.h>
|
||||
#endif
|
||||
|
||||
/* FIXME - should be including a version of syscall.h that does not
|
||||
pollute the name space */
|
||||
#include "../../libgloss/v850/sys/syscall.h"
|
||||
|
||||
#include "bfd.h"
|
||||
#include <errno.h>
|
||||
#if !defined(__GO32__) && !defined(_WIN32)
|
||||
@ -790,9 +797,6 @@ OP_10760 ()
|
||||
static int
|
||||
branch (int code)
|
||||
{
|
||||
unsigned int psw;
|
||||
int op0;
|
||||
|
||||
trace_input ("Bcond", OP_COND_BR, 0);
|
||||
trace_output (OP_COND_BR);
|
||||
|
||||
@ -1692,7 +1696,7 @@ OP_640 ()
|
||||
{
|
||||
trace_input ("movhi", OP_UIMM_REG_REG, 16);
|
||||
|
||||
State.regs[ OP[1] ] = State.regs[ OP[0] ] + OP[2] << 16;
|
||||
State.regs[ OP[1] ] = State.regs[ OP[0] ] + (OP[2] << 16);
|
||||
|
||||
trace_output (OP_UIMM_REG_REG);
|
||||
}
|
||||
@ -2275,37 +2279,34 @@ OP_10007E0 ()
|
||||
|
||||
#ifdef SYS_read
|
||||
case SYS_read:
|
||||
RETVAL = v850_callback->read (v850_callback, PARM1, MEMPTR (PARM2),
|
||||
PARM3);
|
||||
RETVAL = sim_io_read (simulator, PARM1, MEMPTR (PARM2), PARM3);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef SYS_write
|
||||
case SYS_write:
|
||||
if (PARM1 == 1)
|
||||
RETVAL = (int)v850_callback->write_stdout (v850_callback,
|
||||
MEMPTR (PARM2), PARM3);
|
||||
RETVAL = sim_io_write_stdout (simulator, MEMPTR (PARM2), PARM3);
|
||||
else
|
||||
RETVAL = (int)v850_callback->write (v850_callback, PARM1,
|
||||
MEMPTR (PARM2), PARM3);
|
||||
RETVAL = sim_io_write (simulator, PARM1, MEMPTR (PARM2), PARM3);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef SYS_lseek
|
||||
case SYS_lseek:
|
||||
RETVAL = v850_callback->lseek (v850_callback, PARM1, PARM2, PARM3);
|
||||
RETVAL = sim_io_lseek (simulator, PARM1, PARM2, PARM3);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef SYS_close
|
||||
case SYS_close:
|
||||
RETVAL = v850_callback->close (v850_callback, PARM1);
|
||||
RETVAL = sim_io_close (simulator, PARM1);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef SYS_open
|
||||
case SYS_open:
|
||||
RETVAL = v850_callback->open (v850_callback, MEMPTR (PARM1), PARM2);
|
||||
RETVAL = sim_io_open (simulator, MEMPTR (PARM1), PARM2);
|
||||
break;
|
||||
#endif
|
||||
|
||||
@ -2408,8 +2409,8 @@ OP_10007E0 ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(__GO32__) && !defined(_WIN32)
|
||||
#ifdef SYS_utime
|
||||
#if HAVE_UTIME
|
||||
case SYS_utime:
|
||||
/* Cast the second argument to void *, to avoid type mismatch
|
||||
if a prototype is present. */
|
||||
@ -2458,8 +2459,6 @@ OP_2007E0 ()
|
||||
int
|
||||
OP_4007E0 ()
|
||||
{
|
||||
unsigned int op0;
|
||||
|
||||
trace_input ("stsr", OP_STSR, 0);
|
||||
|
||||
State.regs[ OP[1] ] = State.sregs[ OP[0] ];
|
||||
@ -2571,20 +2570,20 @@ divun
|
||||
boolean * overflow_ptr
|
||||
)
|
||||
{
|
||||
unsigned long ald = sfi >> N - 1;
|
||||
unsigned long ald = sfi >> (N - 1);
|
||||
unsigned long alo = als;
|
||||
unsigned int Q = 1;
|
||||
unsigned int C;
|
||||
unsigned int S = 0;
|
||||
unsigned int i;
|
||||
unsigned int R1 = 1;
|
||||
unsigned int OV;
|
||||
unsigned int DBZ = (als == 0) ? 1 : 0;
|
||||
unsigned long alt = Q ? ~als : als;
|
||||
|
||||
/* 1st Loop */
|
||||
alo = ald + alt + Q;
|
||||
C = (alt >> 31) & (ald >> 31) | ((alt >> 31) ^ (ald >> 31)) & (~alo >> 31);
|
||||
C = (((alt >> 31) & (ald >> 31))
|
||||
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
||||
C = C ^ Q;
|
||||
Q = ~(C ^ S) & 1;
|
||||
R1 = (alo == 0) ? 0 : (R1 & Q);
|
||||
@ -2601,7 +2600,8 @@ divun
|
||||
{
|
||||
alt = Q ? ~als : als;
|
||||
alo = ald + alt + Q;
|
||||
C = (alt >> 31) & (ald >> 31) | ((alt >> 31) ^ (ald >> 31)) & (~alo >> 31);
|
||||
C = (((alt >> 31) & (ald >> 31))
|
||||
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
||||
C = C ^ Q;
|
||||
Q = ~(C ^ S) & 1;
|
||||
R1 = (alo == 0) ? 0 : (R1 & Q);
|
||||
@ -2617,7 +2617,8 @@ divun
|
||||
/* Nth Loop */
|
||||
alt = Q ? ~als : als;
|
||||
alo = ald + alt + Q;
|
||||
C = (alt >> 31) & (ald >> 31) | ((alt >> 31) ^ (ald >> 31)) & (~alo >> 31);
|
||||
C = (((alt >> 31) & (ald >> 31))
|
||||
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
||||
C = C ^ Q;
|
||||
Q = ~(C ^ S) & 1;
|
||||
R1 = (alo == 0) ? 0 : (R1 & Q);
|
||||
@ -2660,7 +2661,8 @@ divn
|
||||
/* 1st Loop */
|
||||
|
||||
alo = ald + alt + Q;
|
||||
C = (alt >> 31) & (ald >> 31) | ((alt >> 31) ^ (ald >> 31)) & (~alo >> 31);
|
||||
C = (((alt >> 31) & (ald >> 31))
|
||||
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
||||
Q = C ^ SS;
|
||||
R1 = (alo == 0) ? 0 : (R1 & (Q ^ (SS ^ SD)));
|
||||
S = alo >> 31;
|
||||
@ -2677,7 +2679,8 @@ divn
|
||||
{
|
||||
alt = Q ? ~als : als;
|
||||
alo = ald + alt + Q;
|
||||
C = (alt >> 31) & (ald >> 31) | ((alt >> 31) ^ (ald >> 31)) & (~alo >> 31);
|
||||
C = (((alt >> 31) & (ald >> 31))
|
||||
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
||||
Q = C ^ SS;
|
||||
R1 = (alo == 0) ? 0 : (R1 & (Q ^ (SS ^ SD)));
|
||||
S = alo >> 31;
|
||||
@ -2692,7 +2695,8 @@ divn
|
||||
/* Nth Loop */
|
||||
alt = Q ? ~als : als;
|
||||
alo = ald + alt + Q;
|
||||
C = (alt >> 31) & (ald >> 31) | ((alt >> 31) ^ (ald >> 31)) & (~alo >> 31);
|
||||
C = (((alt >> 31) & (ald >> 31))
|
||||
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
||||
Q = C ^ SS;
|
||||
R1 = (alo == 0) ? 0 : (R1 & (Q ^ (SS ^ SD)));
|
||||
sfi = (sfi << (32-N+1));
|
||||
@ -2716,7 +2720,8 @@ divn
|
||||
* remainder_ptr = alo;
|
||||
|
||||
/* Adj */
|
||||
if ((alo != 0) && ((SS ^ SD) ^ R1) || (alo == 0) && (SS ^ R1))
|
||||
if (((alo != 0) && ((SS ^ SD) ^ R1))
|
||||
|| ((alo == 0) && (SS ^ R1)))
|
||||
alo = ald + 1;
|
||||
else
|
||||
alo = ald;
|
||||
@ -3369,7 +3374,8 @@ OP_10780 (void)
|
||||
|
||||
trace_input ("ld.bu", OP_LOAD32, 1);
|
||||
|
||||
adr = State.regs[ OP[0] ] + SEXT16 (OP[2] & ~1) | ((OP[3] >> 5) & 1);
|
||||
adr = (State.regs[ OP[0] ]
|
||||
+ (SEXT16 (OP[2] & ~1) | ((OP[3] >> 5) & 1)));
|
||||
|
||||
State.regs[ OP[1] ] = load_mem (adr, 1);
|
||||
|
||||
@ -3611,6 +3617,8 @@ OP_107F0 (void)
|
||||
}
|
||||
|
||||
trace_output (OP_PUSHPOP2);
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
/* pushmh list18 */
|
||||
|
@ -1,170 +1,8 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "ansidecl.h"
|
||||
#include "callback.h"
|
||||
#include "opcode/v850.h"
|
||||
#include <limits.h>
|
||||
#include "remote-sim.h"
|
||||
|
||||
extern host_callback *v850_callback;
|
||||
|
||||
#define DEBUG_TRACE 0x00000001
|
||||
#define DEBUG_VALUES 0x00000002
|
||||
|
||||
extern int v850_debug;
|
||||
|
||||
#if UCHAR_MAX == 255
|
||||
typedef unsigned char uint8;
|
||||
typedef signed char int8;
|
||||
#else
|
||||
#error "Char is not an 8-bit type"
|
||||
#endif
|
||||
|
||||
#if SHRT_MAX == 32767
|
||||
typedef unsigned short uint16;
|
||||
typedef signed short int16;
|
||||
#else
|
||||
#error "Short is not a 16-bit type"
|
||||
#endif
|
||||
|
||||
#if INT_MAX == 2147483647
|
||||
|
||||
typedef unsigned int uint32;
|
||||
typedef signed int int32;
|
||||
|
||||
#else
|
||||
# if LONG_MAX == 2147483647
|
||||
|
||||
typedef unsigned long uint32;
|
||||
typedef signed long int32;
|
||||
|
||||
# else
|
||||
# error "Neither int nor long is a 32-bit type"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* FIXME: V850 defines */
|
||||
typedef uint32 reg_t;
|
||||
|
||||
struct simops
|
||||
{
|
||||
long opcode;
|
||||
long mask;
|
||||
int (* func)(void);
|
||||
int (* func) PARAMS ((void));
|
||||
int numops;
|
||||
int operands[12];
|
||||
};
|
||||
|
||||
/* The current state of the processor; registers, memory, etc. */
|
||||
|
||||
struct _state
|
||||
{
|
||||
reg_t regs[32]; /* general-purpose registers */
|
||||
reg_t sregs[32]; /* system registers, including psw */
|
||||
reg_t pc;
|
||||
uint8 * mem; /* main memory */
|
||||
int dummy_mem; /* where invalid accesses go */
|
||||
int exception;
|
||||
int pending_nmi;
|
||||
} State;
|
||||
|
||||
#define SIG_V850_EXIT -1 /* indication of a normal exit */
|
||||
|
||||
extern uint32 OP[4];
|
||||
extern struct simops Simops[];
|
||||
|
||||
#define PC (State.pc)
|
||||
#define SP (State.regs[3])
|
||||
#define EP (State.regs[30])
|
||||
|
||||
#define EIPC (State.sregs[0])
|
||||
#define EIPSW (State.sregs[1])
|
||||
#define FEPC (State.sregs[2])
|
||||
#define FEPSW (State.sregs[3])
|
||||
#define ECR (State.sregs[4])
|
||||
#define PSW (State.sregs[5])
|
||||
/* start-sanitize-v850e */
|
||||
#define CTPC (State.sregs[16])
|
||||
#define CTPSW (State.sregs[17])
|
||||
/* end-sanitize-v850e */
|
||||
#define DBPC (State.sregs[18])
|
||||
#define DBPSW (State.sregs[19])
|
||||
/* start-sanitize-v850e */
|
||||
#define CTBP (State.sregs[20])
|
||||
/* end-sanitize-v850e */
|
||||
|
||||
#define PSW_NP 0x80
|
||||
#define PSW_EP 0x40
|
||||
#define PSW_ID 0x20
|
||||
#define PSW_SAT 0x10
|
||||
#define PSW_CY 0x8
|
||||
#define PSW_OV 0x4
|
||||
#define PSW_S 0x2
|
||||
#define PSW_Z 0x1
|
||||
|
||||
#define SEXT3(x) ((((x)&0x7)^(~0x3))+0x4)
|
||||
|
||||
/* sign-extend a 4-bit number */
|
||||
#define SEXT4(x) ((((x)&0xf)^(~0x7))+0x8)
|
||||
|
||||
/* sign-extend a 5-bit number */
|
||||
#define SEXT5(x) ((((x)&0x1f)^(~0xf))+0x10)
|
||||
|
||||
/* sign-extend an 8-bit number */
|
||||
#define SEXT8(x) ((((x)&0xff)^(~0x7f))+0x80)
|
||||
|
||||
/* sign-extend a 9-bit number */
|
||||
#define SEXT9(x) ((((x)&0x1ff)^(~0xff))+0x100)
|
||||
|
||||
/* sign-extend a 16-bit number */
|
||||
#define SEXT16(x) ((((x)&0xffff)^(~0x7fff))+0x8000)
|
||||
|
||||
/* sign-extend a 22-bit number */
|
||||
#define SEXT22(x) ((((x)&0x3fffff)^(~0x1fffff))+0x200000)
|
||||
|
||||
/* sign-extend a 32-bit number */
|
||||
#define SEXT32(x) ((((x)&0xffffffffLL)^(~0x7fffffffLL))+0x80000000LL)
|
||||
|
||||
/* sign extend a 40 bit number */
|
||||
#define SEXT40(x) ((((x)&0xffffffffffLL)^(~0x7fffffffffLL))+0x8000000000LL)
|
||||
|
||||
/* sign extend a 44 bit number */
|
||||
#define SEXT44(x) ((((x)&0xfffffffffffLL)^(~0x7ffffffffffLL))+0x80000000000LL)
|
||||
|
||||
/* sign extend a 60 bit number */
|
||||
#define SEXT60(x) ((((x)&0xfffffffffffffffLL)^(~0x7ffffffffffffffLL))+0x800000000000000LL)
|
||||
|
||||
/* No sign extension */
|
||||
#define NOP(x) (x)
|
||||
|
||||
#define MAX32 0x7fffffffLL
|
||||
#define MIN32 0xff80000000LL
|
||||
#define MASK32 0xffffffffLL
|
||||
#define MASK40 0xffffffffffLL
|
||||
|
||||
#define INC_ADDR(x,i) x = ((State.MD && x == MOD_E) ? MOD_S : (x)+(i))
|
||||
|
||||
#define RLW(x) load_mem (x, 4)
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef SIGTRAP
|
||||
#define SIGTRAP 5
|
||||
#endif
|
||||
#ifndef SIGQUIT
|
||||
#define SIGQUIT 3
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Function declarations. */
|
||||
|
||||
uint32 get_word PARAMS ((uint8 *));
|
||||
uint16 get_half PARAMS ((uint8 *));
|
||||
uint8 get_byte PARAMS ((uint8 *));
|
||||
void put_word PARAMS ((uint8 *, uint32));
|
||||
void put_half PARAMS ((uint8 *, uint16));
|
||||
void put_byte PARAMS ((uint8 *, uint8));
|
||||
|
||||
extern uint32 load_mem PARAMS ((SIM_ADDR addr, int len));
|
||||
extern void store_mem PARAMS ((SIM_ADDR addr, int len, uint32 data));
|
||||
|
||||
extern uint8 *map PARAMS ((SIM_ADDR addr));
|
||||
|
Loading…
x
Reference in New Issue
Block a user