Add a number of per-simulator options: hostendian, endian, inline, warnings.
Rename *-n.h files to be dos compatible
This commit is contained in:
parent
35a78bd09b
commit
f2de7dfd8c
|
@ -1,3 +1,19 @@
|
|||
Fri Mar 14 19:51:21 1997 Andrew Cagney <cagney@kremvax.cygnus.com>
|
||||
|
||||
* aclocal.m4 (--enable-sim-hostendian): New option. Allow the
|
||||
host endianness to be overridden.
|
||||
(--enable-sim-endian): Allow the target platform's byte order
|
||||
to be overridden.
|
||||
(--enable-sim-inline): Control the inlining of common components.
|
||||
(--enable-sim-bswap): For compatibility, also define WITH_BSWAP.
|
||||
(--enable-sim-warnings): Enable additional GCC compiler checks.
|
||||
* Make-common.in (SIM_ENDIAN, SIM_HOSTENDIAN, SIM_INLINE,
|
||||
SIM_WARNINGS): Add.
|
||||
|
||||
* sim-n-core.h, sim-n-bits.h, sim-n-endian.h: Rename from
|
||||
sim-*-n.h so that the names are uniq on dos machines
|
||||
* sim-core.c, sim-bits.c, sim-endian.c: Update.
|
||||
|
||||
Thu Mar 13 12:32:42 1997 Doug Evans <dje@canuck.cygnus.com>
|
||||
|
||||
* run.c: #include "libiberty.h".
|
||||
|
|
|
@ -0,0 +1,214 @@
|
|||
# Makefile fragment for common parts of all simulators.
|
||||
# Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
# Contributed by Cygnus Support.
|
||||
|
||||
# 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.
|
||||
|
||||
# This Makefile fragment consists of two separate parts.
|
||||
# They are merged into the final Makefile at points denoted by
|
||||
# "## COMMON_PRE_CONFIG_FRAG" and "## COMMON_POST_CONFIG_FRAG".
|
||||
#
|
||||
# The target Makefile should look like:
|
||||
#
|
||||
#># Copyright blah blah
|
||||
#>
|
||||
#>## COMMON_PRE_CONFIG_FRAG
|
||||
#>
|
||||
#># Any overrides necessary for the SIM_FOO config vars.
|
||||
#>SIM_FOO = ...
|
||||
#>
|
||||
#>## COMMON_POST_CONFIG_FRAG
|
||||
#>
|
||||
#># Rules to build target specific .o's.
|
||||
|
||||
## COMMON_PRE_CONFIG_FRAG
|
||||
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
srcroot = $(srcdir)/../..
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
host_alias = @host_alias@
|
||||
target_alias = @target_alias@
|
||||
program_transform_name = @program_transform_name@
|
||||
bindir = @bindir@
|
||||
|
||||
libdir = @libdir@
|
||||
tooldir = $(libdir)/$(target_alias)
|
||||
|
||||
datadir = @datadir@
|
||||
mandir = @mandir@
|
||||
man1dir = $(mandir)/man1
|
||||
infodir = @infodir@
|
||||
includedir = @includedir@
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
INSTALL = $(srcroot)/install.sh -c
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_XFORM = $(INSTALL) -t='$(program_transform_name)'
|
||||
INSTALL_XFORM1= $(INSTALL_XFORM) -b=.1
|
||||
|
||||
CC = @CC@
|
||||
CC_FOR_BUILD = @CC_FOR_BUILD@
|
||||
CFLAGS = @CFLAGS@
|
||||
SIM_BSWAP = @sim_bswap@
|
||||
SIM_CFLAGS = @sim_cflags@
|
||||
SIM_DEBUG = @sim_debug@
|
||||
SIM_ENDIAN = @sim_endian@
|
||||
SIM_HOSTENDIAN = @sim_hostendian@
|
||||
SIM_INLINE = @sim_inline@
|
||||
SIM_TRACE = @sim_trace@
|
||||
SIM_WARNINGS = @sim_warnings@
|
||||
|
||||
HDEFINES = @HDEFINES@
|
||||
TDEFINES =
|
||||
|
||||
AR = @AR@
|
||||
AR_FLAGS = rc
|
||||
RANLIB = @RANLIB@
|
||||
MAKEINFO = makeinfo
|
||||
|
||||
# Each simulator's Makefile.in defines one or more of these variables
|
||||
# to override our settings as necessary.
|
||||
|
||||
# List of object files, less common parts.
|
||||
SIM_OBJS =
|
||||
# List of flags to always pass to $(CC).
|
||||
SIM_EXTRA_CFLAGS =
|
||||
# List of extra libraries to link with.
|
||||
SIM_EXTRA_LIBS =
|
||||
# List of extra program dependencies.
|
||||
SIM_EXTRA_LIBDEPS =
|
||||
# List of main object files for `run'.
|
||||
SIM_RUN_OBJS = run.o
|
||||
# Dependency of `all' to build any extra files.
|
||||
SIM_EXTRA_ALL =
|
||||
# Dependency of `install' to install any extra files.
|
||||
SIM_EXTRA_INSTALL =
|
||||
# Dependency of `clean' to clean any extra files.
|
||||
SIM_EXTRA_CLEAN =
|
||||
|
||||
## End COMMON_PRE_CONFIG_FRAG
|
||||
|
||||
## COMMON_POST_CONFIG_FRAG
|
||||
|
||||
CONFIG_CFLAGS = @DEFS@ $(SIM_CFLAGS) $(SIM_DEBUG) $(SIM_TRACE) $(SIM_BSWAP) \
|
||||
$(SIM_HOSTENDIAN) $(SIM_ENDIAN) $(SIM_INLINE) $(SIM_WARNINGS) \
|
||||
$(SIM_EXTRA_CFLAGS) $(HDEFINES) $(TDEFINES)
|
||||
CSEARCH = -I. -I$(srcdir) -I../common -I$(srcdir)/../common \
|
||||
-I../../include -I$(srcroot)/include \
|
||||
-I../../bfd -I$(srcroot)/bfd -I$(srcroot)/gdb \
|
||||
-I../../opcodes -I$(srcroot)/opcodes
|
||||
ALL_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(CFLAGS)
|
||||
BUILD_CFLAGS = -g -O $(CSEARCH)
|
||||
|
||||
LIBIBERTY_LIB = ../../libiberty/libiberty.a
|
||||
BFD_LIB = ../../bfd/libbfd.a
|
||||
OPCODES_LIB = ../../opcodes/libopcodes.a
|
||||
CONFIG_LIBS = @LIBS@
|
||||
LIBDEPS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \
|
||||
$(SIM_EXTRA_LIBDEPS)
|
||||
EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \
|
||||
$(CONFIG_LIBS) $(SIM_EXTRA_LIBS)
|
||||
|
||||
LIB_OBJS = callback.o targ-map.o $(SIM_OBJS)
|
||||
|
||||
all: libsim.a run $(SIM_EXTRA_ALL)
|
||||
|
||||
libsim.a: $(LIB_OBJS)
|
||||
rm -f libsim.a
|
||||
$(AR) $(ARFLAGS) libsim.a $(LIB_OBJS)
|
||||
$(RANLIB) libsim.a
|
||||
|
||||
run: $(SIM_RUN_OBJS) libsim.a $(LIBDEPS)
|
||||
$(CC) $(ALL_CFLAGS) -o run \
|
||||
$(SIM_RUN_OBJS) libsim.a $(EXTRA_LIBS)
|
||||
|
||||
run.o: $(srcdir)/../common/run.c config.h tconfig.h \
|
||||
$(srcroot)/include/callback.h
|
||||
$(CC) -c $(srcdir)/../common/run.c $(ALL_CFLAGS)
|
||||
|
||||
# FIXME: Ideally, callback.o and friends live in a library outside of
|
||||
# both the gdb and simulator source trees (e.g. devo/remote. Not
|
||||
# devo/libremote because this directory would contain more than just
|
||||
# a library).
|
||||
|
||||
callback.o: $(srcdir)/../common/callback.c config.h tconfig.h \
|
||||
$(srcroot)/include/callback.h targ-vals.h
|
||||
$(CC) -c $(srcdir)/../common/callback.c $(ALL_CFLAGS)
|
||||
|
||||
targ-map.o: targ-map.c targ-vals.h
|
||||
|
||||
gentmap: Makefile $(srcdir)/../common/gentmap.c targ-vals.def
|
||||
$(CC_FOR_BUILD) $(srcdir)/../common/gentmap.c -o gentmap $(BUILD_CFLAGS)
|
||||
|
||||
targ-vals.h: gentmap
|
||||
rm -f targ-vals.h
|
||||
./gentmap -h >targ-vals.h
|
||||
|
||||
targ-map.c: gentmap
|
||||
rm -f targ-map.c
|
||||
./gentmap -c >targ-map.c
|
||||
|
||||
install: install-common $(SIM_EXTRA_INSTALL)
|
||||
|
||||
install-common:
|
||||
$(INSTALL_XFORM) run $(bindir)/run
|
||||
|
||||
check:
|
||||
|
||||
info:
|
||||
clean-info:
|
||||
install-info:
|
||||
|
||||
.NOEXPORT:
|
||||
MAKEOVERRIDES=
|
||||
|
||||
tags etags: TAGS
|
||||
|
||||
TAGS: force
|
||||
etags *.c *.h
|
||||
|
||||
clean: $(SIM_EXTRA_CLEAN)
|
||||
rm -f *.[oa] *~ core
|
||||
rm -f run libsim.a
|
||||
rm -f gentmap targ-map.c targ-vals.h
|
||||
|
||||
distclean mostlyclean maintainer-clean realclean: clean
|
||||
rm -f TAGS
|
||||
rm -f Makefile config.cache config.log config.status
|
||||
rm -f tconfig.h config.h stamp-h
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(ALL_CFLAGS) $<
|
||||
|
||||
# Dummy target to force execution of dependent targets.
|
||||
force:
|
||||
|
||||
Makefile: Makefile.in $(srcdir)/../common/Make-common.in config.status
|
||||
CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
config.status: configure
|
||||
$(SHELL) ./config.status --recheck
|
||||
|
||||
config.h: stamp-h ; @true
|
||||
stamp-h: config.in config.status
|
||||
CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
|
||||
|
||||
## End COMMON_POST_CONFIG_FRAG
|
|
@ -7,9 +7,11 @@
|
|||
#
|
||||
# The simulator's configure.in should look like:
|
||||
#
|
||||
# dnl Process this file with `autoconf -l ../common' to produce a configure script.
|
||||
# dnl Process this file with autoconf to produce a configure script.
|
||||
# sinclude(../common/aclocal.m4)
|
||||
# AC_PREREQ(2.5)dnl
|
||||
# AC_INIT(Makefile.in)
|
||||
#
|
||||
# SIM_AC_COMMON
|
||||
#
|
||||
# ... target specific stuff ...
|
||||
|
@ -26,7 +28,6 @@ AC_CANONICAL_SYSTEM
|
|||
AC_ARG_PROGRAM
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
AC_C_BIGENDIAN
|
||||
|
||||
# Put a plausible default for CC_FOR_BUILD in Makefile.
|
||||
AC_C_CROSS
|
||||
|
@ -51,6 +52,22 @@ dnl Do not add any here that cannot be supported by all simulators.
|
|||
dnl Do not add similar but different options to a particular simulator,
|
||||
dnl all shall eventually behave the same way.
|
||||
|
||||
|
||||
dnl This is a generic option to enable special byte swapping
|
||||
dnl insns on *any* cpu.
|
||||
AC_ARG_ENABLE(sim-bswap,
|
||||
[ --enable-sim-bswap Use Host specific BSWAP instruction.],
|
||||
[case "${enableval}" in
|
||||
yes) sim_bswap="-DWITH_BSWAP=1 -DUSE_BSWAP";;
|
||||
no) sim_bswap="-DWITH_BSWAP=0";;
|
||||
*) AC_MSG_ERROR("--enable-sim-bswap does not take a value"); sim_bswap="";;
|
||||
esac
|
||||
if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then
|
||||
echo "Setting bswap flags = $sim_bswap" 6>&1
|
||||
fi],[sim_bswap=""])dnl
|
||||
AC_SUBST(sim_bswap)
|
||||
|
||||
|
||||
AC_ARG_ENABLE(sim-cflags,
|
||||
[ --enable-sim-cflags=opts Extra CFLAGS for use in building simulator],
|
||||
[case "${enableval}" in
|
||||
|
@ -64,6 +81,7 @@ if test x"$silent" != x"yes" && test x"$sim_cflags" != x""; then
|
|||
fi],[sim_cflags=""])dnl
|
||||
AC_SUBST(sim_cflags)
|
||||
|
||||
|
||||
dnl --enable-sim-debug is for developers of the simulator
|
||||
dnl the allowable values are work-in-progress
|
||||
AC_ARG_ENABLE(sim-debug,
|
||||
|
@ -78,6 +96,7 @@ if test x"$silent" != x"yes" && test x"$sim_debug" != x""; then
|
|||
fi],[sim_debug=""])dnl
|
||||
AC_SUBST(sim_debug)
|
||||
|
||||
|
||||
dnl --enable-sim-trace is for users of the simulator
|
||||
dnl the allowable values are work-in-progress
|
||||
AC_ARG_ENABLE(sim-trace,
|
||||
|
@ -92,19 +111,6 @@ if test x"$silent" != x"yes" && test x"$sim_trace" != x""; then
|
|||
fi],[sim_trace=""])dnl
|
||||
AC_SUBST(sim_trace)
|
||||
|
||||
dnl This is a generic option to enable special byte swapping
|
||||
dnl insns on *any* cpu.
|
||||
AC_ARG_ENABLE(sim-bswap,
|
||||
[ --enable-sim-bswap Use Host specific BSWAP instruction.],
|
||||
[case "${enableval}" in
|
||||
yes) sim_bswap="-DUSE_BSWAP";;
|
||||
no) sim_bswap="";;
|
||||
*) AC_MSG_ERROR("--enable-sim-bswap does not take a value"); sim_bswap="";;
|
||||
esac
|
||||
if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then
|
||||
echo "Setting bswap flags = $sim_bswap" 6>&1
|
||||
fi],[sim_bswap=""])dnl
|
||||
AC_SUBST(sim_bswap)
|
||||
|
||||
dnl These are available to append to as desired.
|
||||
sim_link_files=
|
||||
|
@ -120,203 +126,161 @@ else
|
|||
sim_link_files=../common/tconfig.in
|
||||
fi
|
||||
|
||||
# targ-vals.def points to the libc macro description file.
|
||||
case "${target}" in
|
||||
*-*-*)
|
||||
sim_link_files="${sim_link_files} ../common/nltvals.def"
|
||||
sim_link_links="${sim_link_links} targ-vals.def"
|
||||
;;
|
||||
*-*-*) TARG_VALS_DEF=../common/nltvals.def ;;
|
||||
esac
|
||||
sim_link_files="${sim_link_files} ${TARG_VALS_DEF}"
|
||||
sim_link_links="${sim_link_links} targ-vals.def"
|
||||
|
||||
]) dnl End of SIM_AC_COMMON
|
||||
|
||||
|
||||
dnl Almost standard simulator options.
|
||||
dnl Eventually all simulators will support these.
|
||||
|
||||
|
||||
dnl --enable-sim-endian={yes,no,big,little} is for simulators
|
||||
dnl that support both big and little endian targets.
|
||||
AC_DEFUN(SIM_AC_OPTION_ENDIAN,
|
||||
[
|
||||
default_sim_endian="ifelse([$1],,,-DWITH_TARGET_BYTE_ORDER=[$1])"
|
||||
AC_ARG_ENABLE(sim-endian,
|
||||
[ --enable-sim-endian=endian Specify target byte endian orientation.],
|
||||
[case "${enableval}" in
|
||||
yes) case "$target" in
|
||||
*powerpc-*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
|
||||
*powerpcle-*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
|
||||
*) echo "Unknown target $target" 1>&6; sim_endian="-DWITH_TARGET_BYTE_ORDER=0";;
|
||||
esac;;
|
||||
no) sim_endian="-DWITH_TARGET_BYTE_ORDER=0";;
|
||||
b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
|
||||
l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
|
||||
*) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";;
|
||||
esac
|
||||
if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
|
||||
echo "Setting endian flags = $sim_endian" 6>&1
|
||||
fi],[sim_endian="${default_sim_endian}"])dnl
|
||||
])
|
||||
|
||||
|
||||
dnl --enable-sim-hostendian is for users of the simulator when
|
||||
dnl they find that AC_C_BIGENDIAN does not function correctly
|
||||
dnl (for instance in a canadian cross)
|
||||
AC_DEFUN(SIM_AC_OPTION_HOSTENDIAN,
|
||||
[
|
||||
AC_ARG_ENABLE(sim-hostendian,
|
||||
[ --enable-sim-hostendain=end Specify host byte endian orientation.],
|
||||
[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";;
|
||||
*) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-hostendian"); sim_hostendian="";;
|
||||
esac
|
||||
if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then
|
||||
echo "Setting hostendian flags = $sim_hostendian" 6>&1
|
||||
fi],[
|
||||
if test "x$cross_compiling" = "xno"; then
|
||||
AC_C_BIGENDIAN
|
||||
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])dnl
|
||||
])
|
||||
|
||||
|
||||
dnl --enable-sim-inline is for users that wish to ramp up the simulator's
|
||||
dnl performance by inlining functions.
|
||||
AC_DEFUN(SIM_AC_OPTION_INLINE,
|
||||
[
|
||||
default_sim_inline="ifelse([$1],,,-DDEFAULT_INLINE=[$1])"
|
||||
AC_ARG_ENABLE(sim-inline,
|
||||
[ --enable-sim-inline=inlines Specify which functions should be inlined.],
|
||||
[sim_inline=""
|
||||
case "$enableval" in
|
||||
no) sim_inline="-DDEFAULT_INLINE=0";;
|
||||
0) sim_inline="-DDEFAULT_INLINE=0";;
|
||||
yes | 2) sim_inline="-DDEFAULT_INLINE=ALL_INLINE";;
|
||||
1) sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";;
|
||||
*) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
|
||||
new_flag=""
|
||||
case "$x" in
|
||||
*_INLINE=*) new_flag="-D$x";;
|
||||
*=*) new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;;
|
||||
*_INLINE) new_flag="-D$x=ALL_INLINE";;
|
||||
*) new_flag="-D$x""_INLINE=ALL_INLINE";;
|
||||
esac
|
||||
if test x"$sim_inline" = x""; then
|
||||
sim_inline="$new_flag"
|
||||
else
|
||||
sim_inline="$sim_inline $new_flag"
|
||||
fi
|
||||
done;;
|
||||
esac
|
||||
if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
|
||||
echo "Setting inline flags = $sim_inline" 6>&1
|
||||
fi],[if test x"$GCC" != "x" -a x"${default_sim_inline}" != "x" ; then
|
||||
sim_inline="${default_sim_inline}"
|
||||
if test x"$silent" != x"yes"; then
|
||||
echo "Setting inline flags = $sim_inline" 6>&1
|
||||
fi
|
||||
else
|
||||
sim_inline=""
|
||||
fi])dnl
|
||||
])
|
||||
|
||||
|
||||
dnl --enable-sim-warnings is for developers of the simulator.
|
||||
dnl it enables extra GCC specific warnings.
|
||||
AC_DEFUN(SIM_AC_OPTION_WARNINGS,
|
||||
[
|
||||
AC_ARG_ENABLE(sim-warnings,
|
||||
[ --enable-sim-warnings=opts Extra CFLAGS for turning on compiler warnings except for idecode.o, semantics.o and psim.o],
|
||||
[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],[sim_warnings=""])dnl
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
||||
dnl Generate the Makefile in a target specific directory.
|
||||
dnl Substitutions aren't performed on the file in AC_SUBST_FILE,
|
||||
dnl so this is a cover macro to tuck the details away of how we cope.
|
||||
dnl It also inserts default definitions of the SIM_FOO variables.
|
||||
dnl We cope by having autoconf generate two files and then merge them into
|
||||
dnl one afterwards. The two pieces of the common fragment are inserted into
|
||||
dnl the target's fragment at the appropriate points.
|
||||
|
||||
AC_DEFUN(SIM_AC_OUTPUT,
|
||||
[
|
||||
|
||||
dnl Stuff that gets inserted into the Makefile.
|
||||
dnl This is done now and not in SIM_AC_COMMON to catch updated values for
|
||||
dnl LIBS, etc. that may get changed by target specific checks.
|
||||
|
||||
COMMON_MAKEFILE_FRAG=makefile-temp-$$
|
||||
cat > $COMMON_MAKEFILE_FRAG <<EOF
|
||||
VPATH = ${srcdir}
|
||||
srcdir = ${srcdir}
|
||||
srcroot = \$(srcdir)/../..
|
||||
|
||||
prefix = ${prefix}
|
||||
exec_prefix = ${exec_prefix}
|
||||
|
||||
host_alias = ${host_alias}
|
||||
target_alias = ${target_alias}
|
||||
program_transform_name = ${program_transform_name}
|
||||
bindir = ${bindir}
|
||||
|
||||
libdir = ${libdir}
|
||||
tooldir = \$(libdir)/\$(target_alias)
|
||||
|
||||
datadir = ${datadir}
|
||||
mandir = ${mandir}
|
||||
man1dir = \$(mandir)/man1
|
||||
infodir = ${infodir}
|
||||
includedir = ${includedir}
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
INSTALL = \$(srcroot)/install.sh -c
|
||||
INSTALL_PROGRAM = ${INSTALL_PROGRAM}
|
||||
INSTALL_DATA = ${INSTALL_DATA}
|
||||
INSTALL_XFORM = \$(INSTALL) -t='\$(program_transform_name)'
|
||||
INSTALL_XFORM1= \$(INSTALL_XFORM) -b=.1
|
||||
|
||||
CC = ${CC}
|
||||
CC_FOR_BUILD = ${CC_FOR_BUILD}
|
||||
CFLAGS = ${CFLAGS}
|
||||
SIM_CFLAGS = ${sim_cflags}
|
||||
SIM_DEBUG = ${sim_debug}
|
||||
SIM_TRACE = ${sim_trace}
|
||||
SIM_BSWAP = ${sim_bswap}
|
||||
|
||||
HDEFINES = ${HDEFINES}
|
||||
TDEFINES =
|
||||
|
||||
AR = ${AR}
|
||||
AR_FLAGS = rc
|
||||
RANLIB = ${RANLIB}
|
||||
MAKEINFO = makeinfo
|
||||
|
||||
# Each simulator's Makefile.in defines one or more of these variables
|
||||
# as necessary. The SIM_AC_OUTPUT macro then inserts those values
|
||||
# at '## Config'.
|
||||
|
||||
# List of object files, less common parts.
|
||||
#SIM_OBJS =
|
||||
# List of flags to always pass to \$(CC).
|
||||
#SIM_EXTRA_CFLAGS =
|
||||
# List of extra libraries to link with.
|
||||
#SIM_EXTRA_LIBS =
|
||||
# List of extra program dependencies.
|
||||
#SIM_EXTRA_LIBDEPS =
|
||||
# Dependency of 'all' to build any extra files.
|
||||
#SIM_EXTRA_ALL =
|
||||
# Dependency of 'install' to install any extra files.
|
||||
#SIM_EXTRA_INSTALL =
|
||||
# Dependency of 'clean' to clean any extra files.
|
||||
#SIM_EXTRA_CLEAN =
|
||||
|
||||
CONFIG_CFLAGS = ${DEFS} \$(SIM_CFLAGS) \$(SIM_DEBUG) \$(SIM_TRACE) \$(SIM_BSWAP) \
|
||||
\$(SIM_EXTRA_CFLAGS) \$(HDEFINES) \$(TDEFINES)
|
||||
CSEARCH = -I. -I\$(srcdir) -I../common -I\$(srcdir)/../common \
|
||||
-I../../include -I\$(srcroot)/include \
|
||||
-I../../bfd -I\$(srcroot)/bfd -I\$(srcroot)/gdb \
|
||||
-I../../opcodes -I\$(srcroot)/opcodes
|
||||
ALL_CFLAGS = \$(CONFIG_CFLAGS) \$(CSEARCH) \$(CFLAGS)
|
||||
BUILD_CFLAGS = -g -O \$(CSEARCH)
|
||||
|
||||
.NOEXPORT:
|
||||
MAKEOVERRIDES=
|
||||
|
||||
LIBIBERTY_LIB = ../../libiberty/libiberty.a
|
||||
BFD_LIB = ../../bfd/libbfd.a
|
||||
OPCODES_LIB = ../../opcodes/libopcodes.a
|
||||
CONFIG_LIBS = ${LIBS}
|
||||
LIBDEPS = \$(BFD_LIB) \$(OPCODES_LIB) \$(LIBIBERTY_LIB) \
|
||||
\$(SIM_EXTRA_LIBDEPS)
|
||||
EXTRA_LIBS = \$(BFD_LIB) \$(OPCODES_LIB) \$(LIBIBERTY_LIB) \
|
||||
\$(CONFIG_LIBS) \$(SIM_EXTRA_LIBS)
|
||||
|
||||
LIB_OBJS = callback.o targ-map.o \$(SIM_OBJS)
|
||||
|
||||
all: run libsim.a \$(SIM_EXTRA_ALL)
|
||||
|
||||
libsim.a: \$(LIB_OBJS)
|
||||
rm -f libsim.a
|
||||
\$(AR) \$(ARFLAGS) libsim.a \$(LIB_OBJS)
|
||||
\$(RANLIB) libsim.a
|
||||
|
||||
run: run.o libsim.a \$(LIBDEPS)
|
||||
\$(CC) \$(ALL_CFLAGS) -o run \
|
||||
run.o libsim.a \$(EXTRA_LIBS)
|
||||
|
||||
run.o: \$(srcdir)/../common/run.c config.h tconfig.h \
|
||||
\$(srcroot)/include/callback.h
|
||||
\$(CC) -c \$(srcdir)/../common/run.c \$(ALL_CFLAGS)
|
||||
|
||||
callback.o: \$(srcdir)/../common/callback.c config.h tconfig.h \
|
||||
\$(srcroot)/include/callback.h targ-vals.h
|
||||
\$(CC) -c \$(srcdir)/../common/callback.c \$(ALL_CFLAGS)
|
||||
|
||||
gentmap: \$(srcdir)/../common/gentmap.c targ-vals.def
|
||||
\$(CC_FOR_BUILD) \$(srcdir)/../common/gentmap.c -o gentmap \$(BUILD_CFLAGS) -I\$(srcdir)/../common
|
||||
|
||||
targ-vals.h: gentmap
|
||||
rm -f targ-vals.h
|
||||
./gentmap -h >targ-vals.h
|
||||
|
||||
targ-map.c: gentmap
|
||||
rm -f targ-map.c
|
||||
./gentmap -c >targ-map.c
|
||||
|
||||
install: install-common \$(SIM_EXTRA_INSTALL)
|
||||
|
||||
install-common:
|
||||
\$(INSTALL_XFORM) run \$(bindir)/run
|
||||
|
||||
check:
|
||||
|
||||
info:
|
||||
clean-info:
|
||||
install-info:
|
||||
|
||||
tags etags: TAGS
|
||||
|
||||
TAGS: force
|
||||
etags *.c *.h
|
||||
|
||||
clean: \$(SIM_EXTRA_CLEAN)
|
||||
rm -f *.[[oa]] *~ core gentmap targ-map.c targ-vals.h
|
||||
rm -f run libsim.a
|
||||
|
||||
distclean mostlyclean maintainer-clean realclean: clean
|
||||
rm -f TAGS
|
||||
rm -f Makefile config.cache config.log config.status
|
||||
rm -f tconfig.h config.h stamp-h targ-vals.def
|
||||
|
||||
.c.o:
|
||||
\$(CC) -c \$(ALL_CFLAGS) \$<
|
||||
|
||||
# Dummy target to force execution of dependent targets.
|
||||
force:
|
||||
|
||||
Makefile: Makefile.in config.status
|
||||
CONFIG_HEADERS= \$(SHELL) ./config.status
|
||||
|
||||
config.status: configure
|
||||
\$(SHELL) ./config.status --recheck
|
||||
|
||||
config.h: stamp-h ; @true
|
||||
stamp-h: config.in config.status
|
||||
CONFIG_FILES= CONFIG_HEADERS=config.h:config.in \$(SHELL) ./config.status
|
||||
|
||||
# We can't add dependencies to configure because it causes too much trouble
|
||||
# to end users if configure's timestamp is out of sync.
|
||||
.PHONY: run-autoconf
|
||||
run-autoconf:
|
||||
cd \$(srcdir) && autoconf -l ../common
|
||||
EOF
|
||||
|
||||
dnl end of COMMON_MAKEFILE_FRAG
|
||||
|
||||
AC_SUBST_FILE(COMMON_MAKEFILE_FRAG)
|
||||
|
||||
dnl Optional options
|
||||
AC_SUBST(sim_endian)
|
||||
AC_SUBST(sim_hostendian)
|
||||
AC_SUBST(sim_inline)
|
||||
AC_SUBST(sim_warnings)
|
||||
dnl
|
||||
AC_LINK_FILES($sim_link_files, $sim_link_links)
|
||||
AC_OUTPUT(Makefile,[
|
||||
AC_OUTPUT(Makefile.sim:Makefile.in Make-common.sim:../common/Make-common.in,
|
||||
[case "x$CONFIG_FILES" in xMakefile*)
|
||||
echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
|
||||
rm -f Makesim1.tmp Makesim2.tmp Makefile
|
||||
sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
|
||||
sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
|
||||
sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
|
||||
-e '/^## COMMON_POST_/ r Makesim2.tmp' \
|
||||
<Makefile.sim >Makefile
|
||||
rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
|
||||
;;
|
||||
esac
|
||||
case "x$CONFIG_HEADERS" in xconfig.h:config.in) echo > stamp-h ;; esac
|
||||
])
|
||||
|
||||
rm $COMMON_MAKEFILE_FRAG
|
||||
|
||||
])dnl End of SIM_AC_OUTPUT
|
||||
])
|
||||
])
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,105 @@
|
|||
/* This file is part of the program psim.
|
||||
|
||||
Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SIM_BITS_C_
|
||||
#define _SIM_BITS_C_
|
||||
|
||||
#include "sim-basics.h"
|
||||
|
||||
|
||||
INLINE_SIM_BITS\
|
||||
(unsigned_word)
|
||||
MASKED(unsigned_word val,
|
||||
unsigned start,
|
||||
unsigned stop)
|
||||
{
|
||||
return ((val) & MASK(start, stop));
|
||||
}
|
||||
|
||||
|
||||
|
||||
INLINE_SIM_BITS\
|
||||
(unsigned_word)
|
||||
LSMASKED(unsigned_word val,
|
||||
unsigned nr_bits)
|
||||
{
|
||||
return MASKED(val,
|
||||
WITH_TARGET_WORD_BITSIZE - nr_bits,
|
||||
WITH_TARGET_WORD_BITSIZE - 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
INLINE_SIM_BITS\
|
||||
(unsigned_word)
|
||||
EXTRACTED(unsigned_word val,
|
||||
unsigned start,
|
||||
unsigned stop)
|
||||
{
|
||||
ASSERT(start <= stop);
|
||||
#if (WITH_TARGET_WORD_BITSIZE == 64)
|
||||
return EXTRACTED64(val, start, stop);
|
||||
#endif
|
||||
#if (WITH_TARGET_WORD_BITSIZE == 32)
|
||||
if (stop < 32)
|
||||
return 0;
|
||||
else
|
||||
return ((val >> (63 - stop))
|
||||
& MASK(start+(63-stop), 63));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
INLINE_SIM_BITS\
|
||||
(unsigned_word)
|
||||
INSERTED(unsigned_word val,
|
||||
unsigned start,
|
||||
unsigned stop)
|
||||
{
|
||||
ASSERT(start <= stop);
|
||||
#if (WITH_TARGET_WORD_BITSIZE == 64)
|
||||
return INSERTED64(val, start, stop);
|
||||
#endif
|
||||
#if (WITH_TARGET_WORD_BITSIZE == 32)
|
||||
if (stop < 32)
|
||||
return 0;
|
||||
else
|
||||
return ((val & MASK(start+(63-stop), 63))
|
||||
<< (63 - stop));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define N 16
|
||||
#include "sim-n-bits.h"
|
||||
#undef N
|
||||
|
||||
#define N 32
|
||||
#include "sim-n-bits.h"
|
||||
#undef N
|
||||
|
||||
#define N 64
|
||||
#include "sim-n-bits.h"
|
||||
#undef N
|
||||
|
||||
#endif /* _SIM_BITS_C_ */
|
|
@ -0,0 +1,375 @@
|
|||
/* This file is part of the program psim.
|
||||
|
||||
Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SIM_CORE_C_
|
||||
#define _SIM_CORE_C_
|
||||
|
||||
#include "engine.h"
|
||||
|
||||
|
||||
INLINE_SIM_CORE\
|
||||
(void)
|
||||
core_init(engine *system)
|
||||
{
|
||||
core *memory = &system->memory;
|
||||
core_maps map;
|
||||
for (map = 0;
|
||||
map < nr_core_maps;
|
||||
map++) {
|
||||
/* blow away old mappings */
|
||||
core_mapping *curr = memory->map[map].first;
|
||||
while (curr != NULL) {
|
||||
core_mapping *tbd = curr;
|
||||
curr = curr->next;
|
||||
if (tbd->free_buffer) {
|
||||
ASSERT(tbd->buffer != NULL);
|
||||
zfree(tbd->buffer);
|
||||
}
|
||||
zfree(tbd);
|
||||
}
|
||||
memory->map[map].first = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
STATIC_INLINE_SIM_CORE\
|
||||
(core_mapping *)
|
||||
new_core_mapping(engine *system,
|
||||
attach_type attach,
|
||||
int space,
|
||||
unsigned_word addr,
|
||||
unsigned nr_bytes,
|
||||
device *device,
|
||||
void *buffer,
|
||||
int free_buffer)
|
||||
{
|
||||
core_mapping *new_mapping = ZALLOC(core_mapping);
|
||||
/* common */
|
||||
new_mapping->level = attach;
|
||||
new_mapping->space = space;
|
||||
new_mapping->base = addr;
|
||||
new_mapping->nr_bytes = nr_bytes;
|
||||
new_mapping->bound = addr + (nr_bytes - 1);
|
||||
if (attach == attach_raw_memory) {
|
||||
new_mapping->buffer = buffer;
|
||||
new_mapping->free_buffer = free_buffer;
|
||||
}
|
||||
else if (attach >= attach_callback) {
|
||||
new_mapping->device = device;
|
||||
}
|
||||
else {
|
||||
engine_error(system, "new_core_mapping - internal error - unknown attach type %d\n",
|
||||
attach);
|
||||
}
|
||||
return new_mapping;
|
||||
}
|
||||
|
||||
|
||||
STATIC_INLINE_SIM_CORE\
|
||||
(void)
|
||||
core_map_attach(engine *system,
|
||||
core_map *access_map,
|
||||
attach_type attach,
|
||||
int space,
|
||||
unsigned_word addr,
|
||||
unsigned nr_bytes, /* host limited */
|
||||
device *client, /*callback/default*/
|
||||
void *buffer, /*raw_memory*/
|
||||
int free_buffer) /*raw_memory*/
|
||||
{
|
||||
/* find the insertion point for this additional mapping and then
|
||||
insert */
|
||||
core_mapping *next_mapping;
|
||||
core_mapping **last_mapping;
|
||||
|
||||
ASSERT((attach >= attach_callback && client != NULL && buffer == NULL && !free_buffer)
|
||||
|| (attach == attach_raw_memory && client == NULL && buffer != NULL));
|
||||
|
||||
/* actually do occasionally get a zero size map */
|
||||
if (nr_bytes == 0) {
|
||||
#if (WITH_DEVICES)
|
||||
device_error(client, "called on core_map_attach with size zero");
|
||||
#else
|
||||
engine_error(system, "called on core_map_attach with size zero");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* find the insertion point (between last/next) */
|
||||
next_mapping = access_map->first;
|
||||
last_mapping = &access_map->first;
|
||||
while(next_mapping != NULL
|
||||
&& (next_mapping->level < attach
|
||||
|| (next_mapping->level == attach
|
||||
&& next_mapping->bound < addr))) {
|
||||
/* provided levels are the same */
|
||||
/* assert: next_mapping->base > all bases before next_mapping */
|
||||
/* assert: next_mapping->bound >= all bounds before next_mapping */
|
||||
last_mapping = &next_mapping->next;
|
||||
next_mapping = next_mapping->next;
|
||||
}
|
||||
|
||||
/* check insertion point correct */
|
||||
ASSERT(next_mapping == NULL || next_mapping->level >= attach);
|
||||
if (next_mapping != NULL && next_mapping->level == attach
|
||||
&& next_mapping->base < (addr + (nr_bytes - 1))) {
|
||||
#if (WITH_DEVICES)
|
||||
device_error(client, "map overlap when attaching %d:0x%lx (%ld)",
|
||||
space, (long)addr, (long)nr_bytes);
|
||||
#else
|
||||
engine_error(system, "map overlap when attaching %d:0x%lx (%ld)",
|
||||
space, (long)addr, (long)nr_bytes);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* create/insert the new mapping */
|
||||
*last_mapping = new_core_mapping(system,
|
||||
attach,
|
||||
space, addr, nr_bytes,
|
||||
client, buffer, free_buffer);
|
||||
(*last_mapping)->next = next_mapping;
|
||||
}
|
||||
|
||||
|
||||
INLINE_SIM_CORE\
|
||||
(void)
|
||||
core_attach(engine *system,
|
||||
attach_type attach,
|
||||
access_type access,
|
||||
int space,
|
||||
unsigned_word addr,
|
||||
unsigned nr_bytes, /* host limited */
|
||||
device *client,
|
||||
void *optional_buffer)
|
||||
{
|
||||
core *memory = &system->memory;
|
||||
core_maps map;
|
||||
void *buffer;
|
||||
int buffer_freed;
|
||||
if ((access & access_read_write_exec) == 0
|
||||
|| (access & ~access_read_write_exec) != 0) {
|
||||
#if (WITH_DEVICES)
|
||||
device_error(client, "invalid access for core attach");
|
||||
#else
|
||||
engine_error(system, "invalid access for core attach");
|
||||
#endif
|
||||
}
|
||||
/* verify the attach type */
|
||||
if (attach == attach_raw_memory) {
|
||||
if (optional_buffer == NULL) {
|
||||
buffer = zalloc(nr_bytes);
|
||||
buffer_freed = 0;
|
||||
}
|
||||
else {
|
||||
buffer = optional_buffer;
|
||||
buffer_freed = 1;
|
||||
}
|
||||
}
|
||||
else if (attach >= attach_callback) {
|
||||
buffer = NULL;
|
||||
buffer_freed = 1;
|
||||
}
|
||||
else {
|
||||
#if (WITH_DEVICES)
|
||||
device_error(client, "core_attach - conflicting buffer and attach arguments");
|
||||
#else
|
||||
engine_error(system, "core_attach - conflicting buffer and attach arguments");
|
||||
#endif
|
||||
buffer = NULL;
|
||||
buffer_freed = 1;
|
||||
}
|
||||
/* attach the region to all applicable access maps */
|
||||
for (map = 0;
|
||||
map < nr_core_maps;
|
||||
map++) {
|
||||
switch (map) {
|
||||
case core_read_map:
|
||||
if (access & access_read)
|
||||
core_map_attach(system, &memory->map[map],
|
||||
attach,
|
||||
space, addr, nr_bytes,
|
||||
client, buffer, !buffer_freed);
|
||||
buffer_freed ++;
|
||||
break;
|
||||
case core_write_map:
|
||||
if (access & access_write)
|
||||
core_map_attach(system, &memory->map[map],
|
||||
attach,
|
||||
space, addr, nr_bytes,
|
||||
client, buffer, !buffer_freed);
|
||||
buffer_freed ++;
|
||||
break;
|
||||
case core_execute_map:
|
||||
if (access & access_exec)
|
||||
core_map_attach(system, &memory->map[map],
|
||||
attach,
|
||||
space, addr, nr_bytes,
|
||||
client, buffer, !buffer_freed);
|
||||
buffer_freed ++;
|
||||
break;
|
||||
case nr_core_maps:
|
||||
engine_error(system, "core_attach - internal error - bad switch");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
STATIC_INLINE_SIM_CORE\
|
||||
(core_mapping *)
|
||||
core_map_find_mapping(engine *system,
|
||||
core_maps map,
|
||||
unsigned_word addr,
|
||||
unsigned nr_bytes,
|
||||
int abort) /*either 0 or 1 - helps inline */
|
||||
{
|
||||
core_mapping *mapping = system->memory.map[map].first;
|
||||
ASSERT((addr & (nr_bytes - 1)) == 0); /* must be aligned */
|
||||
ASSERT((addr + (nr_bytes - 1)) >= addr); /* must not wrap */
|
||||
while (mapping != NULL) {
|
||||
if (addr >= mapping->base
|
||||
&& (addr + (nr_bytes - 1)) <= mapping->bound)
|
||||
return mapping;
|
||||
mapping = mapping->next;
|
||||
}
|
||||
if (abort)
|
||||
engine_error(system, "access to unmaped address 0x%x (%d bytes)\n",
|
||||
addr, nr_bytes);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
STATIC_INLINE_SIM_CORE\
|
||||
(void *)
|
||||
core_translate(core_mapping *mapping,
|
||||
unsigned_word addr)
|
||||
{
|
||||
return (void *)(((char *)mapping->buffer) + addr - mapping->base);
|
||||
}
|
||||
|
||||
|
||||
INLINE_SIM_CORE\
|
||||
(unsigned)
|
||||
core_map_read_buffer(engine *system,
|
||||
core_maps map,
|
||||
void *buffer,
|
||||
unsigned_word addr,
|
||||
unsigned len)
|
||||
{
|
||||
unsigned count = 0;
|
||||
while (count < len) {
|
||||
unsigned_word raddr = addr + count;
|
||||
core_mapping *mapping =
|
||||
core_map_find_mapping(system, map,
|
||||
raddr, 1,
|
||||
0); /*dont-abort*/
|
||||
if (mapping == NULL)
|
||||
break;
|
||||
#if (WITH_DEVICES)
|
||||
if (mapping->device != NULL) {
|
||||
int nr_bytes = len - count;
|
||||
if (raddr + nr_bytes - 1> mapping->bound)
|
||||
nr_bytes = mapping->bound - raddr + 1;
|
||||
if (device_io_read_buffer(mapping->device,
|
||||
(unsigned_1*)buffer + count,
|
||||
mapping->space,
|
||||
raddr,
|
||||
nr_bytes) != nr_bytes)
|
||||
break;
|
||||
count += nr_bytes;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
((unsigned_1*)buffer)[count] =
|
||||
*(unsigned_1*)core_translate(mapping, raddr);
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
INLINE_SIM_CORE\
|
||||
(unsigned)
|
||||
core_map_write_buffer(engine *system,
|
||||
core_maps map,
|
||||
const void *buffer,
|
||||
unsigned_word addr,
|
||||
unsigned len)
|
||||
{
|
||||
unsigned count = 0;
|
||||
while (count < len) {
|
||||
unsigned_word raddr = addr + count;
|
||||
core_mapping *mapping = core_map_find_mapping(system, map,
|
||||
raddr, 1,
|
||||
0); /*dont-abort*/
|
||||
if (mapping == NULL)
|
||||
break;
|
||||
#if (WITH_DEVICES)
|
||||
if (WITH_CALLBACK_MEMORY
|
||||
&& mapping->device != NULL) {
|
||||
int nr_bytes = len - count;
|
||||
if (raddr + nr_bytes - 1 > mapping->bound)
|
||||
nr_bytes = mapping->bound - raddr + 1;
|
||||
if (device_io_write_buffer(mapping->device,
|
||||
(unsigned_1*)buffer + count,
|
||||
mapping->space,
|
||||
raddr,
|
||||
nr_bytes) != nr_bytes)
|
||||
break;
|
||||
count += nr_bytes;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
*(unsigned_1*)core_translate(mapping, raddr) =
|
||||
((unsigned_1*)buffer)[count];
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/* define the read/write 1/2/4/8/word functions */
|
||||
|
||||
#define N 1
|
||||
#include "sim-n-core.h"
|
||||
#undef N
|
||||
|
||||
#define N 2
|
||||
#include "sim-n-core.h"
|
||||
#undef N
|
||||
|
||||
#define N 4
|
||||
#include "sim-n-core.h"
|
||||
#undef N
|
||||
|
||||
#define N 8
|
||||
#include "sim-n-core.h"
|
||||
#undef N
|
||||
|
||||
#define N word
|
||||
#include "sim-n-core.h"
|
||||
#undef N
|
||||
|
||||
#endif
|
|
@ -0,0 +1,74 @@
|
|||
/* This file is part of the program psim.
|
||||
|
||||
Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SIM_ENDIAN_C_
|
||||
#define _SIM_ENDIAN_C_
|
||||
|
||||
#include "sim-basics.h"
|
||||
|
||||
|
||||
#if !defined(_SWAP_1)
|
||||
#define _SWAP_1(SET,RAW) SET (RAW)
|
||||
#endif
|
||||
|
||||
#if !defined(_SWAP_2) && (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN) && defined(htons)
|
||||
#define _SWAP_2(SET,RAW) SET htons (RAW)
|
||||
#endif
|
||||
|
||||
#ifndef _SWAP_2
|
||||
#define _SWAP_2(SET,RAW) SET (((RAW) >> 8) | ((RAW) << 8))
|
||||
#endif
|
||||
|
||||
#if !defined(_SWAP_4) && (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN) && defined(htonl)
|
||||
#define _SWAP_4(SET,RAW) SET htonl (RAW)
|
||||
#endif
|
||||
|
||||
#ifndef _SWAP_4
|
||||
#define _SWAP_4(SET,RAW) SET (((RAW) << 24) | (((RAW) & 0xff00) << 8) | (((RAW) & 0xff0000) >> 8) | ((RAW) >> 24))
|
||||
#endif
|
||||
|
||||
#ifndef _SWAP_8
|
||||
#define _SWAP_8(SET,RAW) \
|
||||
union { unsigned_8 dword; unsigned_4 words[2]; } in, out; \
|
||||
in.dword = RAW; \
|
||||
_SWAP_4 (out.words[0] =, in.words[1]); \
|
||||
_SWAP_4 (out.words[1] =, in.words[0]); \
|
||||
SET out.dword;
|
||||
#endif
|
||||
|
||||
|
||||
#define N 1
|
||||
#include "sim-n-endian.h"
|
||||
#undef N
|
||||
|
||||
#define N 2
|
||||
#include "sim-n-endian.h"
|
||||
#undef N
|
||||
|
||||
#define N 4
|
||||
#include "sim-n-endian.h"
|
||||
#undef N
|
||||
|
||||
#define N 8
|
||||
#include "sim-n-endian.h"
|
||||
#undef N
|
||||
|
||||
#endif /* _SIM_ENDIAN_C_ */
|
Loading…
Reference in New Issue